dashboard-ui/bower_components/libjass/libjass.js
2023-08-31 15:30:17 +02:00

1 line
158 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

!function(root,factory){var global=this;"function"==typeof define&&define.amd?define([],function(){return factory(global)}):"object"==typeof exports&&"object"==typeof module?module.exports=factory(global):"object"==typeof exports?exports.libjass=factory(global):root.libjass=factory(global)}(this,function(global){"use strict";return modules=[function(exports,require){var settings=require(23),settings_1=require(23),set=(exports.debugMode=settings_1.debugMode,exports.verboseMode=settings_1.verboseMode,require(33)),settings_1=require(33),map=(exports.Set=settings_1.Set,require(30)),settings_1=require(30),promise=(exports.Map=settings_1.Map,require(32)),settings_1=require(32),settings_1=(exports.Promise=settings_1.Promise,exports.DeferredPromise=settings_1.DeferredPromise,require(37)),settings_1=(exports.webworker=settings_1,require(8)),settings_1=(exports.parts=settings_1,require(1)),settings_1=(exports.parser=settings_1,require(14)),settings_1=(exports.renderers=settings_1,require(24)),settings_1=(exports.ASS=settings_1.ASS,require(25)),settings_1=(exports.Attachment=settings_1.Attachment,exports.AttachmentType=settings_1.AttachmentType,require(26)),settings_1=(exports.Dialogue=settings_1.Dialogue,require(28)),settings_1=(exports.ScriptProperties=settings_1.ScriptProperties,require(29)),settings_1=(exports.Style=settings_1.Style,require(27));exports.BorderStyle=settings_1.BorderStyle,exports.Format=settings_1.Format,exports.WrappingStyle=settings_1.WrappingStyle,Object.defineProperties(exports,{debugMode:{get:function(){return settings.debugMode},set:settings.setDebugMode},verboseMode:{get:function(){return settings.verboseMode},set:settings.setVerboseMode},Set:{get:function(){return set.Set},set:set.setImplementation},Map:{get:function(){return map.Map},set:map.setImplementation},Promise:{get:function(){return promise.Promise},set:promise.setImplementation}})},function(exports,require){var parse_1=require(3),parse_1=(exports.parse=parse_1.parse,require(5)),parse_1=(exports.BrowserReadableStream=parse_1.BrowserReadableStream,exports.StringStream=parse_1.StringStream,exports.XhrStream=parse_1.XhrStream,require(4));exports.StreamParser=parse_1.StreamParser,exports.SrtStreamParser=parse_1.SrtStreamParser},function(exports,require){var map_1=require(30);function parseLineIntoProperty(line){var colonPos=line.indexOf(":");return-1===colonPos?null:{name:line.substr(0,colonPos),value:line.substr(colonPos+1).replace(/^\s+/,"")}}exports.parseLineIntoProperty=parseLineIntoProperty,exports.parseLineIntoTypedTemplate=function(line,formatSpecifier){var value,template;return null===(line=parseLineIntoProperty(line))?null:((value=line.value.split(",")).length>formatSpecifier.length&&(value[formatSpecifier.length-1]=value.slice(formatSpecifier.length-1).join(",")),template=new map_1.Map,formatSpecifier.forEach(function(formatKey,index){template.set(formatKey,value[index])}),{type:line.name,template:template})}},function(exports,require){var parts=require(8),settings_1=require(23),rules=new(require(30).Map);function parse(input,rule){var run=new ParserRun(input,rule);if(null===run.result||run.result.end!==input.length)throw settings_1.debugMode&&console.error("Parse failed. %s %s %o",rule,input,run.result),new Error("Parse failed.");return run.result.value}exports.parse=parse;var ParserRun=function(){function ParserRun(input,rule){this._input=input,this._parseTree=new ParseNode(null),this._result=rules.get(rule).call(this,this._parseTree)}return Object.defineProperty(ParserRun.prototype,"result",{get:function(){return this._result},enumerable:!0,configurable:!0}),ParserRun.prototype.parse_dialogueParts=function(parent){var current=new ParseNode(parent);for(current.value=[];this._haveMore();){var enclosedTagsNode=this.parse_enclosedTags(current);if(null!==enclosedTagsNode)(_a=current.value).push.apply(_a,enclosedTagsNode.value);else{var _a=this.parse_newline(current)||this.parse_hardspace(current)||this.parse_text(current);if(null===_a)return parent.pop(),null;_a.value instanceof parts.Text&&current.value[current.value.length-1]instanceof parts.Text?(enclosedTagsNode=current.value[current.value.length-1],current.value[current.value.length-1]=new parts.Text(enclosedTagsNode.value+_a.value.value)):current.value.push(_a.value)}}var inDrawingMode=!1;return current.value.forEach(function(part,i){part instanceof parts.DrawingMode?inDrawingMode=0!==part.scale:part instanceof parts.Text&&inDrawingMode&&(current.value[i]=new parts.DrawingInstructions(parse(part.value,"drawingInstructions")))}),current},ParserRun.prototype.parse_enclosedTags=function(parent){var current=new ParseNode(parent);if(current.value=[],null===this.read(current,"{"))return parent.pop(),null;for(var next=this._peek();this._haveMore()&&"}"!==next;next=this._peek()){var childNode=null;if(null!==this.read(current,"\\")&&null===(childNode=this.parse_tag_alpha(current)||this.parse_tag_iclip(current)||this.parse_tag_xbord(current)||this.parse_tag_ybord(current)||this.parse_tag_xshad(current)||this.parse_tag_yshad(current)||this.parse_tag_blur(current)||this.parse_tag_bord(current)||this.parse_tag_clip(current)||this.parse_tag_fade(current)||this.parse_tag_fscx(current)||this.parse_tag_fscy(current)||this.parse_tag_move(current)||this.parse_tag_shad(current)||this.parse_tag_fad(current)||this.parse_tag_fax(current)||this.parse_tag_fay(current)||this.parse_tag_frx(current)||this.parse_tag_fry(current)||this.parse_tag_frz(current)||this.parse_tag_fsp(current)||this.parse_tag_fsplus(current)||this.parse_tag_fsminus(current)||this.parse_tag_org(current)||this.parse_tag_pbo(current)||this.parse_tag_pos(current)||this.parse_tag_an(current)||this.parse_tag_be(current)||this.parse_tag_fn(current)||this.parse_tag_fr(current)||this.parse_tag_fs(current)||this.parse_tag_kf(current)||this.parse_tag_ko(current)||this.parse_tag_1a(current)||this.parse_tag_1c(current)||this.parse_tag_2a(current)||this.parse_tag_2c(current)||this.parse_tag_3a(current)||this.parse_tag_3c(current)||this.parse_tag_4a(current)||this.parse_tag_4c(current)||this.parse_tag_a(current)||this.parse_tag_b(current)||this.parse_tag_c(current)||this.parse_tag_i(current)||this.parse_tag_k(current)||this.parse_tag_K(current)||this.parse_tag_p(current)||this.parse_tag_q(current)||this.parse_tag_r(current)||this.parse_tag_s(current)||this.parse_tag_t(current)||this.parse_tag_u(current))&&current.pop(),null===(childNode=null===childNode?this.parse_comment(current):childNode))return parent.pop(),null;childNode.value instanceof parts.Comment&&current.value[current.value.length-1]instanceof parts.Comment?current.value[current.value.length-1]=new parts.Comment(current.value[current.value.length-1].value+childNode.value.value):current.value.push(childNode.value)}return null===this.read(current,"}")?(parent.pop(),null):current},ParserRun.prototype.parse_newline=function(parent){var current=new ParseNode(parent);return null===this.read(current,"\\N")?(parent.pop(),null):(current.value=new parts.NewLine,current)},ParserRun.prototype.parse_hardspace=function(parent){var current=new ParseNode(parent);return null===this.read(current,"\\h")?(parent.pop(),null):(current.value=new parts.Text(" "),current)},ParserRun.prototype.parse_text=function(parent){var value=this._peek(),parent=new ParseNode(parent),value=new ParseNode(parent,value);return parent.value=new parts.Text(value.value),parent},ParserRun.prototype.parse_comment=function(parent){var value=this._peek(),parent=new ParseNode(parent),value=new ParseNode(parent,value);return parent.value=new parts.Comment(value.value),parent},ParserRun.prototype.parse_tag_a=function(parent){var current=new ParseNode(parent);if(null===this.read(current,"a"))return parent.pop(),null;var next=this._peek();switch(next){case"1":var next2=this._peek(2);switch(next2){case"10":case"11":next=next2}break;case"2":case"3":case"5":case"6":case"7":case"9":break;default:return parent.pop(),null}var value=null;switch(new ParseNode(current,next).value){case"1":value=1;break;case"2":value=2;break;case"3":value=3;break;case"5":value=7;break;case"6":value=8;break;case"7":value=9;break;case"9":value=4;break;case"10":value=5;break;case"11":value=6}return current.value=new parts.Alignment(value),current},ParserRun.prototype.parse_tag_alpha=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_an=function(parent){var next,current=new ParseNode(parent);return null===this.read(current,"an")||(next=this._peek())<"1"||"9"<next?(parent.pop(),null):(parent=new ParseNode(current,next),current.value=new parts.Alignment(parseInt(parent.value)),current)},ParserRun.prototype.parse_tag_b=function(parent){var next,current=new ParseNode(parent);return null===this.read(current,"b")?(parent.pop(),null):(parent=null,"1"<=(next=this._peek())&&next<="9"&&"00"===(next=this._peek(3)).substr(1)&&((parent=new ParseNode(current,next)).value=parseInt(parent.value)),null===parent&&(parent=this.parse_enableDisable(current)),current.value=null!==parent?new parts.Bold(parent.value):new parts.Bold(null),current)},ParserRun.prototype.parse_tag_be=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_blur=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_bord=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_c=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_clip=function(parent){return this._parse_tag_clip_or_iclip("clip",parent)},ParserRun.prototype.parse_tag_fad=function(parent){var startNode,endNode,current=new ParseNode(parent);return null===this.read(current,"fad")||null===this.read(current,"(")||null===(startNode=this.parse_decimal(current))||null===this.read(current,",")||null===(endNode=this.parse_decimal(current))||null===this.read(current,")")?(parent.pop(),null):(current.value=new parts.Fade(startNode.value/1e3,endNode.value/1e3),current)},ParserRun.prototype.parse_tag_fade=function(parent){var a1Node,a2Node,a3Node,t1Node,t2Node,t3Node,t4Node,current=new ParseNode(parent);return null===this.read(current,"fade")||null===this.read(current,"(")||null===(a1Node=this.parse_decimal(current))||null===this.read(current,",")||null===(a2Node=this.parse_decimal(current))||null===this.read(current,",")||null===(a3Node=this.parse_decimal(current))||null===this.read(current,",")||null===(t1Node=this.parse_decimal(current))||null===this.read(current,",")||null===(t2Node=this.parse_decimal(current))||null===this.read(current,",")||null===(t3Node=this.parse_decimal(current))||null===this.read(current,",")||null===(t4Node=this.parse_decimal(current))||null===this.read(current,")")?(parent.pop(),null):(current.value=new parts.ComplexFade(1-a1Node.value/255,1-a2Node.value/255,1-a3Node.value/255,t1Node.value/1e3,t2Node.value/1e3,t3Node.value/1e3,t4Node.value/1e3),current)},ParserRun.prototype.parse_tag_fax=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_fay=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_fn=function(parent){var current=new ParseNode(parent);if(null===this.read(current,"fn"))return parent.pop(),null;for(var valueNode=new ParseNode(current,""),next=this._peek();this._haveMore()&&"\\"!==next&&"}"!==next;next=this._peek())valueNode.value+=next;return 0<valueNode.value.length?current.value=new parts.FontName(valueNode.value):current.value=new parts.FontName(null),current},ParserRun.prototype.parse_tag_fr=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_frx=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_fry=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_frz=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_fs=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_fsplus=function(parent){var valueNode,current=new ParseNode(parent);return null===this.read(current,"fs+")||null===(valueNode=this.parse_decimal(current))?(parent.pop(),null):(current.value=new parts.FontSizePlus(valueNode.value),current)},ParserRun.prototype.parse_tag_fsminus=function(parent){var valueNode,current=new ParseNode(parent);return null===this.read(current,"fs-")||null===(valueNode=this.parse_decimal(current))?(parent.pop(),null):(current.value=new parts.FontSizeMinus(valueNode.value),current)},ParserRun.prototype.parse_tag_fscx=function(parent){var current=new ParseNode(parent);return null===this.read(current,"fscx")?(parent.pop(),null):(parent=this.parse_decimal(current),current.value=null!==parent?new parts.FontScaleX(parent.value/100):new parts.FontScaleX(null),current)},ParserRun.prototype.parse_tag_fscy=function(parent){var current=new ParseNode(parent);return null===this.read(current,"fscy")?(parent.pop(),null):(parent=this.parse_decimal(current),current.value=null!==parent?new parts.FontScaleY(parent.value/100):new parts.FontScaleY(null),current)},ParserRun.prototype.parse_tag_fsp=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_i=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_iclip=function(parent){return this._parse_tag_clip_or_iclip("iclip",parent)},ParserRun.prototype.parse_tag_k=function(parent){var valueNode,current=new ParseNode(parent);return null===this.read(current,"k")||null===(valueNode=this.parse_decimal(current))?(parent.pop(),null):(current.value=new parts.ColorKaraoke(valueNode.value/100),current)},ParserRun.prototype.parse_tag_K=function(parent){var valueNode,current=new ParseNode(parent);return null===this.read(current,"K")||null===(valueNode=this.parse_decimal(current))?(parent.pop(),null):(current.value=new parts.SweepingColorKaraoke(valueNode.value/100),current)},ParserRun.prototype.parse_tag_kf=function(parent){var valueNode,current=new ParseNode(parent);return null===this.read(current,"kf")||null===(valueNode=this.parse_decimal(current))?(parent.pop(),null):(current.value=new parts.SweepingColorKaraoke(valueNode.value/100),current)},ParserRun.prototype.parse_tag_ko=function(parent){var valueNode,current=new ParseNode(parent);return null===this.read(current,"ko")||null===(valueNode=this.parse_decimal(current))?(parent.pop(),null):(current.value=new parts.OutlineKaraoke(valueNode.value/100),current)},ParserRun.prototype.parse_tag_move=function(parent){var current=new ParseNode(parent);if(null===this.read(current,"move"))return parent.pop(),null;if(null===this.read(current,"("))return parent.pop(),null;var x1Node=this.parse_decimal(current);if(null===x1Node)return parent.pop(),null;if(null===this.read(current,","))return parent.pop(),null;var y1Node=this.parse_decimal(current);if(null===y1Node)return parent.pop(),null;if(null===this.read(current,","))return parent.pop(),null;var x2Node=this.parse_decimal(current);if(null===x2Node)return parent.pop(),null;if(null===this.read(current,","))return parent.pop(),null;var y2Node=this.parse_decimal(current);if(null===y2Node)return parent.pop(),null;var t1Node=null,t2Node=null;if(null!==this.read(current,",")){if(null===(t1Node=this.parse_decimal(current)))return parent.pop(),null;if(null===this.read(current,","))return parent.pop(),null;if(null===(t2Node=this.parse_decimal(current)))return parent.pop(),null}return null===this.read(current,")")?(parent.pop(),null):(current.value=new parts.Move(x1Node.value,y1Node.value,x2Node.value,y2Node.value,null!==t1Node?t1Node.value/1e3:null,null!==t2Node?t2Node.value/1e3:null),current)},ParserRun.prototype.parse_tag_org=function(parent){var xNode,yNode,current=new ParseNode(parent);return null===this.read(current,"org")||null===this.read(current,"(")||null===(xNode=this.parse_decimal(current))||null===this.read(current,",")||null===(yNode=this.parse_decimal(current))||null===this.read(current,")")?(parent.pop(),null):(current.value=new parts.RotationOrigin(xNode.value,yNode.value),current)},ParserRun.prototype.parse_tag_p=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_pbo=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_pos=function(parent){var xNode,yNode,current=new ParseNode(parent);return null===this.read(current,"pos")||null===this.read(current,"(")||null===(xNode=this.parse_decimal(current))||null===this.read(current,",")||null===(yNode=this.parse_decimal(current))||null===this.read(current,")")?(parent.pop(),null):(current.value=new parts.Position(xNode.value,yNode.value),current)},ParserRun.prototype.parse_tag_q=function(parent){var next,current=new ParseNode(parent);return null===this.read(current,"q")||(next=this._peek())<"0"||"3"<next?(parent.pop(),null):(parent=new ParseNode(current,next),current.value=new parts.WrappingStyle(parseInt(parent.value)),current)},ParserRun.prototype.parse_tag_r=function(parent){var current=new ParseNode(parent);if(null===this.read(current,"r"))return parent.pop(),null;for(var valueNode=new ParseNode(current,""),next=this._peek();this._haveMore()&&"\\"!==next&&"}"!==next;next=this._peek())valueNode.value+=next;return 0<valueNode.value.length?current.value=new parts.Reset(valueNode.value):current.value=new parts.Reset(null),current},ParserRun.prototype.parse_tag_s=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_shad=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_t=function(parent){var current=new ParseNode(parent);if(null===this.read(current,"t"))return parent.pop(),null;if(null===this.read(current,"("))return parent.pop(),null;var startNode=null,endNode=null,accelNode=null,firstNode=this.parse_decimal(current);if(null!==firstNode){if(null===this.read(current,","))return parent.pop(),null;var secondNode=this.parse_decimal(current);if(null!==secondNode){if(startNode=firstNode,endNode=secondNode,null===this.read(current,","))return parent.pop(),null;secondNode=this.parse_decimal(current);if(null!==secondNode&&(accelNode=secondNode,null===this.read(current,",")))return parent.pop(),null}else if(accelNode=firstNode,null===this.read(current,","))return parent.pop(),null}for(var transformTags=[],next=this._peek();this._haveMore()&&")"!==next&&"}"!==next;next=this._peek()){var childNode=null;if(null!==this.read(current,"\\")&&null===(childNode=this.parse_tag_alpha(current)||this.parse_tag_iclip(current)||this.parse_tag_xbord(current)||this.parse_tag_ybord(current)||this.parse_tag_xshad(current)||this.parse_tag_yshad(current)||this.parse_tag_blur(current)||this.parse_tag_bord(current)||this.parse_tag_clip(current)||this.parse_tag_fscx(current)||this.parse_tag_fscy(current)||this.parse_tag_shad(current)||this.parse_tag_fax(current)||this.parse_tag_fay(current)||this.parse_tag_frx(current)||this.parse_tag_fry(current)||this.parse_tag_frz(current)||this.parse_tag_fsp(current)||this.parse_tag_fsplus(current)||this.parse_tag_fsminus(current)||this.parse_tag_be(current)||this.parse_tag_fr(current)||this.parse_tag_fs(current)||this.parse_tag_1a(current)||this.parse_tag_1c(current)||this.parse_tag_2a(current)||this.parse_tag_2c(current)||this.parse_tag_3a(current)||this.parse_tag_3c(current)||this.parse_tag_4a(current)||this.parse_tag_4c(current)||this.parse_tag_c(current))&&current.pop(),null===(childNode=null===childNode?this.parse_comment(current):childNode))return parent.pop(),null;childNode.value instanceof parts.Comment&&transformTags[transformTags.length-1]instanceof parts.Comment?transformTags[transformTags.length-1]=new parts.Comment(transformTags[transformTags.length-1].value+childNode.value.value):transformTags.push(childNode.value)}return this.read(current,")"),current.value=new parts.Transform(null!==startNode?startNode.value/1e3:null,null!==endNode?endNode.value/1e3:null,null!==accelNode?accelNode.value/1e3:null,transformTags),current},ParserRun.prototype.parse_tag_u=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_xbord=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_xshad=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_ybord=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_yshad=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_1a=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_1c=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_2a=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_2c=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_3a=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_3c=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_4a=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_tag_4c=function(){throw new Error("Method not implemented.")},ParserRun.prototype.parse_drawingInstructions=function(parent){var current=new ParseNode(parent),currentType=null,numberParts=[];for(current.value=[];this._haveMore();){for(;null!==this.read(current," "););if(!this._haveMore())break;if(null!==currentType){var numberPart=this.parse_decimal(current);if(null!==numberPart){numberParts.push(numberPart),"m"===currentType&&2===numberParts.length?(current.value.push(new parts.drawing.MoveInstruction(numberParts[0].value,numberParts[1].value)),numberParts.splice(0,numberParts.length)):"l"===currentType&&2===numberParts.length?(current.value.push(new parts.drawing.LineInstruction(numberParts[0].value,numberParts[1].value)),numberParts.splice(0,numberParts.length)):"b"===currentType&&6===numberParts.length&&(current.value.push(new parts.drawing.CubicBezierCurveInstruction(numberParts[0].value,numberParts[1].value,numberParts[2].value,numberParts[3].value,numberParts[4].value,numberParts[5].value)),numberParts.splice(0,numberParts.length));continue}}numberPart=this.parse_text(current);if(null===numberPart)break;var newType=numberPart.value.value;switch(newType){case"m":case"l":case"b":currentType=newType,numberParts.splice(0,numberParts.length)}}for(;null!==this.read(current," "););return current},ParserRun.prototype.parse_decimalInt32=function(parent){for(var current=new ParseNode(parent),isNegative=null!==this.read(current,"-"),numberNode=new ParseNode(current,""),next=this._peek();this._haveMore()&&"0"<=next&&next<="9";next=this._peek())numberNode.value+=next;return 0===numberNode.value.length?(parent.pop(),null):(4294967295<=(parent=parseInt(numberNode.value))?parent=4294967295:isNegative&&(parent=-parent),current.value=parent,current)},ParserRun.prototype.parse_hexInt32=function(parent){for(var current=new ParseNode(parent),isNegative=null!==this.read(current,"-"),numberNode=new ParseNode(current,""),next=this._peek();this._haveMore()&&("0"<=next&&next<="9"||"a"<=next&&next<="f"||"A"<=next&&next<="F");next=this._peek())numberNode.value+=next;return 0===numberNode.value.length?(parent.pop(),null):(4294967295<=(parent=parseInt(numberNode.value,16))?parent=4294967295:isNegative&&(parent=-parent),current.value=parent,current)},ParserRun.prototype.parse_decimalOrHexInt32=function(parent){var current=new ParseNode(parent),valueNode=null!==this.read(current,"&H")||null!==this.read(current,"&h")?this.parse_hexInt32(current):this.parse_decimalInt32(current);return null===valueNode?(parent.pop(),null):(current.value=valueNode.value,current)},ParserRun.prototype.parse_decimal=function(parent){var current=new ParseNode(parent),negative=null!==this.read(current,"-"),numericalPart=this.parse_unsignedDecimal(current);return null===numericalPart?(parent.pop(),null):(current.value=numericalPart.value,negative&&(current.value=-current.value),current)},ParserRun.prototype.parse_unsignedDecimal=function(parent){for(var current=new ParseNode(parent),characteristicNode=new ParseNode(current,""),mantissaNode=null,next=this._peek();this._haveMore()&&"0"<=next&&next<="9";next=this._peek())characteristicNode.value+=next;if(0===characteristicNode.value.length)return parent.pop(),null;if(null!==this.read(current,".")){for(mantissaNode=new ParseNode(current,""),next=this._peek();this._haveMore()&&"0"<=next&&next<="9";next=this._peek())mantissaNode.value+=next;if(0===mantissaNode.value.length)return parent.pop(),null}return current.value=parseFloat(characteristicNode.value+(null!==mantissaNode?"."+mantissaNode.value:"")),current},ParserRun.prototype.parse_enableDisable=function(parent){var next=this._peek();return"0"===next||"1"===next?((parent=new ParseNode(parent,next)).value="1"===parent.value,parent):null},ParserRun.prototype.parse_color=function(parent){for(var current=new ParseNode(parent);null!==this.read(current,"&")||null!==this.read(current,"H"););var valueNode=this.parse_hexInt32(current);if(null===valueNode)return parent.pop(),null;parent=valueNode.value;for(current.value=new parts.Color(255&parent,parent>>8&255,parent>>16&255);null!==this.read(current,"&")||null!==this.read(current,"H"););return current},ParserRun.prototype.parse_alpha=function(parent){for(var current=new ParseNode(parent);null!==this.read(current,"&")||null!==this.read(current,"H"););var valueNode=this.parse_hexInt32(current);if(null===valueNode)return parent.pop(),null;parent=valueNode.value;for(current.value=1-(255&parent)/255;null!==this.read(current,"&")||null!==this.read(current,"H"););return current},ParserRun.prototype.parse_colorWithAlpha=function(parent){var current=new ParseNode(parent),valueNode=this.parse_decimalOrHexInt32(current);return null===valueNode?(parent.pop(),null):(parent=valueNode.value,current.value=new parts.Color(255&parent,parent>>8&255,parent>>16&255,1-(parent>>24&255)/255),current)},ParserRun.prototype.read=function(parent,next){return this._peek(next.length)!==next?null:new ParseNode(parent,next)},ParserRun.prototype._peek=function(count){return 1===(count=void 0===count?1:count)?this._input[this._parseTree.end]:this._input.substr(this._parseTree.end,count)},ParserRun.prototype._haveMore=function(){return this._parseTree.end<this._input.length},ParserRun.prototype._parse_tag_clip_or_iclip=function(tagName,parent){var current=new ParseNode(parent);if(null===this.read(current,tagName))return parent.pop(),null;if(null===this.read(current,"("))return parent.pop(),null;var x1Node=null,y1Node=null,scaleNode=null,commandsNode=null,firstNode=this.parse_decimal(current);if(null!==firstNode){if(null===this.read(current,","))return parent.pop(),null;var secondNode=this.parse_decimal(current);null!==secondNode?(x1Node=firstNode,y1Node=secondNode):scaleNode=firstNode}if(null!==x1Node&&null!==y1Node){if(null===this.read(current,","))return parent.pop(),null;if(secondNode=this.parse_decimal(current),null===this.read(current,","))return parent.pop(),null;firstNode=this.parse_decimal(current),current.value=new parts.RectangularClip(x1Node.value,y1Node.value,secondNode.value,firstNode.value,"clip"===tagName)}else{for(var commandsNode=new ParseNode(current,""),next=this._peek();this._haveMore()&&")"!==next&&"}"!==next;next=this._peek())commandsNode.value+=next;current.value=new parts.VectorClip(null!==scaleNode?scaleNode.value:1,parse(commandsNode.value,"drawingInstructions"),"clip"===tagName)}return null===this.read(current,")")?(parent.pop(),null):current},ParserRun}();function makeTagParserFunction(tagName,tagConstructor,valueParser,required){ParserRun.prototype["parse_tag_"+tagName]=function(parent){var current=new ParseNode(parent);if(null===this.read(current,tagName))return parent.pop(),null;var valueNode=valueParser.call(this,current);if(null!==valueNode)current.value=new tagConstructor(valueNode.value);else{if(required)return parent.pop(),null;current.value=new tagConstructor(null)}return current}}makeTagParserFunction("alpha",parts.Alpha,ParserRun.prototype.parse_alpha,!1),makeTagParserFunction("be",parts.Blur,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("blur",parts.GaussianBlur,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("bord",parts.Border,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("c",parts.PrimaryColor,ParserRun.prototype.parse_color,!1),makeTagParserFunction("fax",parts.SkewX,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("fay",parts.SkewY,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("fr",parts.RotateZ,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("frx",parts.RotateX,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("fry",parts.RotateY,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("frz",parts.RotateZ,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("fs",parts.FontSize,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("fsp",parts.LetterSpacing,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("i",parts.Italic,ParserRun.prototype.parse_enableDisable,!1),makeTagParserFunction("p",parts.DrawingMode,ParserRun.prototype.parse_decimal,!0),makeTagParserFunction("pbo",parts.DrawingBaselineOffset,ParserRun.prototype.parse_decimal,!0),makeTagParserFunction("s",parts.StrikeThrough,ParserRun.prototype.parse_enableDisable,!1),makeTagParserFunction("shad",parts.Shadow,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("u",parts.Underline,ParserRun.prototype.parse_enableDisable,!1),makeTagParserFunction("xbord",parts.BorderX,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("xshad",parts.ShadowX,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("ybord",parts.BorderY,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("yshad",parts.ShadowY,ParserRun.prototype.parse_decimal,!1),makeTagParserFunction("1a",parts.PrimaryAlpha,ParserRun.prototype.parse_alpha,!1),makeTagParserFunction("1c",parts.PrimaryColor,ParserRun.prototype.parse_color,!1),makeTagParserFunction("2a",parts.SecondaryAlpha,ParserRun.prototype.parse_alpha,!1),makeTagParserFunction("2c",parts.SecondaryColor,ParserRun.prototype.parse_color,!1),makeTagParserFunction("3a",parts.OutlineAlpha,ParserRun.prototype.parse_alpha,!1),makeTagParserFunction("3c",parts.OutlineColor,ParserRun.prototype.parse_color,!1),makeTagParserFunction("4a",parts.ShadowAlpha,ParserRun.prototype.parse_alpha,!1),makeTagParserFunction("4c",parts.ShadowColor,ParserRun.prototype.parse_color,!1);for(var _i=0,_a=Object.keys(ParserRun.prototype);_i<_a.length;_i++){var key=_a[_i];0===key.indexOf("parse_")&&"function"==typeof ParserRun.prototype[key]&&rules.set(key.substr("parse_".length),ParserRun.prototype[key])}var ParseNode=function(){function ParseNode(parent,value){void 0===value&&(value=null),this._parent=parent,this._children=[],null!==parent&&parent.children.push(this),this._start=null!==parent?parent.end:0,this._end=this._start,this.value=value}return Object.defineProperty(ParseNode.prototype,"start",{get:function(){return this._start},enumerable:!0,configurable:!0}),Object.defineProperty(ParseNode.prototype,"end",{get:function(){return this._end},enumerable:!0,configurable:!0}),Object.defineProperty(ParseNode.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(ParseNode.prototype,"children",{get:function(){return this._children},enumerable:!0,configurable:!0}),Object.defineProperty(ParseNode.prototype,"value",{get:function(){return this._value},set:function(newValue){this._value=newValue,null!==this._value&&this._value.constructor===String&&0===this._children.length&&this._setEnd(this._start+this._value.length)},enumerable:!0,configurable:!0}),ParseNode.prototype.pop=function(){this._children.splice(this._children.length-1,1),0<this._children.length?this._setEnd(this._children[this._children.length-1].end):this._setEnd(this.start)},ParseNode.prototype._setEnd=function(newEnd){this._end=newEnd,null!==this._parent&&this._parent.end!==this._end&&this._parent._setEnd(this._end)},ParseNode}(),promise_1=require(32),exports=require(36);require(38).registerWorkerCommand(exports.WorkerCommands.Parse,function(parameters){return new promise_1.Promise(function(resolve){resolve(parse(parameters.input,parameters.rule))})})},function(exports,require){var Section,settings_1=require(23),ass_1=require(24),style_1=require(29),dialogue_1=require(26),attachment_1=require(25),map_1=require(30),promise_1=require(32),misc_1=require(2),require=(!function(Section){Section[Section.ScriptInfo=0]="ScriptInfo",Section[Section.Styles=1]="Styles",Section[Section.Events=2]="Events",Section[Section.Fonts=3]="Fonts",Section[Section.Graphics=4]="Graphics",Section[Section.Other=5]="Other",Section[Section.EOF=6]="EOF"}(Section=Section||{}),function(){function StreamParser(stream){var _this=this;this._stream=stream,this._ass=new ass_1.ASS,this._minimalDeferred=new promise_1.DeferredPromise,this._deferred=new promise_1.DeferredPromise,this._shouldSwallowBom=!0,this._currentSection=Section.ScriptInfo,this._currentAttachment=null,this._stream.nextLine().then(function(line){return _this._onNextLine(line)},function(reason){_this._minimalDeferred.reject(reason),_this._deferred.reject(reason)})}return Object.defineProperty(StreamParser.prototype,"minimalASS",{get:function(){return this._minimalDeferred.promise},enumerable:!0,configurable:!0}),Object.defineProperty(StreamParser.prototype,"ass",{get:function(){return this._deferred.promise},enumerable:!0,configurable:!0}),Object.defineProperty(StreamParser.prototype,"currentSection",{get:function(){return this._currentSection},set:function(value){null!==this._currentAttachment&&(this._ass.addAttachment(this._currentAttachment),this._currentAttachment=null),this._currentSection===Section.ScriptInfo&&value!==Section.ScriptInfo&&this._minimalDeferred.resolve(this._ass),value===Section.EOF&&(this._minimalDeferred.resolve(this._ass),this._deferred.resolve(this._ass)),this._currentSection=value},enumerable:!0,configurable:!0}),StreamParser.prototype._onNextLine=function(line){var _this=this;if(null===line)this.currentSection=Section.EOF;else{if(65279===(line="\r"===line[line.length-1]?line.substr(0,line.length-1):line).charCodeAt(0)&&this._shouldSwallowBom&&(line=line.substr(1)),this._shouldSwallowBom=!1,""!==line&&(";"!==line[0]||null!==this._currentAttachment))if("[Script Info]"===line)this.currentSection=Section.ScriptInfo;else if("[V4+ Styles]"===line||"[V4 Styles]"===line)this.currentSection=Section.Styles;else if("[Events]"===line)this.currentSection=Section.Events;else if("[Fonts]"===line)this.currentSection=Section.Fonts;else if("[Graphics]"===line)this.currentSection=Section.Graphics;else switch(null===this._currentAttachment&&"["===line[0]&&"]"===line[line.length-1]&&(this.currentSection=Section.Other),this.currentSection){case Section.ScriptInfo:var property=misc_1.parseLineIntoProperty(line);if(null!==property)switch(property.name){case"PlayResX":this._ass.properties.resolutionX=parseInt(property.value);break;case"PlayResY":this._ass.properties.resolutionY=parseInt(property.value);break;case"WrapStyle":this._ass.properties.wrappingStyle=parseInt(property.value);break;case"ScaledBorderAndShadow":this._ass.properties.scaleBorderAndShadow="yes"===property.value}break;case Section.Styles:if(null===this._ass.stylesFormatSpecifier){var property_1=misc_1.parseLineIntoProperty(line);null!==property_1&&"Format"===property_1.name&&(this._ass.stylesFormatSpecifier=property_1.value.split(",").map(function(str){return str.trim()}))}else try{this._ass.addStyle(line)}catch(ex){settings_1.debugMode&&console.error("Could not parse style from line "+line+" - "+(ex.stack||ex))}break;case Section.Events:if(null===this._ass.dialoguesFormatSpecifier){property_1=misc_1.parseLineIntoProperty(line);null!==property_1&&"Format"===property_1.name&&(this._ass.dialoguesFormatSpecifier=property_1.value.split(",").map(function(str){return str.trim()}))}else try{this._ass.addEvent(line)}catch(ex){settings_1.debugMode&&console.error("Could not parse event from line "+line+" - "+(ex.stack||ex))}break;case Section.Fonts:case Section.Graphics:property_1=(this.currentSection===Section.Fonts?/^fontname:(.+)/:/^filename:(.+)/).exec(line);if(null!==property_1)null!==this._currentAttachment&&(this._ass.addAttachment(this._currentAttachment),this._currentAttachment=null),this._currentAttachment=new attachment_1.Attachment(property_1[1].trim(),this.currentSection===Section.Fonts?attachment_1.AttachmentType.Font:attachment_1.AttachmentType.Graphic);else if(null!==this._currentAttachment)try{this._currentAttachment.contents+=function(str){for(var result="",i=0;i<str.length;i++){var charCode=str.charCodeAt(i)-33;if(charCode<0||63<charCode)throw new Error("Out-of-range character code "+charCode+" at index "+i+" in string "+str);result+=charCode<26?String.fromCharCode("A".charCodeAt(0)+charCode):charCode<52?String.fromCharCode("a".charCodeAt(0)+charCode-26):charCode<62?String.fromCharCode("0".charCodeAt(0)+charCode-52):62==charCode?"+":"/"}return result}(line)}catch(ex){settings_1.debugMode&&console.error("Encountered error while reading font "+this._currentAttachment.filename+": %o",ex),this._currentAttachment=null}break;case Section.Other:break;default:throw new Error("Unhandled state "+this.currentSection)}this._stream.nextLine().then(function(line){return _this._onNextLine(line)},function(reason){_this._minimalDeferred.reject(reason),_this._deferred.reject(reason)})}},StreamParser}()),require=(exports.StreamParser=require,function(){function SrtStreamParser(stream){var _this=this,stream=(this._stream=stream,this._ass=new ass_1.ASS,this._deferred=new promise_1.DeferredPromise,this._shouldSwallowBom=!0,this._currentDialogueNumber=null,this._currentDialogueStart=null,this._currentDialogueEnd=null,this._currentDialogueText=null,this._stream.nextLine().then(function(line){return _this._onNextLine(line)},function(reason){_this._deferred.reject(reason)}),this._ass.properties.resolutionX=1280,this._ass.properties.resolutionY=720,this._ass.properties.wrappingStyle=1,this._ass.properties.scaleBorderAndShadow=!0,new style_1.Style(new map_1.Map([["Name","Default"],["FontSize","36"]])));this._ass.styles.set(stream.name,stream)}return Object.defineProperty(SrtStreamParser.prototype,"ass",{get:function(){return this._deferred.promise},enumerable:!0,configurable:!0}),SrtStreamParser.prototype._onNextLine=function(line){var match,_this=this;null===line?(null!==this._currentDialogueNumber&&null!==this._currentDialogueStart&&null!==this._currentDialogueEnd&&null!==this._currentDialogueText&&this._ass.dialogues.push(new dialogue_1.Dialogue(new map_1.Map([["Style","Default"],["Start",this._currentDialogueStart],["End",this._currentDialogueEnd],["Text",this._currentDialogueText]]),this._ass)),this._deferred.resolve(this._ass)):(65279===(line="\r"===line[line.length-1]?line.substr(0,line.length-1):line).charCodeAt(0)&&this._shouldSwallowBom&&(line=line.substr(1)),this._shouldSwallowBom=!1,""===line?(null!==this._currentDialogueNumber&&null!==this._currentDialogueStart&&null!==this._currentDialogueEnd&&null!==this._currentDialogueText&&this._ass.dialogues.push(new dialogue_1.Dialogue(new map_1.Map([["Style","Default"],["Start",this._currentDialogueStart],["End",this._currentDialogueEnd],["Text",this._currentDialogueText]]),this._ass)),this._currentDialogueNumber=this._currentDialogueStart=this._currentDialogueEnd=this._currentDialogueText=null):null===this._currentDialogueNumber?/^\d+$/.test(line)&&(this._currentDialogueNumber=line):null===this._currentDialogueStart&&null===this._currentDialogueEnd?null!==(match=/^(\d\d:\d\d:\d\d,\d\d\d) --> (\d\d:\d\d:\d\d,\d\d\d)/.exec(line))&&(this._currentDialogueStart=match[1].replace(",","."),this._currentDialogueEnd=match[2].replace(",",".")):(line=line.replace(/<b>/g,"{\\b1}").replace(/\{b\}/g,"{\\b1}").replace(/<\/b>/g,"{\\b0}").replace(/\{\/b\}/g,"{\\b0}").replace(/<i>/g,"{\\i1}").replace(/\{i\}/g,"{\\i1}").replace(/<\/i>/g,"{\\i0}").replace(/\{\/i\}/g,"{\\i0}").replace(/<u>/g,"{\\u1}").replace(/\{u\}/g,"{\\u1}").replace(/<\/u>/g,"{\\u0}").replace(/\{\/u\}/g,"{\\u0}").replace(/<font color="#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})">/g,function(substring,red,green,blue){return"{c&H"+blue+green+red+"&}"}).replace(/<\/font>/g,"{\\c}"),null!==this._currentDialogueText?this._currentDialogueText+="\\N"+line:this._currentDialogueText=line),this._stream.nextLine().then(function(line){return _this._onNextLine(line)},function(reason){_this._deferred.reject(reason)}))},SrtStreamParser}());exports.SrtStreamParser=require},function(exports,require){var promise_1=require(32),require=function(){function StringStream(str){this._str=str,this._readTill=0}return StringStream.prototype.nextLine=function(){var nextNewLinePos,result=null;return this._readTill<this._str.length?-1!==(nextNewLinePos=this._str.indexOf("\n",this._readTill))?(result=promise_1.Promise.resolve(this._str.substring(this._readTill,nextNewLinePos)),this._readTill=nextNewLinePos+1):(result=promise_1.Promise.resolve(this._str.substr(this._readTill)),this._readTill=this._str.length):result=promise_1.Promise.resolve(null),result},StringStream}(),require=(exports.StringStream=require,function(){function XhrStream(xhr){var _this=this;this._xhr=xhr,this._readTill=0,this._pendingDeferred=null,this._failedError=null,xhr.addEventListener("progress",function(){return _this._onXhrProgress()},!1),xhr.addEventListener("load",function(){return _this._onXhrLoad()},!1),xhr.addEventListener("error",function(event){return _this._onXhrError(event)},!1)}return XhrStream.prototype.nextLine=function(){if(null!==this._pendingDeferred)throw new Error("XhrStream only supports one pending unfulfilled read at a time.");var deferred=this._pendingDeferred=new promise_1.DeferredPromise;return this._tryResolveNextLine(),deferred.promise},XhrStream.prototype._onXhrProgress=function(){null!==this._pendingDeferred&&this._xhr.readyState!==XMLHttpRequest.DONE&&this._tryResolveNextLine()},XhrStream.prototype._onXhrLoad=function(){null!==this._pendingDeferred&&this._tryResolveNextLine()},XhrStream.prototype._onXhrError=function(event){this._failedError=event,null!==this._pendingDeferred&&this._tryResolveNextLine()},XhrStream.prototype._tryResolveNextLine=function(){var response,nextNewLinePos;null!==this._failedError?this._pendingDeferred.reject(this._failedError):-1!==(nextNewLinePos=(response=this._xhr.responseText).indexOf("\n",this._readTill))?(this._pendingDeferred.resolve(response.substring(this._readTill,nextNewLinePos)),this._readTill=nextNewLinePos+1,this._pendingDeferred=null):this._xhr.readyState===XMLHttpRequest.DONE&&(null!==this._failedError?this._pendingDeferred.reject(this._failedError):this._readTill<response.length?(this._pendingDeferred.resolve(response.substr(this._readTill)),this._readTill=response.length):this._pendingDeferred.resolve(null),this._pendingDeferred=null)},XhrStream}()),require=(exports.XhrStream=require,function(){function BrowserReadableStream(stream,encoding){this._buffer="",this._pendingDeferred=null,this._reader=stream.getReader(),this._decoder=new global.TextDecoder(encoding,{ignoreBOM:!0})}return BrowserReadableStream.prototype.nextLine=function(){if(null!==this._pendingDeferred)throw new Error("BrowserReadableStream only supports one pending unfulfilled read at a time.");var deferred=this._pendingDeferred=new promise_1.DeferredPromise;return this._tryResolveNextLine(),deferred.promise},BrowserReadableStream.prototype._tryResolveNextLine=function(){var _this=this,nextNewLinePos=this._buffer.indexOf("\n");-1!==nextNewLinePos?(this._pendingDeferred.resolve(this._buffer.substr(0,nextNewLinePos)),this._buffer=this._buffer.substr(nextNewLinePos+1),this._pendingDeferred=null):this._reader.read().then(function(next){var value=next.value;next.done?(0===_this._buffer.length?_this._pendingDeferred.resolve(null):(_this._pendingDeferred.resolve(_this._buffer),_this._buffer=""),_this._pendingDeferred=null):(_this._buffer+=_this._decoder.decode(value,{stream:!0}),_this._tryResolveNextLine())})},BrowserReadableStream}());exports.BrowserReadableStream=require},function(exports,require){var DataType,__decorate=require(34).__decorate,map_1=require(30),set_1=require(33),fieldDecorators=(!function(DataType){DataType[DataType.Char=0]="Char",DataType[DataType.Uint16=1]="Uint16",DataType[DataType.Uint32=2]="Uint32"}(DataType=DataType||{}),new map_1.Map),OffsetTable=(require=function(){},__decorate([field(DataType.Uint16)],require.prototype,"majorVersion",void 0),__decorate([field(DataType.Uint16)],require.prototype,"minorVersion",void 0),__decorate([field(DataType.Uint16)],require.prototype,"numTables",void 0),__decorate([field(DataType.Uint16)],require.prototype,"searchRange",void 0),__decorate([field(DataType.Uint16)],require.prototype,"entrySelector",void 0),__decorate([field(DataType.Uint16)],require.prototype,"rangeShift",void 0),__decorate([struct],require)),TableRecord=(map_1=function(){},__decorate([field(DataType.Char)],map_1.prototype,"c1",void 0),__decorate([field(DataType.Char)],map_1.prototype,"c2",void 0),__decorate([field(DataType.Char)],map_1.prototype,"c3",void 0),__decorate([field(DataType.Char)],map_1.prototype,"c4",void 0),__decorate([field(DataType.Uint32)],map_1.prototype,"checksum",void 0),__decorate([field(DataType.Uint32)],map_1.prototype,"offset",void 0),__decorate([field(DataType.Uint32)],map_1.prototype,"length",void 0),__decorate([struct],map_1)),NameTableHeader=(require=function(){},__decorate([field(DataType.Uint16)],require.prototype,"formatSelector",void 0),__decorate([field(DataType.Uint16)],require.prototype,"count",void 0),__decorate([field(DataType.Uint16)],require.prototype,"stringOffset",void 0),__decorate([struct],require)),NameRecord=(map_1=function(){},__decorate([field(DataType.Uint16)],map_1.prototype,"platformId",void 0),__decorate([field(DataType.Uint16)],map_1.prototype,"encodingId",void 0),__decorate([field(DataType.Uint16)],map_1.prototype,"languageId",void 0),__decorate([field(DataType.Uint16)],map_1.prototype,"nameId",void 0),__decorate([field(DataType.Uint16)],map_1.prototype,"length",void 0),__decorate([field(DataType.Uint16)],map_1.prototype,"offset",void 0),__decorate([struct],map_1));function struct(clazz){var fields=clazz.__fields;return clazz.read=function(reader){for(var result=new clazz,_i=0;_i<fields.length;_i++){var field_1=fields[_i],value=void 0;switch(field_1.type){case DataType.Char:value=String.fromCharCode(reader.dataView.getInt8(reader.position)),reader.position+=1;break;case DataType.Uint16:value=reader.dataView.getUint16(reader.position),reader.position+=2;break;case DataType.Uint32:value=reader.dataView.getUint32(reader.position),reader.position+=4}result[field_1.field]=value}return result},clazz}function field(type){var existingDecorator=fieldDecorators.get(type);return void 0===existingDecorator&&fieldDecorators.set(type,existingDecorator=function(proto,field){proto=proto.constructor;void 0===proto.__fields&&(proto.__fields=[]),proto.__fields.push({type:type,field:field})}),existingDecorator}exports.getTtfNames=function(attachment){for(var decoded=atob(attachment.contents),bytes=new Uint8Array(new ArrayBuffer(decoded.length)),i=0;i<decoded.length;i++)bytes[i]=decoded.charCodeAt(i);var reader={dataView:new DataView(bytes.buffer),position:0},offsetTable=OffsetTable.read(reader),nameTableRecord=null;for(i=0;i<offsetTable.numTables;i++){var tableRecord=TableRecord.read(reader);if(tableRecord.c1+tableRecord.c2+tableRecord.c3+tableRecord.c4==="name"){nameTableRecord=tableRecord;break}}reader.position=nameTableRecord.offset;var nameTableHeader=NameTableHeader.read(reader),result=new set_1.Set;for(i=0;i<nameTableHeader.count;i++){var nameRecord=NameRecord.read(reader);switch(nameRecord.nameId){case 1:case 4:case 6:var recordOffset=nameTableRecord.offset+nameTableHeader.stringOffset+nameRecord.offset,nameBytes=bytes.subarray(recordOffset,recordOffset+nameRecord.length);switch(nameRecord.platformId){case 1:for(var name_1="",j=0;j<nameBytes.length;j++)name_1+=String.fromCharCode(nameBytes[j]);result.add(name_1);break;case 3:var name_2="";for(j=0;j<nameBytes.length;j+=2)name_2+=String.fromCharCode((nameBytes[j]<<8)+nameBytes[j+1]);result.add(name_2)}}}return result}},function(exports){var MoveInstruction=function(){function MoveInstruction(x,y){this._x=x,this._y=y}return Object.defineProperty(MoveInstruction.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(MoveInstruction.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),MoveInstruction}(),MoveInstruction=(exports.MoveInstruction=MoveInstruction,function(){function LineInstruction(x,y){this._x=x,this._y=y}return Object.defineProperty(LineInstruction.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(LineInstruction.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),LineInstruction}()),MoveInstruction=(exports.LineInstruction=MoveInstruction,function(){function CubicBezierCurveInstruction(x1,y1,x2,y2,x3,y3){this._x1=x1,this._y1=y1,this._x2=x2,this._y2=y2,this._x3=x3,this._y3=y3}return Object.defineProperty(CubicBezierCurveInstruction.prototype,"x1",{get:function(){return this._x1},enumerable:!0,configurable:!0}),Object.defineProperty(CubicBezierCurveInstruction.prototype,"y1",{get:function(){return this._y1},enumerable:!0,configurable:!0}),Object.defineProperty(CubicBezierCurveInstruction.prototype,"x2",{get:function(){return this._x2},enumerable:!0,configurable:!0}),Object.defineProperty(CubicBezierCurveInstruction.prototype,"y2",{get:function(){return this._y2},enumerable:!0,configurable:!0}),Object.defineProperty(CubicBezierCurveInstruction.prototype,"x3",{get:function(){return this._x3},enumerable:!0,configurable:!0}),Object.defineProperty(CubicBezierCurveInstruction.prototype,"y3",{get:function(){return this._y3},enumerable:!0,configurable:!0}),CubicBezierCurveInstruction}());exports.CubicBezierCurveInstruction=MoveInstruction},function(exports,require){for(var key,value,drawing=require(7),Color=(exports.drawing=drawing,function(){function Color(red,green,blue,alpha){void 0===alpha&&(alpha=1),this._red=red,this._green=green,this._blue=blue,this._alpha=alpha}return Object.defineProperty(Color.prototype,"red",{get:function(){return this._red},enumerable:!0,configurable:!0}),Object.defineProperty(Color.prototype,"green",{get:function(){return this._green},enumerable:!0,configurable:!0}),Object.defineProperty(Color.prototype,"blue",{get:function(){return this._blue},enumerable:!0,configurable:!0}),Object.defineProperty(Color.prototype,"alpha",{get:function(){return this._alpha},enumerable:!0,configurable:!0}),Color.prototype.withAlpha=function(value){return null!==value?new Color(this._red,this._green,this._blue,value):this},Color.prototype.toString=function(){return"rgba("+this._red+", "+this._green+", "+this._blue+", "+this._alpha.toFixed(3)+")"},Color.prototype.interpolate=function(final,progression){return new Color(this._red+progression*(final.red-this._red),this._green+progression*(final.green-this._green),this._blue+progression*(final.blue-this._blue),this._alpha+progression*(final.alpha-this._alpha))},Color}()),Color=(exports.Color=Color,function(){function Comment(value){this._value=value}return Object.defineProperty(Comment.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),Comment}()),Color=(exports.Comment=Color,function(){function Text(value){this._value=value}return Object.defineProperty(Text.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),Text.prototype.toString=function(){return"Text { value: "+this._value.replace(/\u00A0/g,"\\h")+" }"},Text}()),Color=(exports.Text=Color,function(){}),Color=(exports.NewLine=Color,function(){function Italic(value){this._value=value}return Object.defineProperty(Italic.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),Italic}()),Color=(exports.Italic=Color,function(){function Bold(value){this._value=value}return Object.defineProperty(Bold.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),Bold}()),Color=(exports.Bold=Color,function(){function Underline(value){this._value=value}return Object.defineProperty(Underline.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),Underline}()),Color=(exports.Underline=Color,function(){function StrikeThrough(value){this._value=value}return Object.defineProperty(StrikeThrough.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),StrikeThrough}()),Color=(exports.StrikeThrough=Color,function(){function Border(value){this._value=value}return Object.defineProperty(Border.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),Border}()),Color=(exports.Border=Color,function(){function BorderX(value){this._value=value}return Object.defineProperty(BorderX.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),BorderX}()),Color=(exports.BorderX=Color,function(){function BorderY(value){this._value=value}return Object.defineProperty(BorderY.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),BorderY}()),Color=(exports.BorderY=Color,function(){function Shadow(value){this._value=value}return Object.defineProperty(Shadow.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),Shadow}()),Color=(exports.Shadow=Color,function(){function ShadowX(value){this._value=value}return Object.defineProperty(ShadowX.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),ShadowX}()),Color=(exports.ShadowX=Color,function(){function ShadowY(value){this._value=value}return Object.defineProperty(ShadowY.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),ShadowY}()),Color=(exports.ShadowY=Color,function(){function Blur(value){this._value=value}return Object.defineProperty(Blur.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),Blur}()),Color=(exports.Blur=Color,function(){function GaussianBlur(value){this._value=value}return Object.defineProperty(GaussianBlur.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),GaussianBlur}()),Color=(exports.GaussianBlur=Color,function(){function FontName(value){this._value=value}return Object.defineProperty(FontName.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),FontName}()),Color=(exports.FontName=Color,function(){function FontSize(value){this._value=value}return Object.defineProperty(FontSize.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),FontSize}()),Color=(exports.FontSize=Color,function(){function FontSizePlus(value){this._value=value}return Object.defineProperty(FontSizePlus.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),FontSizePlus}()),Color=(exports.FontSizePlus=Color,function(){function FontSizeMinus(value){this._value=value}return Object.defineProperty(FontSizeMinus.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),FontSizeMinus}()),Color=(exports.FontSizeMinus=Color,function(){function FontScaleX(value){this._value=value}return Object.defineProperty(FontScaleX.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),FontScaleX}()),Color=(exports.FontScaleX=Color,function(){function FontScaleY(value){this._value=value}return Object.defineProperty(FontScaleY.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),FontScaleY}()),Color=(exports.FontScaleY=Color,function(){function LetterSpacing(value){this._value=value}return Object.defineProperty(LetterSpacing.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),LetterSpacing}()),Color=(exports.LetterSpacing=Color,function(){function RotateX(value){this._value=value}return Object.defineProperty(RotateX.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),RotateX}()),Color=(exports.RotateX=Color,function(){function RotateY(value){this._value=value}return Object.defineProperty(RotateY.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),RotateY}()),Color=(exports.RotateY=Color,function(){function RotateZ(value){this._value=value}return Object.defineProperty(RotateZ.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),RotateZ}()),Color=(exports.RotateZ=Color,function(){function SkewX(value){this._value=value}return Object.defineProperty(SkewX.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),SkewX}()),Color=(exports.SkewX=Color,function(){function SkewY(value){this._value=value}return Object.defineProperty(SkewY.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),SkewY}()),Color=(exports.SkewY=Color,function(){function PrimaryColor(value){this._value=value}return Object.defineProperty(PrimaryColor.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),PrimaryColor}()),Color=(exports.PrimaryColor=Color,function(){function SecondaryColor(value){this._value=value}return Object.defineProperty(SecondaryColor.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),SecondaryColor}()),Color=(exports.SecondaryColor=Color,function(){function OutlineColor(value){this._value=value}return Object.defineProperty(OutlineColor.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),OutlineColor}()),Color=(exports.OutlineColor=Color,function(){function ShadowColor(value){this._value=value}return Object.defineProperty(ShadowColor.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),ShadowColor}()),Color=(exports.ShadowColor=Color,function(){function Alpha(value){this._value=value}return Object.defineProperty(Alpha.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),Alpha}()),Color=(exports.Alpha=Color,function(){function PrimaryAlpha(value){this._value=value}return Object.defineProperty(PrimaryAlpha.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),PrimaryAlpha}()),Color=(exports.PrimaryAlpha=Color,function(){function SecondaryAlpha(value){this._value=value}return Object.defineProperty(SecondaryAlpha.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),SecondaryAlpha}()),Color=(exports.SecondaryAlpha=Color,function(){function OutlineAlpha(value){this._value=value}return Object.defineProperty(OutlineAlpha.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),OutlineAlpha}()),Color=(exports.OutlineAlpha=Color,function(){function ShadowAlpha(value){this._value=value}return Object.defineProperty(ShadowAlpha.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),ShadowAlpha}()),Color=(exports.ShadowAlpha=Color,function(){function Alignment(value){this._value=value}return Object.defineProperty(Alignment.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),Alignment}()),Color=(exports.Alignment=Color,function(){function ColorKaraoke(duration){this._duration=duration}return Object.defineProperty(ColorKaraoke.prototype,"duration",{get:function(){return this._duration},enumerable:!0,configurable:!0}),ColorKaraoke}()),Color=(exports.ColorKaraoke=Color,function(){function SweepingColorKaraoke(duration){this._duration=duration}return Object.defineProperty(SweepingColorKaraoke.prototype,"duration",{get:function(){return this._duration},enumerable:!0,configurable:!0}),SweepingColorKaraoke}()),Color=(exports.SweepingColorKaraoke=Color,function(){function OutlineKaraoke(duration){this._duration=duration}return Object.defineProperty(OutlineKaraoke.prototype,"duration",{get:function(){return this._duration},enumerable:!0,configurable:!0}),OutlineKaraoke}()),Color=(exports.OutlineKaraoke=Color,function(){function WrappingStyle(value){this._value=value}return Object.defineProperty(WrappingStyle.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),WrappingStyle}()),Color=(exports.WrappingStyle=Color,function(){function Reset(value){this._value=value}return Object.defineProperty(Reset.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),Reset}()),Color=(exports.Reset=Color,function(){function Position(x,y){this._x=x,this._y=y}return Object.defineProperty(Position.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(Position.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),Position}()),Color=(exports.Position=Color,function(){function Move(x1,y1,x2,y2,t1,t2){this._x1=x1,this._y1=y1,this._x2=x2,this._y2=y2,this._t1=t1,this._t2=t2}return Object.defineProperty(Move.prototype,"x1",{get:function(){return this._x1},enumerable:!0,configurable:!0}),Object.defineProperty(Move.prototype,"y1",{get:function(){return this._y1},enumerable:!0,configurable:!0}),Object.defineProperty(Move.prototype,"x2",{get:function(){return this._x2},enumerable:!0,configurable:!0}),Object.defineProperty(Move.prototype,"y2",{get:function(){return this._y2},enumerable:!0,configurable:!0}),Object.defineProperty(Move.prototype,"t1",{get:function(){return this._t1},enumerable:!0,configurable:!0}),Object.defineProperty(Move.prototype,"t2",{get:function(){return this._t2},enumerable:!0,configurable:!0}),Move}()),Color=(exports.Move=Color,function(){function RotationOrigin(x,y){this._x=x,this._y=y}return Object.defineProperty(RotationOrigin.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(RotationOrigin.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),RotationOrigin}()),Color=(exports.RotationOrigin=Color,function(){function Fade(start,end){this._start=start,this._end=end}return Object.defineProperty(Fade.prototype,"start",{get:function(){return this._start},enumerable:!0,configurable:!0}),Object.defineProperty(Fade.prototype,"end",{get:function(){return this._end},enumerable:!0,configurable:!0}),Fade}()),Color=(exports.Fade=Color,function(){function ComplexFade(a1,a2,a3,t1,t2,t3,t4){this._a1=a1,this._a2=a2,this._a3=a3,this._t1=t1,this._t2=t2,this._t3=t3,this._t4=t4}return Object.defineProperty(ComplexFade.prototype,"a1",{get:function(){return this._a1},enumerable:!0,configurable:!0}),Object.defineProperty(ComplexFade.prototype,"a2",{get:function(){return this._a2},enumerable:!0,configurable:!0}),Object.defineProperty(ComplexFade.prototype,"a3",{get:function(){return this._a3},enumerable:!0,configurable:!0}),Object.defineProperty(ComplexFade.prototype,"t1",{get:function(){return this._t1},enumerable:!0,configurable:!0}),Object.defineProperty(ComplexFade.prototype,"t2",{get:function(){return this._t2},enumerable:!0,configurable:!0}),Object.defineProperty(ComplexFade.prototype,"t3",{get:function(){return this._t3},enumerable:!0,configurable:!0}),Object.defineProperty(ComplexFade.prototype,"t4",{get:function(){return this._t4},enumerable:!0,configurable:!0}),ComplexFade}()),Color=(exports.ComplexFade=Color,function(){function Transform(start,end,accel,tags){this._start=start,this._end=end,this._accel=accel,this._tags=tags}return Object.defineProperty(Transform.prototype,"start",{get:function(){return this._start},enumerable:!0,configurable:!0}),Object.defineProperty(Transform.prototype,"end",{get:function(){return this._end},enumerable:!0,configurable:!0}),Object.defineProperty(Transform.prototype,"accel",{get:function(){return this._accel},enumerable:!0,configurable:!0}),Object.defineProperty(Transform.prototype,"tags",{get:function(){return this._tags},enumerable:!0,configurable:!0}),Transform}()),Color=(exports.Transform=Color,function(){function RectangularClip(x1,y1,x2,y2,inside){this._x1=x1,this._y1=y1,this._x2=x2,this._y2=y2,this._inside=inside}return Object.defineProperty(RectangularClip.prototype,"x1",{get:function(){return this._x1},enumerable:!0,configurable:!0}),Object.defineProperty(RectangularClip.prototype,"y1",{get:function(){return this._y1},enumerable:!0,configurable:!0}),Object.defineProperty(RectangularClip.prototype,"x2",{get:function(){return this._x2},enumerable:!0,configurable:!0}),Object.defineProperty(RectangularClip.prototype,"y2",{get:function(){return this._y2},enumerable:!0,configurable:!0}),Object.defineProperty(RectangularClip.prototype,"inside",{get:function(){return this._inside},enumerable:!0,configurable:!0}),RectangularClip}()),Color=(exports.RectangularClip=Color,function(){function VectorClip(scale,instructions,inside){this._scale=scale,this._instructions=instructions,this._inside=inside}return Object.defineProperty(VectorClip.prototype,"scale",{get:function(){return this._scale},enumerable:!0,configurable:!0}),Object.defineProperty(VectorClip.prototype,"instructions",{get:function(){return this._instructions},enumerable:!0,configurable:!0}),Object.defineProperty(VectorClip.prototype,"inside",{get:function(){return this._inside},enumerable:!0,configurable:!0}),VectorClip}()),Color=(exports.VectorClip=Color,function(){function DrawingMode(scale){this._scale=scale}return Object.defineProperty(DrawingMode.prototype,"scale",{get:function(){return this._scale},enumerable:!0,configurable:!0}),DrawingMode}()),Color=(exports.DrawingMode=Color,function(){function DrawingBaselineOffset(value){this._value=value}return Object.defineProperty(DrawingBaselineOffset.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),DrawingBaselineOffset}()),Color=(exports.DrawingBaselineOffset=Color,function(){function DrawingInstructions(instructions){this._instructions=instructions}return Object.defineProperty(DrawingInstructions.prototype,"instructions",{get:function(){return this._instructions},enumerable:!0,configurable:!0}),DrawingInstructions}()),addToString=(exports.DrawingInstructions=Color,function(ctor,ctorName){var propertyNames;ctor.prototype.hasOwnProperty("toString")||(propertyNames=Object.getOwnPropertyNames(ctor.prototype).filter(function(property){return"constructor"!==property}),ctor.prototype.toString=function(){var _this=this;return ctorName+" { "+propertyNames.map(function(name){return name+": "+_this[name]}).join(", ")+(0<propertyNames.length?" ":"")+"}"})}),misc_1=require(38),_i=0,_a=Object.keys(exports);_i<_a.length;_i++)(value=exports[key=_a[_i]])instanceof Function&&(addToString(value,key),misc_1.registerClassPrototype(value.prototype));for(var _b=0,_c=Object.keys(drawing);_b<_c.length;_b++)(value=drawing[key=_c[_b]])instanceof Function&&(addToString(value,"Drawing"+key),misc_1.registerClassPrototype(value.prototype))},function(exports,require){var settings_1=require(23),manual_1=require(11),require=function(){function AutoClock(getCurrentTime,autoPauseAfter){this._getCurrentTime=getCurrentTime,this._autoPauseAfter=autoPauseAfter,this._manualClock=new manual_1.ManualClock,this._nextAnimationFrameRequestId=null,this._lastKnownExternalTime=null,this._lastKnownExternalTimeObtainedAt=null}return AutoClock.prototype.play=function(){this._manualClock.enabled&&(this._startTicking(),this._manualClock.play())},AutoClock.prototype.pause=function(){this._manualClock.enabled&&(null===this._nextAnimationFrameRequestId?settings_1.debugMode&&console.warn("AutoClock.pause: Abnormal state detected. AutoClock._nextAnimationFrameRequestId should not have been null."):(this._stopTicking(),this._manualClock.pause()))},AutoClock.prototype.seeking=function(){this._manualClock.seek(this._getCurrentTime())},Object.defineProperty(AutoClock.prototype,"currentTime",{get:function(){return this._manualClock.currentTime},enumerable:!0,configurable:!0}),Object.defineProperty(AutoClock.prototype,"enabled",{get:function(){return this._manualClock.enabled},enumerable:!0,configurable:!0}),Object.defineProperty(AutoClock.prototype,"paused",{get:function(){return this._manualClock.paused},enumerable:!0,configurable:!0}),Object.defineProperty(AutoClock.prototype,"rate",{get:function(){return this._manualClock.rate},enumerable:!0,configurable:!0}),AutoClock.prototype.setRate=function(rate){this._manualClock.setRate(rate)},AutoClock.prototype.enable=function(){return!!this._manualClock.enable()&&(this._startTicking(),!0)},AutoClock.prototype.disable=function(){return!!this._manualClock.disable()&&(this._stopTicking(),!0)},AutoClock.prototype.toggle=function(){this._manualClock.enabled?this.disable():this.enable()},AutoClock.prototype.setEnabled=function(enabled){return enabled?this.enable():this.disable()},AutoClock.prototype.addEventListener=function(type,listener){this._manualClock.addEventListener(type,listener)},AutoClock.prototype._onTimerTick=function(timeStamp){var currentTime,currentExternalTime,_this=this;this._manualClock.enabled?(currentTime=this._manualClock.currentTime,currentExternalTime=this._getCurrentTime(),this._manualClock.paused?currentTime!==currentExternalTime&&(this._lastKnownExternalTime=currentExternalTime,this._lastKnownExternalTimeObtainedAt=timeStamp,this._manualClock.tick(currentExternalTime)):null!==this._lastKnownExternalTime&&currentExternalTime===this._lastKnownExternalTime?timeStamp-this._lastKnownExternalTimeObtainedAt>this._autoPauseAfter?(this._lastKnownExternalTimeObtainedAt=null,this._manualClock.pause()):this._manualClock.tick((timeStamp-this._lastKnownExternalTimeObtainedAt)/1e3*this._manualClock.rate+this._lastKnownExternalTime):(this._lastKnownExternalTime=currentExternalTime,this._lastKnownExternalTimeObtainedAt=timeStamp,this._manualClock.tick(currentExternalTime)),this._nextAnimationFrameRequestId=requestAnimationFrame(function(timeStamp){return _this._onTimerTick(timeStamp)})):settings_1.debugMode&&console.warn("AutoClock._onTimerTick: Called when disabled.")},AutoClock.prototype._startTicking=function(){var _this=this;null===this._nextAnimationFrameRequestId&&(this._nextAnimationFrameRequestId=requestAnimationFrame(function(timeStamp){return _this._onTimerTick(timeStamp)}))},AutoClock.prototype._stopTicking=function(){null!==this._nextAnimationFrameRequestId&&(cancelAnimationFrame(this._nextAnimationFrameRequestId),this._nextAnimationFrameRequestId=null)},AutoClock}();exports.AutoClock=require},function(exports){var EventSource=function(){function EventSource(){}return EventSource.prototype.addEventListener=function(type,listener){var listeners=this._eventListeners.get(type);void 0===listeners&&this._eventListeners.set(type,listeners=[]),listeners.push(listener)},EventSource.prototype._dispatchEvent=function(type,args){var listeners=this._eventListeners.get(type);if(void 0!==listeners)for(var _i=0;_i<listeners.length;_i++)listeners[_i].apply(this,args)},EventSource}();exports.EventSource=EventSource,(EventSource=exports.ClockEvent||(exports.ClockEvent={}))[EventSource.Play=0]="Play",EventSource[EventSource.Tick=1]="Tick",EventSource[EventSource.Pause=2]="Pause",EventSource[EventSource.Stop=3]="Stop",EventSource[EventSource.RateChange=4]="RateChange"},function(exports,require){var mixin_1=require(31),map_1=require(30),base_1=require(10),require=function(){function ManualClock(){this._currentTime=-1,this._rate=1,this._enabled=!0,this._paused=!0,this._eventListeners=new map_1.Map}return ManualClock.prototype.play=function(){this._enabled&&this._paused&&(this._paused=!1,this._dispatchEvent(base_1.ClockEvent.Play,[]))},ManualClock.prototype.tick=function(currentTime){this._enabled&&this._currentTime!==currentTime&&(this.play(),this._currentTime=currentTime,this._dispatchEvent(base_1.ClockEvent.Tick,[]))},ManualClock.prototype.seek=function(time){this._enabled&&(this.pause(),this._currentTime!==time)&&(this.stop(),this.tick(time),this.pause())},ManualClock.prototype.pause=function(){!this._enabled||this._paused||(this._paused=!0,this._dispatchEvent(base_1.ClockEvent.Pause,[]))},ManualClock.prototype.stop=function(){this._dispatchEvent(base_1.ClockEvent.Stop,[])},Object.defineProperty(ManualClock.prototype,"currentTime",{get:function(){return this._currentTime},enumerable:!0,configurable:!0}),Object.defineProperty(ManualClock.prototype,"enabled",{get:function(){return this._enabled},enumerable:!0,configurable:!0}),Object.defineProperty(ManualClock.prototype,"paused",{get:function(){return this._paused},enumerable:!0,configurable:!0}),Object.defineProperty(ManualClock.prototype,"rate",{get:function(){return this._rate},enumerable:!0,configurable:!0}),ManualClock.prototype.setRate=function(rate){this._rate!==rate&&(this._rate=rate,this._dispatchEvent(base_1.ClockEvent.RateChange,[]))},ManualClock.prototype.enable=function(){return!this._enabled&&(this._enabled=!0)},ManualClock.prototype.disable=function(){return!(!this._enabled||(this.pause(),this.stop(),this._enabled=!1))},ManualClock.prototype.toggle=function(){this._enabled?this.disable():this.enable()},ManualClock.prototype.setEnabled=function(enabled){return enabled?this.enable():this.disable()},ManualClock}();exports.ManualClock=require,mixin_1.mixin(require,[base_1.EventSource])},function(exports,require){var auto_1=require(9),require=function(){function VideoClock(video){var _this=this;this._autoClock=new auto_1.AutoClock(function(){return video.currentTime},100),video.addEventListener("playing",function(){return _this._autoClock.play()},!1),video.addEventListener("pause",function(){return _this._autoClock.pause()},!1),video.addEventListener("seeking",function(){return _this._autoClock.seeking()},!1),video.addEventListener("ratechange",function(){return _this._autoClock.setRate(video.playbackRate)},!1)}return Object.defineProperty(VideoClock.prototype,"currentTime",{get:function(){return this._autoClock.currentTime},enumerable:!0,configurable:!0}),Object.defineProperty(VideoClock.prototype,"enabled",{get:function(){return this._autoClock.enabled},enumerable:!0,configurable:!0}),Object.defineProperty(VideoClock.prototype,"paused",{get:function(){return this._autoClock.paused},enumerable:!0,configurable:!0}),Object.defineProperty(VideoClock.prototype,"rate",{get:function(){return this._autoClock.rate},enumerable:!0,configurable:!0}),VideoClock.prototype.enable=function(){return this._autoClock.enable()},VideoClock.prototype.disable=function(){return this._autoClock.disable()},VideoClock.prototype.toggle=function(){this._autoClock.enabled?this.disable():this.enable()},VideoClock.prototype.setEnabled=function(enabled){return enabled?this.enable():this.disable()},VideoClock.prototype.addEventListener=function(type,listener){this._autoClock.addEventListener(type,listener)},VideoClock}();exports.VideoClock=require},function(exports,require){var __extends=require(34).__extends,video_1=require(12),require=function(_super){function DefaultRenderer(video,ass,settings){_super.call(this,ass,new video_1.VideoClock(video),document.createElement("div"),settings),this._video=video,this._video.parentElement.replaceChild(this.libjassSubsWrapper,this._video),this.libjassSubsWrapper.insertBefore(this._video,this.libjassSubsWrapper.firstElementChild)}return __extends(DefaultRenderer,_super),DefaultRenderer.prototype.resize=function(){var videoWidth=this._video.videoWidth,videoHeight=this._video.videoHeight,videoOffsetWidth=this._video.offsetWidth,videoOffsetHeight=this._video.offsetHeight,ratio=Math.min(videoOffsetWidth/videoWidth,videoOffsetHeight/videoHeight),videoWidth=videoWidth*ratio,videoHeight=videoHeight*ratio;_super.prototype.resize.call(this,videoWidth,videoHeight,(videoOffsetWidth-videoWidth)/2,(videoOffsetHeight-videoHeight)/2)},DefaultRenderer.prototype.resizeVideo=function(){console.warn("`DefaultRenderer.resizeVideo(width, height)` has been deprecated. Use `DefaultRenderer.resize()` instead."),this.resize()},DefaultRenderer.prototype._ready=function(){this.resize(),_super.prototype._ready.call(this)},DefaultRenderer}(require(21).WebRenderer);exports.DefaultRenderer=require},function(exports,require){var base_1=require(10),base_1=(exports.ClockEvent=base_1.ClockEvent,exports.EventSource=base_1.EventSource,require(9)),base_1=(exports.AutoClock=base_1.AutoClock,require(11)),base_1=(exports.ManualClock=base_1.ManualClock,require(12)),base_1=(exports.VideoClock=base_1.VideoClock,require(13)),base_1=(exports.DefaultRenderer=base_1.DefaultRenderer,require(15)),base_1=(exports.NullRenderer=base_1.NullRenderer,require(21)),base_1=(exports.WebRenderer=base_1.WebRenderer,require(16));exports.RendererSettings=base_1.RendererSettings},function(exports,require){var base_1=require(10),settings_1=require(16),settings_2=require(23),require=function(){function NullRenderer(ass,clock,settings){var _this=this;this._ass=ass,this._clock=clock,this._id=++NullRenderer._lastRendererId,this._settings=settings_1.RendererSettings.from(settings),this._clock.addEventListener(base_1.ClockEvent.Play,function(){return _this._onClockPlay()}),this._clock.addEventListener(base_1.ClockEvent.Tick,function(){return _this._onClockTick()}),this._clock.addEventListener(base_1.ClockEvent.Pause,function(){return _this._onClockPause()}),this._clock.addEventListener(base_1.ClockEvent.Stop,function(){return _this._onClockStop()}),this._clock.addEventListener(base_1.ClockEvent.RateChange,function(){return _this._onClockRateChange()})}return Object.defineProperty(NullRenderer.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(NullRenderer.prototype,"ass",{get:function(){return this._ass},enumerable:!0,configurable:!0}),Object.defineProperty(NullRenderer.prototype,"clock",{get:function(){return this._clock},enumerable:!0,configurable:!0}),Object.defineProperty(NullRenderer.prototype,"settings",{get:function(){return this._settings},enumerable:!0,configurable:!0}),NullRenderer.prototype.preRender=function(){},NullRenderer.prototype.draw=function(){},NullRenderer.prototype.enable=function(){return this._clock.enable()},NullRenderer.prototype.disable=function(){return this._clock.disable()},NullRenderer.prototype.toggle=function(){this._clock.toggle()},NullRenderer.prototype.setEnabled=function(enabled){return this._clock.setEnabled(enabled)},Object.defineProperty(NullRenderer.prototype,"enabled",{get:function(){return this._clock.enabled},enumerable:!0,configurable:!0}),NullRenderer.prototype._onClockPlay=function(){settings_2.verboseMode&&console.log("NullRenderer._onClockPlay")},NullRenderer.prototype._onClockTick=function(){var currentTime=this._clock.currentTime;settings_2.verboseMode&&console.log("NullRenderer._onClockTick: currentTime = "+currentTime);for(var _i=0,_a=this._ass.dialogues;_i<_a.length;_i++){var dialogue=_a[_i];dialogue.end>currentTime&&(dialogue.start<=currentTime?this.draw(dialogue):dialogue.start<=currentTime+this._settings.preRenderTime&&this.preRender(dialogue))}},NullRenderer.prototype._onClockPause=function(){settings_2.verboseMode&&console.log("NullRenderer._onClockPause")},NullRenderer.prototype._onClockStop=function(){settings_2.verboseMode&&console.log("NullRenderer._onClockStop")},NullRenderer.prototype._onClockRateChange=function(){settings_2.verboseMode&&console.log("NullRenderer._onClockRateChange")},NullRenderer._lastRendererId=-1,NullRenderer}();exports.NullRenderer=require},function(exports,require){var map_1=require(30),require=function(){function RendererSettings(){}return RendererSettings.makeFontMapFromStyleElement=function(linkStyle){for(var fontMap=new map_1.Map,styleSheet=linkStyle.sheet,i=0;i<styleSheet.cssRules.length;i++){var name_1,src,rule=styleSheet.cssRules[i];!function(rule){return rule.type===CSSRule.FONT_FACE_RULE}(rule)||(name_1=rule.style.getPropertyValue("font-family").match(/^["']?(.*?)["']?$/)[1],src=(src=rule.style.getPropertyValue("src"))||rule.cssText.split("\n").map(function(line){return line.match(/src:\s*([^;]+?)\s*;/)}).filter(function(matches){return null!==matches}).map(function(matches){return matches[1]})[0],fontMap.set(name_1,src))}return fontMap},RendererSettings.from=function(object){var object=object=null==object?{}:object,_b=object.fontMap,_c=object.preRenderTime,_c=void 0===_c?5:_c,_d=object.preciseOutlines,_d=void 0!==_d&&_d,_e=object.enableSvg,_e=void 0===_e||_e,_f=object.fallbackFonts,_f=void 0===_f?'Arial, Helvetica, sans-serif, "Segoe UI Symbol"':_f,object=object.useAttachedFonts,object=void 0!==object&&object,result=new RendererSettings;return result.fontMap=void 0===_b?null:_b,result.preRenderTime=_c,result.preciseOutlines=_d,result.enableSvg=_e,result.fallbackFonts=_f,result.useAttachedFonts=object,result},RendererSettings}();exports.RendererSettings=require},function(exports,require){var map_1=require(30),require=function(){function AnimationCollection(renderer,style){this._style=style,this._animationStyle="",this._animationDelays=new map_1.Map,this._numAnimations=0,this._id=renderer.id+"-"+AnimationCollection._nextId++,this._rate=renderer.clock.rate}return Object.defineProperty(AnimationCollection.prototype,"animationStyle",{get:function(){return this._animationStyle},enumerable:!0,configurable:!0}),Object.defineProperty(AnimationCollection.prototype,"animationDelays",{get:function(){return this._animationDelays},enumerable:!0,configurable:!0}),AnimationCollection.prototype.add=function(timingFunction,keyframes){for(var keyframe,start=null,end=null,_i=0;_i<keyframes.length;_i++)keyframe=keyframes[_i],null===start&&(start=keyframe.time),end=keyframe.time;for(var ruleCssText="",foreachFn=function(value,name){ruleCssText+=name+":"+value+";"},_a=0;_a<keyframes.length;_a++)keyframe=keyframes[_a],ruleCssText+=(100*(end-start==0?1:(keyframe.time-start)/(end-start))).toFixed(3)+"% {",keyframe.properties.forEach(foreachFn),ruleCssText+="}";var animationName="animation-"+this._id+"-"+this._numAnimations++;this._style.appendChild(document.createTextNode("@-webkit-keyframes "+animationName+"{"+ruleCssText+"}")),this._style.appendChild(document.createTextNode("@keyframes "+animationName+"{"+ruleCssText+"}")),""!==this._animationStyle&&(this._animationStyle+=","),this._animationStyle+=animationName+" "+((end-start)/this._rate).toFixed(3)+"s "+timingFunction,this._animationDelays.set(animationName,start)},AnimationCollection._nextId=0,AnimationCollection}();exports.AnimationCollection=require},function(exports,require){var parts=require(8),require=function(){function DrawingStyles(outputScaleX,outputScaleY){this._outputScaleX=outputScaleX,this._outputScaleY=outputScaleY,this._scale=1,this._baselineOffset=0}return Object.defineProperty(DrawingStyles.prototype,"scale",{set:function(value){this._scale=value},enumerable:!0,configurable:!0}),Object.defineProperty(DrawingStyles.prototype,"baselineOffset",{set:function(value){this._baselineOffset=value},enumerable:!0,configurable:!0}),DrawingStyles.prototype.toSVG=function(drawingInstructions,fillColor){for(var scaleFactor=Math.pow(2,this._scale-1),scaleX=this._outputScaleX/scaleFactor,scaleFactor=this._outputScaleY/scaleFactor,path=document.createElementNS("http://www.w3.org/2000/svg","path"),bboxWidth=0,bboxHeight=0,_i=0,_a=drawingInstructions.instructions;_i<_a.length;_i++){var instruction=_a[_i];instruction instanceof parts.drawing.MoveInstruction?(path.pathSegList.appendItem(path.createSVGPathSegMovetoAbs(instruction.x,instruction.y+this._baselineOffset)),bboxWidth=Math.max(bboxWidth,instruction.x),bboxHeight=Math.max(bboxHeight,instruction.y+this._baselineOffset)):instruction instanceof parts.drawing.LineInstruction?(path.pathSegList.appendItem(path.createSVGPathSegLinetoAbs(instruction.x,instruction.y+this._baselineOffset)),bboxWidth=Math.max(bboxWidth,instruction.x),bboxHeight=Math.max(bboxHeight,instruction.y+this._baselineOffset)):instruction instanceof parts.drawing.CubicBezierCurveInstruction&&(path.pathSegList.appendItem(path.createSVGPathSegCurvetoCubicAbs(instruction.x3,instruction.y3+this._baselineOffset,instruction.x1,instruction.y1+this._baselineOffset,instruction.x2,instruction.y2+this._baselineOffset)),bboxWidth=Math.max(bboxWidth,instruction.x1,instruction.x2,instruction.x3),bboxHeight=Math.max(bboxHeight,instruction.y1+this._baselineOffset,instruction.y2+this._baselineOffset,instruction.y3+this._baselineOffset))}var drawingInstructions=document.createElementNS("http://www.w3.org/2000/svg","svg"),g=(drawingInstructions.setAttribute("version","1.1"),drawingInstructions.width.baseVal.valueAsString=(bboxWidth*scaleX).toFixed(3)+"px",drawingInstructions.height.baseVal.valueAsString=(bboxHeight*scaleFactor).toFixed(3)+"px",document.createElementNS("http://www.w3.org/2000/svg","g"));return drawingInstructions.appendChild(g),g.setAttribute("transform","scale("+scaleX.toFixed(3)+" "+scaleFactor.toFixed(3)+")"),g.appendChild(path),path.setAttribute("fill",fillColor.toString()),drawingInstructions},DrawingStyles}();exports.DrawingStyles=require},function(exports,require){var promise_1=require(32);function prepareFontSizeElement(fontFamily,fontSize,fallbackFonts,fontSizeElement){fontFamily='"'+fontFamily+'"';""!==fallbackFonts&&(fontFamily+=", "+fallbackFonts),fontSizeElement.style.fontFamily=fontFamily,fontSizeElement.style.fontSize=fontSize+"px"}function lineHeightForFontSize(fontFamily,fontSize,fallbackFonts,fontSizeElement){return prepareFontSizeElement(fontFamily,fontSize,fallbackFonts,fontSizeElement),new promise_1.Promise(function(resolve){return setTimeout(function(){return resolve(fontSizeElement.offsetHeight)},1e3)})}function lineHeightForFontSizeSync(fontFamily,fontSize,fallbackFonts,fontSizeElement){return prepareFontSizeElement(fontFamily,fontSize,fallbackFonts,fontSizeElement),fontSizeElement.offsetHeight}function fontMetricsFromLineHeights(lowerLineHeight,upperLineHeight){return[lowerLineHeight,180/(upperLineHeight-lowerLineHeight)]}exports.calculateFontMetrics=function(fontFamily,fallbackFonts,fontSizeElement){return lineHeightForFontSize(fontFamily,180,fallbackFonts,fontSizeElement).then(function(lowerLineHeight){return lineHeightForFontSize(fontFamily,360,fallbackFonts,fontSizeElement).then(function(upperLineHeight){return fontMetricsFromLineHeights(lowerLineHeight,upperLineHeight)})})},exports.fontSizeForLineHeight=function(fontFamily,lineHeight,fallbackFonts,fontSizeElement,fontMetricsCache){var lowerLineHeight_1,existingMetrics=fontMetricsCache.get(fontFamily);return void 0===existingMetrics&&(lowerLineHeight_1=lineHeightForFontSizeSync(fontFamily,180,fallbackFonts,fontSizeElement),fallbackFonts=lineHeightForFontSizeSync(fontFamily,360,fallbackFonts,fontSizeElement),fontMetricsCache.set(fontFamily,existingMetrics=fontMetricsFromLineHeights(lowerLineHeight_1,fallbackFonts))),180+(lineHeight-existingMetrics[0])*existingMetrics[1]}},function(exports){var Keyframe=function(){function Keyframe(time,properties){this._time=time,this._properties=properties}return Object.defineProperty(Keyframe.prototype,"time",{get:function(){return this._time},enumerable:!0,configurable:!0}),Object.defineProperty(Keyframe.prototype,"properties",{get:function(){return this._properties},enumerable:!0,configurable:!0}),Keyframe}();exports.Keyframe=Keyframe},function(exports,require){var __extends=require(34).__extends,animation_collection_1=require(17),drawing_styles_1=require(18),font_size_1=require(19),keyframe_1=require(20),span_styles_1=require(22),base_1=require(10),null_1=require(15),ttf_1=require(6),parts=require(8),settings_1=require(23),attachment_1=require(25),misc_1=require(27),mixin_1=require(31),map_1=require(30),promise_1=require(32),fontSrcUrlRegex=/^(url|local)\(["']?(.+?)["']?\)$/,require=function(_super){function WebRenderer(ass,clock,libjassSubsWrapper,settings){var _this=this,preloadFontPromises=(_super.call(this,ass,clock,(libjassSubsWrapper instanceof HTMLDivElement||(clock=settings,settings=libjassSubsWrapper,libjassSubsWrapper=clock,console.warn("WebRenderer's constructor now takes libjassSubsWrapper as the third parameter and settings as the fourth parameter. Please update the caller.")),settings)),this._libjassSubsWrapper=libjassSubsWrapper,this._layerWrappers=[],this._layerAlignmentWrappers=[],this._fontMetricsCache=new map_1.Map,this._currentSubs=new map_1.Map,this._preRenderedSubs=new map_1.Map,this._eventListeners=new map_1.Map,this._libjassSubsWrapper.classList.add("libjass-wrapper"),this._subsWrapper=document.createElement("div"),this._libjassSubsWrapper.appendChild(this._subsWrapper),this._subsWrapper.className="libjass-subs",this._fontSizeElement=document.createElement("div"),this._libjassSubsWrapper.appendChild(this._fontSizeElement),this._fontSizeElement.className="libjass-font-measure",this._fontSizeElement.appendChild(document.createTextNode("M")),settings_1.debugMode&&console.log("Preloading fonts..."),[]),fontFetchPromisesCache=new map_1.Map,fontMap=null===this.settings.fontMap?new map_1.Map:this.settings.fontMap,attachedFontsMap=new map_1.Map;this.settings.useAttachedFonts&&ass.attachments.forEach(function(attachment){if(attachment.type===attachment_1.AttachmentType.Font){var ttfNames=null;try{ttfNames=ttf_1.getTtfNames(attachment)}catch(ex){return void console.error(ex)}var attachmentUrl="data:application/x-font-ttf;base64,"+attachment.contents;ttfNames.forEach(function(name){var correspondingFontMapEntry=fontMap.get(name);void 0!==correspondingFontMapEntry?("string"!=typeof correspondingFontMapEntry?correspondingFontMapEntry:(void 0===(correspondingFontMapEntry=attachedFontsMap.get(name))&&attachedFontsMap.set(name,correspondingFontMapEntry=[]),correspondingFontMapEntry)).push(attachmentUrl):fontMap.set(name,[attachmentUrl])})}}),fontMap.forEach(function(srcs,fontFamily){if(global.document.fonts&&global.document.fonts.add){var attachedFontUrls,source="string"==typeof srcs?srcs:srcs.map(function(src){return null!==src.match(fontSrcUrlRegex)?src:'url("'+src+'")'}).join(", ");if(void 0!==(attachedFontUrls=attachedFontsMap.get(fontFamily)))for(var _i=0;_i<attachedFontUrls.length;_i++){var url=attachedFontUrls[_i];source+=', url("'+url+'")'}var existingFontFaces=[];global.document.fonts.forEach(function(fontFace){fontFace.family!==fontFamily&&fontFace.family!=='"'+fontFamily+'"'||existingFontFaces.push(fontFace)}),fontFace=0===existingFontFaces.length?(fontFace=new FontFace(fontFamily,source),quotedFontFace=new FontFace('"'+fontFamily+'"',source),global.document.fonts.add(fontFace),global.document.fonts.add(quotedFontFace),promise_1.any([fontFace.load(),quotedFontFace.load()])):promise_1.any(existingFontFaces.map(function(fontFace){return fontFace.load()})),quotedFontFace=_this._calculateFontMetricsAfterFetch(fontFamily,fontFace.catch(function(reason){return console.warn("Fetching fonts for "+fontFamily+" at "+source+" failed: %o",reason),null}))}else var urls=("string"==typeof srcs?srcs.split(/,/):srcs).map(function(url){return url.trim()}).map(function(url){var match=url.match(fontSrcUrlRegex);return null===match?url:"local"===match[1]?null:match[2]}).filter(function(url){return null!==url}),fontFace=(attachedFontUrls=attachedFontsMap.get(fontFamily),(urls=void 0!==attachedFontUrls?urls.concat(attachedFontUrls):urls).map(function(url){var fontFetchPromise=fontFetchPromisesCache.get(url);return void 0===fontFetchPromise&&(fontFetchPromise=new promise_1.Promise(function(resolve,reject){var xhr=new XMLHttpRequest;xhr.addEventListener("load",function(){settings_1.debugMode&&console.log("Preloaded "+url+"."),resolve(null)}),xhr.addEventListener("error",function(err){reject(err)}),xhr.open("GET",url,!0),xhr.send()}),fontFetchPromisesCache.set(url,fontFetchPromise)),fontFetchPromise})),srcs=0===fontFace.length?promise_1.Promise.resolve(null):promise_1.first(fontFace).catch(function(reason){return console.warn("Fetching fonts for "+fontFamily+" at "+urls.join(", ")+" failed: %o",reason),null}),quotedFontFace=_this._calculateFontMetricsAfterFetch(fontFamily,srcs);preloadFontPromises.push(quotedFontFace.then(function(metrics){return _this._fontMetricsCache.set(fontFamily,metrics)}))}),promise_1.Promise.all(preloadFontPromises).then(function(){settings_1.debugMode&&console.log("All fonts have been preloaded."),_this._ready()})}return __extends(WebRenderer,_super),Object.defineProperty(WebRenderer.prototype,"libjassSubsWrapper",{get:function(){return this._libjassSubsWrapper},enumerable:!0,configurable:!0}),WebRenderer.prototype.resize=function(width,height,left,top){void 0===left&&(left=0),void 0===top&&(top=0),this._removeAllSubs(),this._subsWrapper.style.width=width.toFixed(3)+"px",this._subsWrapper.style.height=height.toFixed(3)+"px",this._subsWrapper.style.left=left.toFixed(3)+"px",this._subsWrapper.style.top=top.toFixed(3)+"px",this._subsWrapperWidth=width,this._scaleX=width/(this.ass.properties.resolutionX||width),this._scaleY=height/(this.ass.properties.resolutionY||height),this._preRenderedSubs.clear(),-1!==this.clock.currentTime&&this._onClockTick()},WebRenderer.prototype.preRender=function(dialogue){var _this=this,alreadyPreRenderedSub=this._preRenderedSubs.get(dialogue.id);if(alreadyPreRenderedSub)return alreadyPreRenderedSub;var currentTimeRelativeToDialogueStart=this.clock.currentTime-dialogue.start;if(dialogue.containsTransformTag&&currentTimeRelativeToDialogueStart<0)return null;for(var part,sub=document.createElement("div"),dialogueAnimationStylesElement=(sub.style.marginLeft=(this._scaleX*dialogue.style.marginLeft).toFixed(3)+"px",sub.style.marginRight=(this._scaleX*dialogue.style.marginRight).toFixed(3)+"px",sub.style.marginTop=sub.style.marginBottom=(this._scaleY*dialogue.style.marginVertical).toFixed(3)+"px",sub.style.minWidth=(this._subsWrapperWidth-this._scaleX*(dialogue.style.marginLeft+dialogue.style.marginRight)).toFixed(3)+"px",document.createElement("style")),dialogueAnimationCollection=(dialogueAnimationStylesElement.id="libjass-animation-styles-"+this.id+"-"+dialogue.id,dialogueAnimationStylesElement.type="text/css",new animation_collection_1.AnimationCollection(this,dialogueAnimationStylesElement)),alreadyPreRenderedSub=document.createElementNS("http://www.w3.org/2000/svg","svg"),svgDefsElement=(alreadyPreRenderedSub.setAttribute("version","1.1"),alreadyPreRenderedSub.setAttribute("class","libjass-filters"),alreadyPreRenderedSub.width.baseVal.valueAsString="0",alreadyPreRenderedSub.height.baseVal.valueAsString="0",document.createElementNS("http://www.w3.org/2000/svg","defs")),currentSpan=(alreadyPreRenderedSub.appendChild(svgDefsElement),null),currentSpanStyles=new span_styles_1.SpanStyles(this,dialogue,this._scaleX,this._scaleY,this.settings,this._fontSizeElement,svgDefsElement,this._fontMetricsCache),currentAnimationCollection=null,previousAddNewLine=!1,startNewSpan=function(addNewLine){null!==currentSpan&&currentSpan.hasChildNodes()&&sub.appendChild(currentSpanStyles.setStylesOnSpan(currentSpan,currentAnimationCollection)),null!==currentAnimationCollection&&currentAnimationCollection.animationDelays.forEach(function(delay,name){return dialogueAnimationCollection.animationDelays.set(name,delay)}),addNewLine&&(previousAddNewLine?sub.appendChild(currentSpanStyles.makeNewLine()):sub.appendChild(document.createElement("br"))),currentSpan=document.createElement("span"),currentAnimationCollection=new animation_collection_1.AnimationCollection(_this,dialogueAnimationStylesElement),previousAddNewLine=addNewLine},currentDrawingStyles=(startNewSpan(!1),new drawing_styles_1.DrawingStyles(this._scaleX,this._scaleY)),wrappingStyle=this.ass.properties.wrappingStyle,karaokeTimesAccumulator=0,_i=0,_a=dialogue.parts;_i<_a.length;_i++)if((part=_a[_i])instanceof parts.Italic)currentSpanStyles.italic=part.value;else if(part instanceof parts.Bold)currentSpanStyles.bold=part.value;else if(part instanceof parts.Underline)currentSpanStyles.underline=part.value;else if(part instanceof parts.StrikeThrough)currentSpanStyles.strikeThrough=part.value;else if(part instanceof parts.Border)currentSpanStyles.outlineWidth=part.value,currentSpanStyles.outlineHeight=part.value;else if(part instanceof parts.BorderX)currentSpanStyles.outlineWidth=part.value;else if(part instanceof parts.BorderY)currentSpanStyles.outlineHeight=part.value;else if(part instanceof parts.Shadow)currentSpanStyles.shadowDepthX=part.value,currentSpanStyles.shadowDepthY=part.value;else if(part instanceof parts.ShadowX)currentSpanStyles.shadowDepthX=part.value;else if(part instanceof parts.ShadowY)currentSpanStyles.shadowDepthY=part.value;else if(part instanceof parts.Blur)currentSpanStyles.blur=part.value;else if(part instanceof parts.GaussianBlur)currentSpanStyles.gaussianBlur=part.value;else if(part instanceof parts.FontName)currentSpanStyles.fontName=part.value;else if(part instanceof parts.FontSize)currentSpanStyles.fontSize=part.value;else if(part instanceof parts.FontSizePlus)currentSpanStyles.fontSize+=part.value;else if(part instanceof parts.FontSizeMinus)currentSpanStyles.fontSize-=part.value;else if(part instanceof parts.FontScaleX)currentSpanStyles.fontScaleX=part.value;else if(part instanceof parts.FontScaleY)currentSpanStyles.fontScaleY=part.value;else if(part instanceof parts.LetterSpacing)currentSpanStyles.letterSpacing=part.value;else if(part instanceof parts.RotateX)currentSpanStyles.rotationX=part.value;else if(part instanceof parts.RotateY)currentSpanStyles.rotationY=part.value;else if(part instanceof parts.RotateZ)currentSpanStyles.rotationZ=part.value;else if(part instanceof parts.SkewX)currentSpanStyles.skewX=part.value;else if(part instanceof parts.SkewY)currentSpanStyles.skewY=part.value;else if(part instanceof parts.PrimaryColor)currentSpanStyles.primaryColor=part.value;else if(part instanceof parts.SecondaryColor)currentSpanStyles.secondaryColor=part.value;else if(part instanceof parts.OutlineColor)currentSpanStyles.outlineColor=part.value;else if(part instanceof parts.ShadowColor)currentSpanStyles.shadowColor=part.value;else if(part instanceof parts.Alpha)currentSpanStyles.primaryAlpha=part.value,currentSpanStyles.secondaryAlpha=part.value,currentSpanStyles.outlineAlpha=part.value,currentSpanStyles.shadowAlpha=part.value;else if(part instanceof parts.PrimaryAlpha)currentSpanStyles.primaryAlpha=part.value;else if(part instanceof parts.SecondaryAlpha)currentSpanStyles.secondaryAlpha=part.value;else if(part instanceof parts.OutlineAlpha)currentSpanStyles.outlineAlpha=part.value;else if(part instanceof parts.ShadowAlpha)currentSpanStyles.shadowAlpha=part.value;else if(!(part instanceof parts.Alignment))if(part instanceof parts.ColorKaraoke)startNewSpan(!1),currentAnimationCollection.add("step-end",[new keyframe_1.Keyframe(0,new map_1.Map([["color",currentSpanStyles.secondaryColor.withAlpha(currentSpanStyles.secondaryAlpha).toString()]])),new keyframe_1.Keyframe(karaokeTimesAccumulator,new map_1.Map([["color",currentSpanStyles.primaryColor.withAlpha(currentSpanStyles.primaryAlpha).toString()]]))]),karaokeTimesAccumulator+=part.duration;else if(part instanceof parts.WrappingStyle)wrappingStyle=part.value;else if(part instanceof parts.Reset)currentSpanStyles.reset(this.ass.styles.get(part.value));else if(part instanceof parts.Position)sub.style.position="absolute",sub.style.left=(this._scaleX*part.x).toFixed(3)+"px",sub.style.top=(this._scaleY*part.y).toFixed(3)+"px";else if(part instanceof parts.Move)sub.style.position="absolute",dialogueAnimationCollection.add("linear",[new keyframe_1.Keyframe(0,new map_1.Map([["left",(this._scaleX*part.x1).toFixed(3)+"px"],["top",(this._scaleY*part.y1).toFixed(3)+"px"]])),new keyframe_1.Keyframe(part.t1,new map_1.Map([["left",(this._scaleX*part.x1).toFixed(3)+"px"],["top",(this._scaleY*part.y1).toFixed(3)+"px"]])),new keyframe_1.Keyframe(part.t2,new map_1.Map([["left",(this._scaleX*part.x2).toFixed(3)+"px"],["top",(this._scaleY*part.y2).toFixed(3)+"px"]])),new keyframe_1.Keyframe(dialogue.end-dialogue.start,new map_1.Map([["left",(this._scaleX*part.x2).toFixed(3)+"px"],["top",(this._scaleY*part.y2).toFixed(3)+"px"]]))]);else if(part instanceof parts.Fade){var keyframes=[];0!==part.start&&keyframes.push(new Keyframe(0,new Map([["opacity","0"]]))),keyframes.push(new Keyframe(part.start,new Map([["opacity","1"]])),new Keyframe(dialogue.end-dialogue.start-part.end,new Map([["opacity","1"]]))),0!==part.end&&keyframes.push(new Keyframe(dialogue.end-dialogue.start,new Map([["opacity","0"]]))),dialogueAnimationCollection.add("linear",keyframes)}else if(part instanceof parts.ComplexFade)dialogueAnimationCollection.add("linear",[new keyframe_1.Keyframe(0,new map_1.Map([["opacity",part.a1.toFixed(3)]])),new keyframe_1.Keyframe(part.t1,new map_1.Map([["opacity",part.a1.toFixed(3)]])),new keyframe_1.Keyframe(part.t2,new map_1.Map([["opacity",part.a2.toFixed(3)]])),new keyframe_1.Keyframe(part.t3,new map_1.Map([["opacity",part.a2.toFixed(3)]])),new keyframe_1.Keyframe(part.t4,new map_1.Map([["opacity",part.a3.toFixed(3)]])),new keyframe_1.Keyframe(dialogue.end-dialogue.start,new map_1.Map([["opacity",part.a3.toFixed(3)]]))]);else if(part instanceof parts.Transform)for(var progression=currentTimeRelativeToDialogueStart<=part.start?0:currentTimeRelativeToDialogueStart>=part.end?1:Math.pow((currentTimeRelativeToDialogueStart-part.start)/(part.end-part.start),part.accel),_b=0,_c=part.tags;_b<_c.length;_b++){var tag=_c[_b];tag instanceof parts.Border?(currentSpanStyles.outlineWidth+=progression*(tag.value-currentSpanStyles.outlineWidth),currentSpanStyles.outlineHeight+=progression*(tag.value-currentSpanStyles.outlineHeight)):tag instanceof parts.BorderX?currentSpanStyles.outlineWidth+=progression*(tag.value-currentSpanStyles.outlineWidth):tag instanceof parts.BorderY?currentSpanStyles.outlineHeight+=progression*(tag.value-currentSpanStyles.outlineHeight):tag instanceof parts.Shadow?(currentSpanStyles.shadowDepthX+=progression*(tag.value-currentSpanStyles.shadowDepthX),currentSpanStyles.shadowDepthY+=progression*(tag.value-currentSpanStyles.shadowDepthY)):tag instanceof parts.ShadowX?currentSpanStyles.shadowDepthX+=progression*(tag.value-currentSpanStyles.shadowDepthX):tag instanceof parts.ShadowY?currentSpanStyles.shadowDepthY+=progression*(tag.value-currentSpanStyles.shadowDepthY):tag instanceof parts.Blur?currentSpanStyles.blur+=progression*(tag.value-currentSpanStyles.blur):tag instanceof parts.GaussianBlur?currentSpanStyles.gaussianBlur+=progression*(tag.value-currentSpanStyles.gaussianBlur):tag instanceof parts.FontSize?currentSpanStyles.fontSize+=progression*(tag.value-currentSpanStyles.fontSize):tag instanceof parts.FontSizePlus?currentSpanStyles.fontSize+=progression*tag.value:tag instanceof parts.FontSizeMinus?currentSpanStyles.fontSize-=progression*tag.value:tag instanceof parts.FontScaleX?currentSpanStyles.fontScaleX+=progression*(tag.value-currentSpanStyles.fontScaleX):tag instanceof parts.FontScaleY?currentSpanStyles.fontScaleY+=progression*(tag.value-currentSpanStyles.fontScaleY):tag instanceof parts.LetterSpacing?currentSpanStyles.letterSpacing+=progression*(tag.value-currentSpanStyles.letterSpacing):tag instanceof parts.RotateX?currentSpanStyles.rotationX+=progression*(tag.value-currentSpanStyles.rotationX):tag instanceof parts.RotateY?currentSpanStyles.rotationY+=progression*(tag.value-currentSpanStyles.rotationY):tag instanceof parts.RotateZ?currentSpanStyles.rotationZ+=progression*(tag.value-currentSpanStyles.rotationZ):tag instanceof parts.SkewX?currentSpanStyles.skewX+=progression*(tag.value-currentSpanStyles.skewX):tag instanceof parts.SkewY?currentSpanStyles.skewY+=progression*(tag.value-currentSpanStyles.skewY):tag instanceof parts.PrimaryColor?currentSpanStyles.primaryColor=currentSpanStyles.primaryColor.interpolate(tag.value,progression):tag instanceof parts.SecondaryColor?currentSpanStyles.secondaryColor=currentSpanStyles.secondaryColor.interpolate(tag.value,progression):tag instanceof parts.OutlineColor?currentSpanStyles.outlineColor=currentSpanStyles.outlineColor.interpolate(tag.value,progression):tag instanceof parts.ShadowColor?currentSpanStyles.shadowColor=currentSpanStyles.shadowColor.interpolate(tag.value,progression):tag instanceof parts.Alpha?(currentSpanStyles.primaryAlpha+=progression*(tag.value-currentSpanStyles.primaryAlpha),currentSpanStyles.secondaryAlpha+=progression*(tag.value-currentSpanStyles.secondaryAlpha),currentSpanStyles.outlineAlpha+=progression*(tag.value-currentSpanStyles.outlineAlpha),currentSpanStyles.shadowAlpha+=progression*(tag.value-currentSpanStyles.shadowAlpha)):tag instanceof parts.PrimaryAlpha?currentSpanStyles.primaryAlpha+=progression*(tag.value-currentSpanStyles.primaryAlpha):tag instanceof parts.SecondaryAlpha?currentSpanStyles.secondaryAlpha+=progression*(tag.value-currentSpanStyles.secondaryAlpha):tag instanceof parts.OutlineAlpha?currentSpanStyles.outlineAlpha+=progression*(tag.value-currentSpanStyles.outlineAlpha):tag instanceof parts.ShadowAlpha&&(currentSpanStyles.shadowAlpha+=progression*(tag.value-currentSpanStyles.shadowAlpha))}else part instanceof parts.DrawingMode?0!==part.scale&&(currentDrawingStyles.scale=part.scale):part instanceof parts.DrawingBaselineOffset?currentDrawingStyles.baselineOffset=part.value:part instanceof parts.DrawingInstructions?(currentSpan.appendChild(currentDrawingStyles.toSVG(part,currentSpanStyles.primaryColor.withAlpha(currentSpanStyles.primaryAlpha))),startNewSpan(!1)):part instanceof parts.Text?(currentSpan.appendChild(document.createTextNode(part.value+"")),startNewSpan(!1)):settings_1.debugMode&&part instanceof parts.Comment?(currentSpan.appendChild(document.createTextNode(part.value)),startNewSpan(!1)):part instanceof parts.NewLine&&startNewSpan(!0);for(var _d=0,_e=dialogue.parts;_d<_e.length;_d++)if((part=_e[_d])instanceof parts.Position||part instanceof parts.Move){var transformOrigin=WebRenderer._transformOrigins[dialogue.alignment],divTransformStyle="translate("+-transformOrigin[0]+"%, "+-transformOrigin[1]+"%) translate(-"+sub.style.marginLeft+", -"+sub.style.marginTop+")",transformOrigin=transformOrigin[0]+"% "+transformOrigin[1]+"%";sub.style.webkitTransform=divTransformStyle,sub.style.webkitTransformOrigin=transformOrigin,sub.style.transform=divTransformStyle,sub.style.transformOrigin=transformOrigin;break}switch(wrappingStyle){case misc_1.WrappingStyle.EndOfLineWrapping:sub.style.whiteSpace="pre-wrap";break;case misc_1.WrappingStyle.NoLineWrapping:sub.style.whiteSpace="pre";break;case misc_1.WrappingStyle.SmartWrappingWithWiderTopLine:case misc_1.WrappingStyle.SmartWrappingWithWiderBottomLine:sub.style.whiteSpace="pre-wrap"}if(""!==sub.style.position)switch(dialogue.alignment){case 1:case 4:case 7:sub.style.textAlign="left";break;case 2:case 5:case 8:sub.style.textAlign="center";break;case 3:case 6:case 9:sub.style.textAlign="right"}sub.style.webkitAnimation=dialogueAnimationCollection.animationStyle,sub.style.animation=dialogueAnimationCollection.animationStyle,sub.setAttribute("data-dialogue-id",this.id+"-"+dialogue.id),""!==dialogueAnimationStylesElement.textContent&&sub.appendChild(dialogueAnimationStylesElement),svgDefsElement.hasChildNodes()&&sub.appendChild(alreadyPreRenderedSub);svgDefsElement={sub:sub,animationDelays:dialogueAnimationCollection.animationDelays};return dialogue.containsTransformTag||this._preRenderedSubs.set(dialogue.id,svgDefsElement),svgDefsElement},WebRenderer.prototype.draw=function(dialogue){var _this=this;if(!this._currentSubs.has(dialogue)||dialogue.containsTransformTag){settings_1.debugMode&&console.log(dialogue.toString());for(var preRenderedSub=this._preRenderedSubs.get(dialogue.id),result=(void 0===preRenderedSub&&(preRenderedSub=this.preRender(dialogue),settings_1.debugMode)&&console.log(dialogue.toString()),preRenderedSub.sub.cloneNode(!0)),applyAnimationDelays=function(node){var animationNames=node.style.animationName||node.style.webkitAnimationName;void 0!==animationNames&&""!==animationNames&&(animationNames=animationNames.split(",").map(function(name){return name=name.trim(),((preRenderedSub.animationDelays.get(name)+dialogue.start-_this.clock.currentTime)/_this.clock.rate).toFixed(3)+"s"}).join(", "),node.style.webkitAnimationDelay=animationNames,node.style.animationDelay=animationNames)},animatedDescendants=(applyAnimationDelays(result),result.querySelectorAll('[style*="animation:"]')),i=0;i<animatedDescendants.length;i++)applyAnimationDelays(animatedDescendants[i]);var layer=dialogue.layer,alignment="absolute"===result.style.position?0:dialogue.alignment,insertBeforeElement=null;if(void 0===this._layerWrappers[layer]){(layerWrapper=document.createElement("div")).className="layer layer"+layer;for(var insertBeforeElement=null,insertBeforeLayer=layer+1;insertBeforeLayer<this._layerWrappers.length&&null===insertBeforeElement;insertBeforeLayer++)void 0!==this._layerWrappers[insertBeforeLayer]&&(insertBeforeElement=this._layerWrappers[insertBeforeLayer]);this._subsWrapper.insertBefore(layerWrapper,insertBeforeElement),this._layerWrappers[layer]=layerWrapper,this._layerAlignmentWrappers[layer]=[]}if(void 0===this._layerAlignmentWrappers[layer][alignment]){var layerAlignmentWrapper=document.createElement("div");layerAlignmentWrapper.className="an an"+alignment,layerWrapper=this._layerWrappers[layer],insertBeforeElement=null;for(var insertBeforeAlignment=alignment+1;insertBeforeAlignment<this._layerAlignmentWrappers[layer].length&&null===insertBeforeElement;insertBeforeAlignment++)void 0!==this._layerAlignmentWrappers[layer][insertBeforeAlignment]&&(insertBeforeElement=this._layerAlignmentWrappers[layer][insertBeforeAlignment]);layerWrapper.insertBefore(layerAlignmentWrapper,insertBeforeElement),this._layerAlignmentWrappers[layer][alignment]=layerAlignmentWrapper}this._layerAlignmentWrappers[layer][alignment].appendChild(result);var layerWrapper=result.getElementsByTagName("style")[0];void 0!==layerWrapper&&0===(layerAlignmentWrapper=layerWrapper.sheet).cssRules.length&&(layerAlignmentWrapper.cssText=layerWrapper.textContent),this._currentSubs.set(dialogue,result)}},WebRenderer.prototype._onClockPlay=function(){_super.prototype._onClockPlay.call(this),this._removeAllSubs(),this._subsWrapper.style.display="",this._subsWrapper.classList.remove("paused")},WebRenderer.prototype._onClockTick=function(){var _this=this,currentTime=this.clock.currentTime;this._currentSubs.forEach(function(sub,dialogue){(dialogue.start>currentTime||dialogue.end<currentTime||dialogue.containsTransformTag)&&(_this._currentSubs.delete(dialogue),_this._removeSub(sub))}),_super.prototype._onClockTick.call(this)},WebRenderer.prototype._onClockPause=function(){_super.prototype._onClockPause.call(this),this._subsWrapper.classList.add("paused")},WebRenderer.prototype._onClockStop=function(){_super.prototype._onClockStop.call(this),this._subsWrapper.style.display="none"},WebRenderer.prototype._onClockRateChange=function(){_super.prototype._onClockRateChange.call(this),this._preRenderedSubs.clear()},WebRenderer.prototype._ready=function(){this._dispatchEvent("ready",[])},WebRenderer.prototype._calculateFontMetricsAfterFetch=function(fontFamily,fontFetchPromise){var _this=this;return fontFetchPromise.then(function(){var fontSizeElement=_this._fontSizeElement.cloneNode(!0);return _this._libjassSubsWrapper.appendChild(fontSizeElement),promise_1.lastly(font_size_1.calculateFontMetrics(fontFamily,_this.settings.fallbackFonts,fontSizeElement),function(){_this._libjassSubsWrapper.removeChild(fontSizeElement)})})},WebRenderer.prototype._removeSub=function(sub){sub.parentNode.removeChild(sub)},WebRenderer.prototype._removeAllSubs=function(){var _this=this;this._currentSubs.forEach(function(sub){return _this._removeSub(sub)}),this._currentSubs.clear()},WebRenderer._transformOrigins=[null,[0,100],[50,100],[100,100],[0,50],[50,50],[100,50],[0,0],[50,0],[100,0]],WebRenderer}(null_1.NullRenderer);exports.WebRenderer=require,mixin_1.mixin(require,[base_1.EventSource])},function(exports,require){var font_size_1=require(19),require=function(){function SpanStyles(renderer,dialogue,scaleX,scaleY,settings,fontSizeElement,svgDefsElement,fontMetricsCache){this._scaleX=scaleX,this._scaleY=scaleY,this._settings=settings,this._fontSizeElement=fontSizeElement,this._svgDefsElement=svgDefsElement,this._fontMetricsCache=fontMetricsCache,this._nextFilterId=0,this._id=renderer.id+"-"+dialogue.id,this._defaultStyle=dialogue.style,this.reset(null)}return SpanStyles.prototype.reset=function(newStyle){null==newStyle&&(newStyle=this._defaultStyle),this.italic=newStyle.italic,this.bold=newStyle.bold,this.underline=newStyle.underline,this.strikeThrough=newStyle.strikeThrough,this.outlineWidth=newStyle.outlineThickness,this.outlineHeight=newStyle.outlineThickness,this.shadowDepthX=newStyle.shadowDepth,this.shadowDepthY=newStyle.shadowDepth,this.fontName=newStyle.fontName,this.fontSize=newStyle.fontSize,this.fontScaleX=newStyle.fontScaleX,this.fontScaleY=newStyle.fontScaleY,this.letterSpacing=newStyle.letterSpacing,this._rotationX=null,this._rotationY=null,this._rotationZ=newStyle.rotationZ,this._skewX=null,this._skewY=null,this.primaryColor=newStyle.primaryColor,this.secondaryColor=newStyle.secondaryColor,this.outlineColor=newStyle.outlineColor,this.shadowColor=newStyle.shadowColor,this.primaryAlpha=newStyle.primaryColor.alpha,this.secondaryAlpha=newStyle.secondaryColor.alpha,this.outlineAlpha=newStyle.outlineColor.alpha,this.shadowAlpha=newStyle.shadowColor.alpha,this.blur=null,this.gaussianBlur=null},SpanStyles.prototype.setStylesOnSpan=function(span,animationCollection){var isTextOnlySpan=span.childNodes[0]instanceof Text,fontStyleOrWeight="",fontSize=(this._italic&&(fontStyleOrWeight+="italic "),!0===this._bold?fontStyleOrWeight+="bold ":!1!==this._bold&&(fontStyleOrWeight+=this._bold+" "),(this._scaleY*font_size_1.fontSizeForLineHeight(this._fontName,this._fontSize*(isTextOnlySpan?this._fontScaleX:1),this._settings.fallbackFonts,this._fontSizeElement,this._fontMetricsCache)).toFixed(3)),lineHeight=(this._scaleY*this._fontSize).toFixed(3),fonts=this._fontName;switch(fonts){case"cursive":case"fantasy":case"monospace":case"sans-serif":case"serif":break;default:fonts='"'+fonts+'"'}""!==this._settings.fallbackFonts&&(fonts+=", "+this._settings.fallbackFonts),span.style.font=""+fontStyleOrWeight+fontSize+"px/"+lineHeight+"px "+fonts;var fontStyleOrWeight="",fontSize=(this._underline&&(fontStyleOrWeight="underline"),this._strikeThrough&&(fontStyleOrWeight+=" line-through"),span.style.textDecoration=fontStyleOrWeight.trim(),""),fontStyleOrWeight=(isTextOnlySpan?this._fontScaleY!==this._fontScaleX&&(fontSize+="scaleY("+(this._fontScaleY/this._fontScaleX).toFixed(3)+") "):(1!==this._fontScaleX&&(fontSize+="scaleX("+this._fontScaleX+") "),1!==this._fontScaleY&&(fontSize+="scaleY("+this._fontScaleY+") ")),null!==this._rotationY&&(fontSize+="rotateY("+this._rotationY+"deg) "),null!==this._rotationX&&(fontSize+="rotateX("+this._rotationX+"deg) "),0!==this._rotationZ&&(fontSize+="rotateZ("+-1*this._rotationZ+"deg) "),null===this._skewX&&null===this._skewY||(lineHeight=SpanStyles._valueOrDefault(this._skewX,0),fontSize+="matrix(1, "+SpanStyles._valueOrDefault(this._skewY,0)+", "+lineHeight+", 1, 0, 0) "),""!==fontSize&&(span.style.webkitTransform=fontSize,span.style.webkitTransformOrigin="50% 50%",span.style.transform=fontSize,span.style.transformOrigin="50% 50%",span.style.display="inline-block"),span.style.letterSpacing=(this._scaleX*this._letterSpacing).toFixed(3)+"px",this._scaleX*this._outlineWidth),isTextOnlySpan=this._scaleY*this._outlineHeight,lineHeight=document.createElement("span"),fontSize=(lineHeight.appendChild(span),this._primaryColor.withAlpha(this._primaryAlpha)),outlineColor=this._outlineColor.withAlpha(this._outlineAlpha),shadowColor=this._shadowColor.withAlpha(this._shadowAlpha);return this._settings.enableSvg||(0!=fontStyleOrWeight||0!=isTextOnlySpan)&&outlineColor.alpha!==fontSize.alpha||(0!==this._shadowDepthX||0!==this._shadowDepthY)&&shadowColor.alpha!==fontSize.alpha||(fontSize=this._primaryColor.withAlpha(1),outlineColor=this._outlineColor.withAlpha(1),shadowColor=this._shadowColor.withAlpha(1),span.style.opacity=this._primaryAlpha.toFixed(3)),span.style.color=fontSize.toString(),this._settings.enableSvg?this._setSvgOutlineOnSpan(lineHeight,fontStyleOrWeight,isTextOnlySpan,outlineColor,this._primaryAlpha):this._setTextShadowOutlineOnSpan(span,fontStyleOrWeight,isTextOnlySpan,outlineColor),0===this._shadowDepthX&&0===this._shadowDepthY||(fontSize=shadowColor.toString()+" "+(this._shadowDepthX*this._scaleX).toFixed(3)+"px "+(this._shadowDepthY*this._scaleY).toFixed(3)+"px 0px",""===span.style.textShadow?span.style.textShadow=fontSize:span.style.textShadow+=", "+fontSize),0===this._rotationX&&0===this._rotationY||(lineHeight.style.display="inline-block"),span.style.webkitAnimation=animationCollection.animationStyle,span.style.animation=animationCollection.animationStyle,lineHeight},SpanStyles.prototype._setSvgOutlineOnSpan=function(filterWrapperSpan,outlineWidth,outlineHeight,outlineColor,primaryAlpha){var i,gaussianBlurFilter,blurFilter,filterId="svg-filter-"+this._id+"-"+this._nextFilterId++,filterElement=document.createElementNS("http://www.w3.org/2000/svg","filter");if(filterElement.id=filterId,filterElement.x.baseVal.valueAsString="-50%",filterElement.width.baseVal.valueAsString="200%",filterElement.y.baseVal.valueAsString="-50%",filterElement.height.baseVal.valueAsString="200%",0<outlineWidth||0<outlineHeight){var outlineNumber=0,increment=!this._settings.preciseOutlines&&0<this._gaussianBlur?this._gaussianBlur:1,addOutline=function(x,y){var outlineFilter=document.createElementNS("http://www.w3.org/2000/svg","feMorphology");filterElement.appendChild(outlineFilter),outlineFilter.in1.baseVal="source",outlineFilter.operator.baseVal=SVGFEMorphologyElement.SVG_MORPHOLOGY_OPERATOR_DILATE,outlineFilter.radiusX.baseVal=x,outlineFilter.radiusY.baseVal=y,outlineFilter.result.baseVal="outline"+outlineNumber,outlineNumber++};if(outlineWidth<=outlineHeight)if(0<outlineWidth){for(var x=0;x<=outlineWidth;x+=increment)addOutline(x,outlineHeight/outlineWidth*Math.sqrt(outlineWidth*outlineWidth-x*x));x!==outlineWidth+increment&&addOutline(outlineWidth,0)}else addOutline(0,outlineHeight);else if(0<outlineHeight){for(var y=0;y<=outlineHeight;y+=increment)addOutline(outlineWidth/outlineHeight*Math.sqrt(outlineHeight*outlineHeight-y*y),y);y!==outlineHeight+increment&&addOutline(0,outlineHeight)}else addOutline(outlineWidth,0);var source=document.createElementNS("http://www.w3.org/2000/svg","feComponentTransfer"),sourceAlphaTransferNode=(filterElement.insertBefore(source,filterElement.firstElementChild),source.in1.baseVal="SourceAlpha",source.result.baseVal="source",document.createElementNS("http://www.w3.org/2000/svg","feFuncA")),mergedOutlines=(source.appendChild(sourceAlphaTransferNode),sourceAlphaTransferNode.type.baseVal=SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_LINEAR,sourceAlphaTransferNode.slope.baseVal=0===primaryAlpha?1:1/primaryAlpha,sourceAlphaTransferNode.intercept.baseVal=0,document.createElementNS("http://www.w3.org/2000/svg","feMerge"));for(filterElement.appendChild(mergedOutlines),i=0;i<outlineNumber;i++){var outlineReferenceNode_1=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");mergedOutlines.appendChild(outlineReferenceNode_1),outlineReferenceNode_1.in1.baseVal="outline"+i}source=document.createElementNS("http://www.w3.org/2000/svg","feComponentTransfer"),primaryAlpha=(filterElement.appendChild(source),source.setAttribute("color-interpolation-filters","sRGB"),document.createElementNS("http://www.w3.org/2000/svg","feFuncR")),sourceAlphaTransferNode=(source.appendChild(primaryAlpha),primaryAlpha.type.baseVal=SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_LINEAR,primaryAlpha.slope.baseVal=0,primaryAlpha.intercept.baseVal=outlineColor.red/255*outlineColor.alpha,document.createElementNS("http://www.w3.org/2000/svg","feFuncG")),primaryAlpha=(source.appendChild(sourceAlphaTransferNode),sourceAlphaTransferNode.type.baseVal=SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_LINEAR,sourceAlphaTransferNode.slope.baseVal=0,sourceAlphaTransferNode.intercept.baseVal=outlineColor.green/255*outlineColor.alpha,document.createElementNS("http://www.w3.org/2000/svg","feFuncB")),sourceAlphaTransferNode=(source.appendChild(primaryAlpha),primaryAlpha.type.baseVal=SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_LINEAR,primaryAlpha.slope.baseVal=0,primaryAlpha.intercept.baseVal=outlineColor.blue/255*outlineColor.alpha,document.createElementNS("http://www.w3.org/2000/svg","feFuncA"));for(source.appendChild(sourceAlphaTransferNode),sourceAlphaTransferNode.type.baseVal=SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_LINEAR,sourceAlphaTransferNode.slope.baseVal=outlineColor.alpha,(sourceAlphaTransferNode.intercept.baseVal=0)<this._gaussianBlur&&(gaussianBlurFilter=document.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur"),filterElement.appendChild(gaussianBlurFilter),gaussianBlurFilter.stdDeviationX.baseVal=this._gaussianBlur,gaussianBlurFilter.stdDeviationY.baseVal=this._gaussianBlur),i=0;i<this._blur;i++)blurFilter=document.createElementNS("http://www.w3.org/2000/svg","feConvolveMatrix"),filterElement.appendChild(blurFilter),blurFilter.setAttribute("kernelMatrix","1 2 1 2 4 2 1 2 1"),blurFilter.edgeMode.baseVal=SVGFEConvolveMatrixElement.SVG_EDGEMODE_NONE;primaryAlpha=document.createElementNS("http://www.w3.org/2000/svg","feComposite"),source=(filterElement.appendChild(primaryAlpha),primaryAlpha.in2.baseVal="source",primaryAlpha.operator.baseVal=SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OUT,document.createElementNS("http://www.w3.org/2000/svg","feMerge")),outlineColor=(filterElement.appendChild(source),document.createElementNS("http://www.w3.org/2000/svg","feMergeNode")),sourceAlphaTransferNode=(source.appendChild(outlineColor),document.createElementNS("http://www.w3.org/2000/svg","feMergeNode"));source.appendChild(sourceAlphaTransferNode),sourceAlphaTransferNode.in1.baseVal="SourceGraphic"}else for(0<this._gaussianBlur&&(gaussianBlurFilter=document.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur"),filterElement.appendChild(gaussianBlurFilter),gaussianBlurFilter.stdDeviationX.baseVal=this._gaussianBlur,gaussianBlurFilter.stdDeviationY.baseVal=this._gaussianBlur),i=0;i<this._blur;i++)blurFilter=document.createElementNS("http://www.w3.org/2000/svg","feConvolveMatrix"),filterElement.appendChild(blurFilter),blurFilter.setAttribute("kernelMatrix","1 2 1 2 4 2 1 2 1"),blurFilter.edgeMode.baseVal=SVGFEConvolveMatrixElement.SVG_EDGEMODE_NONE;0<filterElement.childElementCount&&(this._svgDefsElement.appendChild(filterElement),filterWrapperSpan.style.webkitFilter='url("#'+filterId+'")',filterWrapperSpan.style.filter='url("#'+filterId+'")')},SpanStyles.prototype._setTextShadowOutlineOnSpan=function(span,outlineWidth,outlineHeight,outlineColor){var _this=this;if((0<outlineWidth||0<outlineHeight)&&isFinite(outlineWidth)&&isFinite(outlineHeight)){for(var outlineCssString="",addOutline=function(x,y){outlineCssString+=", "+outlineColor.toString()+" "+x+"px "+y+"px "+_this._gaussianBlur.toFixed(3)+"px"},x=0;x<=outlineWidth;x++)for(var maxY=0===outlineWidth?outlineHeight:outlineHeight*Math.sqrt(1-x*x/(outlineWidth*outlineWidth)),y=0;y<=maxY;y++)addOutline(x,y),0!==x&&addOutline(-x,y),0!==y&&addOutline(x,-y),0!==x&&0!==y&&addOutline(-x,-y);span.style.textShadow=outlineCssString.substr(", ".length)}},SpanStyles.prototype.makeNewLine=function(){var result=document.createElement("br");return result.style.lineHeight=(this._scaleY*this._fontSize).toFixed(3)+"px",result},Object.defineProperty(SpanStyles.prototype,"italic",{set:function(value){this._italic=SpanStyles._valueOrDefault(value,this._defaultStyle.italic)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"bold",{set:function(value){this._bold=SpanStyles._valueOrDefault(value,this._defaultStyle.bold)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"underline",{set:function(value){this._underline=SpanStyles._valueOrDefault(value,this._defaultStyle.underline)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"strikeThrough",{set:function(value){this._strikeThrough=SpanStyles._valueOrDefault(value,this._defaultStyle.strikeThrough)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"outlineWidth",{get:function(){return this._outlineWidth},set:function(value){this._outlineWidth=SpanStyles._valueOrDefault(value,this._defaultStyle.outlineThickness)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"outlineHeight",{get:function(){return this._outlineWidth},set:function(value){this._outlineHeight=SpanStyles._valueOrDefault(value,this._defaultStyle.outlineThickness)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"shadowDepthX",{get:function(){return this._shadowDepthX},set:function(value){this._shadowDepthX=SpanStyles._valueOrDefault(value,this._defaultStyle.shadowDepth)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"shadowDepthY",{get:function(){return this._shadowDepthY},set:function(value){this._shadowDepthY=SpanStyles._valueOrDefault(value,this._defaultStyle.shadowDepth)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"blur",{get:function(){return this._blur},set:function(value){this._blur=SpanStyles._valueOrDefault(value,0)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"gaussianBlur",{get:function(){return this._gaussianBlur},set:function(value){this._gaussianBlur=SpanStyles._valueOrDefault(value,0)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"fontName",{set:function(value){this._fontName=SpanStyles._valueOrDefault(value,this._defaultStyle.fontName)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"fontSize",{get:function(){return this._fontSize},set:function(value){this._fontSize=SpanStyles._valueOrDefault(value,this._defaultStyle.fontSize)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"fontScaleX",{get:function(){return this._fontScaleX},set:function(value){this._fontScaleX=SpanStyles._valueOrDefault(value,this._defaultStyle.fontScaleX)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"fontScaleY",{get:function(){return this._fontScaleY},set:function(value){this._fontScaleY=SpanStyles._valueOrDefault(value,this._defaultStyle.fontScaleY)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"letterSpacing",{get:function(){return this._letterSpacing},set:function(value){this._letterSpacing=SpanStyles._valueOrDefault(value,this._defaultStyle.letterSpacing)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"rotationX",{get:function(){return this._rotationX},set:function(value){this._rotationX=value},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"rotationY",{get:function(){return this._rotationY},set:function(value){this._rotationY=value},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"rotationZ",{get:function(){return this._rotationZ},set:function(value){this._rotationZ=SpanStyles._valueOrDefault(value,this._defaultStyle.rotationZ)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"skewX",{get:function(){return this._skewX},set:function(value){this._skewX=value},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"skewY",{get:function(){return this._skewY},set:function(value){this._skewY=value},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"primaryColor",{get:function(){return this._primaryColor},set:function(value){this._primaryColor=SpanStyles._valueOrDefault(value,this._defaultStyle.primaryColor)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"secondaryColor",{get:function(){return this._secondaryColor},set:function(value){this._secondaryColor=SpanStyles._valueOrDefault(value,this._defaultStyle.secondaryColor)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"outlineColor",{get:function(){return this._outlineColor},set:function(value){this._outlineColor=SpanStyles._valueOrDefault(value,this._defaultStyle.outlineColor)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"shadowColor",{get:function(){return this._shadowColor},set:function(value){this._shadowColor=SpanStyles._valueOrDefault(value,this._defaultStyle.shadowColor)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"primaryAlpha",{get:function(){return this._primaryAlpha},set:function(value){this._primaryAlpha=SpanStyles._valueOrDefault(value,this._defaultStyle.primaryColor.alpha)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"secondaryAlpha",{get:function(){return this._secondaryAlpha},set:function(value){this._secondaryAlpha=SpanStyles._valueOrDefault(value,this._defaultStyle.secondaryColor.alpha)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"outlineAlpha",{get:function(){return this._outlineAlpha},set:function(value){this._outlineAlpha=SpanStyles._valueOrDefault(value,this._defaultStyle.outlineColor.alpha)},enumerable:!0,configurable:!0}),Object.defineProperty(SpanStyles.prototype,"shadowAlpha",{get:function(){return this._shadowAlpha},set:function(value){this._shadowAlpha=SpanStyles._valueOrDefault(value,this._defaultStyle.shadowColor.alpha)},enumerable:!0,configurable:!0}),SpanStyles._valueOrDefault=function(newValue,defaultValue){return null!==newValue?newValue:defaultValue},SpanStyles}();exports.SpanStyles=require},function(exports){exports.debugMode=!1,exports.verboseMode=!1,exports.setDebugMode=function(value){exports.debugMode=value},exports.setVerboseMode=function(value){exports.verboseMode=value}},function(exports,require){var dialogue_1=require(26),style_1=require(29),script_properties_1=require(28),misc_1=require(27),settings_1=require(23),parser=require(1),misc_2=require(2),map_1=require(30),promise_1=require(32),require=function(){function ASS(){if(this._properties=new script_properties_1.ScriptProperties,this._styles=new map_1.Map,this._dialogues=[],this._attachments=[],this._stylesFormatSpecifier=null,this._dialoguesFormatSpecifier=null,1===arguments.length)throw new Error("Constructor `new ASS(rawASS)` has been deprecated. Use `ASS.fromString(rawASS)` instead.");this._styles.set("Default",new style_1.Style(new map_1.Map([["Name","Default"]])))}return Object.defineProperty(ASS.prototype,"properties",{get:function(){return this._properties},enumerable:!0,configurable:!0}),Object.defineProperty(ASS.prototype,"styles",{get:function(){return this._styles},enumerable:!0,configurable:!0}),Object.defineProperty(ASS.prototype,"dialogues",{get:function(){return this._dialogues},enumerable:!0,configurable:!0}),Object.defineProperty(ASS.prototype,"attachments",{get:function(){return this._attachments},enumerable:!0,configurable:!0}),Object.defineProperty(ASS.prototype,"stylesFormatSpecifier",{get:function(){return this._stylesFormatSpecifier},set:function(value){this._stylesFormatSpecifier=value},enumerable:!0,configurable:!0}),Object.defineProperty(ASS.prototype,"dialoguesFormatSpecifier",{get:function(){return this._dialoguesFormatSpecifier},set:function(value){this._dialoguesFormatSpecifier=value},enumerable:!0,configurable:!0}),ASS.prototype.addStyle=function(line){var repr,line=misc_2.parseLineIntoTypedTemplate(line,this._stylesFormatSpecifier);null!==line&&"Style"===line.type&&(line=line.template,settings_1.verboseMode&&(repr="",line.forEach(function(value,key){return repr+=key+" = "+value+", "}),console.log("Read style: "+repr)),line=new style_1.Style(line),this._styles.set(line.name,line))},ASS.prototype.addEvent=function(line){var repr,line=misc_2.parseLineIntoTypedTemplate(line,this._dialoguesFormatSpecifier);null!==line&&"Dialogue"===line.type&&(line=line.template,settings_1.verboseMode&&(repr="",line.forEach(function(value,key){return repr+=key+" = "+value+", "}),console.log("Read dialogue: "+repr)),this.dialogues.push(new dialogue_1.Dialogue(line,this)))},ASS.prototype.addAttachment=function(attachment){this._attachments.push(attachment)},ASS.fromString=function(raw,type){return void 0===type&&(type=misc_1.Format.ASS),ASS.fromStream(new parser.StringStream(raw),type)},ASS.fromStream=function(stream,type){switch(type=void 0===type?misc_1.Format.ASS:type){case misc_1.Format.ASS:return new parser.StreamParser(stream).ass;case misc_1.Format.SRT:return new parser.SrtStreamParser(stream).ass;default:throw new Error("Illegal value of type: "+type)}},ASS.fromUrl=function(url,type){return void 0===type&&(type=misc_1.Format.ASS),("function"==typeof global.fetch&&"function"==typeof global.ReadableStream&&"function"==typeof global.ReadableStream.prototype.getReader&&"function"==typeof global.TextDecoder?global.fetch(url).then(function(response){if(!1===response.ok||void 0===response.ok&&(response.status<200||299<response.status))throw new Error("HTTP request for "+url+" failed with status code "+response.status);return ASS.fromReadableStream(response.body,"utf-8",type)}):promise_1.Promise.reject(new Error("Not supported."))).catch(function(reason){console.warn("fetch() failed, falling back to XHR: "+reason);var reason=new XMLHttpRequest,result=ASS.fromStream(new parser.XhrStream(reason),type);return reason.open("GET",url,!0),reason.send(),result})},ASS.fromReadableStream=function(stream,encoding,type){return void 0===type&&(type=misc_1.Format.ASS),ASS.fromStream(new parser.BrowserReadableStream(stream,encoding=void 0===encoding?"utf-8":encoding),type)},ASS}();exports.ASS=require},function(exports){(AttachmentType=exports.AttachmentType||(exports.AttachmentType={}))[AttachmentType.Font=0]="Font",AttachmentType[AttachmentType.Graphic=1]="Graphic";var AttachmentType=function(){function Attachment(filename,type){this._filename=filename,this._type=type,this._contents=""}return Object.defineProperty(Attachment.prototype,"filename",{get:function(){return this._filename},enumerable:!0,configurable:!0}),Object.defineProperty(Attachment.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),Object.defineProperty(Attachment.prototype,"contents",{get:function(){return this._contents},set:function(value){this._contents=value},enumerable:!0,configurable:!0}),Attachment}();exports.Attachment=AttachmentType},function(exports,require){var misc_1=require(27),parse_1=require(3),parts=require(8),settings_1=require(23),map_1=require(30),require=function(){function Dialogue(template,ass){this._parts=null,this._containsTransformTag=!1;var normalizedTemplate=new map_1.Map,styleName=(template.forEach(function(value,key){normalizedTemplate.set(key.toLowerCase(),value)}),template=normalizedTemplate,this._id=++Dialogue._lastDialogueId,template.get("style"));if(null!=styleName&&styleName.constructor===String&&null!==(styleName=styleName.replace(/^\*+/,"")).match(/^Default$/i)&&(styleName="Default"),this._style=ass.styles.get(styleName),void 0===this._style&&(settings_1.debugMode&&console.warn("Unrecognized style "+styleName+'. Falling back to "Default"'),this._style=ass.styles.get("Default")),void 0===this._style)throw new Error("Unrecognized style "+styleName);if(this._start=Dialogue._toTime(template.get("start")),this._end=Dialogue._toTime(template.get("end")),this._layer=Math.max(misc_1.valueOrDefault(template,"layer",parseInt,function(value){return!isNaN(value)},"0"),0),this._rawPartsString=template.get("text"),void 0===this._rawPartsString||null===this._rawPartsString||this._rawPartsString.constructor!==String)throw new Error("Dialogue doesn't have any text.")}return Object.defineProperty(Dialogue.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(Dialogue.prototype,"start",{get:function(){return this._start},enumerable:!0,configurable:!0}),Object.defineProperty(Dialogue.prototype,"end",{get:function(){return this._end},enumerable:!0,configurable:!0}),Object.defineProperty(Dialogue.prototype,"style",{get:function(){return this._style},enumerable:!0,configurable:!0}),Object.defineProperty(Dialogue.prototype,"alignment",{get:function(){return null===this._parts&&this._parsePartsString(),this._alignment},enumerable:!0,configurable:!0}),Object.defineProperty(Dialogue.prototype,"layer",{get:function(){return this._layer},enumerable:!0,configurable:!0}),Object.defineProperty(Dialogue.prototype,"parts",{get:function(){return null===this._parts&&this._parsePartsString(),this._parts},enumerable:!0,configurable:!0}),Object.defineProperty(Dialogue.prototype,"containsTransformTag",{get:function(){return null===this._parts&&this._parsePartsString(),this._containsTransformTag},enumerable:!0,configurable:!0}),Dialogue.prototype.toString=function(){return"#"+this._id+" ["+this._start.toFixed(3)+"-"+this._end.toFixed(3)+"] "+(null!==this._parts?this._parts.join(", "):this._rawPartsString)},Dialogue.prototype._parsePartsString=function(){var possiblyIncorrectParses,_this=this;this._parts=parse_1.parse(this._rawPartsString,"dialogueParts"),this._alignment=this._style.alignment,this._parts.forEach(function(part,index){part instanceof parts.Alignment?_this._alignment=part.value:part instanceof parts.Move?null!==part.t1&&null!==part.t2||(_this._parts[index]=new parts.Move(part.x1,part.y1,part.x2,part.y2,0,_this._end-_this._start)):part instanceof parts.Transform&&(null!==part.start&&null!==part.end&&null!==part.accel||(_this._parts[index]=new parts.Transform(null===part.start?0:part.start,null===part.end?_this._end-_this._start:part.end,null===part.accel?1:part.accel,part.tags)),_this._containsTransformTag=!0)}),settings_1.debugMode&&0<(possiblyIncorrectParses=this._parts.filter(function(part){return part instanceof parts.Comment&&-1!==part.value.indexOf("\\")})).length&&console.warn("Possible incorrect parse:\n"+this._rawPartsString+"\nwas parsed as\n"+this.toString()+"\nThe possibly incorrect parses are:\n"+possiblyIncorrectParses.join("\n"))},Dialogue._toTime=function(str){return str.split(":").reduce(function(previousValue,currentValue){return 60*previousValue+parseFloat(currentValue)},0)},Dialogue._lastDialogueId=-1,Dialogue}();exports.Dialogue=require},function(exports){var Format;(Format=exports.Format||(exports.Format={}))[Format.ASS=0]="ASS",Format[Format.SRT=1]="SRT",(Format=exports.WrappingStyle||(exports.WrappingStyle={}))[Format.SmartWrappingWithWiderTopLine=0]="SmartWrappingWithWiderTopLine",Format[Format.SmartWrappingWithWiderBottomLine=3]="SmartWrappingWithWiderBottomLine",Format[Format.EndOfLineWrapping=1]="EndOfLineWrapping",Format[Format.NoLineWrapping=2]="NoLineWrapping",(Format=exports.BorderStyle||(exports.BorderStyle={}))[Format.Outline=1]="Outline",Format[Format.OpaqueBox=3]="OpaqueBox",exports.valueOrDefault=function(template,key,converter,validator,defaultValue){if(void 0===(template=template.get(key)))return converter(defaultValue);try{var result=converter(template);if(null===validator||validator(result))return result;throw new Error("Validation failed.")}catch(ex){throw new Error("Property "+key+" has invalid value "+template+" - "+ex.stack)}}},function(exports){var ScriptProperties=function(){function ScriptProperties(){}return Object.defineProperty(ScriptProperties.prototype,"resolutionX",{get:function(){return this._resolutionX},set:function(value){this._resolutionX=value},enumerable:!0,configurable:!0}),Object.defineProperty(ScriptProperties.prototype,"resolutionY",{get:function(){return this._resolutionY},set:function(value){this._resolutionY=value},enumerable:!0,configurable:!0}),Object.defineProperty(ScriptProperties.prototype,"wrappingStyle",{get:function(){return this._wrappingStyle},set:function(value){this._wrappingStyle=value},enumerable:!0,configurable:!0}),Object.defineProperty(ScriptProperties.prototype,"scaleBorderAndShadow",{get:function(){return this._scaleBorderAndShadow},set:function(value){this._scaleBorderAndShadow=value},enumerable:!0,configurable:!0}),ScriptProperties}();exports.ScriptProperties=ScriptProperties},function(exports,require){var misc_1=require(27),parse_1=require(3),map_1=require(30),require=function(){function Style(template){var normalizedTemplate=new map_1.Map;if(template.forEach(function(value,key){normalizedTemplate.set(key.toLowerCase(),value)}),this._name=(template=normalizedTemplate).get("name"),void 0===this._name||null===this._name||this._name.constructor!==String)throw new Error("Style doesn't have a name.");this._name=this._name.replace(/^\*+/,""),this._italic=!!misc_1.valueOrDefault(template,"italic",parseFloat,function(value){return!isNaN(value)},"0"),this._bold=!!misc_1.valueOrDefault(template,"bold",parseFloat,function(value){return!isNaN(value)},"0"),this._underline=!!misc_1.valueOrDefault(template,"underline",parseFloat,function(value){return!isNaN(value)},"0"),this._strikeThrough=!!misc_1.valueOrDefault(template,"strikeout",parseFloat,function(value){return!isNaN(value)},"0"),this._fontName=misc_1.valueOrDefault(template,"fontname",function(str){return str},function(value){return value.constructor===String},"sans-serif"),this._fontSize=misc_1.valueOrDefault(template,"fontsize",parseFloat,function(value){return!isNaN(value)},"18"),this._fontScaleX=misc_1.valueOrDefault(template,"scalex",parseFloat,function(value){return 0<=value},"100")/100,this._fontScaleY=misc_1.valueOrDefault(template,"scaley",parseFloat,function(value){return 0<=value},"100")/100,this._letterSpacing=misc_1.valueOrDefault(template,"spacing",parseFloat,function(value){return 0<=value},"0"),this._rotationZ=misc_1.valueOrDefault(template,"angle",parseFloat,function(value){return!isNaN(value)},"0"),this._primaryColor=misc_1.valueOrDefault(template,"primarycolour",function(str){return parse_1.parse(str,"colorWithAlpha")},null,"&H00FFFFFF"),this._secondaryColor=misc_1.valueOrDefault(template,"secondarycolour",function(str){return parse_1.parse(str,"colorWithAlpha")},null,"&H00FFFF00"),this._outlineColor=misc_1.valueOrDefault(template,"outlinecolour",function(str){return parse_1.parse(str,"colorWithAlpha")},null,"&H00000000"),this._shadowColor=misc_1.valueOrDefault(template,"backcolour",function(str){return parse_1.parse(str,"colorWithAlpha")},null,"&H80000000"),this._outlineThickness=misc_1.valueOrDefault(template,"outline",parseFloat,function(value){return 0<=value},"2"),this._borderStyle=misc_1.valueOrDefault(template,"borderstyle",parseInt,function(value){return misc_1.BorderStyle[misc_1.BorderStyle[value]]===value},"1"),this._shadowDepth=misc_1.valueOrDefault(template,"shadow",parseFloat,function(value){return 0<=value},"3"),this._alignment=misc_1.valueOrDefault(template,"alignment",parseInt,function(value){return 1<=value&&value<=9},"2"),this._marginLeft=misc_1.valueOrDefault(template,"marginl",parseFloat,function(value){return!isNaN(value)},"20"),this._marginRight=misc_1.valueOrDefault(template,"marginr",parseFloat,function(value){return!isNaN(value)},"20"),this._marginVertical=misc_1.valueOrDefault(template,"marginv",parseFloat,function(value){return!isNaN(value)},"20")}return Object.defineProperty(Style.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"italic",{get:function(){return this._italic},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"bold",{get:function(){return this._bold},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"underline",{get:function(){return this._underline},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"strikeThrough",{get:function(){return this._strikeThrough},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"fontName",{get:function(){return this._fontName},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"fontSize",{get:function(){return this._fontSize},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"fontScaleX",{get:function(){return this._fontScaleX},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"fontScaleY",{get:function(){return this._fontScaleY},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"letterSpacing",{get:function(){return this._letterSpacing},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"rotationZ",{get:function(){return this._rotationZ},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"primaryColor",{get:function(){return this._primaryColor},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"secondaryColor",{get:function(){return this._secondaryColor},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"outlineColor",{get:function(){return this._outlineColor},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"shadowColor",{get:function(){return this._shadowColor},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"outlineThickness",{get:function(){return this._outlineThickness},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"borderStyle",{get:function(){return this._borderStyle},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"shadowDepth",{get:function(){return this._shadowDepth},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"alignment",{get:function(){return this._alignment},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"marginLeft",{get:function(){return this._marginLeft},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"marginRight",{get:function(){return this._marginRight},enumerable:!0,configurable:!0}),Object.defineProperty(Style.prototype,"marginVertical",{get:function(){return this._marginVertical},enumerable:!0,configurable:!0}),Style}();exports.Style=require},function(exports){exports.Map=global.Map;var SimpleMap=function(){function SimpleMap(iterable){if(this.clear(),void 0!==iterable){if(!Array.isArray(iterable))throw new Error("Non-array iterables are not supported by the SimpleMap constructor.");for(var _i=0;_i<iterable.length;_i++){var element=iterable[_i];this.set(element[0],element[1])}}}return SimpleMap.prototype.get=function(key){key=this._keyToProperty(key);if(null!==key)return this._values[key]},SimpleMap.prototype.has=function(key){key=this._keyToProperty(key);return null!==key&&key in this._keys},SimpleMap.prototype.set=function(key,value){var property=this._keyToProperty(key);if(null===property)throw new Error("This Map implementation only supports Number and String keys, or keys with an id property.");return property in this._keys||this._size++,this._keys[property]=key,this._values[property]=value,this},SimpleMap.prototype.delete=function(key){var result,key=this._keyToProperty(key);return null!==key&&((result=key in this._keys)&&(delete this._keys[key],delete this._values[key],this._size--),result)},SimpleMap.prototype.clear=function(){this._keys=Object.create(null),this._values=Object.create(null),this._size=0},SimpleMap.prototype.forEach=function(callbackfn,thisArg){for(var _i=0,_a=Object.keys(this._keys);_i<_a.length;_i++){var property=_a[_i];callbackfn.call(thisArg,this._values[property],this._keys[property],this)}},Object.defineProperty(SimpleMap.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),SimpleMap.prototype._keyToProperty=function(key){return"number"==typeof key?"#"+key:"string"==typeof key?"'"+key:void 0!==key.id?"!"+key.id:null},SimpleMap}();void 0!==exports.Map&&"function"==typeof exports.Map.prototype.forEach&&!function(){try{return 2!==new exports.Map([[1,"foo"],[2,"bar"]]).size}catch(ex){return 1}}()||(exports.Map=SimpleMap),exports.setImplementation=function(value){exports.Map=null!==value?value:SimpleMap}},function(exports){exports.mixin=function(clazz,mixins){for(var _i=0;_i<mixins.length;_i++)for(var mixin_1=mixins[_i],_a=0,_b=Object.getOwnPropertyNames(mixin_1.prototype);_a<_b.length;_a++){var name_1=_b[_a];clazz.prototype[name_1]=mixin_1.prototype[name_1]}}},function(exports){exports.Promise=global.Promise;MutationObserver=global.MutationObserver||global.WebkitMutationObserver;var pending,currentlyPending,div,MutationObserver,SimplePromiseState,enqueueJob=void 0!==global.process&&"function"==typeof global.process.nextTick?function(callback){global.process.nextTick(callback)}:void 0!==MutationObserver?(currentlyPending=!(pending=[]),div=document.createElement("div"),new MutationObserver(function(){for(var processing=pending.splice(0,pending.length),_i=0;_i<processing.length;_i++)(0,processing[_i])();currentlyPending=!1,0<pending.length&&(div.classList.toggle("foo"),currentlyPending=!0)}).observe(div,{attributes:!0}),function(callback){pending.push(callback),currentlyPending||(div.classList.toggle("foo"),currentlyPending=!0)}):function(callback){return setTimeout(callback,0)},SimplePromise=function(){function SimplePromise(executor){if(this._state=SimplePromiseState.PENDING,this._fulfillReactions=[],this._rejectReactions=[],this._fulfilledValue=null,this._rejectedReason=null,"function"!=typeof executor)throw new TypeError('typeof executor !== "function"');var _a=this._createResolvingFunctions(),resolve=_a.resolve,_a=_a.reject;try{executor(resolve,_a)}catch(ex){_a(ex)}}return SimplePromise.prototype.then=function(onFulfilled,onRejected){var resultCapability=new DeferredPromise,fulfillReaction={capabilities:resultCapability,handler:onFulfilled="function"!=typeof onFulfilled?function(value){return value}:onFulfilled},rejectReaction={capabilities:resultCapability,handler:onRejected="function"!=typeof onRejected?function(reason){throw reason}:onRejected};switch(this._state){case SimplePromiseState.PENDING:this._fulfillReactions.push(fulfillReaction),this._rejectReactions.push(rejectReaction);break;case SimplePromiseState.FULFILLED:this._enqueueFulfilledReactionJob(fulfillReaction,this._fulfilledValue);break;case SimplePromiseState.REJECTED:this._enqueueRejectedReactionJob(rejectReaction,this._rejectedReason)}return resultCapability.promise},SimplePromise.prototype.catch=function(onRejected){return this.then(null,onRejected)},SimplePromise.resolve=function(value){return value instanceof SimplePromise?value:new exports.Promise(function(resolve){return resolve(value)})},SimplePromise.reject=function(reason){return new exports.Promise(function(resolve,reject){return reject(reason)})},SimplePromise.all=function(values){return new exports.Promise(function(resolve,reject){var result=[],numUnresolved=values.length;0===numUnresolved?resolve(result):values.forEach(function(value,index){return exports.Promise.resolve(value).then(function(value){result[index]=value,0===--numUnresolved&&resolve(result)},reject)})})},SimplePromise.race=function(values){return new exports.Promise(function(resolve,reject){for(var _i=0;_i<values.length;_i++){var value=values[_i];exports.Promise.resolve(value).then(resolve,reject)}})},SimplePromise.prototype._createResolvingFunctions=function(){var _this=this,alreadyResolved=!1;return{resolve:function(resolution){if(!alreadyResolved)if(alreadyResolved=!0,resolution===_this)_this._reject(new TypeError("resolution === this"));else if(null===resolution||"object"!=typeof resolution&&"function"!=typeof resolution)_this._fulfill(resolution);else{var then;try{then=resolution.then}catch(ex){return void _this._reject(ex)}"function"!=typeof then?_this._fulfill(resolution):enqueueJob(function(){return _this._resolveWithThenable(resolution,then)})}},reject:function(reason){alreadyResolved||(alreadyResolved=!0,_this._reject(reason))}}},SimplePromise.prototype._resolveWithThenable=function(thenable,then){var _a=this._createResolvingFunctions(),resolve=_a.resolve,_a=_a.reject;try{then.call(thenable,resolve,_a)}catch(ex){_a(ex)}},SimplePromise.prototype._fulfill=function(value){var reactions=this._fulfillReactions;this._fulfilledValue=value,this._fulfillReactions=void 0,this._rejectReactions=void 0,this._state=SimplePromiseState.FULFILLED;for(var _i=0;_i<reactions.length;_i++){var reaction=reactions[_i];this._enqueueFulfilledReactionJob(reaction,value)}},SimplePromise.prototype._reject=function(reason){var reactions=this._rejectReactions;this._rejectedReason=reason,this._fulfillReactions=void 0,this._rejectReactions=void 0,this._state=SimplePromiseState.REJECTED;for(var _i=0;_i<reactions.length;_i++){var reaction=reactions[_i];this._enqueueRejectedReactionJob(reaction,reason)}},SimplePromise.prototype._enqueueFulfilledReactionJob=function(reaction,value){enqueueJob(function(){var handlerResult,_a=reaction.capabilities,resolve=_a.resolve,_a=_a.reject,handler=reaction.handler;try{handlerResult=handler(value)}catch(ex){return void _a(ex)}resolve(handlerResult)})},SimplePromise.prototype._enqueueRejectedReactionJob=function(reaction,reason){enqueueJob(function(){var handlerResult,_a=reaction.capabilities,resolve=_a.resolve,_a=_a.reject,handler=reaction.handler;try{handlerResult=handler(reason)}catch(ex){return void _a(ex)}resolve(handlerResult)})},SimplePromise}();void 0===exports.Promise&&(exports.Promise=SimplePromise),function(SimplePromiseState){SimplePromiseState[SimplePromiseState.PENDING=0]="PENDING",SimplePromiseState[SimplePromiseState.FULFILLED=1]="FULFILLED",SimplePromiseState[SimplePromiseState.REJECTED=2]="REJECTED"}(SimplePromiseState=SimplePromiseState||{}),exports.setImplementation=function(value){exports.Promise=null!==value?value:SimplePromise};var DeferredPromise=function(){function DeferredPromise(){var _this=this;this._promise=new exports.Promise(function(resolve,reject){Object.defineProperties(_this,{resolve:{value:resolve,enumerable:!0},reject:{value:reject,enumerable:!0}})})}return Object.defineProperty(DeferredPromise.prototype,"promise",{get:function(){return this._promise},enumerable:!0,configurable:!0}),DeferredPromise}();exports.DeferredPromise=DeferredPromise,exports.first=function(promises){return function first_rec(promises,previousRejections){if(0===promises.length)return exports.Promise.reject(previousRejections);var head=promises[0];var tail=promises.slice(1);return head.catch(function(reason){return first_rec(tail,previousRejections.concat(reason))})}(promises,[])},exports.any=function(promises){return new exports.Promise(function(resolve,reject){return exports.Promise.all(promises.map(function(promise){return promise.then(resolve,function(reason){return reason})})).then(reject)})},exports.lastly=function(promise,body){return promise.then(function(value){return body(),value},function(reason){throw body(),reason})}},function(exports){exports.Set=global.Set;var SimpleSet=function(){function SimpleSet(iterable){if(this.clear(),void 0!==iterable){if(!Array.isArray(iterable))throw new Error("Non-array iterables are not supported by the SimpleSet constructor.");for(var _i=0;_i<iterable.length;_i++){var value=iterable[_i];this.add(value)}}}return SimpleSet.prototype.add=function(value){var property=this._toProperty(value);if(null===property)throw new Error("This Set implementation only supports Number and String values.");return property in this._elements||this._size++,this._elements[property]=value,this},SimpleSet.prototype.clear=function(){this._elements=Object.create(null),this._size=0},SimpleSet.prototype.has=function(value){value=this._toProperty(value);return null!==value&&value in this._elements},SimpleSet.prototype.forEach=function(callbackfn,thisArg){for(var _i=0,_a=Object.keys(this._elements);_i<_a.length;_i++){var property=_a[_i],property=this._elements[property];callbackfn.call(thisArg,property,property,this)}},Object.defineProperty(SimpleSet.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),SimpleSet.prototype._toProperty=function(value){return"number"==typeof value?"#"+value:"string"==typeof value?"'"+value:null},SimpleSet}();void 0!==exports.Set&&"function"==typeof exports.Set.prototype.forEach&&!function(){try{return 2!==new exports.Set([1,2]).size}catch(ex){return 1}}()||(exports.Set=SimpleSet),exports.setImplementation=function(value){exports.Set=null!==value?value:SimpleSet}},function(exports){exports.__extends=function(derived,base){for(var property in base)base.hasOwnProperty(property)&&(derived[property]=base[property]);function __(){this.constructor=derived}__.prototype=base.prototype,derived.prototype=new __},exports.__decorate=function(decorators,target,key){if(arguments.length<3)return function(decorators,clazz){for(var _i=0;_i<decorators.length;_i++){var decorator=decorators[_i];clazz=decorator(clazz)||clazz}return clazz}(decorators.reverse(),target);!function(decorators,proto,name){for(var _i=0;_i<decorators.length;_i++)(0,decorators[_i])(proto,name)}(decorators.reverse(),target,key)}},function(exports,require){var map_1=require(30),promise_1=require(32),commands_1=require(36),misc_1=require(38),require=function(){function WorkerChannelImpl(comm){var _this=this;this._comm=comm,this._pendingRequests=new map_1.Map,this._comm.addEventListener("message",function(ev){return _this._onMessage(ev.data)},!1)}return WorkerChannelImpl.prototype.request=function(command,parameters){var deferred=new promise_1.DeferredPromise,requestId=++WorkerChannelImpl._lastRequestId,requestId=(this._pendingRequests.set(requestId,deferred),{requestId:requestId,command:command,parameters:parameters});return this._comm.postMessage(misc_1.serialize(requestId)),deferred.promise},WorkerChannelImpl.prototype.cancelRequest=function(requestId){var deferred=this._pendingRequests.get(requestId);void 0!==deferred&&(this._pendingRequests.delete(requestId),deferred.reject(new Error("Cancelled.")))},WorkerChannelImpl.prototype._respond=function(message){var requestId=message.requestId,error=message.error,message=message.result;error instanceof Error&&(error={message:error.message,stack:error.stack}),this._comm.postMessage(misc_1.serialize({command:commands_1.WorkerCommands.Response,requestId:requestId,error:error,result:message}))},WorkerChannelImpl.prototype._onMessage=function(rawMessage){var deferred,requestId,responseMessage,_this=this,rawMessage=misc_1.deserialize(rawMessage);rawMessage.command===commands_1.WorkerCommands.Response?void 0!==(deferred=this._pendingRequests.get((responseMessage=rawMessage).requestId))&&(this._pendingRequests.delete(responseMessage.requestId),null===responseMessage.error?deferred.resolve(responseMessage.result):deferred.reject(responseMessage.error)):(requestId=(deferred=rawMessage).requestId,void 0===(responseMessage=misc_1.getWorkerCommandHandler(deferred.command))?this._respond({requestId:requestId,error:new Error("No handler registered for command "+deferred.command),result:null}):responseMessage(deferred.parameters).then(function(result){return{requestId:requestId,error:null,result:result}},function(error){return{requestId:requestId,error:error,result:null}}).then(function(responseMessage){return _this._respond(responseMessage)}))},WorkerChannelImpl._lastRequestId=-1,WorkerChannelImpl}();exports.WorkerChannelImpl=require,misc_1.registerWorkerCommand(commands_1.WorkerCommands.Ping,function(){return new promise_1.Promise(function(resolve){return resolve(null)})})},function(exports){(exports=exports.WorkerCommands||(exports.WorkerCommands={}))[exports.Response=0]="Response",exports[exports.Parse=1]="Parse",exports[exports.Ping=2]="Ping"},function(exports,require){var channel_1=require(35),require=require(36),_scriptNode=(exports.WorkerCommands=require.WorkerCommands,exports.supported="undefined"!=typeof Worker,"undefined"!=typeof document&&void 0!==document.currentScript?document.currentScript:null);exports.createWorker=function(scriptPath){return void 0===scriptPath&&(scriptPath=_scriptNode.src),new channel_1.WorkerChannelImpl(new Worker(scriptPath))},"undefined"!=typeof WorkerGlobalScope&&global instanceof WorkerGlobalScope&&new channel_1.WorkerChannelImpl(global)},function(exports,require){var require=require(30),workerCommands=new require.Map,classPrototypes=new require.Map;exports.registerWorkerCommand=function(command,handler){workerCommands.set(command,handler)},exports.getWorkerCommandHandler=function(command){return workerCommands.get(command)},exports.registerClassPrototype=function(prototype){prototype._classTag=classPrototypes.size,classPrototypes.set(prototype._classTag,prototype)},exports.serialize=function(obj){return JSON.stringify(obj,function(key,value){return value&&void 0!==value._classTag&&(value._classTag=value._classTag),value})},exports.deserialize=function(str){return JSON.parse(str,function(key,value){if(value&&void 0!==value._classTag){for(var hydratedValue=Object.create(classPrototypes.get(value._classTag)),_i=0,_a=Object.keys(value);_i<_a.length;_i++){var key_1=_a[_i];"_classTag"!==key_1&&(hydratedValue[key_1]=value[key_1])}value=hydratedValue}return value})}}],installedModules=Object.create(null),function require(moduleId){var exports;return installedModules[moduleId]||(exports=installedModules[moduleId]=Object.create(null),modules[moduleId](exports,require),exports)}(0);var modules,installedModules});