import{_ as w,I as E,e as p,w as u,b as f,f as _,g as C,c as k,an as v,P as T,D as B,H as I,V as O,u as L,a9 as U,ao as j,ap as V,z as g,q as R,i as A,l as D,k as $,t as q,am as G}from"./index-DwzE-W2i.js";var b=function(l,e){return Object.defineProperty?Object.defineProperty(l,"raw",{value:e}):l.raw=e,l},r;(function(l){l[l.EOS=0]="EOS",l[l.Text=1]="Text",l[l.Incomplete=2]="Incomplete",l[l.ESC=3]="ESC",l[l.Unknown=4]="Unknown",l[l.SGR=5]="SGR",l[l.OSCURL=6]="OSCURL"})(r||(r={}));class H{constructor(){this.VERSION="6.0.6",this.setup_palettes(),this._use_classes=!1,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1,this.fg=this.bg=null,this._buffer="",this._url_allowlist={http:1,https:1},this._escape_html=!0,this.boldStyle="font-weight:bold",this.faintStyle="opacity:0.7",this.italicStyle="font-style:italic",this.underlineStyle="text-decoration:underline"}set use_classes(e){this._use_classes=e}get use_classes(){return this._use_classes}set url_allowlist(e){this._url_allowlist=e}get url_allowlist(){return this._url_allowlist}set escape_html(e){this._escape_html=e}get escape_html(){return this._escape_html}set boldStyle(e){this._boldStyle=e}get boldStyle(){return this._boldStyle}set faintStyle(e){this._faintStyle=e}get faintStyle(){return this._faintStyle}set italicStyle(e){this._italicStyle=e}get italicStyle(){return this._italicStyle}set underlineStyle(e){this._underlineStyle=e}get underlineStyle(){return this._underlineStyle}setup_palettes(){this.ansi_colors=[[{rgb:[0,0,0],class_name:"ansi-black"},{rgb:[187,0,0],class_name:"ansi-red"},{rgb:[0,187,0],class_name:"ansi-green"},{rgb:[187,187,0],class_name:"ansi-yellow"},{rgb:[0,0,187],class_name:"ansi-blue"},{rgb:[187,0,187],class_name:"ansi-magenta"},{rgb:[0,187,187],class_name:"ansi-cyan"},{rgb:[255,255,255],class_name:"ansi-white"}],[{rgb:[85,85,85],class_name:"ansi-bright-black"},{rgb:[255,85,85],class_name:"ansi-bright-red"},{rgb:[0,255,0],class_name:"ansi-bright-green"},{rgb:[255,255,85],class_name:"ansi-bright-yellow"},{rgb:[85,85,255],class_name:"ansi-bright-blue"},{rgb:[255,85,255],class_name:"ansi-bright-magenta"},{rgb:[85,255,255],class_name:"ansi-bright-cyan"},{rgb:[255,255,255],class_name:"ansi-bright-white"}]],this.palette_256=[],this.ansi_colors.forEach(s=>{s.forEach(t=>{this.palette_256.push(t)})});let e=[0,95,135,175,215,255];for(let s=0;s<6;++s)for(let t=0;t<6;++t)for(let a=0;a<6;++a){let n={rgb:[e[s],e[t],e[a]],class_name:"truecolor"};this.palette_256.push(n)}let i=8;for(let s=0;s<24;++s,i+=10){let t={rgb:[i,i,i],class_name:"truecolor"};this.palette_256.push(t)}}escape_txt_for_html(e){return this._escape_html?e.replace(/[&<>"']/gm,i=>{if(i==="&")return"&amp;";if(i==="<")return"&lt;";if(i===">")return"&gt;";if(i==='"')return"&quot;";if(i==="'")return"&#x27;"}):e}append_buffer(e){var i=this._buffer+e;this._buffer=i}get_next_packet(){var e={kind:r.EOS,text:"",url:""},i=this._buffer.length;if(i==0)return e;var s=this._buffer.indexOf("\x1B");if(s==-1)return e.kind=r.Text,e.text=this._buffer,this._buffer="",e;if(s>0)return e.kind=r.Text,e.text=this._buffer.slice(0,s),this._buffer=this._buffer.slice(s),e;if(s==0){if(i<3)return e.kind=r.Incomplete,e;var t=this._buffer.charAt(1);if(t!="["&&t!="]"&&t!="(")return e.kind=r.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;if(t=="["){this._csi_regex||(this._csi_regex=m(x||(x=b([`
                        ^                           # beginning of line
                                                    #
                                                    # First attempt
                        (?:                         # legal sequence
                          \x1B[                      # CSI
                          ([<-?]?)              # private-mode char
                          ([d;]*)                    # any digits or semicolons
                          ([ -/]?               # an intermediate modifier
                          [@-~])                # the command
                        )
                        |                           # alternate (second attempt)
                        (?:                         # illegal sequence
                          \x1B[                      # CSI
                          [ -~]*                # anything legal
                          ([\0-:])              # anything illegal
                        )
                    `],[`
                        ^                           # beginning of line
                                                    #
                                                    # First attempt
                        (?:                         # legal sequence
                          \\x1b\\[                      # CSI
                          ([\\x3c-\\x3f]?)              # private-mode char
                          ([\\d;]*)                    # any digits or semicolons
                          ([\\x20-\\x2f]?               # an intermediate modifier
                          [\\x40-\\x7e])                # the command
                        )
                        |                           # alternate (second attempt)
                        (?:                         # illegal sequence
                          \\x1b\\[                      # CSI
                          [\\x20-\\x7e]*                # anything legal
                          ([\\x00-\\x1f:])              # anything illegal
                        )
                    `]))));let n=this._buffer.match(this._csi_regex);if(n===null)return e.kind=r.Incomplete,e;if(n[4])return e.kind=r.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;n[1]!=""||n[3]!="m"?e.kind=r.Unknown:e.kind=r.SGR,e.text=n[2];var a=n[0].length;return this._buffer=this._buffer.slice(a),e}else if(t=="]"){if(i<4)return e.kind=r.Incomplete,e;if(this._buffer.charAt(2)!="8"||this._buffer.charAt(3)!=";")return e.kind=r.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;this._osc_st||(this._osc_st=F(S||(S=b([`
                        (?:                         # legal sequence
                          (\x1B\\)                    # ESC                           |                           # alternate
                          (\x07)                      # BEL (what xterm did)
                        )
                        |                           # alternate (second attempt)
                        (                           # illegal sequence
                          [\0-]                 # anything illegal
                          |                           # alternate
                          [\b-]                 # anything illegal
                          |                           # alternate
                          [-]                 # anything illegal
                        )
                    `],[`
                        (?:                         # legal sequence
                          (\\x1b\\\\)                    # ESC \\
                          |                           # alternate
                          (\\x07)                      # BEL (what xterm did)
                        )
                        |                           # alternate (second attempt)
                        (                           # illegal sequence
                          [\\x00-\\x06]                 # anything illegal
                          |                           # alternate
                          [\\x08-\\x1a]                 # anything illegal
                          |                           # alternate
                          [\\x1c-\\x1f]                 # anything illegal
                        )
                    `])))),this._osc_st.lastIndex=0;{let o=this._osc_st.exec(this._buffer);if(o===null)return e.kind=r.Incomplete,e;if(o[3])return e.kind=r.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e}{let o=this._osc_st.exec(this._buffer);if(o===null)return e.kind=r.Incomplete,e;if(o[3])return e.kind=r.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e}this._osc_regex||(this._osc_regex=m(y||(y=b([`
                        ^                           # beginning of line
                                                    #
                        \x1B]8;                    # OSC Hyperlink
                        [ -:<-~]*       # params (excluding ;)
                        ;                           # end of params
                        ([!-~]{0,512})        # URL capture
                        (?:                         # ST
                          (?:\x1B\\)                  # ESC                           |                           # alternate
                          (?:\x07)                    # BEL (what xterm did)
                        )
                        ([ -~]+)              # TEXT capture
                        \x1B]8;;                   # OSC Hyperlink End
                        (?:                         # ST
                          (?:\x1B\\)                  # ESC                           |                           # alternate
                          (?:\x07)                    # BEL (what xterm did)
                        )
                    `],[`
                        ^                           # beginning of line
                                                    #
                        \\x1b\\]8;                    # OSC Hyperlink
                        [\\x20-\\x3a\\x3c-\\x7e]*       # params (excluding ;)
                        ;                           # end of params
                        ([\\x21-\\x7e]{0,512})        # URL capture
                        (?:                         # ST
                          (?:\\x1b\\\\)                  # ESC \\
                          |                           # alternate
                          (?:\\x07)                    # BEL (what xterm did)
                        )
                        ([\\x20-\\x7e]+)              # TEXT capture
                        \\x1b\\]8;;                   # OSC Hyperlink End
                        (?:                         # ST
                          (?:\\x1b\\\\)                  # ESC \\
                          |                           # alternate
                          (?:\\x07)                    # BEL (what xterm did)
                        )
                    `]))));let n=this._buffer.match(this._osc_regex);if(n===null)return e.kind=r.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;e.kind=r.OSCURL,e.url=n[1],e.text=n[2];var a=n[0].length;return this._buffer=this._buffer.slice(a),e}else if(t=="(")return e.kind=r.Unknown,this._buffer=this._buffer.slice(3),e}}ansi_to_html(e){this.append_buffer(e);for(var i=[];;){var s=this.get_next_packet();if(s.kind==r.EOS||s.kind==r.Incomplete)break;s.kind==r.ESC||s.kind==r.Unknown||(s.kind==r.Text?i.push(this.transform_to_html(this.with_state(s))):s.kind==r.SGR?this.process_ansi(s):s.kind==r.OSCURL&&i.push(this.process_hyperlink(s)))}return i.join("")}with_state(e){return{bold:this.bold,faint:this.faint,italic:this.italic,underline:this.underline,fg:this.fg,bg:this.bg,text:e.text}}process_ansi(e){let i=e.text.split(";");for(;i.length>0;){let s=i.shift(),t=parseInt(s,10);if(isNaN(t)||t===0)this.fg=null,this.bg=null,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1;else if(t===1)this.bold=!0;else if(t===2)this.faint=!0;else if(t===3)this.italic=!0;else if(t===4)this.underline=!0;else if(t===21)this.bold=!1;else if(t===22)this.faint=!1,this.bold=!1;else if(t===23)this.italic=!1;else if(t===24)this.underline=!1;else if(t===39)this.fg=null;else if(t===49)this.bg=null;else if(t>=30&&t<38)this.fg=this.ansi_colors[0][t-30];else if(t>=40&&t<48)this.bg=this.ansi_colors[0][t-40];else if(t>=90&&t<98)this.fg=this.ansi_colors[1][t-90];else if(t>=100&&t<108)this.bg=this.ansi_colors[1][t-100];else if((t===38||t===48)&&i.length>0){let a=t===38,n=i.shift();if(n==="5"&&i.length>0){let h=parseInt(i.shift(),10);h>=0&&h<=255&&(a?this.fg=this.palette_256[h]:this.bg=this.palette_256[h])}if(n==="2"&&i.length>2){let h=parseInt(i.shift(),10),o=parseInt(i.shift(),10),c=parseInt(i.shift(),10);if(h>=0&&h<=255&&o>=0&&o<=255&&c>=0&&c<=255){let d={rgb:[h,o,c],class_name:"truecolor"};a?this.fg=d:this.bg=d}}}}}transform_to_html(e){let i=e.text;if(i.length===0||(i=this.escape_txt_for_html(i),!e.bold&&!e.italic&&!e.faint&&!e.underline&&e.fg===null&&e.bg===null))return i;let s=[],t=[],a=e.fg,n=e.bg;e.bold&&s.push(this._boldStyle),e.faint&&s.push(this._faintStyle),e.italic&&s.push(this._italicStyle),e.underline&&s.push(this._underlineStyle),this._use_classes?(a&&(a.class_name!=="truecolor"?t.push(`${a.class_name}-fg`):s.push(`color:rgb(${a.rgb.join(",")})`)),n&&(n.class_name!=="truecolor"?t.push(`${n.class_name}-bg`):s.push(`background-color:rgb(${n.rgb.join(",")})`))):(a&&s.push(`color:rgb(${a.rgb.join(",")})`),n&&s.push(`background-color:rgb(${n.rgb})`));let h="",o="";return t.length&&(h=` class="${t.join(" ")}"`),s.length&&(o=` style="${s.join(";")}"`),`<span${o}${h}>${i}</span>`}process_hyperlink(e){let i=e.url.split(":");return i.length<1||!this._url_allowlist[i[0]]?"":`<a href="${this.escape_txt_for_html(e.url)}">${this.escape_txt_for_html(e.text)}</a>`}}function m(l,...e){let i=l.raw[0],s=/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,t=i.replace(s,"");return new RegExp(t)}function F(l,...e){let i=l.raw[0],s=/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,t=i.replace(s,"");return new RegExp(t,"g")}var x,S,y;const N=new H,W=500,M={name:"Debug",mixins:[E],props:{socket:Object},watch:{},computed:{filteredLogs(){return this.filter?this.debug.filter(l=>l.includes(this.filter)):this.debug},buttons(){return[{id:"start",label:"Start",icon:"play_arrow",color:"success",tooltip:"Start",action:()=>this.toggleDebug(!0),disabled:this.debugActive},{id:"stop",label:"Stop",icon:"stop",color:"error",tooltip:"Stop",action:()=>this.toggleDebug(!1),disabled:!this.debugActive},{id:"clear",label:"Clear",icon:"delete",color:"warning",tooltip:"Clear",action:()=>this.debug=[],disabled:this.debug.length===0},{id:"open",label:"Open",icon:"open_in_new",color:"primary",tooltip:"Open in window",action:this.newWindow,disabled:V()},{id:"scroll",label:"Scroll",icon:"vertical_align_bottom",color:"purple",tooltip:"Enable auto scroll",action:this.enableAutoScroll,disabled:this.autoScroll}]}},data(){return{debug:[],filter:"",debugActive:!0,hideTopbar:!1,autoScroll:!0}},methods:{toggleDebug(l){this.debugActive=l,this.showSnackbar("Debug "+(l?"activated":"disabled"))},newWindow(){j("DEBUG",1e3)},enableAutoScroll(){this.autoScroll=!0,this.scrollBottom()},scrollBottom(){this.autoScroll&&U(()=>{const l=document.getElementById("debug_window");l&&(l.scrollTop=l.scrollHeight)})},onScroll(l){const e=l.target.scrollTop;e<this.prevScrollTop&&(this.autoScroll=!1),this.prevScrollTop=e}},mounted(){window.location.hash.substr(1)==="no-topbar"&&(this.hideTopbar=!0),this.subscribeChannels(["debug"]),this.bindEvent("debug",e=>{this.debugActive&&(e=N.ansi_to_html(e),e=e.replace(/\n/g,"</br>"),e.endsWith("</br>")||(e+="</br>"),e=e.replace(/background-color:rgb\([0-9, ]+\)/g,""),this.debug.push(e),this.debug.length>W&&this.debug.shift(),this.scrollBottom())})},beforeUnmount(){this.socket&&this.unbindEvents()}},X=["innerHTML"];function z(l,e,i,s,t,a){return g(),p(L,{"grid-list-md":""},{default:u(()=>[f(O,null,{default:u(()=>[f(_,{style:{"max-width":"280px","margin-top":"-2px"}},{default:u(()=>[f(C,{density:"compact",multiple:""},{default:u(()=>[(g(!0),k(T,null,v(a.buttons,n=>R((g(),p(A,{size:"small",key:n.label,id:n.id,color:n.disabled?"grey":n.color,disabled:n.disabled,onClick:n.action},{default:u(()=>[f(D,null,{default:u(()=>[$(q(n.icon),1)]),_:2},1024)]),_:2},1032,["id","color","disabled","onClick"])),[[G,n.tooltip,"bottom"]])),128))]),_:1})]),_:1}),f(_,{class:"pa-2",cols:"6"},{default:u(()=>[f(B,{flat:"",variant:"outlined",density:"compact","single-line":"",style:{"max-width":"300px"},label:"Filter logs",hint:"Type to filter logs, case sensitive",modelValue:t.filter,"onUpdate:modelValue":e[0]||(e[0]=n=>t.filter=n),"persistent-hint":"","prepend-icon":"search"},null,8,["modelValue"])]),_:1}),f(_,{class:"pt-0 mb-5",cols:"12"},{default:u(()=>[I("div",{id:"debug_window",onScroll:e[1]||(e[1]=(...n)=>a.onScroll&&a.onScroll(...n)),style:{height:"800px",width:"100%","overflow-y":"scroll",border:"1px solid grey",padding:"10px","white-space":"pre"},class:"mono",innerHTML:a.filteredLogs.join("")},null,40,X)]),_:1})]),_:1})]),_:1})}const Q=w(M,[["render",z]]);export{Q as default};
