"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6835],{6835:(e,t,r)=>{r.r(t),r.d(t,{WebLinksAddon:()=>a});var i=class{constructor(e,t,r,i={}){this._terminal=e,this._regex=t,this._handler=r,this._options=i}provideLinks(e,t){let r=n.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(r))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,r)=>{if(this._options.hover){let{range:i}=e;this._options.hover(t,r,i)}},e))}},n=class e{static computeLink(t,r,i,n){let s=RegExp(r.source,(r.flags||"")+"g"),[o,a]=e._getWindowedLineStrings(t-1,i),l=o.join(""),h,c=[];for(;h=s.exec(l);){let t=h[0];if(!function(e){try{let t=new URL(e),r=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(r.toLocaleLowerCase())}catch{return!1}}(t))continue;let[r,s]=e._mapStrIdx(i,a,0,h.index),[o,l]=e._mapStrIdx(i,r,s,t.length);if(-1===r||-1===s||-1===o||-1===l)continue;let p={start:{x:s+1,y:r+1},end:{x:l,y:o+1}};c.push({range:p,text:t,activate:n})}return c}static _getWindowedLineStrings(e,t){let r,i=e,n=e,s,o,a=[];if(r=t.buffer.active.getLine(e)){let e=r.translateToString(!0);if(r.isWrapped&&" "!==e[0]){for(s=0;(r=t.buffer.active.getLine(--i))&&s<2048&&(s+=(o=r.translateToString(!0)).length,a.push(o),!(!r.isWrapped||-1!==o.indexOf(" "))););a.reverse()}for(a.push(e),s=0;(r=t.buffer.active.getLine(++n))&&r.isWrapped&&s<2048&&(s+=(o=r.translateToString(!0)).length,a.push(o),-1===o.indexOf(" ")););}return[a,i]}static _mapStrIdx(e,t,r,i){let n=e.buffer.active,s=n.getNullCell(),o=r;for(;i;){let e=n.getLine(t);if(!e)return[-1,-1];for(let r=o;r<e.length;++r){e.getCell(r,s);let o=s.getChars();if(s.getWidth()&&(i-=o.length||1,r===e.length-1&&""===o)){let e=n.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,s),2===s.getWidth()&&(i+=1))}if(i<0)return[t,r]}t++,o=0}return[t,o]}},s=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function o(e,t){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var a=class{constructor(e=o,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,r=t.urlRegex??s;this._linkProvider=this._terminal.registerLinkProvider(new i(this._terminal,r,this._handler,t))}dispose(){this._linkProvider?.dispose()}}}}]);