import{a as e}from"./chunk-D9Tnb9aB.js";import{t}from"./codemirror-DtW92bSi.js";var n=e(t());n.default.defineOption(`info`,!1,(e,t,i)=>{if(i&&i!==n.default.Init){let t=e.state.info.onMouseOver;n.default.off(e.getWrapperElement(),`mouseover`,t),clearTimeout(e.state.info.hoverTimeout),delete e.state.info}if(t){let i=e.state.info=r(t);i.onMouseOver=a.bind(null,e),n.default.on(e.getWrapperElement(),`mouseover`,i.onMouseOver)}});function r(e){return{options:e instanceof Function?{render:e}:e===!0?{}:e}}function i(e){let{options:t}=e.state.info;return t?.hoverTime||500}function a(e,t){let r=e.state.info,a=t.target||t.srcElement;if(!(a instanceof HTMLElement)||a.nodeName!==`SPAN`||r.hoverTimeout!==void 0)return;let s=a.getBoundingClientRect(),c=function(){clearTimeout(r.hoverTimeout),r.hoverTimeout=setTimeout(u,d)},l=function(){n.default.off(document,`mousemove`,c),n.default.off(e.getWrapperElement(),`mouseout`,l),clearTimeout(r.hoverTimeout),r.hoverTimeout=void 0},u=function(){n.default.off(document,`mousemove`,c),n.default.off(e.getWrapperElement(),`mouseout`,l),r.hoverTimeout=void 0,o(e,s)},d=i(e);r.hoverTimeout=setTimeout(u,d),n.default.on(document,`mousemove`,c),n.default.on(e.getWrapperElement(),`mouseout`,l)}function o(e,t){let n=e.coordsChar({left:(t.left+t.right)/2,top:(t.top+t.bottom)/2},`window`),{options:r}=e.state.info,i=r.render||e.getHelper(n,`info`);if(i){let a=e.getTokenAt(n,!0);if(a){let o=i(a,r,e,n);o&&s(e,t,o)}}}function s(e,t,r){let i=document.createElement(`div`);i.className=`CodeMirror-info`,i.append(r),document.body.append(i);let a=i.getBoundingClientRect(),{marginLeft:o,marginRight:s,marginBottom:c,marginTop:l}=getComputedStyle(i),u=a.right-a.left+parseFloat(o)+parseFloat(s),d=a.bottom-a.top+parseFloat(l)+parseFloat(c),f=t.bottom;d>window.innerHeight-t.bottom-15&&t.top>window.innerHeight-t.bottom&&(f=t.top-d),f<0&&(f=t.bottom);let p=Math.max(0,window.innerWidth-u-15);p>t.left&&(p=t.left),i.style.opacity=`1`,i.style.top=f+`px`,i.style.left=p+`px`;let m,h=function(){clearTimeout(m)},g=function(){clearTimeout(m),m=setTimeout(_,200)},_=function(){n.default.off(i,`mouseover`,h),n.default.off(i,`mouseout`,g),n.default.off(e.getWrapperElement(),`mouseout`,g),i.style.opacity?(i.style.opacity=`0`,setTimeout(()=>{i.parentNode&&i.remove()},600)):i.parentNode&&i.remove()};n.default.on(i,`mouseover`,h),n.default.on(i,`mouseout`,g),n.default.on(e.getWrapperElement(),`mouseout`,g)}
//# sourceMappingURL=info-addon-By05uFl1.js.map