import{a as U}from"./chunk-C2XBPNOQ.js";import{a as S,b as O}from"./chunk-7BCHGXO4.js";import{a as g}from"./chunk-OKYAIIFA.js";import{M as w,e as x,g as h,ha as E,n as R,na as L}from"./chunk-CKNHTRCL.js";var F=x((v,b)=>{(function(a,l){typeof define=="function"&&define.amd?define([],l):typeof v<"u"?l():(l(),a.FileSaver={})})(v,function(){"use strict";function a(e,t){return typeof t>"u"?t={autoBom:!1}:typeof t!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e}function l(e,t,n){var i=new XMLHttpRequest;i.open("GET",e),i.responseType="blob",i.onload=function(){r(i.response,t,n)},i.onerror=function(){console.error("could not download file")},i.send()}function d(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch{}return 200<=t.status&&299>=t.status}function c(e){try{e.dispatchEvent(new MouseEvent("click"))}catch{var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var s=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof global=="object"&&global.global===global?global:void 0,m=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),r=s.saveAs||(typeof window!="object"||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!m?function(e,t,n){var i=s.URL||s.webkitURL,o=document.createElement("a");t=t||e.name||"download",o.download=t,o.rel="noopener",typeof e=="string"?(o.href=e,o.origin===location.origin?c(o):d(o.href)?l(e,t,n):c(o,o.target="_blank")):(o.href=i.createObjectURL(e),setTimeout(function(){i.revokeObjectURL(o.href)},4e4),setTimeout(function(){c(o)},0))}:"msSaveOrOpenBlob"in navigator?function(e,t,n){if(t=t||e.name||"download",typeof e!="string")navigator.msSaveOrOpenBlob(a(e,n),t);else if(d(e))l(e,t,n);else{var i=document.createElement("a");i.href=e,i.target="_blank",setTimeout(function(){c(i)})}}:function(e,t,n,i){if(i=i||open("","_blank"),i&&(i.document.title=i.document.body.innerText="downloading..."),typeof e=="string")return l(e,t,n);var o=e.type==="application/octet-stream",z=/constructor/i.test(s.HTMLElement)||s.safari,y=/CriOS\/[\d]+/.test(navigator.userAgent);if((y||o&&z||m)&&typeof FileReader<"u"){var u=new FileReader;u.onloadend=function(){var f=u.result;f=y?f:f.replace(/^data:[^;]*;/,"data:attachment/file;"),i?i.location.href=f:location=f,i=null},u.readAsDataURL(e)}else{var A=s.URL||s.webkitURL,p=A.createObjectURL(e);i?i.location=p:location.href=p,i=null,setTimeout(function(){A.revokeObjectURL(p)},4e4)}});s.saveAs=r.saveAs=r,typeof b<"u"&&(b.exports=r)})});var k=h(S(),1),j=h(O(),1),T=h(U(),1);var W=(()=>{class a{$ws=L(g);term;io;fitAddon;webLinksAddon;resize;elementResize;pluginName;constructor(){}startTerminal(d,c={},s,m){this.pluginName=m,this.elementResize=s,this.io=this.$ws.connectToNamespace("log"),this.term=new k.Terminal(c),setTimeout(()=>{this.term.loadAddon(this.fitAddon),this.term.loadAddon(this.webLinksAddon)}),this.fitAddon=new j.FitAddon,this.webLinksAddon=new T.WebLinksAddon,this.resize=new R,this.term.open(d.nativeElement),setTimeout(()=>{this.fitAddon.activate(this.term),this.fitAddon.fit()}),this.io.connected.subscribe(()=>{this.term.reset(),this.io.socket.emit("tail-log",{cols:this.term.cols,rows:this.term.rows})}),this.io.socket.on("disconnect",()=>{this.term.write(`
\r
\rWebsocket failed to connect. Is the server running?
\r
\r`)}),this.resize.pipe(w(500)).subscribe(r=>{this.io.socket.emit("resize",r)}),this.io.socket.on("stdout",r=>{if(this.pluginName){let e=r.split(`
\r`),t=!1;e.forEach(n=>{if(n){if(t)if(n.match(/36m\[.*?\]/))t=!1;else{this.term.write(`${n}
\r`);return}n.includes(`36m[${this.pluginName}]`)&&(this.term.write(`${n}
\r`),t=!0)}})}else this.term.write(r)}),this.term.onResize(r=>{this.resize.next(r)}),this.elementResize&&this.elementResize.pipe(w(100)).subscribe({next:()=>{this.fitAddon.fit()}})}destroyTerminal(){this.io.end(),this.term.dispose(),this.resize.complete(),this.elementResize&&this.elementResize.complete()}static \u0275fac=function(c){return new(c||a)};static \u0275prov=E({token:a,factory:a.\u0275fac,providedIn:"root"})}return a})();export{W as a,F as b};
