var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};var{existsSync:t,lstatSync:n}=require("fs"),{ipcRenderer:r}=require("electron"),o={};Object.defineProperty(o,"__esModule",{value:!0});var i=async function(e,t,n){const r=new WeakMap;switch(n.diffMethod){case"heuristic":_((()=>function(e,t,n){let r=0;function o(t,n){let i=t.firstChild,a=n.firstChild;const s=t.childNodes.length,l=n.childNodes.length;if(s>l)for(;a&&i;){if(J(i,a)){if(i.nodeType===Node.ELEMENT_NODE){const t=r.toString(36);e.set(a,t),e.set(i,t),r++}o(i,a),a=a.nextSibling}i=i.nextSibling}else if(s<l)for(;a&&i;){if(J(i,a)){if(i.nodeType===Node.ELEMENT_NODE){const t=r.toString(36);e.set(a,t),e.set(i,t),r++}o(i,a),i=i.nextSibling}a=a.nextSibling}}o(t,n)}(r,t,e)));break;case"myers":{const n=_((()=>Array.from(q(e)))),o=_((()=>Array.from(q(t))));let i=0,a=0;_((()=>(0,S.diff)(n,o,((e,t)=>(i++,J(e,t))),(e=>{for(const[t,n]of e){const e=a.toString(36);r.set(t,e),r.set(n,e),a++}})))),console.log("a:",n.length,"b:",o.length,"comp:",i);break}}try{(0,E.default)(e,t,{childrenOnly:!0,onBeforeElUpdated:function(e,t){if(e.isEqualNode(t))return!1;const n=k(e,t);return!n||(n[0].textContent!==n[1].textContent&&(n[0].textContent=n[1].textContent),!1)},getNodeKey:function(e){return r.get(e)||""}})}catch(n){console.error(n),e.innerHTML=t.innerHTML}n.renderLaTeX&&await n.mjController.queueTypeset(e)};o.update=i;var a,s={};var l="undefined"==typeof document?void 0:document,d=!!l&&"content"in l.createElement("template"),c=!!l&&l.createRange&&"createContextualFragment"in l.createRange();function u(e){return e=e.trim(),d?function(e){var t=l.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}(e):c?function(e){return a||(a=l.createRange()).selectNode(l.body),a.createContextualFragment(e).childNodes[0]}(e):function(e){var t=l.createElement("body");return t.innerHTML=e,t.childNodes[0]}(e)}function f(e,t){var n,r,o=e.nodeName,i=t.nodeName;return o===i||(n=o.charCodeAt(0),r=i.charCodeAt(0),n<=90&&r>=97?o===i.toUpperCase():r<=90&&n>=97&&i===o.toUpperCase())}function p(e,t,n){e[n]!==t[n]&&(e[n]=t[n],e[n]?e.setAttribute(n,""):e.removeAttribute(n))}var m={OPTION:function(e,t){var n=e.parentNode;if(n){var r=n.nodeName.toUpperCase();"OPTGROUP"===r&&(r=(n=n.parentNode)&&n.nodeName.toUpperCase()),"SELECT"!==r||n.hasAttribute("multiple")||(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),n.selectedIndex=-1)}p(e,t,"selected")},INPUT:function(e,t){p(e,t,"checked"),p(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var n=t.value;e.value!==n&&(e.value=n);var r=e.firstChild;if(r){var o=r.nodeValue;if(o==n||!n&&o==e.placeholder)return;r.nodeValue=n}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var n,r,o=-1,i=0,a=e.firstChild;a;)if("OPTGROUP"===(r=a.nodeName&&a.nodeName.toUpperCase()))a=(n=a).firstChild;else{if("OPTION"===r){if(a.hasAttribute("selected")){o=i;break}i++}!(a=a.nextSibling)&&n&&(a=n.nextSibling,n=null)}e.selectedIndex=o}}};function h(){}function y(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}var v,g,b,w,N,x=(v=function(e,t){var n,r,o,i,a=t.attributes;if(11!==t.nodeType&&11!==e.nodeType){for(var s=a.length-1;s>=0;s--)r=(n=a[s]).name,o=n.namespaceURI,i=n.value,o?(r=n.localName||r,e.getAttributeNS(o,r)!==i&&("xmlns"===n.prefix&&(r=n.name),e.setAttributeNS(o,r,i))):e.getAttribute(r)!==i&&e.setAttribute(r,i);for(var l=e.attributes,d=l.length-1;d>=0;d--)r=(n=l[d]).name,(o=n.namespaceURI)?(r=n.localName||r,t.hasAttributeNS(o,r)||e.removeAttributeNS(o,r)):t.hasAttribute(r)||e.removeAttribute(r)}},function(e,t,n){if(n||(n={}),"string"==typeof t)if("#document"===e.nodeName||"HTML"===e.nodeName||"BODY"===e.nodeName){var r=t;(t=l.createElement("html")).innerHTML=r}else t=u(t);var o=n.getNodeKey||y,i=n.onBeforeNodeAdded||h,a=n.onNodeAdded||h,s=n.onBeforeElUpdated||h,d=n.onElUpdated||h,c=n.onBeforeNodeDiscarded||h,p=n.onNodeDiscarded||h,g=n.onBeforeElChildrenUpdated||h,b=!0===n.childrenOnly,w=Object.create(null),N=[];function x(e){N.push(e)}function M(e,t){if(1===e.nodeType)for(var n=e.firstChild;n;){var r=void 0;t&&(r=o(n))?x(r):(p(n),n.firstChild&&M(n,t)),n=n.nextSibling}}function E(e,t,n){!1!==c(e)&&(t&&t.removeChild(e),p(e),M(e,n))}function S(e){a(e);for(var t=e.firstChild;t;){var n=t.nextSibling,r=o(t);if(r){var i=w[r];i&&f(t,i)?(t.parentNode.replaceChild(i,t),T(i,t)):S(t)}else S(t);t=n}}function T(e,t,n){var r=o(t);if(r&&delete w[r],!n){if(!1===s(e,t))return;if(v(e,t),d(e),!1===g(e,t))return}"TEXTAREA"!==e.nodeName?function(e,t){var n,r,a,s,d,c=t.firstChild,u=e.firstChild;e:for(;c;){for(s=c.nextSibling,n=o(c);u;){if(a=u.nextSibling,c.isSameNode&&c.isSameNode(u)){c=s,u=a;continue e}r=o(u);var p=u.nodeType,h=void 0;if(p===c.nodeType&&(1===p?(n?n!==r&&((d=w[n])?a===d?h=!1:(e.insertBefore(d,u),r?x(r):E(u,e,!0),u=d):h=!1):r&&(h=!1),(h=!1!==h&&f(u,c))&&T(u,c)):3!==p&&8!=p||(h=!0,u.nodeValue!==c.nodeValue&&(u.nodeValue=c.nodeValue))),h){c=s,u=a;continue e}r?x(r):E(u,e,!0),u=a}if(n&&(d=w[n])&&f(d,c))e.appendChild(d),T(d,c);else{var y=i(c);!1!==y&&(y&&(c=y),c.actualize&&(c=c.actualize(e.ownerDocument||l)),e.appendChild(c),S(c))}c=s,u=a}!function(e,t,n){for(;t;){var r=t.nextSibling;(n=o(t))?x(n):E(t,e,!0),t=r}}(e,u,r);var v=m[e.nodeName];v&&v(e,t)}(e,t):m.TEXTAREA(e,t)}!function e(t){if(1===t.nodeType||11===t.nodeType)for(var n=t.firstChild;n;){var r=o(n);r&&(w[r]=n),e(n),n=n.nextSibling}}(e);var C,A,L=e,P=L.nodeType,O=t.nodeType;if(!b)if(1===P)1===O?f(e,t)||(p(e),L=function(e,t){for(var n=e.firstChild;n;){var r=n.nextSibling;t.appendChild(n),n=r}return t}(e,(C=t.nodeName,(A=t.namespaceURI)&&"http://www.w3.org/1999/xhtml"!==A?l.createElementNS(A,C):l.createElement(C)))):L=t;else if(3===P||8===P){if(O===P)return L.nodeValue!==t.nodeValue&&(L.nodeValue=t.nodeValue),L;L=t}if(L===t)p(e);else{if(t.isSameNode&&t.isSameNode(L))return;if(T(L,t,b),N)for(var k=0,I=N.length;k<I;k++){var J=w[N[k]];J&&E(J,J.parentNode,!1)}}return!b&&L!==e&&e.parentNode&&(L.actualize&&(L=L.actualize(e.ownerDocument||l)),e.parentNode.replaceChild(L,e)),L});g=s,b="default",w=function(){return x},Object.defineProperty(g,b,{get:w,enumerable:!0}),N=s,Object.defineProperty(N,"__esModule",{value:!0});var M,E=(M=s)&&M.__esModule?M:{default:M},S={};Object.defineProperty(S,"__esModule",{value:!0});var T=function(e,t,n,r){const o=[];(function e(t,r,i=0,a=0){const[s,l,d,c]=[t.length,r.length,t.length+r.length,2*Math.min(t.length,r.length)+2];if(s>0&&l>0){const[u,f,p]=[s-l,Array(c).fill(0),Array(c).fill(0)];for(let m=0;m<d/2+d%2+1;m++)for(let h=0;h<2;h++){const[y,v,g,b]=0===h?[f,p,1,1]:[p,f,0,-1];for(let f=-(m-2*Math.max(0,m-l));f<m-2*Math.max(0,m-s)+1;f+=2){let p=f===-m||f!==m&&y[(f-1)%c]<y[(f+1)%c]?y[(f+1)%c]:y[(f-1)%c]+1,h=p-f;const[w,N]=[p,h];for(;p<s&&h<l&&n(t[(1-g)*s+b*p+(g-1)],r[(1-g)*l+b*h+(g-1)]);)p++,h++;y[f%c]=p;const x=-(f-u);if(d%2===g&&x>=-(m-g)&&x<=m-g&&y[f%c]+v[x%c]>=s){const[n,d,c,u,f]=1===g?[2*m-1,w,N,p,h]:[2*m,s-p,l-h,s-w,l-N];if(n>1||d!==u&&c!==f)return d!==u&&c!==f&&o.push([t.slice(d,u),r.slice(c,f)]),e(t.slice(0,d),r.slice(0,c),i,a),void e(t.slice(u,s),r.slice(f,l),i+u,a+f);if(l>s)return void o.push([t.slice(0,s),r.slice(0,s)]);if(l<s)return void o.push([t.slice(0,l),r.slice(0,l)])}}}}})(Array.from(e),Array.from(t)),r(function*(e){for(const[t,n]of e)yield*(0,C.zip)(t,n)}(o))};S.diff=T;var C={};Object.defineProperty(C,"__esModule",{value:!0});var A=function(e){if(!e)return;e.catch((e=>{console.error(e)}))};C.handlePromise=A;var L=function(e){return!!t(e)&&n(e).isFile()};C.isFileSync=L;var P=function(e,t){let n=e;for(const e of t){const t=n.querySelectorAll(`:scope > ${e.tag}`).item(e.index);if(!t)break;n=t}return n===e?void 0:n};C.resolveElement=P;var O=function*(e,t){const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let o=n.next(),i=r.next();for(;!o.done&&!i.done;)yield[o.value,i.value],o=n.next(),i=r.next()};function k(e,t){if(!I(e)||!I(t))return!1;if("SPAN"!==e.tagName||"SPAN"!==t.tagName||!e.classList.contains("math")||!t.classList.contains("math"))return!1;const n=e.querySelector(":scope > script");if(!n)return!1;const r=t.querySelector(":scope > script");return!!r&&(n.type===r.type&&[n,r])}function I(e){return e.nodeType===Node.ELEMENT_NODE}function J(e,t){if(e.isEqualNode(t))return!0;if(function(e,t){const n=k(e,t);return n&&n[0].textContent===n[1].textContent}(e,t))return!0;if(e.nodeType!==t.nodeType)return!1;if(e.childNodes.length!==t.childNodes.length)return!1;let n=e.firstChild,r=t.firstChild;for(;n&&r;){if(!J(n,r))return!1;n=n.nextSibling,r=r.nextSibling}switch(e.nodeType){case Node.DOCUMENT_TYPE_NODE:return function(e,t){return e.name===t.name&&e.publicId===t.publicId&&e.systemId===t.systemId}(e,t);case Node.ELEMENT_NODE:return function(e,t){return e.attributes.length===t.attributes.length&&Array.from(e.attributes).every((e=>e.isEqualNode(t.attributes.getNamedItemNS(e.namespaceURI,e.localName))))}(e,t);case Node.ATTRIBUTE_NODE:return function(e,t){return e.namespaceURI===t.namespaceURI&&e.localName===t.localName&&e.value===t.value}(e,t);case Node.PROCESSING_INSTRUCTION_NODE:return function(e,t){return e.target===t.target&&e.data===t.data}(e,t);case Node.TEXT_NODE:case Node.COMMENT_NODE:return function(e,t){return e.data===t.data}(e,t);default:return!0}}function*q(e){for(const t of e.children)"SPAN"===t.tagName&&t.classList.contains("MathJax")||"SPAN"===t.tagName&&t.classList.contains("MathJax_SVG")||"SCRIPT"!==t.tagName&&("DIV"===t.tagName&&t.classList.contains("MathJax_Display")||"DIV"===t.tagName&&t.classList.contains("MathJax_SVG_Display")||(yield t,"PRE"===t.tagName&&t.classList.contains("editor-colors")||(yield*q(t))))}function _(e){const t=performance.now(),n=e();return console.log(e.toString(),performance.now()-t,"ms"),n}C.zip=O;var H={};Object.defineProperty(H,"__esModule",{value:!0});var j=function(e){const t=document.getElementById("MathJax_SVG_Hidden"),n=t&&t.parentElement;return null!==n?n.outerHTML+e.innerHTML:e.innerHTML};H.processHTMLString=j;var R=void 0;H.MathJaxController=R;class D{constructor(e,t){this.userMacros=e,this.mathJaxConfig=t,this.readyPromise=this.attachMathJax()}static async create(e,t){const n=new D(e,t);return await n.readyPromise,n}dispose(){const e=document.head.querySelector(`script[src='${D.mjSrc}']`);e&&e.remove()}jaxTeXConfig(){return{extensions:this.mathJaxConfig.texExtensions,Macros:this.userMacros,equationNumbers:this.mathJaxConfig.numberEquations?{autoNumber:"AMS",useLabelIds:!1}:{}}}async queueTypeset(e){const t=Array.from(e.querySelectorAll('span.math > script[type^="math/tex"]'));if(0!==t.filter((e=>{const t=MathJax.Hub.getJaxFor(e);try{return!t||e.id!==t.inputID||t.needsUpdate()}catch(e){return console.error(e),!0}})).length)return new Promise((e=>{MathJax.InputJax.TeX&&MathJax.Hub.Queue(["resetEquationNumbers",MathJax.InputJax.TeX]);const{temps:n,spans:r}=this.setupTemps(t);MathJax.Hub.Queue(["PreProcess",MathJax.Hub,n]),MathJax.Hub.Queue(["Reprocess",MathJax.Hub,n]),MathJax.Hub.Queue((()=>this.cleanupTemps(n,r))),MathJax.Hub.Queue([e])}))}cleanupTemps(e,t){for(const e of t)e.remove();for(const t of e)t.style.visibility="",t.style.position="",t.style.width="",t.style.display="",t.classList.remove("temp-MathJax")}setupTemps(e){const t=[],n=[];for(const r of e){const e=r.parentElement;if(!e)continue;const o=e.parentElement;if(!o)continue;const i=r.previousElementSibling;if(i){const a=e.cloneNode(!1);a.classList.add("temp-MathJax"),a.appendChild(r.cloneNode(!0)),t.push(a),n.push(e),o.insertBefore(a,e),a.style.visibility="hidden",a.style.position="absolute",r.type.includes("display")&&(a.style.width=window.getComputedStyle(i).width,a.style.display="block")}else t.push(e)}return{temps:t,spans:n}}async attachMathJax(){await async function(e){const t=document.createElement("script");return t.src=e,t.type="text/javascript",document.head.appendChild(t),new Promise((e=>{t.addEventListener("load",(()=>e()))}))}(D.mjSrc),MathJax.Hub.Config({jax:["input/TeX",`output/${this.mathJaxConfig.latexRenderer}`],extensions:[],TeX:this.jaxTeXConfig(),"HTML-CSS":{availableFonts:[],webFont:"TeX",imageFont:null,undefinedFamily:this.mathJaxConfig.undefinedFamily,mtextFontInherit:!0},messageStyle:"none",showMathMenu:!1,skipStartupTypeset:!0}),MathJax.Hub.Configured()}}R=D,H.MathJaxController=R,function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(D,"mjSrc",`${e.require.resolve("mathjax")}?delayStartupUntil=configured`);var U=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=K(t);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}r.default=e,n&&n.set(e,r);return r}(C),B={};Object.defineProperty(B,"__esModule",{value:!0});var V=function(e){return e.querySelectorAll("img[src],audio[src],video[src],link[href]")};function K(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(K=function(e){return e?n:t})(e)}let X;B.getMedia=V;let F=!1;function $(e){r.send("atom-markdown-preview-plus-ipc-uncaught-error",X,{message:e.message,name:e.name,stack:e.stack})}window.addEventListener("error",(e=>{$(e.error)})),window.addEventListener("unhandledrejection",(e=>{$(e.reason)}));const z={mathJax:function(){let e;const t=new Promise((t=>e=t));return t.resolve=e,t}(),sourceLineMap:new Map,revSourceMap:new WeakMap};function W({firstLine:e,lastLine:t}){if(0===e)return void window.scroll({top:0});const n=z.sourceLineMap,r=Array.from(n.keys()).sort(((e,t)=>e-t));let o=r.findIndex((t=>t>=e));o>0&&o--;let i=r.findIndex((e=>e>=t));-1===i?i=r.length-1:i<r.length-1&&i++;const a=r[o],s=r[i];let l=0,d=0;const c=Array.from(n.entries()).slice(o,i+1);for(const[e,t]of c){const n=e<=(s+a)/2?e-a+1:s-e+1;l+=n,d+=t.getBoundingClientRect().top*n}if(0===l)return;const u=document.documentElement.scrollTop-document.documentElement.clientHeight/2+d/l;window.scroll({top:u})}let G,Q;async function Y({id:e,html:t,renderLaTeX:n,map:i,diffMethod:a,scrollSyncParams:s}){const l=document.querySelector("div.update-preview");if(!l)return;const d=(new DOMParser).parseFromString(t,"text/html"),c=document;if(c&&d.head.hasChildNodes()){let e=c.head.querySelector("original-elements");e||(e=c.createElement("original-elements"),c.head.insertBefore(e,c.head.firstElementChild)),e.innerHTML="";for(const t of Array.from(d.head.childNodes))e.appendChild(t)}const u=s?void 0:Array.from(l.children).map((e=>({el:e,r:e.getBoundingClientRect()}))).filter((({r:e})=>e.top<=window.innerHeight&&e.bottom>=0));if(await(0,o.update)(l,d.body,{renderLaTeX:n,diffMethod:a,mjController:await z.mathJax}),u){const e=u.filter((({el:e})=>e.offsetParent)),t=e[e.length-1];t&&window.scrollBy({top:t.el.getBoundingClientRect().bottom-t.r.bottom})}if(i){const e=new Map,t=new WeakMap;for(const[n,r]of Object.entries(i)){const o=parseInt(n,10),i=U.resolveElement(l,r);if(i){e.set(o,i);const n=t.get(i);n?n.push(o):t.set(i,[o])}}z.sourceLineMap=e,z.revSourceMap=t}s&&W(s),r.send("atom-markdown-preview-plus-ipc-request-reply",X,{id:e,request:"update-preview",result:(0,H.processHTMLString)(l)})}function Z(){let e;return Q&&(e=Y(Q).then(Z)),Q=void 0,e}r.on("set-id",((e,t)=>{X=t})),r.on("init",((e,t)=>{z.mathJax.resolve(H.MathJaxController.create(t.userMacros,t.mathJaxConfig)),document.documentElement.dataset.markdownPreviewPlusContext=t.context,"pdf-export"===t.context&&document.documentElement.style.setProperty("width",`${t.pdfExportOptions.width}mm`,"important")})),r.on("set-native-keys",((e,t)=>{F=t})),r.on("scroll-sync",((e,t)=>{W(t)})),r.on("style",((e,{styles:t})=>{let n=document.head.querySelector("style#atom-styles");n||(n=document.createElement("style"),n.id="atom-styles",document.head.appendChild(n)),n.innerHTML=t.join("\n")})),r.on("update-images",((e,{oldsrc:t,v:n})=>{const r=(0,B.getMedia)(document);for(const e of Array.from(r)){let r,o,i;i="LINK"===e.tagName?"href":"src";let a=e.getAttribute(i);const s=a.match(/^(.*)\?v=(\d+)$/);s&&([,a,r]=s),a===t&&(void 0!==r&&(o=parseInt(r,10)),n!==o&&(e[i]=n?`${a}?v=${n}`:`${a}`))}})),r.on("sync",((e,{line:t,flash:n})=>{if(!document.querySelector("div.update-preview"))return;let r=z.sourceLineMap.get(t);if(!r)for(let e=t-1;e>=0&&(r=z.sourceLineMap.get(t),!r);e-=1);r&&(r.scrollIntoViewIfNeeded(!0),n&&(r.classList.add("flash"),setTimeout((()=>r.classList.remove("flash")),1e3)))})),r.on("update-preview",((e,t)=>{G?Q=t:G=Y(t).then(Z).catch($).then((()=>{G=void 0}))})),r.on("await-fully-ready",((e,{id:t})=>{function n(){requestAnimationFrame((function(){r.send("atom-markdown-preview-plus-ipc-request-reply",X,{id:t,request:"await-fully-ready",result:void 0})}))}"complete"!==document.readyState?window.addEventListener("load",(function e(){n(),window.removeEventListener("load",e)})):n()}));const ee=document.createElement("base");function te(e,t){if(F&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&!t.metaKey&&t.code.match(/^(Arrow.*|Page.*|Space|Home|End)$/))return;const n={type:e,altKey:t.altKey,ctrlKey:t.ctrlKey,bubbles:t.bubbles,cancelable:t.cancelable,code:t.code,composed:t.composed,detail:t.detail,isComposing:t.isComposing,key:t.key,location:t.location,metaKey:t.metaKey,repeat:t.repeat,shiftKey:t.shiftKey};r.send("atom-markdown-preview-plus-ipc-key",X,n),t.preventDefault()}let ne;document.head.appendChild(ee),r.on("set-base-path",((e,{path:t})=>{ee.href=t||""})),r.on("error",((e,{msg:t})=>{const n=document.querySelector("div.update-preview");if(!n)return;const r=document.createElement("div");r.innerHTML=`<h2>Previewing Markdown Failed</h2><h3>${t}</h3>`,n.firstElementChild?n.insertBefore(r,n.firstElementChild):n.appendChild(r)})),document.addEventListener("wheel",(e=>{e.ctrlKey&&(e.deltaY>0?r.send("atom-markdown-preview-plus-ipc-zoom-in",X):e.deltaY<0&&r.send("atom-markdown-preview-plus-ipc-zoom-out",X),e.preventDefault(),e.stopPropagation())})),document.addEventListener("scroll",(e=>{const t=document.documentElement.clientHeight,n=Array.from(z.sourceLineMap.entries()).filter((([e,n])=>{const{top:r,bottom:o}=n.getBoundingClientRect();return r>0&&o<t})).map((([e,t])=>e));r.send("atom-markdown-preview-plus-ipc-did-scroll-preview",X,{max:Math.max(...n),min:Math.min(...n)})})),document.addEventListener("keydown",te.bind(void 0,"keydown")),document.addEventListener("keyup",te.bind(void 0,"keyup")),document.addEventListener("contextmenu",(e=>{ne=e.target,r.send("atom-markdown-preview-plus-ipc-show-context-menu",X)})),r.on("sync-source",((e,{id:t})=>{let n=ne;const o=z.revSourceMap;let i=o.get(n);for(;!i&&n.parentElement;)n=n.parentElement,i=o.get(n);i&&r.send("atom-markdown-preview-plus-ipc-request-reply",X,{id:t,request:"sync-source",result:Math.min(...i)})})),r.on("reload",((e,{id:t})=>{window.onbeforeunload=null,r.send("atom-markdown-preview-plus-ipc-request-reply",X,{id:t,request:"reload",result:void 0})})),window.onbeforeunload=function(){return!1},r.on("get-tex-config",(async(e,{id:t})=>{r.send("atom-markdown-preview-plus-ipc-request-reply",X,{id:t,request:"get-tex-config",result:(await z.mathJax).jaxTeXConfig()})})),r.on("get-selection",(async(e,{id:t})=>{const n=window.getSelection(),o=n&&n.toString(),i=n&&n.anchorNode;r.send("atom-markdown-preview-plus-ipc-request-reply",X,{id:t,request:"get-selection",result:o&&i?o:void 0})})),document.addEventListener("click",(e=>{if(!e.target)return;const t=e.target;if("A"===t.tagName){const n=t.getAttribute("href");if(n&&n.startsWith("#")){e.preventDefault();const t=document.getElementById(decodeURIComponent(n).slice(1));t&&t.scrollIntoView()}}}));
//# sourceMappingURL=main.js.map
