!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&¤t.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))&¤t.pop(),null===(childNode=null===childNode?this.parse_comment(current):childNode))return parent.pop(),null;childNode.value instanceof parts.Comment&¤t.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">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 (\d\d:\d\d:\d\d,\d\d\d)/.exec(line))&&(this._currentDialogueStart=match[1].replace(",","."),this._currentDialogueEnd=match[2].replace(",",".")):(line=line.replace(//g,"{\\b1}").replace(/\{b\}/g,"{\\b1}").replace(/<\/b>/g,"{\\b0}").replace(/\{\/b\}/g,"{\\b0}").replace(//g,"{\\i1}").replace(/\{i\}/g,"{\\i1}").replace(/<\/i>/g,"{\\i0}").replace(/\{\/i\}/g,"{\\i0}").replace(//g,"{\\u1}").replace(/\{u\}/g,"{\\u1}").replace(/<\/u>/g,"{\\u0}").replace(/\{\/u\}/g,"{\\u0}").replace(//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._readTillthis._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=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;icurrentTime||dialogue.end