(e,t,r,l)
| 5 | * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files |
| 6 | */ |
| 7 | var L=class{constructor(s,e,t,r={}){this._terminal=s,this._regex=e,this._handler=t,this._options=r}provideLinks(s,e){let t=x.computeLink(s,this._regex,this._terminal,this._handler);e(this._addCallbacks(t))}_addCallbacks(s){return s.map(e=>(e.leave=this._options.leave,e.hover=(t,r)=>{if(this._options.hover){let{range:l}=e;this._options.hover(t,r,l)}},e))}};function m(s){try{let e=new URL(s),t=e.password&&e.username?`${e.protocol}//${e.username}:${e.password}@${e.host}`:e.username?`${e.protocol}//${e.username}@${e.host}`:`${e.protocol}//${e.host}`;return s.toLocaleLowerCase().startsWith(t.toLocaleLowerCase())}catch{return!1}}var x=class d{static computeLink(e,t,r,l){let h=new RegExp(t.source,(t.flags||"")+"g"),[i,n]=d._getWindowedLineStrings(e-1,r),a=i.join(""),o,c=[];for(;o=h.exec(a);){let p=o[0];if(!m(p))continue;let[u,g]=d._mapStrIdx(r,n,0,o.index),[f,_]=d._mapStrIdx(r,u,g,p.length);if(u===-1||g===-1||f===-1||_===-1)continue;let v={start:{x:g+1,y:u+1},end:{x:_,y:f+1}};c.push({range:v,text:p,activate:l})}return c}static _getWindowedLineStrings(e,t){let r,l=e,h=e,i=0,n="",a=[];if(r=t.buffer.active.getLine(e)){let o=r.translateToString(!0);if(r.isWrapped&&o[0]!==" "){for(i=0;(r=t.buffer.active.getLine(--l))&&i<2048&&(n=r.translateToString(!0),i+=n.length,a.push(n),!(!r.isWrapped||n.indexOf(" ")!==-1)););a.reverse()}for(a.push(o),i=0;(r=t.buffer.active.getLine(++h))&&r.isWrapped&&i<2048&&(n=r.translateToString(!0),i+=n.length,a.push(n),n.indexOf(" ")===-1););}return[a,l]}static _mapStrIdx(e,t,r,l){let h=e.buffer.active,i=h.getNullCell(),n=r;for(;l;){let a=h.getLine(t);if(!a)return[-1,-1];for(let o=n;o<a.length;++o){a.getCell(o,i);let c=i.getChars();if(i.getWidth()&&(l-=c.length||1,o===a.length-1&&c==="")){let p=h.getLine(t+1);p&&p.isWrapped&&(p.getCell(0,i),i.getWidth()===2&&(l+=1))}if(l<0)return[t,o]}t++,n=0}return[t,n]}},w=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function k(s,e){let t=window.open();if(t){try{t.opener=null}catch{}t.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}var b=class{constructor(s=k,e={}){this._handler=s,this._options=e}activate(s){this._terminal=s;let e=this._options,t=e.urlRegex||w;this._linkProvider=this._terminal.registerLinkProvider(new L(this._terminal,t,this._handler,e))}dispose(){this._linkProvider?.dispose()}};export{b as WebLinksAddon}; |
no test coverage detected