"use strict";(self.rspackChunk_JUPYTERLAB_CORE_OUTPUT=self.rspackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[9399],{68831(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=s.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))}},s=class e{static computeLink(t,r,i,s){let n=RegExp(r.source,(r.flags||"")+"g"),[o,a]=e._getWindowedLineStrings(t-1,i),l=o.join(""),h,c=[];for(;h=n.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,n]=e._mapStrIdx(i,a,0,h.index),[o,l]=e._mapStrIdx(i,r,n,t.length);if(-1===r||-1===n||-1===o||-1===l)continue;let p={start:{x:n+1,y:r+1},end:{x:l,y:o+1}};c.push({range:p,text:t,activate:s})}return c}static _getWindowedLineStrings(e,t){let r,i=e,s=e,n=0,o="",a=[];if(r=t.buffer.active.getLine(e)){let e=r.translateToString(!0);if(r.isWrapped&&" "!==e[0]){for(n=0;(r=t.buffer.active.getLine(--i))&&n<2048&&(n+=(o=r.translateToString(!0)).length,a.push(o),!(!r.isWrapped||-1!==o.indexOf(" "))););a.reverse()}for(a.push(e),n=0;(r=t.buffer.active.getLine(++s))&&r.isWrapped&&n<2048&&(n+=(o=r.translateToString(!0)).length,a.push(o),-1===o.indexOf(" ")););}return[a,i]}static _mapStrIdx(e,t,r,i){let s=e.buffer.active,n=s.getNullCell(),o=r;for(;i;){let e=s.getLine(t);if(!e)return[-1,-1];for(let r=o;r<e.length;++r){e.getCell(r,n);let o=n.getChars();if(n.getWidth()&&(i-=o.length||1,r===e.length-1&&""===o)){let e=s.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,n),2===n.getWidth()&&(i+=1))}if(i<0)return[t,r]}t++,o=0}return[t,o]}},n=/(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||n;this._linkProvider=this._terminal.registerLinkProvider(new i(this._terminal,r,this._handler,t))}dispose(){this._linkProvider?.dispose()}}}}]);