/* Obsidian LanguageTool v1.4.4 */ var o6=Object.create;var{getPrototypeOf:t6,defineProperty:F0,getOwnPropertyNames:Q2,getOwnPropertyDescriptor:e6}=Object,X2=Object.prototype.hasOwnProperty;function G2(Y){return this[Y]}var Y7,Z7,K2=(Y,Z,Q)=>{var X=Y!=null&&typeof Y==="object";if(X){var G=Z?Y7??=new WeakMap:Z7??=new WeakMap,$=G.get(Y);if($)return $}Q=Y!=null?o6(t6(Y)):{};let K=Z||!Y||!Y.__esModule?F0(Q,"default",{value:Y,enumerable:!0}):Q;for(let V of Q2(Y))if(!X2.call(K,V))F0(K,V,{get:G2.bind(Y,V),enumerable:!0});if(X)G.set(Y,K);return K},Q7=(Y)=>{var Z=(Z2??=new WeakMap).get(Y),Q;if(Z)return Z;if(Z=F0({},"__esModule",{value:!0}),Y&&typeof Y==="object"||typeof Y==="function"){for(var X of Q2(Y))if(!X2.call(Z,X))F0(Z,X,{get:G2.bind(Y,X),enumerable:!(Q=e6(Y,X))||Q.enumerable})}return Z2.set(Y,Z),Z},Z2,C0=(Y,Z)=>()=>(Z||Y((Z={exports:{}}).exports,Z),Z.exports);var X7=(Y)=>Y;function G7(Y,Z){this[Y]=X7.bind(null,Z)}var $2=(Y,Z)=>{for(var Q in Z)F0(Y,Q,{get:Z[Q],enumerable:!0,configurable:!0,set:G7.bind(Z,Q)})};var Q6=C0(($X,Z6)=>{var G0=1000,K0=G0*60,$0=K0*60,f1=$0*24,m4=f1*7,u4=f1*365.25;Z6.exports=function(Y,Z){Z=Z||{};var Q=typeof Y;if(Q==="string"&&Y.length>0)return p4(Y);else if(Q==="number"&&isFinite(Y))return Z.long?f4(Y):l4(Y);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(Y))};function p4(Y){if(Y=String(Y),Y.length>100)return;var Z=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(Y);if(!Z)return;var Q=parseFloat(Z[1]),X=(Z[2]||"ms").toLowerCase();switch(X){case"years":case"year":case"yrs":case"yr":case"y":return Q*u4;case"weeks":case"week":case"w":return Q*m4;case"days":case"day":case"d":return Q*f1;case"hours":case"hour":case"hrs":case"hr":case"h":return Q*$0;case"minutes":case"minute":case"mins":case"min":case"m":return Q*K0;case"seconds":case"second":case"secs":case"sec":case"s":return Q*G0;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return Q;default:return}}function l4(Y){var Z=Math.abs(Y);if(Z>=f1)return Math.round(Y/f1)+"d";if(Z>=$0)return Math.round(Y/$0)+"h";if(Z>=K0)return Math.round(Y/K0)+"m";if(Z>=G0)return Math.round(Y/G0)+"s";return Y+"ms"}function f4(Y){var Z=Math.abs(Y);if(Z>=f1)return f0(Y,Z,f1,"day");if(Z>=$0)return f0(Y,Z,$0,"hour");if(Z>=K0)return f0(Y,Z,K0,"minute");if(Z>=G0)return f0(Y,Z,G0,"second");return Y+" ms"}function f0(Y,Z,Q,X){var G=Z>=Q*1.5;return Math.round(Y/Q)+" "+X+(G?"s":"")}});var G6=C0((HX,X6)=>{function i4(Y){Q.debug=Q,Q.default=Q,Q.coerce=U,Q.disable=K,Q.enable=G,Q.enabled=V,Q.humanize=Q6(),Q.destroy=q,Object.keys(Y).forEach((M)=>{Q[M]=Y[M]}),Q.names=[],Q.skips=[],Q.formatters={};function Z(M){let F=0;for(let R=0;R{if(P==="%%")return"%";m++;let a=Q.formatters[y];if(typeof a==="function"){let r=w[m];P=a.call(A,r),w.splice(m,1),m--}return P}),Q.formatArgs.call(A,w),(A.log||Q.log).apply(A,w)}if(I.namespace=M,I.useColors=Q.useColors(),I.color=Q.selectColor(M),I.extend=X,I.destroy=Q.destroy,Object.defineProperty(I,"enabled",{enumerable:!0,configurable:!1,get:()=>{if(R!==null)return R;if(L!==Q.namespaces)L=Q.namespaces,j=Q.enabled(M);return j},set:(w)=>{R=w}}),typeof Q.init==="function")Q.init(I);return I}function X(M,F){let R=Q(this.namespace+(typeof F>"u"?":":F)+M);return R.log=this.log,R}function G(M){Q.save(M),Q.namespaces=M,Q.names=[],Q.skips=[];let F=(typeof M==="string"?M:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let R of F)if(R[0]==="-")Q.skips.push(R.slice(1));else Q.names.push(R)}function $(M,F){let R=0,L=0,j=-1,I=0;while(R"-"+F)].join(",");return Q.enable(""),M}function V(M){for(let F of Q.skips)if($(M,F))return!1;for(let F of Q.names)if($(M,F))return!0;return!1}function U(M){if(M instanceof Error)return M.stack||M.message;return M}function q(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return Q.enable(Q.load()),Q}X6.exports=i4});var K6=C0((V1,i0)=>{V1.formatArgs=a4;V1.save=d4;V1.load=n4;V1.useColors=r4;V1.storage=s4();V1.destroy=(()=>{let Y=!1;return()=>{if(!Y)Y=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}})();V1.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r4(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let Y;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(Y=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(Y[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function a4(Y){if(Y[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+Y[0]+(this.useColors?"%c ":" ")+"+"+i0.exports.humanize(this.diff),!this.useColors)return;let Z="color: "+this.color;Y.splice(1,0,Z,"color: inherit");let Q=0,X=0;Y[0].replace(/%[a-zA-Z%]/g,(G)=>{if(G==="%%")return;if(Q++,G==="%c")X=Q}),Y.splice(X,0,Z)}V1.log=console.debug||console.log||(()=>{});function d4(Y){try{if(Y)V1.storage.setItem("debug",Y);else V1.storage.removeItem("debug")}catch(Z){}}function n4(){let Y;try{Y=V1.storage.getItem("debug")||V1.storage.getItem("DEBUG")}catch(Z){}if(!Y&&typeof process<"u"&&"env"in process)Y=process.env.DEBUG;return Y}function s4(){try{return localStorage}catch(Y){}}i0.exports=G6()(V1);var{formatters:c4}=i0.exports;c4.j=function(Y){try{return JSON.stringify(Y)}catch(Z){return"[UnexpectedJSONParseError]: "+Z.message}}});var b6=C0((iK,f5)=>{(function(){var Y;if(typeof f5<"u")Y=f5.exports=X;else Y=function(){return this||(0,eval)("this")}();if(Y.format=X,Y.vsprintf=Q,typeof console<"u"&&typeof console.log==="function")Y.printf=Z;function Z(){console.log(X.apply(null,arguments))}function Q(G,$){return X.apply(null,[G].concat($))}function X(G){var $=1,K=[].slice.call(arguments),V=0,U=G.length,q="",M,F=!1,R,L,j=!1,I,w=function(){return K[$++]},A=function(){var x="";while(/\d/.test(G[V]))x+=G[V++],M=G[V];return x.length>0?parseInt(x):null};for(;Vs5});module.exports=Q7(C3);var Q1=require("obsidian");var f=require("obsidian");var Y5=require("obsidian");class V2{add(Y,Z,Q){if(typeof arguments[0]!="string")for(let X in arguments[0])this.add(X,arguments[0][X],arguments[1]);else(Array.isArray(Y)?Y:[Y]).forEach(function(X){if(this[X]=this[X]||[],Z)this[X][Q?"unshift":"push"](Z)},this)}run(Y,Z){this[Y]=this[Y]||[],this[Y].forEach(function(Q){Q.call(Z&&Z.context?Z.context:Z,Z)})}}class W2{constructor(Y){this.jsep=Y,this.registered={}}register(){for(var Y=arguments.length,Z=Array(Y),Q=0;Q{if(typeof X!=="object"||!X.name||!X.init)throw Error("Invalid JSEP plugin format");if(this.registered[X.name])return;X.init(this.jsep),this.registered[X.name]=X})}}class B{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+B.version}static addUnaryOp(Y){return B.max_unop_len=Math.max(Y.length,B.max_unop_len),B.unary_ops[Y]=1,B}static addBinaryOp(Y,Z,Q){if(B.max_binop_len=Math.max(Y.length,B.max_binop_len),B.binary_ops[Y]=Z,Q)B.right_associative.add(Y);else B.right_associative.delete(Y);return B}static addIdentifierChar(Y){return B.additional_identifier_chars.add(Y),B}static addLiteral(Y,Z){return B.literals[Y]=Z,B}static removeUnaryOp(Y){if(delete B.unary_ops[Y],Y.length===B.max_unop_len)B.max_unop_len=B.getMaxKeyLen(B.unary_ops);return B}static removeAllUnaryOps(){return B.unary_ops={},B.max_unop_len=0,B}static removeIdentifierChar(Y){return B.additional_identifier_chars.delete(Y),B}static removeBinaryOp(Y){if(delete B.binary_ops[Y],Y.length===B.max_binop_len)B.max_binop_len=B.getMaxKeyLen(B.binary_ops);return B.right_associative.delete(Y),B}static removeAllBinaryOps(){return B.binary_ops={},B.max_binop_len=0,B}static removeLiteral(Y){return delete B.literals[Y],B}static removeAllLiterals(){return B.literals={},B}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(Y){this.expr=Y,this.index=0}static parse(Y){return new B(Y).parse()}static getMaxKeyLen(Y){return Math.max(0,...Object.keys(Y).map((Z)=>Z.length))}static isDecimalDigit(Y){return Y>=48&&Y<=57}static binaryPrecedence(Y){return B.binary_ops[Y]||0}static isIdentifierStart(Y){return Y>=65&&Y<=90||Y>=97&&Y<=122||Y>=128&&!B.binary_ops[String.fromCharCode(Y)]||B.additional_identifier_chars.has(String.fromCharCode(Y))}static isIdentifierPart(Y){return B.isIdentifierStart(Y)||B.isDecimalDigit(Y)}throwError(Y){let Z=Error(Y+" at character "+this.index);throw Z.index=this.index,Z.description=Y,Z}runHook(Y,Z){if(B.hooks[Y]){let Q={context:this,node:Z};return B.hooks.run(Y,Q),Q.node}return Z}searchHook(Y){if(B.hooks[Y]){let Z={context:this};return B.hooks[Y].find(function(Q){return Q.call(Z.context,Z),Z.node}),Z.node}}gobbleSpaces(){let Y=this.code;while(Y===B.SPACE_CODE||Y===B.TAB_CODE||Y===B.LF_CODE||Y===B.CR_CODE)Y=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let Y=this.gobbleExpressions(),Z=Y.length===1?Y[0]:{type:B.COMPOUND,body:Y};return this.runHook("after-all",Z)}gobbleExpressions(Y){let Z=[],Q,X;while(this.index0){if(B.binary_ops.hasOwnProperty(Y)&&(!B.isIdentifierStart(this.code)||this.index+Y.lengthG.right_a&&M.right_a?Q>M.prec:Q<=M.prec;while(X.length>2&&q(X[X.length-2]))K=X.pop(),Z=X.pop().value,$=X.pop(),Y={type:B.BINARY_EXP,operator:Z,left:$,right:K},X.push(Y);if(Y=this.gobbleToken(),!Y)this.throwError("Expected expression after "+U);X.push(G,Y)}V=X.length-1,Y=X[V];while(V>1)Y={type:B.BINARY_EXP,operator:X[V-1].value,left:X[V-2],right:Y},V-=2;return Y}gobbleToken(){let Y,Z,Q,X;if(this.gobbleSpaces(),X=this.searchHook("gobble-token"),X)return this.runHook("after-token",X);if(Y=this.code,B.isDecimalDigit(Y)||Y===B.PERIOD_CODE)return this.gobbleNumericLiteral();if(Y===B.SQUOTE_CODE||Y===B.DQUOTE_CODE)X=this.gobbleStringLiteral();else if(Y===B.OBRACK_CODE)X=this.gobbleArray();else{Z=this.expr.substr(this.index,B.max_unop_len),Q=Z.length;while(Q>0){if(B.unary_ops.hasOwnProperty(Z)&&(!B.isIdentifierStart(this.code)||this.index+Z.length=Z.length)this.throwError("Unexpected token "+String.fromCharCode(Y));break}else if(G===B.COMMA_CODE){if(this.index++,X++,X!==Z.length){if(Y===B.CPAREN_CODE)this.throwError("Unexpected token ,");else if(Y===B.CBRACK_CODE)for(let $=Z.length;$":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"});B.max_unop_len=B.getMaxKeyLen(B.unary_ops);B.max_binop_len=B.getMaxKeyLen(B.binary_ops);var R1=(Y)=>new B(Y).parse(),$7=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(B).filter((Y)=>!$7.includes(Y)&&R1[Y]===void 0).forEach((Y)=>{R1[Y]=B[Y]});R1.Jsep=B;var H7="ConditionalExpression",V7={name:"ternary",init(Y){Y.hooks.add("after-expression",function(Q){if(Q.node&&this.code===Y.QUMARK_CODE){this.index++;let X=Q.node,G=this.gobbleExpression();if(!G)this.throwError("Expected expression");if(this.gobbleSpaces(),this.code===Y.COLON_CODE){this.index++;let $=this.gobbleExpression();if(!$)this.throwError("Expected expression");if(Q.node={type:H7,test:X,consequent:G,alternate:$},X.operator&&Y.binary_ops[X.operator]<=0.9){let K=X;while(K.right.operator&&Y.binary_ops[K.right.operator]<=0.9)K=K.right;Q.node.test=K.right,K.right=Q.node,Q.node=X}}else this.throwError("Expected :")}})}};R1.plugins.register(V7);var H2=47,W7=92,q7={name:"regex",init(Y){Y.hooks.add("gobble-token",function(Q){if(this.code===H2){let X=++this.index,G=!1;while(this.index=97&&U<=122||U>=65&&U<=90||U>=48&&U<=57)K+=this.char;else break}let V;try{V=new RegExp($,K)}catch(U){this.throwError(U.message)}return Q.node={type:Y.LITERAL,value:V,raw:this.expr.slice(X-1,this.index)},Q.node=this.gobbleTokenProperty(Q.node),Q.node}if(this.code===Y.OBRACK_CODE)G=!0;else if(G&&this.code===Y.CBRACK_CODE)G=!1;this.index+=this.code===W7?2:1}this.throwError("Unclosed Regex")}})}},t0=43,M7=45,c1={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|=","||=","&&=","??="]),updateOperators:[t0,M7],assignmentPrecedence:0.9,init(Y){let Z=[Y.IDENTIFIER,Y.MEMBER_EXP];c1.assignmentOperators.forEach((X)=>Y.addBinaryOp(X,c1.assignmentPrecedence,!0)),Y.hooks.add("gobble-token",function(G){let $=this.code;if(c1.updateOperators.some((K)=>K===$&&K===this.expr.charCodeAt(this.index+1))){if(this.index+=2,G.node={type:"UpdateExpression",operator:$===t0?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},!G.node.argument||!Z.includes(G.node.argument.type))this.throwError(`Unexpected ${G.node.operator}`)}}),Y.hooks.add("after-token",function(G){if(G.node){let $=this.code;if(c1.updateOperators.some((K)=>K===$&&K===this.expr.charCodeAt(this.index+1))){if(!Z.includes(G.node.type))this.throwError(`Unexpected ${G.node.operator}`);this.index+=2,G.node={type:"UpdateExpression",operator:$===t0?"++":"--",argument:G.node,prefix:!1}}}}),Y.hooks.add("after-expression",function(G){if(G.node)Q(G.node)});function Q(X){if(c1.assignmentOperators.has(X.operator))X.type="AssignmentExpression",Q(X.left),Q(X.right);else if(!X.operator)Object.values(X).forEach((G)=>{if(G&&typeof G==="object")Q(G)})}}};R1.plugins.register(q7,c1);R1.addUnaryOp("typeof");R1.addUnaryOp("void");R1.addLiteral("null",null);R1.addLiteral("undefined",void 0);var U7=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),s={evalAst(Y,Z){switch(Y.type){case"BinaryExpression":case"LogicalExpression":return s.evalBinaryExpression(Y,Z);case"Compound":return s.evalCompound(Y,Z);case"ConditionalExpression":return s.evalConditionalExpression(Y,Z);case"Identifier":return s.evalIdentifier(Y,Z);case"Literal":return s.evalLiteral(Y,Z);case"MemberExpression":return s.evalMemberExpression(Y,Z);case"UnaryExpression":return s.evalUnaryExpression(Y,Z);case"ArrayExpression":return s.evalArrayExpression(Y,Z);case"CallExpression":return s.evalCallExpression(Y,Z);case"AssignmentExpression":return s.evalAssignmentExpression(Y,Z);default:throw SyntaxError("Unexpected expression",Y)}},evalBinaryExpression(Y,Z){return{"||":(X,G)=>X||G(),"&&":(X,G)=>X&&G(),"|":(X,G)=>X|G(),"^":(X,G)=>X^G(),"&":(X,G)=>X&G(),"==":(X,G)=>X==G(),"!=":(X,G)=>X!=G(),"===":(X,G)=>X===G(),"!==":(X,G)=>X!==G(),"<":(X,G)=>X":(X,G)=>X>G(),"<=":(X,G)=>X<=G(),">=":(X,G)=>X>=G(),"<<":(X,G)=>X<>":(X,G)=>X>>G(),">>>":(X,G)=>X>>>G(),"+":(X,G)=>X+G(),"-":(X,G)=>X-G(),"*":(X,G)=>X*G(),"/":(X,G)=>X/G(),"%":(X,G)=>X%G()}[Y.operator](s.evalAst(Y.left,Z),()=>s.evalAst(Y.right,Z))},evalCompound(Y,Z){let Q;for(let X=0;X-s.evalAst(X,Z),"!":(X)=>!s.evalAst(X,Z),"~":(X)=>~s.evalAst(X,Z),"+":(X)=>+s.evalAst(X,Z),typeof:(X)=>typeof s.evalAst(X,Z),void:(X)=>void s.evalAst(X,Z)}[Y.operator](Y.argument)},evalArrayExpression(Y,Z){return Y.elements.map((Q)=>s.evalAst(Q,Z))},evalCallExpression(Y,Z){let Q=Y.arguments.map((G)=>s.evalAst(G,Z)),X=s.evalAst(Y.callee,Z);if(X===Function)throw Error("Function constructor is disabled");return X(...Q)},evalAssignmentExpression(Y,Z){if(Y.left.type!=="Identifier")throw SyntaxError("Invalid left-hand side in assignment");let Q=Y.left.name,X=s.evalAst(Y.right,Z);return Z[Q]=X,Z[Q]}};class q2{constructor(Y){this.code=Y,this.ast=R1(this.code)}runInNewContext(Y){let Z=Object.assign(Object.create(null),Y);return s.evalAst(this.ast,Z)}}function C1(Y,Z){return Y=Y.slice(),Y.push(Z),Y}function e0(Y,Z){return Z=Z.slice(),Z.unshift(Y),Z}class M2 extends Error{constructor(Y){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)');this.avoidNew=!0,this.value=Y,this.name="NewError"}}function i(Y,Z,Q,X,G){if(!(this instanceof i))try{return new i(Y,Z,Q,X,G)}catch(K){if(!K.avoidNew)throw K;return K.value}if(typeof Y==="string")G=X,X=Q,Q=Z,Z=Y,Y=null;let $=Y&&typeof Y==="object";if(Y=Y||{},this.json=Y.json||Q,this.path=Y.path||Z,this.resultType=Y.resultType||"value",this.flatten=Y.flatten||!1,this.wrap=Object.hasOwn(Y,"wrap")?Y.wrap:!0,this.sandbox=Y.sandbox||{},this.eval=Y.eval===void 0?"safe":Y.eval,this.ignoreEvalErrors=typeof Y.ignoreEvalErrors>"u"?!1:Y.ignoreEvalErrors,this.parent=Y.parent||null,this.parentProperty=Y.parentProperty||null,this.callback=Y.callback||X||null,this.otherTypeCallback=Y.otherTypeCallback||G||function(){throw TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},Y.autostart!==!1){let K={path:$?Y.path:Z};if(!$)K.json=Q;else if("json"in Y)K.json=Y.json;let V=this.evaluate(K);if(!V||typeof V!=="object")throw new M2(V);return V}}i.prototype.evaluate=function(Y,Z,Q,X){let G=this.parent,$=this.parentProperty,{flatten:K,wrap:V}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,Q=Q||this.callback,this.currOtherTypeCallback=X||this.otherTypeCallback,Z=Z||this.json,Y=Y||this.path,Y&&typeof Y==="object"&&!Array.isArray(Y)){if(!Y.path&&Y.path!=="")throw TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(Y,"json"))throw TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:Z}=Y),K=Object.hasOwn(Y,"flatten")?Y.flatten:K,this.currResultType=Object.hasOwn(Y,"resultType")?Y.resultType:this.currResultType,this.currSandbox=Object.hasOwn(Y,"sandbox")?Y.sandbox:this.currSandbox,V=Object.hasOwn(Y,"wrap")?Y.wrap:V,this.currEval=Object.hasOwn(Y,"eval")?Y.eval:this.currEval,Q=Object.hasOwn(Y,"callback")?Y.callback:Q,this.currOtherTypeCallback=Object.hasOwn(Y,"otherTypeCallback")?Y.otherTypeCallback:this.currOtherTypeCallback,G=Object.hasOwn(Y,"parent")?Y.parent:G,$=Object.hasOwn(Y,"parentProperty")?Y.parentProperty:$,Y=Y.path}if(G=G||null,$=$||null,Array.isArray(Y))Y=i.toPathString(Y);if(!Y&&Y!==""||!Z)return;let U=i.toPathArray(Y);if(U[0]==="$"&&U.length>1)U.shift();this._hasParentSelector=null;let q=this._trace(U,Z,["$"],G,$,Q).filter(function(M){return M&&!M.isParentSelector});if(!q.length)return V?[]:void 0;if(!V&&q.length===1&&!q[0].hasArrExpr)return this._getPreferredOutput(q[0]);return q.reduce((M,F)=>{let R=this._getPreferredOutput(F);if(K&&Array.isArray(R))M=M.concat(R);else M.push(R);return M},[])};i.prototype._getPreferredOutput=function(Y){let Z=this.currResultType;switch(Z){case"all":{let Q=Array.isArray(Y.path)?Y.path:i.toPathArray(Y.path);return Y.pointer=i.toPointer(Q),Y.path=typeof Y.path==="string"?Y.path:i.toPathString(Y.path),Y}case"value":case"parent":case"parentProperty":return Y[Z];case"path":return i.toPathString(Y[Z]);case"pointer":return i.toPointer(Y.path);default:throw TypeError("Unknown result type")}};i.prototype._handleCallback=function(Y,Z,Q){if(Z){let X=this._getPreferredOutput(Y);Y.path=typeof Y.path==="string"?Y.path:i.toPathString(Y.path),Z(X,Q,Y)}};i.prototype._trace=function(Y,Z,Q,X,G,$,K,V){let U;if(!Y.length)return U={path:Q,value:Z,parent:X,parentProperty:G,hasArrExpr:K},this._handleCallback(U,$,"value"),U;let q=Y[0],M=Y.slice(1),F=[];function R(L){if(Array.isArray(L))L.forEach((j)=>{F.push(j)});else F.push(L)}if((typeof q!=="string"||V)&&Z&&Object.hasOwn(Z,q))R(this._trace(M,Z[q],C1(Q,q),Z,q,$,K));else if(q==="*")this._walk(Z,(L)=>{R(this._trace(M,Z[L],C1(Q,L),Z,L,$,!0,!0))});else if(q==="..")R(this._trace(M,Z,Q,X,G,$,K)),this._walk(Z,(L)=>{if(typeof Z[L]==="object")R(this._trace(Y.slice(),Z[L],C1(Q,L),Z,L,$,!0))});else if(q==="^")return this._hasParentSelector=!0,{path:Q.slice(0,-1),expr:M,isParentSelector:!0};else if(q==="~")return U={path:C1(Q,q),value:G,parent:X,parentProperty:null},this._handleCallback(U,$,"property"),U;else if(q==="$")R(this._trace(M,Z,Q,null,null,$,K));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(q))R(this._slice(q,M,Z,Q,X,G,$));else if(q.indexOf("?(")===0){if(this.currEval===!1)throw Error("Eval [?(expr)] prevented in JSONPath expression.");let L=q.replace(/^\?\((.*?)\)$/u,"$1"),j=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(L);if(j)this._walk(Z,(I)=>{let w=[j[2]],A=j[1]?Z[I][j[1]]:Z[I];if(this._trace(w,A,Q,X,G,$,!0).length>0)R(this._trace(M,Z[I],C1(Q,I),Z,I,$,!0))});else this._walk(Z,(I)=>{if(this._eval(L,Z[I],I,Q,X,G))R(this._trace(M,Z[I],C1(Q,I),Z,I,$,!0))})}else if(q[0]==="("){if(this.currEval===!1)throw Error("Eval [(expr)] prevented in JSONPath expression.");R(this._trace(e0(this._eval(q,Z,Q.at(-1),Q.slice(0,-1),X,G),M),Z,Q,X,G,$,K))}else if(q[0]==="@"){let L=!1,j=q.slice(1,-2);switch(j){case"scalar":if(!Z||!["object","function"].includes(typeof Z))L=!0;break;case"boolean":case"string":case"undefined":case"function":if(typeof Z===j)L=!0;break;case"integer":if(Number.isFinite(Z)&&!(Z%1))L=!0;break;case"number":if(Number.isFinite(Z))L=!0;break;case"nonFinite":if(typeof Z==="number"&&!Number.isFinite(Z))L=!0;break;case"object":if(Z&&typeof Z===j)L=!0;break;case"array":if(Array.isArray(Z))L=!0;break;case"other":L=this.currOtherTypeCallback(Z,Q,X,G);break;case"null":if(Z===null)L=!0;break;default:throw TypeError("Unknown value type "+j)}if(L)return U={path:Q,value:Z,parent:X,parentProperty:G},this._handleCallback(U,$,"value"),U}else if(q[0]==="`"&&Z&&Object.hasOwn(Z,q.slice(1))){let L=q.slice(1);R(this._trace(M,Z[L],C1(Q,L),Z,L,$,K,!0))}else if(q.includes(",")){let L=q.split(",");for(let j of L)R(this._trace(e0(j,M),Z,Q,X,G,$,!0))}else if(!V&&Z&&Object.hasOwn(Z,q))R(this._trace(M,Z[q],C1(Q,q),Z,q,$,K,!0));if(this._hasParentSelector)for(let L=0;L{Z(Q)})};i.prototype._slice=function(Y,Z,Q,X,G,$,K){if(!Array.isArray(Q))return;let V=Q.length,U=Y.split(":"),q=U[2]&&Number.parseInt(U[2])||1,M=U[0]&&Number.parseInt(U[0])||0,F=U[1]&&Number.parseInt(U[1])||V;M=M<0?Math.max(0,M+V):Math.min(V,M),F=F<0?Math.max(0,F+V):Math.min(V,F);let R=[];for(let L=M;L{R.push(I)});return R};i.prototype._eval=function(Y,Z,Q,X,G,$){this.currSandbox._$_parentProperty=$,this.currSandbox._$_parent=G,this.currSandbox._$_property=Q,this.currSandbox._$_root=this.json,this.currSandbox._$_v=Z;let K=Y.includes("@path");if(K)this.currSandbox._$_path=i.toPathString(X.concat([Q]));let V=this.currEval+"Script:"+Y;if(!i.cache[V]){let U=Y.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(K)U=U.replaceAll("@path","_$_path");if(this.currEval==="safe"||this.currEval===!0||this.currEval===void 0)i.cache[V]=new this.safeVm.Script(U);else if(this.currEval==="native")i.cache[V]=new this.vm.Script(U);else if(typeof this.currEval==="function"&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){let q=this.currEval;i.cache[V]=new q(U)}else if(typeof this.currEval==="function")i.cache[V]={runInNewContext:(q)=>this.currEval(U,q)};else throw TypeError(`Unknown "eval" property "${this.currEval}"`)}try{return i.cache[V].runInNewContext(this.currSandbox)}catch(U){if(this.ignoreEvalErrors)return!1;throw Error("jsonPath: "+U.message+": "+Y)}};i.cache={};i.toPathString=function(Y){let Z=Y,Q=Z.length,X="$";for(let G=1;G{return typeof Y[U]==="function"});let G=Q.map((U)=>{return Y[U]});if(Z=X.reduce((U,q)=>{let M=Y[q].toString();if(!/function/u.test(M))M="function "+M;return"var "+q+"="+M+";"+U},"")+Z,!/(['"])use strict\1/u.test(Z)&&!Q.includes("arguments"))Z="var arguments = undefined;"+Z;Z=Z.replace(/;\s*$/u,"");let K=Z.lastIndexOf(";"),V=K!==-1?Z.slice(0,K+1)+" return "+Z.slice(K+1):" return "+Z;return Function(...Q,V)(...G)}}i.prototype.vm={Script:U2};async function F2(Y,Z,Q){let X=Q.stringify(),G=Y.staticLanguage??"auto",$={data:X,language:G,enabledOnly:"false",level:Y.pickyMode?"picky":"default"};if(Y.motherTongue)$.motherTongue=Y.motherTongue;if(Y.enabledCategories)$.enabledCategories=Y.enabledCategories;if(Y.disabledCategories)$.disabledCategories=Y.disabledCategories;if(Y.enabledRules)$.enabledRules=Y.enabledRules;if(Y.disabledRules)$.disabledRules=Y.disabledRules;if(G=="auto")$.preferredVariants=Object.values(Y.languageVariety).join(",");if(g1(Y.serverUrl)!=="standard"&&Y.apikey&&Y.username)$.username=Y.username,$.apiKey=Y.apikey;let V=await t1({url:`${Y.serverUrl}/v2/check`,method:"POST",body:new URLSearchParams($).toString(),headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}});if(V.json==null)throw Error("Error processing response from LanguageTool.");return L0("$.matches[*]",V.json).map((q)=>{let M=I1("$.offset@number()",q),F=M+I1("$.length@number()",q);return{range:{from:Z+M,to:Z+F},text:Q.extractSlice(M,F)||"",title:I1("$.shortMessage@string()",q),message:I1("$.message@string()",q),replacements:L0("$.replacements[*].value@string()",q),categoryId:I1("$.rule.category.id@string()",q),ruleId:I1("$.rule.id@string()",q)}})}async function L2(Y){let Z=await Y5.requestUrl({url:`${Y}/v2/languages`}).json;if(Z==null||!(Z instanceof Array))throw Error("Error processing response from LanguageTool.");return Z}async function R2(Y){if(Y.username==null||Y.apikey==null)throw Error("Syncing words is only supported for premium users");try{let Z=(await t1({url:I0(`${Y.serverUrl}/v2/words`,{username:Y.username,apiKey:Y.apikey,limit:"1000"}).href})).json;return L0("$.words[*]@string()",Z)}catch(Z){throw Error(`Requesting words failed ${Z}`)}}async function _2(Y,Z){if(Y.username==null||Y.apikey==null)throw Error("Syncing words is only supported for premium users");try{let Q=(await t1({url:I0(`${Y.serverUrl}/v2/words/add`,{username:Y.username,apiKey:Y.apikey,word:Z}).href,method:"POST"})).json;return I1("$.added@boolean()",Q)}catch(Q){throw Error(`Adding words failed ${Q}`)}}async function N2(Y,Z){if(Y.username==null||Y.apikey==null)throw Error("Syncing words is only supported for premium users");try{let Q=(await t1({url:I0(`${Y.serverUrl}/v2/words/delete`,{username:Y.username,apiKey:Y.apikey,word:Z}).href,method:"POST"})).json;return I1("$.deleted@boolean()",Q)}catch(Q){throw Error(`Deleting words failed ${Q}`)}}class D2{url="https://qb-grammar-en.languagetool.org/phrasal-paraphraser/subscribe";async query(Y,Z){let Q=Y.slice(0,Z.from).split(/\s+/).length,X=Y.slice(Z.from,Z.to),G={message:{indices:[Q],mode:0,phrases:[X],text:Y},meta:{clientStatus:"string",product:"string",traceID:"string",userID:"string"},response_queue:"string"};try{let $=(await t1({url:this.url,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)})).json;return L0("$.data.suggestions[*][*]@string()",$)}catch($){throw Error(`Requesting synonyms failed ${$}`)}}}class j2{url="https://synonyms.languagetool.org/synonyms/de";async query(Y,Z){let Q=Y.slice(Z.from,Z.to).trim(),X=Y.slice(0,Z.from).split(/\s+/).join("+"),G=Y.slice(Z.to).split(/\s+/).join("+");try{let $=(await t1({url:I0(`${this.url}/${Q}`,{before:X,after:G}).href,method:"GET"})).json;return L0("$.synsets[*].terms[*].term@string()",$)}catch($){throw Error(`Requesting synonyms failed ${$}`)}}}var o1={en:new D2,de:new j2};async function t1(Y){let Z;try{Z=await Y5.requestUrl({...Y,throw:!1})}catch(Q){throw Error(`Request to LanguageTool failed: Please check your connection and server URL. ${Q}`)}if(Z.status===504||Z.status===503)throw Error("Request to LanguageTool timed out. Please try again later.");if(Z.status!==200){let Q=Z.text;if(Q.length>310)Q=Q.substring(0,300)+"...";throw Error(`Request to LanguageTool failed ${Z.status}: ${Q}`)}return Z}function I1(Y,Z){let Q=i({path:Y,json:Z,wrap:!1,eval:!1});if(Q==null)throw Error("Error parsing response.");return Q}function L0(Y,Z){let Q=i({path:Y,json:Z,wrap:!0,eval:!1});if(Q==null||!(Q instanceof Array))throw Error("Error parsing response.");return Q}function I0(Y,Z){let Q=new URL(Y);return Q.search=new URLSearchParams(Z).toString(),Q}function J0(Y){switch(Y){case"COLLOQUIALISMS":case"REDUNDANCY":case"STYLE":case"SYNONYMS":return"lt-style";case"TYPOS":return"lt-major";default:return"lt-minor"}}function e1(Y,Z){let Q=new Set(Y);for(let X of Z)Q.delete(X);return Q}function z2(Y,Z){let Q=new Set(Y);for(let X of Z)Q.add(X);return Q}function T2(Y,Z){let Q=new Set;for(let X of Z)if(Y.has(X))Q.add(X);return Q}function Y0(Y,Z){return Y=Y.toLowerCase(),Z=Z.toLowerCase(),Y>Z?1:YQ.code===Z).filter((Q)=>Q.longCode!==Q.code),Object.fromEntries(Y.map((Q)=>[Q.longCode,Q.name]))}class Q5 extends f.PluginSettingTab{plugin;endpointListeners=[];languageListeners=[];languages=[];constructor(Y,Z){super(Y,Z);this.icon="spell-check",this.plugin=Z}async configureCheckDelay(Y,Z){let Q=R0[Z].minDelay;await this.plugin.settings.update({autoCheckDelay:Math.clamp(this.plugin.settings.options.autoCheckDelay,Q,O2)}),Y.setLimits(Q,O2,L7)}async notifyEndpointChange(Y){for(let Z of this.endpointListeners)await Z(Y.serverUrl)}async configureLanguageVariants(Y,Z){let Q=this.plugin.settings.options.languageVariety,X=A2(this.languages,Z);Q[Z]=Q[Z]??Object.keys(X)[0],Y.addOptions(X).setValue(Q[Z]).onChange(async(G)=>{Q[Z]=G,await this.plugin.settings.update({languageVariety:Q})}),this.languageListeners.push(async(G)=>{while(Y.selectEl.options.length>0)Y.selectEl.remove(0);let $=A2(G,Z);Q[Z]=Q[Z]??Object.keys($)[0],Y.addOptions($).setValue(Q[Z])})}display(){this.displayAsync().catch((Y)=>console.error(Y))}async displayAsync(){let{containerEl:Y}=this;Y.empty();let Z=this.plugin.settings;this.plugin.autoCheckSuppressErrorsUntil=0,this.endpointListeners=[],this.endpointListeners.push(async(q)=>{let M=[];if(q)M=await L2(q);this.languages=M;for(let F of this.languageListeners)await F(M)}),this.endpointListeners.push(async(q)=>{await this.plugin.syncDictionary()}),this.languageListeners=[],new f.Setting(Y).setName("Error logs").setDesc(`${this.plugin.logs.length} messages`).addButton((q)=>{q.setButtonText("Copy to clipboard").onClick(async()=>{await window.navigator.clipboard.writeText(this.plugin.logs.join(` `)),new f.Notice("Logs copied to clipboard")})});let Q=g1(Z.options.serverUrl),X=null,G=null,$=null;new f.Setting(Y).setName("Endpoint").setDesc("Choose the LanguageTool server URL").then((q)=>{q.controlEl.classList.add("lt-settings-grid");let M=null,F=null;q.addDropdown((R)=>{M=R,R.addOptions({standard:"(Standard) api.languagetool.org",premium:"(Premium) api.languagetoolplus.com",custom:"Custom URL"}).setValue(Q).onChange(async(L)=>{if(Q=L,await Z.update({serverUrl:R0[Q].url}),F)F.setValue(Z.options.serverUrl).setDisabled(L!=="custom");if(X)await this.configureCheckDelay(X,Q);await this.notifyEndpointChange(Z.options)})}),q.addText((R)=>{F=R,R.setPlaceholder("http://your-custom-url.com").setValue(Z.options.serverUrl).setDisabled(Q!=="custom").onChange(async(L)=>{if(await Z.update({serverUrl:L.replace(/\/v2\/check\/$/,"").replace(/\/$/,"")}),Q=g1(Z.options.serverUrl),Q!=="custom")M?.setValue(Q),F?.setDisabled(!0);if(G)window.clearTimeout(G);G=window.setTimeout(()=>{this.notifyEndpointChange(Z.options).then(()=>{if($)$.hide();$=new f.Notice("Successfully contacted LanguageTool server.",3000)},(j)=>{let I=j;if($)$.hide();$=new f.Notice(`Error contacting LanguageTool server: ${I.message}`,3000)})},600)})})}),new f.Setting(Y).setName("API username").setDesc("Enter a username/mail for API access").addText((q)=>q.setPlaceholder("peterlustig@example.com").setValue(Z.options.username||"").onChange(async(M)=>{await Z.update({username:M.replace(/\s+/g,"")})})),new f.Setting(Y).setName("API key").setDesc(createFragment((q)=>{q.createEl("a",{text:"Click here for information about premium access",href:"https://github.com/wrenger/obsidian-languagetool#premium-accounts",attr:{target:"_blank"}})})).addText((q)=>q.setValue(Z.options.apikey||"").onChange(async(M)=>{if(await Z.update({apikey:M.replace(/\s+/g,"")}),Z.options.apikey&&Q!=="premium")new f.Notice("You have entered an API key but you are not using the premium endpoint")})),new f.Setting(Y).setName("Auto check text").setDesc("Check text as you type").addToggle((q)=>{q.setValue(Z.options.shouldAutoCheck).onChange(async(M)=>{await Z.update({shouldAutoCheck:M})})}),new f.Setting(Y).setName("Auto check delay (ms)").setDesc("Time to wait for autocheck after the last key press").addSlider(async(q)=>{X=q,await this.configureCheckDelay(q,Q),q.setValue(Z.options.autoCheckDelay).onChange(async(M)=>{await Z.update({autoCheckDelay:M})}).setDynamicTooltip()});function K(q){if(q.appendText("Enables the context menu for synonyms fetched from"),q.createEl("br"),Z.options.synonyms!=null){let M=o1[Z.options.synonyms];if(!M){q.appendText(" (unknown API)");return}q.createEl("a",{text:M.url,href:M.url,attr:{target:"_blank"}})}else q.appendText("(none)")}let V=new f.Setting(Y).setName("Find synonyms").setDesc(createFragment(K));V.addDropdown((q)=>{q.addOption("none","---");for(let M of Object.keys(o1))q.addOption(M,M);q.setValue(Z.options.synonyms??"none").onChange(async(M)=>{await Z.update({synonyms:M!=="none"?M:void 0}),V.setDesc(createFragment(K))})}),new f.Setting(Y).setName("Language").setHeading(),new f.Setting(Y).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((q)=>{q.addOption("none","---").addOptions(R7).setValue(Z.options.motherTongue??"none").onChange(async(M)=>{await Z.update({motherTongue:M!=="none"?M:void 0})})}),new f.Setting(Y).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((q)=>{this.languageListeners.push(async(M)=>{let F=M.filter((R)=>R.longCode.length>2||R.longCode!==R.code||M.filter((L)=>L.code==R.code).length<=1);while(q.selectEl.options.length>0)q.selectEl.remove(0);q.addOption("auto","Auto detect").addOptions(Object.fromEntries(F.map((R)=>[R.longCode,R.name]))).setValue(Z.options.staticLanguage??"auto").onChange(async(R)=>{await Z.update({staticLanguage:R!=="auto"?R:void 0})})})}),new f.Setting(Y).setName("Language varieties").setHeading().setDesc("Some languages have varieties depending on the country they are spoken in.");let U={en:"English",de:"German",pt:"Portuguese",ca:"Catalan"};for(let[q,M]of Object.entries(U))new f.Setting(Y).setName(`Interpret ${M} as`).addDropdown(async(F)=>{await this.configureLanguageVariants(F,q)});new f.Setting(Y).setName("Spellcheck dictionary").setHeading(),new f.Setting(Y).setName("Ignored words").setDesc("Words that should not be highlighted as spelling mistakes.").addButton((q)=>{q.setIcon("settings").setTooltip("Edit dictionary").onClick(()=>{new C2(this.app,this.plugin).open()})}),new f.Setting(Y).setName("Sync with LanguageTool").setDesc("This is only supported for premium users.").addToggle((q)=>{q.setDisabled(Q!=="premium").setValue(Z.options.syncDictionary).onChange(async(M)=>{if(await Z.update({syncDictionary:M}),M)await this.plugin.syncDictionary()}),this.endpointListeners.push(async(M)=>{q.setDisabled(g1(M)!=="premium")})}),new f.Setting(Y).setName("Rule categories").setHeading().setDesc(createFragment((q)=>{q.appendText("The picky mode enables a lot of extra categories and rules. Additionally, you can enable or disable specific rules down below."),q.createEl("br"),q.createEl("a",{text:"Click here for a list of rules and categories",href:"https://community.languagetool.org/rule/list",attr:{target:"_blank"}})})),new f.Setting(Y).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((q)=>{q.setValue(Z.options.pickyMode).onChange(async(M)=>{await Z.update({pickyMode:M})})}),new f.Setting(Y).setName("Enabled categories").setDesc("Comma-separated list of categories").addText((q)=>q.setPlaceholder("CATEGORY_1,CATEGORY_2").setValue(Z.options.enabledCategories??"").onChange(async(M)=>{await Z.update({enabledCategories:M.replace(/\s+/g,"")})})),new f.Setting(Y).setName("Disabled categories").setDesc("Comma-separated list of categories").addText((q)=>q.setPlaceholder("CATEGORY_1,CATEGORY_2").setValue(Z.options.disabledCategories??"").onChange(async(M)=>{await Z.update({disabledCategories:M.replace(/\s+/g,"")})})),new f.Setting(Y).setName("Enabled rules").setDesc("Comma-separated list of rules").addText((q)=>q.setPlaceholder("RULE_1,RULE_2").setValue(Z.options.enabledRules??"").onChange(async(M)=>{await Z.update({enabledRules:M.replace(/\s+/g,"")})})),new f.Setting(Y).setName("Disabled rules").setDesc("Comma-separated list of rules").addText((q)=>q.setPlaceholder("RULE_1,RULE_2").setValue(Z.options.disabledRules??"").onChange(async(M)=>{await Z.update({disabledRules:M.replace(/\s+/g,"")})})),new f.Setting(Y).setName("Advanced").setHeading(),new f.Setting(Y).setName("Long check notification").setDesc("Show the 'check spelling...' notification when a manual check is taking a long time").addToggle((q)=>{q.setValue(Z.options.longCheckNotification).onChange(async(M)=>{await Z.update({longCheckNotification:M})})}),new f.Setting(Y).setName("Inject property types").setDesc("Define the properties for note-specific LanguageTool settings.").addToggle((q)=>{q.setValue(Z.options.injectProperties).onChange(async(M)=>{await Z.update({injectProperties:M}),this.plugin.injectProperties(M)})}),await this.notifyEndpointChange(Z.options)}}class C2 extends f.Modal{plugin;words;constructor(Y,Z){super(Y);this.setTitle("Spellcheck dictionary"),this.plugin=Z,this.words=Z.settings.options.dictionary}async onOpen(){this.words=this.plugin.settings.options.dictionary;let{contentEl:Y}=this,Z=(K)=>{K.replaceChildren(...this.words.map((V)=>K.createDiv({cls:"multi-select-pill"},(U)=>{U.createDiv({cls:"multi-select-pill-content"},(q)=>q.createSpan({text:V})),U.createDiv({cls:"multi-select-pill-remove-button"},(q)=>{q.appendChild(f.getIcon("x")),q.onClickEvent(()=>{this.words.remove(V),Z(K)})})})))},Q=null;Y.createDiv({cls:["multi-select-container","lt-dictionary-words"]},(K)=>{Q=K,Z(K)}),this.plugin.syncDictionary().then(()=>{if(this.words=this.plugin.settings.options.dictionary,Q)Z(Q)},(K)=>{});let X="",G=null,$=()=>{if(X){if(this.words=[...new Set([...this.words,X])].sort(Y0),Q)Z(Q);if(G)G.setValue("");X=""}};new f.Setting(Y).setName("Add").addText((K)=>{G=K.setValue(X).onChange((V)=>X=V.trim()),K.inputEl.addEventListener("keypress",(V)=>{if(V.key==="Enter")$()})}).addExtraButton((K)=>{K.setIcon("plus").setTooltip("Add").onClick(()=>{$()})})}onClose(){this.onCloseAsync().catch((Y)=>console.error(Y))}async onCloseAsync(){this.contentEl.empty(),await this.plugin.settings.update({dictionary:this.words}),await this.plugin.syncDictionary()}}var I2=require("@codemirror/view"),J2=require("obsidian");function S2(Y){let Z=-1,Q={from:1/0,to:-1/0};return I2.EditorView.updateListener.of((X)=>{let G=Y.getActiveFileSettings();if(!X.docChanged||!G.shouldAutoCheck)return;X.changes.iterChangedRanges((K,V,U,q)=>{Q.from=Math.min(Q.from,U,q),Q.to=Math.max(Q.to,U,q)});let $=X.view;window.clearTimeout(Z),Z=window.setTimeout(()=>{let K=Q;Q={from:1/0,to:-1/0},Y.runDetection($,!0,K).then(()=>{},(V)=>{let U=V;if(Date.now()>Y.autoCheckSuppressErrorsUntil)Y.autoCheckSuppressErrorsUntil=Date.now()+900000,new J2.Notice(`Auto-check failed: `+U.message,1e4);console.error("Auto-check failed",V)})},Y.settings.options.autoCheckDelay)})}var Z0=require("@codemirror/view"),h1=require("@codemirror/state");var E0=h1.StateEffect.define(),N0=h1.StateEffect.define(),_1=h1.StateEffect.define(),x1=h1.StateEffect.define();function E2(Y,Z){return Y.from<=Z.from&&Z.from<=Y.to||Y.from<=Z.to&&Z.to<=Y.to||Z.from<=Y.from&&Y.from<=Z.to||Z.from<=Y.to&&Y.to<=Z.to}var P1=h1.StateField.define({create(){return Z0.Decoration.none},update(Y,Z){if(Y=Y.map(Z.changes),Z.docChanged&&Z.selection&&Y.size)Y=Y.update({filter:(Q,X)=>!E2({from:Q,to:X},Z.selection.main)});for(let Q of Z.effects)if(Q.is(E0)){let X=Q.value,G=X.range;Y=Y.update({add:[Z0.Decoration.mark({class:`lt-underline ${J0(X.categoryId)}`,underline:X}).range(G.from,G.to)]})}else if(Q.is(N0))Y=Z0.Decoration.none;else if(Q.is(_1))Y=Y.update({filterFrom:Q.value.from,filterTo:Q.value.to,filter:(X,G)=>!E2({from:X,to:G},Q.value)});else if(Q.is(x1))Y=Y.update({filter:(X,G,$)=>!Q.value($.spec.underline)});return Y},provide:(Y)=>Z0.EditorView.decorations.from(Y)});var w0=require("@codemirror/view");var k1=require("obsidian");function _7(Y,Z,Q,X){let G=Q.replacements.slice(0,_0/2),$=Q.categoryId,K=Q.ruleId;return createDiv({cls:["lt-tooltip",J0($)]},(V)=>{if(Q.title)V.createSpan({cls:"lt-title",text:Q.title});if(Q.message)V.createSpan({cls:"lt-message",text:Q.message});V.createDiv({cls:"lt-bottom"},(U)=>{U.createDiv({cls:"lt-buttoncontainer"},(q)=>{for(let M of G){let F=new k1.ButtonComponent(q);F.setButtonText(M||"(delete)"),F.onClick(()=>{Z.dispatch({changes:[{...X,insert:M}],effects:[_1.of(X)]})})}})}),V.createDiv({cls:"lt-ignore-container"},(U)=>{if($==="TYPOS")U.createDiv({cls:"lt-ignore-btn"},(q)=>{k1.setIcon(q.createSpan(),"plus-with-circle"),q.createSpan({text:"Add to dictionary"}),q.onclick=async()=>{let M=[...Y.settings.options.dictionary,Q.text.trim()];await Y.settings.update({dictionary:M}),Z.dispatch({effects:[x1.of((F)=>F.text===Q.text)]})}});else if(U.createDiv({cls:"lt-ignore-btn"},(q)=>{k1.setIcon(q.createSpan(),"cross"),q.createSpan({text:"Ignore"}),q.onclick=()=>Z.dispatch({effects:[_1.of(X)]})}),$!=="SYNONYMS")U.createDiv({cls:"lt-ignore-btn"},(q)=>{k1.setIcon(q.createSpan(),"circle-off"),q.createSpan({text:"Disable rule"}),q.onclick=async()=>{let M=Y.settings.options.disabledRules;if(M)M+=","+K;else M=K;await Y.settings.update({disabledRules:M}),Z.dispatch({effects:[x1.of((F)=>F.ruleId===K)]})}});U.createDiv({cls:"lt-info-container"},(q)=>{q.createDiv({cls:"lt-info-button clickable-icon"},(M)=>{k1.setIcon(M,"info"),M.onclick=()=>{let F=activeDocument.getElementsByClassName("lt-info-box").item(0);if(F)F.toggleAttribute("hidden")}})})}),V.createDiv({cls:"lt-info-box",attr:{hidden:!0}},(U)=>{U.createDiv({cls:"lt-info",text:`Category: ${$}`}),U.createDiv({cls:"lt-info",text:`Rule: ${K}`}),U.createDiv({cls:"lt-info",text:`Text: ${Q.text} (${X.from}-${X.to})`})})})}function N7(Y,Z,Q,X){let G=Z.state,$=G.field(P1);if($.size===0||G.selection.ranges.length>1)return null;let K=$.iter(Q);if(K.value!=null&&K.from<=Q&&K.to>=Q){let V=K.value.spec.underline;return{pos:K.from,end:K.to,above:!0,strictSide:!1,arrow:!1,clip:!1,create:(U)=>({dom:_7(Y,U,V,K)})}}return null}function w2(Y){return w0.hoverTooltip(N7.bind(null,Y),{hideOnChange:!0})}var y2=w0.EditorView.baseTheme({".cm-tooltip.cm-tooltip-hover":{padding:"var(--size-2-3)",border:"1px solid var(--background-modifier-border-hover)",backgroundColor:"var(--background-secondary)",borderRadius:"var(--radius-m)",boxShadow:"var(--shadow-s)",zIndex:"var(--layer-menu)",userSelect:"none",overflow:"hidden","& > .lt-tooltip":{fontFamily:"var(--default-font)",fontSize:"var(--font-ui-small)",width:"300px",lineHeight:1.5,"& > .lt-title":{display:"block",fontWeight:600,marginBottom:"6px",padding:"0 12px",textDecoration:"underline 2px var(--lt-highlight)","-webkit-text-decoration":"underline 2px var(--lt-highlight)"},"& > .lt-message":{display:"block",padding:"0 12px"},"& > .lt-bottom":{minHeight:"10px",padding:"0 12px",position:"relative","& > .lt-buttoncontainer":{"&:not(:empty)":{paddingTop:"10px"},"& > button":{marginRight:"4px",marginBottom:"4px",padding:"4px 6px"}}},"& > .lt-ignore-container":{display:"flex","& > .lt-ignore-btn":{fontSize:"var(--font-ui-small)",padding:"4px",display:"flex",flex:1,width:"100%",textAlign:"left",alignItems:"center",lineHeight:1,color:"var(--text-muted)","& > span":{display:"flex","&:last-child":{marginLeft:"5px"}},"&:hover":{color:"var(--text-normal)"}},"& > .lt-info-container":{display:"flex",flex:0,"& > .lt-info-button":{color:"var(--text-faint)",height:"100%"}}},"& > .lt-info-box":{padding:"5px 0px 0px 0px",overflowX:"scroll",color:"var(--text-muted)"}}},".lt-underline":{cursor:"pointer",transition:"background-color 100ms ease-out",textDecoration:"wavy underline var(--lt-highlight)","-webkit-text-decoration":"wavy underline var(--lt-highlight)","&:hover":{backgroundColor:"color-mix(in srgb, var(--lt-highlight), transparent 80%)"}}});function b2(Y){return[P1,S2(Y),w2(Y),y2]}class g2 extends Error{name="Assertion";code="ERR_ASSERTION";constructor(Y,Z,Q,X,G){super(Y);if(Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);this.actual=Z,this.expected=Q,this.generated=G,this.operator=X}}function _(Y,Z){D7(Boolean(Y),!1,!0,"ok","Expected value to be truthy",Z)}function D7(Y,Z,Q,X,G,$){if(!Y)throw $ instanceof Error?$:new g2($||G,Z,Q,X,!$)}var j7={};function X5(Y,Z){let Q=Z||j7,X=typeof Q.includeImageAlt==="boolean"?Q.includeImageAlt:!0,G=typeof Q.includeHtml==="boolean"?Q.includeHtml:!0;return x2(Y,X,G)}function x2(Y,Z,Q){if(B7(Y)){if("value"in Y)return Y.type==="html"&&!Q?"":Y.value;if(Z&&"alt"in Y&&Y.alt)return Y.alt;if("children"in Y)return h2(Y.children,Z,Q)}if(Array.isArray(Y))return h2(Y,Z,Q);return""}function h2(Y,Z,Q){let X=[],G=-1;while(++G",questionMark:"?",atSign:"@",uppercaseA:"A",uppercaseB:"B",uppercaseC:"C",uppercaseD:"D",uppercaseE:"E",uppercaseF:"F",uppercaseG:"G",uppercaseH:"H",uppercaseI:"I",uppercaseJ:"J",uppercaseK:"K",uppercaseL:"L",uppercaseM:"M",uppercaseN:"N",uppercaseO:"O",uppercaseP:"P",uppercaseQ:"Q",uppercaseR:"R",uppercaseS:"S",uppercaseT:"T",uppercaseU:"U",uppercaseV:"V",uppercaseW:"W",uppercaseX:"X",uppercaseY:"Y",uppercaseZ:"Z",leftSquareBracket:"[",backslash:"\\",rightSquareBracket:"]",caret:"^",underscore:"_",graveAccent:"`",lowercaseA:"a",lowercaseB:"b",lowercaseC:"c",lowercaseD:"d",lowercaseE:"e",lowercaseF:"f",lowercaseG:"g",lowercaseH:"h",lowercaseI:"i",lowercaseJ:"j",lowercaseK:"k",lowercaseL:"l",lowercaseM:"m",lowercaseN:"n",lowercaseO:"o",lowercaseP:"p",lowercaseQ:"q",lowercaseR:"r",lowercaseS:"s",lowercaseT:"t",lowercaseU:"u",lowercaseV:"v",lowercaseW:"w",lowercaseX:"x",lowercaseY:"y",lowercaseZ:"z",leftCurlyBrace:"{",verticalBar:"|",rightCurlyBrace:"}",tilde:"~",replacementCharacter:"�"};function o(Y,Z,Q,X){let G=Y.length,$=0,K;if(Z<0)Z=-Z>G?0:G+Z;else Z=Z>G?G:Z;if(Q=Q>0?Q:0,X.length0)return o(Y,Y.length,0,Z),Y;return Z}var v2={}.hasOwnProperty;function y0(Y){let Z={},Q=-1;while(++QH.cr&&QH.tilde&&Q<160||Q>55295&&Q<57344||Q>64975&&Q<65008||(Q&65535)===65535||(Q&65535)===65534||Q>1114111)return M1.replacementCharacter;return String.fromCodePoint(Q)}function G1(Y){return Y.replace(/[\t\n\r ]+/g,M1.space).replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Y1=J1(/[A-Za-z]/),Z1=J1(/[\dA-Za-z]/),m2=J1(/[#-'*+\--9=?A-Z^-~]/);function v1(Y){return Y!==null&&(Y-1&&Y.test(String.fromCharCode(Q))}}function k(Y,Z,Q,X){let G=X?X-1:Number.POSITIVE_INFINITY,$=0;return K;function K(U){if(h(U))return Y.enter(Q),V(U);return Z(U)}function V(U){if(h(U)&&$++K))return;let y=Z.events.length,a=y,r,z;while(a--)if(Z.events[a][0]==="exit"&&Z.events[a][1].type===W.chunkFlow){if(r){z=Z.events[a][1].end;break}r=!0}_(z,"could not find previous flow chunk"),A(X),P=y;while(PS){let E=Q[m];Z.containerState=E[1],_(E[0].exit,"expected `exit` to be defined on container construct"),E[0].exit.call(Z,Y)}Q.length=S}function x(){_(Z.containerState,"expected `containerState` to be defined when closing flow"),_(G,"expected `childFlow` to be defined when closing it"),G.write([H.eof]),$=void 0,G=void 0,Z.containerState._closeFlow=void 0}}function A7(Y,Z,Q){return _(this.parser.constructs.disable.null,"expected `disable.null` to be populated"),k(Y,Y.attempt(this.parser.constructs.document,Z,Q),W.linePrefix,this.parser.constructs.disable.null.includes("codeIndented")?void 0:C.tabSize)}function X0(Y){if(Y===H.eof||l(Y)||N1(Y))return C.characterGroupWhitespace;if(m1(Y))return C.characterGroupPunctuation}function S1(Y,Z,Q){let X=[],G=-1;while(++G1&&Y[Q][1].end.offset-Y[Q][1].start.offset>1?2:1;let F={...Y[X][1].end},R={...Y[Q][1].start};if(r2(F,-U),r2(R,U),K={type:U>1?W.strongSequence:W.emphasisSequence,start:F,end:{...Y[X][1].end}},V={type:U>1?W.strongSequence:W.emphasisSequence,start:{...Y[Q][1].start},end:R},$={type:U>1?W.strongText:W.emphasisText,start:{...Y[X][1].end},end:{...Y[Q][1].start}},G={type:U>1?W.strong:W.emphasis,start:{...K.start},end:{...V.end}},Y[X][1].end={...K.start},Y[Q][1].start={...V.end},q=[],Y[X][1].end.offset-Y[X][1].start.offset)q=$1(q,[["enter",Y[X][1],Z],["exit",Y[X][1],Z]]);if(q=$1(q,[["enter",G,Z],["enter",K,Z],["exit",K,Z],["enter",$,Z]]),_(Z.parser.constructs.insideSpan.null,"expected `insideSpan` to be populated"),q=$1(q,S1(Z.parser.constructs.insideSpan.null,Y.slice(X+1,Q),Z)),q=$1(q,[["exit",$,Z],["enter",V,Z],["exit",V,Z],["exit",G,Z]]),Y[Q][1].end.offset-Y[Q][1].start.offset)M=2,q=$1(q,[["enter",Y[Q][1],Z],["exit",Y[Q][1],Z]]);else M=0;o(Y,X-1,Q-X+3,q),Q=X+q.length-M-2;break}}Q=-1;while(++Q0&&h(P)?k(Y,x,W.linePrefix,$+1)(P):x(P)}function x(P){if(P===H.eof||J(P))return Y.check(a2,I,m)(P);return Y.enter(W.codeFlowValue),S(P)}function S(P){if(P===H.eof||J(P))return Y.exit(W.codeFlowValue),x(P);return Y.consume(P),S}function m(P){return Y.exit(W.codeFenced),Z(P)}function E(P,y,a){let r=0;return z;function z(u){return _(J(u),"expected eol"),P.enter(W.lineEnding),P.consume(u),P.exit(W.lineEnding),X1}function X1(u){return _(X.parser.constructs.disable.null,"expected `disable.null` to be populated"),P.enter(W.codeFencedFence),h(u)?k(P,d,W.linePrefix,X.parser.constructs.disable.null.includes("codeIndented")?void 0:C.tabSize)(u):d(u)}function d(u){if(u===V)return P.enter(W.codeFencedFenceSequence),b(u);return a(u)}function b(u){if(u===V)return r++,P.consume(u),b;if(r>=K)return P.exit(W.codeFencedFenceSequence),h(u)?k(P,v,W.whitespace)(u):v(u);return a(u)}function v(u){if(u===H.eof||J(u))return P.exit(W.codeFencedFence),y(u);return a(u)}}}function x7(Y,Z,Q){let X=this;return G;function G(K){if(K===H.eof)return Q(K);return _(J(K),"expected eol"),Y.enter(W.lineEnding),Y.consume(K),Y.exit(W.lineEnding),$}function $(K){return X.parser.lazy[X.now().line]?Q(K):Z(K)}}var B0={name:"codeIndented",tokenize:v7},k7={partial:!0,tokenize:m7};function v7(Y,Z,Q){let X=this;return G;function G(q){return _(h(q)),Y.enter(W.codeIndented),k(Y,$,W.linePrefix,C.tabSize+1)(q)}function $(q){let M=X.events[X.events.length-1];return M&&M[1].type===W.linePrefix&&M[2].sliceSerialize(M[1],!0).length>=C.tabSize?K(q):Q(q)}function K(q){if(q===H.eof)return U(q);if(J(q))return Y.attempt(k7,K,U)(q);return Y.enter(W.codeFlowValue),V(q)}function V(q){if(q===H.eof||J(q))return Y.exit(W.codeFlowValue),K(q);return Y.consume(q),V}function U(q){return Y.exit(W.codeIndented),Z(q)}}function m7(Y,Z,Q){let X=this;return G;function G(K){if(X.parser.lazy[X.now().line])return Q(K);if(J(K))return Y.enter(W.lineEnding),Y.consume(K),Y.exit(W.lineEnding),G;return k(Y,$,W.linePrefix,C.tabSize+1)(K)}function $(K){let V=X.events[X.events.length-1];return V&&V[1].type===W.linePrefix&&V[2].sliceSerialize(V[1],!0).length>=C.tabSize?Z(K):J(K)?G(K):Q(K)}}var K5={name:"codeText",previous:d2,resolve:u7,tokenize:p7};function u7(Y){let Z=Y.length-4,Q=3,X,G;if((Y[Q][1].type===W.lineEnding||Y[Q][1].type==="space")&&(Y[Z][1].type===W.lineEnding||Y[Z][1].type==="space")){X=Q;while(++X=this.left.length+this.right.length)throw RangeError("Cannot access index `"+Y+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");if(Ythis.left.length)return this.right.slice(this.right.length-Q+this.left.length,this.right.length-Y+this.left.length).reverse();return this.left.slice(Y).concat(this.right.slice(this.right.length-Q+this.left.length).reverse())}splice(Y,Z,Q){let X=Z||0;this.setCursor(Math.trunc(Y));let G=this.right.splice(this.right.length-X,Number.POSITIVE_INFINITY);if(Q)z0(this.left,Q);return G.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(Y){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(Y)}pushMany(Y){this.setCursor(Number.POSITIVE_INFINITY),z0(this.left,Y)}unshift(Y){this.setCursor(0),this.right.push(Y)}unshiftMany(Y){this.setCursor(0),z0(this.right,Y.reverse())}setCursor(Y){if(Y===this.left.length||Y>this.left.length&&this.right.length===0||Y<0&&this.left.length===0)return;if(Y=C.tabSize)return Z(K);return Y.interrupt(X.parser.constructs.flow,Q,Z)(K)}}function m0(Y,Z,Q,X,G,$,K,V,U){let q=U||Number.POSITIVE_INFINITY,M=0;return F;function F(A){if(A===H.lessThan)return Y.enter(X),Y.enter(G),Y.enter($),Y.consume(A),Y.exit($),R;if(A===H.eof||A===H.space||A===H.rightParenthesis||v1(A))return Q(A);return Y.enter(X),Y.enter(K),Y.enter(V),Y.enter(W.chunkString,{contentType:C.contentTypeString}),I(A)}function R(A){if(A===H.greaterThan)return Y.enter($),Y.consume(A),Y.exit($),Y.exit(G),Y.exit(X),Z;return Y.enter(V),Y.enter(W.chunkString,{contentType:C.contentTypeString}),L(A)}function L(A){if(A===H.greaterThan)return Y.exit(W.chunkString),Y.exit(V),R(A);if(A===H.eof||A===H.lessThan||J(A))return Q(A);return Y.consume(A),A===H.backslash?j:L}function j(A){if(A===H.lessThan||A===H.greaterThan||A===H.backslash)return Y.consume(A),L;return L(A)}function I(A){if(!M&&(A===H.eof||A===H.rightParenthesis||l(A)))return Y.exit(W.chunkString),Y.exit(V),Y.exit(K),Y.exit(X),Z(A);if(MC.linkReferenceSizeMax||L===H.eof||L===H.leftSquareBracket||L===H.rightSquareBracket&&!U||L===H.caret&&!V&&"_hiddenFootnoteSupport"in K.parser.constructs)return Q(L);if(L===H.rightSquareBracket)return Y.exit($),Y.enter(G),Y.consume(L),Y.exit(G),Y.exit(X),Z;if(J(L))return Y.enter(W.lineEnding),Y.consume(L),Y.exit(W.lineEnding),M;return Y.enter(W.chunkString,{contentType:C.contentTypeString}),F(L)}function F(L){if(L===H.eof||L===H.leftSquareBracket||L===H.rightSquareBracket||J(L)||V++>C.linkReferenceSizeMax)return Y.exit(W.chunkString),M(L);if(Y.consume(L),!U)U=!h(L);return L===H.backslash?R:F}function R(L){if(L===H.leftSquareBracket||L===H.backslash||L===H.rightSquareBracket)return Y.consume(L),V++,F;return F(L)}}function p0(Y,Z,Q,X,G,$){let K;return V;function V(R){if(R===H.quotationMark||R===H.apostrophe||R===H.leftParenthesis)return Y.enter(X),Y.enter(G),Y.consume(R),Y.exit(G),K=R===H.leftParenthesis?H.rightParenthesis:R,U;return Q(R)}function U(R){if(R===K)return Y.enter(G),Y.consume(R),Y.exit(G),Y.exit(X),Z;return Y.enter($),q(R)}function q(R){if(R===K)return Y.exit($),U(K);if(R===H.eof)return Q(R);if(J(R))return Y.enter(W.lineEnding),Y.consume(R),Y.exit(W.lineEnding),k(Y,q,W.linePrefix);return Y.enter(W.chunkString,{contentType:C.contentTypeString}),M(R)}function M(R){if(R===K||R===H.eof||J(R))return Y.exit(W.chunkString),q(R);return Y.consume(R),R===H.backslash?F:M}function F(R){if(R===K||R===H.backslash)return Y.consume(R),M;return M(R)}}function u1(Y,Z){let Q;return X;function X(G){if(J(G))return Y.enter(W.lineEnding),Y.consume(G),Y.exit(W.lineEnding),Q=!0,X;if(h(G))return k(Y,X,Q?W.linePrefix:W.lineSuffix)(G);return Z(G)}}var V5={name:"definition",tokenize:n7},d7={partial:!0,tokenize:s7};function n7(Y,Z,Q){let X=this,G;return $;function $(L){return Y.enter(W.definition),K(L)}function K(L){return _(L===H.leftSquareBracket,"expected `[`"),u0.call(X,Y,V,Q,W.definitionLabel,W.definitionLabelMarker,W.definitionLabelString)(L)}function V(L){if(G=G1(X.sliceSerialize(X.events[X.events.length-1][1]).slice(1,-1)),L===H.colon)return Y.enter(W.definitionMarker),Y.consume(L),Y.exit(W.definitionMarker),U;return Q(L)}function U(L){return l(L)?u1(Y,q)(L):q(L)}function q(L){return m0(Y,M,Q,W.definitionDestination,W.definitionDestinationLiteral,W.definitionDestinationLiteralMarker,W.definitionDestinationRaw,W.definitionDestinationString)(L)}function M(L){return Y.attempt(d7,F,F)(L)}function F(L){return h(L)?k(Y,R,W.whitespace)(L):R(L)}function R(L){if(L===H.eof||J(L))return Y.exit(W.definition),X.parser.defined.push(G),Z(L);return Q(L)}}function s7(Y,Z,Q){return X;function X(V){return l(V)?u1(Y,G)(V):Q(V)}function G(V){return p0(Y,$,Q,W.definitionTitle,W.definitionTitleMarker,W.definitionTitleString)(V)}function $(V){return h(V)?k(Y,K,W.whitespace)(V):K(V)}function K(V){return V===H.eof||J(V)?Z(V):Q(V)}}var W5={name:"hardBreakEscape",tokenize:c7};function c7(Y,Z,Q){return X;function X($){return _($===H.backslash,"expected `\\`"),Y.enter(W.hardBreakEscape),Y.consume($),G}function G($){if(J($))return Y.exit(W.hardBreakEscape),Z($);return Q($)}}var q5={name:"headingAtx",resolve:o7,tokenize:t7};function o7(Y,Z){let Q=Y.length-2,X=3,G,$;if(Y[X][1].type===W.whitespace)X+=2;if(Q-2>X&&Y[Q][1].type===W.whitespace)Q-=2;if(Y[Q][1].type===W.atxHeadingSequence&&(X===Q-1||Q-4>X&&Y[Q-2][1].type===W.whitespace))Q-=X+1===Q?2:4;if(Q>X)G={type:W.atxHeadingText,start:Y[X][1].start,end:Y[Q][1].end},$={type:W.chunkText,start:Y[X][1].start,end:Y[Q][1].end,contentType:C.contentTypeText},o(Y,X,Q-X+1,[["enter",G,Z],["enter",$,Z],["exit",$,Z],["exit",G,Z]]);return Y}function t7(Y,Z,Q){let X=0;return G;function G(M){return Y.enter(W.atxHeading),$(M)}function $(M){return _(M===H.numberSign,"expected `#`"),Y.enter(W.atxHeadingSequence),K(M)}function K(M){if(M===H.numberSign&&X++1&&Y[Z-2][1].type===W.linePrefix)Y[Z][1].start=Y[Z-2][1].start,Y[Z+1][1].start=Y[Z-2][1].start,Y.splice(Z-2,2);return Y}function Q4(Y,Z,Q){let X=this,G,$,K,V,U;return q;function q(D){return M(D)}function M(D){return _(D===H.lessThan,"expected `<`"),Y.enter(W.htmlFlow),Y.enter(W.htmlFlowData),Y.consume(D),F}function F(D){if(D===H.exclamationMark)return Y.consume(D),R;if(D===H.slash)return Y.consume(D),$=!0,I;if(D===H.questionMark)return Y.consume(D),G=C.htmlInstruction,X.interrupt?Z:N;if(Y1(D))return _(D!==null),Y.consume(D),K=String.fromCharCode(D),w;return Q(D)}function R(D){if(D===H.dash)return Y.consume(D),G=C.htmlComment,L;if(D===H.leftSquareBracket)return Y.consume(D),G=C.htmlCdata,V=0,j;if(Y1(D))return Y.consume(D),G=C.htmlDeclaration,X.interrupt?Z:N;return Q(D)}function L(D){if(D===H.dash)return Y.consume(D),X.interrupt?Z:N;return Q(D)}function j(D){let W1=C.cdataOpeningString;if(D===W1.charCodeAt(V++)){if(Y.consume(D),V===W1.length)return X.interrupt?Z:d;return j}return Q(D)}function I(D){if(Y1(D))return _(D!==null),Y.consume(D),K=String.fromCharCode(D),w;return Q(D)}function w(D){if(D===H.eof||D===H.slash||D===H.greaterThan||l(D)){let W1=D===H.slash,w1=K.toLowerCase();if(!W1&&!$&&M5.includes(w1))return G=C.htmlRaw,X.interrupt?Z(D):d(D);if(n2.includes(K.toLowerCase())){if(G=C.htmlBasic,W1)return Y.consume(D),A;return X.interrupt?Z(D):d(D)}return G=C.htmlComplete,X.interrupt&&!X.parser.lazy[X.now().line]?Q(D):$?x(D):S(D)}if(D===H.dash||Z1(D))return Y.consume(D),K+=String.fromCharCode(D),w;return Q(D)}function A(D){if(D===H.greaterThan)return Y.consume(D),X.interrupt?Z:d;return Q(D)}function x(D){if(h(D))return Y.consume(D),x;return z(D)}function S(D){if(D===H.slash)return Y.consume(D),z;if(D===H.colon||D===H.underscore||Y1(D))return Y.consume(D),m;if(h(D))return Y.consume(D),S;return z(D)}function m(D){if(D===H.dash||D===H.dot||D===H.colon||D===H.underscore||Z1(D))return Y.consume(D),m;return E(D)}function E(D){if(D===H.equalsTo)return Y.consume(D),P;if(h(D))return Y.consume(D),E;return S(D)}function P(D){if(D===H.eof||D===H.lessThan||D===H.equalsTo||D===H.greaterThan||D===H.graveAccent)return Q(D);if(D===H.quotationMark||D===H.apostrophe)return Y.consume(D),U=D,y;if(h(D))return Y.consume(D),P;return a(D)}function y(D){if(D===U)return Y.consume(D),U=null,r;if(D===H.eof||J(D))return Q(D);return Y.consume(D),y}function a(D){if(D===H.eof||D===H.quotationMark||D===H.apostrophe||D===H.slash||D===H.lessThan||D===H.equalsTo||D===H.greaterThan||D===H.graveAccent||l(D))return E(D);return Y.consume(D),a}function r(D){if(D===H.slash||D===H.greaterThan||h(D))return S(D);return Q(D)}function z(D){if(D===H.greaterThan)return Y.consume(D),X1;return Q(D)}function X1(D){if(D===H.eof||J(D))return d(D);if(h(D))return Y.consume(D),X1;return Q(D)}function d(D){if(D===H.dash&&G===C.htmlComment)return Y.consume(D),c;if(D===H.lessThan&&G===C.htmlRaw)return Y.consume(D),t;if(D===H.greaterThan&&G===C.htmlDeclaration)return Y.consume(D),F1;if(D===H.questionMark&&G===C.htmlInstruction)return Y.consume(D),N;if(D===H.rightSquareBracket&&G===C.htmlCdata)return Y.consume(D),L1;if(J(D)&&(G===C.htmlBasic||G===C.htmlComplete))return Y.exit(W.htmlFlowData),Y.check(e7,B1,b)(D);if(D===H.eof||J(D))return Y.exit(W.htmlFlowData),b(D);return Y.consume(D),d}function b(D){return Y.check(Y4,v,B1)(D)}function v(D){return _(J(D)),Y.enter(W.lineEnding),Y.consume(D),Y.exit(W.lineEnding),u}function u(D){if(D===H.eof||J(D))return b(D);return Y.enter(W.htmlFlowData),d(D)}function c(D){if(D===H.dash)return Y.consume(D),N;return d(D)}function t(D){if(D===H.slash)return Y.consume(D),K="",U1;return d(D)}function U1(D){if(D===H.greaterThan){let W1=K.toLowerCase();if(M5.includes(W1))return Y.consume(D),F1;return d(D)}if(Y1(D)&&K.length=C.thematicBreakMarkerCountMin&&(q===H.eof||J(q)))return Y.exit(W.thematicBreak),Z(q);return Q(q)}function U(q){if(q===G)return Y.consume(q),X++,U;return Y.exit(W.thematicBreakSequence),h(q)?k(Y,V,W.whitespace)(q):V(q)}}var K1={continuation:{tokenize:T4},exit:P4,name:"list",tokenize:z4},j4={partial:!0,tokenize:A4},B4={partial:!0,tokenize:O4};function z4(Y,Z,Q){let X=this,G=X.events[X.events.length-1],$=G&&G[1].type===W.linePrefix?G[2].sliceSerialize(G[1],!0).length:0,K=0;return V;function V(L){_(X.containerState,"expected state");let j=X.containerState.type||(L===H.asterisk||L===H.plusSign||L===H.dash?W.listUnordered:W.listOrdered);if(j===W.listUnordered?!X.containerState.marker||L===X.containerState.marker:D0(L)){if(!X.containerState.type)X.containerState.type=j,Y.enter(j,{_container:!0});if(j===W.listUnordered)return Y.enter(W.listItemPrefix),L===H.asterisk||L===H.dash?Y.check(l1,Q,q)(L):q(L);if(!X.interrupt||L===H.digit1)return Y.enter(W.listItemPrefix),Y.enter(W.listItemValue),U(L)}return Q(L)}function U(L){if(_(X.containerState,"expected state"),D0(L)&&++Kh4,string:()=>g4,insideSpan:()=>x4,flowInitial:()=>y4,flow:()=>b4,document:()=>E4,disable:()=>v4,contentInitial:()=>w4,attentionMarkers:()=>k4});var E4={[H.asterisk]:K1,[H.plusSign]:K1,[H.dash]:K1,[H.digit0]:K1,[H.digit1]:K1,[H.digit2]:K1,[H.digit3]:K1,[H.digit4]:K1,[H.digit5]:K1,[H.digit6]:K1,[H.digit7]:K1,[H.digit8]:K1,[H.digit9]:K1,[H.greaterThan]:g0},w4={[H.leftSquareBracket]:V5},y4={[H.horizontalTab]:B0,[H.virtualSpace]:B0,[H.space]:B0},b4={[H.numberSign]:q5,[H.asterisk]:l1,[H.dash]:[l0,l1],[H.lessThan]:U5,[H.equalsTo]:l0,[H.underscore]:l1,[H.graveAccent]:k0,[H.tilde]:k0},g4={[H.ampersand]:x0,[H.backslash]:h0},h4={[H.carriageReturn]:T0,[H.lineFeed]:T0,[H.carriageReturnLineFeed]:T0,[H.exclamationMark]:L5,[H.ampersand]:x0,[H.asterisk]:j0,[H.lessThan]:[G5,F5],[H.leftSquareBracket]:R5,[H.backslash]:[W5,h0],[H.rightSquareBracket]:p1,[H.underscore]:j0,[H.graveAccent]:K5},x4={null:[j0,c2]},k4={null:[H.asterisk,H.underscore]},v4={null:[]};var $6=K2(K6(),1);var i1=$6.default("micromark");function H6(Y,Z,Q){let X={_bufferIndex:-1,_index:0,line:Q&&Q.line||1,column:Q&&Q.column||1,offset:Q&&Q.offset||0},G={},$=[],K=[],V=[],U=!0,q={attempt:r(y),check:r(a),consume:m,enter:E,exit:P,interrupt:r(a,{interrupt:!0})},M={code:H.eof,containerState:{},defineSkip:A,events:[],now:w,parser:Y,previous:H.eof,sliceSerialize:j,sliceStream:I,write:L},F=Z.tokenize.call(M,q),R;if(Z.resolveAll)$.push(Z);return M;function L(b){if(K=$1(K,b),x(),K[K.length-1]!==H.eof)return[];return z(Z,0),M.events=S1($,M.events,M),M.events}function j(b,v){return t4(I(b),v)}function I(b){return o4(K,b)}function w(){let{_bufferIndex:b,_index:v,line:u,column:c,offset:t}=X;return{_bufferIndex:b,_index:v,line:u,column:c,offset:t}}function A(b){G[b.line]=b.column,d(),i1("position: define skip: `%j`",X)}function x(){let b;while(X._index0,"expected non-empty string"),i1("enter: `%s`",b),M.events.push(["enter",u,M]),V.push(u),u}function P(b){_(typeof b==="string","expected string type"),_(b.length>0,"expected non-empty string");let v=V.pop();return _(v,"cannot close w/o open tokens"),v.end=w(),_(b===v.type,"expected exit token to match current token"),_(!(v.start._index===v.end._index&&v.start._bufferIndex===v.end._bufferIndex),"expected non-empty token (`"+b+"`)"),i1("exit: `%s`",v.type),M.events.push(["exit",v,M]),v}function y(b,v){z(b,v.from)}function a(b,v){v.restore()}function r(b,v){return u;function u(c,t,U1){let L1,N,F1,B1;return Array.isArray(c)?W1(c):("tokenize"in c)?W1([c]):D(c);function D(e){return q0;function q0(z1){let y1=z1!==null&&e[z1],n1=z1!==null&&e.null,o0=[...Array.isArray(y1)?y1:y1?[y1]:[],...Array.isArray(n1)?n1:n1?[n1]:[]];return W1(o0)(z1)}}function W1(e){if(L1=e,N=0,e.length===0)return _(U1,"expected `bogusState` to be given"),U1;return w1(e[N])}function w1(e){return q0;function q0(z1){if(B1=X1(),F1=e,!e.partial)M.currentConstruct=e;if(_(M.parser.constructs.disable.null,"expected `disable.null` to be populated"),e.name&&M.parser.constructs.disable.null.includes(e.name))return A0(z1);return e.tokenize.call(v?Object.assign(Object.create(M),v):M,q,c0,A0)(z1)}}function c0(e){return _(e===R,"expected code"),U=!0,b(F1,B1),t}function A0(e){if(_(e===R,"expected code"),U=!0,B1.restore(),++N-1,"expected non-negative end buffer index"),_(X>-1,"expected non-negative start buffer index"),K=[Y[Q].slice(X,$)];else{if(K=Y.slice(Q,G),X>-1){let V=K[0];if(typeof V==="string")K[0]=V.slice(X);else _(X===0,"expected `startBufferIndex` to be `0`"),K.shift()}if($>0)K.push(Y[G].slice(0,$))}return K}function t4(Y,Z){let Q=-1,X=[],G;while(++Q0){let H1=g.tokenStack[g.tokenStack.length-1];(H1[1]||U6).call(g,void 0,H1[0])}O.position={start:E1(T.length>0?T[0][1].start:{line:1,column:1,offset:0}),end:E1(T.length>0?T[T.length-2][1].end:{line:1,column:1,offset:0})},n=-1;while(++n0&&!Q)Y[Y.length-1][1]._gfmAutolinkLiteralWalkedInto=!0;return Q}var F9={tokenize:B9,partial:!0};function A5(){return{document:{[H.leftSquareBracket]:{name:"gfmFootnoteDefinition",tokenize:N9,continuation:{tokenize:D9},exit:j9}},text:{[H.leftSquareBracket]:{name:"gfmFootnoteCall",tokenize:_9},[H.rightSquareBracket]:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:L9,resolveTo:R9}}}}function L9(Y,Z,Q){let X=this,G=X.events.length,$=X.parser.gfmFootnotes||(X.parser.gfmFootnotes=[]),K;while(G--){let U=X.events[G][1];if(U.type===W.labelImage){K=U;break}if(U.type==="gfmFootnoteCall"||U.type===W.labelLink||U.type===W.label||U.type===W.image||U.type===W.link)break}return V;function V(U){if(_(U===H.rightSquareBracket,"expected `]`"),!K||!K._balanced)return Q(U);let q=G1(X.sliceSerialize({start:K.end,end:X.now()}));if(q.codePointAt(0)!==H.caret||!$.includes(q.slice(1)))return Q(U);return Y.enter("gfmFootnoteCallLabelMarker"),Y.consume(U),Y.exit("gfmFootnoteCallLabelMarker"),Z(U)}}function R9(Y,Z){let Q=Y.length,X;while(Q--)if(Y[Q][1].type===W.labelImage&&Y[Q][0]==="enter"){X=Y[Q][1];break}_(X,"expected `labelStart` to resolve"),Y[Q+1][1].type=W.data,Y[Q+3][1].type="gfmFootnoteCallLabelMarker";let G={type:"gfmFootnoteCall",start:Object.assign({},Y[Q+3][1].start),end:Object.assign({},Y[Y.length-1][1].end)},$={type:"gfmFootnoteCallMarker",start:Object.assign({},Y[Q+3][1].end),end:Object.assign({},Y[Q+3][1].end)};$.end.column++,$.end.offset++,$.end._bufferIndex++;let K={type:"gfmFootnoteCallString",start:Object.assign({},$.end),end:Object.assign({},Y[Y.length-1][1].start)},V={type:W.chunkString,contentType:"string",start:Object.assign({},K.start),end:Object.assign({},K.end)},U=[Y[Q+1],Y[Q+2],["enter",G,Z],Y[Q+3],Y[Q+4],["enter",$,Z],["exit",$,Z],["enter",K,Z],["enter",V,Z],["exit",V,Z],["exit",K,Z],Y[Y.length-2],Y[Y.length-1],["exit",G,Z]];return Y.splice(Q,Y.length-Q+1,...U),Y}function _9(Y,Z,Q){let X=this,G=X.parser.gfmFootnotes||(X.parser.gfmFootnotes=[]),$=0,K;return V;function V(F){return _(F===H.leftSquareBracket,"expected `[`"),Y.enter("gfmFootnoteCall"),Y.enter("gfmFootnoteCallLabelMarker"),Y.consume(F),Y.exit("gfmFootnoteCallLabelMarker"),U}function U(F){if(F!==H.caret)return Q(F);return Y.enter("gfmFootnoteCallMarker"),Y.consume(F),Y.exit("gfmFootnoteCallMarker"),Y.enter("gfmFootnoteCallString"),Y.enter("chunkString").contentType="string",q}function q(F){if($>C.linkReferenceSizeMax||F===H.rightSquareBracket&&!K||F===H.eof||F===H.leftSquareBracket||l(F))return Q(F);if(F===H.rightSquareBracket){Y.exit("chunkString");let R=Y.exit("gfmFootnoteCallString");if(!G.includes(G1(X.sliceSerialize(R))))return Q(F);return Y.enter("gfmFootnoteCallLabelMarker"),Y.consume(F),Y.exit("gfmFootnoteCallLabelMarker"),Y.exit("gfmFootnoteCall"),Z}if(!l(F))K=!0;return $++,Y.consume(F),F===H.backslash?M:q}function M(F){if(F===H.leftSquareBracket||F===H.backslash||F===H.rightSquareBracket)return Y.consume(F),$++,q;return q(F)}}function N9(Y,Z,Q){let X=this,G=X.parser.gfmFootnotes||(X.parser.gfmFootnotes=[]),$,K=0,V;return U;function U(j){return _(j===H.leftSquareBracket,"expected `[`"),Y.enter("gfmFootnoteDefinition")._container=!0,Y.enter("gfmFootnoteDefinitionLabel"),Y.enter("gfmFootnoteDefinitionLabelMarker"),Y.consume(j),Y.exit("gfmFootnoteDefinitionLabelMarker"),q}function q(j){if(j===H.caret)return Y.enter("gfmFootnoteDefinitionMarker"),Y.consume(j),Y.exit("gfmFootnoteDefinitionMarker"),Y.enter("gfmFootnoteDefinitionLabelString"),Y.enter("chunkString").contentType="string",M;return Q(j)}function M(j){if(K>C.linkReferenceSizeMax||j===H.rightSquareBracket&&!V||j===H.eof||j===H.leftSquareBracket||l(j))return Q(j);if(j===H.rightSquareBracket){Y.exit("chunkString");let I=Y.exit("gfmFootnoteDefinitionLabelString");return $=G1(X.sliceSerialize(I)),Y.enter("gfmFootnoteDefinitionLabelMarker"),Y.consume(j),Y.exit("gfmFootnoteDefinitionLabelMarker"),Y.exit("gfmFootnoteDefinitionLabel"),R}if(!l(j))V=!0;return K++,Y.consume(j),j===H.backslash?F:M}function F(j){if(j===H.leftSquareBracket||j===H.backslash||j===H.rightSquareBracket)return Y.consume(j),K++,M;return M(j)}function R(j){if(j===H.colon){if(Y.enter("definitionMarker"),Y.consume(j),Y.exit("definitionMarker"),!G.includes($))G.push($);return k(Y,L,"gfmFootnoteDefinitionWhitespace")}return Q(j)}function L(j){return Z(j)}}function D9(Y,Z,Q){return Y.check(D1,Z,Y.attempt(F9,Z,Q))}function j9(Y){Y.exit("gfmFootnoteDefinition")}function B9(Y,Z,Q){let X=this;return k(Y,G,"gfmFootnoteDefinitionIndent",C.tabSize+1);function G($){let K=X.events[X.events.length-1];return K&&K[1].type==="gfmFootnoteDefinitionIndent"&&K[2].sliceSerialize(K[1],!0).length===C.tabSize?Z($):Q($)}}function C5(Y){let Q=(Y||{}).singleTilde,X={name:"strikethrough",tokenize:$,resolveAll:G};if(Q===null||Q===void 0)Q=!0;return{text:{[H.tilde]:X},insideSpan:{null:[X]},attentionMarkers:{null:[H.tilde]}};function G(K,V){let U=-1;while(++U1)return U(j);return K.consume(j),F++,L}if(F<2&&!Q)return U(j);let w=K.exit("strikethroughSequenceTemporary"),A=X0(j);return w._open=!A||A===C.attentionSideAfter&&Boolean(I),w._close=!I||I===C.attentionSideAfter&&Boolean(A),V(j)}}}class I5{constructor(){this.map=[]}add(Y,Z,Q){z9(this,Y,Z,Q)}consume(Y){if(this.map.sort(function(G,$){return G[0]-$[0]}),this.map.length===0)return;let Z=this.map.length,Q=[];while(Z>0)Z-=1,Q.push(Y.slice(this.map[Z][0]+this.map[Z][1]),this.map[Z][2]),Y.length=this.map[Z][0];Q.push(Y.slice()),Y.length=0;let X=Q.pop();while(X){for(let G of X)Y.push(G);X=Q.pop()}this.map.length=0}}function z9(Y,Z,Q,X){let G=0;if(Q===0&&X.length===0)return;while(G-1){let v=X.events[X1][1].type;if(v===W.lineEnding||v===W.linePrefix)X1--;else break}let d=X1>-1?X.events[X1][1].type:null,b=d==="tableHead"||d==="tableRow"?P:U;if(b===P&&X.parser.lazy[X.now().line])return Q(z);return b(z)}function U(z){return Y.enter("tableHead"),Y.enter("tableRow"),q(z)}function q(z){if(z===H.verticalBar)return M(z);return K=!0,$+=1,M(z)}function M(z){if(z===H.eof)return Q(z);if(J(z)){if($>1)return $=0,X.interrupt=!0,Y.exit("tableRow"),Y.enter(W.lineEnding),Y.consume(z),Y.exit(W.lineEnding),L;return Q(z)}if(h(z))return k(Y,M,W.whitespace)(z);if($+=1,K)K=!1,G+=1;if(z===H.verticalBar)return Y.enter("tableCellDivider"),Y.consume(z),Y.exit("tableCellDivider"),K=!0,M;return Y.enter(W.data),F(z)}function F(z){if(z===H.eof||z===H.verticalBar||l(z))return Y.exit(W.data),M(z);return Y.consume(z),z===H.backslash?R:F}function R(z){if(z===H.backslash||z===H.verticalBar)return Y.consume(z),F;return F(z)}function L(z){if(X.interrupt=!1,X.parser.lazy[X.now().line])return Q(z);if(Y.enter("tableDelimiterRow"),K=!1,h(z))return _(X.parser.constructs.disable.null,"expected `disabled.null`"),k(Y,j,W.linePrefix,X.parser.constructs.disable.null.includes("codeIndented")?void 0:C.tabSize)(z);return j(z)}function j(z){if(z===H.dash||z===H.colon)return w(z);if(z===H.verticalBar)return K=!0,Y.enter("tableCellDivider"),Y.consume(z),Y.exit("tableCellDivider"),I;return E(z)}function I(z){if(h(z))return k(Y,w,W.whitespace)(z);return w(z)}function w(z){if(z===H.colon)return $+=1,K=!0,Y.enter("tableDelimiterMarker"),Y.consume(z),Y.exit("tableDelimiterMarker"),A;if(z===H.dash)return $+=1,A(z);if(z===H.eof||J(z))return m(z);return E(z)}function A(z){if(z===H.dash)return Y.enter("tableDelimiterFiller"),x(z);return E(z)}function x(z){if(z===H.dash)return Y.consume(z),x;if(z===H.colon)return K=!0,Y.exit("tableDelimiterFiller"),Y.enter("tableDelimiterMarker"),Y.consume(z),Y.exit("tableDelimiterMarker"),S;return Y.exit("tableDelimiterFiller"),S(z)}function S(z){if(h(z))return k(Y,m,W.whitespace)(z);return m(z)}function m(z){if(z===H.verticalBar)return j(z);if(z===H.eof||J(z)){if(!K||G!==$)return E(z);return Y.exit("tableDelimiterRow"),Y.exit("tableHead"),Z(z)}return E(z)}function E(z){return Q(z)}function P(z){return Y.enter("tableRow"),y(z)}function y(z){if(z===H.verticalBar)return Y.enter("tableCellDivider"),Y.consume(z),Y.exit("tableCellDivider"),y;if(z===H.eof||J(z))return Y.exit("tableRow"),Z(z);if(h(z))return k(Y,y,W.whitespace)(z);return Y.enter(W.data),a(z)}function a(z){if(z===H.eof||z===H.verticalBar||l(z))return Y.exit(W.data),y(z);return Y.consume(z),z===H.backslash?r:a}function r(z){if(z===H.backslash||z===H.verticalBar)return Y.consume(z),a;return a(z)}}function O9(Y,Z){let Q=-1,X=!0,G=0,$=[0,0,0,0],K=[0,0,0,0],V=!1,U=0,q,M,F,R=new I5;while(++QQ[2]+1){let j=Q[2]+1,I=Q[3]-Q[2]-1;Y.add(j,I,[])}}Y.add(Q[3]+1,0,[["exit",F,Z]])}if(G!==void 0)$.end=Object.assign({},V0(Z.events,G)),Y.add(G,0,[["exit",$,Z]]),$=void 0;return $}function P6(Y,Z,Q,X,G){let $=[],K=V0(Z.events,Q);if(G)G.end=Object.assign({},K),$.push(["exit",G,Z]);X.end=Object.assign({},K),$.push(["exit",X,Z]),Y.add(Q+1,0,$)}function V0(Y,Z){let Q=Y[Z],X=Q[0]==="enter"?"start":"end";return Q[1][X]}var P9={name:"tasklistCheck",tokenize:A9};function S5(){return{text:{[H.leftSquareBracket]:P9}}}function A9(Y,Z,Q){let X=this;return G;function G(U){if(_(U===H.leftSquareBracket,"expected `[`"),X.previous!==H.eof||!X._gfmTasklistFirstContentOfListItem)return Q(U);return Y.enter("taskListCheck"),Y.enter("taskListCheckMarker"),Y.consume(U),Y.exit("taskListCheckMarker"),$}function $(U){if(l(U))return Y.enter("taskListCheckValueUnchecked"),Y.consume(U),Y.exit("taskListCheckValueUnchecked"),K;if(U===H.uppercaseX||U===H.lowercaseX)return Y.enter("taskListCheckValueChecked"),Y.consume(U),Y.exit("taskListCheckValueChecked"),K;return Q(U)}function K(U){if(U===H.rightSquareBracket)return Y.enter("taskListCheckMarker"),Y.consume(U),Y.exit("taskListCheckMarker"),Y.exit("taskListCheck"),V;return Q(U)}function V(U){if(J(U))return Z(U);if(h(U))return Y.check({tokenize:C9},Z,Q)(U);return Q(U)}}function C9(Y,Z,Q){return k(Y,X,W.whitespace);function X(G){return G===H.eof?Q(G):Z(G)}}function A6(Y){return y0([O5(),A5(),C5(Y),J5(),S5()])}function E5(Y,Z){let Q=String(Y);if(typeof Z!=="string")throw TypeError("Expected character");let X=0,G=Q.indexOf(Z);while(G!==-1)X++,G=Q.indexOf(Z,G+Z.length);return X}function w5(Y){if(typeof Y!=="string")throw TypeError("Expected a string");return Y.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var W0=function(Y){if(Y===null||Y===void 0)return E9;if(typeof Y==="function")return a0(Y);if(typeof Y==="object")return Array.isArray(Y)?I9(Y):J9(Y);if(typeof Y==="string")return S9(Y);throw Error("Expected function, string, or object as test")};function I9(Y){let Z=[],Q=-1;while(++Q":""))+")"})}return R;function R(){let L=I6,j,I,w;if(!Z||$(U,q,M[M.length-1]||void 0)){if(L=y9(Q(U,M)),L[0]===y5)return L}if("children"in U&&U.children){let A=U;if(A.children&&L[0]!==S6){I=(X?A.children.length:-1)+K,w=M.concat(A);while(I>-1&&I0?{type:"text",value:P}:void 0;if(P===!1)R.lastIndex=m+1;else{if(j!==m)x.push({type:"text",value:q.value.slice(j,m)});if(Array.isArray(P))x.push(...P);else if(P)x.push(P);j=m+S[0].length,A=!0}if(!R.global)break;S=R.exec(q.value)}if(A){if(j?\]}]+$/.exec(Y);if(!Z)return[Y,void 0];Y=Y.slice(0,Z.index);let Q=Z[0],X=Q.indexOf(")"),G=E5(Y,"("),$=E5(Y,")");while(X!==-1&&G>$)Y+=Q.slice(0,X+1),Q=Q.slice(X+1),X=Q.indexOf(")"),$++;return[Y,Q]}function E6(Y,Z){let Q=Y.input.charCodeAt(Y.index-1);return(Y.index===0||N1(Q)||m1(Q))&&(!Z||Q!==47)}Q3.peek=Z3;function d9(){this.buffer()}function n9(Y){this.enter({type:"footnoteReference",identifier:"",label:""},Y)}function s9(){this.buffer()}function c9(Y){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},Y)}function o9(Y){let Z=this.resume(),Q=this.stack[this.stack.length-1];_(Q.type==="footnoteReference"),Q.identifier=G1(this.sliceSerialize(Y)).toLowerCase(),Q.label=Z}function t9(Y){this.exit(Y)}function e9(Y){let Z=this.resume(),Q=this.stack[this.stack.length-1];_(Q.type==="footnoteDefinition"),Q.identifier=G1(this.sliceSerialize(Y)).toLowerCase(),Q.label=Z}function Y3(Y){this.exit(Y)}function Z3(){return"["}function Q3(Y,Z,Q,X){let G=Q.createTracker(X),$=G.move("[^"),K=Q.enter("footnoteReference"),V=Q.enter("reference");return $+=G.move(Q.safe(Q.associationId(Y),{after:"]",before:$})),V(),K(),$+=G.move("]"),$}function k5(){return{enter:{gfmFootnoteCallString:d9,gfmFootnoteCall:n9,gfmFootnoteDefinitionLabelString:s9,gfmFootnoteDefinition:c9},exit:{gfmFootnoteCallString:o9,gfmFootnoteCall:t9,gfmFootnoteDefinitionLabelString:e9,gfmFootnoteDefinition:Y3}}}$3.peek=H3;function v5(){return{canContainEols:["delete"],enter:{strikethrough:G3},exit:{strikethrough:K3}}}function G3(Y){this.enter({type:"delete",children:[]},Y)}function K3(Y){this.exit(Y)}function $3(Y,Z,Q,X){let G=Q.createTracker(X),$=Q.enter("strikethrough"),K=G.move("~~");return K+=Q.containerPhrasing(Y,{...G.current(),before:K,after:"~"}),K+=G.move("~~"),$(),K}function H3(){return"~"}function u5(){return{enter:{table:W3,tableData:w6,tableHeader:w6,tableRow:M3},exit:{codeText:U3,table:q3,tableData:m5,tableHeader:m5,tableRow:m5}}}function W3(Y){let Z=Y._align;_(Z,"expected `_align` on table"),this.enter({type:"table",align:Z.map(function(Q){return Q==="none"?null:Q}),children:[]},Y),this.data.inTable=!0}function q3(Y){this.exit(Y),this.data.inTable=void 0}function M3(Y){this.enter({type:"tableRow",children:[]},Y)}function m5(Y){this.exit(Y)}function w6(Y){this.enter({type:"tableCell",children:[]},Y)}function U3(Y){let Z=this.resume();if(this.data.inTable)Z=Z.replace(/\\([\\|])/g,F3);let Q=this.stack[this.stack.length-1];_(Q.type==="inlineCode"),Q.value=Z,this.exit(Y)}function F3(Y,Z){return Z==="|"?Z:Y}function p5(){return{exit:{taskListCheckValueChecked:y6,taskListCheckValueUnchecked:y6,paragraph:R3}}}function y6(Y){let Z=this.stack[this.stack.length-2];_(Z.type==="listItem"),Z.checked=Y.type==="taskListCheckValueChecked"}function R3(Y){let Z=this.stack[this.stack.length-2];if(Z&&Z.type==="listItem"&&typeof Z.checked==="boolean"){let Q=this.stack[this.stack.length-1];_(Q.type==="paragraph");let X=Q.children[0];if(X&&X.type==="text"){let G=Z.children,$=-1,K;while(++$0)this.annotations.push({text:Y})}pushMarkup(Y,Z){this.annotations.push({markup:Y,interpretAs:Z})}extend(Y){for(let Z of Y.annotations)if("text"in Z)this.pushText(Z.text);else this.pushMarkup(Z.markup,Z.interpretAs)}optimize(){let Y=[];for(let Q of this.annotations){if("text"in Q&&Q.text.length===0||"markup"in Q&&Q.markup.length===0&&!Q.interpretAs)continue;let X=Y.at(-1);if(X===void 0)Y.push(Q);else if("text"in X&&"text"in Q)X.text+=Q.text;else if("markup"in X&&"markup"in Q){if(X.markup+=Q.markup,X.interpretAs&&Q.interpretAs)X.interpretAs+=Q.interpretAs;else if(Q.interpretAs)X.interpretAs=Q.interpretAs}else Y.push(Q)}for(let Q of Y)if("markup"in Q&&Q.interpretAs)Q.interpretAs=Q.interpretAs.replace(/\n{3,}/g,` `);for(let Q=Y.at(-1);Q&&"markup"in Q;Q=Y.at(-1))Y.pop();let Z=0;for(let Q=Y.at(0);Q&&"markup"in Q;Q=Y.at(0))Z+=Q.markup.length,Y.shift();return this.annotations=Y,Z}extractSlice(Y,Z){let Q=0;for(;Q=Z)return X.slice(Y,Z).trim()}return null}length(){return this.annotations.reduce((Y,Z)=>{if("text"in Z)return Y+Z.text.length;if("markup"in Z)return Y+Z.markup.length;return Y},0)}stringify(){return JSON.stringify({annotation:this.annotations})}}var d1={horizontalTab:-2,virtualSpace:-1,nul:0,eof:null,space:32,leftSquareBracket:91};function k6(Y){return Y!=null&&(YU.replace(/ /g,"_").toLowerCase(),Q;function X(U){Q={type:"wikiLink",children:[]},this.enter(Q,U)}function G(U){let q=U.at(-1);if(q&&q.type==="wikiLink")return q;throw Error("Expected wikiLink node")}function $(U){let q=this.sliceSerialize(U),M=G(this.stack);M.data={value:q,link:Z(q)},M.children=[{type:"text",value:q,position:{start:U.start,end:U.end}}]}function K(U){let q=this.sliceSerialize(U),M=G(this.stack);if(M.data!=null)M.data.value=q;M.children=[{type:"text",value:q,position:{start:U.start,end:U.end}}]}function V(U){this.exit(U)}return{enter:{wikiLink:X},exit:{wikiLinkTarget:$,wikiLinkAlias:K,wikiLink:V}}}var p6=/\\[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]/g;class n5{#Z;#Y;constructor(Y){this.#Z=Y,this.#Y=z5(Y,{extensions:[A6(),r5(["yaml"]),v6({aliasDivider:"|"})],mdastExtensions:[l5(),a5(["yaml"]),m6()]})}annotate(Y){let Z=new l6(this.#Z,Y);try{this.#Y.children.forEach((Q)=>Z.visitRoot(Q))}catch(Q){throw console.error(`Error while parsing markdown: `,JSON.stringify(this.#Y,void 0," ")),Q}return{offset:Z.output_start??0,annotations:Z.output}}isInside(Y,Z){function Q(X){let G=X?.position?.start.offset,$=X?.position?.end.offset;if(G==null||$==null)throw Error("Markdown parsing: unknown position for text node");if(G<=Y&&Y<$){if(X.type===Z)return!0;if("children"in X)return X.children.some((K)=>Q(K))}return!1}return this.#Y.children.some((X)=>Q(X))}}class l6{raw;output;output_start;output_end;offset;range;constructor(Y,Z){this.raw=Y,this.output=new n0,this.offset=0,this.range=Z}visitText(Y){let Z=Y?.position?.start.offset,Q=Y?.position?.end.offset;if(Z==null||Q==null)throw Error("Markdown parsing: unknown position for text node");let X=this.raw.slice(Z,Q);if(O3(X,Y.value,this.output),this.output.length()!==Q-(this.output_start||0))throw console.error("Invalid output length",this.output.length(),Q,JSON.stringify(Y,void 0," ")),Error("Markdown parsing: invalid output length");this.offset=Q}visitRoot(Y){if(Y.position==null)throw Error("Markdown parsing: unknown position");let Z=Y?.position?.start.offset,Q=Y?.position?.end.offset;if(Z==null||Q==null)throw Error("Markdown parsing: unknown position for text node");if(this.range&&P3(Y)){if(Q<=this.range.from-1)return;if(Z>=this.range.to+1)return;if(Z<=this.range.from&&this.range.from<=Q)this.output=new n0,this.offset=Z,this.output_start=this.offset,console.debug("Start from",this.output_start);if(Z<=this.range.to&&this.range.to<=Q)this.output_end=Q,console.debug("End at",this.output_end)}if(this.offsetthis.visitRoot(X));break;case"list":case"heading":Y.children.forEach((X)=>this.visitRoot(X)),this.output.pushMarkup("",` `);break;case"inlineCode":this.output.pushMarkup(s0(Z,Q),Y.value),this.offset=Q;break;case"break":this.output.pushMarkup(s0(Z,Q),` `),this.offset=Q;break;case"blockquote":case"paragraph":if(Y.children.length>0)Y.children.forEach((X)=>this.visitRoot(X)),this.output.pushMarkup("",` `);break;case"listItem":if(Y.children.length>0)this.output.pushMarkup("","• "),Y.children.forEach((X)=>this.visitRoot(X));break;case"link":case"wikiLink":if(Y.children)Y.children.forEach((X)=>this.visitRoot(X));else this.output.pushMarkup(s0(Z,Q),"DUMMY"),this.offset=Q;break;case"table":this.output.pushMarkup("",` `),Y.children.forEach((X)=>this.visitRoot(X));break;case"tableRow":Y.children.forEach((X)=>this.visitRoot(X)),this.output.pushMarkup("",` `);break;case"tableCell":Y.children.forEach((X)=>this.visitRoot(X)),this.output.pushMarkup("",` `);break;case"thematicBreak":this.output.pushMarkup(s0(Z,Q),` `),this.offset=Q;break}if(this.offsetthis.handleStatusBarClick(),this.setStatusBarReady(),this.registerEditorExtension(b2(this)),this.registerCommands(),this.registerMenuItems(),this.settings.options.injectProperties)this.injectProperties(!0);let Y=new Set(this.settings.options.dictionary.map((Z)=>Z.trim()));Y.delete(""),await this.settings.update({dictionary:[...Y].sort(Y0)}),await this.syncDictionary()}onunload(){this.logs=[],this.isLoading=!1}injectProperties(Y){let Z={"lt-language":"text","lt-picky":"checkbox","lt-autoCheck":"checkbox","lt-dictionary":"multitext","lt-disabledRules":"multitext","lt-disabledCategories":"multitext"};try{let Q=this.app.metadataTypeManager;for(let[X,G]of Object.entries(Z))if(Y)Q.setType(X,G);else Q.unsetType(X)}catch{console.error("Failed to set metadata types")}}registerCommands(){this.addCommand({id:"check",name:"Check text",icon:"spell-check",editorCallback:(Y,Z)=>{let Q=Y.cm;this.runDetection(Q).then((X)=>{if(!X)new Q1.Notice("No suggestions found.")},(X)=>console.error(X))}}),this.addCommand({id:"toggle-auto-check",name:"Toggle automatic checking",icon:"uppercase-lowercase-a",callback:async()=>{await this.settings.update({shouldAutoCheck:!this.settings.options.shouldAutoCheck})}}),this.addCommand({id:"clear",name:"Clear suggestions",icon:"cross",editorCallback:(Y)=>{Y.cm.dispatch({effects:[N0.of(null)]})}}),this.addCommand({id:"accept-all",name:"Accept all suggestions",icon:"circle-check-big",editorCallback:(Y)=>{let Z=Y.cm,Q=[],X=[];Z.state.field(P1).between(0,1/0,(G,$,K)=>{let V=K.spec.underline;if(V?.replacements?.length)Q.push({from:G,to:$,insert:V.replacements[0]}),X.push(_1.of({from:G,to:$}))}),Z.dispatch({changes:Q,effects:X})}}),this.addCommand({id:"next",name:"Jump to next suggestion",icon:"chevron-right",editorCheckCallback:(Y,Z)=>{let Q=Z.cm,X=Z.posToOffset(Z.getCursor()),G=null;if(Q.state.field(P1).between(X+1,1/0,($,K)=>{if(!G||G.from>$)G={from:$,to:K}}),Y)return G!=null;if(G!=null)Q.dispatch({selection:{anchor:G.from,head:G.to}})}});for(let Y=1;Y<=_0;Y++)this.addCommand(this.applySuggestionCommand(Y));this.addCommand({id:"synonyms",name:"Show synonyms",icon:"square-stack",editorCheckCallback:(Y,Z)=>this.showSynonyms(Z,Y)})}applySuggestionCommand(Y){return{id:`accept-${Y}`,name:`Accept suggestion ${Y}`,icon:"circle-check",editorCheckCallback(Z,Q){let X=Q.cm,G=Q.posToOffset(Q.getCursor()),$=[];if(X.state.field(P1).between(G,G,(R,L,j)=>{$.push({from:R,to:L,value:j})}),!$||$.length!==1)return!1;let{from:K,to:V,value:U}=$[0],q=U.spec.underline,M=q&&q.replacements.length>=Y;if(Z)return M;if(!M)return;let F={from:K,to:V,insert:q.replacements[Y-1]};X.dispatch({changes:[F],effects:[_1.of({from:K,to:V})]})}}}registerMenuItems(){this.registerEvent(this.app.workspace.on("editor-menu",(Y,Z,Q)=>{console.debug(Y);let X=Z.cm;if(this.populateSuggestionMenu(Y,X),this.showSynonyms(Z,!0))Y.addItem((G)=>{G.setTitle("Synonyms"),G.setIcon("square-stack"),G.setSection("spellcheck"),G.onClick(()=>this.showSynonyms(Z))})}))}populateSuggestionMenu(Y,Z){let Q=Z.state.field(P1),X=Z.state.selection.main,G=!1,$=Q.iter(X.from);while($.value!=null&&$.from<=X.to){G=!0;let K=$.value.spec.underline;Y.addItem((V)=>{V.setTitle(`LanguageTool (${K.text})`),V.setIcon("spell-check"),V.setSection("spellcheck");let U=V.setSubmenu();this.populateSuggestionSubmenu(U,K,$,Z)}),$.next()}return G}populateSuggestionSubmenu(Y,Z,Q,X){if(Z.message||Z.title)Y.addItem((G)=>{let $=new DocumentFragment;$.appendChild(createDiv({cls:"lt-menu-info"},(K)=>{if(Z.title)K.createDiv({text:Z.title,cls:"lt-menu-title"});if(Z.message)K.createDiv({text:Z.message,cls:"lt-menu-message"})})),G.setIsLabel(!0),G.setTitle($)}),Y.addSeparator();for(let G of Z.replacements.slice(0,_0))Y.addItem(($)=>{$.setTitle(G?JSON.stringify(G):"(delete)"),$.onClick(()=>{X.dispatch({changes:{...Q,insert:G},effects:[_1.of(Q)]})})});if(Y.addSeparator(),Z.categoryId==="TYPOS")Y.addItem((G)=>{G.setTitle("Add to dictionary"),G.setIcon("plus-with-circle"),G.onClick(async()=>{let $=[...this.settings.options.dictionary,Z.text.trim()];$.sort(Y0),await this.settings.update({dictionary:$}),await this.syncDictionary(),X.dispatch({effects:[x1.of((K)=>K.text===Z.text)]})})});else if(Y.addItem((G)=>{G.setTitle("Ignore suggestion"),G.setIcon("cross"),G.onClick(()=>{X.dispatch({effects:[_1.of(Q)]})})}),Z.ruleId&&Z.ruleId!=="SYNONYMS")Y.addItem((G)=>{G.setTitle("Disable rule"),G.setIcon("circle-off"),G.onClick(async()=>{let K=this.settings.options.disabledRules;if(K)K+=","+Z.ruleId;else K=Z.ruleId;await this.settings.update({disabledRules:K}),X.dispatch({effects:[x1.of((V)=>V.ruleId===Z.ruleId)]})});let $=G.dom;Q1.setTooltip($,`${Z.categoryId} > ${Z.ruleId}`)})}showSynonyms(Y,Z=!1){if(!this.settings.options.synonyms||!(this.settings.options.synonyms in o1))return!1;let Q=o1[this.settings.options.synonyms];if(!Q)return!1;let X=Y.cm,G=X.state.selection.main;if(G.empty)return!1;let $=X.state.sliceDoc(X.state.selection.main.from,X.state.selection.main.to);if($.match(/[\s.]/))return!1;if(Z)return!0;let K=X.state.doc.lineAt(G.from),V=K.text.slice(0,G.from-K.from).lastIndexOf(".")+1,U=K.text.slice(V),q=U.trimStart(),M=K.from+V+U.length-q.length,F={from:G.from-M,to:G.to-M};q=q.trimEnd();let R=q.indexOf(".");if(R!==-1)q=q.slice(0,R+1);return Q.query(q,F).then((L)=>X.dispatch({effects:[E0.of({text:$,range:G,title:"Synonyms",message:"",categoryId:"SYNONYMS",ruleId:"SYNONYMS",replacements:L})]}),(L)=>{let j=L;console.error(j),this.pushLogs(j),new Q1.Notice(j.message,30000)}),!0}setStatusBarReady(){this.isLoading=!1,Q1.setIcon(this.statusBarItem,"spell-check")}setStatusBarWorking(){if(this.isLoading)return;this.isLoading=!0,Q1.setIcon(this.statusBarItem,"sync-small")}handleStatusBarClick(){let Y=this.statusBarItem.getBoundingClientRect(),Z=this.statusBarItem.getBoundingClientRect();new Q1.Menu().addItem((Q)=>{Q.setTitle("Check text"),Q.setIcon("spell-check"),Q.onClick(async()=>{let X=this.app.workspace.getActiveViewOfType(Q1.MarkdownView);if(X&&X.getMode()==="source"){let G=X.editor.cm;if(!await this.runDetection(G))new Q1.Notice("No suggestions found.")}})}).addItem((Q)=>{Q.setTitle(this.settings.options.shouldAutoCheck?"Disable automatic checking":"Enable automatic checking"),Q.setIcon("uppercase-lowercase-a"),Q.onClick(async()=>{await this.settings.update({shouldAutoCheck:!this.settings.options.shouldAutoCheck})})}).addItem((Q)=>{Q.setTitle("Clear suggestions"),Q.setIcon("cross"),Q.onClick(()=>{let X=this.app.workspace.getActiveViewOfType(Q1.MarkdownView);if(!X)return;X.editor.cm.dispatch({effects:[N0.of(null)]})})}).showAtPosition({x:Z.right+5,y:(Y?.top||0)-5})}getActiveFileSettings(){let Y=this.app.workspace.getActiveFile(),Z=Y&&this.app.metadataCache.getFileCache(Y);if(Z?.frontmatter!=null){let Q=Z.frontmatter["lt-language"]??Z.frontmatter.lt_language,X=Z.frontmatter["lt-picky"],G=Z.frontmatter["lt-autoCheck"],$=Z.frontmatter["lt-dictionary"],K=Z.frontmatter["lt-disabledRules"],V=Z.frontmatter["lt-disabledCategories"],U={...this.settings.options};if(typeof Q==="string")U.staticLanguage=Q;if(typeof G==="boolean")U.shouldAutoCheck=G;if(typeof X==="boolean")U.pickyMode=X;if(Array.isArray($))U.dictionary=$;if(Array.isArray(K)&&K.length)U.disabledRules+=","+K.join(",");if(Array.isArray(V)&&V.length)U.disabledCategories+=","+V.join(",");return U}return this.settings.options}async runDetection(Y,Z=!1,Q){let X=this.getActiveFileSettings(),G=Y.state.selection.main;if(!Q&&!G.empty)Q={...G};let $=Y.state,K=$.doc,V=$.sliceDoc();if(!V.trim())return!1;let U,q=void 0,M;try{this.setStatusBarWorking(),M=new n5(V);let{offset:R,annotations:L}=M.annotate(Q);if(R+=L.optimize(),L.length()===0)return!1;if(X.longCheckNotification&&!Z&&L.length()>500)q=new Q1.Notice("Checking spelling...",30000);if(console.debug(`Checking ${L.length()} characters...`),U=await F2(X,R,L),Q)Q={from:R,to:R+L.length()}}catch(R){if(console.error(R),R instanceof Error){if(this.pushLogs(R),!Z)new Q1.Notice(R.message,30000)}if(Z)throw R;return!0}finally{if(this.setStatusBarReady(),q)q.hide()}if(K!==Y.state.doc)return!0;let F=[];if(Q)F.push(_1.of(Q));else F.push(N0.of(null));if(U){let R=X.dictionary;for(let L of U){if(L.range.to>Y.state.doc.length)continue;if(L.categoryId==="TYPOS"&&R.includes(L.text))continue;if(L.categoryId==="WHITESPACE"&&(M.isInside(L.range.from,"table")||M.isInside(L.range.to,"table")))continue;F.push(E0.of(L))}}if(F.length)Y.dispatch({effects:F});return console.debug(`Found ${F.length-1} suggestions.`),this.autoCheckSuppressErrorsUntil=0,F.length>1}pushLogs(Y){let Z=`${new Date().toLocaleString()}: Error: '${Y.message}' Settings: ${JSON.stringify({...this.settings,username:"REDACTED",apikey:"REDACTED"})} `;if(this.logs.push(Z),this.logs.length>10)this.logs.shift()}async onExternalSettingsChange(){await this.settings.load(),await this.settingTab.notifyEndpointChange(this.settings.options)}async syncDictionary(){if(!this.settings.options.syncDictionary||g1(this.settings.options.serverUrl)!=="premium")return;try{let Y=new Set(this.settings.options.remoteDictionary),Z=new Set(this.settings.options.dictionary),Q=new Set(await R2(this.settings.options)),X=e1(Y,Z);X=T2(X,Q);for(let U of X)await N2(this.settings.options,U);let G=e1(Y,Q);Q=e1(Q,X),Z=e1(Z,G);let $=e1(Z,Q);for(let U of $)await _2(this.settings.options,U);let V=[...z2(Q,Z)].sort(Y0);await this.settings.update({dictionary:V,remoteDictionary:V})}catch(Y){let Z=Y;this.pushLogs(Z),new Q1.Notice(Z.message,30000),console.error("Failed sync spellcheck with LanguageTool",Y)}}} /* nosourcemap */