react-terminal-viewer
Version:
<h1 align="center"> react-terminal-viewer </h1>
3 lines (2 loc) • 48.4 kB
JavaScript
!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var t=function(){function t(e){var t=this;this.events={},this.context=e,this.context.addEventListener("message",(function(e){var n=e.data.topic;t.exec(n,e.data)}))}return t.prototype.on=function(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),this},t.prototype.exec=function(e,t){var n=this;return Array.isArray(this.events[e])?(this.events[e].forEach((function(e){e(n,t)})),this):this},t.prototype.send=function(t,n){return void 0===n&&(n={}),this.context.postMessage(e({topic:t},n)),this},t}(),n=function(){function e(e){this.map=new Map,this.queue=[],this.limit=(null==e?void 0:e.limit)||50}return e.prototype.get=function(e){return this.map.get(e)},Object.defineProperty(e.prototype,"size",{get:function(){return this.map.size},enumerable:!1,configurable:!0}),e.prototype.set=function(e,t){if(this.size>=this.limit){var n=this.queue.shift();n&&this.delete(n)}return this.queue.push(e),this.map.set(e,t)},e.prototype.has=function(e){return this.map.has(e)},e.prototype.delete=function(e){return this.map.delete(e)},e}(),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var a,o={};a=o,function(e,t){if("string"!=typeof a.nodeName)t(a);else{var n={};t(n),e.AnsiUp=n.default}}(r,(function(e){var t,n=this&&this.__makeTemplateObject||function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e};!function(e){e[e.EOS=0]="EOS",e[e.Text=1]="Text",e[e.Incomplete=2]="Incomplete",e[e.ESC=3]="ESC",e[e.Unknown=4]="Unknown",e[e.SGR=5]="SGR",e[e.OSCURL=6]="OSCURL"}(t||(t={}));var r=function(){function e(){this.VERSION="5.2.1",this.setup_palettes(),this._use_classes=!1,this.bold=!1,this.italic=!1,this.underline=!1,this.fg=this.bg=null,this._buffer="",this._url_whitelist={http:1,https:1},this._escape_html=!0}return Object.defineProperty(e.prototype,"use_classes",{get:function(){return this._use_classes},set:function(e){this._use_classes=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"url_whitelist",{get:function(){return this._url_whitelist},set:function(e){this._url_whitelist=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"escape_html",{get:function(){return this._escape_html},set:function(e){this._escape_html=e},enumerable:!1,configurable:!0}),e.prototype.setup_palettes=function(){var e=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(t){t.forEach((function(t){e.palette_256.push(t)}))}));for(var t=[0,95,135,175,215,255],n=0;n<6;++n)for(var r=0;r<6;++r)for(var i=0;i<6;++i){var a={rgb:[t[n],t[r],t[i]],class_name:"truecolor"};this.palette_256.push(a)}for(var o=8,s=0;s<24;++s,o+=10){var l={rgb:[o,o,o],class_name:"truecolor"};this.palette_256.push(l)}},e.prototype.escape_txt_for_html=function(e){return this._escape_html?e.replace(/[&<>"']/gm,(function(e){return"&"===e?"&":"<"===e?"<":">"===e?">":'"'===e?""":"'"===e?"'":void 0})):e},e.prototype.append_buffer=function(e){var t=this._buffer+e;this._buffer=t},e.prototype.get_next_packet=function(){var e={kind:t.EOS,text:"",url:""},r=this._buffer.length;if(0==r)return e;var a,o,s,l,u=this._buffer.indexOf("");if(-1==u)return e.kind=t.Text,e.text=this._buffer,this._buffer="",e;if(u>0)return e.kind=t.Text,e.text=this._buffer.slice(0,u),this._buffer=this._buffer.slice(u),e;if(0==u){if(r<3)return e.kind=t.Incomplete,e;var c=this._buffer.charAt(1);if("["!=c&&"]"!=c&&"("!=c)return e.kind=t.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;if("["==c){if(this._csi_regex||(this._csi_regex=i(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===(d=this._buffer.match(this._csi_regex)))return e.kind=t.Incomplete,e;if(d[4])return e.kind=t.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;""!=d[1]||"m"!=d[3]?e.kind=t.Unknown:e.kind=t.SGR,e.text=d[2];var h=d[0].length;return this._buffer=this._buffer.slice(h),e}if("]"==c){if(r<4)return e.kind=t.Incomplete,e;if("8"!=this._buffer.charAt(2)||";"!=this._buffer.charAt(3))return e.kind=t.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;this._osc_st||(this._osc_st=(a=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 "]),o=a.raw[0],s=/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,l=o.replace(s,""),new RegExp(l,"g"))),this._osc_st.lastIndex=0;var f=this._osc_st.exec(this._buffer);if(null===f)return e.kind=t.Incomplete,e;if(f[3])return e.kind=t.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;var d,p=this._osc_st.exec(this._buffer);return null===p?(e.kind=t.Incomplete,e):p[3]?(e.kind=t.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e):(this._osc_regex||(this._osc_regex=i(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 ([\\x20-\\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===(d=this._buffer.match(this._osc_regex))?(e.kind=t.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e):(e.kind=t.OSCURL,e.url=d[1],e.text=d[2],h=d[0].length,this._buffer=this._buffer.slice(h),e))}if("("==c)return e.kind=t.Unknown,this._buffer=this._buffer.slice(3),e}},e.prototype.ansi_to_html=function(e){this.append_buffer(e);for(var n=[];;){var r=this.get_next_packet();if(r.kind==t.EOS||r.kind==t.Incomplete)break;r.kind!=t.ESC&&r.kind!=t.Unknown&&(r.kind==t.Text?n.push(this.transform_to_html(this.with_state(r))):r.kind==t.SGR?this.process_ansi(r):r.kind==t.OSCURL&&n.push(this.process_hyperlink(r)))}return n.join("")},e.prototype.with_state=function(e){return{bold:this.bold,italic:this.italic,underline:this.underline,fg:this.fg,bg:this.bg,text:e.text}},e.prototype.process_ansi=function(e){for(var t=e.text.split(";");t.length>0;){var n=t.shift(),r=parseInt(n,10);if(isNaN(r)||0===r)this.fg=this.bg=null,this.bold=!1,this.italic=!1,this.underline=!1;else if(1===r)this.bold=!0;else if(3===r)this.italic=!0;else if(4===r)this.underline=!0;else if(22===r)this.bold=!1;else if(23===r)this.italic=!1;else if(24===r)this.underline=!1;else if(39===r)this.fg=null;else if(49===r)this.bg=null;else if(r>=30&&r<38)this.fg=this.ansi_colors[0][r-30];else if(r>=40&&r<48)this.bg=this.ansi_colors[0][r-40];else if(r>=90&&r<98)this.fg=this.ansi_colors[1][r-90];else if(r>=100&&r<108)this.bg=this.ansi_colors[1][r-100];else if((38===r||48===r)&&t.length>0){var i=38===r,a=t.shift();if("5"===a&&t.length>0){var o=parseInt(t.shift(),10);o>=0&&o<=255&&(i?this.fg=this.palette_256[o]:this.bg=this.palette_256[o])}if("2"===a&&t.length>2){var s=parseInt(t.shift(),10),l=parseInt(t.shift(),10),u=parseInt(t.shift(),10);if(s>=0&&s<=255&&l>=0&&l<=255&&u>=0&&u<=255){var c={rgb:[s,l,u],class_name:"truecolor"};i?this.fg=c:this.bg=c}}}}},e.prototype.transform_to_html=function(e){var t=e.text;if(0===t.length)return t;if(t=this.escape_txt_for_html(t),!e.bold&&!e.italic&&!e.underline&&null===e.fg&&null===e.bg)return t;var n=[],r=[],i=e.fg,a=e.bg;e.bold&&n.push("font-weight:bold"),e.italic&&n.push("font-style:italic"),e.underline&&n.push("text-decoration:underline"),this._use_classes?(i&&("truecolor"!==i.class_name?r.push(i.class_name+"-fg"):n.push("color:rgb("+i.rgb.join(",")+")")),a&&("truecolor"!==a.class_name?r.push(a.class_name+"-bg"):n.push("background-color:rgb("+a.rgb.join(",")+")"))):(i&&n.push("color:rgb("+i.rgb.join(",")+")"),a&&n.push("background-color:rgb("+a.rgb+")"));var o="",s="";return r.length&&(o=' class="'+r.join(" ")+'"'),n.length&&(s=' style="'+n.join(";")+'"'),"<span"+s+o+">"+t+"</span>"},e.prototype.process_hyperlink=function(e){var t=e.url.split(":");return t.length<1?"":this._url_whitelist[t[0]]?'<a href="'+this.escape_txt_for_html(e.url)+'">'+this.escape_txt_for_html(e.text)+"</a>":""},e}();function i(e){var t=e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,"");return new RegExp(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r}));var s=i(o),l={entityMap:{lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",times:"×",divide:"÷",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",euro:"€",trade:"™",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"}},u={},c=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,h=new RegExp("[\\-\\.0-9"+c.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),f=new RegExp("^"+c.source+h.source+"*(?::"+c.source+h.source+"*)?$"),d=0,p=1,m=2,g=3,b=4,v=5,N=6,w=7;function _(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,_)}function x(){}function y(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function E(e,t,n,r,i,a){function o(e,t,r){e in n.attributeNames&&a.fatalError("Attribute "+e+" redefined"),n.addValue(e,t,r)}for(var s,l=++t,u=d;;){var c=e.charAt(l);switch(c){case"=":if(u===p)s=e.slice(t,l),u=g;else{if(u!==m)throw new Error("attribute equal must after attrName");u=g}break;case"'":case'"':if(u===g||u===p){if(u===p&&(a.warning('attribute value must after "="'),s=e.slice(t,l)),t=l+1,!((l=e.indexOf(c,t))>0))throw new Error("attribute value no end '"+c+"' match");o(s,h=e.slice(t,l).replace(/&#?\w+;/g,i),t-1),u=v}else{if(u!=b)throw new Error('attribute value must after "="');o(s,h=e.slice(t,l).replace(/&#?\w+;/g,i),t),a.warning('attribute "'+s+'" missed start quot('+c+")!!"),t=l+1,u=v}break;case"/":switch(u){case d:n.setTagName(e.slice(t,l));case v:case N:case w:u=w,n.closed=!0;case b:case p:case m:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return a.error("unexpected end of input"),u==d&&n.setTagName(e.slice(t,l)),l;case">":switch(u){case d:n.setTagName(e.slice(t,l));case v:case N:case w:break;case b:case p:"/"===(h=e.slice(t,l)).slice(-1)&&(n.closed=!0,h=h.slice(0,-1));case m:u===m&&(h=s),u==b?(a.warning('attribute "'+h+'" missed quot(")!'),o(s,h.replace(/&#?\w+;/g,i),t)):("http://www.w3.org/1999/xhtml"===r[""]&&h.match(/^(?:disabled|checked|selected)$/i)||a.warning('attribute "'+h+'" missed value!! "'+h+'" instead!!'),o(h,h,t));break;case g:throw new Error("attribute value missed!!")}return l;case"":c=" ";default:if(c<=" ")switch(u){case d:n.setTagName(e.slice(t,l)),u=N;break;case p:s=e.slice(t,l),u=m;break;case b:var h=e.slice(t,l).replace(/&#?\w+;/g,i);a.warning('attribute "'+h+'" missed quot(")!!'),o(s,h,t);case v:u=N}else switch(u){case m:n.tagName,"http://www.w3.org/1999/xhtml"===r[""]&&s.match(/^(?:disabled|checked|selected)$/i)||a.warning('attribute "'+s+'" missed value!! "'+s+'" instead2!!'),o(s,s,t),t=l,u=p;break;case v:a.warning('attribute space is required"'+s+'"!!');case N:u=p,t=l;break;case g:u=b,t=l;break;case w:throw new Error("elements closed character '/' and '>' must be connected to")}}l++}}function S(e,t,n){for(var r=e.tagName,i=null,a=e.length;a--;){var o=e[a],s=o.qName,l=o.value;if((f=s.indexOf(":"))>0)var u=o.prefix=s.slice(0,f),c=s.slice(f+1),h="xmlns"===u&&c;else c=s,u=null,h="xmlns"===s&&"";o.localName=c,!1!==h&&(null==i&&(i={},I(n,n={})),n[h]=i[h]=l,o.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(h,l))}for(a=e.length;a--;){(u=(o=e[a]).prefix)&&("xml"===u&&(o.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==u&&(o.uri=n[u||""]))}var f;(f=r.indexOf(":"))>0?(u=e.prefix=r.slice(0,f),c=e.localName=r.slice(f+1)):(u=null,c=e.localName=r);var d=e.uri=n[u||""];if(t.startElement(d,c,r,e),!e.closed)return e.currentNSMap=n,e.localNSMap=i,!0;if(t.endElement(d,c,r),i)for(u in i)t.endPrefixMapping(u)}function C(e,t,n,r,i){if(/^(?:script|textarea)$/i.test(n)){var a=e.indexOf("</"+n+">",t),o=e.substring(t+1,a);if(/[&<]/.test(o))return/^script$/i.test(n)?(i.characters(o,0,o.length),a):(o=o.replace(/&#?\w+;/g,r),i.characters(o,0,o.length),a)}return t+1}function T(e,t,n,r){var i=r[n];return null==i&&((i=e.lastIndexOf("</"+n+">"))<t&&(i=e.lastIndexOf("</"+n)),r[n]=i),i<t}function I(e,t){for(var n in e)t[n]=e[n]}function D(e,t,n,r){if("-"===e.charAt(t+2))return"-"===e.charAt(t+3)?(i=e.indexOf("--\x3e",t+4))>t?(n.comment(e,t+4,i-t-4),i+3):(r.error("Unclosed comment"),-1):-1;if("CDATA["==e.substr(t+3,6)){var i=e.indexOf("]]>",t+9);return n.startCDATA(),n.characters(e,t+9,i-t-9),n.endCDATA(),i+3}var a=function(e,t){var n,r=[],i=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;i.lastIndex=t,i.exec(e);for(;n=i.exec(e);)if(r.push(n),n[1])return r}(e,t),o=a.length;if(o>1&&/!doctype/i.test(a[0][0])){var s=a[1][0],l=!1,u=!1;o>3&&(/^public$/i.test(a[2][0])?(l=a[3][0],u=o>4&&a[4][0]):/^system$/i.test(a[2][0])&&(u=a[3][0]));var c=a[o-1];return n.startDTD(s,l,u),n.endDTD(),c.index+c[0].length}return-1}function k(e,t,n){var r=e.indexOf("?>",t);if(r){var i=e.substring(t,r).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);return i?(i[0].length,n.processingInstruction(i[1],i[2]),r+2):-1}return-1}function A(){this.attributeNames={}}_.prototype=new Error,_.prototype.name=_.name,x.prototype={parse:function(e,t,n){var r=this.domBuilder;r.startDocument(),I(t,t={}),function(e,t,n,r,i){function a(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}function o(e){var t=e.slice(1,-1);return t in n?n[t]:"#"===t.charAt(0)?a(parseInt(t.substr(1).replace("x","0x"))):(i.error("entity not found:"+e),e)}function s(t){if(t>m){var n=e.substring(m,t).replace(/&#?\w+;/g,o);f&&l(m),r.characters(n,0,t-m),m=t}}function l(t,n){for(;t>=c&&(n=h.exec(e));)u=n.index,c=u+n[0].length,f.lineNumber++;f.columnNumber=t-u+1}var u=0,c=0,h=/.*(?:\r\n?|\n)|.*$/g,f=r.locator,d=[{currentNSMap:t}],p={},m=0;for(;;){try{var g=e.indexOf("<",m);if(g<0){if(!e.substr(m).match(/^\s*$/)){var b=r.doc,v=b.createTextNode(e.substr(m));b.appendChild(v),r.currentElement=v}return}switch(g>m&&s(g),e.charAt(g+1)){case"/":var N=e.indexOf(">",g+3),w=e.substring(g+2,N),x=d.pop();N<0?(w=e.substring(g+2).replace(/[\s<].*/,""),i.error("end tag name: "+w+" is not complete:"+x.tagName),N=g+1+w.length):w.match(/\s</)&&(w=w.replace(/[\s<].*/,""),i.error("end tag name: "+w+" maybe not complete"),N=g+1+w.length);var I=x.localNSMap,O=x.tagName==w;if(O||x.tagName&&x.tagName.toLowerCase()==w.toLowerCase()){if(r.endElement(x.uri,x.localName,w),I)for(var R in I)r.endPrefixMapping(R);O||i.fatalError("end tag name: "+w+" is not match the current start tagName:"+x.tagName)}else d.push(x);N++;break;case"?":f&&l(g),N=k(e,g,r);break;case"!":f&&l(g),N=D(e,g,r,i);break;default:f&&l(g);var M=new A,U=d[d.length-1].currentNSMap,L=(N=E(e,g,M,U,o,i),M.length);if(!M.closed&&T(e,N,M.tagName,p)&&(M.closed=!0,n.nbsp||i.warning("unclosed xml attribute")),f&&L){for(var B=y(f,{}),F=0;F<L;F++){var P=M[F];l(P.offset),P.locator=y(f,{})}r.locator=B,S(M,r,U)&&d.push(M),r.locator=f}else S(M,r,U)&&d.push(M);"http://www.w3.org/1999/xhtml"!==M.uri||M.closed?N++:N=C(e,N,M.tagName,o,r)}}catch(e){if(e instanceof _)throw e;i.error("element parse error: "+e),N=-1}N>m?m=N:s(Math.max(g,m)+1)}}(e,t,n,r,this.errorHandler),r.endDocument()}},A.prototype={setTagName:function(e){if(!f.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,n){if(!f.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:n}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},u.XMLReader=x,u.ParseError=_;var O={};function R(e,t){for(var n in e)t[n]=e[n]}function M(e,t){var n=e.prototype;if(!(n instanceof t)){function r(){}r.prototype=t.prototype,R(n,r=new r),e.prototype=n=r}n.constructor!=e&&("function"!=typeof e&&console.error("unknow Class:"+e),n.constructor=e)}var U="http://www.w3.org/1999/xhtml",L={},B=L.ELEMENT_NODE=1,F=L.ATTRIBUTE_NODE=2,P=L.TEXT_NODE=3,q=L.CDATA_SECTION_NODE=4,j=L.ENTITY_REFERENCE_NODE=5,$=L.ENTITY_NODE=6,V=L.PROCESSING_INSTRUCTION_NODE=7,z=L.COMMENT_NODE=8,H=L.DOCUMENT_NODE=9,X=L.DOCUMENT_TYPE_NODE=10,Y=L.DOCUMENT_FRAGMENT_NODE=11,G=L.NOTATION_NODE=12,W={},K={};W.INDEX_SIZE_ERR=(K[1]="Index size error",1),W.DOMSTRING_SIZE_ERR=(K[2]="DOMString size error",2);var Z=W.HIERARCHY_REQUEST_ERR=(K[3]="Hierarchy request error",3);W.WRONG_DOCUMENT_ERR=(K[4]="Wrong document",4),W.INVALID_CHARACTER_ERR=(K[5]="Invalid character",5),W.NO_DATA_ALLOWED_ERR=(K[6]="No data allowed",6),W.NO_MODIFICATION_ALLOWED_ERR=(K[7]="No modification allowed",7);var Q=W.NOT_FOUND_ERR=(K[8]="Not found",8);W.NOT_SUPPORTED_ERR=(K[9]="Not supported",9);var J=W.INUSE_ATTRIBUTE_ERR=(K[10]="Attribute in use",10);function ee(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,K[e]),this.message=K[e],Error.captureStackTrace&&Error.captureStackTrace(this,ee);return n.code=e,t&&(this.message=this.message+": "+t),n}function te(){}function ne(e,t){this._node=e,this._refresh=t,re(this)}function re(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!=t){var n=e._refresh(e._node);Ue(e,"length",n.length),R(n,e),e._inc=t}}function ie(){}function ae(e,t){for(var n=e.length;n--;)if(e[n]===t)return n}function oe(e,t,n,r){if(r?t[ae(t,r)]=n:t[t.length++]=n,e){n.ownerElement=e;var i=e.ownerDocument;i&&(r&&de(i,e,r),function(e,t,n){e&&e._inc++;var r=n.namespaceURI;"http://www.w3.org/2000/xmlns/"==r&&(t._nsMap[n.prefix?n.localName:""]=n.value)}(i,e,n))}}function se(e,t,n){var r=ae(t,n);if(!(r>=0))throw ee(Q,new Error(e.tagName+"@"+n));for(var i=t.length-1;r<i;)t[r]=t[++r];if(t.length=i,e){var a=e.ownerDocument;a&&(de(a,e,n),n.ownerElement=null)}}function le(e){if(this._features={},e)for(var t in e)this._features=e[t]}function ue(){}function ce(e){return("<"==e?"<":">"==e&&">")||"&"==e&&"&"||'"'==e&&"""||"&#"+e.charCodeAt()+";"}function he(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(he(e,t))return!0}while(e=e.nextSibling)}function fe(){}function de(e,t,n,r){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==n.namespaceURI&&delete t._nsMap[n.prefix?n.localName:""]}function pe(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n)r[r.length++]=n;else{for(var i=t.firstChild,a=0;i;)r[a++]=i,i=i.nextSibling;r.length=a}}}function me(e,t){var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,pe(e.ownerDocument,e),t}function ge(e,t,n){var r=t.parentNode;if(r&&r.removeChild(t),t.nodeType===Y){var i=t.firstChild;if(null==i)return t;var a=t.lastChild}else i=a=t;var o=n?n.previousSibling:e.lastChild;i.previousSibling=o,a.nextSibling=n,o?o.nextSibling=i:e.firstChild=i,null==n?e.lastChild=a:n.previousSibling=a;do{i.parentNode=e}while(i!==a&&(i=i.nextSibling));return pe(e.ownerDocument||e,e),t.nodeType==Y&&(t.firstChild=t.lastChild=null),t}function be(){this._nsMap={}}function ve(){}function Ne(){}function we(){}function _e(){}function xe(){}function ye(){}function Ee(){}function Se(){}function Ce(){}function Te(){}function Ie(){}function De(){}function ke(e,t){var n=[],r=9==this.nodeType&&this.documentElement||this,i=r.prefix,a=r.namespaceURI;if(a&&null==i&&null==(i=r.lookupPrefix(a)))var o=[{namespace:a,prefix:null}];return Oe(this,n,e,t,o),n.join("")}function Ae(e,t,n){var r=e.prefix||"",i=e.namespaceURI;if(!r&&!i)return!1;if("xml"===r&&"http://www.w3.org/XML/1998/namespace"===i||"http://www.w3.org/2000/xmlns/"==i)return!1;for(var a=n.length;a--;){var o=n[a];if(o.prefix==r)return o.namespace!=i}return!0}function Oe(e,t,n,r,i){if(r){if(!(e=r(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case B:i||(i=[]),i.length;var a=e.attributes,o=a.length,s=e.firstChild,l=e.tagName;n=U===e.namespaceURI||n,t.push("<",l);for(var u=0;u<o;u++){"xmlns"==(c=a.item(u)).prefix?i.push({prefix:c.localName,namespace:c.value}):"xmlns"==c.nodeName&&i.push({prefix:"",namespace:c.value})}for(u=0;u<o;u++){var c;if(Ae(c=a.item(u),0,i)){var h=c.prefix||"",f=c.namespaceURI,d=h?" xmlns:"+h:" xmlns";t.push(d,'="',f,'"'),i.push({prefix:h,namespace:f})}Oe(c,t,n,r,i)}if(Ae(e,0,i)){h=e.prefix||"";if(f=e.namespaceURI){d=h?" xmlns:"+h:" xmlns";t.push(d,'="',f,'"'),i.push({prefix:h,namespace:f})}}if(s||n&&!/^(?:meta|link|img|br|hr|input)$/i.test(l)){if(t.push(">"),n&&/^script$/i.test(l))for(;s;)s.data?t.push(s.data):Oe(s,t,n,r,i),s=s.nextSibling;else for(;s;)Oe(s,t,n,r,i),s=s.nextSibling;t.push("</",l,">")}else t.push("/>");return;case H:case Y:for(s=e.firstChild;s;)Oe(s,t,n,r,i),s=s.nextSibling;return;case F:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,ce),'"');case P:return t.push(e.data.replace(/[<&]/g,ce).replace(/]]>/g,"]]>"));case q:return t.push("<![CDATA[",e.data,"]]>");case z:return t.push("\x3c!--",e.data,"--\x3e");case X:var p=e.publicId,m=e.systemId;if(t.push("<!DOCTYPE ",e.name),p)t.push(" PUBLIC ",p),m&&"."!=m&&t.push(" ",m),t.push(">");else if(m&&"."!=m)t.push(" SYSTEM ",m,">");else{var g=e.internalSubset;g&&t.push(" [",g,"]"),t.push(">")}return;case V:return t.push("<?",e.target," ",e.data,"?>");case j:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function Re(e,t,n){var r;switch(t.nodeType){case B:(r=t.cloneNode(!1)).ownerDocument=e;case Y:break;case F:n=!0}if(r||(r=t.cloneNode(!1)),r.ownerDocument=e,r.parentNode=null,n)for(var i=t.firstChild;i;)r.appendChild(Re(e,i,n)),i=i.nextSibling;return r}function Me(e,t,n){var r=new t.constructor;for(var i in t){var a=t[i];"object"!=typeof a&&a!=r[i]&&(r[i]=a)}switch(t.childNodes&&(r.childNodes=new te),r.ownerDocument=e,r.nodeType){case B:var o=t.attributes,s=r.attributes=new ie,l=o.length;s._ownerElement=r;for(var u=0;u<l;u++)r.setAttributeNode(Me(e,o.item(u),!0));break;case F:n=!0}if(n)for(var c=t.firstChild;c;)r.appendChild(Me(e,c,n)),c=c.nextSibling;return r}function Ue(e,t,n){e[t]=n}W.INVALID_STATE_ERR=(K[11]="Invalid state",11),W.SYNTAX_ERR=(K[12]="Syntax error",12),W.INVALID_MODIFICATION_ERR=(K[13]="Invalid modification",13),W.NAMESPACE_ERR=(K[14]="Invalid namespace",14),W.INVALID_ACCESS_ERR=(K[15]="Invalid access",15),ee.prototype=Error.prototype,R(W,ee),te.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],r=0;r<this.length;r++)Oe(this[r],n,e,t);return n.join("")}},ne.prototype.item=function(e){return re(this),this[e]},M(ne,te),ie.prototype={length:0,item:te.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var n=this[t];if(n.nodeName==e)return n}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new ee(J);var n=this.getNamedItem(e.nodeName);return oe(this._ownerElement,this,e,n),n},setNamedItemNS:function(e){var t,n=e.ownerElement;if(n&&n!=this._ownerElement)throw new ee(J);return t=this.getNamedItemNS(e.namespaceURI,e.localName),oe(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return se(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var n=this.getNamedItemNS(e,t);return se(this._ownerElement,this,n),n},getNamedItemNS:function(e,t){for(var n=this.length;n--;){var r=this[n];if(r.localName==t&&r.namespaceURI==e)return r}return null}},le.prototype={hasFeature:function(e,t){var n=this._features[e.toLowerCase()];return!(!n||t&&!(t in n))},createDocument:function(e,t,n){var r=new fe;if(r.implementation=this,r.childNodes=new te,r.doctype=n,n&&r.appendChild(n),t){var i=r.createElementNS(e,t);r.appendChild(i)}return r},createDocumentType:function(e,t,n){var r=new ye;return r.name=e,r.nodeName=e,r.publicId=t,r.systemId=n,r}},ue.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return ge(this,e,t)},replaceChild:function(e,t){this.insertBefore(e,t),t&&this.removeChild(t)},removeChild:function(e){return me(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return Me(this.ownerDocument||this,this,e)},normalize:function(){for(var e=this.firstChild;e;){var t=e.nextSibling;t&&t.nodeType==P&&e.nodeType==P?(this.removeChild(t),e.appendData(t.data)):(e.normalize(),e=t)}},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n)for(var r in n)if(n[r]==e)return r;t=t.nodeType==F?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&e in n)return n[e];t=t.nodeType==F?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},R(L,ue),R(L,ue.prototype),fe.prototype={nodeName:"#document",nodeType:H,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==Y){for(var n=e.firstChild;n;){var r=n.nextSibling;this.insertBefore(n,t),n=r}return e}return null==this.documentElement&&e.nodeType==B&&(this.documentElement=e),ge(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),me(this,e)},importNode:function(e,t){return Re(this,e,t)},getElementById:function(e){var t=null;return he(this.documentElement,(function(n){if(n.nodeType==B&&n.getAttribute("id")==e)return t=n,!0})),t},getElementsByClassName:function(e){var t=new RegExp("(^|\\s)"+e+"(\\s|$)");return new ne(this,(function(e){var n=[];return he(e.documentElement,(function(r){r!==e&&r.nodeType==B&&t.test(r.getAttribute("class"))&&n.push(r)})),n}))},createElement:function(e){var t=new be;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new te,(t.attributes=new ie)._ownerElement=t,t},createDocumentFragment:function(){var e=new Te;return e.ownerDocument=this,e.childNodes=new te,e},createTextNode:function(e){var t=new we;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new _e;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new xe;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new Ie;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new ve;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new Ce;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new be,r=t.split(":"),i=n.attributes=new ie;return n.childNodes=new te,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,i._ownerElement=n,n},createAttributeNS:function(e,t){var n=new ve,r=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,n}},M(fe,ue),be.prototype={nodeType:B,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===Y?this.insertBefore(e,null):function(e,t){var n=t.parentNode;if(n){var r=e.lastChild;n.removeChild(t),r=e.lastChild}return r=e.lastChild,t.parentNode=e,t.previousSibling=r,t.nextSibling=null,r?r.nextSibling=t:e.firstChild=t,e.lastChild=t,pe(e.ownerDocument,e,t),t}(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var r=this.ownerDocument.createAttributeNS(e,t);r.value=r.nodeValue=""+n,this.setAttributeNode(r)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new ne(this,(function(t){var n=[];return he(t,(function(r){r===t||r.nodeType!=B||"*"!==e&&r.tagName!=e||n.push(r)})),n}))},getElementsByTagNameNS:function(e,t){return new ne(this,(function(n){var r=[];return he(n,(function(i){i===n||i.nodeType!==B||"*"!==e&&i.namespaceURI!==e||"*"!==t&&i.localName!=t||r.push(i)})),r}))}},fe.prototype.getElementsByTagName=be.prototype.getElementsByTagName,fe.prototype.getElementsByTagNameNS=be.prototype.getElementsByTagNameNS,M(be,ue),ve.prototype.nodeType=F,M(ve,ue),Ne.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(K[Z])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){n=this.data.substring(0,e)+n+this.data.substring(e+t),this.nodeValue=this.data=n,this.length=n.length}},M(Ne,ue),we.prototype={nodeName:"#text",nodeType:P,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}},M(we,Ne),_e.prototype={nodeName:"#comment",nodeType:z},M(_e,Ne),xe.prototype={nodeName:"#cdata-section",nodeType:q},M(xe,Ne),ye.prototype.nodeType=X,M(ye,ue),Ee.prototype.nodeType=G,M(Ee,ue),Se.prototype.nodeType=$,M(Se,ue),Ce.prototype.nodeType=j,M(Ce,ue),Te.prototype.nodeName="#document-fragment",Te.prototype.nodeType=Y,M(Te,ue),Ie.prototype.nodeType=V,M(Ie,ue),De.prototype.serializeToString=function(e,t,n){return ke.call(e,t,n)},ue.prototype.toString=ke;try{if(Object.defineProperty){function Je(e){switch(e.nodeType){case B:case Y:var t=[];for(e=e.firstChild;e;)7!==e.nodeType&&8!==e.nodeType&&t.push(Je(e)),e=e.nextSibling;return t.join("");default:return e.nodeValue}}Object.defineProperty(ne.prototype,"length",{get:function(){return re(this),this.$$length}}),Object.defineProperty(ue.prototype,"textContent",{get:function(){return Je(this)},set:function(e){switch(this.nodeType){case B:case Y:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),Ue=function(e,t,n){e["$$"+t]=n}}}catch(et){}function Le(e){this.options=e||{locator:{}}}function Be(){this.cdata=!1}function Fe(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function Pe(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function qe(e,t,n){return"string"==typeof e?e.substr(t,n):e.length>=t+n||t?new java.lang.String(e,t,n)+"":e}function je(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}O.Node=ue,O.DOMException=ee,O.DOMImplementation=le,O.XMLSerializer=De,Le.prototype.parseFromString=function(e,t){var n=this.options,r=new ze,i=n.domBuilder||new Be,a=n.errorHandler,o=n.locator,s=n.xmlns||{},l=/\/x?html?$/.test(t),u=l?$e.entityMap:{lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return o&&i.setDocumentLocator(o),r.errorHandler=function(e,t,n){if(!e){if(t instanceof Be)return t;e=t}var r={},i=e instanceof Function;function a(t){var a=e[t];!a&&i&&(a=2==e.length?function(n){e(t,n)}:e),r[t]=a&&function(e){a("[xmldom "+t+"]\t"+e+Pe(n))}||function(){}}return n=n||{},a("warning"),a("error"),a("fatalError"),r}(a,i,o),r.domBuilder=n.domBuilder||i,l&&(s[""]="http://www.w3.org/1999/xhtml"),s.xml=s.xml||"http://www.w3.org/XML/1998/namespace",e&&"string"==typeof e?r.parse(e,s,u):r.errorHandler.error("invalid doc source"),i.doc},Be.prototype={startDocument:function(){this.doc=(new Xe).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,r){var i=this.doc,a=i.createElementNS(e,n||t),o=r.length;je(this,a),this.currentElement=a,this.locator&&Fe(this.locator,a);for(var s=0;s<o;s++){e=r.getURI(s);var l=r.getValue(s),u=(n=r.getQName(s),i.createAttributeNS(e,n));this.locator&&Fe(r.getLocator(s),u),u.value=u.nodeValue=l,a.setAttributeNode(u)}},endElement:function(e,t,n){var r=this.currentElement;r.tagName,this.currentElement=r.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var n=this.doc.createProcessingInstruction(e,t);this.locator&&Fe(this.locator,n),je(this,n)},ignorableWhitespace:function(e,t,n){},characters:function(e,t,n){if(e=qe.apply(this,arguments)){if(this.cdata)var r=this.doc.createCDATASection(e);else r=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(r):/^\s*$/.test(e)&&this.doc.appendChild(r),this.locator&&Fe(this.locator,r)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,n){e=qe.apply(this,arguments);var r=this.doc.createComment(e);this.locator&&Fe(this.locator,r),je(this,r)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,n){var r=this.doc.implementation;if(r&&r.createDocumentType){var i=r.createDocumentType(e,t,n);this.locator&&Fe(this.locator,i),je(this,i)}},warning:function(e){console.warn("[xmldom warning]\t"+e,Pe(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,Pe(this.locator))},fatalError:function(e){throw new He(e,this.locator)}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,(function(e){Be.prototype[e]=function(){return null}}));var $e=l,Ve=u,ze=Ve.XMLReader,He=Ve.ParseError,Xe=O.DOMImplementation,Ye=Le,Ge=function(){function e(e,t){void 0===t&&(t={className:"terminal-viewer-hl-mark",markedClassName:"terminal-viewer-hl-mark terminal-viewer-hl-marked"}),this.isMarked=!1,this.dom=(new Ye).parseFromString("".concat('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',"<html><body>").concat(e,"</body></html>"),"text/html"),this.options=t,this.matchCount=0,this.matchedIndex=0,this.isMarked=!1,this.hlIndex=0}return e.prototype.mark=function(e,t){var n=this;void 0===t&&(t={matchedIndex:0,hlIndex:0});var r=new RegExp(this.escapeStr(e),"gi"),i=Array.from(this.dom.getElementsByTagName("body")[0].childNodes),a=e.length;return this.matchedIndex=t.matchedIndex,this.hlIndex=t.hlIndex,i.forEach((function(e){var t=n.getTextNodes(e);t.forEach((function(e){for(var t=e,i=t.textContent||"";i;){var o=i.search(r);if(-1===o)break;i=(null==(t=n.wrapRangeInTextNode(t,o,o+a))?void 0:t.textContent)||"",n.matchCount++,n.matchedIndex++}})),t=[]})),i=[],this},e.prototype.escapeStr=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},e.prototype.getStyle=function(e){var t=(e?this.options.markedStyle:this.options.style)||{};return Object.keys(t).filter((function(e){return t[e]})).map((function(e){return"".concat(e,":").concat(t[e],";")})).join("")},e.prototype.getTextNodes=function(e){for(var t=[],n=[e];0!==n.length;){var r=n.shift();if(r&&3===r.nodeType&&t.push(r),r&&r.hasChildNodes()){var i=Array.from(r.childNodes);i.forEach((function(e){3===e.nodeType&&t.push(e)})),n.push.apply(n,i)}}return t},e.prototype.wrapRangeInTextNode=function(e,t,n){var r,i=this.options,a=i.className,o=i.markedClassName,s=e.splitText(t),l=s.splitText(n-t),u=this.dom.createElement("mark"),c=this.getStyle(this.matchedIndex===this.hlIndex);return this.matchedIndex===this.hlIndex&&(this.isMarked=!0),u.setAttribute("class",(this.matchedIndex===this.hlIndex?o:a)||""),c&&u.setAttribute("style",c),u.textContent=s.textContent,null===(r=s.parentNode)||void 0===r||r.replaceChild(u,s),l},e.prototype.toString=function(){var e=this.dom.getElementsByTagName("body")[0].toString().match(/^<body xmlns="http:\/\/www\.w3\.org\/1999\/xhtml">(.[\s\S]*?)<\/body>$/);return e&&e[1]?e[1]:""},e.prototype.distory=function(){this.dom=null},e}(),We=function(){function e(e){void 0===e&&(e={markClassName:"terminal-viewer-hl-mark",markedClassName:"terminal-viewer-hl-mark terminal-viewer-hl-marked"}),this.options=e}return e.prototype.search=function(e,t,n,r){var i,a,o,s,l;if(void 0===n&&(n=0),void 0===r&&(r=void 0),!Array.isArray(t)||0===t.length||!e)return{count:0,map:{},markedKey:0};for(var u=this.options,c=u.markClassName,h=u.markedClassName,f={color:null===(i=null==r?void 0:r.decorations)||void 0===i?void 0:i.matchForegroundColor,background:null===(a=null==r?void 0:r.decorations)||void 0===a?void 0:a.matchBackground,border:null===(o=null==r?void 0:r.decorations)||void 0===o?void 0:o.matchBorder},d={background:null===(s=null==r?void 0:r.decorations)||void 0===s?void 0:s.activeMatchBackground,border:null===(l=null==r?void 0:r.decorations)||void 0===l?void 0:l.activeMatchBorder},p=0,m=0,g={},b=0,v=t.length;b<v&&!(p>=1e3);b++){var N=t[b]||"";if(N.toLowerCase().includes(e.toLowerCase())){var w=new Ge(N,{className:c,markedClassName:h,style:f,markedStyle:d}),_=w.mark(e,{matchedIndex:p,hlIndex:n}).toString();w.isMarked&&(m=b),0!==w.matchCount&&(p+=w.matchCount,g[b]=_||N),w.distory(),w=null}}return{count:p,map:g,markedKey:m}},e}(),Ke=function(){function e(e){var t=e.id,r=e.string;this.id=t,this.string=r,this.searcher=new We,this.logDataMap=new n({limit:1})}return e.prototype.convert=function(){return 0===this.string.length?[]:this.string.split("\r\n").map((function(e){return(new s).ansi_to_html(e)}))},e.prototype.getArrayData=function(){return this.logDataMap.has(this.id)||this.logDataMap.set(this.id,this.convert()),this.logDataMap.get(this.id)||[]},e.prototype.mark=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=void 0),e?this.searcher.search(e,this.getArrayData(),t,n):this.searcher.search(e,[])},e}(),Ze=new t(self),Qe=new n({limit:8});Ze.on("highlight-log",(function(e,t){var n=t.id,r=t.string;Qe.has(n)||Qe.set(n,new Ke({id:n,string:r}));var i=Qe.get(n);e.send("highlight-log-success",{id:n,logs:null==i?void 0:i.getArrayData()})})),Ze.on("search-log",(function(e,t){var n=t.id,r=t.searchId,i=t.keyword,a=void 0===i?"":i,o=t.hlIndex,s=t.string,l=void 0===s?"":s,u=t.options;if(a){Qe.has(n)||Qe.set(n,new Ke({id:n,string:l}));var c=Qe.get(n);c&&e.send("search-log-success",{id:n,searchId:r,searcherResult:c.mark(a,o,u)||{map:{},count:0,markedKey:0}})}else e.send("search-log-success",{id:n,searchId:r,searcherResult:{map:{},count:0,markedKey:0}})}))}));
//# sourceMappingURL=log.worker.js.map