forked from wavedrom/wavedrom.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwavedrom.min.js
14 lines (14 loc) · 178 KB
/
wavedrom.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*! wavedrom 2.9.1 2022-2-13 PDT */
!function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,(function(r){return o(e[i][1][r]||r)}),p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({1:[function(require,module,exports){"use strict";module.exports=function(index,output){var div,menu;function closeMenu(e){var left=parseInt(menu.style.left,10),top=parseInt(menu.style.top,10);(e.x<left||e.x>left+menu.offsetWidth||e.y<top||e.y>top+menu.offsetHeight)&&(menu.parentNode.removeChild(menu),document.body.removeEventListener("mousedown",closeMenu,!1))}(div=document.getElementById(output+index)).childNodes[0].addEventListener("contextmenu",(function(e){var list,savePng,saveSvg;(menu=document.createElement("div")).className="wavedromMenu",menu.style.top=e.y+"px",menu.style.left=e.x+"px",list=document.createElement("ul"),(savePng=document.createElement("li")).innerHTML="Save as PNG",list.appendChild(savePng),(saveSvg=document.createElement("li")).innerHTML="Save as SVG",list.appendChild(saveSvg),menu.appendChild(list),document.body.appendChild(menu),savePng.addEventListener("click",(function(){var html,firstDiv,svgdata,img,canvas,pngdata,a;html="",0!==index&&(html+=(firstDiv=document.getElementById(output+0)).innerHTML.substring(166,firstDiv.innerHTML.indexOf('<g id="waves_0">'))),html=[div.innerHTML.slice(0,166),html,div.innerHTML.slice(166)].join(""),svgdata="data:image/svg+xml;base64,"+btoa(html),(img=new Image).src=svgdata,(canvas=document.createElement("canvas")).width=img.width,canvas.height=img.height,canvas.getContext("2d").drawImage(img,0,0),pngdata=canvas.toDataURL("image/png"),(a=document.createElement("a")).href=pngdata,a.download="wavedrom.png",a.click(),menu.parentNode.removeChild(menu),document.body.removeEventListener("mousedown",closeMenu,!1)}),!1),saveSvg.addEventListener("click",(function(){var html,firstDiv,svgdata,a;html="",0!==index&&(html+=(firstDiv=document.getElementById(output+0)).innerHTML.substring(166,firstDiv.innerHTML.indexOf('<g id="waves_0">'))),html=[div.innerHTML.slice(0,166),html,div.innerHTML.slice(166)].join(""),svgdata="data:image/svg+xml;base64,"+btoa(html),(a=document.createElement("a")).href=svgdata,a.download="wavedrom.svg",a.click(),menu.parentNode.removeChild(menu),document.body.removeEventListener("mousedown",closeMenu,!1)}),!1),menu.addEventListener("contextmenu",(function(ee){ee.preventDefault()}),!1),document.body.addEventListener("mousedown",closeMenu,!1),e.preventDefault()}),!1)}},{}],2:[function(require,module,exports){"use strict";module.exports=function(Edge,from,to){var d,style,dx=to.x-from.x,dy=to.y-from.y,lx=(from.x+to.x)/2,ly=(from.y+to.y)/2;switch(Edge.shape){case"-":break;case"~":d="M "+from.x+","+from.y+" c "+.7*dx+", 0 "+.3*dx+", "+dy+" "+dx+", "+dy;break;case"-~":d="M "+from.x+","+from.y+" c "+.7*dx+", 0 "+dx+", "+dy+" "+dx+", "+dy,Edge.label&&(lx=from.x+.75*(to.x-from.x));break;case"~-":d="M "+from.x+","+from.y+" c 0, 0 "+.3*dx+", "+dy+" "+dx+", "+dy,Edge.label&&(lx=from.x+.25*(to.x-from.x));break;case"-|":d="m "+from.x+","+from.y+" "+dx+",0 0,"+dy,Edge.label&&(lx=to.x);break;case"|-":d="m "+from.x+","+from.y+" 0,"+dy+" "+dx+",0",Edge.label&&(lx=from.x);break;case"-|-":d="m "+from.x+","+from.y+" "+dx/2+",0 0,"+dy+" "+dx/2+",0";break;case"->":style="marker-end:url(#arrowhead);stroke:#0041c4;stroke-width:1;fill:none";break;case"~>":style="marker-end:url(#arrowhead);stroke:#0041c4;stroke-width:1;fill:none",d="M "+from.x+","+from.y+" c "+.7*dx+", 0 "+.3*dx+", "+dy+" "+dx+", "+dy;break;case"-~>":style="marker-end:url(#arrowhead);stroke:#0041c4;stroke-width:1;fill:none",d="M "+from.x+","+from.y+" c "+.7*dx+", 0 "+dx+", "+dy+" "+dx+", "+dy,Edge.label&&(lx=from.x+.75*(to.x-from.x));break;case"~->":style="marker-end:url(#arrowhead);stroke:#0041c4;stroke-width:1;fill:none",d="M "+from.x+","+from.y+" c 0, 0 "+.3*dx+", "+dy+" "+dx+", "+dy,Edge.label&&(lx=from.x+.25*(to.x-from.x));break;case"-|>":style="marker-end:url(#arrowhead);stroke:#0041c4;stroke-width:1;fill:none",d="m "+from.x+","+from.y+" "+dx+",0 0,"+dy,Edge.label&&(lx=to.x);break;case"|->":style="marker-end:url(#arrowhead);stroke:#0041c4;stroke-width:1;fill:none",d="m "+from.x+","+from.y+" 0,"+dy+" "+dx+",0",Edge.label&&(lx=from.x);break;case"-|->":style="marker-end:url(#arrowhead);stroke:#0041c4;stroke-width:1;fill:none",d="m "+from.x+","+from.y+" "+dx/2+",0 0,"+dy+" "+dx/2+",0";break;case"<->":style="marker-end:url(#arrowhead);marker-start:url(#arrowtail);stroke:#0041c4;stroke-width:1;fill:none";break;case"<~>":style="marker-end:url(#arrowhead);marker-start:url(#arrowtail);stroke:#0041c4;stroke-width:1;fill:none",d="M "+from.x+","+from.y+" c "+.7*dx+", 0 "+.3*dx+", "+dy+" "+dx+", "+dy;break;case"<-~>":style="marker-end:url(#arrowhead);marker-start:url(#arrowtail);stroke:#0041c4;stroke-width:1;fill:none",d="M "+from.x+","+from.y+" c "+.7*dx+", 0 "+dx+", "+dy+" "+dx+", "+dy,Edge.label&&(lx=from.x+.75*(to.x-from.x));break;case"<-|>":style="marker-end:url(#arrowhead);marker-start:url(#arrowtail);stroke:#0041c4;stroke-width:1;fill:none",d="m "+from.x+","+from.y+" "+dx+",0 0,"+dy,Edge.label&&(lx=to.x);break;case"<-|->":style="marker-end:url(#arrowhead);marker-start:url(#arrowtail);stroke:#0041c4;stroke-width:1;fill:none",d="m "+from.x+","+from.y+" "+dx/2+",0 0,"+dy+" "+dx/2+",0";break;case"+":style="marker-end:url(#tee);marker-start:url(#tee);fill:none;stroke:#00F;stroke-width:1";break;default:style="fill:none;stroke:#F00;stroke-width:1"}return{lx:lx,ly:ly,d:d,style:style}}},{}],3:[function(require,module,exports){module.exports={chars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,34,47,74,74,118,89,25,44,44,52,78,37,44,37,37,74,74,74,74,74,74,74,74,74,74,37,37,78,78,78,74,135,89,89,96,96,89,81,103,96,37,67,89,74,109,96,103,89,103,96,89,81,96,89,127,89,87,81,37,37,37,61,74,44,74,74,67,74,74,37,74,74,30,30,67,30,112,74,74,74,74,44,67,37,74,67,95,66,65,67,44,34,44,78,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,43,74,74,74,74,34,74,44,98,49,74,78,0,98,73,53,73,44,44,44,77,71,37,44,44,49,74,111,111,111,81,89,89,89,89,89,89,133,96,89,89,89,89,37,37,37,37,96,96,103,103,103,103,103,78,103,96,96,96,96,87,89,81,74,74,74,74,74,74,118,67,74,74,74,74,36,36,36,36,74,74,74,74,74,74,74,73,81,74,74,74,74,65,74,65,89,74,89,74,89,74,96,67,96,67,96,67,96,67,96,82,96,74,89,74,89,74,89,74,89,74,89,74,103,74,103,74,103,74,103,74,96,74,96,74,37,36,37,36,37,36,37,30,37,36,98,59,67,30,89,67,67,74,30,74,30,74,39,74,44,74,30,96,74,96,74,96,74,80,96,74,103,74,103,74,103,74,133,126,96,44,96,44,96,44,89,67,89,67,89,67,89,67,81,38,81,50,81,37,96,74,96,74,96,74,96,74,96,74,96,74,127,95,87,65,87,81,67,81,67,81,67,30,84,97,91,84,91,84,94,92,73,104,109,91,84,81,84,100,82,76,74,103,91,131,47,40,99,77,37,79,130,100,84,104,114,87,126,101,87,84,93,84,69,84,46,52,82,52,82,114,89,102,96,100,98,91,70,88,88,77,70,85,89,77,67,84,39,65,61,39,189,173,153,111,105,61,123,123,106,89,74,37,30,103,74,96,74,96,74,96,74,96,74,96,74,81,91,81,91,81,130,131,102,84,103,84,87,78,104,81,104,81,88,76,37,189,173,153,103,84,148,90,100,84,89,74,133,118,103,81],other:114}},{}],4:[function(require,module,exports){"use strict";var onmlStringify=require("onml/stringify.js"),w3=require("./w3.js");module.exports=function(arr){arr[1].xmlns=w3.svg,arr[1]["xmlns:xlink"]=w3.xlink;var s1=onmlStringify(arr);return(new DOMParser).parseFromString(s1,"image/svg+xml").firstChild}},{"./w3.js":33,"onml/stringify.js":52}],5:[function(require,module,exports){"use strict";var eva=require("./eva.js"),renderWaveForm=require("./render-wave-form.js");module.exports=function(){renderWaveForm(0,eva("InputJSON_0"),"WaveDrom_Display_")}},{"./eva.js":6,"./render-wave-form.js":30}],6:[function(require,module,exports){"use strict";function eva(id){var TheTextBox,source;function erra(e){return{signal:[{name:["tspan",["tspan",{class:"error h5"},"Error: "],e.message]}]}}if(TheTextBox=document.getElementById(id),TheTextBox.type&&"textarea"===TheTextBox.type)try{source=eval("("+TheTextBox.value+")")}catch(e){return erra(e)}else try{source=eval("("+TheTextBox.innerHTML+")")}catch(e){return erra(e)}if("[object Object]"!==Object.prototype.toString.call(source))return erra({message:'[Semantic]: The root has to be an Object: "{signal:[...]}"'});if(source.signal){if("[object Array]"!==Object.prototype.toString.call(source.signal))return erra({message:'[Semantic]: "signal" object has to be an Array "signal:[]"'})}else if(source.assign){if("[object Array]"!==Object.prototype.toString.call(source.assign))return erra({message:'[Semantic]: "assign" object hasto be an Array "assign:[]"'})}else if(!source.reg)return erra({message:'[Semantic]: "signal:[...]" or "assign:[...]" property is missing inside the root Object'});return source}module.exports=eva},{}],7:[function(require,module,exports){"use strict";module.exports=function(lanetext){var gcount=0,lcount=0,ret=[];return lanetext.forEach((function(e){"vvv-2"===e||"vvv-3"===e||"vvv-4"===e||"vvv-5"===e||"vvv-6"===e||"vvv-7"===e||"vvv-8"===e||"vvv-9"===e?lcount+=1:0!==lcount&&(ret.push(gcount-(lcount+1)/2),lcount=0),gcount+=1})),0!==lcount&&ret.push(gcount-(lcount+1)/2),ret}},{}],8:[function(require,module,exports){"use strict";module.exports=function(texts,extra,times){var i,j,R=[];if(4===texts.length){for(j=0;j<times;j+=1){for(R.push(texts[0]),i=0;i<extra;i+=1)R.push(texts[1]);for(R.push(texts[2]),i=0;i<extra;i+=1)R.push(texts[3])}return R}for(1===texts.length&&texts.push(texts[0]),R.push(texts[0]),i=0;i<times*(2*(extra+1))-1;i+=1)R.push(texts[1]);return R}},{}],9:[function(require,module,exports){"use strict";var genBrick=require("./gen-brick.js");module.exports=function(text,extra,times){var tmp;switch(tmp=[],text){case"p":tmp=genBrick(["pclk","111","nclk","000"],extra,times);break;case"n":tmp=genBrick(["nclk","000","pclk","111"],extra,times);break;case"P":tmp=genBrick(["Pclk","111","nclk","000"],extra,times);break;case"N":tmp=genBrick(["Nclk","000","pclk","111"],extra,times);break;case"l":case"L":case"0":tmp=genBrick(["000"],extra,times);break;case"h":case"H":case"1":tmp=genBrick(["111"],extra,times);break;case"=":case"2":tmp=genBrick(["vvv-2"],extra,times);break;case"3":tmp=genBrick(["vvv-3"],extra,times);break;case"4":tmp=genBrick(["vvv-4"],extra,times);break;case"5":tmp=genBrick(["vvv-5"],extra,times);break;case"6":tmp=genBrick(["vvv-6"],extra,times);break;case"7":tmp=genBrick(["vvv-7"],extra,times);break;case"8":tmp=genBrick(["vvv-8"],extra,times);break;case"9":tmp=genBrick(["vvv-9"],extra,times);break;case"d":tmp=genBrick(["ddd"],extra,times);break;case"u":tmp=genBrick(["uuu"],extra,times);break;case"z":tmp=genBrick(["zzz"],extra,times);break;default:tmp=genBrick(["xxx"],extra,times)}return tmp}},{"./gen-brick.js":8}],10:[function(require,module,exports){"use strict";var genBrick=require("./gen-brick.js");module.exports=function(text,extra,times){var x1,x2,x3,y1,y2,x5,x6,xclude,atext,tmp0,tmp1,tmp2,tmp3,tmp4;return x1={p:"pclk",n:"nclk",P:"Pclk",N:"Nclk",h:"pclk",l:"nclk",H:"Pclk",L:"Nclk"},x2={0:"0",1:"1",x:"x",d:"d",u:"u",z:"z","=":"v",2:"v",3:"v",4:"v",5:"v",6:"v",7:"v",8:"v",9:"v"},x3={0:"",1:"",x:"",d:"",u:"",z:"","=":"-2",2:"-2",3:"-3",4:"-4",5:"-5",6:"-6",7:"-7",8:"-8",9:"-9"},y1={p:"0",n:"1",P:"0",N:"1",h:"1",l:"0",H:"1",L:"0",0:"0",1:"1",x:"x",d:"d",u:"u",z:"z","=":"v",2:"v",3:"v",4:"v",5:"v",6:"v",7:"v",8:"v",9:"v"},y2={p:"",n:"",P:"",N:"",h:"",l:"",H:"",L:"",0:"",1:"",x:"",d:"",u:"",z:"","=":"-2",2:"-2",3:"-3",4:"-4",5:"-5",6:"-6",7:"-7",8:"-8",9:"-9"},x5={p:"nclk",n:"pclk",P:"nclk",N:"pclk"},x6={p:"000",n:"111",P:"000",N:"111"},xclude={hp:"111",Hp:"111",ln:"000",Ln:"000",nh:"111",Nh:"111",pl:"000",Pl:"000"},tmp0={p:"111",n:"000",P:"111",N:"000",h:"111",l:"000",H:"111",L:"000",0:"000",1:"111",x:"xxx",d:"ddd",u:"uuu",z:"zzz","=":"vvv-2",2:"vvv-2",3:"vvv-3",4:"vvv-4",5:"vvv-5",6:"vvv-6",7:"vvv-7",8:"vvv-8",9:"vvv-9"}[(atext=text.split(""))[1]],void 0===(tmp1=x1[atext[1]])?void 0===(tmp2=x2[atext[1]])?genBrick(["xxx"],extra,times):(tmp3=y1[atext[0]],genBrick(void 0===tmp3?["xxx"]:[tmp3+"m"+tmp2+y2[atext[0]]+x3[atext[1]],tmp0],extra,times)):(void 0!==(tmp4=xclude[text])&&(tmp1=tmp4),tmp2=x5[atext[1]],genBrick(void 0===tmp2?[tmp1,tmp0]:[tmp1,tmp0,tmp2,x6[atext[1]]],extra,times))}},{"./gen-brick.js":8}],11:[function(require,module,exports){"use strict";var w3=require("./w3.js");module.exports=function(index,source,lane,waveSkin,content,lanes,groups,notFirstSignal){var first,skin,e;for(first in waveSkin)break;skin=waveSkin.default||waveSkin[first],source&&source.config&&source.config.skin&&waveSkin[source.config.skin]&&(skin=waveSkin[source.config.skin]),e=notFirstSignal?["svg",{id:"svg",xmlns:w3.svg,"xmlns:xlink":w3.xlink},["g"]]:skin;var width=lane.xg+lane.xs*(lane.xmax+1),height=content.length*lane.yo+lane.yh0+lane.yh1+lane.yf0+lane.yf1,body=e[e.length-1];body[1]={id:"waves_"+index},body[2]=["g",{id:"lanes_"+index,transform:"translate("+(lane.xg+.5)+", "+(lane.yh0+lane.yh1+.5)+")"}].concat(lanes),body[3]=["g",{id:"groups_"+index},groups];var head=e[1];return head.id="svgcontent_"+index,head.height=height,head.width=width,head.viewBox="0 0 "+width+" "+height,head.overflow="hidden",e}},{"./w3.js":33}],12:[function(require,module,exports){"use strict";module.exports={xs:20,ys:20,xg:120,yh0:0,yh1:0,yf0:0,yf1:0,y0:5,yo:30,tgo:-10,ym:15,xlabel:6,xmax:1,scale:1,head:{},foot:{}}},{}],13:[function(require,module,exports){"use strict";module.exports=function(source,lane){var hscale,x;lane.hscale=1,lane.hscale0&&(lane.hscale=lane.hscale0),source&&source.config&&source.config.hscale&&(hscale=Math.round((x=source.config.hscale)>0?Math.round(x):1))>0&&(hscale>100&&(hscale=100),lane.hscale=hscale),lane.yh0=0,lane.yh1=0,lane.head=source.head,lane.xmin_cfg=0,lane.xmax_cfg=1e12,source&&source.config&&source.config.hbounds&&2==source.config.hbounds.length&&(source.config.hbounds[0]=Math.floor(source.config.hbounds[0]),source.config.hbounds[1]=Math.ceil(source.config.hbounds[1]),source.config.hbounds[0]<source.config.hbounds[1]&&(lane.xmin_cfg=2*Math.floor(source.config.hbounds[0]),lane.xmax_cfg=2*Math.floor(source.config.hbounds[1]))),source&&source.head&&((source.head.tick||0===source.head.tick||source.head.tock||0===source.head.tock)&&(lane.yh0=20),(source.head.tick||0===source.head.tick)&&(source.head.tick=source.head.tick+lane.xmin_cfg/2),(source.head.tock||0===source.head.tock)&&(source.head.tock=source.head.tock+lane.xmin_cfg/2),source.head.text&&(lane.yh1=46,lane.head.text=source.head.text)),lane.yf0=0,lane.yf1=0,lane.foot=source.foot,source&&source.foot&&((source.foot.tick||0===source.foot.tick||source.foot.tock||0===source.foot.tock)&&(lane.yf0=20),(source.foot.tick||0===source.foot.tick)&&(source.foot.tick=source.foot.tick+lane.xmin_cfg/2),(source.foot.tock||0===source.foot.tock)&&(source.foot.tock=source.foot.tock+lane.xmin_cfg/2),source.foot.text&&(lane.yf1=46,lane.foot.text=source.foot.text))}},{}],14:[function(require,module,exports){"use strict";var genFirstWaveBrick=require("./gen-first-wave-brick.js"),genWaveBrick=require("./gen-wave-brick.js"),findLaneMarkers=require("./find-lane-markers.js");module.exports=function(src,extra,lane){var Repeats,Top,Next,i,subCycle,num_unseen_markers,Stack=[],R=[],unseen_bricks=[];for(Next=(Stack=src.split("")).shift(),subCycle=!1,Repeats=1;"."===Stack[0]||"|"===Stack[0];)Stack.shift(),Repeats+=1;for(R=R.concat(genFirstWaveBrick(Next,extra,Repeats));Stack.length;){for(Top=Next,"<"===(Next=Stack.shift())&&(subCycle=!0,Next=Stack.shift()),">"===Next&&(subCycle=!1,Next=Stack.shift()),Repeats=1;"."===Stack[0]||"|"===Stack[0];)Stack.shift(),Repeats+=1;R=subCycle?R.concat(genWaveBrick(Top+Next,0,Repeats-lane.period)):R.concat(genWaveBrick(Top+Next,extra,Repeats))}for(i=0;i<lane.phase;i+=1)unseen_bricks.push(R.shift());return unseen_bricks.length>0?(num_unseen_markers=findLaneMarkers(unseen_bricks).length,1==findLaneMarkers([unseen_bricks[unseen_bricks.length-1]]).length&&1==findLaneMarkers([R[0]]).length&&(num_unseen_markers-=1)):num_unseen_markers=0,[R,num_unseen_markers]}},{"./find-lane-markers.js":7,"./gen-first-wave-brick.js":9,"./gen-wave-brick.js":10}],15:[function(require,module,exports){"use strict";var parseWaveLane=require("./parse-wave-lane.js");module.exports=function(sig,lane){var content=[],tmp0=[];return sig.map((function(sigx){var parsed_wave_lane,num_unseen_markers,content_wave=null,current=[];content.push(current),lane.period=sigx.period||1,lane.phase=(sigx.phase?2*sigx.phase:0)+lane.xmin_cfg,tmp0[0]=sigx.name||" ",tmp0[1]=(sigx.phase||0)+lane.xmin_cfg/2,"string"==typeof sigx.wave&&(content_wave=(parsed_wave_lane=parseWaveLane(sigx.wave,lane.period*lane.hscale-1,lane))[0],num_unseen_markers=parsed_wave_lane[1]),current.push(tmp0.slice(0),content_wave,function(e,num_unseen_markers){var ret_data;return void 0===(ret_data=e.data)?null:("string"==typeof ret_data&&(ret_data=ret_data.trim().split(/\s+/)),ret_data=ret_data.slice(num_unseen_markers))}(sigx,num_unseen_markers),sigx)})),content}},{"./parse-wave-lane.js":14}],16:[function(require,module,exports){"use strict";var eva=require("./eva.js"),appendSaveAsDialog=require("./append-save-as-dialog.js"),renderWaveForm=require("./render-wave-form.js");module.exports=function(){var points,i,index,notFirstSignal,obj,node0;for(index=0,points=document.querySelectorAll("*"),i=0;i<points.length;i++)points.item(i).type&&"wavedrom"===points.item(i).type.toLowerCase()&&(points.item(i).setAttribute("id","InputJSON_"+index),(node0=document.createElement("div")).id="WaveDrom_Display_"+index,points.item(i).parentNode.insertBefore(node0,points.item(i)),index+=1);for(i=0;i<index;i+=1)obj=eva("InputJSON_"+i),renderWaveForm(i,obj,"WaveDrom_Display_",notFirstSignal),obj&&obj.signal&&!notFirstSignal&&(notFirstSignal=!0),appendSaveAsDialog(i,"WaveDrom_Display_");document.head.innerHTML+='<style type="text/css">div.wavedromMenu{position:fixed;border:solid 1pt#CCCCCC;background-color:white;box-shadow:0px 10px 20px #808080;cursor:default;margin:0px;padding:0px;}div.wavedromMenu>ul{margin:0px;padding:0px;}div.wavedromMenu>ul>li{padding:2px 10px;list-style:none;}div.wavedromMenu>ul>li:hover{background-color:#b5d5ff;}</style>'}},{"./append-save-as-dialog.js":1,"./eva.js":6,"./render-wave-form.js":30}],17:[function(require,module,exports){"use strict";module.exports=function rec(tmp,state){var i,name,old={},delta={x:10};for("string"!=typeof tmp[0]&&"number"!=typeof tmp[0]||(name=tmp[0],delta.x=25),state.x+=delta.x,i=0;i<tmp.length;i++)"object"==typeof tmp[i]&&("[object Array]"===Object.prototype.toString.call(tmp[i])?(old.y=state.y,(state=rec(tmp[i],state)).groups.push({x:state.xx,y:old.y,height:state.y-old.y,name:state.name})):(state.lanes.push(tmp[i]),state.width.push(state.x),state.y+=1));return state.xx=state.x,state.x-=delta.x,state.name=name,state}},{}],18:[function(require,module,exports){"use strict";var renderAssign=require("logidrom/lib/render-assign.js"),renderReg=require("./render-reg.js"),renderSignal=require("./render-signal.js");module.exports=function(index,source,waveSkin,notFirstSignal){var res=source.signal?renderSignal(index,source,waveSkin,notFirstSignal):source.assign?renderAssign(index,source):source.reg?renderReg(index,source):["div",{}];return res[1].class="WaveDrom",res}},{"./render-reg.js":27,"./render-signal.js":28,"logidrom/lib/render-assign.js":46}],19:[function(require,module,exports){"use strict";var arcShape=require("./arc-shape.js"),renderLabel=require("./render-label.js");function renderArc(Edge,from,to,shapeProps){return["path",{id:"gmark_"+Edge.from+"_"+Edge.to,d:shapeProps.d||"M "+from.x+","+from.y+" "+to.x+","+to.y,style:shapeProps.style||"fill:none;stroke:#00F;stroke-width:1"}]}module.exports=function(source,index,top,lane){var res=["g",{id:"wavearcs_"+index}],Events={};return Array.isArray(source)&&(source.map((function(element,i){var pos,eventname,stack,text=element.node;if(lane.period=element.period?element.period:1,lane.phase=(element.phase?2*element.phase:0)+lane.xmin_cfg,text)for(stack=text.split(""),pos=0;stack.length;)"."!==(eventname=stack.shift())&&(Events[eventname]={x:lane.xs*(2*pos*lane.period*lane.hscale-lane.phase)+lane.xlabel,y:i*lane.yo+lane.y0+.5*lane.ys}),pos+=1})),Array.isArray(top.edge)&&top.edge.map((function(element){var shapeProps,lx,ly,words=element.trim().split(/\s+/),Edge={words:words,label:element.substring(words[0].length).substring(1),from:words[0].substr(0,1),to:words[0].substr(-1,1),shape:words[0].slice(1,-1)},from=Events[Edge.from],to=Events[Edge.to];from&&to&&(lx=(shapeProps=arcShape(Edge,from,to)).lx,ly=shapeProps.ly,res=res.concat([renderArc(Edge,from,to,shapeProps)]),Edge.label&&(res=res.concat([renderLabel({x:lx,y:ly},Edge.label)])))})),Object.keys(Events).map((function(k){k===k.toLowerCase()&&Events[k].x>0&&(res=res.concat([renderLabel({x:Events[k].x,y:Events[k].y},k+"")]))}))),res}},{"./arc-shape.js":2,"./render-label.js":22}],20:[function(require,module,exports){"use strict";function renderGapUses(text,lane){for(var next,res=[],Stack=(text||"").split(""),pos=0,subCycle=!1;Stack.length;)"<"===(next=Stack.shift())&&(subCycle=!0,next=Stack.shift()),">"===next&&(subCycle=!1,next=Stack.shift()),pos+=subCycle?1:2*lane.period,"|"===next&&res.push(["use",{"xlink:href":"#gap",transform:"translate("+lane.xs*((pos-(subCycle?0:lane.period))*lane.hscale-lane.phase)+")"}]);return res}module.exports=function(source,index,lane){var i,gaps,res=[];if(source)for(i in source)lane.period=source[i].period?source[i].period:1,lane.phase=(source[i].phase?2*source[i].phase:0)+lane.xmin_cfg,"string"==typeof source[i].wave&&(gaps=renderGapUses(source[i].wave,lane),res=res.concat([["g",{id:"wavegap_"+i+"_"+index,transform:"translate(0,"+(lane.y0+i*lane.yo)+")"}].concat(gaps)]));return["g",{id:"wavegaps_"+index}].concat(res)}},{}],21:[function(require,module,exports){"use strict";var tspan=require("tspan");module.exports=function(groups,index,lane){var x,y,ts,res=["g"];return groups.forEach((function(e,i){res.push(["path",{id:"group_"+i+"_"+index,d:"m "+(e.x+.5)+","+(e.y*lane.yo+3.5+lane.yh0+lane.yh1)+" c -3,0 -5,2 -5,5 l 0,"+(e.height*lane.yo-16)+" c 0,3 2,5 5,5",style:"stroke:#0041c4;stroke-width:1;fill:none"}]),void 0!==e.name&&(x=e.x-10,y=lane.yo*(e.y+e.height/2)+lane.yh0+lane.yh1,(ts=tspan.parse(e.name)).unshift("text",{"text-anchor":"middle",class:"info","xml:space":"preserve"}),res.push(["g",{transform:"translate("+x+","+y+")"},["g",{transform:"rotate(270)"},ts]]))})),res}},{tspan:74}],22:[function(require,module,exports){"use strict";var tspan=require("tspan"),textWidth=require("./text-width.js");module.exports=function(p,text){var w=textWidth(text,8)+2;return["g",{transform:"translate("+p.x+","+p.y+")"},["rect",{x:-(w>>1),y:-5,width:w,height:10,style:"fill:#FFF;"}],["text",{"text-anchor":"middle",y:3,style:"font-size:8px;"}].concat(tspan.parse(text))]}},{"./text-width.js":32,tspan:74}],23:[function(require,module,exports){"use strict";var renderMarks=require("./render-marks.js"),renderArcs=require("./render-arcs.js"),renderGaps=require("./render-gaps.js"),renderPieceWise=require("./render-piece-wise.js");module.exports=function(index,content,waveLanes,ret,source,lane){return[renderMarks(content,index,lane,source)].concat(waveLanes.res,[renderArcs(ret.lanes,index,source,lane),renderGaps(ret.lanes,index,lane),renderPieceWise(ret.lanes,index,lane)])}},{"./render-arcs.js":19,"./render-gaps.js":20,"./render-marks.js":24,"./render-piece-wise.js":26}],24:[function(require,module,exports){"use strict";var tspan=require("tspan");function captext(cxt,anchor,y){return cxt[anchor]&&cxt[anchor].text?[["text",{x:cxt.xmax*cxt.xs/2,y:y,fill:"#000","text-anchor":"middle","xml:space":"preserve"}].concat(tspan.parse(cxt[anchor].text))]:[]}function ticktock(cxt,ref1,ref2,x,dx,y,len){var offset,val,tmp,i,step=1,dp=0,L=[];if(void 0===cxt[ref1]||void 0===cxt[ref1][ref2])return[];if("string"==typeof(val=cxt[ref1][ref2]))val=val.trim().split(/\s+/);else if("number"==typeof val||"boolean"==typeof val)for(offset=Number(val),val=[],i=0;i<len;i+=1)val.push(i+offset);if("[object Array]"!==Object.prototype.toString.call(val))return[];if(0===val.length)return[];if(1===val.length)if(offset=Number(val[0]),isNaN(offset))L=val;else for(i=0;i<len;i+=1)L[i]=i+offset;else if(2===val.length)if(offset=Number(val[0]),step=Number(val[1]),2===(tmp=val[1].split(".")).length&&(dp=tmp[1].length),isNaN(offset)||isNaN(step))L=val;else for(offset*=step,i=0;i<len;i+=1)L[i]=(step*i+offset).toFixed(dp);else L=val;var res=["g",{class:"muted","text-anchor":"middle","xml:space":"preserve"}];for(i=0;i<len;i+=1)cxt[ref1]&&cxt[ref1].every&&(i+offset)%cxt[ref1].every!=0||res.push(["text",{x:i*dx+x,y:y}].concat(tspan.parse(L[i])));return[res]}module.exports=function(content,index,lane,source){var i,mstep=2*lane.hscale,mmstep=mstep*lane.xs,marks=lane.xmax/mstep,gy=content.length*lane.yo,res=["g",{id:"gmarks_"+index}],gmarkLines=["g",{style:"stroke:#888;stroke-width:0.5;stroke-dasharray:1,3"}];if(!source||!source.config||!1!==source.config.marks){for(i=0;i<marks+1;i+=1)gmarkLines.push(["line",{id:"gmark_"+i+"_"+index,x1:i*mmstep,y1:0,x2:i*mmstep,y2:gy}]);res=res.concat([gmarkLines])}return res.concat(captext(lane,"head",lane.yh0?-33:-13)).concat(captext(lane,"foot",gy+(lane.yf0?45:25))).concat(ticktock(lane,"head","tick",0,mmstep,-5,marks+1)).concat(ticktock(lane,"head","tock",mmstep/2,mmstep,-5,marks)).concat(ticktock(lane,"foot","tick",0,mmstep,gy+15,marks+1)).concat(ticktock(lane,"foot","tock",mmstep/2,mmstep,gy+15,marks))}},{tspan:74}],25:[function(require,module,exports){"use strict";var colors={1:"#000000",2:"#e90000",3:"#3edd00",4:"#0074cd",5:"#ff15db",6:"#af9800",7:"#00864f",8:"#a076ff"};module.exports=function(el,key,lane){var color,start,xs=lane.xs,ys=lane.ys,period=2*(el.period||1)*xs,xoffset=2*-(el.phase||0)*xs,y="under"===key?ys:0;function line(x){return void 0===start?[]:[["line",{style:"stroke:"+color,x1:period*start+12,x2:period*x}]]}if(el[key]){var res=["g",{transform:"translate("+xoffset+","+y+")",style:"stroke-width:3"}];const arr=el[key].split("");return arr.map((function(dot,i){"."!==dot&&void 0!==start&&(res=res.concat(line(i)),"over"===key&&res.push(["path",{style:"stroke:none;fill:"+color,d:"m"+(period*i-7)+" 0 l7 7 v-7 z"}])),"0"===dot?start=void 0:"."!==dot&&(start=i,color=colors[dot]||colors[1])})),void 0!==start&&(res=res.concat(line(arr.length))),[res]}return[]}},{}],26:[function(require,module,exports){"use strict";const onml=require("onml");function renderLane(wave,idx,cfg){if(Array.isArray(wave)){const tag=wave[0],attr=wave[1];if("pw"===tag&&"object"==typeof attr){const d=function(d,cfg){if("string"==typeof d&&(d=d.trim().split(/[\s,]+/)),Array.isArray(d))return((d,sx,sy)=>{void 0===sy&&(sy=sx);let i=0;for(;i<d.length;){switch(d[i]){case"h":case"H":d[i+1]*=sx,i++;break;case"v":case"V":d[i+1]*=sy,i++;break;case"m":case"M":case"l":case"L":d[i+1]*=sx,d[i+2]*=sy,i+=2;break;case"q":case"Q":d[i+1]*=sx,d[i+2]*=sy,d[i+3]*=sx,d[i+4]*=sy,i+=4;break;case"a":case"A":d[i+1]*=sx,d[i+2]*=sy,d[i+6]*=sx,d[i+7]*=sy,i+=7}i++}return d})(d,2*cfg.xs,-cfg.ys)}(attr.d,cfg);return["g",onml.tt(0,cfg.yo*idx+cfg.ys+cfg.y0),["path",{style:"fill:none;stroke:#000;stroke-width:1px;",d:d}]]}}}module.exports=function(lanes,index,cfg){let res=["g"];return lanes.map(((row,idx)=>{const wave=row.wave;Array.isArray(wave)&&res.push(renderLane(wave,idx,cfg))})),res}},{onml:49}],27:[function(require,module,exports){"use strict";var render=require("bit-field/lib/render.js");module.exports=function(index,source){return render(source.reg,source.config)}},{"bit-field/lib/render.js":36}],28:[function(require,module,exports){"use strict";var rec=require("./rec.js"),lane=require("./lane.js"),parseConfig=require("./parse-config.js"),parseWaveLanes=require("./parse-wave-lanes.js"),renderGroups=require("./render-groups.js"),renderLanes=require("./render-lanes.js"),renderWaveLane=require("./render-wave-lane.js"),insertSVGTemplate=require("./insert-svg-template.js");module.exports=function(index,source,waveSkin,notFirstSignal){!function(index,source,lane,waveSkin){if(0===index){var first,skin,socket;for(first in waveSkin)break;skin=waveSkin.default||waveSkin[first],source&&source.config&&source.config.skin&&waveSkin[source.config.skin]&&(skin=waveSkin[source.config.skin]),socket=skin[3][1][2][1],lane.xs=Number(socket.width),lane.ys=Number(socket.height),lane.xlabel=Number(socket.x),lane.ym=Number(socket.y)}}(index,source,lane,waveSkin),parseConfig(source,lane);var ret=rec(source.signal,{x:0,y:0,xmax:0,width:[],lanes:[],groups:[]}),content=parseWaveLanes(ret.lanes,lane),waveLanes=renderWaveLane(content,index,lane),waveGroups=renderGroups(ret.groups,index,lane),xmax=waveLanes.glengths.reduce((function(res,len,i){return Math.max(res,len+ret.width[i])}),0);return lane.xg=Math.ceil((xmax-lane.tgo)/lane.xs)*lane.xs,insertSVGTemplate(index,source,lane,waveSkin,content,renderLanes(index,content,waveLanes,ret,source,lane),waveGroups,notFirstSignal)}},{"./insert-svg-template.js":11,"./lane.js":12,"./parse-config.js":13,"./parse-wave-lanes.js":15,"./rec.js":17,"./render-groups.js":21,"./render-lanes.js":23,"./render-wave-lane.js":31}],29:[function(require,module,exports){"use strict";var renderAny=require("./render-any.js"),createElement=require("./create-element.js");module.exports=function(index,source,outputElement,waveSkin,notFirstSignal){for(;outputElement.childNodes.length;)outputElement.removeChild(outputElement.childNodes[0]);outputElement.insertBefore(createElement(renderAny(index,source,waveSkin,notFirstSignal)),null)}},{"./create-element.js":4,"./render-any.js":18}],30:[function(require,module,exports){"use strict";var renderWaveElement=require("./render-wave-element.js");module.exports=function(index,source,output,notFirstSignal){renderWaveElement(index,source,document.getElementById(output+index),window.WaveSkin,notFirstSignal)}},{"./render-wave-element.js":29}],31:[function(require,module,exports){"use strict";var tspan=require("tspan"),textWidth=require("./text-width.js"),findLaneMarkers=require("./find-lane-markers.js"),renderOverUnder=require("./render-over-under.js");function renderLaneUses(cont,lane){var res=[],labels=[];return cont[1]&&(cont[1].map((function(ref,i){res.push(["use",{"xlink:href":"#"+ref,transform:"translate("+i*lane.xs+")"}])})),cont[2]&&cont[2].length&&(labels=findLaneMarkers(cont[1])).length&&labels.map((function(label,i){cont[2]&&void 0!==cont[2][i]&&res.push(["text",{x:label*lane.xs+lane.xlabel,y:lane.ym,"text-anchor":"middle","xml:space":"preserve"}].concat(tspan.parse(cont[2][i])))}))),res}module.exports=function(content,index,lane){var xmax=0,glengths=[],res=[];return content.map((function(el,j){var name=el[0][0];if(name){var xoffset=el[0][1];xoffset=xoffset>0?Math.ceil(2*xoffset)-2*xoffset:-2*xoffset,res.push(["g",{id:"wavelane_"+j+"_"+index,transform:"translate(0,"+(lane.y0+j*lane.yo)+")"}].concat([["text",{x:lane.tgo,y:lane.ym,class:"info","text-anchor":"end","xml:space":"preserve"}].concat(tspan.parse(name))]).concat([["g",{id:"wavelane_draw_"+j+"_"+index,transform:"translate("+xoffset*lane.xs+", 0)"}].concat(renderLaneUses(el,lane))]).concat(renderOverUnder(el[3],"over",lane),renderOverUnder(el[3],"under",lane))),xmax=Math.max(xmax,(el[1]||[]).length),glengths.push(textWidth(name,11))}})),lane.xmax=Math.min(xmax,lane.xmax_cfg-lane.xmin_cfg),lane.xg=20,{glengths:glengths,res:res}}},{"./find-lane-markers.js":7,"./render-over-under.js":25,"./text-width.js":32,tspan:74}],32:[function(require,module,exports){"use strict";var charWidth=require("./char-width.json");module.exports=function(str,size){var i,len,c,w,width;for(size=size||11,len=str.length,width=0,i=0;i<len;i++)c=str.charCodeAt(i),void 0===(w=charWidth.chars[c])&&(w=charWidth.other),width+=w;return width*size/100}},{"./char-width.json":3}],33:[function(require,module,exports){"use strict";module.exports={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/XML/1998/namespace"}},{}],34:[function(require,module,exports){"use strict";window.WaveDrom=window.WaveDrom||{};var pkg=require("../package.json"),processAll=require("./process-all.js"),eva=require("./eva.js"),renderWaveForm=require("./render-wave-form.js"),editorRefresh=require("./editor-refresh.js");window.WaveDrom.ProcessAll=processAll,window.WaveDrom.RenderWaveForm=renderWaveForm,window.WaveDrom.EditorRefresh=editorRefresh,window.WaveDrom.eva=eva,window.WaveDrom.version=pkg.version},{"../package.json":78,"./editor-refresh.js":5,"./eva.js":6,"./process-all.js":16,"./render-wave-form.js":30}],35:[function(require,module,exports){"use strict";exports.byteLength=function(b64){var lens=getLens(b64),validLen=lens[0],placeHoldersLen=lens[1];return 3*(validLen+placeHoldersLen)/4-placeHoldersLen},exports.toByteArray=function(b64){var tmp,i,lens=getLens(b64),validLen=lens[0],placeHoldersLen=lens[1],arr=new Arr(function(b64,validLen,placeHoldersLen){return 3*(validLen+placeHoldersLen)/4-placeHoldersLen}(0,validLen,placeHoldersLen)),curByte=0,len=placeHoldersLen>0?validLen-4:validLen;for(i=0;i<len;i+=4)tmp=revLookup[b64.charCodeAt(i)]<<18|revLookup[b64.charCodeAt(i+1)]<<12|revLookup[b64.charCodeAt(i+2)]<<6|revLookup[b64.charCodeAt(i+3)],arr[curByte++]=tmp>>16&255,arr[curByte++]=tmp>>8&255,arr[curByte++]=255&tmp;2===placeHoldersLen&&(tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4,arr[curByte++]=255&tmp);1===placeHoldersLen&&(tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2,arr[curByte++]=tmp>>8&255,arr[curByte++]=255&tmp);return arr},exports.fromByteArray=function(uint8){for(var tmp,len=uint8.length,extraBytes=len%3,parts=[],i=0,len2=len-extraBytes;i<len2;i+=16383)parts.push(encodeChunk(uint8,i,i+16383>len2?len2:i+16383));1===extraBytes?(tmp=uint8[len-1],parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")):2===extraBytes&&(tmp=(uint8[len-2]<<8)+uint8[len-1],parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"="));return parts.join("")};for(var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function getLens(b64){var len=b64.length;if(len%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var validLen=b64.indexOf("=");return-1===validLen&&(validLen=len),[validLen,validLen===len?0:4-validLen%4]}function encodeChunk(uint8,start,end){for(var tmp,num,output=[],i=start;i<end;i+=3)tmp=(uint8[i]<<16&16711680)+(uint8[i+1]<<8&65280)+(255&uint8[i+2]),output.push(lookup[(num=tmp)>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[63&num]);return output.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63},{}],36:[function(require,module,exports){"use strict";const tspan=require("tspan"),round=Math.round,tt=(x,y,obj)=>Object.assign({transform:"translate("+x+(y?","+y:"")+")"},"object"==typeof obj?obj:{}),colors={2:0,3:80,4:170,5:45,6:126,7:215},norm=(obj,other)=>Object.assign(Object.keys(obj).reduce(((prev,key)=>{const val=Number(obj[key]),valInt=isNaN(val)?0:Math.round(val);return 0!==valInt&&(prev[key]=valInt),prev}),{}),other),text=(body,x,y,rotate)=>{const props={y:6};return void 0!==rotate&&(props.transform="rotate("+rotate+")"),["g",tt(round(x),round(y)),["text",props].concat(tspan.parse(body))]},hline=(len,x,y)=>["line",norm({x1:x,x2:x+len,y1:y,y2:y})],vline=(len,x,y)=>["line",norm({x1:x,x2:x,y1:y,y2:y+len})],getLabel=(val,x,y,step,len,rotate)=>{if("number"!=typeof val)return text(val,x,y,rotate);const res=["g",{}];for(let i=0;i<len;i++)res.push(text(val>>i&1,x+step*(len/2-i-.5),y));return res},labelArr=(desc,opt)=>{const{margin:margin,hspace:hspace,vspace:vspace,mod:mod,index:index,fontsize:fontsize,vflip:vflip,compact:compact}=opt,width=hspace-margin.left-margin.right-1,height=vspace-margin.top-margin.bottom,step=width/mod,blanks=["g"],bits=["g",tt(round(step/2),-round(.5*fontsize+4))],names=["g",tt(round(step/2),round(.5*height+.4*fontsize-6))],attrs=["g",tt(round(step/2),round(height+.7*fontsize-2))];return desc.map((e=>{let lsbm=0,msbm=mod-1,lsb=index*mod,msb=(index+1)*mod-1;if(e.lsb/mod>>0===index)lsbm=e.lsbm,lsb=e.lsb,e.msb/mod>>0===index&&(msb=e.msb,msbm=e.msbm);else if(e.msb/mod>>0===index)msb=e.msb,msbm=e.msbm;else if(!(lsb>e.lsb&&msb<e.msb))return;var t;compact||(bits.push(text(lsb,step*(vflip?lsbm:mod-lsbm-1))),lsbm!==msbm&&bits.push(text(msb,step*(vflip?msbm:mod-msbm-1)))),void 0!==e.name&&names.push(getLabel(e.name,step*(vflip?(msbm+lsbm)/2:mod-(msbm+lsbm)/2-1),0,step,e.bits,e.rotate)),void 0!==e.name&&void 0===e.type||blanks.push(["rect",norm({x:step*(vflip?lsbm:mod-msbm-1),width:step*(msbm-lsbm+1),height:height},{style:"fill-opacity:0.1"+(t=e.type,void 0!==colors[t]?";fill:hsl("+colors[t]+",100%,50%)":"")})]),void 0!==e.attr&&attrs.push(((e,opt,step,lsbm,msbm)=>{const x=opt.vflip?step*((msbm+lsbm)/2):step*(opt.mod-(msbm+lsbm)/2-1);return Array.isArray(e.attr)?e.attr.reduce(((prev,a,i)=>null==a?prev:prev.concat([getLabel(a,x,opt.fontsize*i,step,e.bits)])),["g",{}]):getLabel(e.attr,x,0,step,e.bits)})(e,opt,step,lsbm,msbm))})),["g",blanks,bits,names,attrs]},cage=(desc,opt)=>{const{hspace:hspace,vspace:vspace,mod:mod,margin:margin,index:index,vflip:vflip}=opt,width=hspace-margin.left-margin.right-1,height=vspace-margin.top-margin.bottom,res=["g",{stroke:"black","stroke-width":1,"stroke-linecap":"round"}];opt.uneven&&opt.bits%2==1&&index===opt.lanes-1?vflip?(res.push(hline(width-width/mod,0,0)),res.push(hline(width-width/mod,0,height))):(res.push(hline(width-width/mod,width/mod,0)),res.push(hline(width-width/mod,width/mod,height))):(res.push(hline(width,0,0)),res.push(hline(width,0,height)),res.push(vline(height,vflip?width:0,0)));let i=index*mod;const delta=vflip?1:-1;let j=vflip?0:mod;for(let k=0;k<mod;k++){const xj=j*(width/mod);0===k||desc.some((e=>e.msb+1===i))?res.push(vline(height,xj,0)):(res.push(vline(height>>>3,xj,0)),res.push(vline(-(height>>>3),xj,height))),i++,j+=delta}return res},lane=(desc,opt)=>{const{index:index,vspace:vspace,hspace:hspace,margin:margin,hflip:hflip,lanes:lanes,compact:compact,label:label}=opt,height=vspace-margin.top-margin.bottom,width=hspace-margin.left-margin.right-1;let tx=margin.left;const idx=hflip?index:lanes-index-1;let ty=round(idx*vspace+margin.top);compact&&(ty=round(idx*height+margin.top));const res=["g",tt(tx,ty),cage(desc,opt),labelArr(desc,opt)];if(label&&void 0!==label.left){const lab=label.left;let txt=index;"string"==typeof lab?txt=lab:"number"==typeof lab?txt+=lab:"object"==typeof lab&&(txt=lab[index]||txt),res.push(["g",{"text-anchor":"end"},text(txt,-4,round(height/2))])}if(label&&void 0!==label.right){const lab=label.right;let txt=index;"string"==typeof lab?txt=lab:"number"==typeof lab?txt+=lab:"object"==typeof lab&&(txt=lab[index]||txt),res.push(["g",{"text-anchor":"start"},text(txt,width+4,round(height/2))])}return res};module.exports=(desc,opt)=>{[["hspace",40,800],["lanes",1,1],["bits",1,void 0],["fontsize",6,14]].map((opt=>row=>{const[key,min,def]=row,val=Math.round(opt[key]);opt[key]="number"==typeof val&&val>=min?val:def})(opt="object"==typeof opt?opt:{}));const maxAttributes=(desc=>desc.reduce(((prev,field)=>Math.max(prev,void 0===field.attr?0:Array.isArray(field.attr)?field.attr.length:1)),0))(desc);opt.vspace=opt.vspace||(maxAttributes+4)*opt.fontsize,opt.fontfamily=opt.fontfamily||"sans-serif",opt.fontweight=opt.fontweight||"normal",opt.compact=opt.compact||!1,opt.hflip=opt.hflip||!1,opt.uneven=opt.uneven||!1,opt.margin=opt.margin||{},void 0===opt.bits&&(opt.bits=(desc=>desc.reduce(((prev,field)=>prev+(void 0===field.bits?0:field.bits)),0))(desc));const{hspace:hspace,vspace:vspace,lanes:lanes,margin:margin,compact:compact,fontsize:fontsize,bits:bits,label:label}=opt;void 0===margin.right&&(label&&void 0!==label.right?margin.right=round(.1*hspace):margin.right=4),void 0===margin.left&&(label&&void 0!==label.left?margin.left=round(.1*hspace):margin.left=4),void 0===margin.top?(margin.top=1.5*fontsize,void 0===margin.bottom&&(margin.bottom=fontsize*maxAttributes+4)):void 0===margin.bottom&&(margin.bottom=4);let width=hspace,height=vspace*lanes;compact&&(height-=(lanes-1)*(margin.top+margin.bottom));const res=["g",tt(.5,.5,{"text-anchor":"middle","font-size":opt.fontsize,"font-family":opt.fontfamily,"font-weight":opt.fontweight})];let lsb=0;const mod=Math.ceil(1*bits/lanes);opt.mod=0|mod,desc.map((e=>{e.lsb=lsb,e.lsbm=lsb%mod,lsb+=e.bits,e.msb=lsb-1,e.msbm=e.msb%mod}));for(let i=0;i<lanes;i++)opt.index=i,res.push(lane(desc,opt));return compact&&res.push(((desc,opt)=>{const{hspace:hspace,margin:margin,mod:mod,fontsize:fontsize,vflip:vflip}=opt,step=(hspace-margin.left-margin.right-1)/mod,labels=["g",tt(margin.left,-3)],mask=((desc,mod)=>{const mask=[];let idx=0;return desc.map((e=>{mask[idx%mod]=!0,idx+=e.bits,mask[(idx-1)%mod]=!0})),mask})(desc,mod);for(let i=0;i<mod;i++){const idx=vflip?i:mod-i-1;mask[idx]&&labels.push(text(idx,step*(i+.5),.5*fontsize+4))}return labels})(desc,opt)),(w=width,h=height,["svg",{xmlns:"http://www.w3.org/2000/svg",width:w,height:h,viewBox:[0,0,w,h].join(" ")}]).concat([res]);var w,h}},{tspan:74}],37:[function(require,module,exports){},{}],38:[function(require,module,exports){(function(Buffer){(function(){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
"use strict";var base64=require("base64-js"),ieee754=require("ieee754");exports.Buffer=Buffer,exports.SlowBuffer=function(length){+length!=length&&(length=0);return Buffer.alloc(+length)},exports.INSPECT_MAX_BYTES=50;function createBuffer(length){if(length>2147483647)throw new RangeError('The value "'+length+'" is invalid for option "size"');var buf=new Uint8Array(length);return buf.__proto__=Buffer.prototype,buf}function Buffer(arg,encodingOrOffset,length){if("number"==typeof arg){if("string"==typeof encodingOrOffset)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(arg)}return from(arg,encodingOrOffset,length)}function from(value,encodingOrOffset,length){if("string"==typeof value)return function(string,encoding){"string"==typeof encoding&&""!==encoding||(encoding="utf8");if(!Buffer.isEncoding(encoding))throw new TypeError("Unknown encoding: "+encoding);var length=0|byteLength(string,encoding),buf=createBuffer(length),actual=buf.write(string,encoding);actual!==length&&(buf=buf.slice(0,actual));return buf}(value,encodingOrOffset);if(ArrayBuffer.isView(value))return fromArrayLike(value);if(null==value)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof value);if(isInstance(value,ArrayBuffer)||value&&isInstance(value.buffer,ArrayBuffer))return function(array,byteOffset,length){if(byteOffset<0||array.byteLength<byteOffset)throw new RangeError('"offset" is outside of buffer bounds');if(array.byteLength<byteOffset+(length||0))throw new RangeError('"length" is outside of buffer bounds');var buf;buf=void 0===byteOffset&&void 0===length?new Uint8Array(array):void 0===length?new Uint8Array(array,byteOffset):new Uint8Array(array,byteOffset,length);return buf.__proto__=Buffer.prototype,buf}(value,encodingOrOffset,length);if("number"==typeof value)throw new TypeError('The "value" argument must not be of type number. Received type number');var valueOf=value.valueOf&&value.valueOf();if(null!=valueOf&&valueOf!==value)return Buffer.from(valueOf,encodingOrOffset,length);var b=function(obj){if(Buffer.isBuffer(obj)){var len=0|checked(obj.length),buf=createBuffer(len);return 0===buf.length||obj.copy(buf,0,0,len),buf}if(void 0!==obj.length)return"number"!=typeof obj.length||numberIsNaN(obj.length)?createBuffer(0):fromArrayLike(obj);if("Buffer"===obj.type&&Array.isArray(obj.data))return fromArrayLike(obj.data)}(value);if(b)return b;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof value[Symbol.toPrimitive])return Buffer.from(value[Symbol.toPrimitive]("string"),encodingOrOffset,length);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof value)}function assertSize(size){if("number"!=typeof size)throw new TypeError('"size" argument must be of type number');if(size<0)throw new RangeError('The value "'+size+'" is invalid for option "size"')}function allocUnsafe(size){return assertSize(size),createBuffer(size<0?0:0|checked(size))}function fromArrayLike(array){for(var length=array.length<0?0:0|checked(array.length),buf=createBuffer(length),i=0;i<length;i+=1)buf[i]=255&array[i];return buf}function checked(length){if(length>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|length}function byteLength(string,encoding){if(Buffer.isBuffer(string))return string.length;if(ArrayBuffer.isView(string)||isInstance(string,ArrayBuffer))return string.byteLength;if("string"!=typeof string)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof string);var len=string.length,mustMatch=arguments.length>2&&!0===arguments[2];if(!mustMatch&&0===len)return 0;for(var loweredCase=!1;;)switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*len;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return mustMatch?-1:utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase(),loweredCase=!0}}function slowToString(encoding,start,end){var loweredCase=!1;if((void 0===start||start<0)&&(start=0),start>this.length)return"";if((void 0===end||end>this.length)&&(end=this.length),end<=0)return"";if((end>>>=0)<=(start>>>=0))return"";for(encoding||(encoding="utf8");;)switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase(),loweredCase=!0}}function swap(b,n,m){var i=b[n];b[n]=b[m],b[m]=i}function bidirectionalIndexOf(buffer,val,byteOffset,encoding,dir){if(0===buffer.length)return-1;if("string"==typeof byteOffset?(encoding=byteOffset,byteOffset=0):byteOffset>2147483647?byteOffset=2147483647:byteOffset<-2147483648&&(byteOffset=-2147483648),numberIsNaN(byteOffset=+byteOffset)&&(byteOffset=dir?0:buffer.length-1),byteOffset<0&&(byteOffset=buffer.length+byteOffset),byteOffset>=buffer.length){if(dir)return-1;byteOffset=buffer.length-1}else if(byteOffset<0){if(!dir)return-1;byteOffset=0}if("string"==typeof val&&(val=Buffer.from(val,encoding)),Buffer.isBuffer(val))return 0===val.length?-1:arrayIndexOf(buffer,val,byteOffset,encoding,dir);if("number"==typeof val)return val&=255,"function"==typeof Uint8Array.prototype.indexOf?dir?Uint8Array.prototype.indexOf.call(buffer,val,byteOffset):Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset):arrayIndexOf(buffer,[val],byteOffset,encoding,dir);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var i,indexSize=1,arrLength=arr.length,valLength=val.length;if(void 0!==encoding&&("ucs2"===(encoding=String(encoding).toLowerCase())||"ucs-2"===encoding||"utf16le"===encoding||"utf-16le"===encoding)){if(arr.length<2||val.length<2)return-1;indexSize=2,arrLength/=2,valLength/=2,byteOffset/=2}function read(buf,i){return 1===indexSize?buf[i]:buf.readUInt16BE(i*indexSize)}if(dir){var foundIndex=-1;for(i=byteOffset;i<arrLength;i++)if(read(arr,i)===read(val,-1===foundIndex?0:i-foundIndex)){if(-1===foundIndex&&(foundIndex=i),i-foundIndex+1===valLength)return foundIndex*indexSize}else-1!==foundIndex&&(i-=i-foundIndex),foundIndex=-1}else for(byteOffset+valLength>arrLength&&(byteOffset=arrLength-valLength),i=byteOffset;i>=0;i--){for(var found=!0,j=0;j<valLength;j++)if(read(arr,i+j)!==read(val,j)){found=!1;break}if(found)return i}return-1}function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;length?(length=Number(length))>remaining&&(length=remaining):length=remaining;var strLen=string.length;length>strLen/2&&(length=strLen/2);for(var i=0;i<length;++i){var parsed=parseInt(string.substr(2*i,2),16);if(numberIsNaN(parsed))return i;buf[offset+i]=parsed}return i}function utf8Write(buf,string,offset,length){return blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length)}function asciiWrite(buf,string,offset,length){return blitBuffer(function(str){for(var byteArray=[],i=0;i<str.length;++i)byteArray.push(255&str.charCodeAt(i));return byteArray}(string),buf,offset,length)}function latin1Write(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){return blitBuffer(base64ToBytes(string),buf,offset,length)}function ucs2Write(buf,string,offset,length){return blitBuffer(function(str,units){for(var c,hi,lo,byteArray=[],i=0;i<str.length&&!((units-=2)<0);++i)hi=(c=str.charCodeAt(i))>>8,lo=c%256,byteArray.push(lo),byteArray.push(hi);return byteArray}(string,buf.length-offset),buf,offset,length)}function base64Slice(buf,start,end){return 0===start&&end===buf.length?base64.fromByteArray(buf):base64.fromByteArray(buf.slice(start,end))}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);for(var res=[],i=start;i<end;){var secondByte,thirdByte,fourthByte,tempCodePoint,firstByte=buf[i],codePoint=null,bytesPerSequence=firstByte>239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end)switch(bytesPerSequence){case 1:firstByte<128&&(codePoint=firstByte);break;case 2:128==(192&(secondByte=buf[i+1]))&&(tempCodePoint=(31&firstByte)<<6|63&secondByte)>127&&(codePoint=tempCodePoint);break;case 3:secondByte=buf[i+1],thirdByte=buf[i+2],128==(192&secondByte)&&128==(192&thirdByte)&&(tempCodePoint=(15&firstByte)<<12|(63&secondByte)<<6|63&thirdByte)>2047&&(tempCodePoint<55296||tempCodePoint>57343)&&(codePoint=tempCodePoint);break;case 4:secondByte=buf[i+1],thirdByte=buf[i+2],fourthByte=buf[i+3],128==(192&secondByte)&&128==(192&thirdByte)&&128==(192&fourthByte)&&(tempCodePoint=(15&firstByte)<<18|(63&secondByte)<<12|(63&thirdByte)<<6|63&fourthByte)>65535&&tempCodePoint<1114112&&(codePoint=tempCodePoint)}null===codePoint?(codePoint=65533,bytesPerSequence=1):codePoint>65535&&(codePoint-=65536,res.push(codePoint>>>10&1023|55296),codePoint=56320|1023&codePoint),res.push(codePoint),i+=bytesPerSequence}return function(codePoints){var len=codePoints.length;if(len<=4096)return String.fromCharCode.apply(String,codePoints);var res="",i=0;for(;i<len;)res+=String.fromCharCode.apply(String,codePoints.slice(i,i+=4096));return res}(res)}exports.kMaxLength=2147483647,Buffer.TYPED_ARRAY_SUPPORT=function(){try{var arr=new Uint8Array(1);return arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===arr.foo()}catch(e){return!1}}(),Buffer.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(Buffer.prototype,"parent",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),Buffer.poolSize=8192,Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length)},Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,Buffer.alloc=function(size,fill,encoding){return function(size,fill,encoding){return assertSize(size),size<=0?createBuffer(size):void 0!==fill?"string"==typeof encoding?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill):createBuffer(size)}(size,fill,encoding)},Buffer.allocUnsafe=function(size){return allocUnsafe(size)},Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size)},Buffer.isBuffer=function(b){return null!=b&&!0===b._isBuffer&&b!==Buffer.prototype},Buffer.compare=function(a,b){if(isInstance(a,Uint8Array)&&(a=Buffer.from(a,a.offset,a.byteLength)),isInstance(b,Uint8Array)&&(b=Buffer.from(b,b.offset,b.byteLength)),!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(a===b)return 0;for(var x=a.length,y=b.length,i=0,len=Math.min(x,y);i<len;++i)if(a[i]!==b[i]){x=a[i],y=b[i];break}return x<y?-1:y<x?1:0},Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function(list,length){if(!Array.isArray(list))throw new TypeError('"list" argument must be an Array of Buffers');if(0===list.length)return Buffer.alloc(0);var i;if(void 0===length)for(length=0,i=0;i<list.length;++i)length+=list[i].length;var buffer=Buffer.allocUnsafe(length),pos=0;for(i=0;i<list.length;++i){var buf=list[i];if(isInstance(buf,Uint8Array)&&(buf=Buffer.from(buf)),!Buffer.isBuffer(buf))throw new TypeError('"list" argument must be an Array of Buffers');buf.copy(buffer,pos),pos+=buf.length}return buffer},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function(){var len=this.length;if(len%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var i=0;i<len;i+=2)swap(this,i,i+1);return this},Buffer.prototype.swap32=function(){var len=this.length;if(len%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var i=0;i<len;i+=4)swap(this,i,i+3),swap(this,i+1,i+2);return this},Buffer.prototype.swap64=function(){var len=this.length;if(len%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var i=0;i<len;i+=8)swap(this,i,i+7),swap(this,i+1,i+6),swap(this,i+2,i+5),swap(this,i+3,i+4);return this},Buffer.prototype.toString=function(){var length=this.length;return 0===length?"":0===arguments.length?utf8Slice(this,0,length):slowToString.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b||0===Buffer.compare(this,b)},Buffer.prototype.inspect=function(){var str="",max=exports.INSPECT_MAX_BYTES;return str=this.toString("hex",0,max).replace(/(.{2})/g,"$1 ").trim(),this.length>max&&(str+=" ... "),"<Buffer "+str+">"},Buffer.prototype.compare=function(target,start,end,thisStart,thisEnd){if(isInstance(target,Uint8Array)&&(target=Buffer.from(target,target.offset,target.byteLength)),!Buffer.isBuffer(target))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof target);if(void 0===start&&(start=0),void 0===end&&(end=target?target.length:0),void 0===thisStart&&(thisStart=0),void 0===thisEnd&&(thisEnd=this.length),start<0||end>target.length||thisStart<0||thisEnd>this.length)throw new RangeError("out of range index");if(thisStart>=thisEnd&&start>=end)return 0;if(thisStart>=thisEnd)return-1;if(start>=end)return 1;if(this===target)return 0;for(var x=(thisEnd>>>=0)-(thisStart>>>=0),y=(end>>>=0)-(start>>>=0),len=Math.min(x,y),thisCopy=this.slice(thisStart,thisEnd),targetCopy=target.slice(start,end),i=0;i<len;++i)if(thisCopy[i]!==targetCopy[i]){x=thisCopy[i],y=targetCopy[i];break}return x<y?-1:y<x?1:0},Buffer.prototype.includes=function(val,byteOffset,encoding){return-1!==this.indexOf(val,byteOffset,encoding)},Buffer.prototype.indexOf=function(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,!0)},Buffer.prototype.lastIndexOf=function(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,!1)},Buffer.prototype.write=function(string,offset,length,encoding){if(void 0===offset)encoding="utf8",length=this.length,offset=0;else if(void 0===length&&"string"==typeof offset)encoding=offset,length=this.length,offset=0;else{if(!isFinite(offset))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");offset>>>=0,isFinite(length)?(length>>>=0,void 0===encoding&&(encoding="utf8")):(encoding=length,length=void 0)}var remaining=this.length-offset;if((void 0===length||length>remaining)&&(length=remaining),string.length>0&&(length<0||offset<0)||offset>this.length)throw new RangeError("Attempt to write outside buffer bounds");encoding||(encoding="utf8");for(var loweredCase=!1;;)switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase(),loweredCase=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i)ret+=String.fromCharCode(127&buf[i]);return ret}function latin1Slice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i)ret+=String.fromCharCode(buf[i]);return ret}function hexSlice(buf,start,end){var len=buf.length;(!start||start<0)&&(start=0),(!end||end<0||end>len)&&(end=len);for(var out="",i=start;i<end;++i)out+=toHex(buf[i]);return out}function utf16leSlice(buf,start,end){for(var bytes=buf.slice(start,end),res="",i=0;i<bytes.length;i+=2)res+=String.fromCharCode(bytes[i]+256*bytes[i+1]);return res}function checkOffset(offset,ext,length){if(offset%1!=0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||value<min)throw new RangeError('"value" argument is out of bounds');if(offset+ext>buf.length)throw new RangeError("Index out of range")}function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){return value=+value,offset>>>=0,noAssert||checkIEEE754(buf,0,offset,4),ieee754.write(buf,value,offset,littleEndian,23,4),offset+4}function writeDouble(buf,value,offset,littleEndian,noAssert){return value=+value,offset>>>=0,noAssert||checkIEEE754(buf,0,offset,8),ieee754.write(buf,value,offset,littleEndian,52,8),offset+8}Buffer.prototype.slice=function(start,end){var len=this.length;(start=~~start)<0?(start+=len)<0&&(start=0):start>len&&(start=len),(end=void 0===end?len:~~end)<0?(end+=len)<0&&(end=0):end>len&&(end=len),end<start&&(end=start);var newBuf=this.subarray(start,end);return newBuf.__proto__=Buffer.prototype,newBuf},Buffer.prototype.readUIntLE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset],mul=1,i=0;++i<byteLength&&(mul*=256);)val+=this[offset+i]*mul;return val},Buffer.prototype.readUIntBE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset+--byteLength],mul=1;byteLength>0&&(mul*=256);)val+=this[offset+--byteLength]*mul;return val},Buffer.prototype.readUInt8=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,1,this.length),this[offset]},Buffer.prototype.readUInt16LE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,2,this.length),this[offset]|this[offset+1]<<8},Buffer.prototype.readUInt16BE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,2,this.length),this[offset]<<8|this[offset+1]},Buffer.prototype.readUInt32LE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+16777216*this[offset+3]},Buffer.prototype.readUInt32BE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),16777216*this[offset]+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])},Buffer.prototype.readIntLE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset],mul=1,i=0;++i<byteLength&&(mul*=256);)val+=this[offset+i]*mul;return val>=(mul*=128)&&(val-=Math.pow(2,8*byteLength)),val},Buffer.prototype.readIntBE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var i=byteLength,mul=1,val=this[offset+--i];i>0&&(mul*=256);)val+=this[offset+--i]*mul;return val>=(mul*=128)&&(val-=Math.pow(2,8*byteLength)),val},Buffer.prototype.readInt8=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,1,this.length),128&this[offset]?-1*(255-this[offset]+1):this[offset]},Buffer.prototype.readInt16LE=function(offset,noAssert){offset>>>=0,noAssert||checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return 32768&val?4294901760|val:val},Buffer.prototype.readInt16BE=function(offset,noAssert){offset>>>=0,noAssert||checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return 32768&val?4294901760|val:val},Buffer.prototype.readInt32LE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24},Buffer.prototype.readInt32BE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]},Buffer.prototype.readFloatLE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),ieee754.read(this,offset,!0,23,4)},Buffer.prototype.readFloatBE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),ieee754.read(this,offset,!1,23,4)},Buffer.prototype.readDoubleLE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,8,this.length),ieee754.read(this,offset,!0,52,8)},Buffer.prototype.readDoubleBE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,8,this.length),ieee754.read(this,offset,!1,52,8)},Buffer.prototype.writeUIntLE=function(value,offset,byteLength,noAssert){(value=+value,offset>>>=0,byteLength>>>=0,noAssert)||checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength)-1,0);var mul=1,i=0;for(this[offset]=255&value;++i<byteLength&&(mul*=256);)this[offset+i]=value/mul&255;return offset+byteLength},Buffer.prototype.writeUIntBE=function(value,offset,byteLength,noAssert){(value=+value,offset>>>=0,byteLength>>>=0,noAssert)||checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength)-1,0);var i=byteLength-1,mul=1;for(this[offset+i]=255&value;--i>=0&&(mul*=256);)this[offset+i]=value/mul&255;return offset+byteLength},Buffer.prototype.writeUInt8=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,1,255,0),this[offset]=255&value,offset+1},Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,65535,0),this[offset]=255&value,this[offset+1]=value>>>8,offset+2},Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,65535,0),this[offset]=value>>>8,this[offset+1]=255&value,offset+2},Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,4294967295,0),this[offset+3]=value>>>24,this[offset+2]=value>>>16,this[offset+1]=value>>>8,this[offset]=255&value,offset+4},Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,4294967295,0),this[offset]=value>>>24,this[offset+1]=value>>>16,this[offset+2]=value>>>8,this[offset+3]=255&value,offset+4},Buffer.prototype.writeIntLE=function(value,offset,byteLength,noAssert){if(value=+value,offset>>>=0,!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0,mul=1,sub=0;for(this[offset]=255&value;++i<byteLength&&(mul*=256);)value<0&&0===sub&&0!==this[offset+i-1]&&(sub=1),this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength},Buffer.prototype.writeIntBE=function(value,offset,byteLength,noAssert){if(value=+value,offset>>>=0,!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1,mul=1,sub=0;for(this[offset+i]=255&value;--i>=0&&(mul*=256);)value<0&&0===sub&&0!==this[offset+i+1]&&(sub=1),this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength},Buffer.prototype.writeInt8=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,1,127,-128),value<0&&(value=255+value+1),this[offset]=255&value,offset+1},Buffer.prototype.writeInt16LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,32767,-32768),this[offset]=255&value,this[offset+1]=value>>>8,offset+2},Buffer.prototype.writeInt16BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,32767,-32768),this[offset]=value>>>8,this[offset+1]=255&value,offset+2},Buffer.prototype.writeInt32LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,2147483647,-2147483648),this[offset]=255&value,this[offset+1]=value>>>8,this[offset+2]=value>>>16,this[offset+3]=value>>>24,offset+4},Buffer.prototype.writeInt32BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,2147483647,-2147483648),value<0&&(value=4294967295+value+1),this[offset]=value>>>24,this[offset+1]=value>>>16,this[offset+2]=value>>>8,this[offset+3]=255&value,offset+4},Buffer.prototype.writeFloatLE=function(value,offset,noAssert){return writeFloat(this,value,offset,!0,noAssert)},Buffer.prototype.writeFloatBE=function(value,offset,noAssert){return writeFloat(this,value,offset,!1,noAssert)},Buffer.prototype.writeDoubleLE=function(value,offset,noAssert){return writeDouble(this,value,offset,!0,noAssert)},Buffer.prototype.writeDoubleBE=function(value,offset,noAssert){return writeDouble(this,value,offset,!1,noAssert)},Buffer.prototype.copy=function(target,targetStart,start,end){if(!Buffer.isBuffer(target))throw new TypeError("argument should be a Buffer");if(start||(start=0),end||0===end||(end=this.length),targetStart>=target.length&&(targetStart=target.length),targetStart||(targetStart=0),end>0&&end<start&&(end=start),end===start)return 0;if(0===target.length||0===this.length)return 0;if(targetStart<0)throw new RangeError("targetStart out of bounds");if(start<0||start>=this.length)throw new RangeError("Index out of range");if(end<0)throw new RangeError("sourceEnd out of bounds");end>this.length&&(end=this.length),target.length-targetStart<end-start&&(end=target.length-targetStart+start);var len=end-start;if(this===target&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(targetStart,start,end);else if(this===target&&start<targetStart&&targetStart<end)for(var i=len-1;i>=0;--i)target[i+targetStart]=this[i+start];else Uint8Array.prototype.set.call(target,this.subarray(start,end),targetStart);return len},Buffer.prototype.fill=function(val,start,end,encoding){if("string"==typeof val){if("string"==typeof start?(encoding=start,start=0,end=this.length):"string"==typeof end&&(encoding=end,end=this.length),void 0!==encoding&&"string"!=typeof encoding)throw new TypeError("encoding must be a string");if("string"==typeof encoding&&!Buffer.isEncoding(encoding))throw new TypeError("Unknown encoding: "+encoding);if(1===val.length){var code=val.charCodeAt(0);("utf8"===encoding&&code<128||"latin1"===encoding)&&(val=code)}}else"number"==typeof val&&(val&=255);if(start<0||this.length<start||this.length<end)throw new RangeError("Out of range index");if(end<=start)return this;var i;if(start>>>=0,end=void 0===end?this.length:end>>>0,val||(val=0),"number"==typeof val)for(i=start;i<end;++i)this[i]=val;else{var bytes=Buffer.isBuffer(val)?val:Buffer.from(val,encoding),len=bytes.length;if(0===len)throw new TypeError('The value "'+val+'" is invalid for argument "value"');for(i=0;i<end-start;++i)this[i+start]=bytes[i%len]}return this};var INVALID_BASE64_RE=/[^+/0-9A-Za-z-_]/g;function toHex(n){return n<16?"0"+n.toString(16):n.toString(16)}function utf8ToBytes(string,units){var codePoint;units=units||1/0;for(var length=string.length,leadSurrogate=null,bytes=[],i=0;i<length;++i){if((codePoint=string.charCodeAt(i))>55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){(units-=3)>-1&&bytes.push(239,191,189);continue}if(i+1===length){(units-=3)>-1&&bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){(units-=3)>-1&&bytes.push(239,191,189),leadSurrogate=codePoint;continue}codePoint=65536+(leadSurrogate-55296<<10|codePoint-56320)}else leadSurrogate&&(units-=3)>-1&&bytes.push(239,191,189);if(leadSurrogate=null,codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,63&codePoint|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,63&codePoint|128)}else{if(!(codePoint<1114112))throw new Error("Invalid code point");if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,63&codePoint|128)}}return bytes}function base64ToBytes(str){return base64.toByteArray(function(str){if((str=(str=str.split("=")[0]).trim().replace(INVALID_BASE64_RE,"")).length<2)return"";for(;str.length%4!=0;)str+="=";return str}(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i<length&&!(i+offset>=dst.length||i>=src.length);++i)dst[i+offset]=src[i];return i}function isInstance(obj,type){return obj instanceof type||null!=obj&&null!=obj.constructor&&null!=obj.constructor.name&&obj.constructor.name===type.name}function numberIsNaN(obj){return obj!=obj}}).call(this)}).call(this,require("buffer").Buffer)},{"base64-js":35,buffer:38,ieee754:40}],39:[function(require,module,exports){"use strict";var ReflectOwnKeys,R="object"==typeof Reflect?Reflect:null,ReflectApply=R&&"function"==typeof R.apply?R.apply:function(target,receiver,args){return Function.prototype.apply.call(target,receiver,args)};ReflectOwnKeys=R&&"function"==typeof R.ownKeys?R.ownKeys:Object.getOwnPropertySymbols?function(target){return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target))}:function(target){return Object.getOwnPropertyNames(target)};var NumberIsNaN=Number.isNaN||function(value){return value!=value};function EventEmitter(){EventEmitter.init.call(this)}module.exports=EventEmitter,module.exports.once=function(emitter,name){return new Promise((function(resolve,reject){function errorListener(err){emitter.removeListener(name,resolver),reject(err)}function resolver(){"function"==typeof emitter.removeListener&&emitter.removeListener("error",errorListener),resolve([].slice.call(arguments))}eventTargetAgnosticAddListener(emitter,name,resolver,{once:!0}),"error"!==name&&function(emitter,handler,flags){"function"==typeof emitter.on&&eventTargetAgnosticAddListener(emitter,"error",handler,flags)}(emitter,errorListener,{once:!0})}))},EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._eventsCount=0,EventEmitter.prototype._maxListeners=void 0;var defaultMaxListeners=10;function checkListener(listener){if("function"!=typeof listener)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof listener)}function _getMaxListeners(that){return void 0===that._maxListeners?EventEmitter.defaultMaxListeners:that._maxListeners}function _addListener(target,type,listener,prepend){var m,events,existing,warning;if(checkListener(listener),void 0===(events=target._events)?(events=target._events=Object.create(null),target._eventsCount=0):(void 0!==events.newListener&&(target.emit("newListener",type,listener.listener?listener.listener:listener),events=target._events),existing=events[type]),void 0===existing)existing=events[type]=listener,++target._eventsCount;else if("function"==typeof existing?existing=events[type]=prepend?[listener,existing]:[existing,listener]:prepend?existing.unshift(listener):existing.push(listener),(m=_getMaxListeners(target))>0&&existing.length>m&&!existing.warned){existing.warned=!0;var w=new Error("Possible EventEmitter memory leak detected. "+existing.length+" "+String(type)+" listeners added. Use emitter.setMaxListeners() to increase limit");w.name="MaxListenersExceededWarning",w.emitter=target,w.type=type,w.count=existing.length,warning=w,console&&console.warn&&console.warn(warning)}return target}function onceWrapper(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _onceWrap(target,type,listener){var state={fired:!1,wrapFn:void 0,target:target,type:type,listener:listener},wrapped=onceWrapper.bind(state);return wrapped.listener=listener,state.wrapFn=wrapped,wrapped}function _listeners(target,type,unwrap){var events=target._events;if(void 0===events)return[];var evlistener=events[type];return void 0===evlistener?[]:"function"==typeof evlistener?unwrap?[evlistener.listener||evlistener]:[evlistener]:unwrap?function(arr){for(var ret=new Array(arr.length),i=0;i<ret.length;++i)ret[i]=arr[i].listener||arr[i];return ret}(evlistener):arrayClone(evlistener,evlistener.length)}function listenerCount(type){var events=this._events;if(void 0!==events){var evlistener=events[type];if("function"==typeof evlistener)return 1;if(void 0!==evlistener)return evlistener.length}return 0}function arrayClone(arr,n){for(var copy=new Array(n),i=0;i<n;++i)copy[i]=arr[i];return copy}function eventTargetAgnosticAddListener(emitter,name,listener,flags){if("function"==typeof emitter.on)flags.once?emitter.once(name,listener):emitter.on(name,listener);else{if("function"!=typeof emitter.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof emitter);emitter.addEventListener(name,(function wrapListener(arg){flags.once&&emitter.removeEventListener(name,wrapListener),listener(arg)}))}}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:!0,get:function(){return defaultMaxListeners},set:function(arg){if("number"!=typeof arg||arg<0||NumberIsNaN(arg))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+arg+".");defaultMaxListeners=arg}}),EventEmitter.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},EventEmitter.prototype.setMaxListeners=function(n){if("number"!=typeof n||n<0||NumberIsNaN(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this},EventEmitter.prototype.getMaxListeners=function(){return _getMaxListeners(this)},EventEmitter.prototype.emit=function(type){for(var args=[],i=1;i<arguments.length;i++)args.push(arguments[i]);var doError="error"===type,events=this._events;if(void 0!==events)doError=doError&&void 0===events.error;else if(!doError)return!1;if(doError){var er;if(args.length>0&&(er=args[0]),er instanceof Error)throw er;var err=new Error("Unhandled error."+(er?" ("+er.message+")":""));throw err.context=er,err}var handler=events[type];if(void 0===handler)return!1;if("function"==typeof handler)ReflectApply(handler,this,args);else{var len=handler.length,listeners=arrayClone(handler,len);for(i=0;i<len;++i)ReflectApply(listeners[i],this,args)}return!0},EventEmitter.prototype.addListener=function(type,listener){return _addListener(this,type,listener,!1)},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.prependListener=function(type,listener){return _addListener(this,type,listener,!0)},EventEmitter.prototype.once=function(type,listener){return checkListener(listener),this.on(type,_onceWrap(this,type,listener)),this},EventEmitter.prototype.prependOnceListener=function(type,listener){return checkListener(listener),this.prependListener(type,_onceWrap(this,type,listener)),this},EventEmitter.prototype.removeListener=function(type,listener){var list,events,position,i,originalListener;if(checkListener(listener),void 0===(events=this._events))return this;if(void 0===(list=events[type]))return this;if(list===listener||list.listener===listener)0==--this._eventsCount?this._events=Object.create(null):(delete events[type],events.removeListener&&this.emit("removeListener",type,list.listener||listener));else if("function"!=typeof list){for(position=-1,i=list.length-1;i>=0;i--)if(list[i]===listener||list[i].listener===listener){originalListener=list[i].listener,position=i;break}if(position<0)return this;0===position?list.shift():function(list,index){for(;index+1<list.length;index++)list[index]=list[index+1];list.pop()}(list,position),1===list.length&&(events[type]=list[0]),void 0!==events.removeListener&&this.emit("removeListener",type,originalListener||listener)}return this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.removeAllListeners=function(type){var listeners,events,i;if(void 0===(events=this._events))return this;if(void 0===events.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==events[type]&&(0==--this._eventsCount?this._events=Object.create(null):delete events[type]),this;if(0===arguments.length){var key,keys=Object.keys(events);for(i=0;i<keys.length;++i)"removeListener"!==(key=keys[i])&&this.removeAllListeners(key);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(listeners=events[type]))this.removeListener(type,listeners);else if(void 0!==listeners)for(i=listeners.length-1;i>=0;i--)this.removeListener(type,listeners[i]);return this},EventEmitter.prototype.listeners=function(type){return _listeners(this,type,!0)},EventEmitter.prototype.rawListeners=function(type){return _listeners(this,type,!1)},EventEmitter.listenerCount=function(emitter,type){return"function"==typeof emitter.listenerCount?emitter.listenerCount(type):listenerCount.call(emitter,type)},EventEmitter.prototype.listenerCount=listenerCount,EventEmitter.prototype.eventNames=function(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]}},{}],40:[function(require,module,exports){
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=8*nBytes-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];for(i+=d,e=s&(1<<-nBits)-1,s>>=-nBits,nBits+=eLen;nBits>0;e=256*e+buffer[offset+i],i+=d,nBits-=8);for(m=e&(1<<-nBits)-1,e>>=-nBits,nBits+=mLen;nBits>0;m=256*m+buffer[offset+i],i+=d,nBits-=8);if(0===e)e=1-eBias;else{if(e===eMax)return m?NaN:1/0*(s?-1:1);m+=Math.pow(2,mLen),e-=eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)},exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=8*nBytes-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,rt=23===mLen?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=value<0||0===value&&1/value<0?1:0;for(value=Math.abs(value),isNaN(value)||value===1/0?(m=isNaN(value)?1:0,e=eMax):(e=Math.floor(Math.log(value)/Math.LN2),value*(c=Math.pow(2,-e))<1&&(e--,c*=2),(value+=e+eBias>=1?rt/c:rt*Math.pow(2,1-eBias))*c>=2&&(e++,c/=2),e+eBias>=eMax?(m=0,e=eMax):e+eBias>=1?(m=(value*c-1)*Math.pow(2,mLen),e+=eBias):(m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen),e=0));mLen>=8;buffer[offset+i]=255&m,i+=d,m/=256,mLen-=8);for(e=e<<mLen|m,eLen+=mLen;eLen>0;buffer[offset+i]=255&e,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=128*s}},{}],41:[function(require,module,exports){"function"==typeof Object.create?module.exports=function(ctor,superCtor){superCtor&&(ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}}))}:module.exports=function(ctor,superCtor){if(superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype,ctor.prototype=new TempCtor,ctor.prototype.constructor=ctor}}},{}],42:[function(require,module,exports){"use strict";const tspan=require("tspan"),circle="M 4,0 C 4,1.1 3.1,2 2,2 0.9,2 0,1.1 0,0 c 0,-1.1 0.9,-2 2,-2 1.1,0 2,0.9 2,2 z",buf1="M -11,-6 -11,6 0,0 z m -5,6 5,0",and2="m -16,-10 5,0 c 6,0 11,4 11,10 0,6 -5,10 -11,10 l -5,0 z",or2="m -18,-10 4,0 c 6,0 12,5 14,10 -2,5 -8,10 -14,10 l -4,0 c 2.5,-5 2.5,-15 0,-20 z",xor2="m -21,-10 c 1,3 2,6 2,10 m 0,0 c 0,4 -1,7 -2,10 m 3,-20 4,0 c 6,0 12,5 14,10 -2,5 -8,10 -14,10 l -4,0 c 1,-3 2,-6 2,-10 0,-4 -1,-7 -2,-10 z",circle2="c 0,4.418278 -3.581722,8 -8,8 -4.418278,0 -8,-3.581722 -8,-8 0,-4.418278 3.581722,-8 8,-8 4.418278,0 8,3.581722 8,8 z",gates={"=":buf1,"~":buf1+circle,"&":and2,"~&":and2+circle,"|":or2,"~|":or2+circle,"^":xor2,"~^":xor2+circle,"+":"m -8,5 0,-10 m -5,5 10,0 m 3,0"+circle2,"*":"m -4,4 -8,-8 m 0,8 8,-8 m 4,4"+circle2,"-":"m -3,0 -10,0 m 13,0"+circle2},aliasGates={add:"+",mul:"*",sub:"-",and:"&",or:"|",xor:"^",andr:"&",orr:"|",xorr:"^",input:"="};Object.keys(aliasGates).reduce(((res,key)=>(res[key]=gates[aliasGates[key]],res)),gates);const gater1_is=type=>void 0!==gates[type],gater1_render=type=>["path",{class:"gate",d:gates[type]}],iec={eq:"==",ne:"!=",slt:"<",sle:"<=",sgt:">",sge:">=",ult:"<",ule:"<=",ugt:">",uge:">=",BUF:1,INV:1,AND:"&",NAND:"&",OR:"≥1",NOR:"≥1",XOR:"=1",XNOR:"=1",box:"",MUX:"M"},circled={INV:1,NAND:1,NOR:1,XNOR:1},gater2_is=type=>void 0!==iec[type],gater2_render=(type,ymin,ymax)=>(ymin===ymax&&(ymin=-4,ymax=4),["g",["path",{class:"gate",d:"m -16,"+(ymin-3)+" 16,0 0,"+(ymax-ymin+6)+" -16,0 z"+(circled[type]?circle:"")}],["text",{x:-14,y:4,class:"wirename"}].concat(tspan.parse(iec[type]))]);module.exports=function(type,ymin,ymax){return gater1_is(type)?gater1_render(type):gater2_is(type)?gater2_render(type,ymin,ymax):["text",{x:-14,y:4,class:"wirename"}].concat(tspan.parse(type))}},{tspan:74}],43:[function(require,module,exports){"use strict";const tspan=require("tspan"),drawGate=require("./draw_gate.js");module.exports=function drawBoxes(tree,xmax){const ret=["g"],spec=[];if(Array.isArray(tree)){spec.push(tree[0].name),spec.push([32*(xmax-tree[0].x),8*tree[0].y]);for(let i=1;i<tree.length;i++){const branch=tree[i];Array.isArray(branch)?spec.push([32*(xmax-branch[0].x),8*branch[0].y]):spec.push([32*(xmax-branch.x),8*branch.y])}ret.push(drawGate(spec));for(let i=1;i<tree.length;i++){const branch=tree[i];ret.push(drawBoxes(branch,xmax))}return ret}const fname=tree.name,fx=32*(xmax-tree.x),fy=8*tree.y;return ret.push(["g",{transform:"translate("+fx+","+fy+")"},["title"].concat(tspan.parse(fname)),["path",{d:"M 2,0 a 2,2 0 1 1 -4,0 2,2 0 1 1 4,0 z"}],["text",{x:-4,y:4,class:"pinname"}].concat(tspan.parse(fname))]),ret}},{"./draw_gate.js":44,tspan:74}],44:[function(require,module,exports){"use strict";const tspan=require("tspan"),drawBody=require("./draw_body.js");module.exports=function(spec){const ilen=spec.length,ys=[];for(let i=2;i<ilen;i++)ys.push(spec[i][1]);const ret=["g"],ymin=Math.min.apply(null,ys),ymax=Math.max.apply(null,ys);ret.push(["g",{transform:"translate(16,0)"},["path",{d:"M"+spec[2][0]+","+ymin+" "+spec[2][0]+","+ymax,class:"wire"}]]);for(let i=2;i<ilen;i++)ret.push(["g",["path",{d:"m"+spec[i][0]+","+spec[i][1]+" 16,0",class:"wire"}]]);return ret.push(["g",{transform:"translate("+spec[1][0]+","+spec[1][1]+")"},["title"].concat(tspan.parse(spec[0])),drawBody(spec[0],ymin-spec[1][1],ymax-spec[1][1])]),ret}},{"./draw_body.js":42,tspan:74}],45:[function(require,module,exports){"use strict";module.exports=function(){return["style",".pinname {font-size:12px; font-style:normal; font-variant:normal; font-weight:500; font-stretch:normal; text-align:center; text-anchor:end; font-family:Helvetica} .wirename {font-size:12px; font-style:normal; font-variant:normal; font-weight:500; font-stretch:normal; text-align:center; text-anchor:start; font-family:Helvetica} .wirename:hover {fill:blue} .gate {color:#000; fill:#ffc; fill-opacity: 1;stroke:#000; stroke-width:1; stroke-opacity:1} .gate:hover {fill:red !important; } .wire {fill:none; stroke:#000; stroke-width:1; stroke-opacity:1} .grid {fill:#fff; fill-opacity:1; stroke:none}"]}},{}],46:[function(require,module,exports){"use strict";const render=require("./render.js"),drawBoxes=require("./draw_boxes.js"),insertSVGTemplateAssign=require("./insert-svg-template-assign.js");module.exports=function(index,source){let state={x:0,y:2,xmax:0};const tree=source.assign,ilen=tree.length;for(let i=0;i<ilen;i++)state=render(tree[i],state),state.x++;const xmax=state.xmax+3,svg=["g"];for(let i=0;i<ilen;i++)svg.push(drawBoxes(tree[i],xmax));const width=32*(xmax+1)+1,height=8*(state.y+1)-7;return["svg",{id:"svgcontent_"+index,viewBox:"0 0 "+width+" "+height,width:width,height:height},insertSVGTemplateAssign(),["g",{transform:"translate(0.5, 0.5)"},svg]]}},{"./draw_boxes.js":43,"./insert-svg-template-assign.js":45,"./render.js":47}],47:[function(require,module,exports){"use strict";module.exports=function render(tree,state){state.xmax=Math.max(state.xmax,state.x);const y=state.y,ilen=tree.length;for(let i=1;i<ilen;i++){const branch=tree[i];Array.isArray(branch)?state=render(branch,{x:state.x+1,y:state.y,xmax:state.xmax}):(tree[i]={name:branch,x:state.x+1,y:state.y},state.y+=2)}return tree[0]={name:tree[0],x:state.x,y:Math.round((y+(state.y-2))/2)},state.x--,state}},{}],48:[function(require,module,exports){"use strict";const w3_svg="http://www.w3.org/2000/svg",w3_xlink="http://www.w3.org/1999/xlink";module.exports=(w,h)=>["svg",{xmlns:w3_svg,"xmlns:xlink":w3_xlink,width:w,height:h,viewBox:"0 0 "+w+" "+h}]},{}],49:[function(require,module,exports){"use strict";const parse=require("./parse.js"),stringify=require("./stringify.js"),traverse=require("./traverse.js"),renderer=require("./renderer.js"),tt=require("./tt.js"),genSvg=require("./gen-svg.js");exports.renderer=renderer,exports.parse=parse,exports.stringify=stringify,exports.traverse=traverse,exports.tt=tt,exports.gen={svg:genSvg},exports.p=parse,exports.s=stringify,exports.t=traverse},{"./gen-svg.js":48,"./parse.js":50,"./renderer.js":51,"./stringify.js":52,"./traverse.js":53,"./tt.js":54}],50:[function(require,module,exports){"use strict";const parser=require("sax").parser;module.exports=function(data,config){const res=[],stack=[];let pointer=res,trim=!0,strict=!0;config&&void 0!==config.strict&&(strict=config.strict),void 0!==config&&void 0!==config.trim&&(trim=config.trim);const p=parser(strict);return p.ontext=function(e){!1!==trim&&""===e.trim()||pointer.push(e)},p.onopentag=function(e){const leaf=[e.name,e.attributes];stack.push(pointer),pointer.push(leaf),pointer=leaf},p.onclosetag=function(){pointer=stack.pop()},p.oncdata=function(e){!1!==trim&&""===e.trim()||pointer.push("<![CDATA["+e+"]]>")},p.write(data).close(),res[0]}},{sax:57}],51:[function(require,module,exports){"use strict";const stringify=require("./stringify.js");module.exports=root=>{const content="string"==typeof root?document.getElementById(root):root;return ml=>{let str;try{str=stringify(ml),content.innerHTML=str}catch(err){console.log(ml)}}}},{"./stringify.js":52}],52:[function(require,module,exports){"use strict";module.exports=function(a,indentation){const cr=indentation>0?"\n":"",indent=function(indentation){if(!(indentation>0))return txt=>txt;var space=" ".repeat(indentation);return txt=>{if("string"!=typeof txt)return txt;const arr=txt.split("\n");return 1===arr.length?space+txt:arr.map((e=>""===e.trim()?e:space+e)).join("\n")}}(indentation);return function rec(a){let res,body="",isFlat=!0;return a.some(((e,i,arr)=>{if(0===i)return res="<"+e,1===arr.length;if(1===i){if((o=e)&&"[object Object]"===Object.prototype.toString.call(o))return Object.keys(e).map((key=>{let val=e[key];Array.isArray(val)&&(val=val.join(" ")),res+=" "+key+'="'+val+'"'})),2===arr.length||void(res+=">");res+=">"}var o;switch(typeof e){case"string":case"number":case"boolean":case"undefined":return void(body+=e+cr)}isFlat=!1,body+=rec(e)}))?res+"/>"+cr:isFlat?res+body.split("\n").filter((e=>""!==e.trim())).join("\n")+"</"+a[0]+">"+cr:res+cr+indent(body)+"</"+a[0]+">"+cr}(a)}},{}],53:[function(require,module,exports){"use strict";function skipFn(){this._skip=!0}function removeFn(){this._remove=!0}function nameFn(name){this._name=name}function replaceFn(node){this._replace=node}module.exports=function(origin,callbacks){const empty=function(){},enter=callbacks&&callbacks.enter||empty,leave=callbacks&&callbacks.leave||empty;!function rec(tree,parent){if(void 0===tree)return;if(null===tree)return;if(!0===tree)return;if(!1===tree)return;const node={attr:{},full:tree},cxt={name:nameFn,skip:skipFn,remove:removeFn,replace:replaceFn,_name:void 0,_skip:!1,_remove:!1,_replace:void 0};let e1IsNotAnObject=!0;switch(Object.prototype.toString.call(tree)){case"[object String]":case"[object Number]":return;case"[object Array]":if(tree.some((function(e,i){return 0===i?(node.name=e,!1):1===i?("[object Object]"===Object.prototype.toString.call(e)&&(e1IsNotAnObject=!1,node.attr=e),!0):void 0})),enter.call(cxt,node,parent),cxt._name&&(tree[0]=cxt._name),cxt._replace)return cxt._replace;if(cxt._remove)return null;if(!cxt._skip){let index=0,ilen=tree.length;for(;index<ilen;){if(index>1||1===index&&e1IsNotAnObject){const returnRes=rec(tree[index],node);if(null===returnRes){tree.splice(index,1),ilen-=1;continue}returnRes&&(tree[index]=returnRes)}index+=1}if(leave.call(cxt,node,parent),cxt._name&&(tree[0]=cxt._name),cxt._replace)return cxt._replace;if(cxt._remove)return null}}}(origin,void 0)}},{}],54:[function(require,module,exports){"use strict";module.exports=(x,y,obj)=>{let objt={};if(x||y){objt={transform:"translate("+[x||0].concat(y?[y]:[]).join(",")+")"}}return obj="object"==typeof obj?obj:{},Object.assign(objt,obj)}},{}],55:[function(require,module,exports){var cachedSetTimeout,cachedClearTimeout,process=module.exports={};function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(fun){if(cachedSetTimeout===setTimeout)return setTimeout(fun,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(fun,0);try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}!function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}}();var currentQueue,queue=[],draining=!1,queueIndex=-1;function cleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var timeout=runTimeout(cleanUpNextTick);draining=!0;for(var len=queue.length;len;){for(currentQueue=queue,queue=[];++queueIndex<len;)currentQueue&¤tQueue[queueIndex].run();queueIndex=-1,len=queue.length}currentQueue=null,draining=!1,function(marker){if(cachedClearTimeout===clearTimeout)return clearTimeout(marker);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(marker);try{cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}(timeout)}}function Item(fun,array){this.fun=fun,this.array=array}function noop(){}process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)args[i-1]=arguments[i];queue.push(new Item(fun,args)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.prependListener=noop,process.prependOnceListener=noop,process.listeners=function(name){return[]},process.binding=function(name){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(dir){throw new Error("process.chdir is not supported")},process.umask=function(){return 0}},{}],56:[function(require,module,exports){
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
var buffer=require("buffer"),Buffer=buffer.Buffer;function copyProps(src,dst){for(var key in src)dst[key]=src[key]}function SafeBuffer(arg,encodingOrOffset,length){return Buffer(arg,encodingOrOffset,length)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?module.exports=buffer:(copyProps(buffer,exports),exports.Buffer=SafeBuffer),SafeBuffer.prototype=Object.create(Buffer.prototype),copyProps(Buffer,SafeBuffer),SafeBuffer.from=function(arg,encodingOrOffset,length){if("number"==typeof arg)throw new TypeError("Argument must not be a number");return Buffer(arg,encodingOrOffset,length)},SafeBuffer.alloc=function(size,fill,encoding){if("number"!=typeof size)throw new TypeError("Argument must be a number");var buf=Buffer(size);return void 0!==fill?"string"==typeof encoding?buf.fill(fill,encoding):buf.fill(fill):buf.fill(0),buf},SafeBuffer.allocUnsafe=function(size){if("number"!=typeof size)throw new TypeError("Argument must be a number");return Buffer(size)},SafeBuffer.allocUnsafeSlow=function(size){if("number"!=typeof size)throw new TypeError("Argument must be a number");return buffer.SlowBuffer(size)}},{buffer:38}],57:[function(require,module,exports){(function(Buffer){(function(){!function(sax){sax.parser=function(strict,opt){return new SAXParser(strict,opt)},sax.SAXParser=SAXParser,sax.SAXStream=SAXStream,sax.createStream=function(strict,opt){return new SAXStream(strict,opt)},sax.MAX_BUFFER_LENGTH=65536;var Stream,buffers=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];function SAXParser(strict,opt){if(!(this instanceof SAXParser))return new SAXParser(strict,opt);!function(parser){for(var i=0,l=buffers.length;i<l;i++)parser[buffers[i]]=""}(this),this.q=this.c="",this.bufferCheckPosition=sax.MAX_BUFFER_LENGTH,this.opt=opt||{},this.opt.lowercase=this.opt.lowercase||this.opt.lowercasetags,this.looseCase=this.opt.lowercase?"toLowerCase":"toUpperCase",this.tags=[],this.closed=this.closedRoot=this.sawRoot=!1,this.tag=this.error=null,this.strict=!!strict,this.noscript=!(!strict&&!this.opt.noscript),this.state=S.BEGIN,this.strictEntities=this.opt.strictEntities,this.ENTITIES=this.strictEntities?Object.create(sax.XML_ENTITIES):Object.create(sax.ENTITIES),this.attribList=[],this.opt.xmlns&&(this.ns=Object.create(rootNS)),this.trackPosition=!1!==this.opt.position,this.trackPosition&&(this.position=this.line=this.column=0),emit(this,"onready")}sax.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Object.create||(Object.create=function(o){function F(){}return F.prototype=o,new F}),Object.keys||(Object.keys=function(o){var a=[];for(var i in o)o.hasOwnProperty(i)&&a.push(i);return a}),SAXParser.prototype={end:function(){end(this)},write:function(chunk){if(this.error)throw this.error;if(this.closed)return error(this,"Cannot write after close. Assign an onready handler.");if(null===chunk)return end(this);"object"==typeof chunk&&(chunk=chunk.toString());var i=0,c="";for(;c=charAt(chunk,i++),this.c=c,c;)switch(this.trackPosition&&(this.position++,"\n"===c?(this.line++,this.column=0):this.column++),this.state){case S.BEGIN:if(this.state=S.BEGIN_WHITESPACE,"\ufeff"===c)continue;beginWhiteSpace(this,c);continue;case S.BEGIN_WHITESPACE:beginWhiteSpace(this,c);continue;case S.TEXT:if(this.sawRoot&&!this.closedRoot){for(var starti=i-1;c&&"<"!==c&&"&"!==c;)(c=charAt(chunk,i++))&&this.trackPosition&&(this.position++,"\n"===c?(this.line++,this.column=0):this.column++);this.textNode+=chunk.substring(starti,i-1)}"<"!==c||this.sawRoot&&this.closedRoot&&!this.strict?(isWhitespace(c)||this.sawRoot&&!this.closedRoot||strictFail(this,"Text data outside of root node."),"&"===c?this.state=S.TEXT_ENTITY:this.textNode+=c):(this.state=S.OPEN_WAKA,this.startTagPosition=this.position);continue;case S.SCRIPT:"<"===c?this.state=S.SCRIPT_ENDING:this.script+=c;continue;case S.SCRIPT_ENDING:"/"===c?this.state=S.CLOSE_TAG:(this.script+="<"+c,this.state=S.SCRIPT);continue;case S.OPEN_WAKA:if("!"===c)this.state=S.SGML_DECL,this.sgmlDecl="";else if(isWhitespace(c));else if(isMatch(nameStart,c))this.state=S.OPEN_TAG,this.tagName=c;else if("/"===c)this.state=S.CLOSE_TAG,this.tagName="";else if("?"===c)this.state=S.PROC_INST,this.procInstName=this.procInstBody="";else{if(strictFail(this,"Unencoded <"),this.startTagPosition+1<this.position){var pad=this.position-this.startTagPosition;c=new Array(pad).join(" ")+c}this.textNode+="<"+c,this.state=S.TEXT}continue;case S.SGML_DECL:"[CDATA["===(this.sgmlDecl+c).toUpperCase()?(emitNode(this,"onopencdata"),this.state=S.CDATA,this.sgmlDecl="",this.cdata=""):this.sgmlDecl+c==="--"?(this.state=S.COMMENT,this.comment="",this.sgmlDecl=""):"DOCTYPE"===(this.sgmlDecl+c).toUpperCase()?(this.state=S.DOCTYPE,(this.doctype||this.sawRoot)&&strictFail(this,"Inappropriately located doctype declaration"),this.doctype="",this.sgmlDecl=""):">"===c?(emitNode(this,"onsgmldeclaration",this.sgmlDecl),this.sgmlDecl="",this.state=S.TEXT):isQuote(c)?(this.state=S.SGML_DECL_QUOTED,this.sgmlDecl+=c):this.sgmlDecl+=c;continue;case S.SGML_DECL_QUOTED:c===this.q&&(this.state=S.SGML_DECL,this.q=""),this.sgmlDecl+=c;continue;case S.DOCTYPE:">"===c?(this.state=S.TEXT,emitNode(this,"ondoctype",this.doctype),this.doctype=!0):(this.doctype+=c,"["===c?this.state=S.DOCTYPE_DTD:isQuote(c)&&(this.state=S.DOCTYPE_QUOTED,this.q=c));continue;case S.DOCTYPE_QUOTED:this.doctype+=c,c===this.q&&(this.q="",this.state=S.DOCTYPE);continue;case S.DOCTYPE_DTD:this.doctype+=c,"]"===c?this.state=S.DOCTYPE:isQuote(c)&&(this.state=S.DOCTYPE_DTD_QUOTED,this.q=c);continue;case S.DOCTYPE_DTD_QUOTED:this.doctype+=c,c===this.q&&(this.state=S.DOCTYPE_DTD,this.q="");continue;case S.COMMENT:"-"===c?this.state=S.COMMENT_ENDING:this.comment+=c;continue;case S.COMMENT_ENDING:"-"===c?(this.state=S.COMMENT_ENDED,this.comment=textopts(this.opt,this.comment),this.comment&&emitNode(this,"oncomment",this.comment),this.comment=""):(this.comment+="-"+c,this.state=S.COMMENT);continue;case S.COMMENT_ENDED:">"!==c?(strictFail(this,"Malformed comment"),this.comment+="--"+c,this.state=S.COMMENT):this.state=S.TEXT;continue;case S.CDATA:"]"===c?this.state=S.CDATA_ENDING:this.cdata+=c;continue;case S.CDATA_ENDING:"]"===c?this.state=S.CDATA_ENDING_2:(this.cdata+="]"+c,this.state=S.CDATA);continue;case S.CDATA_ENDING_2:">"===c?(this.cdata&&emitNode(this,"oncdata",this.cdata),emitNode(this,"onclosecdata"),this.cdata="",this.state=S.TEXT):"]"===c?this.cdata+="]":(this.cdata+="]]"+c,this.state=S.CDATA);continue;case S.PROC_INST:"?"===c?this.state=S.PROC_INST_ENDING:isWhitespace(c)?this.state=S.PROC_INST_BODY:this.procInstName+=c;continue;case S.PROC_INST_BODY:if(!this.procInstBody&&isWhitespace(c))continue;"?"===c?this.state=S.PROC_INST_ENDING:this.procInstBody+=c;continue;case S.PROC_INST_ENDING:">"===c?(emitNode(this,"onprocessinginstruction",{name:this.procInstName,body:this.procInstBody}),this.procInstName=this.procInstBody="",this.state=S.TEXT):(this.procInstBody+="?"+c,this.state=S.PROC_INST_BODY);continue;case S.OPEN_TAG:isMatch(nameBody,c)?this.tagName+=c:(newTag(this),">"===c?openTag(this):"/"===c?this.state=S.OPEN_TAG_SLASH:(isWhitespace(c)||strictFail(this,"Invalid character in tag name"),this.state=S.ATTRIB));continue;case S.OPEN_TAG_SLASH:">"===c?(openTag(this,!0),closeTag(this)):(strictFail(this,"Forward-slash in opening tag not followed by >"),this.state=S.ATTRIB);continue;case S.ATTRIB:if(isWhitespace(c))continue;">"===c?openTag(this):"/"===c?this.state=S.OPEN_TAG_SLASH:isMatch(nameStart,c)?(this.attribName=c,this.attribValue="",this.state=S.ATTRIB_NAME):strictFail(this,"Invalid attribute name");continue;case S.ATTRIB_NAME:"="===c?this.state=S.ATTRIB_VALUE:">"===c?(strictFail(this,"Attribute without value"),this.attribValue=this.attribName,attrib(this),openTag(this)):isWhitespace(c)?this.state=S.ATTRIB_NAME_SAW_WHITE:isMatch(nameBody,c)?this.attribName+=c:strictFail(this,"Invalid attribute name");continue;case S.ATTRIB_NAME_SAW_WHITE:if("="===c)this.state=S.ATTRIB_VALUE;else{if(isWhitespace(c))continue;strictFail(this,"Attribute without value"),this.tag.attributes[this.attribName]="",this.attribValue="",emitNode(this,"onattribute",{name:this.attribName,value:""}),this.attribName="",">"===c?openTag(this):isMatch(nameStart,c)?(this.attribName=c,this.state=S.ATTRIB_NAME):(strictFail(this,"Invalid attribute name"),this.state=S.ATTRIB)}continue;case S.ATTRIB_VALUE:if(isWhitespace(c))continue;isQuote(c)?(this.q=c,this.state=S.ATTRIB_VALUE_QUOTED):(strictFail(this,"Unquoted attribute value"),this.state=S.ATTRIB_VALUE_UNQUOTED,this.attribValue=c);continue;case S.ATTRIB_VALUE_QUOTED:if(c!==this.q){"&"===c?this.state=S.ATTRIB_VALUE_ENTITY_Q:this.attribValue+=c;continue}attrib(this),this.q="",this.state=S.ATTRIB_VALUE_CLOSED;continue;case S.ATTRIB_VALUE_CLOSED:isWhitespace(c)?this.state=S.ATTRIB:">"===c?openTag(this):"/"===c?this.state=S.OPEN_TAG_SLASH:isMatch(nameStart,c)?(strictFail(this,"No whitespace between attributes"),this.attribName=c,this.attribValue="",this.state=S.ATTRIB_NAME):strictFail(this,"Invalid attribute name");continue;case S.ATTRIB_VALUE_UNQUOTED:if(!isAttribEnd(c)){"&"===c?this.state=S.ATTRIB_VALUE_ENTITY_U:this.attribValue+=c;continue}attrib(this),">"===c?openTag(this):this.state=S.ATTRIB;continue;case S.CLOSE_TAG:if(this.tagName)">"===c?closeTag(this):isMatch(nameBody,c)?this.tagName+=c:this.script?(this.script+="</"+this.tagName,this.tagName="",this.state=S.SCRIPT):(isWhitespace(c)||strictFail(this,"Invalid tagname in closing tag"),this.state=S.CLOSE_TAG_SAW_WHITE);else{if(isWhitespace(c))continue;notMatch(nameStart,c)?this.script?(this.script+="</"+c,this.state=S.SCRIPT):strictFail(this,"Invalid tagname in closing tag."):this.tagName=c}continue;case S.CLOSE_TAG_SAW_WHITE:if(isWhitespace(c))continue;">"===c?closeTag(this):strictFail(this,"Invalid characters in closing tag");continue;case S.TEXT_ENTITY:case S.ATTRIB_VALUE_ENTITY_Q:case S.ATTRIB_VALUE_ENTITY_U:var returnState,buffer;switch(this.state){case S.TEXT_ENTITY:returnState=S.TEXT,buffer="textNode";break;case S.ATTRIB_VALUE_ENTITY_Q:returnState=S.ATTRIB_VALUE_QUOTED,buffer="attribValue";break;case S.ATTRIB_VALUE_ENTITY_U:returnState=S.ATTRIB_VALUE_UNQUOTED,buffer="attribValue"}";"===c?(this[buffer]+=parseEntity(this),this.entity="",this.state=returnState):isMatch(this.entity.length?entityBody:entityStart,c)?this.entity+=c:(strictFail(this,"Invalid character in entity name"),this[buffer]+="&"+this.entity+c,this.entity="",this.state=returnState);continue;default:throw new Error(this,"Unknown state: "+this.state)}this.position>=this.bufferCheckPosition&&function(parser){for(var maxAllowed=Math.max(sax.MAX_BUFFER_LENGTH,10),maxActual=0,i=0,l=buffers.length;i<l;i++){var len=parser[buffers[i]].length;if(len>maxAllowed)switch(buffers[i]){case"textNode":closeText(parser);break;case"cdata":emitNode(parser,"oncdata",parser.cdata),parser.cdata="";break;case"script":emitNode(parser,"onscript",parser.script),parser.script="";break;default:error(parser,"Max buffer length exceeded: "+buffers[i])}maxActual=Math.max(maxActual,len)}var m=sax.MAX_BUFFER_LENGTH-maxActual;parser.bufferCheckPosition=m+parser.position}(this);return this}
/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){var parser;closeText(parser=this),""!==parser.cdata&&(emitNode(parser,"oncdata",parser.cdata),parser.cdata=""),""!==parser.script&&(emitNode(parser,"onscript",parser.script),parser.script="")}};try{Stream=require("stream").Stream}catch(ex){Stream=function(){}}var streamWraps=sax.EVENTS.filter((function(ev){return"error"!==ev&&"end"!==ev}));function SAXStream(strict,opt){if(!(this instanceof SAXStream))return new SAXStream(strict,opt);Stream.apply(this),this._parser=new SAXParser(strict,opt),this.writable=!0,this.readable=!0;var me=this;this._parser.onend=function(){me.emit("end")},this._parser.onerror=function(er){me.emit("error",er),me._parser.error=null},this._decoder=null,streamWraps.forEach((function(ev){Object.defineProperty(me,"on"+ev,{get:function(){return me._parser["on"+ev]},set:function(h){if(!h)return me.removeAllListeners(ev),me._parser["on"+ev]=h,h;me.on(ev,h)},enumerable:!0,configurable:!1})}))}SAXStream.prototype=Object.create(Stream.prototype,{constructor:{value:SAXStream}}),SAXStream.prototype.write=function(data){if("function"==typeof Buffer&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(data)){if(!this._decoder){var SD=require("string_decoder").StringDecoder;this._decoder=new SD("utf8")}data=this._decoder.write(data)}return this._parser.write(data.toString()),this.emit("data",data),!0},SAXStream.prototype.end=function(chunk){return chunk&&chunk.length&&this.write(chunk),this._parser.end(),!0},SAXStream.prototype.on=function(ev,handler){var me=this;return me._parser["on"+ev]||-1===streamWraps.indexOf(ev)||(me._parser["on"+ev]=function(){var args=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);args.splice(0,0,ev),me.emit.apply(me,args)}),Stream.prototype.on.call(me,ev,handler)};var XML_NAMESPACE="http://www.w3.org/XML/1998/namespace",rootNS={xml:XML_NAMESPACE,xmlns:"http://www.w3.org/2000/xmlns/"},nameStart=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,nameBody=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,entityStart=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,entityBody=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function isWhitespace(c){return" "===c||"\n"===c||"\r"===c||"\t"===c}function isQuote(c){return'"'===c||"'"===c}function isAttribEnd(c){return">"===c||isWhitespace(c)}function isMatch(regex,c){return regex.test(c)}function notMatch(regex,c){return!isMatch(regex,c)}var stringFromCharCode,floor,fromCodePoint,S=0;for(var s in sax.STATE={BEGIN:S++,BEGIN_WHITESPACE:S++,TEXT:S++,TEXT_ENTITY:S++,OPEN_WAKA:S++,SGML_DECL:S++,SGML_DECL_QUOTED:S++,DOCTYPE:S++,DOCTYPE_QUOTED:S++,DOCTYPE_DTD:S++,DOCTYPE_DTD_QUOTED:S++,COMMENT_STARTING:S++,COMMENT:S++,COMMENT_ENDING:S++,COMMENT_ENDED:S++,CDATA:S++,CDATA_ENDING:S++,CDATA_ENDING_2:S++,PROC_INST:S++,PROC_INST_BODY:S++,PROC_INST_ENDING:S++,OPEN_TAG:S++,OPEN_TAG_SLASH:S++,ATTRIB:S++,ATTRIB_NAME:S++,ATTRIB_NAME_SAW_WHITE:S++,ATTRIB_VALUE:S++,ATTRIB_VALUE_QUOTED:S++,ATTRIB_VALUE_CLOSED:S++,ATTRIB_VALUE_UNQUOTED:S++,ATTRIB_VALUE_ENTITY_Q:S++,ATTRIB_VALUE_ENTITY_U:S++,CLOSE_TAG:S++,CLOSE_TAG_SAW_WHITE:S++,SCRIPT:S++,SCRIPT_ENDING:S++},sax.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},sax.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(sax.ENTITIES).forEach((function(key){var e=sax.ENTITIES[key],s="number"==typeof e?String.fromCharCode(e):e;sax.ENTITIES[key]=s})),sax.STATE)sax.STATE[sax.STATE[s]]=s;function emit(parser,event,data){parser[event]&&parser[event](data)}function emitNode(parser,nodeType,data){parser.textNode&&closeText(parser),emit(parser,nodeType,data)}function closeText(parser){parser.textNode=textopts(parser.opt,parser.textNode),parser.textNode&&emit(parser,"ontext",parser.textNode),parser.textNode=""}function textopts(opt,text){return opt.trim&&(text=text.trim()),opt.normalize&&(text=text.replace(/\s+/g," ")),text}function error(parser,er){return closeText(parser),parser.trackPosition&&(er+="\nLine: "+parser.line+"\nColumn: "+parser.column+"\nChar: "+parser.c),er=new Error(er),parser.error=er,emit(parser,"onerror",er),parser}function end(parser){return parser.sawRoot&&!parser.closedRoot&&strictFail(parser,"Unclosed root tag"),parser.state!==S.BEGIN&&parser.state!==S.BEGIN_WHITESPACE&&parser.state!==S.TEXT&&error(parser,"Unexpected end"),closeText(parser),parser.c="",parser.closed=!0,emit(parser,"onend"),SAXParser.call(parser,parser.strict,parser.opt),parser}function strictFail(parser,message){if("object"!=typeof parser||!(parser instanceof SAXParser))throw new Error("bad call to strictFail");parser.strict&&error(parser,message)}function newTag(parser){parser.strict||(parser.tagName=parser.tagName[parser.looseCase]());var parent=parser.tags[parser.tags.length-1]||parser,tag=parser.tag={name:parser.tagName,attributes:{}};parser.opt.xmlns&&(tag.ns=parent.ns),parser.attribList.length=0,emitNode(parser,"onopentagstart",tag)}function qname(name,attribute){var qualName=name.indexOf(":")<0?["",name]:name.split(":"),prefix=qualName[0],local=qualName[1];return attribute&&"xmlns"===name&&(prefix="xmlns",local=""),{prefix:prefix,local:local}}function attrib(parser){if(parser.strict||(parser.attribName=parser.attribName[parser.looseCase]()),-1!==parser.attribList.indexOf(parser.attribName)||parser.tag.attributes.hasOwnProperty(parser.attribName))parser.attribName=parser.attribValue="";else{if(parser.opt.xmlns){var qn=qname(parser.attribName,!0),prefix=qn.prefix,local=qn.local;if("xmlns"===prefix)if("xml"===local&&parser.attribValue!==XML_NAMESPACE)strictFail(parser,"xml: prefix must be bound to "+XML_NAMESPACE+"\nActual: "+parser.attribValue);else if("xmlns"===local&&"http://www.w3.org/2000/xmlns/"!==parser.attribValue)strictFail(parser,"xmlns: prefix must be bound to http://www.w3.org/2000/xmlns/\nActual: "+parser.attribValue);else{var tag=parser.tag,parent=parser.tags[parser.tags.length-1]||parser;tag.ns===parent.ns&&(tag.ns=Object.create(parent.ns)),tag.ns[local]=parser.attribValue}parser.attribList.push([parser.attribName,parser.attribValue])}else parser.tag.attributes[parser.attribName]=parser.attribValue,emitNode(parser,"onattribute",{name:parser.attribName,value:parser.attribValue});parser.attribName=parser.attribValue=""}}function openTag(parser,selfClosing){if(parser.opt.xmlns){var tag=parser.tag,qn=qname(parser.tagName);tag.prefix=qn.prefix,tag.local=qn.local,tag.uri=tag.ns[qn.prefix]||"",tag.prefix&&!tag.uri&&(strictFail(parser,"Unbound namespace prefix: "+JSON.stringify(parser.tagName)),tag.uri=qn.prefix);var parent=parser.tags[parser.tags.length-1]||parser;tag.ns&&parent.ns!==tag.ns&&Object.keys(tag.ns).forEach((function(p){emitNode(parser,"onopennamespace",{prefix:p,uri:tag.ns[p]})}));for(var i=0,l=parser.attribList.length;i<l;i++){var nv=parser.attribList[i],name=nv[0],value=nv[1],qualName=qname(name,!0),prefix=qualName.prefix,local=qualName.local,uri=""===prefix?"":tag.ns[prefix]||"",a={name:name,value:value,prefix:prefix,local:local,uri:uri};prefix&&"xmlns"!==prefix&&!uri&&(strictFail(parser,"Unbound namespace prefix: "+JSON.stringify(prefix)),a.uri=prefix),parser.tag.attributes[name]=a,emitNode(parser,"onattribute",a)}parser.attribList.length=0}parser.tag.isSelfClosing=!!selfClosing,parser.sawRoot=!0,parser.tags.push(parser.tag),emitNode(parser,"onopentag",parser.tag),selfClosing||(parser.noscript||"script"!==parser.tagName.toLowerCase()?parser.state=S.TEXT:parser.state=S.SCRIPT,parser.tag=null,parser.tagName=""),parser.attribName=parser.attribValue="",parser.attribList.length=0}function closeTag(parser){if(!parser.tagName)return strictFail(parser,"Weird empty close tag."),parser.textNode+="</>",void(parser.state=S.TEXT);if(parser.script){if("script"!==parser.tagName)return parser.script+="</"+parser.tagName+">",parser.tagName="",void(parser.state=S.SCRIPT);emitNode(parser,"onscript",parser.script),parser.script=""}var t=parser.tags.length,tagName=parser.tagName;parser.strict||(tagName=tagName[parser.looseCase]());for(var closeTo=tagName;t--;){if(parser.tags[t].name===closeTo)break;strictFail(parser,"Unexpected close tag")}if(t<0)return strictFail(parser,"Unmatched closing tag: "+parser.tagName),parser.textNode+="</"+parser.tagName+">",void(parser.state=S.TEXT);parser.tagName=tagName;for(var s=parser.tags.length;s-- >t;){var tag=parser.tag=parser.tags.pop();parser.tagName=parser.tag.name,emitNode(parser,"onclosetag",parser.tagName);var x={};for(var i in tag.ns)x[i]=tag.ns[i];var parent=parser.tags[parser.tags.length-1]||parser;parser.opt.xmlns&&tag.ns!==parent.ns&&Object.keys(tag.ns).forEach((function(p){var n=tag.ns[p];emitNode(parser,"onclosenamespace",{prefix:p,uri:n})}))}0===t&&(parser.closedRoot=!0),parser.tagName=parser.attribValue=parser.attribName="",parser.attribList.length=0,parser.state=S.TEXT}function parseEntity(parser){var num,entity=parser.entity,entityLC=entity.toLowerCase(),numStr="";return parser.ENTITIES[entity]?parser.ENTITIES[entity]:parser.ENTITIES[entityLC]?parser.ENTITIES[entityLC]:("#"===(entity=entityLC).charAt(0)&&("x"===entity.charAt(1)?(entity=entity.slice(2),numStr=(num=parseInt(entity,16)).toString(16)):(entity=entity.slice(1),numStr=(num=parseInt(entity,10)).toString(10))),entity=entity.replace(/^0+/,""),isNaN(num)||numStr.toLowerCase()!==entity?(strictFail(parser,"Invalid character entity"),"&"+parser.entity+";"):String.fromCodePoint(num))}function beginWhiteSpace(parser,c){"<"===c?(parser.state=S.OPEN_WAKA,parser.startTagPosition=parser.position):isWhitespace(c)||(strictFail(parser,"Non-whitespace before first tag."),parser.textNode=c,parser.state=S.TEXT)}function charAt(chunk,i){var result="";return i<chunk.length&&(result=chunk.charAt(i)),result}S=sax.STATE,String.fromCodePoint||(stringFromCharCode=String.fromCharCode,floor=Math.floor,fromCodePoint=function(){var highSurrogate,lowSurrogate,MAX_SIZE=16384,codeUnits=[],index=-1,length=arguments.length;if(!length)return"";for(var result="";++index<length;){var codePoint=Number(arguments[index]);if(!isFinite(codePoint)||codePoint<0||codePoint>1114111||floor(codePoint)!==codePoint)throw RangeError("Invalid code point: "+codePoint);codePoint<=65535?codeUnits.push(codePoint):(highSurrogate=55296+((codePoint-=65536)>>10),lowSurrogate=codePoint%1024+56320,codeUnits.push(highSurrogate,lowSurrogate)),(index+1===length||codeUnits.length>MAX_SIZE)&&(result+=stringFromCharCode.apply(null,codeUnits),codeUnits.length=0)}return result},Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:fromCodePoint,configurable:!0,writable:!0}):String.fromCodePoint=fromCodePoint)}(void 0===exports?this.sax={}:exports)}).call(this)}).call(this,require("buffer").Buffer)},{buffer:38,stream:58,string_decoder:73}],58:[function(require,module,exports){module.exports=Stream;var EE=require("events").EventEmitter;function Stream(){EE.call(this)}require("inherits")(Stream,EE),Stream.Readable=require("readable-stream/lib/_stream_readable.js"),Stream.Writable=require("readable-stream/lib/_stream_writable.js"),Stream.Duplex=require("readable-stream/lib/_stream_duplex.js"),Stream.Transform=require("readable-stream/lib/_stream_transform.js"),Stream.PassThrough=require("readable-stream/lib/_stream_passthrough.js"),Stream.finished=require("readable-stream/lib/internal/streams/end-of-stream.js"),Stream.pipeline=require("readable-stream/lib/internal/streams/pipeline.js"),Stream.Stream=Stream,Stream.prototype.pipe=function(dest,options){var source=this;function ondata(chunk){dest.writable&&!1===dest.write(chunk)&&source.pause&&source.pause()}function ondrain(){source.readable&&source.resume&&source.resume()}source.on("data",ondata),dest.on("drain",ondrain),dest._isStdio||options&&!1===options.end||(source.on("end",onend),source.on("close",onclose));var didOnEnd=!1;function onend(){didOnEnd||(didOnEnd=!0,dest.end())}function onclose(){didOnEnd||(didOnEnd=!0,"function"==typeof dest.destroy&&dest.destroy())}function onerror(er){if(cleanup(),0===EE.listenerCount(this,"error"))throw er}function cleanup(){source.removeListener("data",ondata),dest.removeListener("drain",ondrain),source.removeListener("end",onend),source.removeListener("close",onclose),source.removeListener("error",onerror),dest.removeListener("error",onerror),source.removeListener("end",cleanup),source.removeListener("close",cleanup),dest.removeListener("close",cleanup)}return source.on("error",onerror),dest.on("error",onerror),source.on("end",cleanup),source.on("close",cleanup),dest.on("close",cleanup),dest.emit("pipe",source),dest}},{events:39,inherits:41,"readable-stream/lib/_stream_duplex.js":60,"readable-stream/lib/_stream_passthrough.js":61,"readable-stream/lib/_stream_readable.js":62,"readable-stream/lib/_stream_transform.js":63,"readable-stream/lib/_stream_writable.js":64,"readable-stream/lib/internal/streams/end-of-stream.js":68,"readable-stream/lib/internal/streams/pipeline.js":70}],59:[function(require,module,exports){"use strict";var codes={};function createErrorType(code,message,Base){Base||(Base=Error);var NodeError=function(_Base){var subClass,superClass;function NodeError(arg1,arg2,arg3){return _Base.call(this,function(arg1,arg2,arg3){return"string"==typeof message?message:message(arg1,arg2,arg3)}(arg1,arg2,arg3))||this}return superClass=_Base,(subClass=NodeError).prototype=Object.create(superClass.prototype),subClass.prototype.constructor=subClass,subClass.__proto__=superClass,NodeError}(Base);NodeError.prototype.name=Base.name,NodeError.prototype.code=code,codes[code]=NodeError}function oneOf(expected,thing){if(Array.isArray(expected)){var len=expected.length;return expected=expected.map((function(i){return String(i)})),len>2?"one of ".concat(thing," ").concat(expected.slice(0,len-1).join(", "),", or ")+expected[len-1]:2===len?"one of ".concat(thing," ").concat(expected[0]," or ").concat(expected[1]):"of ".concat(thing," ").concat(expected[0])}return"of ".concat(thing," ").concat(String(expected))}createErrorType("ERR_INVALID_OPT_VALUE",(function(name,value){return'The value "'+value+'" is invalid for option "'+name+'"'}),TypeError),createErrorType("ERR_INVALID_ARG_TYPE",(function(name,expected,actual){var determiner,search,pos,msg;if("string"==typeof expected&&(search="not ",expected.substr(!pos||pos<0?0:+pos,search.length)===search)?(determiner="must not be",expected=expected.replace(/^not /,"")):determiner="must be",function(str,search,this_len){return(void 0===this_len||this_len>str.length)&&(this_len=str.length),str.substring(this_len-search.length,this_len)===search}(name," argument"))msg="The ".concat(name," ").concat(determiner," ").concat(oneOf(expected,"type"));else{var type=function(str,search,start){return"number"!=typeof start&&(start=0),!(start+search.length>str.length)&&-1!==str.indexOf(search,start)}(name,".")?"property":"argument";msg='The "'.concat(name,'" ').concat(type," ").concat(determiner," ").concat(oneOf(expected,"type"))}return msg+=". Received type ".concat(typeof actual)}),TypeError),createErrorType("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),createErrorType("ERR_METHOD_NOT_IMPLEMENTED",(function(name){return"The "+name+" method is not implemented"})),createErrorType("ERR_STREAM_PREMATURE_CLOSE","Premature close"),createErrorType("ERR_STREAM_DESTROYED",(function(name){return"Cannot call "+name+" after a stream was destroyed"})),createErrorType("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),createErrorType("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),createErrorType("ERR_STREAM_WRITE_AFTER_END","write after end"),createErrorType("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),createErrorType("ERR_UNKNOWN_ENCODING",(function(arg){return"Unknown encoding: "+arg}),TypeError),createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),module.exports.codes=codes},{}],60:[function(require,module,exports){(function(process){(function(){"use strict";var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj)keys.push(key);return keys};module.exports=Duplex;var Readable=require("./_stream_readable"),Writable=require("./_stream_writable");require("inherits")(Duplex,Readable);for(var keys=objectKeys(Writable.prototype),v=0;v<keys.length;v++){var method=keys[v];Duplex.prototype[method]||(Duplex.prototype[method]=Writable.prototype[method])}function Duplex(options){if(!(this instanceof Duplex))return new Duplex(options);Readable.call(this,options),Writable.call(this,options),this.allowHalfOpen=!0,options&&(!1===options.readable&&(this.readable=!1),!1===options.writable&&(this.writable=!1),!1===options.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",onend)))}function onend(){this._writableState.ended||process.nextTick(onEndNT,this)}function onEndNT(self){self.end()}Object.defineProperty(Duplex.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(Duplex.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(Duplex.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(Duplex.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(value){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=value,this._writableState.destroyed=value)}})}).call(this)}).call(this,require("_process"))},{"./_stream_readable":62,"./_stream_writable":64,_process:55,inherits:41}],61:[function(require,module,exports){"use strict";module.exports=PassThrough;var Transform=require("./_stream_transform");function PassThrough(options){if(!(this instanceof PassThrough))return new PassThrough(options);Transform.call(this,options)}require("inherits")(PassThrough,Transform),PassThrough.prototype._transform=function(chunk,encoding,cb){cb(null,chunk)}},{"./_stream_transform":63,inherits:41}],62:[function(require,module,exports){(function(process,global){(function(){"use strict";var Duplex;module.exports=Readable,Readable.ReadableState=ReadableState;require("events").EventEmitter;var EElistenerCount=function(emitter,type){return emitter.listeners(type).length},Stream=require("./internal/streams/stream"),Buffer=require("buffer").Buffer,OurUint8Array=global.Uint8Array||function(){};var debug,debugUtil=require("util");debug=debugUtil&&debugUtil.debuglog?debugUtil.debuglog("stream"):function(){};var StringDecoder,createReadableStreamAsyncIterator,from,BufferList=require("./internal/streams/buffer_list"),destroyImpl=require("./internal/streams/destroy"),getHighWaterMark=require("./internal/streams/state").getHighWaterMark,_require$codes=require("../errors").codes,ERR_INVALID_ARG_TYPE=_require$codes.ERR_INVALID_ARG_TYPE,ERR_STREAM_PUSH_AFTER_EOF=_require$codes.ERR_STREAM_PUSH_AFTER_EOF,ERR_METHOD_NOT_IMPLEMENTED=_require$codes.ERR_METHOD_NOT_IMPLEMENTED,ERR_STREAM_UNSHIFT_AFTER_END_EVENT=_require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;require("inherits")(Readable,Stream);var errorOrDestroy=destroyImpl.errorOrDestroy,kProxyEvents=["error","close","destroy","pause","resume"];function ReadableState(options,stream,isDuplex){Duplex=Duplex||require("./_stream_duplex"),options=options||{},"boolean"!=typeof isDuplex&&(isDuplex=stream instanceof Duplex),this.objectMode=!!options.objectMode,isDuplex&&(this.objectMode=this.objectMode||!!options.readableObjectMode),this.highWaterMark=getHighWaterMark(this,options,"readableHighWaterMark",isDuplex),this.buffer=new BufferList,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==options.emitClose,this.autoDestroy=!!options.autoDestroy,this.destroyed=!1,this.defaultEncoding=options.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,options.encoding&&(StringDecoder||(StringDecoder=require("string_decoder/").StringDecoder),this.decoder=new StringDecoder(options.encoding),this.encoding=options.encoding)}function Readable(options){if(Duplex=Duplex||require("./_stream_duplex"),!(this instanceof Readable))return new Readable(options);var isDuplex=this instanceof Duplex;this._readableState=new ReadableState(options,this,isDuplex),this.readable=!0,options&&("function"==typeof options.read&&(this._read=options.read),"function"==typeof options.destroy&&(this._destroy=options.destroy)),Stream.call(this)}function readableAddChunk(stream,chunk,encoding,addToFront,skipChunkCheck){debug("readableAddChunk",chunk);var er,state=stream._readableState;if(null===chunk)state.reading=!1,function(stream,state){if(debug("onEofChunk"),state.ended)return;if(state.decoder){var chunk=state.decoder.end();chunk&&chunk.length&&(state.buffer.push(chunk),state.length+=state.objectMode?1:chunk.length)}state.ended=!0,state.sync?emitReadable(stream):(state.needReadable=!1,state.emittedReadable||(state.emittedReadable=!0,emitReadable_(stream)))}(stream,state);else if(skipChunkCheck||(er=function(state,chunk){var er;obj=chunk,Buffer.isBuffer(obj)||obj instanceof OurUint8Array||"string"==typeof chunk||void 0===chunk||state.objectMode||(er=new ERR_INVALID_ARG_TYPE("chunk",["string","Buffer","Uint8Array"],chunk));var obj;return er}(state,chunk)),er)errorOrDestroy(stream,er);else if(state.objectMode||chunk&&chunk.length>0)if("string"==typeof chunk||state.objectMode||Object.getPrototypeOf(chunk)===Buffer.prototype||(chunk=function(chunk){return Buffer.from(chunk)}(chunk)),addToFront)state.endEmitted?errorOrDestroy(stream,new ERR_STREAM_UNSHIFT_AFTER_END_EVENT):addChunk(stream,state,chunk,!0);else if(state.ended)errorOrDestroy(stream,new ERR_STREAM_PUSH_AFTER_EOF);else{if(state.destroyed)return!1;state.reading=!1,state.decoder&&!encoding?(chunk=state.decoder.write(chunk),state.objectMode||0!==chunk.length?addChunk(stream,state,chunk,!1):maybeReadMore(stream,state)):addChunk(stream,state,chunk,!1)}else addToFront||(state.reading=!1,maybeReadMore(stream,state));return!state.ended&&(state.length<state.highWaterMark||0===state.length)}function addChunk(stream,state,chunk,addToFront){state.flowing&&0===state.length&&!state.sync?(state.awaitDrain=0,stream.emit("data",chunk)):(state.length+=state.objectMode?1:chunk.length,addToFront?state.buffer.unshift(chunk):state.buffer.push(chunk),state.needReadable&&emitReadable(stream)),maybeReadMore(stream,state)}Object.defineProperty(Readable.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(value){this._readableState&&(this._readableState.destroyed=value)}}),Readable.prototype.destroy=destroyImpl.destroy,Readable.prototype._undestroy=destroyImpl.undestroy,Readable.prototype._destroy=function(err,cb){cb(err)},Readable.prototype.push=function(chunk,encoding){var skipChunkCheck,state=this._readableState;return state.objectMode?skipChunkCheck=!0:"string"==typeof chunk&&((encoding=encoding||state.defaultEncoding)!==state.encoding&&(chunk=Buffer.from(chunk,encoding),encoding=""),skipChunkCheck=!0),readableAddChunk(this,chunk,encoding,!1,skipChunkCheck)},Readable.prototype.unshift=function(chunk){return readableAddChunk(this,chunk,null,!0,!1)},Readable.prototype.isPaused=function(){return!1===this._readableState.flowing},Readable.prototype.setEncoding=function(enc){StringDecoder||(StringDecoder=require("string_decoder/").StringDecoder);var decoder=new StringDecoder(enc);this._readableState.decoder=decoder,this._readableState.encoding=this._readableState.decoder.encoding;for(var p=this._readableState.buffer.head,content="";null!==p;)content+=decoder.write(p.data),p=p.next;return this._readableState.buffer.clear(),""!==content&&this._readableState.buffer.push(content),this._readableState.length=content.length,this};function howMuchToRead(n,state){return n<=0||0===state.length&&state.ended?0:state.objectMode?1:n!=n?state.flowing&&state.length?state.buffer.head.data.length:state.length:(n>state.highWaterMark&&(state.highWaterMark=function(n){return n>=1073741824?n=1073741824:(n--,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n++),n}(n)),n<=state.length?n:state.ended?state.length:(state.needReadable=!0,0))}function emitReadable(stream){var state=stream._readableState;debug("emitReadable",state.needReadable,state.emittedReadable),state.needReadable=!1,state.emittedReadable||(debug("emitReadable",state.flowing),state.emittedReadable=!0,process.nextTick(emitReadable_,stream))}function emitReadable_(stream){var state=stream._readableState;debug("emitReadable_",state.destroyed,state.length,state.ended),state.destroyed||!state.length&&!state.ended||(stream.emit("readable"),state.emittedReadable=!1),state.needReadable=!state.flowing&&!state.ended&&state.length<=state.highWaterMark,flow(stream)}function maybeReadMore(stream,state){state.readingMore||(state.readingMore=!0,process.nextTick(maybeReadMore_,stream,state))}function maybeReadMore_(stream,state){for(;!state.reading&&!state.ended&&(state.length<state.highWaterMark||state.flowing&&0===state.length);){var len=state.length;if(debug("maybeReadMore read 0"),stream.read(0),len===state.length)break}state.readingMore=!1}function updateReadableListening(self){var state=self._readableState;state.readableListening=self.listenerCount("readable")>0,state.resumeScheduled&&!state.paused?state.flowing=!0:self.listenerCount("data")>0&&self.resume()}function nReadingNextTick(self){debug("readable nexttick read 0"),self.read(0)}function resume_(stream,state){debug("resume",state.reading),state.reading||stream.read(0),state.resumeScheduled=!1,stream.emit("resume"),flow(stream),state.flowing&&!state.reading&&stream.read(0)}function flow(stream){var state=stream._readableState;for(debug("flow",state.flowing);state.flowing&&null!==stream.read(););}function fromList(n,state){return 0===state.length?null:(state.objectMode?ret=state.buffer.shift():!n||n>=state.length?(ret=state.decoder?state.buffer.join(""):1===state.buffer.length?state.buffer.first():state.buffer.concat(state.length),state.buffer.clear()):ret=state.buffer.consume(n,state.decoder),ret);var ret}function endReadable(stream){var state=stream._readableState;debug("endReadable",state.endEmitted),state.endEmitted||(state.ended=!0,process.nextTick(endReadableNT,state,stream))}function endReadableNT(state,stream){if(debug("endReadableNT",state.endEmitted,state.length),!state.endEmitted&&0===state.length&&(state.endEmitted=!0,stream.readable=!1,stream.emit("end"),state.autoDestroy)){var wState=stream._writableState;(!wState||wState.autoDestroy&&wState.finished)&&stream.destroy()}}function indexOf(xs,x){for(var i=0,l=xs.length;i<l;i++)if(xs[i]===x)return i;return-1}Readable.prototype.read=function(n){debug("read",n),n=parseInt(n,10);var state=this._readableState,nOrig=n;if(0!==n&&(state.emittedReadable=!1),0===n&&state.needReadable&&((0!==state.highWaterMark?state.length>=state.highWaterMark:state.length>0)||state.ended))return debug("read: emitReadable",state.length,state.ended),0===state.length&&state.ended?endReadable(this):emitReadable(this),null;if(0===(n=howMuchToRead(n,state))&&state.ended)return 0===state.length&&endReadable(this),null;var ret,doRead=state.needReadable;return debug("need readable",doRead),(0===state.length||state.length-n<state.highWaterMark)&&debug("length less than watermark",doRead=!0),state.ended||state.reading?debug("reading or ended",doRead=!1):doRead&&(debug("do read"),state.reading=!0,state.sync=!0,0===state.length&&(state.needReadable=!0),this._read(state.highWaterMark),state.sync=!1,state.reading||(n=howMuchToRead(nOrig,state))),null===(ret=n>0?fromList(n,state):null)?(state.needReadable=state.length<=state.highWaterMark,n=0):(state.length-=n,state.awaitDrain=0),0===state.length&&(state.ended||(state.needReadable=!0),nOrig!==n&&state.ended&&endReadable(this)),null!==ret&&this.emit("data",ret),ret},Readable.prototype._read=function(n){errorOrDestroy(this,new ERR_METHOD_NOT_IMPLEMENTED("_read()"))},Readable.prototype.pipe=function(dest,pipeOpts){var src=this,state=this._readableState;switch(state.pipesCount){case 0:state.pipes=dest;break;case 1:state.pipes=[state.pipes,dest];break;default:state.pipes.push(dest)}state.pipesCount+=1,debug("pipe count=%d opts=%j",state.pipesCount,pipeOpts);var endFn=(!pipeOpts||!1!==pipeOpts.end)&&dest!==process.stdout&&dest!==process.stderr?onend:unpipe;function onunpipe(readable,unpipeInfo){debug("onunpipe"),readable===src&&unpipeInfo&&!1===unpipeInfo.hasUnpiped&&(unpipeInfo.hasUnpiped=!0,debug("cleanup"),dest.removeListener("close",onclose),dest.removeListener("finish",onfinish),dest.removeListener("drain",ondrain),dest.removeListener("error",onerror),dest.removeListener("unpipe",onunpipe),src.removeListener("end",onend),src.removeListener("end",unpipe),src.removeListener("data",ondata),cleanedUp=!0,!state.awaitDrain||dest._writableState&&!dest._writableState.needDrain||ondrain())}function onend(){debug("onend"),dest.end()}state.endEmitted?process.nextTick(endFn):src.once("end",endFn),dest.on("unpipe",onunpipe);var ondrain=function(src){return function(){var state=src._readableState;debug("pipeOnDrain",state.awaitDrain),state.awaitDrain&&state.awaitDrain--,0===state.awaitDrain&&EElistenerCount(src,"data")&&(state.flowing=!0,flow(src))}}(src);dest.on("drain",ondrain);var cleanedUp=!1;function ondata(chunk){debug("ondata");var ret=dest.write(chunk);debug("dest.write",ret),!1===ret&&((1===state.pipesCount&&state.pipes===dest||state.pipesCount>1&&-1!==indexOf(state.pipes,dest))&&!cleanedUp&&(debug("false write response, pause",state.awaitDrain),state.awaitDrain++),src.pause())}function onerror(er){debug("onerror",er),unpipe(),dest.removeListener("error",onerror),0===EElistenerCount(dest,"error")&&errorOrDestroy(dest,er)}function onclose(){dest.removeListener("finish",onfinish),unpipe()}function onfinish(){debug("onfinish"),dest.removeListener("close",onclose),unpipe()}function unpipe(){debug("unpipe"),src.unpipe(dest)}return src.on("data",ondata),function(emitter,event,fn){if("function"==typeof emitter.prependListener)return emitter.prependListener(event,fn);emitter._events&&emitter._events[event]?Array.isArray(emitter._events[event])?emitter._events[event].unshift(fn):emitter._events[event]=[fn,emitter._events[event]]:emitter.on(event,fn)}(dest,"error",onerror),dest.once("close",onclose),dest.once("finish",onfinish),dest.emit("pipe",src),state.flowing||(debug("pipe resume"),src.resume()),dest},Readable.prototype.unpipe=function(dest){var state=this._readableState,unpipeInfo={hasUnpiped:!1};if(0===state.pipesCount)return this;if(1===state.pipesCount)return dest&&dest!==state.pipes||(dest||(dest=state.pipes),state.pipes=null,state.pipesCount=0,state.flowing=!1,dest&&dest.emit("unpipe",this,unpipeInfo)),this;if(!dest){var dests=state.pipes,len=state.pipesCount;state.pipes=null,state.pipesCount=0,state.flowing=!1;for(var i=0;i<len;i++)dests[i].emit("unpipe",this,{hasUnpiped:!1});return this}var index=indexOf(state.pipes,dest);return-1===index||(state.pipes.splice(index,1),state.pipesCount-=1,1===state.pipesCount&&(state.pipes=state.pipes[0]),dest.emit("unpipe",this,unpipeInfo)),this},Readable.prototype.on=function(ev,fn){var res=Stream.prototype.on.call(this,ev,fn),state=this._readableState;return"data"===ev?(state.readableListening=this.listenerCount("readable")>0,!1!==state.flowing&&this.resume()):"readable"===ev&&(state.endEmitted||state.readableListening||(state.readableListening=state.needReadable=!0,state.flowing=!1,state.emittedReadable=!1,debug("on readable",state.length,state.reading),state.length?emitReadable(this):state.reading||process.nextTick(nReadingNextTick,this))),res},Readable.prototype.addListener=Readable.prototype.on,Readable.prototype.removeListener=function(ev,fn){var res=Stream.prototype.removeListener.call(this,ev,fn);return"readable"===ev&&process.nextTick(updateReadableListening,this),res},Readable.prototype.removeAllListeners=function(ev){var res=Stream.prototype.removeAllListeners.apply(this,arguments);return"readable"!==ev&&void 0!==ev||process.nextTick(updateReadableListening,this),res},Readable.prototype.resume=function(){var state=this._readableState;return state.flowing||(debug("resume"),state.flowing=!state.readableListening,function(stream,state){state.resumeScheduled||(state.resumeScheduled=!0,process.nextTick(resume_,stream,state))}(this,state)),state.paused=!1,this},Readable.prototype.pause=function(){return debug("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(debug("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},Readable.prototype.wrap=function(stream){var _this=this,state=this._readableState,paused=!1;for(var i in stream.on("end",(function(){if(debug("wrapped end"),state.decoder&&!state.ended){var chunk=state.decoder.end();chunk&&chunk.length&&_this.push(chunk)}_this.push(null)})),stream.on("data",(function(chunk){(debug("wrapped data"),state.decoder&&(chunk=state.decoder.write(chunk)),state.objectMode&&null==chunk)||(state.objectMode||chunk&&chunk.length)&&(_this.push(chunk)||(paused=!0,stream.pause()))})),stream)void 0===this[i]&&"function"==typeof stream[i]&&(this[i]=function(method){return function(){return stream[method].apply(stream,arguments)}}(i));for(var n=0;n<kProxyEvents.length;n++)stream.on(kProxyEvents[n],this.emit.bind(this,kProxyEvents[n]));return this._read=function(n){debug("wrapped _read",n),paused&&(paused=!1,stream.resume())},this},"function"==typeof Symbol&&(Readable.prototype[Symbol.asyncIterator]=function(){return void 0===createReadableStreamAsyncIterator&&(createReadableStreamAsyncIterator=require("./internal/streams/async_iterator")),createReadableStreamAsyncIterator(this)}),Object.defineProperty(Readable.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(Readable.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(Readable.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(state){this._readableState&&(this._readableState.flowing=state)}}),Readable._fromList=fromList,Object.defineProperty(Readable.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(Readable.from=function(iterable,opts){return void 0===from&&(from=require("./internal/streams/from")),from(Readable,iterable,opts)})}).call(this)}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":59,"./_stream_duplex":60,"./internal/streams/async_iterator":65,"./internal/streams/buffer_list":66,"./internal/streams/destroy":67,"./internal/streams/from":69,"./internal/streams/state":71,"./internal/streams/stream":72,_process:55,buffer:38,events:39,inherits:41,"string_decoder/":73,util:37}],63:[function(require,module,exports){"use strict";module.exports=Transform;var _require$codes=require("../errors").codes,ERR_METHOD_NOT_IMPLEMENTED=_require$codes.ERR_METHOD_NOT_IMPLEMENTED,ERR_MULTIPLE_CALLBACK=_require$codes.ERR_MULTIPLE_CALLBACK,ERR_TRANSFORM_ALREADY_TRANSFORMING=_require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,ERR_TRANSFORM_WITH_LENGTH_0=_require$codes.ERR_TRANSFORM_WITH_LENGTH_0,Duplex=require("./_stream_duplex");function afterTransform(er,data){var ts=this._transformState;ts.transforming=!1;var cb=ts.writecb;if(null===cb)return this.emit("error",new ERR_MULTIPLE_CALLBACK);ts.writechunk=null,ts.writecb=null,null!=data&&this.push(data),cb(er);var rs=this._readableState;rs.reading=!1,(rs.needReadable||rs.length<rs.highWaterMark)&&this._read(rs.highWaterMark)}function Transform(options){if(!(this instanceof Transform))return new Transform(options);Duplex.call(this,options),this._transformState={afterTransform:afterTransform.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,options&&("function"==typeof options.transform&&(this._transform=options.transform),"function"==typeof options.flush&&(this._flush=options.flush)),this.on("prefinish",prefinish)}function prefinish(){var _this=this;"function"!=typeof this._flush||this._readableState.destroyed?done(this,null,null):this._flush((function(er,data){done(_this,er,data)}))}function done(stream,er,data){if(er)return stream.emit("error",er);if(null!=data&&stream.push(data),stream._writableState.length)throw new ERR_TRANSFORM_WITH_LENGTH_0;if(stream._transformState.transforming)throw new ERR_TRANSFORM_ALREADY_TRANSFORMING;return stream.push(null)}require("inherits")(Transform,Duplex),Transform.prototype.push=function(chunk,encoding){return this._transformState.needTransform=!1,Duplex.prototype.push.call(this,chunk,encoding)},Transform.prototype._transform=function(chunk,encoding,cb){cb(new ERR_METHOD_NOT_IMPLEMENTED("_transform()"))},Transform.prototype._write=function(chunk,encoding,cb){var ts=this._transformState;if(ts.writecb=cb,ts.writechunk=chunk,ts.writeencoding=encoding,!ts.transforming){var rs=this._readableState;(ts.needTransform||rs.needReadable||rs.length<rs.highWaterMark)&&this._read(rs.highWaterMark)}},Transform.prototype._read=function(n){var ts=this._transformState;null===ts.writechunk||ts.transforming?ts.needTransform=!0:(ts.transforming=!0,this._transform(ts.writechunk,ts.writeencoding,ts.afterTransform))},Transform.prototype._destroy=function(err,cb){Duplex.prototype._destroy.call(this,err,(function(err2){cb(err2)}))}},{"../errors":59,"./_stream_duplex":60,inherits:41}],64:[function(require,module,exports){(function(process,global){(function(){"use strict";function CorkedRequest(state){var _this=this;this.next=null,this.entry=null,this.finish=function(){!function(corkReq,state,err){var entry=corkReq.entry;corkReq.entry=null;for(;entry;){var cb=entry.callback;state.pendingcb--,cb(err),entry=entry.next}state.corkedRequestsFree.next=corkReq}(_this,state)}}var Duplex;module.exports=Writable,Writable.WritableState=WritableState;var internalUtil={deprecate:require("util-deprecate")},Stream=require("./internal/streams/stream"),Buffer=require("buffer").Buffer,OurUint8Array=global.Uint8Array||function(){};var realHasInstance,destroyImpl=require("./internal/streams/destroy"),getHighWaterMark=require("./internal/streams/state").getHighWaterMark,_require$codes=require("../errors").codes,ERR_INVALID_ARG_TYPE=_require$codes.ERR_INVALID_ARG_TYPE,ERR_METHOD_NOT_IMPLEMENTED=_require$codes.ERR_METHOD_NOT_IMPLEMENTED,ERR_MULTIPLE_CALLBACK=_require$codes.ERR_MULTIPLE_CALLBACK,ERR_STREAM_CANNOT_PIPE=_require$codes.ERR_STREAM_CANNOT_PIPE,ERR_STREAM_DESTROYED=_require$codes.ERR_STREAM_DESTROYED,ERR_STREAM_NULL_VALUES=_require$codes.ERR_STREAM_NULL_VALUES,ERR_STREAM_WRITE_AFTER_END=_require$codes.ERR_STREAM_WRITE_AFTER_END,ERR_UNKNOWN_ENCODING=_require$codes.ERR_UNKNOWN_ENCODING,errorOrDestroy=destroyImpl.errorOrDestroy;function nop(){}function WritableState(options,stream,isDuplex){Duplex=Duplex||require("./_stream_duplex"),options=options||{},"boolean"!=typeof isDuplex&&(isDuplex=stream instanceof Duplex),this.objectMode=!!options.objectMode,isDuplex&&(this.objectMode=this.objectMode||!!options.writableObjectMode),this.highWaterMark=getHighWaterMark(this,options,"writableHighWaterMark",isDuplex),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var noDecode=!1===options.decodeStrings;this.decodeStrings=!noDecode,this.defaultEncoding=options.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(er){!function(stream,er){var state=stream._writableState,sync=state.sync,cb=state.writecb;if("function"!=typeof cb)throw new ERR_MULTIPLE_CALLBACK;if(function(state){state.writing=!1,state.writecb=null,state.length-=state.writelen,state.writelen=0}(state),er)!function(stream,state,sync,er,cb){--state.pendingcb,sync?(process.nextTick(cb,er),process.nextTick(finishMaybe,stream,state),stream._writableState.errorEmitted=!0,errorOrDestroy(stream,er)):(cb(er),stream._writableState.errorEmitted=!0,errorOrDestroy(stream,er),finishMaybe(stream,state))}(stream,state,sync,er,cb);else{var finished=needFinish(state)||stream.destroyed;finished||state.corked||state.bufferProcessing||!state.bufferedRequest||clearBuffer(stream,state),sync?process.nextTick(afterWrite,stream,state,finished,cb):afterWrite(stream,state,finished,cb)}}(stream,er)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==options.emitClose,this.autoDestroy=!!options.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new CorkedRequest(this)}function Writable(options){var isDuplex=this instanceof(Duplex=Duplex||require("./_stream_duplex"));if(!isDuplex&&!realHasInstance.call(Writable,this))return new Writable(options);this._writableState=new WritableState(options,this,isDuplex),this.writable=!0,options&&("function"==typeof options.write&&(this._write=options.write),"function"==typeof options.writev&&(this._writev=options.writev),"function"==typeof options.destroy&&(this._destroy=options.destroy),"function"==typeof options.final&&(this._final=options.final)),Stream.call(this)}function doWrite(stream,state,writev,len,chunk,encoding,cb){state.writelen=len,state.writecb=cb,state.writing=!0,state.sync=!0,state.destroyed?state.onwrite(new ERR_STREAM_DESTROYED("write")):writev?stream._writev(chunk,state.onwrite):stream._write(chunk,encoding,state.onwrite),state.sync=!1}function afterWrite(stream,state,finished,cb){finished||function(stream,state){0===state.length&&state.needDrain&&(state.needDrain=!1,stream.emit("drain"))}(stream,state),state.pendingcb--,cb(),finishMaybe(stream,state)}function clearBuffer(stream,state){state.bufferProcessing=!0;var entry=state.bufferedRequest;if(stream._writev&&entry&&entry.next){var l=state.bufferedRequestCount,buffer=new Array(l),holder=state.corkedRequestsFree;holder.entry=entry;for(var count=0,allBuffers=!0;entry;)buffer[count]=entry,entry.isBuf||(allBuffers=!1),entry=entry.next,count+=1;buffer.allBuffers=allBuffers,doWrite(stream,state,!0,state.length,buffer,"",holder.finish),state.pendingcb++,state.lastBufferedRequest=null,holder.next?(state.corkedRequestsFree=holder.next,holder.next=null):state.corkedRequestsFree=new CorkedRequest(state),state.bufferedRequestCount=0}else{for(;entry;){var chunk=entry.chunk,encoding=entry.encoding,cb=entry.callback;if(doWrite(stream,state,!1,state.objectMode?1:chunk.length,chunk,encoding,cb),entry=entry.next,state.bufferedRequestCount--,state.writing)break}null===entry&&(state.lastBufferedRequest=null)}state.bufferedRequest=entry,state.bufferProcessing=!1}function needFinish(state){return state.ending&&0===state.length&&null===state.bufferedRequest&&!state.finished&&!state.writing}function callFinal(stream,state){stream._final((function(err){state.pendingcb--,err&&errorOrDestroy(stream,err),state.prefinished=!0,stream.emit("prefinish"),finishMaybe(stream,state)}))}function finishMaybe(stream,state){var need=needFinish(state);if(need&&(function(stream,state){state.prefinished||state.finalCalled||("function"!=typeof stream._final||state.destroyed?(state.prefinished=!0,stream.emit("prefinish")):(state.pendingcb++,state.finalCalled=!0,process.nextTick(callFinal,stream,state)))}(stream,state),0===state.pendingcb&&(state.finished=!0,stream.emit("finish"),state.autoDestroy))){var rState=stream._readableState;(!rState||rState.autoDestroy&&rState.endEmitted)&&stream.destroy()}return need}require("inherits")(Writable,Stream),WritableState.prototype.getBuffer=function(){for(var current=this.bufferedRequest,out=[];current;)out.push(current),current=current.next;return out},function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:internalUtil.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(_){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(realHasInstance=Function.prototype[Symbol.hasInstance],Object.defineProperty(Writable,Symbol.hasInstance,{value:function(object){return!!realHasInstance.call(this,object)||this===Writable&&(object&&object._writableState instanceof WritableState)}})):realHasInstance=function(object){return object instanceof this},Writable.prototype.pipe=function(){errorOrDestroy(this,new ERR_STREAM_CANNOT_PIPE)},Writable.prototype.write=function(chunk,encoding,cb){var obj,state=this._writableState,ret=!1,isBuf=!state.objectMode&&(obj=chunk,Buffer.isBuffer(obj)||obj instanceof OurUint8Array);return isBuf&&!Buffer.isBuffer(chunk)&&(chunk=function(chunk){return Buffer.from(chunk)}(chunk)),"function"==typeof encoding&&(cb=encoding,encoding=null),isBuf?encoding="buffer":encoding||(encoding=state.defaultEncoding),"function"!=typeof cb&&(cb=nop),state.ending?function(stream,cb){var er=new ERR_STREAM_WRITE_AFTER_END;errorOrDestroy(stream,er),process.nextTick(cb,er)}(this,cb):(isBuf||function(stream,state,chunk,cb){var er;return null===chunk?er=new ERR_STREAM_NULL_VALUES:"string"==typeof chunk||state.objectMode||(er=new ERR_INVALID_ARG_TYPE("chunk",["string","Buffer"],chunk)),!er||(errorOrDestroy(stream,er),process.nextTick(cb,er),!1)}(this,state,chunk,cb))&&(state.pendingcb++,ret=function(stream,state,isBuf,chunk,encoding,cb){if(!isBuf){var newChunk=function(state,chunk,encoding){state.objectMode||!1===state.decodeStrings||"string"!=typeof chunk||(chunk=Buffer.from(chunk,encoding));return chunk}(state,chunk,encoding);chunk!==newChunk&&(isBuf=!0,encoding="buffer",chunk=newChunk)}var len=state.objectMode?1:chunk.length;state.length+=len;var ret=state.length<state.highWaterMark;ret||(state.needDrain=!0);if(state.writing||state.corked){var last=state.lastBufferedRequest;state.lastBufferedRequest={chunk:chunk,encoding:encoding,isBuf:isBuf,callback:cb,next:null},last?last.next=state.lastBufferedRequest:state.bufferedRequest=state.lastBufferedRequest,state.bufferedRequestCount+=1}else doWrite(stream,state,!1,len,chunk,encoding,cb);return ret}(this,state,isBuf,chunk,encoding,cb)),ret},Writable.prototype.cork=function(){this._writableState.corked++},Writable.prototype.uncork=function(){var state=this._writableState;state.corked&&(state.corked--,state.writing||state.corked||state.bufferProcessing||!state.bufferedRequest||clearBuffer(this,state))},Writable.prototype.setDefaultEncoding=function(encoding){if("string"==typeof encoding&&(encoding=encoding.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((encoding+"").toLowerCase())>-1))throw new ERR_UNKNOWN_ENCODING(encoding);return this._writableState.defaultEncoding=encoding,this},Object.defineProperty(Writable.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(Writable.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Writable.prototype._write=function(chunk,encoding,cb){cb(new ERR_METHOD_NOT_IMPLEMENTED("_write()"))},Writable.prototype._writev=null,Writable.prototype.end=function(chunk,encoding,cb){var state=this._writableState;return"function"==typeof chunk?(cb=chunk,chunk=null,encoding=null):"function"==typeof encoding&&(cb=encoding,encoding=null),null!=chunk&&this.write(chunk,encoding),state.corked&&(state.corked=1,this.uncork()),state.ending||function(stream,state,cb){state.ending=!0,finishMaybe(stream,state),cb&&(state.finished?process.nextTick(cb):stream.once("finish",cb));state.ended=!0,stream.writable=!1}(this,state,cb),this},Object.defineProperty(Writable.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(Writable.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(value){this._writableState&&(this._writableState.destroyed=value)}}),Writable.prototype.destroy=destroyImpl.destroy,Writable.prototype._undestroy=destroyImpl.undestroy,Writable.prototype._destroy=function(err,cb){cb(err)}}).call(this)}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":59,"./_stream_duplex":60,"./internal/streams/destroy":67,"./internal/streams/state":71,"./internal/streams/stream":72,_process:55,buffer:38,inherits:41,"util-deprecate":77}],65:[function(require,module,exports){(function(process){(function(){"use strict";var _Object$setPrototypeO;function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}var finished=require("./end-of-stream"),kLastResolve=Symbol("lastResolve"),kLastReject=Symbol("lastReject"),kError=Symbol("error"),kEnded=Symbol("ended"),kLastPromise=Symbol("lastPromise"),kHandlePromise=Symbol("handlePromise"),kStream=Symbol("stream");function createIterResult(value,done){return{value:value,done:done}}function readAndResolve(iter){var resolve=iter[kLastResolve];if(null!==resolve){var data=iter[kStream].read();null!==data&&(iter[kLastPromise]=null,iter[kLastResolve]=null,iter[kLastReject]=null,resolve(createIterResult(data,!1)))}}function onReadable(iter){process.nextTick(readAndResolve,iter)}var AsyncIteratorPrototype=Object.getPrototypeOf((function(){})),ReadableStreamAsyncIteratorPrototype=Object.setPrototypeOf((_defineProperty(_Object$setPrototypeO={get stream(){return this[kStream]},next:function(){var _this=this,error=this[kError];if(null!==error)return Promise.reject(error);if(this[kEnded])return Promise.resolve(createIterResult(void 0,!0));if(this[kStream].destroyed)return new Promise((function(resolve,reject){process.nextTick((function(){_this[kError]?reject(_this[kError]):resolve(createIterResult(void 0,!0))}))}));var promise,lastPromise=this[kLastPromise];if(lastPromise)promise=new Promise(function(lastPromise,iter){return function(resolve,reject){lastPromise.then((function(){iter[kEnded]?resolve(createIterResult(void 0,!0)):iter[kHandlePromise](resolve,reject)}),reject)}}(lastPromise,this));else{var data=this[kStream].read();if(null!==data)return Promise.resolve(createIterResult(data,!1));promise=new Promise(this[kHandlePromise])}return this[kLastPromise]=promise,promise}},Symbol.asyncIterator,(function(){return this})),_defineProperty(_Object$setPrototypeO,"return",(function(){var _this2=this;return new Promise((function(resolve,reject){_this2[kStream].destroy(null,(function(err){err?reject(err):resolve(createIterResult(void 0,!0))}))}))})),_Object$setPrototypeO),AsyncIteratorPrototype);module.exports=function(stream){var _Object$create,iterator=Object.create(ReadableStreamAsyncIteratorPrototype,(_defineProperty(_Object$create={},kStream,{value:stream,writable:!0}),_defineProperty(_Object$create,kLastResolve,{value:null,writable:!0}),_defineProperty(_Object$create,kLastReject,{value:null,writable:!0}),_defineProperty(_Object$create,kError,{value:null,writable:!0}),_defineProperty(_Object$create,kEnded,{value:stream._readableState.endEmitted,writable:!0}),_defineProperty(_Object$create,kHandlePromise,{value:function(resolve,reject){var data=iterator[kStream].read();data?(iterator[kLastPromise]=null,iterator[kLastResolve]=null,iterator[kLastReject]=null,resolve(createIterResult(data,!1))):(iterator[kLastResolve]=resolve,iterator[kLastReject]=reject)},writable:!0}),_Object$create));return iterator[kLastPromise]=null,finished(stream,(function(err){if(err&&"ERR_STREAM_PREMATURE_CLOSE"!==err.code){var reject=iterator[kLastReject];return null!==reject&&(iterator[kLastPromise]=null,iterator[kLastResolve]=null,iterator[kLastReject]=null,reject(err)),void(iterator[kError]=err)}var resolve=iterator[kLastResolve];null!==resolve&&(iterator[kLastPromise]=null,iterator[kLastResolve]=null,iterator[kLastReject]=null,resolve(createIterResult(void 0,!0))),iterator[kEnded]=!0})),stream.on("readable",onReadable.bind(null,iterator)),iterator}}).call(this)}).call(this,require("_process"))},{"./end-of-stream":68,_process:55}],66:[function(require,module,exports){"use strict";function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter((function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable}))),keys.push.apply(keys,symbols)}return keys}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}var Buffer=require("buffer").Buffer,inspect=require("util").inspect,custom=inspect&&inspect.custom||"inspect";module.exports=function(){function BufferList(){!function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,BufferList),this.head=null,this.tail=null,this.length=0}var Constructor,protoProps,staticProps;return Constructor=BufferList,protoProps=[{key:"push",value:function(v){var entry={data:v,next:null};this.length>0?this.tail.next=entry:this.head=entry,this.tail=entry,++this.length}},{key:"unshift",value:function(v){var entry={data:v,next:this.head};0===this.length&&(this.tail=entry),this.head=entry,++this.length}},{key:"shift",value:function(){if(0!==this.length){var ret=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,ret}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(s){if(0===this.length)return"";for(var p=this.head,ret=""+p.data;p=p.next;)ret+=s+p.data;return ret}},{key:"concat",value:function(n){if(0===this.length)return Buffer.alloc(0);for(var src,target,offset,ret=Buffer.allocUnsafe(n>>>0),p=this.head,i=0;p;)src=p.data,target=ret,offset=i,Buffer.prototype.copy.call(src,target,offset),i+=p.data.length,p=p.next;return ret}},{key:"consume",value:function(n,hasStrings){var ret;return n<this.head.data.length?(ret=this.head.data.slice(0,n),this.head.data=this.head.data.slice(n)):ret=n===this.head.data.length?this.shift():hasStrings?this._getString(n):this._getBuffer(n),ret}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(n){var p=this.head,c=1,ret=p.data;for(n-=ret.length;p=p.next;){var str=p.data,nb=n>str.length?str.length:n;if(nb===str.length?ret+=str:ret+=str.slice(0,n),0==(n-=nb)){nb===str.length?(++c,p.next?this.head=p.next:this.head=this.tail=null):(this.head=p,p.data=str.slice(nb));break}++c}return this.length-=c,ret}},{key:"_getBuffer",value:function(n){var ret=Buffer.allocUnsafe(n),p=this.head,c=1;for(p.data.copy(ret),n-=p.data.length;p=p.next;){var buf=p.data,nb=n>buf.length?buf.length:n;if(buf.copy(ret,ret.length-n,0,nb),0==(n-=nb)){nb===buf.length?(++c,p.next?this.head=p.next:this.head=this.tail=null):(this.head=p,p.data=buf.slice(nb));break}++c}return this.length-=c,ret}},{key:custom,value:function(_,options){return inspect(this,function(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach((function(key){_defineProperty(target,key,source[key])})):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach((function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))}))}return target}({},options,{depth:0,customInspect:!1}))}}],protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),BufferList}()},{buffer:38,util:37}],67:[function(require,module,exports){(function(process){(function(){"use strict";function emitErrorAndCloseNT(self,err){emitErrorNT(self,err),emitCloseNT(self)}function emitCloseNT(self){self._writableState&&!self._writableState.emitClose||self._readableState&&!self._readableState.emitClose||self.emit("close")}function emitErrorNT(self,err){self.emit("error",err)}module.exports={destroy:function(err,cb){var _this=this,readableDestroyed=this._readableState&&this._readableState.destroyed,writableDestroyed=this._writableState&&this._writableState.destroyed;return readableDestroyed||writableDestroyed?(cb?cb(err):err&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(emitErrorNT,this,err)):process.nextTick(emitErrorNT,this,err)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(err||null,(function(err){!cb&&err?_this._writableState?_this._writableState.errorEmitted?process.nextTick(emitCloseNT,_this):(_this._writableState.errorEmitted=!0,process.nextTick(emitErrorAndCloseNT,_this,err)):process.nextTick(emitErrorAndCloseNT,_this,err):cb?(process.nextTick(emitCloseNT,_this),cb(err)):process.nextTick(emitCloseNT,_this)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(stream,err){var rState=stream._readableState,wState=stream._writableState;rState&&rState.autoDestroy||wState&&wState.autoDestroy?stream.destroy(err):stream.emit("error",err)}}}).call(this)}).call(this,require("_process"))},{_process:55}],68:[function(require,module,exports){"use strict";var ERR_STREAM_PREMATURE_CLOSE=require("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function noop(){}module.exports=function eos(stream,opts,callback){if("function"==typeof opts)return eos(stream,null,opts);opts||(opts={}),callback=function(callback){var called=!1;return function(){if(!called){called=!0;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];callback.apply(this,args)}}}(callback||noop);var readable=opts.readable||!1!==opts.readable&&stream.readable,writable=opts.writable||!1!==opts.writable&&stream.writable,onlegacyfinish=function(){stream.writable||onfinish()},writableEnded=stream._writableState&&stream._writableState.finished,onfinish=function(){writable=!1,writableEnded=!0,readable||callback.call(stream)},readableEnded=stream._readableState&&stream._readableState.endEmitted,onend=function(){readable=!1,readableEnded=!0,writable||callback.call(stream)},onerror=function(err){callback.call(stream,err)},onclose=function(){var err;return readable&&!readableEnded?(stream._readableState&&stream._readableState.ended||(err=new ERR_STREAM_PREMATURE_CLOSE),callback.call(stream,err)):writable&&!writableEnded?(stream._writableState&&stream._writableState.ended||(err=new ERR_STREAM_PREMATURE_CLOSE),callback.call(stream,err)):void 0},onrequest=function(){stream.req.on("finish",onfinish)};return!function(stream){return stream.setHeader&&"function"==typeof stream.abort}(stream)?writable&&!stream._writableState&&(stream.on("end",onlegacyfinish),stream.on("close",onlegacyfinish)):(stream.on("complete",onfinish),stream.on("abort",onclose),stream.req?onrequest():stream.on("request",onrequest)),stream.on("end",onend),stream.on("finish",onfinish),!1!==opts.error&&stream.on("error",onerror),stream.on("close",onclose),function(){stream.removeListener("complete",onfinish),stream.removeListener("abort",onclose),stream.removeListener("request",onrequest),stream.req&&stream.req.removeListener("finish",onfinish),stream.removeListener("end",onlegacyfinish),stream.removeListener("close",onlegacyfinish),stream.removeListener("finish",onfinish),stream.removeListener("end",onend),stream.removeListener("error",onerror),stream.removeListener("close",onclose)}}},{"../../../errors":59}],69:[function(require,module,exports){module.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],70:[function(require,module,exports){"use strict";var eos;var _require$codes=require("../../../errors").codes,ERR_MISSING_ARGS=_require$codes.ERR_MISSING_ARGS,ERR_STREAM_DESTROYED=_require$codes.ERR_STREAM_DESTROYED;function noop(err){if(err)throw err}function destroyer(stream,reading,writing,callback){callback=function(callback){var called=!1;return function(){called||(called=!0,callback.apply(void 0,arguments))}}(callback);var closed=!1;stream.on("close",(function(){closed=!0})),void 0===eos&&(eos=require("./end-of-stream")),eos(stream,{readable:reading,writable:writing},(function(err){if(err)return callback(err);closed=!0,callback()}));var destroyed=!1;return function(err){if(!closed&&!destroyed)return destroyed=!0,function(stream){return stream.setHeader&&"function"==typeof stream.abort}(stream)?stream.abort():"function"==typeof stream.destroy?stream.destroy():void callback(err||new ERR_STREAM_DESTROYED("pipe"))}}function call(fn){fn()}function pipe(from,to){return from.pipe(to)}function popCallback(streams){return streams.length?"function"!=typeof streams[streams.length-1]?noop:streams.pop():noop}module.exports=function(){for(var _len=arguments.length,streams=new Array(_len),_key=0;_key<_len;_key++)streams[_key]=arguments[_key];var error,callback=popCallback(streams);if(Array.isArray(streams[0])&&(streams=streams[0]),streams.length<2)throw new ERR_MISSING_ARGS("streams");var destroys=streams.map((function(stream,i){var reading=i<streams.length-1;return destroyer(stream,reading,i>0,(function(err){error||(error=err),err&&destroys.forEach(call),reading||(destroys.forEach(call),callback(error))}))}));return streams.reduce(pipe)}},{"../../../errors":59,"./end-of-stream":68}],71:[function(require,module,exports){"use strict";var ERR_INVALID_OPT_VALUE=require("../../../errors").codes.ERR_INVALID_OPT_VALUE;module.exports={getHighWaterMark:function(state,options,duplexKey,isDuplex){var hwm=function(options,isDuplex,duplexKey){return null!=options.highWaterMark?options.highWaterMark:isDuplex?options[duplexKey]:null}(options,isDuplex,duplexKey);if(null!=hwm){if(!isFinite(hwm)||Math.floor(hwm)!==hwm||hwm<0)throw new ERR_INVALID_OPT_VALUE(isDuplex?duplexKey:"highWaterMark",hwm);return Math.floor(hwm)}return state.objectMode?16:16384}}},{"../../../errors":59}],72:[function(require,module,exports){module.exports=require("events").EventEmitter},{events:39}],73:[function(require,module,exports){"use strict";var Buffer=require("safe-buffer").Buffer,isEncoding=Buffer.isEncoding||function(encoding){switch((encoding=""+encoding)&&encoding.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function StringDecoder(encoding){var nb;switch(this.encoding=function(enc){var nenc=function(enc){if(!enc)return"utf8";for(var retried;;)switch(enc){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return enc;default:if(retried)return;enc=(""+enc).toLowerCase(),retried=!0}}(enc);if("string"!=typeof nenc&&(Buffer.isEncoding===isEncoding||!isEncoding(enc)))throw new Error("Unknown encoding: "+enc);return nenc||enc}(encoding),this.encoding){case"utf16le":this.text=utf16Text,this.end=utf16End,nb=4;break;case"utf8":this.fillLast=utf8FillLast,nb=4;break;case"base64":this.text=base64Text,this.end=base64End,nb=3;break;default:return this.write=simpleWrite,void(this.end=simpleEnd)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(nb)}function utf8CheckByte(byte){return byte<=127?0:byte>>5==6?2:byte>>4==14?3:byte>>3==30?4:byte>>6==2?-1:-2}function utf8FillLast(buf){var p=this.lastTotal-this.lastNeed,r=function(self,buf,p){if(128!=(192&buf[0]))return self.lastNeed=0,"�";if(self.lastNeed>1&&buf.length>1){if(128!=(192&buf[1]))return self.lastNeed=1,"�";if(self.lastNeed>2&&buf.length>2&&128!=(192&buf[2]))return self.lastNeed=2,"�"}}(this,buf);return void 0!==r?r:this.lastNeed<=buf.length?(buf.copy(this.lastChar,p,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(buf.copy(this.lastChar,p,0,buf.length),void(this.lastNeed-=buf.length))}function utf16Text(buf,i){if((buf.length-i)%2==0){var r=buf.toString("utf16le",i);if(r){var c=r.charCodeAt(r.length-1);if(c>=55296&&c<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=buf[buf.length-2],this.lastChar[1]=buf[buf.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=buf[buf.length-1],buf.toString("utf16le",i,buf.length-1)}function utf16End(buf){var r=buf&&buf.length?this.write(buf):"";if(this.lastNeed){var end=this.lastTotal-this.lastNeed;return r+this.lastChar.toString("utf16le",0,end)}return r}function base64Text(buf,i){var n=(buf.length-i)%3;return 0===n?buf.toString("base64",i):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=buf[buf.length-1]:(this.lastChar[0]=buf[buf.length-2],this.lastChar[1]=buf[buf.length-1]),buf.toString("base64",i,buf.length-n))}function base64End(buf){var r=buf&&buf.length?this.write(buf):"";return this.lastNeed?r+this.lastChar.toString("base64",0,3-this.lastNeed):r}function simpleWrite(buf){return buf.toString(this.encoding)}function simpleEnd(buf){return buf&&buf.length?this.write(buf):""}exports.StringDecoder=StringDecoder,StringDecoder.prototype.write=function(buf){if(0===buf.length)return"";var r,i;if(this.lastNeed){if(void 0===(r=this.fillLast(buf)))return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i<buf.length?r?r+this.text(buf,i):this.text(buf,i):r||""},StringDecoder.prototype.end=function(buf){var r=buf&&buf.length?this.write(buf):"";return this.lastNeed?r+"�":r},StringDecoder.prototype.text=function(buf,i){var total=function(self,buf,i){var j=buf.length-1;if(j<i)return 0;var nb=utf8CheckByte(buf[j]);if(nb>=0)return nb>0&&(self.lastNeed=nb-1),nb;if(--j<i||-2===nb)return 0;if((nb=utf8CheckByte(buf[j]))>=0)return nb>0&&(self.lastNeed=nb-2),nb;if(--j<i||-2===nb)return 0;if((nb=utf8CheckByte(buf[j]))>=0)return nb>0&&(2===nb?nb=0:self.lastNeed=nb-3),nb;return 0}(this,buf,i);if(!this.lastNeed)return buf.toString("utf8",i);this.lastTotal=total;var end=buf.length-(total-this.lastNeed);return buf.copy(this.lastChar,0,end),buf.toString("utf8",i,end)},StringDecoder.prototype.fillLast=function(buf){if(this.lastNeed<=buf.length)return buf.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);buf.copy(this.lastChar,this.lastTotal-this.lastNeed,0,buf.length),this.lastNeed-=buf.length}},{"safe-buffer":56}],74:[function(require,module,exports){"use strict";var parse=require("./parse"),reparse=require("./reparse");exports.parse=parse,exports.reparse=reparse},{"./parse":75,"./reparse":76}],75:[function(require,module,exports){"use strict";var escapeMap={"&":"&",'"':""","<":"<",">":">"};function xscape(val){return"string"!=typeof val?val:val.replace(/([&"<>])/g,(function(_,e){return escapeMap[e]}))}var token=/<o>|<ins>|<s>|<sub>|<sup>|<b>|<i>|<tt>|<\/o>|<\/ins>|<\/s>|<\/sub>|<\/sup>|<\/b>|<\/i>|<\/tt>/;function update(s,cmd){cmd.add&&cmd.add.split(";").forEach((function(e){var arr=e.split(" ");s[arr[0]][arr[1]]=!0})),cmd.del&&cmd.del.split(";").forEach((function(e){var arr=e.split(" ");delete s[arr[0]][arr[1]]}))}var trans={"<o>":{add:"text-decoration overline"},"</o>":{del:"text-decoration overline"},"<ins>":{add:"text-decoration underline"},"</ins>":{del:"text-decoration underline"},"<s>":{add:"text-decoration line-through"},"</s>":{del:"text-decoration line-through"},"<b>":{add:"font-weight bold"},"</b>":{del:"font-weight bold"},"<i>":{add:"font-style italic"},"</i>":{del:"font-style italic"},"<sub>":{add:"baseline-shift sub;font-size .7em"},"</sub>":{del:"baseline-shift sub;font-size .7em"},"<sup>":{add:"baseline-shift super;font-size .7em"},"</sup>":{del:"baseline-shift super;font-size .7em"},"<tt>":{add:"font-family monospace"},"</tt>":{del:"font-family monospace"}};function dump(s){return Object.keys(s).reduce((function(pre,cur){var keys=Object.keys(s[cur]);return keys.length>0&&(pre[cur]=keys.join(" ")),pre}),{})}module.exports=function(str){var state,res,i,m,a;if(void 0===str)return[];if("number"==typeof str)return[str+""];if("string"!=typeof str)return[str];for(res=[],state={"text-decoration":{},"font-weight":{},"font-style":{},"baseline-shift":{},"font-size":{},"font-family":{}};;){if(-1===(i=str.search(token)))return res.push(["tspan",dump(state),xscape(str)]),res;if(i>0&&(a=str.slice(0,i),res.push(["tspan",dump(state),xscape(a)])),m=str.match(token)[0],update(state,trans[m]),0===(str=str.slice(i+m.length)).length)return res}}},{}],76:[function(require,module,exports){"use strict";var parse=require("./parse");module.exports=function(React){var $=React.createElement;function reTspan(e,i){var tag=e[0],attr=e[1],newAttr=Object.keys(attr).reduce((function(res,key){var str,m;return res[null===(m=(str=key).match(/(\w+)-(\w)(\w+)/))?str:m[1]+m[2].toUpperCase()+m[3]]=attr[key],res}),{}),body=e[2];return newAttr.key=i,$(tag,newAttr,body)}return function(str){return parse(str).map(reTspan)}}},{"./parse":75}],77:[function(require,module,exports){(function(global){(function(){function config(name){try{if(!global.localStorage)return!1}catch(_){return!1}var val=global.localStorage[name];return null!=val&&"true"===String(val).toLowerCase()}module.exports=function(fn,msg){if(config("noDeprecation"))return fn;var warned=!1;return function(){if(!warned){if(config("throwDeprecation"))throw new Error(msg);config("traceDeprecation")?console.trace(msg):console.warn(msg),warned=!0}return fn.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],78:[function(require,module,exports){module.exports={name:"wavedrom",version:"2.9.1",description:"Digital timing diagram in your browser",homepage:"http://wavedrom.com",author:"[email protected]",license:"MIT",repository:{type:"git",url:"https://github.com/wavedrom/wavedrom.git"},bugs:{url:"https://github.com/wavedrom/wavedrom/issues"},main:"./lib",unpkg:"wavedrom.unpkg.min.js",files:["bin/cli.js","wavedrom.js","wavedrom.min.js","wavedrom.unpkg.js","wavedrom.unpkg.min.js","LICENSE","lib/**","skins/**"],scripts:{test:"npm-run-all eslint nyc",eslint:"eslint lib/*.js",nyc:"nyc -r=lcov -r=text mocha test",dist:"browserify ./lib/wave-drom.js > wavedrom.js","watch.dist":"watchify ./lib/wave-drom.js -o wavedrom.js -v","dist.min":"terser --compress --mengle -- wavedrom.js | node ./bin/header.js > wavedrom.min.js",unpkg:"browserify --standalone wavedrom lib/index.js > wavedrom.unpkg.js","unpkg.min":"terser --compress --mengle -- wavedrom.unpkg.js | node ./bin/header.js > wavedrom.unpkg.min.js",cli:"{ echo '#!/usr/bin/env node' ; browserify --node bin/cli.js ; } > bin/wavedrom.js ; chmod +x bin/wavedrom.js",prepare:"npm-run-all test dist dist.min unpkg unpkg.min",coverage:"nyc report -r=text-lcov | coveralls",clean:"rm -rf wavedrom.js wavedrom.*.js coverage .nyc_output",skins:"for S in default narrow dark lowkey ; do node bin/svg2js.js -i unpacked/skins/$S.svg > skins/$S.js ; done"},keywords:["waveform","verilog","RTL"],devDependencies:{"@drom/eslint-config":"^0.10.0",browserify:"^17.0.0",chai:"^4.3",coveralls:"^3.1.1",eslint:"^8.9","fs-extra":"^10",json5:"^2.2.0",mocha:"^9.2","npm-run-all":"^4.1.5",nyc:"^15.1.0",terser:"^5.10",watchify:"^4.0.0",yargs:"^17.3"},dependencies:{"bit-field":"^1.5.3",logidrom:"^0.3.1",onml:"^2.1.0",tspan:"^0.4.0"},eslintConfig:{extends:"@drom/eslint-config/eslint4/node4",rules:{camelcase:0}}}},{}]},{},[34]);