var e,t={exports:{}};var i=e?t.exports:(e=1,self,t.exports=(()=>{var e={6:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LinkComputer=t.WebLinkProvider=void 0,t.WebLinkProvider=class{constructor(e,t,i,n={}){this._terminal=e,this._regex=t,this._handler=i,this._options=n}provideLinks(e,t){const n=i.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,i)=>{if(this._options.hover){const{range:n}=e;this._options.hover(t,i,n)}},e))}};class i{static computeLink(e,t,n,r){const s=new RegExp(t.source,(t.flags||"")+"g"),[o,a]=i._getWindowedLineStrings(e-1,n),l=o.join("");let c;const d=[];for(;c=s.exec(l);){const t=c[0];try{const e=new URL(t),i=decodeURI(e.toString());if(t!==i&&t+"/"!==i)continue}catch(e){continue}const[s,o]=i._mapStrIdx(n,a,0,c.index),[l,h]=i._mapStrIdx(n,s,o,t.length);if(-1===s||-1===o||-1===l||-1===h)continue;const p={start:{x:o+1,y:s+1},end:{x:h,y:l+1}};d.push({range:p,text:t,activate:r})}return d}static _getWindowedLineStrings(e,t){let i,n=e,r=e,s=0,o="";const a=[];if(i=t.buffer.active.getLine(e)){const e=i.translateToString(!0);if(i.isWrapped&&" "!==e[0]){for(s=0;(i=t.buffer.active.getLine(--n))&&s<2048&&(o=i.translateToString(!0),s+=o.length,a.push(o),i.isWrapped&&-1===o.indexOf(" ")););a.reverse()}for(a.push(e),s=0;(i=t.buffer.active.getLine(++r))&&i.isWrapped&&s<2048&&(o=i.translateToString(!0),s+=o.length,a.push(o),-1===o.indexOf(" ")););}return[a,n]}static _mapStrIdx(e,t,i,n){const r=e.buffer.active,s=r.getNullCell();let o=i;for(;n;){const e=r.getLine(t);if(!e)return[-1,-1];for(let i=o;i<e.length;++i){e.getCell(i,s);const o=s.getChars();if(s.getWidth()&&(n-=o.length||1,i===e.length-1&&""===o)){const e=r.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,s),2===s.getWidth()&&(n+=1))}if(n<0)return[t,i]}t++,o=0}return[t,o]}}t.LinkComputer=i}},t={};function i(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,i),s.exports}var n={};return(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.WebLinksAddon=void 0;const t=i(6),r=/https?:[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function s(e,t){const i=window.open();if(i){try{i.opener=null}catch(e){}i.location.href=t}}e.WebLinksAddon=class{constructor(e=s,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;const i=this._options,n=i.urlRegex||r;this._linkProvider=this._terminal.registerLinkProvider(new t.WebLinkProvider(this._terminal,n,this._handler,i))}dispose(){var e;null===(e=this._linkProvider)||void 0===e||e.dispose()}}})(),n})());export{i as x};
