code-server
Version:
Run VS Code on a remote server.
4 lines (3 loc) • 24.9 kB
JavaScript
var rt=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}};var We=rt((fn,Ve)=>{var Fe="Expected a function",Oe=NaN,Ct="[object Symbol]",St=/^\s+|\s+$/g,Tt=/^[-+]0x[0-9a-f]+$/i,Et=/^0b[01]+$/i,Lt=/^0o[0-7]+$/i,Mt=parseInt,At=typeof global=="object"&&global&&global.Object===Object&&global,xt=typeof self=="object"&&self&&self.Object===Object&&self,Nt=At||xt||Function("return this")(),Pt=Object.prototype,kt=Pt.toString,It=Math.max,Dt=Math.min,we=function(){return Nt.Date.now()};function Ht(e,t,r){var n,i,o,a,s,l,u=0,b=!1,v=!1,E=!0;if(typeof e!="function")throw new TypeError(Fe);t=Re(t)||0,ae(r)&&(b=!!r.leading,v="maxWait"in r,o=v?It(Re(r.maxWait)||0,t):o,E="trailing"in r?!!r.trailing:E);function x(g){var L=n,B=i;return n=i=void 0,u=g,a=e.apply(B,L),a}function de(g){return u=g,s=setTimeout(M,t),b?x(g):a}function $(g){var L=g-l,B=g-u,O=t-L;return v?Dt(O,o-B):O}function F(g){var L=g-l,B=g-u;return l===void 0||L>=t||L<0||v&&B>=o}function M(){var g=we();if(F(g))return H(g);s=setTimeout(M,$(g))}function H(g){return s=void 0,E&&n?x(g):(n=i=void 0,a)}function V(){s!==void 0&&clearTimeout(s),u=0,n=l=i=s=void 0}function K(){return s===void 0?a:H(we())}function P(){var g=we(),L=F(g);if(n=arguments,i=this,l=g,L){if(s===void 0)return de(l);if(v)return s=setTimeout(M,t),x(l)}return s===void 0&&(s=setTimeout(M,t)),a}return P.cancel=V,P.flush=K,P}function Bt(e,t,r){var n=!0,i=!0;if(typeof e!="function")throw new TypeError(Fe);return ae(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),Ht(e,t,{leading:n,maxWait:t,trailing:i})}function ae(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Ot(e){return!!e&&typeof e=="object"}function Rt(e){return typeof e=="symbol"||Ot(e)&&kt.call(e)==Ct}function Re(e){if(typeof e=="number")return e;if(Rt(e))return Oe;if(ae(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ae(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(St,"");var r=Et.test(e);return r||Lt.test(e)?Mt(e.slice(2),r?2:8):Tt.test(e)?Oe:+e}Ve.exports=Bt});var Ee="code-line",_=class{constructor(t,r,n,i){this.element=t;this.line=r;this.codeElement=n;this.endLine=i;this.#e=Array.from(at(t,"DETAILS"))}element;line;codeElement;endLine;#e;get isVisible(){if(this.#e.some(n=>!n.open))return!1;let t=window.getComputedStyle(this.element);if(t.display==="none"||t.visibility==="hidden")return!1;let r=this.element.getBoundingClientRect();return!(r.height===0||r.width===0)}},ee=(()=>{let e,t=-1;return r=>{if(!e||r!==t){t=r,e=[new _(document.body,-1)];for(let n of document.getElementsByClassName(Ee)){if(!(n instanceof HTMLElement))continue;let i=+n.getAttribute("data-line");if(!isNaN(i))if(n.tagName==="CODE"&&n.parentElement?.tagName==="PRE"){let a=((n.textContent||"").match(/\n/g)||[]).length+1,s=i+a-1;e.push(new _(n.parentElement,i,n,s))}else n.tagName==="PRE"||n.tagName==="UL"||n.tagName==="OL"||e.push(new _(n,i))}}return e}})();function q(e,t){let r=Math.floor(e),n=ee(t),i=n[0]||null;for(let o of n){if(o.line===r)return{previous:o,next:void 0};if(o.line>r)return{previous:i,next:o};i=o}return{previous:i}}function Le(e,t,r){let n=Math.floor(e),i=Math.max(n+1,Math.ceil(t)),o=ee(r).filter(s=>s.line>=0),a=[];for(let s=0;s<o.length;s++){let l=o[s],u=o[s+1],b=l.line,v=l.endLine!==void 0?l.endLine+1:u&&u.line>l.line?u.line:l.line+1;it(n,i,b,v)&&a.push(l)}return a}function it(e,t,r,n){return e<n&&r<t}function ot(e,t){let r=ee(t).filter(l=>l.isVisible),n=e-window.scrollY,i=-1,o=r.length-1;for(;i+1<o;){let l=Math.floor((i+o)/2),u=R(r[l]);u.top+u.height>=n?o=l:i=l}let a=r[o],s=R(a);return o>=1&&s.top>n?{previous:r[i],next:a}:o>1&&o<r.length&&s.top+s.height>n?{previous:a,next:r[o+1]}:{previous:a}}function R(e){let{element:t,codeElement:r}=e,n=t.getBoundingClientRect();if(r)return n;let i=t.querySelector(`.${Ee}`);if(i){let o=i.getBoundingClientRect(),a=Math.max(1,o.top-n.top);return{top:n.top,height:a}}return n}function Me(e){let{element:t,codeElement:r}=e,n=R(e);if(r){let i=window.getComputedStyle(t),o=parseFloat(i.paddingTop)||0,a=parseFloat(i.paddingBottom)||0;return{top:n.top+o,height:n.height-o-a,paddingTop:o,paddingBottom:a}}return{top:n.top,height:n.height,paddingTop:0,paddingBottom:0}}function G(e,t,r){if(!r.settings?.scrollPreviewWithEditor)return;if(e<=0){window.scroll(window.scrollX,0);return}let{previous:n,next:i}=q(e,t);if(!n)return;let o=0,a=R(n),s=a.top;if(n.endLine&&n.endLine>n.line)if(e<n.endLine){let l=Me(n),u=(e-n.line)/(n.endLine-n.line);o=window.scrollY+l.top+l.height*u}else if(i&&i.line!==n.line){let l=(e-n.endLine)/(i.line-n.endLine),u=window.scrollY+s+a.height,v=window.scrollY+i.element.getBoundingClientRect().top-u;o=u+l*v}else o=window.scrollY+s+a.height;else if(i&&i.line!==n.line){let l=(e-n.line)/(i.line-n.line),u=window.scrollY+s+a.height,v=window.scrollY+i.element.getBoundingClientRect().top-u;o=u+l*v}else{let l=e-Math.floor(e);o=window.scrollY+s+a.height*l}window.scroll(window.scrollX,Math.max(1,o))}function me(e,t){let{previous:r,next:n}=ot(e,t);if(r){if(r.line<0)return 0;let i=R(r),o=e-window.scrollY-i.top;if(r.endLine&&r.endLine>r.line){let a=Me(r),s=e-window.scrollY-a.top;if(s>=0&&s<=a.height){let l=s/a.height;return r.line+l*(r.endLine-r.line)}else if(n&&s>a.height){let l=s-a.height,u=R(n),b=a.top+a.height,v=u.top-b,E=l/v;return r.endLine+E*(n.line-r.endLine)}else s<0}if(n){let a=o/(R(n).top-i.top);return r.line+a*(n.line-r.line)}else{let a=o/i.height;return r.line+a}}return null}function Ae(e,t){return ee(t).find(r=>r.element.id===e)}function*at(e,t){for(let r=e.parentElement;r;r=r.parentElement)r.tagName===t&&(yield r)}var te=class{#e;onDidChangeTextEditorSelection(t,r){let{previous:n}=q(t,r);this.#r(n&&(n.codeElement||n.element))}#r(t){this.#n(this.#e),this.#t(t),this.#e=t}#n(t){t&&t.classList.toggle("code-active-line",!1)}#t(t){t&&t.classList.toggle("code-active-line",!0)}};function xe(e){document.readyState==="loading"||document.readyState==="uninitialized"?document.addEventListener("DOMContentLoaded",e):e()}var Ne=(e,t)=>({postMessage(r,n){e.postMessage({type:r,source:t.settings.source,...n})}});function ge(e){let t=document.getElementById("vscode-markdown-preview-data");if(t){let r=t.getAttribute(e);if(r)return r}throw new Error(`Could not load data for ${e}`)}function pe(e){return JSON.parse(ge(e))}var ne=class{#e=pe("data-settings");get settings(){return this.#e}updateSettings(t){this.#e=t}};var Pe=11;function st(e,t){var r=t.attributes,n,i,o,a,s;if(!(t.nodeType===Pe||e.nodeType===Pe)){for(var l=r.length-1;l>=0;l--)n=r[l],i=n.name,o=n.namespaceURI,a=n.value,o?(i=n.localName||i,s=e.getAttributeNS(o,i),s!==a&&(n.prefix==="xmlns"&&(i=n.name),e.setAttributeNS(o,i,a))):(s=e.getAttribute(i),s!==a&&e.setAttribute(i,a));for(var u=e.attributes,b=u.length-1;b>=0;b--)n=u[b],i=n.name,o=n.namespaceURI,o?(i=n.localName||i,t.hasAttributeNS(o,i)||e.removeAttributeNS(o,i)):t.hasAttribute(i)||e.removeAttribute(i)}}var re,lt="http://www.w3.org/1999/xhtml",C=typeof document>"u"?void 0:document,dt=!!C&&"content"in C.createElement("template"),ct=!!C&&C.createRange&&"createContextualFragment"in C.createRange();function ut(e){var t=C.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}function ft(e){re||(re=C.createRange(),re.selectNode(C.body));var t=re.createContextualFragment(e);return t.childNodes[0]}function mt(e){var t=C.createElement("body");return t.innerHTML=e,t.childNodes[0]}function gt(e){return e=e.trim(),dt?ut(e):ct?ft(e):mt(e)}function ie(e,t){var r=e.nodeName,n=t.nodeName,i,o;return r===n?!0:(i=r.charCodeAt(0),o=n.charCodeAt(0),i<=90&&o>=97?r===n.toUpperCase():o<=90&&i>=97?n===r.toUpperCase():!1)}function pt(e,t){return!t||t===lt?C.createElement(e):C.createElementNS(t,e)}function ht(e,t){for(var r=e.firstChild;r;){var n=r.nextSibling;t.appendChild(r),r=n}return t}function he(e,t,r){e[r]!==t[r]&&(e[r]=t[r],e[r]?e.setAttribute(r,""):e.removeAttribute(r))}var ke={OPTION:function(e,t){var r=e.parentNode;if(r){var n=r.nodeName.toUpperCase();n==="OPTGROUP"&&(r=r.parentNode,n=r&&r.nodeName.toUpperCase()),n==="SELECT"&&!r.hasAttribute("multiple")&&(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),r.selectedIndex=-1)}he(e,t,"selected")},INPUT:function(e,t){he(e,t,"checked"),he(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var r=t.value;e.value!==r&&(e.value=r);var n=e.firstChild;if(n){var i=n.nodeValue;if(i==r||!r&&i==e.placeholder)return;n.nodeValue=r}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var r=-1,n=0,i=e.firstChild,o,a;i;)if(a=i.nodeName&&i.nodeName.toUpperCase(),a==="OPTGROUP")o=i,i=o.firstChild,i||(i=o.nextSibling,o=null);else{if(a==="OPTION"){if(i.hasAttribute("selected")){r=n;break}n++}i=i.nextSibling,!i&&o&&(i=o.nextSibling,o=null)}e.selectedIndex=r}}},z=1,Ie=11,De=3,He=8;function D(){}function vt(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}function bt(e){return function(r,n,i){if(i||(i={}),typeof n=="string")if(r.nodeName==="#document"||r.nodeName==="HTML"||r.nodeName==="BODY"){var o=n;n=C.createElement("html"),n.innerHTML=o}else n=gt(n);else n.nodeType===Ie&&(n=n.firstElementChild);var a=i.getNodeKey||vt,s=i.onBeforeNodeAdded||D,l=i.onNodeAdded||D,u=i.onBeforeElUpdated||D,b=i.onElUpdated||D,v=i.onBeforeNodeDiscarded||D,E=i.onNodeDiscarded||D,x=i.onBeforeElChildrenUpdated||D,de=i.skipFromChildren||D,$=i.addChild||function(d,c){return d.appendChild(c)},F=i.childrenOnly===!0,M=Object.create(null),H=[];function V(d){H.push(d)}function K(d,c){if(d.nodeType===z)for(var p=d.firstChild;p;){var f=void 0;c&&(f=a(p))?V(f):(E(p),p.firstChild&&K(p,c)),p=p.nextSibling}}function P(d,c,p){v(d)!==!1&&(c&&c.removeChild(d),E(d),K(d,p))}function g(d){if(d.nodeType===z||d.nodeType===Ie)for(var c=d.firstChild;c;){var p=a(c);p&&(M[p]=c),g(c),c=c.nextSibling}}g(r);function L(d){l(d);for(var c=d.firstChild;c;){var p=c.nextSibling,f=a(c);if(f){var m=M[f];m&&ie(c,m)?(c.parentNode.replaceChild(m,c),O(m,c)):L(c)}else L(c);c=p}}function B(d,c,p){for(;c;){var f=c.nextSibling;(p=a(c))?V(p):P(c,d,!0),c=f}}function O(d,c,p){var f=a(c);if(f&&delete M[f],!p){var m=u(d,c);if(m===!1||(m instanceof HTMLElement&&(d=m,g(d)),e(d,c),b(d),x(d,c)===!1))return}d.nodeName!=="TEXTAREA"?tt(d,c):ke.TEXTAREA(d,c)}function tt(d,c){var p=de(d,c),f=c.firstChild,m=d.firstChild,W,N,U,J,k;e:for(;f;){for(J=f.nextSibling,W=a(f);!p&&m;){if(U=m.nextSibling,f.isSameNode&&f.isSameNode(m)){f=J,m=U;continue e}N=a(m);var Q=m.nodeType,I=void 0;if(Q===f.nodeType&&(Q===z?(W?W!==N&&((k=M[W])?U===k?I=!1:(d.insertBefore(k,m),N?V(N):P(m,d,!0),m=k,N=a(m)):I=!1):N&&(I=!1),I=I!==!1&&ie(m,f),I&&O(m,f)):(Q===De||Q==He)&&(I=!0,m.nodeValue!==f.nodeValue&&(m.nodeValue=f.nodeValue))),I){f=J,m=U;continue e}N?V(N):P(m,d,!0),m=U}if(W&&(k=M[W])&&ie(k,f))p||$(d,k),O(k,f);else{var fe=s(f);fe!==!1&&(fe&&(f=fe),f.actualize&&(f=f.actualize(d.ownerDocument||C)),$(d,f),L(f))}f=J,m=U}B(d,m,N);var Te=ke[d.nodeName];Te&&Te(d,c)}var y=r,Z=y.nodeType,Se=n.nodeType;if(!F){if(Z===z)Se===z?ie(r,n)||(E(r),y=ht(r,pt(n.nodeName,n.namespaceURI))):y=n;else if(Z===De||Z===He){if(Se===Z)return y.nodeValue!==n.nodeValue&&(y.nodeValue=n.nodeValue),y;y=n}}if(y===n)E(r);else{if(n.isSameNode&&n.isSameNode(y))return;if(O(y,n,F),H)for(var ce=0,nt=H.length;ce<nt;ce++){var ue=M[H[ce]];ue&&P(ue,ue.parentNode,!1)}}return!F&&y!==r&&r.parentNode&&(y.actualize&&(y=y.actualize(r.ownerDocument||C)),r.parentNode.replaceChild(y,r)),y}}var wt=bt(st),Be=wt;var ve=Object.freeze({http:"http",https:"https",file:"file",untitled:"untitled",mailto:"mailto",vscode:"vscode","vscode-insiders":"vscode-insiders",notebookCell:"vscode-notebook-cell"});function be(e,t){return t.toLowerCase().startsWith(e+":")}var oe=class{#e=Math.random().toString(36).slice(2,10);#r;#n;#t;#i=0;constructor(t,r){this.#r=r,this.#n=t,this.#t=new BroadcastChannel(t.channelName),this.#t.onmessage=n=>{let{line:i,sender:o}=n.data;if(o===this.#e||typeof i!="number"||isNaN(i))return;let a=yt(i,this.#n.lineMappings);this.#i=Date.now()+100,this.#r(a)}}update(t){this.#n=t}broadcastScroll(t){!this.#t||Date.now()<this.#i||this.#t.postMessage({line:t,sender:this.#e})}};function yt(e,t){if(!t?.length)return e;let r=Math.floor(e),n=e-r,i=t[r]??e;if(n<=0)return Math.max(0,i);let o=t[r+1];return typeof o!="number"?Math.max(0,i+n):Math.max(0,i+(o-i)*n)}var _e=We(),S=0,w,Ge=new te,h=new ne,T=0,j=h.settings.source,ye=h.settings.lineChanges,Y=acquireVsCodeApi(),Ft=e=>{S=1,w&&clearTimeout(w),w=window.setTimeout(()=>{S=0},100),le(()=>G(e,T,h))},ze=h.settings.diffScrollSync?new oe(h.settings.diffScrollSync,Ft):void 0,se=Y.getState()??{},A={...se,...pe("data-state")},Vt=typeof h.settings.line=="number"&&!isNaN(h.settings.line);typeof se.scrollProgress<"u"&&(se?.resource!==A.resource||Vt&&se.line!==h.settings.line)&&(A.scrollProgress=void 0);Y.setState(A);var X=Ne(Y,h);window.cspAlerter.setPoster(X);window.styleLoadingMonitor.setPoster(X);function le(e){let t=document.getElementsByTagName("img");if(t.length>0){let r=Array.from(t,n=>n.complete?Promise.resolve():new Promise(i=>{n.addEventListener("load",()=>i()),n.addEventListener("error",()=>i())}));Promise.all(r).then(()=>setTimeout(e,0))}else setTimeout(e,0)}xe(()=>{let r=[...new DOMParser().parseFromString(ge("data-initial-md-content"),"text/html").body.children];document.body.append(...r);for(let i of r)i instanceof HTMLElement&&Ce(i);let n=A.scrollProgress;if(Xe(),$e(),Ze(ye),typeof n=="number"&&!h.settings.fragment){le(()=>{S=1,w&&clearTimeout(w),w=window.setTimeout(()=>{S=0},200);let i=Math.max(1,n*document.body.clientHeight);window.scrollTo(0,i)});return}h.settings.scrollPreviewWithEditor&&le(()=>{if(h.settings.fragment){let i;try{i=encodeURIComponent(h.settings.fragment)}catch{i=h.settings.fragment}A.fragment=void 0,Y.setState(A);let o=Ae(i,T);o&&(S=1,w&&clearTimeout(w),w=window.setTimeout(()=>{S=0},200),G(o.line,T,h))}else isNaN(h.settings.line)||(S=1,w&&clearTimeout(w),w=window.setTimeout(()=>{S=0},200),G(h.settings.line,T,h))}),typeof h.settings.selectedLine=="number"&&Ge.onDidChangeTextEditorSelection(h.settings.selectedLine,T)});var Wt=(()=>{let e=_e(t=>{S=1,w&&clearTimeout(w),w=window.setTimeout(()=>{S=0},50),le(()=>G(t,T,h))},50);return t=>{isNaN(t)||(A.line=t,e(t))}})();window.addEventListener("resize",()=>{S=1,w&&clearTimeout(w),w=window.setTimeout(()=>{S=0},200),Qe()},!0);function Xe(){let e=document.getElementsByTagName("img"),t=0;for(let r of e){r.id="image-"+t,t+=1;let n=r.getAttribute("data-src"),o=n&&!(be(ve.http,n)||be(ve.https,n))?"localImage":"image";r.setAttribute("data-vscode-context",JSON.stringify({webviewSection:o,id:r.id,preventDefaultContextMenuItems:!0,resource:j,imageSource:n}))}}function Ue(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false"),e.setAttribute("width","16"),e.setAttribute("height","16"),e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("fill","none");let t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d","M4 4H2V14H11V12H4V4Z"),t.setAttribute("fill","currentColor");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M5 2H14V11H5V2ZM6 3H13V10H6V3Z"),r.setAttribute("fill","currentColor"),e.appendChild(t),e.appendChild(r),e}function Ut(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false"),e.setAttribute("width","16"),e.setAttribute("height","16"),e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("fill","none");let t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","M6.27 10.87L3.63 8.23L2.56 9.3L6.27 13.01L14.07 5.21L13 4.14L6.27 10.87Z"),t.setAttribute("fill","currentColor"),e.appendChild(t),e}function $e(){let e=document.querySelectorAll("pre > code");for(let t of e){let r=t.parentElement;if(!r.querySelector(".code-block-copy-button")){let n=document.createElement("button");n.className="code-block-copy-button",n.setAttribute("aria-label","Copy code block"),n.appendChild(Ue()),n.addEventListener("click",async i=>{i.preventDefault(),i.stopPropagation();let o=t.textContent??"";try{await navigator.clipboard.writeText(o),n.replaceChildren(Ut()),n.classList.add("copied"),setTimeout(()=>{n.replaceChildren(Ue()),n.classList.remove("copied")},2e3)}catch{let a=window.getSelection();if(a){a.removeAllRanges();let s=document.createRange();s.selectNodeContents(t),a.addRange(s),document.execCommand("copy"),a.removeAllRanges()}}}),r.appendChild(n)}}}async function Ke(e,t=5){if(!document.hasFocus()&&t>0){setTimeout(()=>{Ke(e,t-1)},20);return}try{await navigator.clipboard.write([new ClipboardItem({"image/png":new Promise(r=>{let n=document.createElement("canvas");n!==null&&(n.width=e.naturalWidth,n.height=e.naturalHeight,n.getContext("2d")?.drawImage(e,0,0)),n.toBlob(i=>{i&&r(i),n.remove()},"image/png")})})])}catch(r){console.error(r);let n=window.getSelection();if(!n){await navigator.clipboard.writeText(e.getAttribute("data-src")??e.src);return}n.removeAllRanges();let i=document.createRange();i.selectNode(e),n.addRange(i),document.execCommand("copy"),n.removeAllRanges()}}window.addEventListener("message",async e=>{let t=e.data;switch(t.type){case"copyImage":{let r=document.getElementById(t.id);r instanceof HTMLImageElement&&Ke(r);return}case"onDidChangeTextEditorSelection":t.source===j&&Ge.onDidChangeTextEditorSelection(t.line,T);return;case"updateView":t.source===j&&Wt(t.line);return;case"updateContent":{ye=t.lineChanges,t.diffScrollSync&&ze?.update(t.diffScrollSync);let r=document.querySelector(".markdown-body"),i=new DOMParser().parseFromString(t.content,"text/html");for(let o of Array.from(i.querySelectorAll("meta")))o.hasAttribute("http-equiv")&&o.remove();if(t.source!==j){j=t.source;let o=i.querySelector(".markdown-body");r.replaceWith(o),Ce(o)}else{let o=i.querySelector(".markdown-body"),a=o.querySelectorAll("link");for(let s of a)s.remove();o.prepend(...a),Be(r,o,{childrenOnly:!0,onBeforeElUpdated:(s,l)=>{if(et(s,l)){let u=s.querySelectorAll("[data-line]"),b=l.querySelectorAll("[data-line]");u.length!==b.length&&console.log("unexpected line number change");for(let v=0;v<u.length;++v){let E=u[v],x=b[v];x&&E.setAttribute("data-line",x.getAttribute("data-line"))}return!1}return s.tagName==="DETAILS"&&l.tagName==="DETAILS"&&s.hasAttribute("open")&&l.setAttribute("open",""),!0},addChild:(s,l)=>{s.appendChild(l),l instanceof HTMLElement&&Ce(l)}})}++T,window.dispatchEvent(new CustomEvent("vscode.markdown.updateContent")),Xe(),$e(),Ze(ye);break}}},!1);function Ze(e){for(let t of document.querySelectorAll(".code-line-diff-added, .code-line-diff-deleted, .code-line-diff-modified"))t.classList.remove("code-line-diff","code-line-diff-added","code-line-diff-deleted","code-line-diff-modified");for(let t of document.querySelectorAll(".diff-change-indicator"))t.remove();for(let t of document.querySelectorAll(".diff-modification-gutter"))t.remove();qe(e?.added,"code-line-diff-added"),qe(e?.deleted,"code-line-diff-deleted"),qt(e),Jt(e)}function qe(e,t){if(e)for(let r of e){let{previous:n,next:i}=q(r,T),o=n.line>=0?n:i,a=o?.codeElement||o?.element;a&&a.classList.add("code-line-diff",t)}}function qt(e){if(e?.changeIndicators?.length)for(let t of jt(e.changeIndicators)){if(t.indicator.type==="deletion"){let n=Gt(t.indicator);t.elements[0].parentElement?.insertBefore(n,t.elements[0]);continue}let r=!0;for(let n of t.elements)n.classList.add("code-line-diff-modified"),zt(n,r?t.indicator:void 0),r=!1}}function jt(e){let t=[];for(let r of e){let n=r.type==="deletion"?Yt(r.modifiedLine):_t(r.modifiedLine,r.modifiedLineCount);n.length&&t.push({indicator:r,elements:n})}return t}function Yt(e){let{previous:t,next:r}=q(e,T),n=t.line===e?t.codeElement||t.element:r?.codeElement||r?.element||t.codeElement||t.element;return n?[n]:[]}function _t(e,t){let r=[],n=new Set,i=Le(e,e+t,T);for(let o of i){let a=o.codeElement||o.element;a&&!n.has(a)&&(n.add(a),r.push(a))}return r}function Gt(e){let t=document.createElement("div");t.className=`diff-change-indicator diff-change-indicator-${e.type}`,t.setAttribute("data-original-line-count",String(e.originalLineCount));let r=document.createElement("span");r.className="diff-change-indicator-arrow";let n=Je(e);return r.appendChild(n),t.appendChild(r),t}function zt(e,t){let r=document.createElement("div");if(r.className="diff-modification-gutter",t){let n=Je(t);r.appendChild(n)}e.style.position="relative",e.appendChild(r)}function Je(e){let t=document.createElement("div");return t.className="diff-change-indicator-tooltip",e.originalContent&&je(t,"diff-tooltip-deleted",e.originalContent,e.originalInnerChanges,"diff-tooltip-inner-deleted"),e.modifiedContent&&je(t,"diff-tooltip-added",e.modifiedContent,e.modifiedInnerChanges,"diff-tooltip-inner-added"),t}function je(e,t,r,n,i){let o=document.createElement("div");o.className=t;let a=document.createElement("pre");Xt(a,r,n,i),o.appendChild(a),e.appendChild(o)}function Xt(e,t,r,n){if(!r?.length){e.textContent=t;return}let i=Kt(r),o=t.split(`
`);for(let a=0;a<o.length;++a)$t(e,o[a],i.get(a),n),a+1<o.length&&e.appendChild(document.createTextNode(`
`))}function $t(e,t,r,n){let i=Zt(r,t.length),o=0;for(let a of i){o<a.startColumn&&e.appendChild(document.createTextNode(t.slice(o,a.startColumn)));let s=document.createElement("span");s.className=n,s.textContent=t.slice(a.startColumn,a.endColumn),e.appendChild(s),o=a.endColumn}o<t.length&&e.appendChild(document.createTextNode(t.slice(o)))}function Kt(e){let t=new Map;for(let r of e){let n=t.get(r.line);n?n.push(r):t.set(r.line,[r])}return t}function Zt(e,t){if(!e?.length)return[];let r=e.map(i=>({startColumn:Ye(i.startColumn,t),endColumn:Ye(i.endColumn,t)})).filter(i=>i.startColumn<i.endColumn).sort((i,o)=>i.startColumn-o.startColumn||i.endColumn-o.endColumn),n=[];for(let i of r){let o=n[n.length-1];o&&i.startColumn<=o.endColumn?o.endColumn=Math.max(o.endColumn,i.endColumn):n.push(i)}return n}function Ye(e,t){return Math.min(Math.max(e,0),t)}function Jt(e){let t="diff-inner-added",r="diff-inner-deleted";if(CSS.highlights?.delete(t),CSS.highlights?.delete(r),!e?.innerChanges?.length||!CSS.highlights)return;let n=e.added?t:r,i=[],o=document.querySelector(".markdown-body");if(o){for(let{startMarker:a,endMarker:s}of Qt(o)){let l=new Range;l.setStartAfter(a),l.setEndBefore(s),i.push(l)}i.length>0&&CSS.highlights.set(n,new Highlight(...i))}}function Qt(e){let t=new Map;for(let n of e.querySelectorAll("[data-diff-end]")){let i=n.getAttribute("data-diff-end");i!==null&&t.set(i,n)}let r=[];for(let n of e.querySelectorAll("[data-diff-start]")){let i=n.getAttribute("data-diff-start"),o=i===null?void 0:t.get(i);o&&!(n.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_PRECEDING)&&r.push({startMarker:n,endMarker:o})}return r}document.addEventListener("dblclick",e=>{if(!h.settings.doubleClickToSwitchToEditor||j.endsWith(".copilotmd"))return;for(let n=e.target;n;n=n.parentNode)if(n.tagName==="A")return;let t=e.pageY,r=me(t,T);typeof r=="number"&&!isNaN(r)&&X.postMessage("didClick",{line:Math.floor(r)})});var en=["http:","https:","mailto:","vscode:","vscode-insiders:"];document.addEventListener("click",e=>{if(!e)return;let t=e.target;for(;t;){if(t.tagName&&t.tagName==="A"&&t.href){if(t.getAttribute("href")?.startsWith("#"))return;let r=t.getAttribute("data-href");if(!r&&(r=t.getAttribute("href"),r&&en.some(n=>r.startsWith(n))))return;if(r&&!/^[a-z\-]+:/i.test(r)){X.postMessage("openLink",{href:r}),e.preventDefault(),e.stopPropagation();return}return}t=t.parentElement}},!0);window.addEventListener("scroll",_e(()=>{if(Qe(),S>0)return;let e=me(window.scrollY,T);typeof e=="number"&&!isNaN(e)&&(A.line=e,Y.setState(A),X.postMessage("revealLine",{line:e}),ze?.broadcastScroll(e))},50));function Qe(){A.scrollProgress=window.scrollY/document.body.clientHeight,Y.setState(A)}function et(e,t){let r=["open"];if(e.isEqualNode(t))return!0;if(e.tagName!==t.tagName||e.textContent!==t.textContent)return!1;let n=[...e.attributes].filter(s=>!r.includes(s.name)),i=[...t.attributes].filter(s=>!r.includes(s.name));if(n.length!==i.length)return!1;for(let s=0;s<n.length;++s){let l=n[s],u=i[s];if(l.name!==u.name||l.value!==u.value&&l.name!=="data-line")return!1}let o=Array.from(e.children),a=Array.from(t.children);return o.length===a.length&&o.every((s,l)=>et(s,a[l]))}function Ce(e){let t=["type","src","nonce","noModule","async"],r=e.tagName==="SCRIPT"?[e]:Array.from(e.getElementsByTagName("script"));for(let n of r){if(!(n instanceof HTMLElement))continue;let i=document.createElement("script"),o=n.innerText;i.text=o;for(let a of t){let s=n.getAttribute?.(a);s&&i.setAttribute(a,s)}n.insertAdjacentElement("afterend",i),n.remove()}}