define(["exports"],function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["css!modules/webvtt/vtt.css"]);function ParsingError(errorData,message){this.name="ParsingError",this.code=errorData.code,this.message=message||errorData.message}function parseTimeStamp(input){function computeSeconds(h,m,s,f){return 3600*(0|h)+60*(0|m)+(0|s)+(0|f)/1e3}input=input.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return input?input[3]?computeSeconds(input[1],input[2],input[3].replace(":",""),input[4]):59","":"","":""," ":" "},TAG_NAME={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},TAG_ANNOTATION={v:"title",lang:"lang"},NEEDS_PARENT={rt:"ruby"};function parseContent(window,input){function unescape1(e){return ESCAPE[e]}for(var t,node,ts,type,annotation,tagName,rootDiv=window.document.createElement("div"),current=rootDiv,tagStack=[];null!==(t=function(){var m;return input?(m=(m=input.match(/^([^<]*)(<[^>]*>?)?/))[1]||m[2],input=input.substr(m.length),m):null}());)"<"===t[0]?"/"===t[1]?tagStack.length&&tagStack[tagStack.length-1]===t.substr(2).replace(">","")&&(tagStack.pop(),current=current.parentNode):(node=void 0,(ts=parseTimeStamp(t.substr(1,t.length-2)))?(node=window.document.createProcessingInstruction("timestamp",ts),current.appendChild(node)):(ts=t.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/))&&(type=ts[1],annotation=ts[3],tagName=void 0,node=(tagName=TAG_NAME[type])?(tagName=window.document.createElement(tagName),(type=TAG_ANNOTATION[type])&&annotation&&(tagName[type]=annotation.trim()),tagName):null)&&function(current,element){return!NEEDS_PARENT[element.localName]||NEEDS_PARENT[element.localName]===current.localName}(current,node)&&(ts[2]&&(node.className=ts[2].substr(1).replace("."," ")),tagStack.push(ts[1]),current.appendChild(node),current=node)):current.appendChild(window.document.createTextNode(function(s){for(var sMatch;sMatch=s.match(/&(amp|quot|lt|gt|lrm|rlm|nbsp);/);)s=s.replace(sMatch[0],unescape1);return s}(t)));return rootDiv}var strongRTLRanges=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function pushNodes(nodeStack,node){for(var i=node.childNodes.length-1;0<=i;i--)nodeStack.push(node.childNodes[i])}function determineBidi(cueDiv,options){var nodeStack=[],text="";if(cueDiv&&cueDiv.childNodes&&!options.forceLTR)for(pushNodes(nodeStack,cueDiv);text=function nextTextNode(nodeStack,options){if(!nodeStack||!nodeStack.length)return null;var node=nodeStack.pop(),text=node.textContent||node.innerText;{var m;if(text)return!options.forceLTR&&text.match(/(^| )[\?\!\.\,]/m)?(options.forceLTR=!0,null):(m=text.match(/^.*(\n|\r)/))?m[nodeStack.length=0]:text}return"ruby"===node.tagName?nextTextNode(nodeStack,options):node.childNodes?(pushNodes(nodeStack,node),nextTextNode(nodeStack,options)):void 0}(nodeStack,options);)for(var i=0;i=currentRange[0]&&charCode<=currentRange[1])return 1}}(text.charCodeAt(i)))return"rtl";return"ltr"}function StyleBox(){}StyleBox.prototype.applyStyles=function(styles,div){div=div||this.div,Object.assign(div.style,styles)},StyleBox.prototype.formatStyle=function(val,unit){return 0===val?0:val+unit};var supportsFlowRelativeTextAlign=CSS.supports("text-align","start");function CueStyleBox(window,cue,options){StyleBox.call(this),this.cue=cue,options=options||{},this.cueDiv=parseContent(window,cue.text);var styles=Object.assign({position:"relative",left:0,right:0,top:0,bottom:0,display:"inline-block",padding:".08em .5em",borderRadius:".25em"},options.textStyle),textPos=(styles.writingMode=cue.vertical?"lr"===cue.vertical?"vertical-lr":"vertical-rl":"horizontal-tb",this.applyStyles(styles,this.cueDiv),this.div=window.document.createElement("div"),(styles={textAlign:"middle"===(window=cue.align||"center")?"center":"start"!==window||supportsFlowRelativeTextAlign?"end"!==window||supportsFlowRelativeTextAlign?window:"right":"left",whiteSpace:"pre-line",position:"absolute"}).direction=determineBidi(this.cueDiv,options),styles.writingMode=cue.vertical?"lr"===cue.vertical?"vertical-lr":"vertical-rl":"horizontal-tb",styles.unicodeBidi="plaintext",this.applyStyles(styles),this.div.appendChild(this.cueDiv),0),cueSize=cue.size||100;switch(cue.positionAlign){case"start":textPos=cue.position;break;case"center":textPos=cue.position-cueSize/2;break;case"end":textPos=cue.position-cueSize}cue.vertical?this.applyStyles({top:this.formatStyle(textPos,"%"),height:this.formatStyle(cueSize,"%")}):this.applyStyles({left:this.formatStyle(textPos,"%"),width:this.formatStyle(cueSize,"%")})}function BoxPosition(obj){var height,width,top,rects;obj.div&&(height=obj.div.offsetHeight,width=obj.div.offsetWidth,top=obj.div.offsetTop,(rects=(rects=obj.div.childNodes)&&rects[0])&&rects.getClientRects&&(rects=rects.getClientRects()),obj=obj.div.getBoundingClientRect(),rects=rects?Math.max(rects[0]&&rects[0].height||0,obj.height/rects.length):0),this.left=obj.left,this.right=obj.right,this.top=obj.top||top,this.height=obj.height||height,this.bottom=obj.bottom||top+(obj.height||height),this.width=obj.width||width,this.lineHeight=void 0!==rects?rects:obj.lineHeight}function moveBoxToLinePosition(window,styleBox,containerBox,boxPositions){var relativeToEnd,size,boxPosition=new BoxPosition(styleBox),cue=styleBox.cue,linePos=function(cue){return"number"==typeof cue.line&&(!1!==cue.snapToLines||0<=cue.line&&cue.line<=100)?cue.line:-1}(cue),axis=[];if(!1!==cue.snapToLines){switch(cue.vertical||""){case"":axis=["+y","-y"],size="height",relativeToEnd=linePos<0;break;case"rl":axis=["+x","-x"],size="width";break;case"lr":axis=["-x","+x"],size="width"}var step=boxPosition.lineHeight,position=step*Math.round(linePos),maxPosition=containerBox[size]+step,initialAxis=axis[0];Math.abs(position)>maxPosition&&(position=position<0?-1:1,position*=Math.ceil(maxPosition/step)*step),linePos<0&&(position+=cue.vertical?containerBox.width:Math.floor(.92*containerBox.height),axis=axis.reverse()),boxPosition.move(initialAxis,position)}else{var calculatedPercentage=boxPosition.lineHeight/containerBox.height*100;switch(cue.lineAlign){case"center":linePos-=calculatedPercentage/2;break;case"end":relativeToEnd=!0,linePos-=calculatedPercentage,linePos=Math.max(linePos,92)}switch(cue.vertical||""){case"":styleBox.applyStyles({top:styleBox.formatStyle(linePos,"%")});break;case"rl":styleBox.applyStyles({left:styleBox.formatStyle(linePos,"%")});break;case"lr":styleBox.applyStyles({right:styleBox.formatStyle(linePos,"%")})}axis=["+y","-x","+x","-y"],boxPosition=new BoxPosition(styleBox)}maxPosition=function(b,axis){for(var bestPosition,specifiedPosition=new BoxPosition(b),percentage=1,i=0;ib2.left&&this.topb2.top},BoxPosition.prototype.overlapsAny=function(boxes){for(var i=0;i=container.top&&this.bottom<=container.bottom&&this.left>=container.left&&this.right<=container.right},BoxPosition.prototype.overlapsOppositeAxis=function(container,axis){switch(axis){case"+x":return this.leftcontainer.right;case"+y":return this.topcontainer.bottom}},BoxPosition.prototype.intersectPercentage=function(b2){return Math.max(0,Math.min(this.right,b2.right)-Math.max(this.left,b2.left))*Math.max(0,Math.min(this.bottom,b2.bottom)-Math.max(this.top,b2.top))/(this.height*this.width)},BoxPosition.getSimpleBoxPosition=function(obj){var height=obj.div?obj.div.offsetHeight:obj.tagName?obj.offsetHeight:0,width=obj.div?obj.div.offsetWidth:obj.tagName?obj.offsetWidth:0,top=obj.div?obj.div.offsetTop:obj.tagName?obj.offsetTop:0;return{left:(obj=obj.div?obj.div.getBoundingClientRect():obj.tagName?obj.getBoundingClientRect():obj).left,right:obj.right,top:obj.top||top,height:obj.height||height,bottom:obj.bottom||top+(obj.height||height),width:obj.width||width}},WebVTT.StringDecoder=function(){return{decode:function(data){if(!data)return"";if("string"!=typeof data)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(data))}}},WebVTT.convertCueToDOMTree=function(window,cuetext){return window&&cuetext?parseContent(window,cuetext):null},WebVTT.processCues=function(window,cues,overlay,options){if(!window||!cues||!overlay)return null;for(;overlay.firstChild;)overlay.removeChild(overlay.firstChild);if(function(cues){for(var i=0;i