import{e as m,a as x,u as S,o as y,s as _,n as w}from"./index-Ms_1iFoB.js";var c=function(l,e){return Object.defineProperty?Object.defineProperty(l,"raw",{value:e}):l.raw=e,l},n;(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"})(n||(n={}));class v{constructor(){this.VERSION="6.0.2",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(i=>{i.forEach(s=>{this.palette_256.push(s)})});let e=[0,95,135,175,215,255];for(let i=0;i<6;++i)for(let s=0;s<6;++s)for(let a=0;a<6;++a){let r={rgb:[e[i],e[s],e[a]],class_name:"truecolor"};this.palette_256.push(r)}let t=8;for(let i=0;i<24;++i,t+=10){let s={rgb:[t,t,t],class_name:"truecolor"};this.palette_256.push(s)}}escape_txt_for_html(e){return this._escape_html?e.replace(/[&<>"']/gm,t=>{if(t==="&")return"&amp;";if(t==="<")return"&lt;";if(t===">")return"&gt;";if(t==='"')return"&quot;";if(t==="'")return"&#x27;"}):e}append_buffer(e){var t=this._buffer+e;this._buffer=t}get_next_packet(){var e={kind:n.EOS,text:"",url:""},t=this._buffer.length;if(t==0)return e;var i=this._buffer.indexOf("\x1B");if(i==-1)return e.kind=n.Text,e.text=this._buffer,this._buffer="",e;if(i>0)return e.kind=n.Text,e.text=this._buffer.slice(0,i),this._buffer=this._buffer.slice(i),e;if(i==0){if(t<3)return e.kind=n.Incomplete,e;var s=this._buffer.charAt(1);if(s!="["&&s!="]"&&s!="(")return e.kind=n.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;if(s=="["){this._csi_regex||(this._csi_regex=g(b||(b=c([`
                        ^                           # 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 r=this._buffer.match(this._csi_regex);if(r===null)return e.kind=n.Incomplete,e;if(r[4])return e.kind=n.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;r[1]!=""||r[3]!="m"?e.kind=n.Unknown:e.kind=n.SGR,e.text=r[2];var a=r[0].length;return this._buffer=this._buffer.slice(a),e}else if(s=="]"){if(t<4)return e.kind=n.Incomplete,e;if(this._buffer.charAt(2)!="8"||this._buffer.charAt(3)!=";")return e.kind=n.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;this._osc_st||(this._osc_st=E(d||(d=c([`
                        (?:                         # 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=n.Incomplete,e;if(o[3])return e.kind=n.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=n.Incomplete,e;if(o[3])return e.kind=n.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e}this._osc_regex||(this._osc_regex=g(p||(p=c([`
                        ^                           # 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 r=this._buffer.match(this._osc_regex);if(r===null)return e.kind=n.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;e.kind=n.OSCURL,e.url=r[1],e.text=r[2];var a=r[0].length;return this._buffer=this._buffer.slice(a),e}else if(s=="(")return e.kind=n.Unknown,this._buffer=this._buffer.slice(3),e}}ansi_to_html(e){this.append_buffer(e);for(var t=[];;){var i=this.get_next_packet();if(i.kind==n.EOS||i.kind==n.Incomplete)break;i.kind==n.ESC||i.kind==n.Unknown||(i.kind==n.Text?t.push(this.transform_to_html(this.with_state(i))):i.kind==n.SGR?this.process_ansi(i):i.kind==n.OSCURL&&t.push(this.process_hyperlink(i)))}return t.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 t=e.text.split(";");for(;t.length>0;){let i=t.shift(),s=parseInt(i,10);if(isNaN(s)||s===0)this.fg=null,this.bg=null,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1;else if(s===1)this.bold=!0;else if(s===2)this.faint=!0;else if(s===3)this.italic=!0;else if(s===4)this.underline=!0;else if(s===21)this.bold=!1;else if(s===22)this.faint=!1,this.bold=!1;else if(s===23)this.italic=!1;else if(s===24)this.underline=!1;else if(s===39)this.fg=null;else if(s===49)this.bg=null;else if(s>=30&&s<38)this.fg=this.ansi_colors[0][s-30];else if(s>=40&&s<48)this.bg=this.ansi_colors[0][s-40];else if(s>=90&&s<98)this.fg=this.ansi_colors[1][s-90];else if(s>=100&&s<108)this.bg=this.ansi_colors[1][s-100];else if((s===38||s===48)&&t.length>0){let a=s===38,r=t.shift();if(r==="5"&&t.length>0){let h=parseInt(t.shift(),10);h>=0&&h<=255&&(a?this.fg=this.palette_256[h]:this.bg=this.palette_256[h])}if(r==="2"&&t.length>2){let h=parseInt(t.shift(),10),o=parseInt(t.shift(),10),f=parseInt(t.shift(),10);if(h>=0&&h<=255&&o>=0&&o<=255&&f>=0&&f<=255){let u={rgb:[h,o,f],class_name:"truecolor"};a?this.fg=u:this.bg=u}}}}}transform_to_html(e){let t=e.text;if(t.length===0||(t=this.escape_txt_for_html(t),!e.bold&&!e.italic&&!e.underline&&e.fg===null&&e.bg===null))return t;let i=[],s=[],a=e.fg,r=e.bg;e.bold&&i.push(this._boldStyle),e.faint&&i.push(this._faintStyle),e.italic&&i.push(this._italicStyle),e.underline&&i.push(this._underlineStyle),this._use_classes?(a&&(a.class_name!=="truecolor"?s.push(`${a.class_name}-fg`):i.push(`color:rgb(${a.rgb.join(",")})`)),r&&(r.class_name!=="truecolor"?s.push(`${r.class_name}-bg`):i.push(`background-color:rgb(${r.rgb.join(",")})`))):(a&&i.push(`color:rgb(${a.rgb.join(",")})`),r&&i.push(`background-color:rgb(${r.rgb})`));let h="",o="";return s.length&&(h=` class="${s.join(" ")}"`),i.length&&(o=` style="${i.join(";")}"`),`<span${o}${h}>${t}</span>`}process_hyperlink(e){let t=e.url.split(":");return t.length<1||!this._url_allowlist[t[0]]?"":`<a href="${this.escape_txt_for_html(e.url)}">${this.escape_txt_for_html(e.text)}</a>`}}function g(l,...e){let t=l.raw[0],i=/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,s=t.replace(i,"");return new RegExp(s)}function E(l,...e){let t=l.raw[0],i=/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,s=t.replace(i,"");return new RegExp(s,"g")}var b,d,p;const k=new v,C=500,T={name:"Debug",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:"green",tooltip:"Start",action:()=>this.toggleDebug(!0),disabled:this.debugActive},{id:"stop",label:"Stop",icon:"stop",color:"red",tooltip:"Stop",action:()=>this.toggleDebug(!1),disabled:!this.debugActive},{id:"clear",label:"Clear",icon:"delete",color:"orange",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:m()},{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:{...x(S,["showSnackbar"]),toggleDebug(l){this.debugActive=l,this.showSnackbar("Debug "+(l?"activated":"disabled"))},newWindow(){y("DEBUG",1e3)},enableAutoScroll(){this.autoScroll=!0,this.scrollBottom()},scrollBottom(){this.autoScroll&&this.$nextTick(()=>{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.socket.on(_.debug,e=>{this.debugActive&&(e=k.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>C&&this.debug.shift(),this.scrollBottom())})},beforeDestroy(){this.socket&&this.socket.off(_.debug)}};var O=function(){var e=this,t=e._self._c;return t("v-container",{attrs:{"grid-list-md":""}},[t("v-row",[t("v-col",{staticStyle:{"max-width":"260px","margin-top":"-2px"}},[t("v-btn-toggle",{attrs:{dense:"",multiple:""}},e._l(e.buttons,function(i){return t("v-tooltip",{key:i.label,attrs:{bottom:"",target:`#${i.id}`},scopedSlots:e._u([{key:"activator",fn:function({on:s}){return[t("v-btn",e._g({attrs:{id:i.id,color:i.color,disabled:i.disabled},on:{click:i.action}},s),[t("v-icon",[e._v(e._s(i.icon))])],1)]}}],null,!0)},[t("span",[e._v(e._s(i.tooltip))])])}),1)],1),t("v-col",{staticClass:"pa-2",attrs:{cols:"6"}},[t("v-text-field",{staticStyle:{"max-width":"300px"},attrs:{flat:"",outlined:"",dense:"","single-line":"",label:"Filter logs",hint:"Type to filter logs, case sensitive","persistent-hint":"","prepend-icon":"search"},model:{value:e.filter,callback:function(i){e.filter=i},expression:"filter"}})],1),t("v-col",{staticClass:"pt-0 mb-5",attrs:{cols:"12"}},[t("div",{staticClass:"mono",staticStyle:{height:"800px",width:"100%","overflow-y":"scroll",border:"1px solid grey",padding:"10px","white-space":"pre"},attrs:{id:"debug_window"},domProps:{innerHTML:e._s(e.filteredLogs.join(""))},on:{scroll:e.onScroll}})])],1)],1)},I=[],B=w(T,O,I,!1,null,null);const j=B.exports;export{j as default};
