text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t["diablo-output"]=e()}(this,function(){"use strict";var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,i,s=(function(t,n){!function(t,e){if("string"!=typeof n.nodeName)e(n);else{var i={};e(i),t.AnsiUp=i.default}}(e,function(t){var e,n=this&&this.__makeTemplateObject||function(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t};!function(t){t[t.EOS=0]="EOS",t[t.Text=1]="Text",t[t.Incomplete=2]="Incomplete",t[t.ESC=3]="ESC",t[t.Unknown=4]="Unknown",t[t.SGR=5]="SGR",t[t.OSCURL=6]="OSCURL"}(e||(e={}));var i=function(){function t(){this.VERSION="4.0.4",this.setup_palettes(),this._use_classes=!1,this._escape_for_html=!0,this.bold=!1,this.fg=this.bg=null,this._buffer="",this._url_whitelist={http:1,https:1}}return Object.defineProperty(t.prototype,"use_classes",{get:function(){return this._use_classes},set:function(t){this._use_classes=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"escape_for_html",{get:function(){return this._escape_for_html},set:function(t){this._escape_for_html=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"url_whitelist",{get:function(){return this._url_whitelist},set:function(t){this._url_whitelist=t},enumerable:!0,configurable:!0}),t.prototype.setup_palettes=function(){var t=this;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(function(e){e.forEach(function(e){t.palette_256.push(e)})});for(var e=[0,95,135,175,215,255],n=0;n<6;++n)for(var i=0;i<6;++i)for(var s=0;s<6;++s){var r={rgb:[e[n],e[i],e[s]],class_name:"truecolor"};this.palette_256.push(r)}for(var a=8,o=0;o<24;++o,a+=10){var l={rgb:[a,a,a],class_name:"truecolor"};this.palette_256.push(l)}},t.prototype.escape_txt_for_html=function(t){return t.replace(/[&<>]/gm,function(t){return"&"===t?"&amp;":"<"===t?"&lt;":">"===t?"&gt;":void 0})},t.prototype.append_buffer=function(t){var e=this._buffer+t;this._buffer=e},t.prototype.get_next_packet=function(){var t={kind:e.EOS,text:"",url:""},i=this._buffer.length;if(0==i)return t;var r=this._buffer.indexOf("");if(-1==r)return t.kind=e.Text,t.text=this._buffer,this._buffer="",t;if(r>0)return t.kind=e.Text,t.text=this._buffer.slice(0,r),this._buffer=this._buffer.slice(r),t;if(0==r){if(1==i)return t.kind=e.Incomplete,t;var a=this._buffer.charAt(1);if("["!=a&&"]"!=a)return t.kind=e.ESC,t.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),t;if("["==a){if(this._csi_regex||(this._csi_regex=s(n(["\n                        ^                           # beginning of line\n                                                    #\n                                                    # First attempt\n                        (?:                         # legal sequence\n                          [                      # CSI\n                          ([<-?]?)              # private-mode char\n                          ([d;]*)                    # any digits or semicolons\n                          ([ -/]?               # an intermediate modifier\n                          [@-~])                # the command\n                        )\n                        |                           # alternate (second attempt)\n                        (?:                         # illegal sequence\n                          [                      # CSI\n                          [ -~]*                # anything legal\n                          ([\0-:])              # anything illegal\n                        )\n                    "],["\n                        ^                           # beginning of line\n                                                    #\n                                                    # First attempt\n                        (?:                         # legal sequence\n                          \\x1b\\[                      # CSI\n                          ([\\x3c-\\x3f]?)              # private-mode char\n                          ([\\d;]*)                    # any digits or semicolons\n                          ([\\x20-\\x2f]?               # an intermediate modifier\n                          [\\x40-\\x7e])                # the command\n                        )\n                        |                           # alternate (second attempt)\n                        (?:                         # illegal sequence\n                          \\x1b\\[                      # CSI\n                          [\\x20-\\x7e]*                # anything legal\n                          ([\\x00-\\x1f:])              # anything illegal\n                        )\n                    "]))),null===(f=this._buffer.match(this._csi_regex)))return t.kind=e.Incomplete,t;if(f[4])return t.kind=e.ESC,t.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),t;""!=f[1]||"m"!=f[3]?t.kind=e.Unknown:t.kind=e.SGR,t.text=f[2];var o=f[0].length;return this._buffer=this._buffer.slice(o),t}if("]"==a){if(i<4)return t.kind=e.Incomplete,t;if("8"!=this._buffer.charAt(2)||";"!=this._buffer.charAt(3))return t.kind=e.ESC,t.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),t;this._osc_st||(this._osc_st=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var i=t.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,"");return new RegExp(i,"g")}(n(["\n                        (?:                         # legal sequence\n                          (\\)                    # ESC                           |                           # alternate\n                          ()                      # BEL (what xterm did)\n                        )\n                        |                           # alternate (second attempt)\n                        (                           # illegal sequence\n                          [\0-]                 # anything illegal\n                          |                           # alternate\n                          [\b-]                 # anything illegal\n                          |                           # alternate\n                          [-]                 # anything illegal\n                        )\n                    "],["\n                        (?:                         # legal sequence\n                          (\\x1b\\\\)                    # ESC \\\n                          |                           # alternate\n                          (\\x07)                      # BEL (what xterm did)\n                        )\n                        |                           # alternate (second attempt)\n                        (                           # illegal sequence\n                          [\\x00-\\x06]                 # anything illegal\n                          |                           # alternate\n                          [\\x08-\\x1a]                 # anything illegal\n                          |                           # alternate\n                          [\\x1c-\\x1f]                 # anything illegal\n                        )\n                    "]))),this._osc_st.lastIndex=0;var l=this._osc_st.exec(this._buffer);if(null===l)return t.kind=e.Incomplete,t;if(l[3])return t.kind=e.ESC,t.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),t;var f,u=this._osc_st.exec(this._buffer);if(null===u)return t.kind=e.Incomplete,t;if(u[3])return t.kind=e.ESC,t.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),t;if(this._osc_regex||(this._osc_regex=s(n(["\n                        ^                           # beginning of line\n                                                    #\n                        ]8;                    # OSC Hyperlink\n                        [ -:<-~]*       # params (excluding ;)\n                        ;                           # end of params\n                        ([!-~]{0,512})        # URL capture\n                        (?:                         # ST\n                          (?:\\)                  # ESC                           |                           # alternate\n                          (?:)                    # BEL (what xterm did)\n                        )\n                        ([!-~]+)              # TEXT capture\n                        ]8;;                   # OSC Hyperlink End\n                        (?:                         # ST\n                          (?:\\)                  # ESC                           |                           # alternate\n                          (?:)                    # BEL (what xterm did)\n                        )\n                    "],["\n                        ^                           # beginning of line\n                                                    #\n                        \\x1b\\]8;                    # OSC Hyperlink\n                        [\\x20-\\x3a\\x3c-\\x7e]*       # params (excluding ;)\n                        ;                           # end of params\n                        ([\\x21-\\x7e]{0,512})        # URL capture\n                        (?:                         # ST\n                          (?:\\x1b\\\\)                  # ESC \\\n                          |                           # alternate\n                          (?:\\x07)                    # BEL (what xterm did)\n                        )\n                        ([\\x21-\\x7e]+)              # TEXT capture\n                        \\x1b\\]8;;                   # OSC Hyperlink End\n                        (?:                         # ST\n                          (?:\\x1b\\\\)                  # ESC \\\n                          |                           # alternate\n                          (?:\\x07)                    # BEL (what xterm did)\n                        )\n                    "]))),null===(f=this._buffer.match(this._osc_regex)))return t.kind=e.ESC,t.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),t;t.kind=e.OSCURL,t.url=f[1],t.text=f[2];o=f[0].length;return this._buffer=this._buffer.slice(o),t}}},t.prototype.ansi_to_html=function(t){this.append_buffer(t);for(var n=[];;){var i=this.get_next_packet();if(i.kind==e.EOS||i.kind==e.Incomplete)break;i.kind!=e.ESC&&i.kind!=e.Unknown&&(i.kind==e.Text?n.push(this.transform_to_html(this.with_state(i))):i.kind==e.SGR?this.process_ansi(i):i.kind==e.OSCURL&&n.push(this.process_hyperlink(i)))}return n.join("")},t.prototype.with_state=function(t){return{bold:this.bold,fg:this.fg,bg:this.bg,text:t.text}},t.prototype.process_ansi=function(t){for(var e=t.text.split(";");e.length>0;){var n=e.shift(),i=parseInt(n,10);if(isNaN(i)||0===i)this.fg=this.bg=null,this.bold=!1;else if(1===i)this.bold=!0;else if(22===i)this.bold=!1;else if(39===i)this.fg=null;else if(49===i)this.bg=null;else if(i>=30&&i<38)this.fg=this.ansi_colors[0][i-30];else if(i>=40&&i<48)this.bg=this.ansi_colors[0][i-40];else if(i>=90&&i<98)this.fg=this.ansi_colors[1][i-90];else if(i>=100&&i<108)this.bg=this.ansi_colors[1][i-100];else if((38===i||48===i)&&e.length>0){var s=38===i,r=e.shift();if("5"===r&&e.length>0){var a=parseInt(e.shift(),10);a>=0&&a<=255&&(s?this.fg=this.palette_256[a]:this.bg=this.palette_256[a])}if("2"===r&&e.length>2){var o=parseInt(e.shift(),10),l=parseInt(e.shift(),10),f=parseInt(e.shift(),10);if(o>=0&&o<=255&&l>=0&&l<=255&&f>=0&&f<=255){var u={rgb:[o,l,f],class_name:"truecolor"};s?this.fg=u:this.bg=u}}}}},t.prototype.transform_to_html=function(t){var e=t.text;if(0===e.length)return e;if(this._escape_for_html&&(e=this.escape_txt_for_html(e)),!t.bold&&null===t.fg&&null===t.bg)return e;var n=[],i=[],s=t.fg,r=t.bg;t.bold&&n.push("font-weight:bold"),this._use_classes?(s&&("truecolor"!==s.class_name?i.push(s.class_name+"-fg"):n.push("color:rgb("+s.rgb.join(",")+")")),r&&("truecolor"!==r.class_name?i.push(r.class_name+"-bg"):n.push("background-color:rgb("+r.rgb.join(",")+")"))):(s&&n.push("color:rgb("+s.rgb.join(",")+")"),r&&n.push("background-color:rgb("+r.rgb+")"));var a="",o="";return i.length&&(a=' class="'+i.join(" ")+'"'),n.length&&(o=' style="'+n.join(";")+'"'),"<span"+o+a+">"+e+"</span>"},t.prototype.process_hyperlink=function(t){var e=t.url.split(":");return e.length<1?"":this._url_whitelist[e[0]]?'<a href="'+this.escape_txt_for_html(t.url)+'">'+this.escape_txt_for_html(t.text)+"</a>":""},t}();function s(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var i=t.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,"");return new RegExp(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i})}(n={exports:{}},n.exports),n.exports),r=(i=s)&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i,a=function(e){function n(t){var n,i=e.call(this)||this;return i.au=new r,i._option=t,i._document=document.querySelector((null===(n=i._option)||void 0===n?void 0:n.el)||""),i}return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}(n,e),n.prototype.destroy=function(){},n.prototype.write=function(t,e){var n,i;this.au.ansi_to_html(t);null===(i=null===(n=this._document)||void 0===n?void 0:n.querySelector(".diablo-output"))||void 0===i||i.insertAdjacentHTML("beforeend",this.au.ansi_to_html(t))},n.prototype.create=function(){var t,e=document.createElement("div");null===(t=this._document)||void 0===t||t.appendChild(e),e.classList.add("diablo-output"),e.style.background="#333",e.style.color="#fff"},n}(function(){function t(){this._disposables=[],this._isDisposed=!1}return t.prototype.dispose=function(){this._isDisposed=!0,this._disposables.forEach(function(t){return t.dispose()}),this._disposables.length=0},t.prototype.register=function(t){this._disposables.push(t)},t.prototype.unregister=function(t){var e=this._disposables.indexOf(t);-1!==e&&this._disposables.splice(e,1)},t}()),o=function(){function t(t){this.option=t,this._output=new a(t)}return t.prototype.write=function(t,e){this._output.write(t,e)},t.prototype.create=function(){this._output.create()},t}();return window.DiabloOutput=o,o});
  