2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
"use strict";(()=>{var De=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ne=De((Et,Le)=>{var Ae="Expected a function",Ee=NaN,Ye="[object Symbol]",$e=/^\s+|\s+$/g,Ke=/^[-+]0x[0-9a-f]+$/i,Je=/^0b[01]+$/i,Qe=/^0o[0-7]+$/i,Ze=parseInt,et=typeof global=="object"&&global&&global.Object===Object&&global,tt=typeof self=="object"&&self&&self.Object===Object&&self,nt=et||tt||Function("return this")(),rt=Object.prototype,it=rt.toString,at=Math.max,ot=Math.min,de=function(){return nt.Date.now()};function st(e,t,n){var r,i,a,s,d,c,m=0,v=!1,h=!1,w=!0;if(typeof e!="function")throw new TypeError(Ae);t=Se(t)||0,Z(n)&&(v=!!n.leading,h="maxWait"in n,a=h?at(Se(n.maxWait)||0,t):a,w="trailing"in n?!!n.trailing:w);function b(g){var E=r,k=i;return r=i=void 0,m=g,s=e.apply(k,E),s}function S(g){return m=g,d=setTimeout(N,t),v?b(g):s}function A(g){var E=g-c,k=g-m,p=t-E;return h?ot(p,a-k):p}function D(g){var E=g-c,k=g-m;return c===void 0||E>=t||E<0||h&&k>=a}function N(){var g=de();if(D(g))return I(g);d=setTimeout(N,A(g))}function I(g){return d=void 0,w&&r?b(g):(r=i=void 0,s)}function U(){d!==void 0&&clearTimeout(d),m=0,r=c=i=d=void 0}function q(){return d===void 0?s:I(de())}function R(){var g=de(),E=D(g);if(r=arguments,i=this,c=g,E){if(d===void 0)return S(c);if(h)return d=setTimeout(N,t),b(c)}return d===void 0&&(d=setTimeout(N,t)),s}return R.cancel=U,R.flush=q,R}function lt(e,t,n){var r=!0,i=!0;if(typeof e!="function")throw new TypeError(Ae);return Z(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),st(e,t,{leading:r,maxWait:t,trailing:i})}function Z(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function dt(e){return!!e&&typeof e=="object"}function ut(e){return typeof e=="symbol"||dt(e)&&it.call(e)==Ye}function Se(e){if(typeof e=="number")return e;if(ut(e))return Ee;if(Z(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Z(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace($e,"");var n=Je.test(e);return n||Qe.test(e)?Ze(e.slice(2),n?2:8):Ke.test(e)?Ee:+e}Le.exports=lt});var me="code-line",ie=(()=>{let e,t=-1;return n=>{if(!e||n!==t){t=n,e=[{element:document.body,line:0}];for(let r of document.getElementsByClassName(me)){let i=+r.getAttribute("data-line");isNaN(i)||(r.tagName==="CODE"&&r.parentElement&&r.parentElement.tagName==="PRE"?e.push({element:r.parentElement,line:i}):r.tagName==="UL"||r.tagName==="OL"||e.push({element:r,line:i}))}}return e}})();function ae(e,t){let n=Math.floor(e),r=ie(t),i=r[0]||null;for(let a of r){if(a.line===n)return{previous:a,next:void 0};if(a.line>n)return{previous:i,next:a};i=a}return{previous:i}}function Re(e,t){let n=ie(t),r=e-window.scrollY,i=-1,a=n.length-1;for(;i+1<a;){let c=Math.floor((i+a)/2),m=F(n[c]);m.top+m.height>=r?a=c:i=c}let s=n[a],d=F(s);return a>=1&&d.top>r?{previous:n[i],next:s}:a>1&&a<n.length&&d.top+d.height>r?{previous:s,next:n[a+1]}:{previous:s}}function F({element:e}){let t=e.getBoundingClientRect(),n=e.querySelector(`.${me}`);if(n){let r=n.getBoundingClientRect(),i=Math.max(1,r.top-t.top);return{top:t.top,height:i}}return t}function Y(e,t,n){if(!n.settings?.scrollPreviewWithEditor)return;if(e<=0){window.scroll(window.scrollX,0);return}let{previous:r,next:i}=ae(e,t);if(!r)return;let a=0,s=F(r),d=s.top;if(i&&i.line!==r.line){let c=(e-r.line)/(i.line-r.line),m=d+s.height,v=i.element.getBoundingClientRect().top-m;a=m+c*v}else{let c=e-Math.floor(e);a=d+s.height*c}a=Math.abs(a)<1?Math.sign(a):a,window.scroll(window.scrollX,Math.max(1,window.scrollY+a))}function oe(e,t){let{previous:n,next:r}=Re(e,t);if(n){let i=F(n),a=e-window.scrollY-i.top;if(r){let s=a/(F(r).top-i.top);return n.line+s*(r.line-n.line)}else{let s=a/i.height;return n.line+s}}return null}function ge(e,t){return ie(t).find(n=>n.element.id===e)}var $=class{onDidChangeTextEditorSelection(t,n){let{previous:r}=ae(t,n);this._update(r&&r.element)}_update(t){this._unmarkActiveElement(this._current),this._markActiveElement(t),this._current=t}_unmarkActiveElement(t){!t||(t.className=t.className.replace(/\bcode-active-line\b/g,""))}_markActiveElement(t){!t||(t.className+=" code-active-line"
|