bitmovin-player 8.280.0 → 8.281.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/bitmovinplayer-serviceworker.js +2 -2
  2. package/bitmovinplayer-serviceworker.prod.js +2 -2
  3. package/bitmovinplayer-ui.js +1 -1
  4. package/bitmovinplayer.js +2 -2
  5. package/bitmovinplayer.prod.js +2 -2
  6. package/modules/bitmovinplayer-abr.js +2 -2
  7. package/modules/bitmovinplayer-abr.prod.js +2 -2
  8. package/modules/bitmovinplayer-advertising-bitmovin.js +2 -2
  9. package/modules/bitmovinplayer-advertising-bitmovin.prod.js +2 -2
  10. package/modules/bitmovinplayer-advertising-core.js +2 -2
  11. package/modules/bitmovinplayer-advertising-core.prod.js +2 -2
  12. package/modules/bitmovinplayer-advertising-ima.js +2 -2
  13. package/modules/bitmovinplayer-advertising-ima.prod.js +2 -2
  14. package/modules/bitmovinplayer-advertising-omsdk.js +2 -2
  15. package/modules/bitmovinplayer-advertising-omsdk.prod.js +2 -2
  16. package/modules/bitmovinplayer-analytics.js +2 -2
  17. package/modules/bitmovinplayer-analytics.prod.js +2 -2
  18. package/modules/bitmovinplayer-container-mp4.js +2 -2
  19. package/modules/bitmovinplayer-container-mp4.prod.js +2 -2
  20. package/modules/bitmovinplayer-container-ts.js +2 -2
  21. package/modules/bitmovinplayer-container-ts.prod.js +2 -2
  22. package/modules/bitmovinplayer-container-webm.js +2 -2
  23. package/modules/bitmovinplayer-container-webm.prod.js +2 -2
  24. package/modules/bitmovinplayer-core.js +2 -2
  25. package/modules/bitmovinplayer-core.prod.js +2 -2
  26. package/modules/bitmovinplayer-crypto.js +2 -2
  27. package/modules/bitmovinplayer-crypto.prod.js +2 -2
  28. package/modules/bitmovinplayer-dash.js +2 -2
  29. package/modules/bitmovinplayer-dash.prod.js +2 -2
  30. package/modules/bitmovinplayer-drm.js +2 -2
  31. package/modules/bitmovinplayer-drm.prod.js +2 -2
  32. package/modules/bitmovinplayer-engine-bitmovin.js +2 -2
  33. package/modules/bitmovinplayer-engine-bitmovin.prod.js +2 -2
  34. package/modules/bitmovinplayer-engine-native.js +2 -2
  35. package/modules/bitmovinplayer-engine-native.prod.js +2 -2
  36. package/modules/bitmovinplayer-engine-webrtc.js +2 -2
  37. package/modules/bitmovinplayer-engine-webrtc.prod.js +2 -2
  38. package/modules/bitmovinplayer-envivio.js +1 -1
  39. package/modules/bitmovinplayer-envivio.prod.js +1 -1
  40. package/modules/bitmovinplayer-hls.js +2 -2
  41. package/modules/bitmovinplayer-hls.prod.js +2 -2
  42. package/modules/bitmovinplayer-lowlatency.js +2 -2
  43. package/modules/bitmovinplayer-lowlatency.prod.js +2 -2
  44. package/modules/bitmovinplayer-mserenderer.js +2 -2
  45. package/modules/bitmovinplayer-mserenderer.prod.js +2 -2
  46. package/modules/bitmovinplayer-patch.js +1 -1
  47. package/modules/bitmovinplayer-patch.prod.js +1 -1
  48. package/modules/bitmovinplayer-playstation4.js +2 -2
  49. package/modules/bitmovinplayer-playstation4.prod.js +2 -2
  50. package/modules/bitmovinplayer-playstation5.js +2 -2
  51. package/modules/bitmovinplayer-playstation5.prod.js +2 -2
  52. package/modules/bitmovinplayer-polyfill.js +1 -1
  53. package/modules/bitmovinplayer-polyfill.prod.js +1 -1
  54. package/modules/bitmovinplayer-reactnative.js +1 -1
  55. package/modules/bitmovinplayer-reactnative.prod.js +1 -1
  56. package/modules/bitmovinplayer-remotecontrol.js +2 -2
  57. package/modules/bitmovinplayer-remotecontrol.prod.js +2 -2
  58. package/modules/bitmovinplayer-serviceworker-client.js +2 -2
  59. package/modules/bitmovinplayer-serviceworker-client.prod.js +2 -2
  60. package/modules/bitmovinplayer-serviceworker.js +2 -2
  61. package/modules/bitmovinplayer-serviceworker.prod.js +2 -2
  62. package/modules/bitmovinplayer-sgai.js +2 -2
  63. package/modules/bitmovinplayer-sgai.prod.js +2 -2
  64. package/modules/bitmovinplayer-smooth.js +2 -2
  65. package/modules/bitmovinplayer-smooth.prod.js +2 -2
  66. package/modules/bitmovinplayer-style.js +2 -2
  67. package/modules/bitmovinplayer-style.prod.js +2 -2
  68. package/modules/bitmovinplayer-subtitles-cea608.js +2 -2
  69. package/modules/bitmovinplayer-subtitles-cea608.prod.js +2 -2
  70. package/modules/bitmovinplayer-subtitles-native.js +2 -2
  71. package/modules/bitmovinplayer-subtitles-native.prod.js +2 -2
  72. package/modules/bitmovinplayer-subtitles-ttml.js +2 -2
  73. package/modules/bitmovinplayer-subtitles-ttml.prod.js +2 -2
  74. package/modules/bitmovinplayer-subtitles-vtt.js +2 -2
  75. package/modules/bitmovinplayer-subtitles-vtt.prod.js +2 -2
  76. package/modules/bitmovinplayer-subtitles.js +2 -2
  77. package/modules/bitmovinplayer-subtitles.prod.js +2 -2
  78. package/modules/bitmovinplayer-thumbnail-imp.js +2 -2
  79. package/modules/bitmovinplayer-thumbnail-imp.prod.js +2 -2
  80. package/modules/bitmovinplayer-thumbnail.js +2 -2
  81. package/modules/bitmovinplayer-thumbnail.prod.js +2 -2
  82. package/modules/bitmovinplayer-tizen.js +2 -2
  83. package/modules/bitmovinplayer-tizen.prod.js +2 -2
  84. package/modules/bitmovinplayer-ui.js +2 -2
  85. package/modules/bitmovinplayer-ui.prod.js +2 -2
  86. package/modules/bitmovinplayer-vidaa.js +2 -2
  87. package/modules/bitmovinplayer-vidaa.prod.js +2 -2
  88. package/modules/bitmovinplayer-vr.js +2 -2
  89. package/modules/bitmovinplayer-vr.prod.js +2 -2
  90. package/modules/bitmovinplayer-webos.js +2 -2
  91. package/modules/bitmovinplayer-webos.prod.js +2 -2
  92. package/modules/bitmovinplayer-wpe.js +2 -2
  93. package/modules/bitmovinplayer-wpe.prod.js +2 -2
  94. package/modules/bitmovinplayer-xml.js +1 -1
  95. package/modules/bitmovinplayer-xml.prod.js +1 -1
  96. package/package.json +1 -1
  97. package/types/advertising/API.d.ts +9 -0
  98. package/types/advertising/ConfigAPI.d.ts +6 -5
  99. package/types/core/BufferSettings.d.ts +58 -0
  100. package/types/core/LogLevels.d.ts +54 -0
  101. package/types/core/Logger.d.ts +51 -0
  102. package/types/core/Settings.d.ts +856 -0
  103. package/types/core/network/ManifestMimeType.d.ts +5 -0
  104. package/types/core/util/MimeTypeHelper.d.ts +52 -0
  105. package/types/sgai/SgaiConfigAPI.d.ts +1 -1
  106. package/types/sgai/SgaiErrorCode.d.ts +6 -1
@@ -9,10 +9,10 @@
9
9
  * This software includes open-source components. See THIRD_PARTY_NOTICES
10
10
  * in the distribution for details.
11
11
  *
12
- * Bitmovin Player Version 8.280.0
12
+ * Bitmovin Player Version 8.281.0
13
13
  *
14
14
  ****************************************************************************/
15
15
 
16
16
  (function() {
17
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["subtitles-cea608"]=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player["subtitles-cea608"]=e())}(self,function(){return(self.webpackChunkbitmovin_player=self.webpackChunkbitmovin_player||[]).push([[886],{30251:function(t){!function(){t.exports=function(){"use strict";var t=function(){this.init=function(){var t={};this.on=function(e,i){t[e]||(t[e]=[]),t[e]=t[e].concat(i)},this.off=function(e,i){var s;return!!t[e]&&(s=t[e].indexOf(i),t[e]=t[e].slice(),t[e].splice(s,1),s>-1)},this.trigger=function(e){var i,s,n,o;if(i=t[e])if(2===arguments.length)for(n=i.length,s=0;s<n;++s)i[s].call(this,arguments[1]);else{for(o=[],s=arguments.length,s=1;s<arguments.length;++s)o.push(arguments[s]);for(n=i.length,s=0;s<n;++s)i[s].apply(this,o)}},this.dispose=function(){t={}}}};t.prototype.pipe=function(t){return this.on("data",function(e){t.push(e)}),this.on("done",function(e){t.flush(e)}),this.on("partialdone",function(e){t.partialFlush(e)}),this.on("endedtimeline",function(e){t.endTimeline(e)}),this.on("reset",function(e){t.reset(e)}),t},t.prototype.push=function(t){this.trigger("data",t)},t.prototype.flush=function(t){this.trigger("done",t)},t.prototype.partialFlush=function(t){this.trigger("partialdone",t)},t.prototype.endTimeline=function(t){this.trigger("endedtimeline",t)},t.prototype.reset=function(t){this.trigger("reset",t)};var e=t,i=function(t){for(var e=0,i=[],s=0,n=0;e<t.byteLength&&128!==t[e];){for(;255===t[e];)s+=255,e++;for(s+=t[e++];255===t[e];)n+=255,e++;n+=t[e++];var o=String.fromCharCode(t[e+3],t[e+4],t[e+5],t[e+6]);4===s&&"GA94"===o&&i.push({payloadType:s,payloadSize:n,payload:t.subarray(e,e+n)}),e+=n,s=0,n=0}return i},s=function(t){return 181!==t.payload[0]||49!=(t.payload[1]<<8|t.payload[2])||"GA94"!==String.fromCharCode(t.payload[3],t.payload[4],t.payload[5],t.payload[6])||3!==t.payload[7]?null:t.payload.subarray(8,t.payload.length-1)},n=function(t,e){var i,s,n,o,r=[];if(!(64&e[0]))return r;for(s=31&e[0],i=0;i<s;i++)o={type:3&e[2+(n=3*i)],pts:t},4&e[n+2]&&(o.ccData=e[n+3]<<8|e[n+4],r.push(o));return r},o=4,r=function t(e){e=e||{},t.prototype.init.call(this),this.parse708captions_="boolean"!=typeof e.parse708captions||e.parse708captions,this.captionPackets_=[],this.ccStreams_=[new C(0,0),new C(0,1),new C(1,0),new C(1,1)],this.parse708captions_&&(this.cc708Stream_=new l({captionServices:e.captionServices})),this.reset(),this.ccStreams_.forEach(function(t){t.on("data",this.trigger.bind(this,"data")),t.on("partialdone",this.trigger.bind(this,"partialdone")),t.on("done",this.trigger.bind(this,"done"))},this),this.parse708captions_&&(this.cc708Stream_.on("data",this.trigger.bind(this,"data")),this.cc708Stream_.on("partialdone",this.trigger.bind(this,"partialdone")),this.cc708Stream_.on("done",this.trigger.bind(this,"done")))};(r.prototype=new e).push=function(t){var e=this;"sei_rbsp"===t.nalUnitType&&i(t.escapedRBSP).filter(function(t){return t.payloadType===o}).map(s).forEach(function(i){i&&(e.captionPackets_=e.captionPackets_.concat(n(t.pts,i)))})},r.prototype.flushCCStreams=function(t){this.ccStreams_.forEach(function(e){return"flush"===t?e.flush():e.partialFlush()},this)},r.prototype.flushStream=function(t){this.captionPackets_.length?(this.captionPackets_.forEach(function(t,e){t.presortIndex=e}),this.captionPackets_.sort(function(t,e){return t.pts===e.pts?t.presortIndex-e.presortIndex:t.pts-e.pts}),this.captionPackets_.forEach(function(t){t.type<2?this.dispatchCea608Packet(t):this.dispatchCea708Packet(t)},this),this.captionPackets_.length=0,this.flushCCStreams(t)):this.flushCCStreams(t)},r.prototype.flush=function(){return this.flushStream("flush")},r.prototype.partialFlush=function(){return this.flushStream("partialFlush")},r.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(t){t.reset()})},r.prototype.dispatchCea608Packet=function(t){this.setsTextOrXDSActive(t)?this.activeCea608Channel_[t.type]=null:this.setsChannel1Active(t)?this.activeCea608Channel_[t.type]=0:this.setsChannel2Active(t)&&(this.activeCea608Channel_[t.type]=1),null!==this.activeCea608Channel_[t.type]&&this.ccStreams_[(t.type<<1)+this.activeCea608Channel_[t.type]].push(t)},r.prototype.setsChannel1Active=function(t){return 4096==(30720&t.ccData)},r.prototype.setsChannel2Active=function(t){return 6144==(30720&t.ccData)},r.prototype.setsTextOrXDSActive=function(t){return 256==(28928&t.ccData)||4138==(30974&t.ccData)||6186==(30974&t.ccData)},r.prototype.dispatchCea708Packet=function(t){this.parse708captions_&&this.cc708Stream_.push(t)};var a={127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600},h=function(t){return 32<=t&&t<=127||160<=t&&t<=255},p=function(t){this.windowNum=t,this.reset()};p.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},p.prototype.getText=function(){return this.rows.join("\n")},p.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},p.prototype.newLine=function(t){for(this.rows.length>=this.virtualRowCount&&"function"==typeof this.beforeRowOverflow&&this.beforeRowOverflow(t),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},p.prototype.isEmpty=function(){return 0===this.rows.length||1===this.rows.length&&""===this.rows[0]},p.prototype.addText=function(t){this.rows[this.rowIdx]+=t},p.prototype.backspace=function(){if(!this.isEmpty()){var t=this.rows[this.rowIdx];this.rows[this.rowIdx]=t.substr(0,t.length-1)}};var c=function(t,e,i){this.serviceNum=t,this.text="",this.currentWindow=new p(-1),this.windows=[],this.stream=i,"string"==typeof e&&this.createTextDecoder(e)};c.prototype.init=function(t,e){this.startPts=t;for(var i=0;i<8;i++)this.windows[i]=new p(i),"function"==typeof e&&(this.windows[i].beforeRowOverflow=e)},c.prototype.setCurrentWindow=function(t){this.currentWindow=this.windows[t]},c.prototype.createTextDecoder=function(t){if("undefined"==typeof TextDecoder)this.stream.trigger("log",{level:"warn",message:"The `encoding` option is unsupported without TextDecoder support"});else try{this.textDecoder_=new TextDecoder(t)}catch(e){this.stream.trigger("log",{level:"warn",message:"TextDecoder could not be created with "+t+" encoding. "+e})}};var l=function t(e){e=e||{},t.prototype.init.call(this);var i,s=this,n=e.captionServices||{},o={};Object.keys(n).forEach(function(t){i=n[t],/^SERVICE/.test(t)&&(o[t]=i.encoding)}),this.serviceEncodings=o,this.current708Packet=null,this.services={},this.push=function(t){3===t.type?(s.new708Packet(),s.add708Bytes(t)):(null===s.current708Packet&&s.new708Packet(),s.add708Bytes(t))}};l.prototype=new e,l.prototype.new708Packet=function(){null!==this.current708Packet&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},l.prototype.add708Bytes=function(t){var e=t.ccData,i=e>>>8,s=255&e;this.current708Packet.ptsVals.push(t.pts),this.current708Packet.data.push(i),this.current708Packet.data.push(s)},l.prototype.push708Packet=function(){var t=this.current708Packet,e=t.data,i=null,s=null,n=0,o=e[n++];for(t.seq=o>>6,t.sizeCode=63&o;n<e.length;n++)s=31&(o=e[n++]),7==(i=o>>5)&&s>0&&(i=o=e[n++]),this.pushServiceBlock(i,n,s),s>0&&(n+=s-1)},l.prototype.pushServiceBlock=function(t,e,i){var s,n=e,o=this.current708Packet.data,r=this.services[t];for(r||(r=this.initService(t,n));n<e+i&&n<o.length;n++)s=o[n],h(s)?n=this.handleText(n,r):24===s?n=this.multiByteCharacter(n,r):16===s?n=this.extendedCommands(n,r):128<=s&&s<=135?n=this.setCurrentWindow(n,r):152<=s&&s<=159?n=this.defineWindow(n,r):136===s?n=this.clearWindows(n,r):140===s?n=this.deleteWindows(n,r):137===s?n=this.displayWindows(n,r):138===s?n=this.hideWindows(n,r):139===s?n=this.toggleWindows(n,r):151===s?n=this.setWindowAttributes(n,r):144===s?n=this.setPenAttributes(n,r):145===s?n=this.setPenColor(n,r):146===s?n=this.setPenLocation(n,r):143===s?r=this.reset(n,r):8===s?r.currentWindow.backspace():12===s?r.currentWindow.clearText():13===s?r.currentWindow.pendingNewLine=!0:14===s?r.currentWindow.clearText():141===s&&n++},l.prototype.extendedCommands=function(t,e){var i=this.current708Packet.data[++t];return h(i)&&(t=this.handleText(t,e,{isExtended:!0})),t},l.prototype.getPts=function(t){return this.current708Packet.ptsVals[Math.floor(t/2)]},l.prototype.initService=function(t,e){var i,s,n=this;return(i="SERVICE"+t)in this.serviceEncodings&&(s=this.serviceEncodings[i]),this.services[t]=new c(t,s,n),this.services[t].init(this.getPts(e),function(e){n.flushDisplayed(e,n.services[t])}),this.services[t]},l.prototype.handleText=function(t,e,i){var s,n,o=i&&i.isExtended,r=i&&i.isMultiByte,h=this.current708Packet.data,p=o?4096:0,c=h[t],l=h[t+1],d=e.currentWindow;return e.textDecoder_&&!o?(r?(n=[c,l],t++):n=[c],s=e.textDecoder_.decode(new Uint8Array(n))):s=function(t){var e=a[t]||t;return 4096&t&&t===e?"":String.fromCharCode(e)}(p|c),d.pendingNewLine&&!d.isEmpty()&&d.newLine(this.getPts(t)),d.pendingNewLine=!1,d.addText(s),t},l.prototype.multiByteCharacter=function(t,e){var i=this.current708Packet.data,s=i[t+1],n=i[t+2];return h(s)&&h(n)&&(t=this.handleText(++t,e,{isMultiByte:!0})),t},l.prototype.setCurrentWindow=function(t,e){var i=7&this.current708Packet.data[t];return e.setCurrentWindow(i),t},l.prototype.defineWindow=function(t,e){var i=this.current708Packet.data,s=i[t],n=7&s;e.setCurrentWindow(n);var o=e.currentWindow;return s=i[++t],o.visible=(32&s)>>5,o.rowLock=(16&s)>>4,o.columnLock=(8&s)>>3,o.priority=7&s,s=i[++t],o.relativePositioning=(128&s)>>7,o.anchorVertical=127&s,s=i[++t],o.anchorHorizontal=s,s=i[++t],o.anchorPoint=(240&s)>>4,o.rowCount=15&s,s=i[++t],o.columnCount=63&s,s=i[++t],o.windowStyle=(56&s)>>3,o.penStyle=7&s,o.virtualRowCount=o.rowCount+1,t},l.prototype.setWindowAttributes=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.winAttr;return s=i[++t],n.fillOpacity=(192&s)>>6,n.fillRed=(48&s)>>4,n.fillGreen=(12&s)>>2,n.fillBlue=3&s,s=i[++t],n.borderType=(192&s)>>6,n.borderRed=(48&s)>>4,n.borderGreen=(12&s)>>2,n.borderBlue=3&s,s=i[++t],n.borderType+=(128&s)>>5,n.wordWrap=(64&s)>>6,n.printDirection=(48&s)>>4,n.scrollDirection=(12&s)>>2,n.justify=3&s,s=i[++t],n.effectSpeed=(240&s)>>4,n.effectDirection=(12&s)>>2,n.displayEffect=3&s,t},l.prototype.flushDisplayed=function(t,e){for(var i=[],s=0;s<8;s++)e.windows[s].visible&&!e.windows[s].isEmpty()&&i.push(e.windows[s].getText());e.endPts=t,e.text=i.join("\n\n"),this.pushCaption(e),e.startPts=t},l.prototype.pushCaption=function(t){""!==t.text&&(this.trigger("data",{startPts:t.startPts,endPts:t.endPts,text:t.text,stream:"cc708_"+t.serviceNum}),t.text="",t.startPts=t.endPts)},l.prototype.displayWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&(e.windows[n].visible=1);return t},l.prototype.hideWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&(e.windows[n].visible=0);return t},l.prototype.toggleWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&(e.windows[n].visible^=1);return t},l.prototype.clearWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&e.windows[n].clearText();return t},l.prototype.deleteWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&e.windows[n].reset();return t},l.prototype.setPenAttributes=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.penAttr;return s=i[++t],n.textTag=(240&s)>>4,n.offset=(12&s)>>2,n.penSize=3&s,s=i[++t],n.italics=(128&s)>>7,n.underline=(64&s)>>6,n.edgeType=(56&s)>>3,n.fontStyle=7&s,t},l.prototype.setPenColor=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.penColor;return s=i[++t],n.fgOpacity=(192&s)>>6,n.fgRed=(48&s)>>4,n.fgGreen=(12&s)>>2,n.fgBlue=3&s,s=i[++t],n.bgOpacity=(192&s)>>6,n.bgRed=(48&s)>>4,n.bgGreen=(12&s)>>2,n.bgBlue=3&s,s=i[++t],n.edgeRed=(48&s)>>4,n.edgeGreen=(12&s)>>2,n.edgeBlue=3&s,t},l.prototype.setPenLocation=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.penLoc;return e.currentWindow.pendingNewLine=!0,s=i[++t],n.row=15&s,s=i[++t],n.column=63&s,t},l.prototype.reset=function(t,e){var i=this.getPts(t);return this.flushDisplayed(i,e),this.initService(e.serviceNum,t)};var d={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},u=function(t){return t=d[t]||t,String.fromCharCode(t).replace(/[\x00]/g,"")},_=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],f=function(){for(var t=[],e=15;e--;)t.push("");return t},y=function(){for(var t=[],e=15;e--;)t[e]=0;return t},C=function t(e,i,s){t.prototype.init.call(this),this.field_=e||0,this.dataChannel_=i||0,this.name_="CC"+(1+(this.field_<<1|this.dataChannel_)),this.setConstants(),this.reset(),this.push=function(t){var e,i,s,n,o;if((e=32639&t.ccData)!==this.lastControlCode_){if(4096==(61440&e)?this.lastControlCode_=e:e!==this.PADDING_&&(this.lastControlCode_=null),s=e>>>8,n=255&e,e!==this.PADDING_)if(e===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(e===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(t.pts),this.flushDisplayed(t.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,i=this.displayedIndent_,this.displayedIndent_=this.nonDisplayedIndent_,this.nonDisplayedIndent_=i,this.startPts_=t.pts;else if(e===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(t.pts);else if(e===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(t.pts);else if(e===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(t.pts);else if(e===this.CARRIAGE_RETURN_)this.clearFormatting(t.pts),this.flushDisplayed(t.pts),this.shiftRowsUp_(),this.startPts_=t.pts;else if(e===this.BACKSPACE_)"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(e===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(t.pts),this.displayed_=f(),this.displayedIndent_=y();else if(e===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=f(),this.nonDisplayedIndent_=y();else if(e===this.RESUME_DIRECT_CAPTIONING_)"paintOn"!==this.mode_&&(this.flushDisplayed(t.pts),this.displayed_=f(),this.displayedIndent_=y()),this.mode_="paintOn",this.startPts_=t.pts;else{if(!Boolean(this.mode_))return;if(this.isSpecialCharacter(s,n))o=u((s=(3&s)<<8)|n),this[this.mode_](t.pts,o),this.column_++;else if(this.isExtCharacter(s,n))"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),o=u((s=(3&s)<<8)|n),this[this.mode_](t.pts,o),this.column_++;else if(this.isMidRowCode(s,n))this.clearFormatting(t.pts),this[this.mode_](t.pts," "),this.column_++,14&~n||this.addFormatting(t.pts,["i"]),1&~n||this.addFormatting(t.pts,["u"]);else if(this.isOffsetControlCode(s,n)){var r=3&n;this.column_+=r,this.incrementIdentation(r)}else if(this.isPAC(s,n)){var a=_.indexOf(7968&e);"rollUp"===this.mode_&&(a-this.rollUpRows_+1<0&&(a=this.rollUpRows_-1),this.setRollUp(t.pts,a)),a!==this.row_&&(this.clearFormatting(t.pts),this.changeRow(a)),1&n&&-1===this.formatting_.indexOf("u")&&this.addFormatting(t.pts,["u"]),16&~e||(this.column_=4*((14&e)>>1),"popOn"===this.mode_?this.nonDisplayedIndent_[this.row_]=this.column_:"rollUp"===this.mode_&&(this.displayedIndent_[this.row_]=this.column_)),this.isColorPAC(n)&&(14&~n||this.addFormatting(t.pts,["i"]))}else this.isNormalChar(s)&&(o=u(s),0!==n&&(o+=u(n)),this[this.mode_](t.pts,o),this.column_+=o.length)}}else this.lastControlCode_=null}};return C.prototype=new e,C.prototype.flushDisplayed=function(t){for(var e=0;e<this.displayed_.length;e++){var i=this.displayed_[e];i&&i.length&&this.trigger("data",{startPts:this.startPts_,endPts:t,text:i,stream:this.name_,position:{row:e,column:this.displayedIndent_[e]}})}},C.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=f(),this.nonDisplayed_=f(),this.displayedIndent_=y(),this.nonDisplayedIndent_=y(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[]},C.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_,this.TAB_OFFSET_1_=33,this.TAB_OFFSET_2_=34,this.TAB_OFFSET_3_=35},C.prototype.isSpecialCharacter=function(t,e){return t===this.EXT_&&e>=48&&e<=63},C.prototype.isExtCharacter=function(t,e){return(t===this.EXT_+1||t===this.EXT_+2)&&e>=32&&e<=63},C.prototype.isMidRowCode=function(t,e){return t===this.EXT_&&e>=32&&e<=47},C.prototype.isOffsetControlCode=function(t,e){return t===this.OFFSET_&&e>=this.TAB_OFFSET_1_&&e<=this.TAB_OFFSET_3_},C.prototype.isPAC=function(t,e){return t>=this.BASE_&&t<this.BASE_+8&&e>=64&&e<=127},C.prototype.isColorPAC=function(t){return t>=64&&t<=79||t>=96&&t<=127},C.prototype.isNormalChar=function(t){return t>=32&&t<=127},C.prototype.setRollUp=function(t,e){if("rollUp"!==this.mode_&&(this.row_=14,this.mode_="rollUp",this.flushDisplayed(t),this.nonDisplayed_=f(),this.displayed_=f(),this.displayedIndent_=y(),this.nonDisplayedIndent_=y()),void 0!==e&&e!==this.row_)for(var i=0;i<this.rollUpRows_;i++)this.displayed_[e-i]=this.displayed_[this.row_-i],this.displayed_[this.row_-i]="";void 0===e&&(e=this.row_),this.topRow_=e-this.rollUpRows_+1},C.prototype.addFormatting=function(t,e){this.formatting_=this.formatting_.concat(e);var i=e.reduce(function(t,e){return t+"<"+e+">"},"");this[this.mode_](t,i)},C.prototype.clearFormatting=function(t){if(this.formatting_.length){var e=this.formatting_.reverse().reduce(function(t,e){return t+"</"+e+">"},"");this.formatting_=[],this[this.mode_](t,e)}},C.prototype.popOn=function(t,e){var i=this.nonDisplayed_[this.row_];i+=e,this.nonDisplayed_[this.row_]=i},C.prototype.rollUp=function(t,e){var i=this.displayed_[this.row_];i+=e,this.displayed_[this.row_]=i},C.prototype.shiftRowsUp_=function(){var t;for(t=0;t<this.topRow_;t++)this.displayed_[t]="";for(t=this.row_+1;t<15;t++)this.displayed_[t]="";for(t=this.topRow_;t<this.row_;t++)this.displayed_[t]=this.displayed_[t+1];this.displayed_[this.row_]=""},C.prototype.paintOn=function(t,e){var i=this.displayed_[this.row_];i+=e,this.displayed_[this.row_]=i},C.prototype.changeRow=function(t){if("rollUp"===this.mode_){var e=this.row_-this.topRow_+1;this.topRow_=t-e+1;var i=this.displayed_,s=this.displayedIndent_;this.displayed_=f(),this.displayedIndent_=y();for(var n=0;n<e;n++)t-n>=0&&(this.displayed_[t-n]=i[this.row_-n],this.displayedIndent_[t-n]=s[this.row_-n])}this.row_=t},C.prototype.incrementIdentation=function(t){"popOn"===this.mode_?this.nonDisplayedIndent_[this.row_]+=t:"rollUp"===this.mode_&&(this.displayedIndent_[this.row_]+=t)},{CaptionStream:{CaptionStream:r,Cea608Stream:C,Cea708Stream:l}.CaptionStream}}()}()},82396:function(t,e,i){"use strict";var s=this&&this.__spreadArray||function(t,e,i){if(i||2===arguments.length)for(var s,n=0,o=e.length;n<o;n++)!s&&n in e||(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.Cea608Extractor=e.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS=e.MPEG_TS_TIMESCALE=void 0;var n=i(1001),o=i(34047),r=i(3188);e.MPEG_TS_TIMESCALE=9e4,e.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS=s(s([],o.AVC_CODEC_TAGS,!0),o.HEVC_CODEC_TAGS,!0);var a=function(){function t(t,e,i){void 0===i&&(i=!1),this.logger=t,this.MP4Module=e,this.parseCea708Caption=i,this.Mv=1,this.Nv=0}return t.prototype.extract=function(t){var i,s,r=this,a=(null!==(s=null===(i=t.getInitSegment())||void 0===i?void 0:i.getParsedData())&&void 0!==s?s:t.getParsedData()).get("moov.trak.mdia.mdhd"),h=(0,o.getCodecTag)(t);if(!e.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS.includes(h))return Promise.resolve([]);var p=o.AVC_CODEC_TAGS.includes(h)?n.NalUnitTypeAvc.SEI:n.NalUnitTypeHevc.SEI;a&&(this.Mv=a.timescale);var c=t.getParsedData().get("moov.mvex.trex");c&&(this.Nv=c.default_sample_duration);var l=this.MP4Module.getMp4Fragments(t).flatMap(function(e){var i=e.moof.get("traf.tfdt"),s=r.MP4Module.getVideoSamples(e,t,[p],r.logger),n=i?r.Ov(i.baseMediaDecodeTime):0;return s.flatMap(function(t){var e=t.nalus.map(function(e){return function(t,e){return{nalUnitType:"sei_rbsp",escapedRBSP:new Uint8Array(t.data.buffer,t.data.byteOffset,t.data.byteLength),pts:e}}(e,n+r.Ov(t.compositionTimeOffset))});return n+=Math.floor(r.Ov(t.duration||r.Nv)),e})});return this.Pv(l)},t.prototype.Ov=function(t){return t/this.Mv*e.MPEG_TS_TIMESCALE},t.prototype.Pv=function(t){return 0===t.length?Promise.resolve([]):(this.Lv||(this.Lv=new r.Cea608Processor(this.parseCea708Caption)),this.Lv.getCaptions(t).catch(function(){return Promise.resolve([])}))},t.prototype.reset=function(){this.Lv&&this.Lv.reset()},t.prototype.dispose=function(){this.Lv&&this.Lv.dispose()},t}();e.Cea608Extractor=a},3188:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Cea608Processor=void 0;var s=i(30251),n=i(85269),o=function(){function t(t){var e=this;this.DV=[],this.pushCaptions=function(t){e.CV=!1,t.forEach(function(t){return e.HV.push(t)})},this.IV=function(){e.HV.on("data",e.JV),e.HV.on("done",e.KV)},this.JV=function(t){e.DV.push((0,n.assembleCaption)(t))},this.KV=function(){if(!e.CV)if(e.CV=!0,e.LV(e.DV),e.DV=[],e.FV.length>0){var t=e.FV[0];e.process(t.captionPackets)}else e.GV=!1},this.EV=t,this.DV=[],this.FV=[],this.GV=!1,this.HV=new s.CaptionStream({parse708captions:t}),this.IV()}return t.prototype.getCaptions=function(t){var e=this;return new Promise(function(i,s){(!t||!Array.isArray(t)||t.length<1)&&s(new Error("Could not get captions, no SeiNal provided")),e.FV.push({captionPackets:t,resolve:i,reject:s}),e.GV||(e.GV=!0,e.process(t))})},t.prototype.process=function(t){this.pushCaptions(t),this.flush()},t.prototype.flush=function(){this.HV.flush()},t.prototype.reset=function(){this.HV.reset()},t.prototype.LV=function(t){var e=this,i=t.filter(function(t){return e.EV?t.channel.includes("708"):!t.channel.includes("708")}),s=this.FV.shift();null==s||s.resolve(i)},t.prototype.dispose=function(){this.HV.reset()},t}();e.Cea608Processor=o},20784:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CeaSubtitlesModuleDefinition=void 0;var s=i(62756),n=i(82396);e.CeaSubtitlesModuleDefinition={name:s.ModuleName.SubtitlesCEA608,module:function(){return{Cea608Extractor:n.Cea608Extractor,CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS:n.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS}},dependencies:[s.ModuleName.Subtitles]},e.default=e.CeaSubtitlesModuleDefinition},85269:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assembleCaption=function(t){return{start:t.startPts/i,end:t.endPts/i,text:t.text,channel:t.stream,position:t.position}};var i=9e4}},function(t){return function(){return t(20784)}()}])});
17
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["subtitles-cea608"]=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player["subtitles-cea608"]=e())}(self,function(){return(self.webpackChunkbitmovin_player=self.webpackChunkbitmovin_player||[]).push([[886],{30251:function(t){!function(){t.exports=function(){"use strict";var t=function(){this.init=function(){var t={};this.on=function(e,i){t[e]||(t[e]=[]),t[e]=t[e].concat(i)},this.off=function(e,i){var s;return!!t[e]&&(s=t[e].indexOf(i),t[e]=t[e].slice(),t[e].splice(s,1),s>-1)},this.trigger=function(e){var i,s,n,o;if(i=t[e])if(2===arguments.length)for(n=i.length,s=0;s<n;++s)i[s].call(this,arguments[1]);else{for(o=[],s=arguments.length,s=1;s<arguments.length;++s)o.push(arguments[s]);for(n=i.length,s=0;s<n;++s)i[s].apply(this,o)}},this.dispose=function(){t={}}}};t.prototype.pipe=function(t){return this.on("data",function(e){t.push(e)}),this.on("done",function(e){t.flush(e)}),this.on("partialdone",function(e){t.partialFlush(e)}),this.on("endedtimeline",function(e){t.endTimeline(e)}),this.on("reset",function(e){t.reset(e)}),t},t.prototype.push=function(t){this.trigger("data",t)},t.prototype.flush=function(t){this.trigger("done",t)},t.prototype.partialFlush=function(t){this.trigger("partialdone",t)},t.prototype.endTimeline=function(t){this.trigger("endedtimeline",t)},t.prototype.reset=function(t){this.trigger("reset",t)};var e=t,i=function(t){for(var e=0,i=[],s=0,n=0;e<t.byteLength&&128!==t[e];){for(;255===t[e];)s+=255,e++;for(s+=t[e++];255===t[e];)n+=255,e++;n+=t[e++];var o=String.fromCharCode(t[e+3],t[e+4],t[e+5],t[e+6]);4===s&&"GA94"===o&&i.push({payloadType:s,payloadSize:n,payload:t.subarray(e,e+n)}),e+=n,s=0,n=0}return i},s=function(t){return 181!==t.payload[0]||49!=(t.payload[1]<<8|t.payload[2])||"GA94"!==String.fromCharCode(t.payload[3],t.payload[4],t.payload[5],t.payload[6])||3!==t.payload[7]?null:t.payload.subarray(8,t.payload.length-1)},n=function(t,e){var i,s,n,o,r=[];if(!(64&e[0]))return r;for(s=31&e[0],i=0;i<s;i++)o={type:3&e[2+(n=3*i)],pts:t},4&e[n+2]&&(o.ccData=e[n+3]<<8|e[n+4],r.push(o));return r},o=4,r=function t(e){e=e||{},t.prototype.init.call(this),this.parse708captions_="boolean"!=typeof e.parse708captions||e.parse708captions,this.captionPackets_=[],this.ccStreams_=[new w(0,0),new w(0,1),new w(1,0),new w(1,1)],this.parse708captions_&&(this.cc708Stream_=new l({captionServices:e.captionServices})),this.reset(),this.ccStreams_.forEach(function(t){t.on("data",this.trigger.bind(this,"data")),t.on("partialdone",this.trigger.bind(this,"partialdone")),t.on("done",this.trigger.bind(this,"done"))},this),this.parse708captions_&&(this.cc708Stream_.on("data",this.trigger.bind(this,"data")),this.cc708Stream_.on("partialdone",this.trigger.bind(this,"partialdone")),this.cc708Stream_.on("done",this.trigger.bind(this,"done")))};(r.prototype=new e).push=function(t){var e=this;"sei_rbsp"===t.nalUnitType&&i(t.escapedRBSP).filter(function(t){return t.payloadType===o}).map(s).forEach(function(i){i&&(e.captionPackets_=e.captionPackets_.concat(n(t.pts,i)))})},r.prototype.flushCCStreams=function(t){this.ccStreams_.forEach(function(e){return"flush"===t?e.flush():e.partialFlush()},this)},r.prototype.flushStream=function(t){this.captionPackets_.length?(this.captionPackets_.forEach(function(t,e){t.presortIndex=e}),this.captionPackets_.sort(function(t,e){return t.pts===e.pts?t.presortIndex-e.presortIndex:t.pts-e.pts}),this.captionPackets_.forEach(function(t){t.type<2?this.dispatchCea608Packet(t):this.dispatchCea708Packet(t)},this),this.captionPackets_.length=0,this.flushCCStreams(t)):this.flushCCStreams(t)},r.prototype.flush=function(){return this.flushStream("flush")},r.prototype.partialFlush=function(){return this.flushStream("partialFlush")},r.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(t){t.reset()})},r.prototype.dispatchCea608Packet=function(t){this.setsTextOrXDSActive(t)?this.activeCea608Channel_[t.type]=null:this.setsChannel1Active(t)?this.activeCea608Channel_[t.type]=0:this.setsChannel2Active(t)&&(this.activeCea608Channel_[t.type]=1),null!==this.activeCea608Channel_[t.type]&&this.ccStreams_[(t.type<<1)+this.activeCea608Channel_[t.type]].push(t)},r.prototype.setsChannel1Active=function(t){return 4096==(30720&t.ccData)},r.prototype.setsChannel2Active=function(t){return 6144==(30720&t.ccData)},r.prototype.setsTextOrXDSActive=function(t){return 256==(28928&t.ccData)||4138==(30974&t.ccData)||6186==(30974&t.ccData)},r.prototype.dispatchCea708Packet=function(t){this.parse708captions_&&this.cc708Stream_.push(t)};var a={127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600},h=function(t){return 32<=t&&t<=127||160<=t&&t<=255},p=function(t){this.windowNum=t,this.reset()};p.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},p.prototype.getText=function(){return this.rows.join("\n")},p.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},p.prototype.newLine=function(t){for(this.rows.length>=this.virtualRowCount&&"function"==typeof this.beforeRowOverflow&&this.beforeRowOverflow(t),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},p.prototype.isEmpty=function(){return 0===this.rows.length||1===this.rows.length&&""===this.rows[0]},p.prototype.addText=function(t){this.rows[this.rowIdx]+=t},p.prototype.backspace=function(){if(!this.isEmpty()){var t=this.rows[this.rowIdx];this.rows[this.rowIdx]=t.substr(0,t.length-1)}};var c=function(t,e,i){this.serviceNum=t,this.text="",this.currentWindow=new p(-1),this.windows=[],this.stream=i,"string"==typeof e&&this.createTextDecoder(e)};c.prototype.init=function(t,e){this.startPts=t;for(var i=0;i<8;i++)this.windows[i]=new p(i),"function"==typeof e&&(this.windows[i].beforeRowOverflow=e)},c.prototype.setCurrentWindow=function(t){this.currentWindow=this.windows[t]},c.prototype.createTextDecoder=function(t){if("undefined"==typeof TextDecoder)this.stream.trigger("log",{level:"warn",message:"The `encoding` option is unsupported without TextDecoder support"});else try{this.textDecoder_=new TextDecoder(t)}catch(e){this.stream.trigger("log",{level:"warn",message:"TextDecoder could not be created with "+t+" encoding. "+e})}};var l=function t(e){e=e||{},t.prototype.init.call(this);var i,s=this,n=e.captionServices||{},o={};Object.keys(n).forEach(function(t){i=n[t],/^SERVICE/.test(t)&&(o[t]=i.encoding)}),this.serviceEncodings=o,this.current708Packet=null,this.services={},this.push=function(t){3===t.type?(s.new708Packet(),s.add708Bytes(t)):(null===s.current708Packet&&s.new708Packet(),s.add708Bytes(t))}};l.prototype=new e,l.prototype.new708Packet=function(){null!==this.current708Packet&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},l.prototype.add708Bytes=function(t){var e=t.ccData,i=e>>>8,s=255&e;this.current708Packet.ptsVals.push(t.pts),this.current708Packet.data.push(i),this.current708Packet.data.push(s)},l.prototype.push708Packet=function(){var t=this.current708Packet,e=t.data,i=null,s=null,n=0,o=e[n++];for(t.seq=o>>6,t.sizeCode=63&o;n<e.length;n++)s=31&(o=e[n++]),7==(i=o>>5)&&s>0&&(i=o=e[n++]),this.pushServiceBlock(i,n,s),s>0&&(n+=s-1)},l.prototype.pushServiceBlock=function(t,e,i){var s,n=e,o=this.current708Packet.data,r=this.services[t];for(r||(r=this.initService(t,n));n<e+i&&n<o.length;n++)s=o[n],h(s)?n=this.handleText(n,r):24===s?n=this.multiByteCharacter(n,r):16===s?n=this.extendedCommands(n,r):128<=s&&s<=135?n=this.setCurrentWindow(n,r):152<=s&&s<=159?n=this.defineWindow(n,r):136===s?n=this.clearWindows(n,r):140===s?n=this.deleteWindows(n,r):137===s?n=this.displayWindows(n,r):138===s?n=this.hideWindows(n,r):139===s?n=this.toggleWindows(n,r):151===s?n=this.setWindowAttributes(n,r):144===s?n=this.setPenAttributes(n,r):145===s?n=this.setPenColor(n,r):146===s?n=this.setPenLocation(n,r):143===s?r=this.reset(n,r):8===s?r.currentWindow.backspace():12===s?r.currentWindow.clearText():13===s?r.currentWindow.pendingNewLine=!0:14===s?r.currentWindow.clearText():141===s&&n++},l.prototype.extendedCommands=function(t,e){var i=this.current708Packet.data[++t];return h(i)&&(t=this.handleText(t,e,{isExtended:!0})),t},l.prototype.getPts=function(t){return this.current708Packet.ptsVals[Math.floor(t/2)]},l.prototype.initService=function(t,e){var i,s,n=this;return(i="SERVICE"+t)in this.serviceEncodings&&(s=this.serviceEncodings[i]),this.services[t]=new c(t,s,n),this.services[t].init(this.getPts(e),function(e){n.flushDisplayed(e,n.services[t])}),this.services[t]},l.prototype.handleText=function(t,e,i){var s,n,o=i&&i.isExtended,r=i&&i.isMultiByte,h=this.current708Packet.data,p=o?4096:0,c=h[t],l=h[t+1],d=e.currentWindow;return e.textDecoder_&&!o?(r?(n=[c,l],t++):n=[c],s=e.textDecoder_.decode(new Uint8Array(n))):s=function(t){var e=a[t]||t;return 4096&t&&t===e?"":String.fromCharCode(e)}(p|c),d.pendingNewLine&&!d.isEmpty()&&d.newLine(this.getPts(t)),d.pendingNewLine=!1,d.addText(s),t},l.prototype.multiByteCharacter=function(t,e){var i=this.current708Packet.data,s=i[t+1],n=i[t+2];return h(s)&&h(n)&&(t=this.handleText(++t,e,{isMultiByte:!0})),t},l.prototype.setCurrentWindow=function(t,e){var i=7&this.current708Packet.data[t];return e.setCurrentWindow(i),t},l.prototype.defineWindow=function(t,e){var i=this.current708Packet.data,s=i[t],n=7&s;e.setCurrentWindow(n);var o=e.currentWindow;return s=i[++t],o.visible=(32&s)>>5,o.rowLock=(16&s)>>4,o.columnLock=(8&s)>>3,o.priority=7&s,s=i[++t],o.relativePositioning=(128&s)>>7,o.anchorVertical=127&s,s=i[++t],o.anchorHorizontal=s,s=i[++t],o.anchorPoint=(240&s)>>4,o.rowCount=15&s,s=i[++t],o.columnCount=63&s,s=i[++t],o.windowStyle=(56&s)>>3,o.penStyle=7&s,o.virtualRowCount=o.rowCount+1,t},l.prototype.setWindowAttributes=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.winAttr;return s=i[++t],n.fillOpacity=(192&s)>>6,n.fillRed=(48&s)>>4,n.fillGreen=(12&s)>>2,n.fillBlue=3&s,s=i[++t],n.borderType=(192&s)>>6,n.borderRed=(48&s)>>4,n.borderGreen=(12&s)>>2,n.borderBlue=3&s,s=i[++t],n.borderType+=(128&s)>>5,n.wordWrap=(64&s)>>6,n.printDirection=(48&s)>>4,n.scrollDirection=(12&s)>>2,n.justify=3&s,s=i[++t],n.effectSpeed=(240&s)>>4,n.effectDirection=(12&s)>>2,n.displayEffect=3&s,t},l.prototype.flushDisplayed=function(t,e){for(var i=[],s=0;s<8;s++)e.windows[s].visible&&!e.windows[s].isEmpty()&&i.push(e.windows[s].getText());e.endPts=t,e.text=i.join("\n\n"),this.pushCaption(e),e.startPts=t},l.prototype.pushCaption=function(t){""!==t.text&&(this.trigger("data",{startPts:t.startPts,endPts:t.endPts,text:t.text,stream:"cc708_"+t.serviceNum}),t.text="",t.startPts=t.endPts)},l.prototype.displayWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&(e.windows[n].visible=1);return t},l.prototype.hideWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&(e.windows[n].visible=0);return t},l.prototype.toggleWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&(e.windows[n].visible^=1);return t},l.prototype.clearWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&e.windows[n].clearText();return t},l.prototype.deleteWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&e.windows[n].reset();return t},l.prototype.setPenAttributes=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.penAttr;return s=i[++t],n.textTag=(240&s)>>4,n.offset=(12&s)>>2,n.penSize=3&s,s=i[++t],n.italics=(128&s)>>7,n.underline=(64&s)>>6,n.edgeType=(56&s)>>3,n.fontStyle=7&s,t},l.prototype.setPenColor=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.penColor;return s=i[++t],n.fgOpacity=(192&s)>>6,n.fgRed=(48&s)>>4,n.fgGreen=(12&s)>>2,n.fgBlue=3&s,s=i[++t],n.bgOpacity=(192&s)>>6,n.bgRed=(48&s)>>4,n.bgGreen=(12&s)>>2,n.bgBlue=3&s,s=i[++t],n.edgeRed=(48&s)>>4,n.edgeGreen=(12&s)>>2,n.edgeBlue=3&s,t},l.prototype.setPenLocation=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.penLoc;return e.currentWindow.pendingNewLine=!0,s=i[++t],n.row=15&s,s=i[++t],n.column=63&s,t},l.prototype.reset=function(t,e){var i=this.getPts(t);return this.flushDisplayed(i,e),this.initService(e.serviceNum,t)};var d={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},u=function(t){return t=d[t]||t,String.fromCharCode(t).replace(/[\x00]/g,"")},_=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],f=function(){for(var t=[],e=15;e--;)t.push("");return t},y=function(){for(var t=[],e=15;e--;)t[e]=0;return t},w=function t(e,i,s){t.prototype.init.call(this),this.field_=e||0,this.dataChannel_=i||0,this.name_="CC"+(1+(this.field_<<1|this.dataChannel_)),this.setConstants(),this.reset(),this.push=function(t){var e,i,s,n,o;if((e=32639&t.ccData)!==this.lastControlCode_){if(4096==(61440&e)?this.lastControlCode_=e:e!==this.PADDING_&&(this.lastControlCode_=null),s=e>>>8,n=255&e,e!==this.PADDING_)if(e===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(e===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(t.pts),this.flushDisplayed(t.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,i=this.displayedIndent_,this.displayedIndent_=this.nonDisplayedIndent_,this.nonDisplayedIndent_=i,this.startPts_=t.pts;else if(e===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(t.pts);else if(e===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(t.pts);else if(e===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(t.pts);else if(e===this.CARRIAGE_RETURN_)this.clearFormatting(t.pts),this.flushDisplayed(t.pts),this.shiftRowsUp_(),this.startPts_=t.pts;else if(e===this.BACKSPACE_)"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(e===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(t.pts),this.displayed_=f(),this.displayedIndent_=y();else if(e===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=f(),this.nonDisplayedIndent_=y();else if(e===this.RESUME_DIRECT_CAPTIONING_)"paintOn"!==this.mode_&&(this.flushDisplayed(t.pts),this.displayed_=f(),this.displayedIndent_=y()),this.mode_="paintOn",this.startPts_=t.pts;else{if(!Boolean(this.mode_))return;if(this.isSpecialCharacter(s,n))o=u((s=(3&s)<<8)|n),this[this.mode_](t.pts,o),this.column_++;else if(this.isExtCharacter(s,n))"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),o=u((s=(3&s)<<8)|n),this[this.mode_](t.pts,o),this.column_++;else if(this.isMidRowCode(s,n))this.clearFormatting(t.pts),this[this.mode_](t.pts," "),this.column_++,14&~n||this.addFormatting(t.pts,["i"]),1&~n||this.addFormatting(t.pts,["u"]);else if(this.isOffsetControlCode(s,n)){var r=3&n;this.column_+=r,this.incrementIdentation(r)}else if(this.isPAC(s,n)){var a=_.indexOf(7968&e);"rollUp"===this.mode_&&(a-this.rollUpRows_+1<0&&(a=this.rollUpRows_-1),this.setRollUp(t.pts,a)),a!==this.row_&&(this.clearFormatting(t.pts),this.changeRow(a)),1&n&&-1===this.formatting_.indexOf("u")&&this.addFormatting(t.pts,["u"]),16&~e||(this.column_=4*((14&e)>>1),"popOn"===this.mode_?this.nonDisplayedIndent_[this.row_]=this.column_:"rollUp"===this.mode_&&(this.displayedIndent_[this.row_]=this.column_)),this.isColorPAC(n)&&(14&~n||this.addFormatting(t.pts,["i"]))}else this.isNormalChar(s)&&(o=u(s),0!==n&&(o+=u(n)),this[this.mode_](t.pts,o),this.column_+=o.length)}}else this.lastControlCode_=null}};return w.prototype=new e,w.prototype.flushDisplayed=function(t){for(var e=0;e<this.displayed_.length;e++){var i=this.displayed_[e];i&&i.length&&this.trigger("data",{startPts:this.startPts_,endPts:t,text:i,stream:this.name_,position:{row:e,column:this.displayedIndent_[e]}})}},w.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=f(),this.nonDisplayed_=f(),this.displayedIndent_=y(),this.nonDisplayedIndent_=y(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[]},w.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_,this.TAB_OFFSET_1_=33,this.TAB_OFFSET_2_=34,this.TAB_OFFSET_3_=35},w.prototype.isSpecialCharacter=function(t,e){return t===this.EXT_&&e>=48&&e<=63},w.prototype.isExtCharacter=function(t,e){return(t===this.EXT_+1||t===this.EXT_+2)&&e>=32&&e<=63},w.prototype.isMidRowCode=function(t,e){return t===this.EXT_&&e>=32&&e<=47},w.prototype.isOffsetControlCode=function(t,e){return t===this.OFFSET_&&e>=this.TAB_OFFSET_1_&&e<=this.TAB_OFFSET_3_},w.prototype.isPAC=function(t,e){return t>=this.BASE_&&t<this.BASE_+8&&e>=64&&e<=127},w.prototype.isColorPAC=function(t){return t>=64&&t<=79||t>=96&&t<=127},w.prototype.isNormalChar=function(t){return t>=32&&t<=127},w.prototype.setRollUp=function(t,e){if("rollUp"!==this.mode_&&(this.row_=14,this.mode_="rollUp",this.flushDisplayed(t),this.nonDisplayed_=f(),this.displayed_=f(),this.displayedIndent_=y(),this.nonDisplayedIndent_=y()),void 0!==e&&e!==this.row_)for(var i=0;i<this.rollUpRows_;i++)this.displayed_[e-i]=this.displayed_[this.row_-i],this.displayed_[this.row_-i]="";void 0===e&&(e=this.row_),this.topRow_=e-this.rollUpRows_+1},w.prototype.addFormatting=function(t,e){this.formatting_=this.formatting_.concat(e);var i=e.reduce(function(t,e){return t+"<"+e+">"},"");this[this.mode_](t,i)},w.prototype.clearFormatting=function(t){if(this.formatting_.length){var e=this.formatting_.reverse().reduce(function(t,e){return t+"</"+e+">"},"");this.formatting_=[],this[this.mode_](t,e)}},w.prototype.popOn=function(t,e){var i=this.nonDisplayed_[this.row_];i+=e,this.nonDisplayed_[this.row_]=i},w.prototype.rollUp=function(t,e){var i=this.displayed_[this.row_];i+=e,this.displayed_[this.row_]=i},w.prototype.shiftRowsUp_=function(){var t;for(t=0;t<this.topRow_;t++)this.displayed_[t]="";for(t=this.row_+1;t<15;t++)this.displayed_[t]="";for(t=this.topRow_;t<this.row_;t++)this.displayed_[t]=this.displayed_[t+1];this.displayed_[this.row_]=""},w.prototype.paintOn=function(t,e){var i=this.displayed_[this.row_];i+=e,this.displayed_[this.row_]=i},w.prototype.changeRow=function(t){if("rollUp"===this.mode_){var e=this.row_-this.topRow_+1;this.topRow_=t-e+1;var i=this.displayed_,s=this.displayedIndent_;this.displayed_=f(),this.displayedIndent_=y();for(var n=0;n<e;n++)t-n>=0&&(this.displayed_[t-n]=i[this.row_-n],this.displayedIndent_[t-n]=s[this.row_-n])}this.row_=t},w.prototype.incrementIdentation=function(t){"popOn"===this.mode_?this.nonDisplayedIndent_[this.row_]+=t:"rollUp"===this.mode_&&(this.displayedIndent_[this.row_]+=t)},{CaptionStream:{CaptionStream:r,Cea608Stream:w,Cea708Stream:l}.CaptionStream}}()}()},82396:function(t,e,i){"use strict";var s=this&&this.__spreadArray||function(t,e,i){if(i||2===arguments.length)for(var s,n=0,o=e.length;n<o;n++)!s&&n in e||(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.Cea608Extractor=e.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS=e.MPEG_TS_TIMESCALE=void 0;var n=i(1001),o=i(34047),r=i(3188);e.MPEG_TS_TIMESCALE=9e4,e.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS=s(s([],o.AVC_CODEC_TAGS,!0),o.HEVC_CODEC_TAGS,!0);var a=function(){function t(t,e,i){void 0===i&&(i=!1),this.logger=t,this.MP4Module=e,this.parseCea708Caption=i,this.qu=1,this.ru=0}return t.prototype.extract=function(t){var i,s,r=this,a=(null!==(s=null===(i=t.getInitSegment())||void 0===i?void 0:i.getParsedData())&&void 0!==s?s:t.getParsedData()).get("moov.trak.mdia.mdhd"),h=(0,o.getCodecTag)(t);if(!e.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS.includes(h))return Promise.resolve([]);var p=o.AVC_CODEC_TAGS.includes(h)?n.NalUnitTypeAvc.SEI:n.NalUnitTypeHevc.SEI;a&&(this.qu=a.timescale);var c=t.getParsedData().get("moov.mvex.trex");c&&(this.ru=c.default_sample_duration);var l=this.MP4Module.getMp4Fragments(t).flatMap(function(e){var i=e.moof.get("traf.tfdt"),s=r.MP4Module.getVideoSamples(e,t,[p],r.logger),n=i?r.su(i.baseMediaDecodeTime):0;return s.flatMap(function(t){var e=t.nalus.map(function(e){return function(t,e){return{nalUnitType:"sei_rbsp",escapedRBSP:new Uint8Array(t.data.buffer,t.data.byteOffset,t.data.byteLength),pts:e}}(e,n+r.su(t.compositionTimeOffset))});return n+=Math.floor(r.su(t.duration||r.ru)),e})});return this.tu(l)},t.prototype.su=function(t){return t/this.qu*e.MPEG_TS_TIMESCALE},t.prototype.tu=function(t){return 0===t.length?Promise.resolve([]):(this.pu||(this.pu=new r.Cea608Processor(this.parseCea708Caption)),this.pu.getCaptions(t).catch(function(){return Promise.resolve([])}))},t.prototype.reset=function(){this.pu&&this.pu.reset()},t.prototype.dispose=function(){this.pu&&this.pu.dispose()},t}();e.Cea608Extractor=a},3188:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Cea608Processor=void 0;var s=i(30251),n=i(85269),o=function(){function t(t){var e=this;this.xU=[],this.pushCaptions=function(t){e.wU=!1,t.forEach(function(t){return e.BU.push(t)})},this.CU=function(){e.BU.on("data",e.DU),e.BU.on("done",e.EU)},this.DU=function(t){e.xU.push((0,n.assembleCaption)(t))},this.EU=function(){if(!e.wU)if(e.wU=!0,e.FU(e.xU),e.xU=[],e.zU.length>0){var t=e.zU[0];e.process(t.captionPackets)}else e.AU=!1},this.yU=t,this.xU=[],this.zU=[],this.AU=!1,this.BU=new s.CaptionStream({parse708captions:t}),this.CU()}return t.prototype.getCaptions=function(t){var e=this;return new Promise(function(i,s){(!t||!Array.isArray(t)||t.length<1)&&s(new Error("Could not get captions, no SeiNal provided")),e.zU.push({captionPackets:t,resolve:i,reject:s}),e.AU||(e.AU=!0,e.process(t))})},t.prototype.process=function(t){this.pushCaptions(t),this.flush()},t.prototype.flush=function(){this.BU.flush()},t.prototype.reset=function(){this.BU.reset()},t.prototype.FU=function(t){var e=this,i=t.filter(function(t){return e.yU?t.channel.includes("708"):!t.channel.includes("708")}),s=this.zU.shift();null==s||s.resolve(i)},t.prototype.dispose=function(){this.BU.reset()},t}();e.Cea608Processor=o},20784:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CeaSubtitlesModuleDefinition=void 0;var s=i(62756),n=i(82396);e.CeaSubtitlesModuleDefinition={name:s.ModuleName.SubtitlesCEA608,module:function(){return{Cea608Extractor:n.Cea608Extractor,CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS:n.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS}},dependencies:[s.ModuleName.Subtitles]},e.default=e.CeaSubtitlesModuleDefinition},85269:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assembleCaption=function(t){return{start:t.startPts/i,end:t.endPts/i,text:t.text,channel:t.stream,position:t.position}};var i=9e4}},function(t){return function(){return t(20784)}()}])});
18
18
  })();
@@ -9,10 +9,10 @@
9
9
  * This software includes open-source components. See THIRD_PARTY_NOTICES
10
10
  * in the distribution for details.
11
11
  *
12
- * Bitmovin Player Version 8.280.0
12
+ * Bitmovin Player Version 8.281.0
13
13
  *
14
14
  ****************************************************************************/
15
15
 
16
16
  (function() {
17
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["subtitles-cea608"]=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player["subtitles-cea608"]=e())}(self,function(){return(self.webpackChunkbitmovin_player=self.webpackChunkbitmovin_player||[]).push([[886],{30251:function(t){!function(){t.exports=function(){"use strict";var t=function(){this.init=function(){var t={};this.on=function(e,i){t[e]||(t[e]=[]),t[e]=t[e].concat(i)},this.off=function(e,i){var s;return!!t[e]&&(s=t[e].indexOf(i),t[e]=t[e].slice(),t[e].splice(s,1),s>-1)},this.trigger=function(e){var i,s,n,o;if(i=t[e])if(2===arguments.length)for(n=i.length,s=0;s<n;++s)i[s].call(this,arguments[1]);else{for(o=[],s=arguments.length,s=1;s<arguments.length;++s)o.push(arguments[s]);for(n=i.length,s=0;s<n;++s)i[s].apply(this,o)}},this.dispose=function(){t={}}}};t.prototype.pipe=function(t){return this.on("data",function(e){t.push(e)}),this.on("done",function(e){t.flush(e)}),this.on("partialdone",function(e){t.partialFlush(e)}),this.on("endedtimeline",function(e){t.endTimeline(e)}),this.on("reset",function(e){t.reset(e)}),t},t.prototype.push=function(t){this.trigger("data",t)},t.prototype.flush=function(t){this.trigger("done",t)},t.prototype.partialFlush=function(t){this.trigger("partialdone",t)},t.prototype.endTimeline=function(t){this.trigger("endedtimeline",t)},t.prototype.reset=function(t){this.trigger("reset",t)};var e=t,i=function(t){for(var e=0,i=[],s=0,n=0;e<t.byteLength&&128!==t[e];){for(;255===t[e];)s+=255,e++;for(s+=t[e++];255===t[e];)n+=255,e++;n+=t[e++];var o=String.fromCharCode(t[e+3],t[e+4],t[e+5],t[e+6]);4===s&&"GA94"===o&&i.push({payloadType:s,payloadSize:n,payload:t.subarray(e,e+n)}),e+=n,s=0,n=0}return i},s=function(t){return 181!==t.payload[0]||49!=(t.payload[1]<<8|t.payload[2])||"GA94"!==String.fromCharCode(t.payload[3],t.payload[4],t.payload[5],t.payload[6])||3!==t.payload[7]?null:t.payload.subarray(8,t.payload.length-1)},n=function(t,e){var i,s,n,o,r=[];if(!(64&e[0]))return r;for(s=31&e[0],i=0;i<s;i++)o={type:3&e[2+(n=3*i)],pts:t},4&e[n+2]&&(o.ccData=e[n+3]<<8|e[n+4],r.push(o));return r},o=4,r=function t(e){e=e||{},t.prototype.init.call(this),this.parse708captions_="boolean"!=typeof e.parse708captions||e.parse708captions,this.captionPackets_=[],this.ccStreams_=[new w(0,0),new w(0,1),new w(1,0),new w(1,1)],this.parse708captions_&&(this.cc708Stream_=new l({captionServices:e.captionServices})),this.reset(),this.ccStreams_.forEach(function(t){t.on("data",this.trigger.bind(this,"data")),t.on("partialdone",this.trigger.bind(this,"partialdone")),t.on("done",this.trigger.bind(this,"done"))},this),this.parse708captions_&&(this.cc708Stream_.on("data",this.trigger.bind(this,"data")),this.cc708Stream_.on("partialdone",this.trigger.bind(this,"partialdone")),this.cc708Stream_.on("done",this.trigger.bind(this,"done")))};(r.prototype=new e).push=function(t){var e=this;"sei_rbsp"===t.nalUnitType&&i(t.escapedRBSP).filter(function(t){return t.payloadType===o}).map(s).forEach(function(i){i&&(e.captionPackets_=e.captionPackets_.concat(n(t.pts,i)))})},r.prototype.flushCCStreams=function(t){this.ccStreams_.forEach(function(e){return"flush"===t?e.flush():e.partialFlush()},this)},r.prototype.flushStream=function(t){this.captionPackets_.length?(this.captionPackets_.forEach(function(t,e){t.presortIndex=e}),this.captionPackets_.sort(function(t,e){return t.pts===e.pts?t.presortIndex-e.presortIndex:t.pts-e.pts}),this.captionPackets_.forEach(function(t){t.type<2?this.dispatchCea608Packet(t):this.dispatchCea708Packet(t)},this),this.captionPackets_.length=0,this.flushCCStreams(t)):this.flushCCStreams(t)},r.prototype.flush=function(){return this.flushStream("flush")},r.prototype.partialFlush=function(){return this.flushStream("partialFlush")},r.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(t){t.reset()})},r.prototype.dispatchCea608Packet=function(t){this.setsTextOrXDSActive(t)?this.activeCea608Channel_[t.type]=null:this.setsChannel1Active(t)?this.activeCea608Channel_[t.type]=0:this.setsChannel2Active(t)&&(this.activeCea608Channel_[t.type]=1),null!==this.activeCea608Channel_[t.type]&&this.ccStreams_[(t.type<<1)+this.activeCea608Channel_[t.type]].push(t)},r.prototype.setsChannel1Active=function(t){return 4096==(30720&t.ccData)},r.prototype.setsChannel2Active=function(t){return 6144==(30720&t.ccData)},r.prototype.setsTextOrXDSActive=function(t){return 256==(28928&t.ccData)||4138==(30974&t.ccData)||6186==(30974&t.ccData)},r.prototype.dispatchCea708Packet=function(t){this.parse708captions_&&this.cc708Stream_.push(t)};var a={127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600},h=function(t){return 32<=t&&t<=127||160<=t&&t<=255},p=function(t){this.windowNum=t,this.reset()};p.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},p.prototype.getText=function(){return this.rows.join("\n")},p.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},p.prototype.newLine=function(t){for(this.rows.length>=this.virtualRowCount&&"function"==typeof this.beforeRowOverflow&&this.beforeRowOverflow(t),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},p.prototype.isEmpty=function(){return 0===this.rows.length||1===this.rows.length&&""===this.rows[0]},p.prototype.addText=function(t){this.rows[this.rowIdx]+=t},p.prototype.backspace=function(){if(!this.isEmpty()){var t=this.rows[this.rowIdx];this.rows[this.rowIdx]=t.substr(0,t.length-1)}};var c=function(t,e,i){this.serviceNum=t,this.text="",this.currentWindow=new p(-1),this.windows=[],this.stream=i,"string"==typeof e&&this.createTextDecoder(e)};c.prototype.init=function(t,e){this.startPts=t;for(var i=0;i<8;i++)this.windows[i]=new p(i),"function"==typeof e&&(this.windows[i].beforeRowOverflow=e)},c.prototype.setCurrentWindow=function(t){this.currentWindow=this.windows[t]},c.prototype.createTextDecoder=function(t){if("undefined"==typeof TextDecoder)this.stream.trigger("log",{level:"warn",message:"The `encoding` option is unsupported without TextDecoder support"});else try{this.textDecoder_=new TextDecoder(t)}catch(e){this.stream.trigger("log",{level:"warn",message:"TextDecoder could not be created with "+t+" encoding. "+e})}};var l=function t(e){e=e||{},t.prototype.init.call(this);var i,s=this,n=e.captionServices||{},o={};Object.keys(n).forEach(function(t){i=n[t],/^SERVICE/.test(t)&&(o[t]=i.encoding)}),this.serviceEncodings=o,this.current708Packet=null,this.services={},this.push=function(t){3===t.type?(s.new708Packet(),s.add708Bytes(t)):(null===s.current708Packet&&s.new708Packet(),s.add708Bytes(t))}};l.prototype=new e,l.prototype.new708Packet=function(){null!==this.current708Packet&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},l.prototype.add708Bytes=function(t){var e=t.ccData,i=e>>>8,s=255&e;this.current708Packet.ptsVals.push(t.pts),this.current708Packet.data.push(i),this.current708Packet.data.push(s)},l.prototype.push708Packet=function(){var t=this.current708Packet,e=t.data,i=null,s=null,n=0,o=e[n++];for(t.seq=o>>6,t.sizeCode=63&o;n<e.length;n++)s=31&(o=e[n++]),7==(i=o>>5)&&s>0&&(i=o=e[n++]),this.pushServiceBlock(i,n,s),s>0&&(n+=s-1)},l.prototype.pushServiceBlock=function(t,e,i){var s,n=e,o=this.current708Packet.data,r=this.services[t];for(r||(r=this.initService(t,n));n<e+i&&n<o.length;n++)s=o[n],h(s)?n=this.handleText(n,r):24===s?n=this.multiByteCharacter(n,r):16===s?n=this.extendedCommands(n,r):128<=s&&s<=135?n=this.setCurrentWindow(n,r):152<=s&&s<=159?n=this.defineWindow(n,r):136===s?n=this.clearWindows(n,r):140===s?n=this.deleteWindows(n,r):137===s?n=this.displayWindows(n,r):138===s?n=this.hideWindows(n,r):139===s?n=this.toggleWindows(n,r):151===s?n=this.setWindowAttributes(n,r):144===s?n=this.setPenAttributes(n,r):145===s?n=this.setPenColor(n,r):146===s?n=this.setPenLocation(n,r):143===s?r=this.reset(n,r):8===s?r.currentWindow.backspace():12===s?r.currentWindow.clearText():13===s?r.currentWindow.pendingNewLine=!0:14===s?r.currentWindow.clearText():141===s&&n++},l.prototype.extendedCommands=function(t,e){var i=this.current708Packet.data[++t];return h(i)&&(t=this.handleText(t,e,{isExtended:!0})),t},l.prototype.getPts=function(t){return this.current708Packet.ptsVals[Math.floor(t/2)]},l.prototype.initService=function(t,e){var i,s,n=this;return(i="SERVICE"+t)in this.serviceEncodings&&(s=this.serviceEncodings[i]),this.services[t]=new c(t,s,n),this.services[t].init(this.getPts(e),function(e){n.flushDisplayed(e,n.services[t])}),this.services[t]},l.prototype.handleText=function(t,e,i){var s,n,o=i&&i.isExtended,r=i&&i.isMultiByte,h=this.current708Packet.data,p=o?4096:0,c=h[t],l=h[t+1],d=e.currentWindow;return e.textDecoder_&&!o?(r?(n=[c,l],t++):n=[c],s=e.textDecoder_.decode(new Uint8Array(n))):s=function(t){var e=a[t]||t;return 4096&t&&t===e?"":String.fromCharCode(e)}(p|c),d.pendingNewLine&&!d.isEmpty()&&d.newLine(this.getPts(t)),d.pendingNewLine=!1,d.addText(s),t},l.prototype.multiByteCharacter=function(t,e){var i=this.current708Packet.data,s=i[t+1],n=i[t+2];return h(s)&&h(n)&&(t=this.handleText(++t,e,{isMultiByte:!0})),t},l.prototype.setCurrentWindow=function(t,e){var i=7&this.current708Packet.data[t];return e.setCurrentWindow(i),t},l.prototype.defineWindow=function(t,e){var i=this.current708Packet.data,s=i[t],n=7&s;e.setCurrentWindow(n);var o=e.currentWindow;return s=i[++t],o.visible=(32&s)>>5,o.rowLock=(16&s)>>4,o.columnLock=(8&s)>>3,o.priority=7&s,s=i[++t],o.relativePositioning=(128&s)>>7,o.anchorVertical=127&s,s=i[++t],o.anchorHorizontal=s,s=i[++t],o.anchorPoint=(240&s)>>4,o.rowCount=15&s,s=i[++t],o.columnCount=63&s,s=i[++t],o.windowStyle=(56&s)>>3,o.penStyle=7&s,o.virtualRowCount=o.rowCount+1,t},l.prototype.setWindowAttributes=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.winAttr;return s=i[++t],n.fillOpacity=(192&s)>>6,n.fillRed=(48&s)>>4,n.fillGreen=(12&s)>>2,n.fillBlue=3&s,s=i[++t],n.borderType=(192&s)>>6,n.borderRed=(48&s)>>4,n.borderGreen=(12&s)>>2,n.borderBlue=3&s,s=i[++t],n.borderType+=(128&s)>>5,n.wordWrap=(64&s)>>6,n.printDirection=(48&s)>>4,n.scrollDirection=(12&s)>>2,n.justify=3&s,s=i[++t],n.effectSpeed=(240&s)>>4,n.effectDirection=(12&s)>>2,n.displayEffect=3&s,t},l.prototype.flushDisplayed=function(t,e){for(var i=[],s=0;s<8;s++)e.windows[s].visible&&!e.windows[s].isEmpty()&&i.push(e.windows[s].getText());e.endPts=t,e.text=i.join("\n\n"),this.pushCaption(e),e.startPts=t},l.prototype.pushCaption=function(t){""!==t.text&&(this.trigger("data",{startPts:t.startPts,endPts:t.endPts,text:t.text,stream:"cc708_"+t.serviceNum}),t.text="",t.startPts=t.endPts)},l.prototype.displayWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&(e.windows[n].visible=1);return t},l.prototype.hideWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&(e.windows[n].visible=0);return t},l.prototype.toggleWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&(e.windows[n].visible^=1);return t},l.prototype.clearWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&e.windows[n].clearText();return t},l.prototype.deleteWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&e.windows[n].reset();return t},l.prototype.setPenAttributes=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.penAttr;return s=i[++t],n.textTag=(240&s)>>4,n.offset=(12&s)>>2,n.penSize=3&s,s=i[++t],n.italics=(128&s)>>7,n.underline=(64&s)>>6,n.edgeType=(56&s)>>3,n.fontStyle=7&s,t},l.prototype.setPenColor=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.penColor;return s=i[++t],n.fgOpacity=(192&s)>>6,n.fgRed=(48&s)>>4,n.fgGreen=(12&s)>>2,n.fgBlue=3&s,s=i[++t],n.bgOpacity=(192&s)>>6,n.bgRed=(48&s)>>4,n.bgGreen=(12&s)>>2,n.bgBlue=3&s,s=i[++t],n.edgeRed=(48&s)>>4,n.edgeGreen=(12&s)>>2,n.edgeBlue=3&s,t},l.prototype.setPenLocation=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.penLoc;return e.currentWindow.pendingNewLine=!0,s=i[++t],n.row=15&s,s=i[++t],n.column=63&s,t},l.prototype.reset=function(t,e){var i=this.getPts(t);return this.flushDisplayed(i,e),this.initService(e.serviceNum,t)};var d={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},u=function(t){return t=d[t]||t,String.fromCharCode(t).replace(/[\x00]/g,"")},_=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],f=function(){for(var t=[],e=15;e--;)t.push("");return t},y=function(){for(var t=[],e=15;e--;)t[e]=0;return t},w=function t(e,i,s){t.prototype.init.call(this),this.field_=e||0,this.dataChannel_=i||0,this.name_="CC"+(1+(this.field_<<1|this.dataChannel_)),this.setConstants(),this.reset(),this.push=function(t){var e,i,s,n,o;if((e=32639&t.ccData)!==this.lastControlCode_){if(4096==(61440&e)?this.lastControlCode_=e:e!==this.PADDING_&&(this.lastControlCode_=null),s=e>>>8,n=255&e,e!==this.PADDING_)if(e===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(e===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(t.pts),this.flushDisplayed(t.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,i=this.displayedIndent_,this.displayedIndent_=this.nonDisplayedIndent_,this.nonDisplayedIndent_=i,this.startPts_=t.pts;else if(e===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(t.pts);else if(e===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(t.pts);else if(e===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(t.pts);else if(e===this.CARRIAGE_RETURN_)this.clearFormatting(t.pts),this.flushDisplayed(t.pts),this.shiftRowsUp_(),this.startPts_=t.pts;else if(e===this.BACKSPACE_)"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(e===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(t.pts),this.displayed_=f(),this.displayedIndent_=y();else if(e===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=f(),this.nonDisplayedIndent_=y();else if(e===this.RESUME_DIRECT_CAPTIONING_)"paintOn"!==this.mode_&&(this.flushDisplayed(t.pts),this.displayed_=f(),this.displayedIndent_=y()),this.mode_="paintOn",this.startPts_=t.pts;else{if(!Boolean(this.mode_))return;if(this.isSpecialCharacter(s,n))o=u((s=(3&s)<<8)|n),this[this.mode_](t.pts,o),this.column_++;else if(this.isExtCharacter(s,n))"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),o=u((s=(3&s)<<8)|n),this[this.mode_](t.pts,o),this.column_++;else if(this.isMidRowCode(s,n))this.clearFormatting(t.pts),this[this.mode_](t.pts," "),this.column_++,14&~n||this.addFormatting(t.pts,["i"]),1&~n||this.addFormatting(t.pts,["u"]);else if(this.isOffsetControlCode(s,n)){var r=3&n;this.column_+=r,this.incrementIdentation(r)}else if(this.isPAC(s,n)){var a=_.indexOf(7968&e);"rollUp"===this.mode_&&(a-this.rollUpRows_+1<0&&(a=this.rollUpRows_-1),this.setRollUp(t.pts,a)),a!==this.row_&&(this.clearFormatting(t.pts),this.changeRow(a)),1&n&&-1===this.formatting_.indexOf("u")&&this.addFormatting(t.pts,["u"]),16&~e||(this.column_=4*((14&e)>>1),"popOn"===this.mode_?this.nonDisplayedIndent_[this.row_]=this.column_:"rollUp"===this.mode_&&(this.displayedIndent_[this.row_]=this.column_)),this.isColorPAC(n)&&(14&~n||this.addFormatting(t.pts,["i"]))}else this.isNormalChar(s)&&(o=u(s),0!==n&&(o+=u(n)),this[this.mode_](t.pts,o),this.column_+=o.length)}}else this.lastControlCode_=null}};return w.prototype=new e,w.prototype.flushDisplayed=function(t){for(var e=0;e<this.displayed_.length;e++){var i=this.displayed_[e];i&&i.length&&this.trigger("data",{startPts:this.startPts_,endPts:t,text:i,stream:this.name_,position:{row:e,column:this.displayedIndent_[e]}})}},w.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=f(),this.nonDisplayed_=f(),this.displayedIndent_=y(),this.nonDisplayedIndent_=y(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[]},w.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_,this.TAB_OFFSET_1_=33,this.TAB_OFFSET_2_=34,this.TAB_OFFSET_3_=35},w.prototype.isSpecialCharacter=function(t,e){return t===this.EXT_&&e>=48&&e<=63},w.prototype.isExtCharacter=function(t,e){return(t===this.EXT_+1||t===this.EXT_+2)&&e>=32&&e<=63},w.prototype.isMidRowCode=function(t,e){return t===this.EXT_&&e>=32&&e<=47},w.prototype.isOffsetControlCode=function(t,e){return t===this.OFFSET_&&e>=this.TAB_OFFSET_1_&&e<=this.TAB_OFFSET_3_},w.prototype.isPAC=function(t,e){return t>=this.BASE_&&t<this.BASE_+8&&e>=64&&e<=127},w.prototype.isColorPAC=function(t){return t>=64&&t<=79||t>=96&&t<=127},w.prototype.isNormalChar=function(t){return t>=32&&t<=127},w.prototype.setRollUp=function(t,e){if("rollUp"!==this.mode_&&(this.row_=14,this.mode_="rollUp",this.flushDisplayed(t),this.nonDisplayed_=f(),this.displayed_=f(),this.displayedIndent_=y(),this.nonDisplayedIndent_=y()),void 0!==e&&e!==this.row_)for(var i=0;i<this.rollUpRows_;i++)this.displayed_[e-i]=this.displayed_[this.row_-i],this.displayed_[this.row_-i]="";void 0===e&&(e=this.row_),this.topRow_=e-this.rollUpRows_+1},w.prototype.addFormatting=function(t,e){this.formatting_=this.formatting_.concat(e);var i=e.reduce(function(t,e){return t+"<"+e+">"},"");this[this.mode_](t,i)},w.prototype.clearFormatting=function(t){if(this.formatting_.length){var e=this.formatting_.reverse().reduce(function(t,e){return t+"</"+e+">"},"");this.formatting_=[],this[this.mode_](t,e)}},w.prototype.popOn=function(t,e){var i=this.nonDisplayed_[this.row_];i+=e,this.nonDisplayed_[this.row_]=i},w.prototype.rollUp=function(t,e){var i=this.displayed_[this.row_];i+=e,this.displayed_[this.row_]=i},w.prototype.shiftRowsUp_=function(){var t;for(t=0;t<this.topRow_;t++)this.displayed_[t]="";for(t=this.row_+1;t<15;t++)this.displayed_[t]="";for(t=this.topRow_;t<this.row_;t++)this.displayed_[t]=this.displayed_[t+1];this.displayed_[this.row_]=""},w.prototype.paintOn=function(t,e){var i=this.displayed_[this.row_];i+=e,this.displayed_[this.row_]=i},w.prototype.changeRow=function(t){if("rollUp"===this.mode_){var e=this.row_-this.topRow_+1;this.topRow_=t-e+1;var i=this.displayed_,s=this.displayedIndent_;this.displayed_=f(),this.displayedIndent_=y();for(var n=0;n<e;n++)t-n>=0&&(this.displayed_[t-n]=i[this.row_-n],this.displayedIndent_[t-n]=s[this.row_-n])}this.row_=t},w.prototype.incrementIdentation=function(t){"popOn"===this.mode_?this.nonDisplayedIndent_[this.row_]+=t:"rollUp"===this.mode_&&(this.displayedIndent_[this.row_]+=t)},{CaptionStream:{CaptionStream:r,Cea608Stream:w,Cea708Stream:l}.CaptionStream}}()}()},82396:function(t,e,i){"use strict";var s=this&&this.__spreadArray||function(t,e,i){if(i||2===arguments.length)for(var s,n=0,o=e.length;n<o;n++)!s&&n in e||(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.Cea608Extractor=e.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS=e.MPEG_TS_TIMESCALE=void 0;var n=i(1001),o=i(34047),r=i(3188);e.MPEG_TS_TIMESCALE=9e4,e.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS=s(s([],o.AVC_CODEC_TAGS,!0),o.HEVC_CODEC_TAGS,!0);var a=function(){function t(t,e,i){void 0===i&&(i=!1),this.logger=t,this.MP4Module=e,this.parseCea708Caption=i,this.wq=1,this.xq=0}return t.prototype.extract=function(t){var i,s,r=this,a=(null!==(s=null===(i=t.getInitSegment())||void 0===i?void 0:i.getParsedData())&&void 0!==s?s:t.getParsedData()).get("moov.trak.mdia.mdhd"),h=(0,o.getCodecTag)(t);if(!e.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS.includes(h))return Promise.resolve([]);var p=o.AVC_CODEC_TAGS.includes(h)?n.NalUnitTypeAvc.SEI:n.NalUnitTypeHevc.SEI;a&&(this.wq=a.timescale);var c=t.getParsedData().get("moov.mvex.trex");c&&(this.xq=c.default_sample_duration);var l=this.MP4Module.getMp4Fragments(t).flatMap(function(e){var i=e.moof.get("traf.tfdt"),s=r.MP4Module.getVideoSamples(e,t,[p],r.logger),n=i?r.yq(i.baseMediaDecodeTime):0;return s.flatMap(function(t){var e=t.nalus.map(function(e){return function(t,e){return{nalUnitType:"sei_rbsp",escapedRBSP:new Uint8Array(t.data.buffer,t.data.byteOffset,t.data.byteLength),pts:e}}(e,n+r.yq(t.compositionTimeOffset))});return n+=Math.floor(r.yq(t.duration||r.xq)),e})});return this.zq(l)},t.prototype.yq=function(t){return t/this.wq*e.MPEG_TS_TIMESCALE},t.prototype.zq=function(t){return 0===t.length?Promise.resolve([]):(this.vq||(this.vq=new r.Cea608Processor(this.parseCea708Caption)),this.vq.getCaptions(t).catch(function(){return Promise.resolve([])}))},t.prototype.reset=function(){this.vq&&this.vq.reset()},t.prototype.dispose=function(){this.vq&&this.vq.dispose()},t}();e.Cea608Extractor=a},3188:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Cea608Processor=void 0;var s=i(30251),n=i(85269),o=function(){function t(t){var e=this;this.aT=[],this.pushCaptions=function(t){e.ZT=!1,t.forEach(function(t){return e.eT.push(t)})},this.fT=function(){e.eT.on("data",e.gT),e.eT.on("done",e.hT)},this.gT=function(t){e.aT.push((0,n.assembleCaption)(t))},this.hT=function(){if(!e.ZT)if(e.ZT=!0,e.iT(e.aT),e.aT=[],e.cT.length>0){var t=e.cT[0];e.process(t.captionPackets)}else e.dT=!1},this.bT=t,this.aT=[],this.cT=[],this.dT=!1,this.eT=new s.CaptionStream({parse708captions:t}),this.fT()}return t.prototype.getCaptions=function(t){var e=this;return new Promise(function(i,s){(!t||!Array.isArray(t)||t.length<1)&&s(new Error("Could not get captions, no SeiNal provided")),e.cT.push({captionPackets:t,resolve:i,reject:s}),e.dT||(e.dT=!0,e.process(t))})},t.prototype.process=function(t){this.pushCaptions(t),this.flush()},t.prototype.flush=function(){this.eT.flush()},t.prototype.reset=function(){this.eT.reset()},t.prototype.iT=function(t){var e=this,i=t.filter(function(t){return e.bT?t.channel.includes("708"):!t.channel.includes("708")}),s=this.cT.shift();null==s||s.resolve(i)},t.prototype.dispose=function(){this.eT.reset()},t}();e.Cea608Processor=o},20784:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CeaSubtitlesModuleDefinition=void 0;var s=i(62756),n=i(82396);e.CeaSubtitlesModuleDefinition={name:s.ModuleName.SubtitlesCEA608,module:function(){return{Cea608Extractor:n.Cea608Extractor,CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS:n.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS}},dependencies:[s.ModuleName.Subtitles]},e.default=e.CeaSubtitlesModuleDefinition},85269:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assembleCaption=function(t){return{start:t.startPts/i,end:t.endPts/i,text:t.text,channel:t.stream,position:t.position}};var i=9e4}},function(t){return function(){return t(20784)}()}])});
17
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["subtitles-cea608"]=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player["subtitles-cea608"]=e())}(self,function(){return(self.webpackChunkbitmovin_player=self.webpackChunkbitmovin_player||[]).push([[886],{30251:function(t){!function(){t.exports=function(){"use strict";var t=function(){this.init=function(){var t={};this.on=function(e,i){t[e]||(t[e]=[]),t[e]=t[e].concat(i)},this.off=function(e,i){var s;return!!t[e]&&(s=t[e].indexOf(i),t[e]=t[e].slice(),t[e].splice(s,1),s>-1)},this.trigger=function(e){var i,s,n,o;if(i=t[e])if(2===arguments.length)for(n=i.length,s=0;s<n;++s)i[s].call(this,arguments[1]);else{for(o=[],s=arguments.length,s=1;s<arguments.length;++s)o.push(arguments[s]);for(n=i.length,s=0;s<n;++s)i[s].apply(this,o)}},this.dispose=function(){t={}}}};t.prototype.pipe=function(t){return this.on("data",function(e){t.push(e)}),this.on("done",function(e){t.flush(e)}),this.on("partialdone",function(e){t.partialFlush(e)}),this.on("endedtimeline",function(e){t.endTimeline(e)}),this.on("reset",function(e){t.reset(e)}),t},t.prototype.push=function(t){this.trigger("data",t)},t.prototype.flush=function(t){this.trigger("done",t)},t.prototype.partialFlush=function(t){this.trigger("partialdone",t)},t.prototype.endTimeline=function(t){this.trigger("endedtimeline",t)},t.prototype.reset=function(t){this.trigger("reset",t)};var e=t,i=function(t){for(var e=0,i=[],s=0,n=0;e<t.byteLength&&128!==t[e];){for(;255===t[e];)s+=255,e++;for(s+=t[e++];255===t[e];)n+=255,e++;n+=t[e++];var o=String.fromCharCode(t[e+3],t[e+4],t[e+5],t[e+6]);4===s&&"GA94"===o&&i.push({payloadType:s,payloadSize:n,payload:t.subarray(e,e+n)}),e+=n,s=0,n=0}return i},s=function(t){return 181!==t.payload[0]||49!=(t.payload[1]<<8|t.payload[2])||"GA94"!==String.fromCharCode(t.payload[3],t.payload[4],t.payload[5],t.payload[6])||3!==t.payload[7]?null:t.payload.subarray(8,t.payload.length-1)},n=function(t,e){var i,s,n,o,r=[];if(!(64&e[0]))return r;for(s=31&e[0],i=0;i<s;i++)o={type:3&e[2+(n=3*i)],pts:t},4&e[n+2]&&(o.ccData=e[n+3]<<8|e[n+4],r.push(o));return r},o=4,r=function t(e){e=e||{},t.prototype.init.call(this),this.parse708captions_="boolean"!=typeof e.parse708captions||e.parse708captions,this.captionPackets_=[],this.ccStreams_=[new w(0,0),new w(0,1),new w(1,0),new w(1,1)],this.parse708captions_&&(this.cc708Stream_=new l({captionServices:e.captionServices})),this.reset(),this.ccStreams_.forEach(function(t){t.on("data",this.trigger.bind(this,"data")),t.on("partialdone",this.trigger.bind(this,"partialdone")),t.on("done",this.trigger.bind(this,"done"))},this),this.parse708captions_&&(this.cc708Stream_.on("data",this.trigger.bind(this,"data")),this.cc708Stream_.on("partialdone",this.trigger.bind(this,"partialdone")),this.cc708Stream_.on("done",this.trigger.bind(this,"done")))};(r.prototype=new e).push=function(t){var e=this;"sei_rbsp"===t.nalUnitType&&i(t.escapedRBSP).filter(function(t){return t.payloadType===o}).map(s).forEach(function(i){i&&(e.captionPackets_=e.captionPackets_.concat(n(t.pts,i)))})},r.prototype.flushCCStreams=function(t){this.ccStreams_.forEach(function(e){return"flush"===t?e.flush():e.partialFlush()},this)},r.prototype.flushStream=function(t){this.captionPackets_.length?(this.captionPackets_.forEach(function(t,e){t.presortIndex=e}),this.captionPackets_.sort(function(t,e){return t.pts===e.pts?t.presortIndex-e.presortIndex:t.pts-e.pts}),this.captionPackets_.forEach(function(t){t.type<2?this.dispatchCea608Packet(t):this.dispatchCea708Packet(t)},this),this.captionPackets_.length=0,this.flushCCStreams(t)):this.flushCCStreams(t)},r.prototype.flush=function(){return this.flushStream("flush")},r.prototype.partialFlush=function(){return this.flushStream("partialFlush")},r.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(t){t.reset()})},r.prototype.dispatchCea608Packet=function(t){this.setsTextOrXDSActive(t)?this.activeCea608Channel_[t.type]=null:this.setsChannel1Active(t)?this.activeCea608Channel_[t.type]=0:this.setsChannel2Active(t)&&(this.activeCea608Channel_[t.type]=1),null!==this.activeCea608Channel_[t.type]&&this.ccStreams_[(t.type<<1)+this.activeCea608Channel_[t.type]].push(t)},r.prototype.setsChannel1Active=function(t){return 4096==(30720&t.ccData)},r.prototype.setsChannel2Active=function(t){return 6144==(30720&t.ccData)},r.prototype.setsTextOrXDSActive=function(t){return 256==(28928&t.ccData)||4138==(30974&t.ccData)||6186==(30974&t.ccData)},r.prototype.dispatchCea708Packet=function(t){this.parse708captions_&&this.cc708Stream_.push(t)};var a={127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600},h=function(t){return 32<=t&&t<=127||160<=t&&t<=255},p=function(t){this.windowNum=t,this.reset()};p.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},p.prototype.getText=function(){return this.rows.join("\n")},p.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},p.prototype.newLine=function(t){for(this.rows.length>=this.virtualRowCount&&"function"==typeof this.beforeRowOverflow&&this.beforeRowOverflow(t),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},p.prototype.isEmpty=function(){return 0===this.rows.length||1===this.rows.length&&""===this.rows[0]},p.prototype.addText=function(t){this.rows[this.rowIdx]+=t},p.prototype.backspace=function(){if(!this.isEmpty()){var t=this.rows[this.rowIdx];this.rows[this.rowIdx]=t.substr(0,t.length-1)}};var c=function(t,e,i){this.serviceNum=t,this.text="",this.currentWindow=new p(-1),this.windows=[],this.stream=i,"string"==typeof e&&this.createTextDecoder(e)};c.prototype.init=function(t,e){this.startPts=t;for(var i=0;i<8;i++)this.windows[i]=new p(i),"function"==typeof e&&(this.windows[i].beforeRowOverflow=e)},c.prototype.setCurrentWindow=function(t){this.currentWindow=this.windows[t]},c.prototype.createTextDecoder=function(t){if("undefined"==typeof TextDecoder)this.stream.trigger("log",{level:"warn",message:"The `encoding` option is unsupported without TextDecoder support"});else try{this.textDecoder_=new TextDecoder(t)}catch(e){this.stream.trigger("log",{level:"warn",message:"TextDecoder could not be created with "+t+" encoding. "+e})}};var l=function t(e){e=e||{},t.prototype.init.call(this);var i,s=this,n=e.captionServices||{},o={};Object.keys(n).forEach(function(t){i=n[t],/^SERVICE/.test(t)&&(o[t]=i.encoding)}),this.serviceEncodings=o,this.current708Packet=null,this.services={},this.push=function(t){3===t.type?(s.new708Packet(),s.add708Bytes(t)):(null===s.current708Packet&&s.new708Packet(),s.add708Bytes(t))}};l.prototype=new e,l.prototype.new708Packet=function(){null!==this.current708Packet&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},l.prototype.add708Bytes=function(t){var e=t.ccData,i=e>>>8,s=255&e;this.current708Packet.ptsVals.push(t.pts),this.current708Packet.data.push(i),this.current708Packet.data.push(s)},l.prototype.push708Packet=function(){var t=this.current708Packet,e=t.data,i=null,s=null,n=0,o=e[n++];for(t.seq=o>>6,t.sizeCode=63&o;n<e.length;n++)s=31&(o=e[n++]),7==(i=o>>5)&&s>0&&(i=o=e[n++]),this.pushServiceBlock(i,n,s),s>0&&(n+=s-1)},l.prototype.pushServiceBlock=function(t,e,i){var s,n=e,o=this.current708Packet.data,r=this.services[t];for(r||(r=this.initService(t,n));n<e+i&&n<o.length;n++)s=o[n],h(s)?n=this.handleText(n,r):24===s?n=this.multiByteCharacter(n,r):16===s?n=this.extendedCommands(n,r):128<=s&&s<=135?n=this.setCurrentWindow(n,r):152<=s&&s<=159?n=this.defineWindow(n,r):136===s?n=this.clearWindows(n,r):140===s?n=this.deleteWindows(n,r):137===s?n=this.displayWindows(n,r):138===s?n=this.hideWindows(n,r):139===s?n=this.toggleWindows(n,r):151===s?n=this.setWindowAttributes(n,r):144===s?n=this.setPenAttributes(n,r):145===s?n=this.setPenColor(n,r):146===s?n=this.setPenLocation(n,r):143===s?r=this.reset(n,r):8===s?r.currentWindow.backspace():12===s?r.currentWindow.clearText():13===s?r.currentWindow.pendingNewLine=!0:14===s?r.currentWindow.clearText():141===s&&n++},l.prototype.extendedCommands=function(t,e){var i=this.current708Packet.data[++t];return h(i)&&(t=this.handleText(t,e,{isExtended:!0})),t},l.prototype.getPts=function(t){return this.current708Packet.ptsVals[Math.floor(t/2)]},l.prototype.initService=function(t,e){var i,s,n=this;return(i="SERVICE"+t)in this.serviceEncodings&&(s=this.serviceEncodings[i]),this.services[t]=new c(t,s,n),this.services[t].init(this.getPts(e),function(e){n.flushDisplayed(e,n.services[t])}),this.services[t]},l.prototype.handleText=function(t,e,i){var s,n,o=i&&i.isExtended,r=i&&i.isMultiByte,h=this.current708Packet.data,p=o?4096:0,c=h[t],l=h[t+1],d=e.currentWindow;return e.textDecoder_&&!o?(r?(n=[c,l],t++):n=[c],s=e.textDecoder_.decode(new Uint8Array(n))):s=function(t){var e=a[t]||t;return 4096&t&&t===e?"":String.fromCharCode(e)}(p|c),d.pendingNewLine&&!d.isEmpty()&&d.newLine(this.getPts(t)),d.pendingNewLine=!1,d.addText(s),t},l.prototype.multiByteCharacter=function(t,e){var i=this.current708Packet.data,s=i[t+1],n=i[t+2];return h(s)&&h(n)&&(t=this.handleText(++t,e,{isMultiByte:!0})),t},l.prototype.setCurrentWindow=function(t,e){var i=7&this.current708Packet.data[t];return e.setCurrentWindow(i),t},l.prototype.defineWindow=function(t,e){var i=this.current708Packet.data,s=i[t],n=7&s;e.setCurrentWindow(n);var o=e.currentWindow;return s=i[++t],o.visible=(32&s)>>5,o.rowLock=(16&s)>>4,o.columnLock=(8&s)>>3,o.priority=7&s,s=i[++t],o.relativePositioning=(128&s)>>7,o.anchorVertical=127&s,s=i[++t],o.anchorHorizontal=s,s=i[++t],o.anchorPoint=(240&s)>>4,o.rowCount=15&s,s=i[++t],o.columnCount=63&s,s=i[++t],o.windowStyle=(56&s)>>3,o.penStyle=7&s,o.virtualRowCount=o.rowCount+1,t},l.prototype.setWindowAttributes=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.winAttr;return s=i[++t],n.fillOpacity=(192&s)>>6,n.fillRed=(48&s)>>4,n.fillGreen=(12&s)>>2,n.fillBlue=3&s,s=i[++t],n.borderType=(192&s)>>6,n.borderRed=(48&s)>>4,n.borderGreen=(12&s)>>2,n.borderBlue=3&s,s=i[++t],n.borderType+=(128&s)>>5,n.wordWrap=(64&s)>>6,n.printDirection=(48&s)>>4,n.scrollDirection=(12&s)>>2,n.justify=3&s,s=i[++t],n.effectSpeed=(240&s)>>4,n.effectDirection=(12&s)>>2,n.displayEffect=3&s,t},l.prototype.flushDisplayed=function(t,e){for(var i=[],s=0;s<8;s++)e.windows[s].visible&&!e.windows[s].isEmpty()&&i.push(e.windows[s].getText());e.endPts=t,e.text=i.join("\n\n"),this.pushCaption(e),e.startPts=t},l.prototype.pushCaption=function(t){""!==t.text&&(this.trigger("data",{startPts:t.startPts,endPts:t.endPts,text:t.text,stream:"cc708_"+t.serviceNum}),t.text="",t.startPts=t.endPts)},l.prototype.displayWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&(e.windows[n].visible=1);return t},l.prototype.hideWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&(e.windows[n].visible=0);return t},l.prototype.toggleWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&(e.windows[n].visible^=1);return t},l.prototype.clearWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&e.windows[n].clearText();return t},l.prototype.deleteWindows=function(t,e){var i=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,e);for(var n=0;n<8;n++)i&1<<n&&e.windows[n].reset();return t},l.prototype.setPenAttributes=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.penAttr;return s=i[++t],n.textTag=(240&s)>>4,n.offset=(12&s)>>2,n.penSize=3&s,s=i[++t],n.italics=(128&s)>>7,n.underline=(64&s)>>6,n.edgeType=(56&s)>>3,n.fontStyle=7&s,t},l.prototype.setPenColor=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.penColor;return s=i[++t],n.fgOpacity=(192&s)>>6,n.fgRed=(48&s)>>4,n.fgGreen=(12&s)>>2,n.fgBlue=3&s,s=i[++t],n.bgOpacity=(192&s)>>6,n.bgRed=(48&s)>>4,n.bgGreen=(12&s)>>2,n.bgBlue=3&s,s=i[++t],n.edgeRed=(48&s)>>4,n.edgeGreen=(12&s)>>2,n.edgeBlue=3&s,t},l.prototype.setPenLocation=function(t,e){var i=this.current708Packet.data,s=i[t],n=e.currentWindow.penLoc;return e.currentWindow.pendingNewLine=!0,s=i[++t],n.row=15&s,s=i[++t],n.column=63&s,t},l.prototype.reset=function(t,e){var i=this.getPts(t);return this.flushDisplayed(i,e),this.initService(e.serviceNum,t)};var d={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},u=function(t){return t=d[t]||t,String.fromCharCode(t).replace(/[\x00]/g,"")},_=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],f=function(){for(var t=[],e=15;e--;)t.push("");return t},y=function(){for(var t=[],e=15;e--;)t[e]=0;return t},w=function t(e,i,s){t.prototype.init.call(this),this.field_=e||0,this.dataChannel_=i||0,this.name_="CC"+(1+(this.field_<<1|this.dataChannel_)),this.setConstants(),this.reset(),this.push=function(t){var e,i,s,n,o;if((e=32639&t.ccData)!==this.lastControlCode_){if(4096==(61440&e)?this.lastControlCode_=e:e!==this.PADDING_&&(this.lastControlCode_=null),s=e>>>8,n=255&e,e!==this.PADDING_)if(e===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(e===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(t.pts),this.flushDisplayed(t.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,i=this.displayedIndent_,this.displayedIndent_=this.nonDisplayedIndent_,this.nonDisplayedIndent_=i,this.startPts_=t.pts;else if(e===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(t.pts);else if(e===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(t.pts);else if(e===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(t.pts);else if(e===this.CARRIAGE_RETURN_)this.clearFormatting(t.pts),this.flushDisplayed(t.pts),this.shiftRowsUp_(),this.startPts_=t.pts;else if(e===this.BACKSPACE_)"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(e===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(t.pts),this.displayed_=f(),this.displayedIndent_=y();else if(e===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=f(),this.nonDisplayedIndent_=y();else if(e===this.RESUME_DIRECT_CAPTIONING_)"paintOn"!==this.mode_&&(this.flushDisplayed(t.pts),this.displayed_=f(),this.displayedIndent_=y()),this.mode_="paintOn",this.startPts_=t.pts;else{if(!Boolean(this.mode_))return;if(this.isSpecialCharacter(s,n))o=u((s=(3&s)<<8)|n),this[this.mode_](t.pts,o),this.column_++;else if(this.isExtCharacter(s,n))"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),o=u((s=(3&s)<<8)|n),this[this.mode_](t.pts,o),this.column_++;else if(this.isMidRowCode(s,n))this.clearFormatting(t.pts),this[this.mode_](t.pts," "),this.column_++,14&~n||this.addFormatting(t.pts,["i"]),1&~n||this.addFormatting(t.pts,["u"]);else if(this.isOffsetControlCode(s,n)){var r=3&n;this.column_+=r,this.incrementIdentation(r)}else if(this.isPAC(s,n)){var a=_.indexOf(7968&e);"rollUp"===this.mode_&&(a-this.rollUpRows_+1<0&&(a=this.rollUpRows_-1),this.setRollUp(t.pts,a)),a!==this.row_&&(this.clearFormatting(t.pts),this.changeRow(a)),1&n&&-1===this.formatting_.indexOf("u")&&this.addFormatting(t.pts,["u"]),16&~e||(this.column_=4*((14&e)>>1),"popOn"===this.mode_?this.nonDisplayedIndent_[this.row_]=this.column_:"rollUp"===this.mode_&&(this.displayedIndent_[this.row_]=this.column_)),this.isColorPAC(n)&&(14&~n||this.addFormatting(t.pts,["i"]))}else this.isNormalChar(s)&&(o=u(s),0!==n&&(o+=u(n)),this[this.mode_](t.pts,o),this.column_+=o.length)}}else this.lastControlCode_=null}};return w.prototype=new e,w.prototype.flushDisplayed=function(t){for(var e=0;e<this.displayed_.length;e++){var i=this.displayed_[e];i&&i.length&&this.trigger("data",{startPts:this.startPts_,endPts:t,text:i,stream:this.name_,position:{row:e,column:this.displayedIndent_[e]}})}},w.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=f(),this.nonDisplayed_=f(),this.displayedIndent_=y(),this.nonDisplayedIndent_=y(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[]},w.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_,this.TAB_OFFSET_1_=33,this.TAB_OFFSET_2_=34,this.TAB_OFFSET_3_=35},w.prototype.isSpecialCharacter=function(t,e){return t===this.EXT_&&e>=48&&e<=63},w.prototype.isExtCharacter=function(t,e){return(t===this.EXT_+1||t===this.EXT_+2)&&e>=32&&e<=63},w.prototype.isMidRowCode=function(t,e){return t===this.EXT_&&e>=32&&e<=47},w.prototype.isOffsetControlCode=function(t,e){return t===this.OFFSET_&&e>=this.TAB_OFFSET_1_&&e<=this.TAB_OFFSET_3_},w.prototype.isPAC=function(t,e){return t>=this.BASE_&&t<this.BASE_+8&&e>=64&&e<=127},w.prototype.isColorPAC=function(t){return t>=64&&t<=79||t>=96&&t<=127},w.prototype.isNormalChar=function(t){return t>=32&&t<=127},w.prototype.setRollUp=function(t,e){if("rollUp"!==this.mode_&&(this.row_=14,this.mode_="rollUp",this.flushDisplayed(t),this.nonDisplayed_=f(),this.displayed_=f(),this.displayedIndent_=y(),this.nonDisplayedIndent_=y()),void 0!==e&&e!==this.row_)for(var i=0;i<this.rollUpRows_;i++)this.displayed_[e-i]=this.displayed_[this.row_-i],this.displayed_[this.row_-i]="";void 0===e&&(e=this.row_),this.topRow_=e-this.rollUpRows_+1},w.prototype.addFormatting=function(t,e){this.formatting_=this.formatting_.concat(e);var i=e.reduce(function(t,e){return t+"<"+e+">"},"");this[this.mode_](t,i)},w.prototype.clearFormatting=function(t){if(this.formatting_.length){var e=this.formatting_.reverse().reduce(function(t,e){return t+"</"+e+">"},"");this.formatting_=[],this[this.mode_](t,e)}},w.prototype.popOn=function(t,e){var i=this.nonDisplayed_[this.row_];i+=e,this.nonDisplayed_[this.row_]=i},w.prototype.rollUp=function(t,e){var i=this.displayed_[this.row_];i+=e,this.displayed_[this.row_]=i},w.prototype.shiftRowsUp_=function(){var t;for(t=0;t<this.topRow_;t++)this.displayed_[t]="";for(t=this.row_+1;t<15;t++)this.displayed_[t]="";for(t=this.topRow_;t<this.row_;t++)this.displayed_[t]=this.displayed_[t+1];this.displayed_[this.row_]=""},w.prototype.paintOn=function(t,e){var i=this.displayed_[this.row_];i+=e,this.displayed_[this.row_]=i},w.prototype.changeRow=function(t){if("rollUp"===this.mode_){var e=this.row_-this.topRow_+1;this.topRow_=t-e+1;var i=this.displayed_,s=this.displayedIndent_;this.displayed_=f(),this.displayedIndent_=y();for(var n=0;n<e;n++)t-n>=0&&(this.displayed_[t-n]=i[this.row_-n],this.displayedIndent_[t-n]=s[this.row_-n])}this.row_=t},w.prototype.incrementIdentation=function(t){"popOn"===this.mode_?this.nonDisplayedIndent_[this.row_]+=t:"rollUp"===this.mode_&&(this.displayedIndent_[this.row_]+=t)},{CaptionStream:{CaptionStream:r,Cea608Stream:w,Cea708Stream:l}.CaptionStream}}()}()},82396:function(t,e,i){"use strict";var s=this&&this.__spreadArray||function(t,e,i){if(i||2===arguments.length)for(var s,n=0,o=e.length;n<o;n++)!s&&n in e||(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.Cea608Extractor=e.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS=e.MPEG_TS_TIMESCALE=void 0;var n=i(1001),o=i(34047),r=i(3188);e.MPEG_TS_TIMESCALE=9e4,e.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS=s(s([],o.AVC_CODEC_TAGS,!0),o.HEVC_CODEC_TAGS,!0);var a=function(){function t(t,e,i){void 0===i&&(i=!1),this.logger=t,this.MP4Module=e,this.parseCea708Caption=i,this.Uu=1,this.Vu=0}return t.prototype.extract=function(t){var i,s,r=this,a=(null!==(s=null===(i=t.getInitSegment())||void 0===i?void 0:i.getParsedData())&&void 0!==s?s:t.getParsedData()).get("moov.trak.mdia.mdhd"),h=(0,o.getCodecTag)(t);if(!e.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS.includes(h))return Promise.resolve([]);var p=o.AVC_CODEC_TAGS.includes(h)?n.NalUnitTypeAvc.SEI:n.NalUnitTypeHevc.SEI;a&&(this.Uu=a.timescale);var c=t.getParsedData().get("moov.mvex.trex");c&&(this.Vu=c.default_sample_duration);var l=this.MP4Module.getMp4Fragments(t).flatMap(function(e){var i=e.moof.get("traf.tfdt"),s=r.MP4Module.getVideoSamples(e,t,[p],r.logger),n=i?r.Wu(i.baseMediaDecodeTime):0;return s.flatMap(function(t){var e=t.nalus.map(function(e){return function(t,e){return{nalUnitType:"sei_rbsp",escapedRBSP:new Uint8Array(t.data.buffer,t.data.byteOffset,t.data.byteLength),pts:e}}(e,n+r.Wu(t.compositionTimeOffset))});return n+=Math.floor(r.Wu(t.duration||r.Vu)),e})});return this.Xu(l)},t.prototype.Wu=function(t){return t/this.Uu*e.MPEG_TS_TIMESCALE},t.prototype.Xu=function(t){return 0===t.length?Promise.resolve([]):(this.Tu||(this.Tu=new r.Cea608Processor(this.parseCea708Caption)),this.Tu.getCaptions(t).catch(function(){return Promise.resolve([])}))},t.prototype.reset=function(){this.Tu&&this.Tu.reset()},t.prototype.dispose=function(){this.Tu&&this.Tu.dispose()},t}();e.Cea608Extractor=a},3188:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Cea608Processor=void 0;var s=i(30251),n=i(85269),o=function(){function t(t){var e=this;this.iU=[],this.pushCaptions=function(t){e.hU=!1,t.forEach(function(t){return e.mU.push(t)})},this.nU=function(){e.mU.on("data",e.oU),e.mU.on("done",e.pU)},this.oU=function(t){e.iU.push((0,n.assembleCaption)(t))},this.pU=function(){if(!e.hU)if(e.hU=!0,e.qU(e.iU),e.iU=[],e.kU.length>0){var t=e.kU[0];e.process(t.captionPackets)}else e.lU=!1},this.jU=t,this.iU=[],this.kU=[],this.lU=!1,this.mU=new s.CaptionStream({parse708captions:t}),this.nU()}return t.prototype.getCaptions=function(t){var e=this;return new Promise(function(i,s){(!t||!Array.isArray(t)||t.length<1)&&s(new Error("Could not get captions, no SeiNal provided")),e.kU.push({captionPackets:t,resolve:i,reject:s}),e.lU||(e.lU=!0,e.process(t))})},t.prototype.process=function(t){this.pushCaptions(t),this.flush()},t.prototype.flush=function(){this.mU.flush()},t.prototype.reset=function(){this.mU.reset()},t.prototype.qU=function(t){var e=this,i=t.filter(function(t){return e.jU?t.channel.includes("708"):!t.channel.includes("708")}),s=this.kU.shift();null==s||s.resolve(i)},t.prototype.dispose=function(){this.mU.reset()},t}();e.Cea608Processor=o},20784:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CeaSubtitlesModuleDefinition=void 0;var s=i(62756),n=i(82396);e.CeaSubtitlesModuleDefinition={name:s.ModuleName.SubtitlesCEA608,module:function(){return{Cea608Extractor:n.Cea608Extractor,CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS:n.CEA_EXTRACTOR_SUPPORTED_CODEC_TAGS}},dependencies:[s.ModuleName.Subtitles]},e.default=e.CeaSubtitlesModuleDefinition},85269:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assembleCaption=function(t){return{start:t.startPts/i,end:t.endPts/i,text:t.text,channel:t.stream,position:t.position}};var i=9e4}},function(t){return function(){return t(20784)}()}])});
18
18
  })();
@@ -9,10 +9,10 @@
9
9
  * This software includes open-source components. See THIRD_PARTY_NOTICES
10
10
  * in the distribution for details.
11
11
  *
12
- * Bitmovin Player Version 8.280.0
12
+ * Bitmovin Player Version 8.281.0
13
13
  *
14
14
  ****************************************************************************/
15
15
 
16
16
  (function() {
17
- "use strict";!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["subtitles-native"]=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player["subtitles-native"]=e())}(self,function(){return(self.webpackChunkbitmovin_player=self.webpackChunkbitmovin_player||[]).push([[826],{91444:function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.NativeSubtitlesModuleDefinition=void 0;var n=i(62756),r=i(43931);e.NativeSubtitlesModuleDefinition={name:n.ModuleName.SubtitlesNative,module:function(){return{TextTrackController:r.TextTrackController}},dependencies:[n.ModuleName.Subtitles]},e.default=e.NativeSubtitlesModuleDefinition},43931:function(t,e,i){var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},n.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.TextTrackController=void 0;var r,u,a,o=i(25926),s=i(4224),l=i(3714),d=i(4129),c=i(29669),h=i(74853),v=i(15487),f=i(88844),p=i(58313),b=i(88052),g=i(62756),m=i(52364);!function(t){t.Showing="showing",t.Hidden="hidden",t.Disabled="disabled"}(r||(r={})),function(t){t.Subtitle="subtitles",t.ForcedSubtitle="forced",t.Caption="captions",t.Metadata="metadata"}(u||(u={})),function(t){t.ID3="org.id3",t.DATERANGE="com.apple.quicktime.HLS",t.EMSG="https://aomedia.org/emsg/ID3"}(a||(a={}));var T=new RegExp("^(?:[a-z]+:)?//","i"),y=function(t){var e={id:t.id,lang:t.lang,label:t.label,kind:t.kind,isFragmented:t.isFragmented,isSideloaded:t.isSideloaded,enabled:t.textTrack&&t.textTrack.mode!==r.Disabled,forced:t.kind===u.ForcedSubtitle};return t.url&&(e.url=t.url),t.metadata&&(e.metadata=t.metadata),e},k=function(){function t(t,e,i,u){var o=this;this.cv=function(){o.Qu=!0,o.dv()},this.jv=function(t){var e=t.currentTarget.activeCues,i={frames:[]};for(var r in e)if(e[r].type===a.ID3&&void 0!==e[r].value){var u=e[r].value;h.ArrayHelper.isArrayBuffer(u.data)&&((u=n({},u)).data=h.ArrayHelper.getArray(new Uint8Array(u.data))),i[u.key]=u.data,i.frames.push(u),o.Pu&&o.kv(e[r],t.currentTarget)}i.frames.length&&o.Bu.dispatchEvent(l.PlayerEvent.Metadata,{metadataType:l.MetadataType.ID3,metadata:i})},this.lv=function(t){var e=t.target;if(e.activeCues&&e.activeCues.length>0){var i=m.TextTrackCueHelper.cueListToArray(e.activeCues),n=o.Bv(e);m.TextTrackCueHelper.sort(i).forEach(function(t){return o.nv(n,t)})}},this.uv=function(t){var e=window.setTimeout(function(){return o.vv(t)},0);o.Mu.push(e)},this.Av=function(){return null},this.Ev=function(){var t;o.Du?o.Eu&&o.disableSubtitle(o.Eu):(o.Eu=null===(t=o.Dv())||void 0===t?void 0:t.id,o.Eu&&o.enableSubtitle(o.Eu,!0))},this.Fv=function(){o.disableSubtitle(o.Eu),o.Ev()},this.Hv=function(){var t=o.Cv(),e=t[0],i=t[1];if(o.Gv(i))return o.disableSubtitle(i),void o.Ev();i||(o.Du=void 0),o.Ev(),o.Ru&&o.Iv(),i&&e&&e.mode!==r.Hidden&&!o.Nu.includes(e)&&o.enableSubtitle(i)},this.Au=t,this.Bu=t.eventHandler,this.Cu=e,this.type=u,this.Iu=[],this.Ju={},this.Gu=1,this.Hu=0,this.Lu=!1,this.Mu=[],this.Nu=[],this.Ou=[],this.Fu=null,this.Pu=(0,v.isSafariPlatform18orNewer)(),this.Qu=!1,i.hasOwnProperty("style")&&i.style.hasOwnProperty("nativeSubtitles")?this.Ku=!!i.style.nativeSubtitles:this.Ku=!1,e.audioTracks&&e.audioTracks.addEventListener("change",this.Fv),e.textTracks&&"function"==typeof e.textTracks.addEventListener&&(e.textTracks.addEventListener("addtrack",this.uv),e.textTracks.addEventListener("change",this.Hv)),this.Bu.one(l.PlayerEvent.SourceLoaded,this.cv,!0)}return Object.defineProperty(t.prototype,"Ru",{get:function(){return this.Lu||this.Ku},enumerable:!1,configurable:!0}),t.prototype.getAvailableSubtitles=function(){return Object.values(this.Ju||{}).filter(function(t){return t.kind!==u.ForcedSubtitle}).map(y)},t.prototype.dv=function(){var t=this;this.getAvailableSubtitles().filter(function(t){return!t.isSideloaded}).forEach(function(e){return t.Bu.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:e})})},t.prototype.enableSubtitle=function(t,e){void 0===e&&(e=!1);var i=this.Ju[t];return i?(e||(this.Du=t),i.textTrack&&(this.Ku||this.Lu?i.textTrack.mode=r.Showing:i.textTrack.mode=r.Hidden),i.enabled?Promise.resolve(!1):(i.enabled=!0,i.textTrack?i.loadPromise.then(function(){return!0},function(){return!1}):Promise.resolve(!0))):Promise.resolve(!1)},t.prototype.disableSubtitle=function(t){var e=this.Ju[t];return!!e&&(e.textTrack&&(e.textTrack.mode=r.Disabled),e.enabled=!1,this.sv(t),!0)},t.prototype.ev=function(t){var e,i;return window.VTTCue?new window.VTTCue(t.start,t.end,null!==(e=t.html)&&void 0!==e?e:t.text):window.TextTrackCue?new TextTrackCue(t.start,t.end,null!==(i=t.html)&&void 0!==i?i:t.text):void 0},t.prototype.fv=function(t,e){var i;if((null===(i=this.Ju)||void 0===i?void 0:i[e])&&t){for(var r=b.ModuleManager.get(g.ModuleName.Subtitles).SubtitleParserFactory.createInstance(this.Au,t).parse(t),u=0;u<r.length;u++)this.Bu.dispatchEvent(l.PlayerEvent.CueParsed,n(n({subtitleId:e},r[u]),{periodId:null})),this.Ju[e].textTrack.addCue(this.ev(r[u]));this.Bu.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:y(this.Ju[e])})}},t.prototype.gv=function(t,e){var i=e.body;i&&this.fv(i.trim(),t)},t.prototype.hv=function(t,e,i){this.Au.logger.debug("Error loading subtitle file: "+JSON.stringify(i)),this.removeSubtitle(t),this.Bu.dispatchEvent(l.PlayerEvent.Warning,new o.PlayerWarning(s.WarningCode.NETWORK_COULD_NOT_LOAD_SUBTITLE)),this.Au.logger.debug("Could not load subtitles/captions, got HTTP status code "+e.status)},t.prototype.iv=function(t){var e=this;return new d.DefaultContentLoader(this.Au,{maxRetries:this.Au.settings.MAX_RETRIES,retryDelay:this.Au.settings.RETRY_DELAY,onSuccess:function(i){return e.gv(t,i)},onFailure:function(i,n){return e.hv(t,i,n)},requestType:c.HttpRequestType.MEDIA_SUBTITLES})},t.prototype.kv=function(t,e){try{e.removeCue(t)}catch(t){"NotFoundError"!==t.name&&this.Au.logger.debug("Error removing cue from native TextTrack: ".concat(t.name,": ").concat(t.message))}},t.prototype.mv=function(t,e){var i=b.ModuleManager.get(g.ModuleName.Subtitles).HtmlTransformer,n=i.htmlToText,r=i.stripHtmlTags,u=(b.ModuleManager.get(g.ModuleName.SubtitlesWebVTT,!1)||{}).extractVttProperties,a={subtitleId:t,text:n(e.text),start:e.startTime,end:e.endTime},o=[a];if("subtitles"===e.track.kind)a.html=function(t){var e=(0,b.ModuleManager.get(g.ModuleName.Subtitles).HtmlTransformer.prepareHtml)(t);return e.startsWith("<span>")?e:"<span>".concat(e,"</span>")}(e.text),window.VTTCue&&(e instanceof VTTCue&&u?a.vtt=u(e):e instanceof VTTCue&&this.Au.logger.debug("Could not interpret VTT properties from native VTTCue Event as ".concat(g.ModuleName.SubtitlesWebVTT," is missing")));else if("captions"===e.track.kind){a.position=function(t){var e=80/15,i=t.line-10,n=t.position-10;return i-=i%e,n-=n%2.5,{row:i=Math.round(i/e),column:n=Math.round(n/2.5)}}(e);var s=r(a.text);a.position.column+s.length>m.CEA_608_MAX_LINE_LENGTH-1&&(o=m.TextTrackCueHelper.splitCea608Cue(a))}return o},t.prototype.nv=function(t,e){var i=this;if(e){var n=Object.values(this.Ju).find(function(t){return t.textTrack===e.track});if(function(t,e,i){if(i){var n=b.ModuleManager.get(g.ModuleName.Subtitles).HtmlTransformer,r=n.stripAwayHtmlBreakPoints,u=n.replaceHtmlBreakPointsWithNewLine;t&&i.isSideloaded&&(e.text=u(e.text)),t||i.isSideloaded||(e.text=r(e.text))}}(this.Ku||this.Lu,e,n),!this.Ku&&!this.Lu){var r=this.mv(t,e);r.forEach(function(n){i.pv(n)?i.Bu.dispatchEvent(l.PlayerEvent.CueUpdate,n):i.qv(t,e,n)}),this.ov(t,r)}}},t.prototype.ov=function(t,e){var i=this,n=this.Ou.filter(function(i){return!e.find(function(t){return i.start===t.start&&i.text===t.text&&i.subtitleId===t.subtitleId})&&i.end===1/0&&i.subtitleId===t});n.length>0&&n.forEach(function(e){i.rv(t,e)})},t.prototype.pv=function(t){var e=this,i=this.Ou.find(function(i){var n=i.start===t.start,r=i.text===t.text,u=!t.end||i.end===1/0||i.end===e.Cu.duration||i.end===t.end;return n&&r&&u});return!!i&&(i.end=t.end,!0)},t.prototype.qv=function(t,e,i){var n=this;this.Ou.push(i),e.onexit=function(){n.mv(t,e).forEach(function(e){return n.rv(t,e)})},this.Bu.dispatchEvent(l.PlayerEvent.CueEnter,i)},t.prototype.rv=function(t,e){var i=this.Ou.find(function(i){return i.subtitleId===t&&i.start===e.start&&i.end===e.end&&i.text===e.text});if(i){this.Ou=this.Ou.filter(function(t){return t!==i});var n={subtitleId:t,text:i.text,start:i.start,end:i.end};i.position&&(n.position=i.position),this.Bu.dispatchEvent(l.PlayerEvent.CueExit,n)}},t.prototype.sv=function(t){for(var e=0,i=this.Ou;e<i.length;e++){var n=i[e];!n.subtitleId||t&&n.subtitleId!==t||this.rv(n.subtitleId,n)}},t.prototype.removeSubtitle=function(t){if(this.Ju.hasOwnProperty(t)){this.Ju[t].textTrack.mode!==r.Disabled&&this.disableSubtitle(t),this.Ju[t].textTrack.mode=r.Disabled;var e=this.Ju[t];delete this.Ju[t],this.Bu.dispatchEvent(l.PlayerEvent.SubtitleRemoved,{subtitle:y(e)})}},t.prototype.signalSourceChange=function(){this.Cu&&this.Cu.textTracks&&"function"==typeof this.Cu.textTracks.addEventListener&&this.Cu.textTracks.removeEventListener("addtrack",this.uv),this.removeAll()},t.prototype.removeAll=function(){for(var t in this.Au.logger.debug("removing all subtitle tracks"),this.Mu.forEach(function(t){return(0,f.clearTimeoutIfDefined)(t)}),this.Mu=[],this.sv(),this.Ju)this.Ju.hasOwnProperty(t)&&(this.Ju[t].textTrack.mode=r.Disabled,this.Ju[t].textTrack.removeEventListener("cuechange",this.lv));this.Ju={},this.Ou=[],this.Gu=1,this.Hu=0},t.prototype.addSubtitle=function(t){if("function"!=typeof this.Cu.addTextTrack)return this.Au.logger.warn("adding subtitles not supported!"),Promise.reject();this.Ju.hasOwnProperty(t.id)&&(this.Au.logger.debug("re-adding subtitle "+t.id),this.removeSubtitle(t.id));var e=t.url?p.URLHelper.toFullUrl(function(t){return"https:"===location.protocol?t.replace(T,"//"):t}(t.url.trim())):null,i={id:t.id,url:e,kind:t.kind,lang:t.lang,label:t.label,textTrack:null,isFragmented:!1,isSideloaded:!0,loadPromise:null,metadata:t.metadata};return this.Ju[t.id]=i,this.Ju[t.id].textTrack=this.Cu.addTextTrack(t.kind,t.label),this.Ju[t.id].textTrack.mode=r.Disabled,this.Ju[t.id].textTrack.addEventListener("cuechange",this.lv),this.tv(i)},t.prototype.tv=function(t){var e=this;return t.url?(this.Au.logger.debug("loading "+t.url),this.Fu=this.iv(t.id),t.loadPromise=this.Fu.load(t.url).catch(function(t){return e.Au.logger.debug("Error while loading subtitles ",t)}).then(function(){if(!e.getAvailableSubtitles().find(function(e){return e.id===t.id}))throw"subtitle adding failed"})):(this.Au.logger.log("No url was provided for an external subtitle, nothing will be loaded."),t.loadPromise=Promise.resolve(),this.Bu.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:y(t)})),t.loadPromise},t.prototype.vv=function(t){for(var e,i,n=this,a=t.track,o=t.isFragmented&&a.kind===u.Subtitle||!1,s=0,d=Object.keys(this.Ju);s<d.length;s++){var c=d[s],h=this.Ju[c];if(h.textTrack===a&&h.isSideloaded)return void this.Au.logger.insane("track "+a.label+" has already been added externally")}switch(a.kind){case u.Subtitle:e=a.id||"sub".concat(this.Hu),i=a.label||"Subtitles (".concat(this.Hu,")"),this.Hu++;break;case u.ForcedSubtitle:e=a.id||"fsub".concat(this.Hu),i=a.label||"Subtitles (".concat(this.Hu,")) (Forced)"),this.Hu++;break;case u.Caption:e="CC".concat(this.Gu),i=a.label||"Captions (CC ".concat(this.Gu,")"),this.Gu++;break;default:return void this.wv(a)}this.Au.logger.debug("adding ".concat(a.kind," text track ").concat(e)),this.Ju[e]={id:e,url:null,kind:a.kind,lang:a.language||"unknown",label:i,textTrack:a,isFragmented:o,isSideloaded:!1,loadPromise:Promise.resolve()},(i=this.yv(this.Ju[e]))&&"string"==typeof i&&(this.Ju[e].label=i),this.Nu.push(a),a.addEventListener("cuechange",this.lv),a.kind!==u.ForcedSubtitle&&(this.Qu?this.Bu.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:y(this.Ju[e])}):this.Au.logger.debug('Delaying SubtitleAdded event until source is loaded track id="'.concat(e,'" label="').concat(this.Ju[e].label,'"'))),a.mode=r.Disabled;var v=window.setTimeout(function(){n.Nu=n.Nu.filter(function(t){return t!==a}),Object.keys(n.Ju).map(function(t){return n.Ju[t]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)&&t.textTrack.mode===r.Disabled}).forEach(function(t){n.Ru?t.textTrack.mode=r.Showing:t.textTrack.mode=r.Hidden})},0);this.Mu.push(v),this.xv()&&this.Ev()},t.prototype.wv=function(t){this.Au.settings.HLS_PARSE_NATIVE_METADATA&&(this.Iu.push(t),t.mode=r.Hidden,t.addEventListener("cuechange",this.jv))},t.prototype.xv=function(){var t=Object.keys(this.Ju).length;return this.Cu.textTracks.length===t},t.prototype.yv=function(t){var e={kind:t.kind,id:t.id,label:t.label,lang:t.lang};return this.zv()(e)},t.prototype.zv=function(){var t=this.Au.sourceContext,e=t&&t.source&&t.source.labeling;return e&&e[this.type]&&e[this.type].subtitles?"function"!=typeof e[this.type].subtitles?this.Av:e[this.type].subtitles:this.Av},t.prototype.Bv=function(t){var e;return(null===(e=Object.values(this.Ju).find(function(e){return e.textTrack===t}))||void 0===e?void 0:e.id)||null},t.prototype.Cv=function(){for(var t=0,e=this.Cu.textTracks;t<e.length;t++){var i=e[t];if((i.mode===r.Showing||i.mode===r.Hidden)&&i.kind!==u.Metadata&&i.kind!==u.ForcedSubtitle)return[i,this.Bv(i)]}return[void 0,void 0]},t.prototype.enableNative=function(){var t=this;Object.keys(this.Ju).map(function(e){return t.Ju[e]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)}).forEach(function(t){return t.textTrack.mode=r.Showing}),this.Lu=!0},t.prototype.disableNative=function(){var t=this;Object.keys(this.Ju).map(function(e){return t.Ju[e]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)}).forEach(function(t){return t.textTrack.mode=r.Hidden}),this.Lu=!1},t.prototype.seek=function(){var t=this;Object.keys(this.Ju).map(function(e){return t.Ju[e]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)}).forEach(function(t){var e=t.textTrack.mode;t.textTrack.mode=r.Disabled,t.textTrack.mode=e})},t.prototype.Dv=function(){var t,e,i,n=this.Cu.audioTracks,r=b.ModuleManager.get(g.ModuleName.Subtitles).LanguageComparer.isEqualIsoLanguage;if(this.Du)i=null===(t=this.Ju[this.Du])||void 0===t?void 0:t.lang;else{if(!n)return;var a=h.ArrayHelper.toArray(n).find(function(t){return t.enabled});i=null==a?void 0:a.language}i=null!==(e=null!=i?i:navigator.language)&&void 0!==e?e:navigator.userLanguage;var o=Object.values(this.Ju).filter(function(t){return t.kind===u.ForcedSubtitle}),s=o.find(function(t){return r(t.lang,i)});return null!=s?s:o[0]},t.prototype.Gv=function(t){var e=this,i=Object.keys(this.Ju).some(function(i){return i===t&&e.Ju[i].enabled});return t&&!this.Ru&&!i},t.prototype.Iv=function(){var t=this,e=function(t){var e=n({},t);return delete e.loadPromise,delete e.textTrack,n({},e)};this.Jv().forEach(function(i){t.disableSubtitle(i.id),t.Bu.dispatchEvent(l.PlayerEvent.SubtitleDisabled,{subtitle:e(i)})}),this.Kv().forEach(function(i){t.Bu.dispatchEvent(l.PlayerEvent.SubtitleEnabled,{subtitle:e(i)})})},t.prototype.Jv=function(){var t=this.Cu.textTracks;return Object.values(this.Ju).filter(function(t){return t.enabled}).filter(function(e){var i=E(t,e);return i&&i.mode===r.Disabled})},t.prototype.Kv=function(){var t=this.Cu.textTracks;return Object.values(this.Ju).filter(function(t){return!t.enabled}).filter(function(e){var i=E(t,e);return i&&i.mode!==r.Disabled})},t.prototype.dispose=function(){var t;this.removeAll(),this.Bu.off(l.PlayerEvent.SourceLoaded,this.cv),this.Bu=null,this.Ou=null,this.Ju=null,this.Iu=null,null===(t=this.Cu.audioTracks)||void 0===t||t.removeEventListener("change",this.Fv),this.Cu&&this.Cu.textTracks&&"function"==typeof this.Cu.textTracks.addEventListener&&(this.Cu.textTracks.removeEventListener("addtrack",this.uv),this.Cu.textTracks.removeEventListener("change",this.Hv)),this.Fu&&this.Fu.dispose(),this.Fu=null},t}();function E(t,e){for(var i=0,n=t;i<n.length;i++){var r=n[i];if(r===e.textTrack)return r}}e.TextTrackController=k},52364:function(t,e){var i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},i.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.TextTrackCueHelper=e.CEA_608_MAX_LINE_LENGTH=void 0,e.CEA_608_MAX_LINE_LENGTH=32;var n=function(){function t(){}return t.cueListToArray=function(t){for(var e=[],i=0;i<t.length;i++)e.push(t[i]);return e},t.sortEqualStartTimeByLineFn=function(t,e){if("line"in t&&"line"in e&&t.startTime===e.startTime){if(t.line<e.line)return-1;if(t.line>e.line)return 1}return 0},t.sortByStartTimeFn=function(t,e){return t.startTime<e.startTime?-1:t.startTime>e.startTime?1:0},t.sort=function(e){return e.sort(t.sortByStartTimeFn),e.sort(t.sortEqualStartTimeByLineFn),e},t.getTagIndexRanges=function(t){for(var e,i=RegExp("<[^>]*>","g"),n=[];e=i.exec(t);){var r=e[0];n.push({start:e.index,end:e.index+r.length-1})}return n},t.splitCea608Cue=function(i){for(var n=e.CEA_608_MAX_LINE_LENGTH-i.position.column,r=i.text,u=t.getTagIndexRanges(r),a=[],o=0,s=0,l=!1,d=0,c=0;c<r.length;){if(c===r.length-1){a.push(r.substring(o));break}if(u.length>0&&c===u[0].start&&(l=!0),l);else if(s++," "===r[c]&&(d=c),s>=n&&d>o){c=d+1;var h=r.substring(o,c);h&&a.push(h),o=c,s=1}l&&u.length>0&&c===u[0].end&&(l=!1,u.shift()),c++}var v=t.createCueEvents(a,i);return t.adjustCea608CaptionPositioning(v),v},t.createCueEvents=function(t,e){var n=t.length-1;return t.map(function(t){var r=i({},e);return r.text=t,r.position={column:r.position.column,row:r.position.row-n},n--,r})},t.adjustCea608CaptionPositioning=function(t){var e=Math.max.apply(Math,t.map(function(t){return t.position.row})),i=Math.min.apply(Math,t.map(function(t){return t.position.row}));if(e>14){var n=14-e;t.forEach(function(t){return t.position.row+=n})}if(i<0){var r=0-i;t.forEach(function(t){return t.position.row+=r})}},t}();e.TextTrackCueHelper=n}},function(t){return function(){return t(91444)}()}])});
17
+ "use strict";!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["subtitles-native"]=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player["subtitles-native"]=e())}(self,function(){return(self.webpackChunkbitmovin_player=self.webpackChunkbitmovin_player||[]).push([[826],{91444:function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.NativeSubtitlesModuleDefinition=void 0;var n=i(62756),r=i(43931);e.NativeSubtitlesModuleDefinition={name:n.ModuleName.SubtitlesNative,module:function(){return{TextTrackController:r.TextTrackController}},dependencies:[n.ModuleName.Subtitles]},e.default=e.NativeSubtitlesModuleDefinition},43931:function(t,e,i){var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},n.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.TextTrackController=void 0;var r,a,o,s=i(25926),u=i(4224),l=i(3714),d=i(4129),c=i(29669),h=i(74853),f=i(15487),p=i(88844),v=i(58313),b=i(88052),g=i(62756),m=i(52364);!function(t){t.Showing="showing",t.Hidden="hidden",t.Disabled="disabled"}(r||(r={})),function(t){t.Subtitle="subtitles",t.ForcedSubtitle="forced",t.Caption="captions",t.Metadata="metadata"}(a||(a={})),function(t){t.ID3="org.id3",t.DATERANGE="com.apple.quicktime.HLS",t.EMSG="https://aomedia.org/emsg/ID3"}(o||(o={}));var T=new RegExp("^(?:[a-z]+:)?//","i"),y=function(t){var e={id:t.id,lang:t.lang,label:t.label,kind:t.kind,isFragmented:t.isFragmented,isSideloaded:t.isSideloaded,enabled:t.textTrack&&t.textTrack.mode!==r.Disabled,forced:t.kind===a.ForcedSubtitle};return t.url&&(e.url=t.url),t.metadata&&(e.metadata=t.metadata),e},k=function(){function t(t,e,i,a){var s=this;this.wt=function(){s.ut=!0,s.xt()},this.Dt=function(t){var e=t.currentTarget.activeCues,i={frames:[]};for(var r in e)if(e[r].type===o.ID3&&void 0!==e[r].value){var a=e[r].value;h.ArrayHelper.isArrayBuffer(a.data)&&((a=n({},a)).data=h.ArrayHelper.getArray(new Uint8Array(a.data))),i[a.key]=a.data,i.frames.push(a),s.tt&&s.Et(e[r],t.currentTarget)}i.frames.length&&s.ft.dispatchEvent(l.PlayerEvent.Metadata,{metadataType:l.MetadataType.ID3,metadata:i})},this.Ft=function(t){var e=t.target;if(e.activeCues&&e.activeCues.length>0){var i=m.TextTrackCueHelper.cueListToArray(e.activeCues),n=s.fu(e);m.TextTrackCueHelper.sort(i).forEach(function(t){return s.Ht(n,t)})}},this.Yu=function(t){var e=window.setTimeout(function(){return s.Zu(t)},0);s.qt.push(e)},this.eu=function(){return null},this.iu=function(){var t;s.ht?s.it&&s.disableSubtitle(s.it):(s.it=null===(t=s.hu())||void 0===t?void 0:t.id,s.it&&s.enableSubtitle(s.it,!0))},this.ju=function(){s.disableSubtitle(s.it),s.iu()},this.lu=function(){var t=s.gu(),e=t[0],i=t[1];if(s.ku(i))return s.disableSubtitle(i),void s.iu();i||(s.ht=void 0),s.iu(),s.vt&&s.mu(),i&&e&&e.mode!==r.Hidden&&!s.rt.includes(e)&&s.enableSubtitle(i)},this.et=t,this.ft=t.eventHandler,this.gt=e,this.type=a,this.mt=[],this.nt={},this.kt=1,this.lt=0,this.pt=!1,this.qt=[],this.rt=[],this.st=[],this.jt=null,this.tt=(0,f.isSafariPlatform18orNewer)(),this.ut=!1,i.hasOwnProperty("style")&&i.style.hasOwnProperty("nativeSubtitles")?this.ot=!!i.style.nativeSubtitles:this.ot=!1,e.audioTracks&&e.audioTracks.addEventListener("change",this.ju),e.textTracks&&"function"==typeof e.textTracks.addEventListener&&(e.textTracks.addEventListener("addtrack",this.Yu),e.textTracks.addEventListener("change",this.lu)),this.ft.one(l.PlayerEvent.SourceLoaded,this.wt,!0)}return Object.defineProperty(t.prototype,"vt",{get:function(){return this.pt||this.ot},enumerable:!1,configurable:!0}),t.prototype.getAvailableSubtitles=function(){return Object.values(this.nt||{}).filter(function(t){return t.kind!==a.ForcedSubtitle}).map(y)},t.prototype.xt=function(){var t=this;this.getAvailableSubtitles().filter(function(t){return!t.isSideloaded}).forEach(function(e){return t.ft.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:e})})},t.prototype.enableSubtitle=function(t,e){void 0===e&&(e=!1);var i=this.nt[t];return i?(e||(this.ht=t),i.textTrack&&(this.ot||this.pt?i.textTrack.mode=r.Showing:i.textTrack.mode=r.Hidden),i.enabled?Promise.resolve(!1):(i.enabled=!0,i.textTrack?i.loadPromise.then(function(){return!0},function(){return!1}):Promise.resolve(!0))):Promise.resolve(!1)},t.prototype.disableSubtitle=function(t){var e=this.nt[t];return!!e&&(e.textTrack&&(e.textTrack.mode=r.Disabled),e.enabled=!1,this.Wu(t),!0)},t.prototype.yt=function(t){var e,i;return window.VTTCue?new window.VTTCue(t.start,t.end,null!==(e=t.html)&&void 0!==e?e:t.text):window.TextTrackCue?new TextTrackCue(t.start,t.end,null!==(i=t.html)&&void 0!==i?i:t.text):void 0},t.prototype.zt=function(t,e){var i;if((null===(i=this.nt)||void 0===i?void 0:i[e])&&t){for(var r=b.ModuleManager.get(g.ModuleName.Subtitles).SubtitleParserFactory.createInstance(this.et,t).parse(t),a=0;a<r.length;a++)this.ft.dispatchEvent(l.PlayerEvent.CueParsed,n(n({subtitleId:e},r[a]),{periodId:null})),this.nt[e].textTrack.addCue(this.yt(r[a]));this.ft.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:y(this.nt[e])})}},t.prototype.At=function(t,e){var i=e.body;i&&this.zt(i.trim(),t)},t.prototype.Bt=function(t,e,i){this.et.logger.debug("Error loading subtitle file: "+JSON.stringify(i)),this.removeSubtitle(t),this.ft.dispatchEvent(l.PlayerEvent.Warning,new s.PlayerWarning(u.WarningCode.NETWORK_COULD_NOT_LOAD_SUBTITLE)),this.et.logger.debug("Could not load subtitles/captions, got HTTP status code "+e.status)},t.prototype.Ct=function(t){var e=this;return new d.DefaultContentLoader(this.et,{maxRetries:this.et.settings.MAX_RETRIES,retryDelay:this.et.settings.RETRY_DELAY,onSuccess:function(i){return e.At(t,i)},onFailure:function(i,n){return e.Bt(t,i,n)},requestType:c.HttpRequestType.MEDIA_SUBTITLES})},t.prototype.Et=function(t,e){try{e.removeCue(t)}catch(t){"NotFoundError"!==t.name&&this.et.logger.debug("Error removing cue from native TextTrack: ".concat(t.name,": ").concat(t.message))}},t.prototype.Gt=function(t,e){var i=b.ModuleManager.get(g.ModuleName.Subtitles).HtmlTransformer,n=i.htmlToText,r=i.stripHtmlTags,a=(b.ModuleManager.get(g.ModuleName.SubtitlesWebVTT,!1)||{}).extractVttProperties,o={subtitleId:t,text:n(e.text),start:e.startTime,end:e.endTime},s=[o];if("subtitles"===e.track.kind)o.html=function(t){var e=(0,b.ModuleManager.get(g.ModuleName.Subtitles).HtmlTransformer.prepareHtml)(t);return e.startsWith("<span>")?e:"<span>".concat(e,"</span>")}(e.text),window.VTTCue&&(e instanceof VTTCue&&a?o.vtt=a(e):e instanceof VTTCue&&this.et.logger.debug("Could not interpret VTT properties from native VTTCue Event as ".concat(g.ModuleName.SubtitlesWebVTT," is missing")));else if("captions"===e.track.kind){o.position=function(t){var e=80/15,i=t.line-10,n=t.position-10;return i-=i%e,n-=n%2.5,{row:i=Math.round(i/e),column:n=Math.round(n/2.5)}}(e);var u=r(o.text);o.position.column+u.length>m.CEA_608_MAX_LINE_LENGTH-1&&(s=m.TextTrackCueHelper.splitCea608Cue(o))}return s},t.prototype.Ht=function(t,e){var i=this;if(e){var n=Object.values(this.nt).find(function(t){return t.textTrack===e.track});if(function(t,e,i){if(i){var n=b.ModuleManager.get(g.ModuleName.Subtitles).HtmlTransformer,r=n.stripAwayHtmlBreakPoints,a=n.replaceHtmlBreakPointsWithNewLine;t&&i.isSideloaded&&(e.text=a(e.text)),t||i.isSideloaded||(e.text=r(e.text))}}(this.ot||this.pt,e,n),!this.ot&&!this.pt){var r=this.Gt(t,e);r.forEach(function(n){i.Tu(n)?i.ft.dispatchEvent(l.PlayerEvent.CueUpdate,n):i.Uu(t,e,n)}),this.Su(t,r)}}},t.prototype.Su=function(t,e){var i=this,n=this.st.filter(function(i){return!e.find(function(t){return i.start===t.start&&i.text===t.text&&i.subtitleId===t.subtitleId})&&i.end===1/0&&i.subtitleId===t});n.length>0&&n.forEach(function(e){i.Vu(t,e)})},t.prototype.Tu=function(t){var e=this,i=this.st.find(function(i){var n=i.start===t.start,r=i.text===t.text,a=!t.end||i.end===1/0||i.end===e.gt.duration||i.end===t.end;return n&&r&&a});return!!i&&(i.end=t.end,!0)},t.prototype.Uu=function(t,e,i){var n=this;this.st.push(i),e.onexit=function(){n.Gt(t,e).forEach(function(e){return n.Vu(t,e)})},this.ft.dispatchEvent(l.PlayerEvent.CueEnter,i)},t.prototype.Vu=function(t,e){var i=this.st.find(function(i){return i.subtitleId===t&&i.start===e.start&&i.end===e.end&&i.text===e.text});if(i){this.st=this.st.filter(function(t){return t!==i});var n={subtitleId:t,text:i.text,start:i.start,end:i.end};i.position&&(n.position=i.position),this.ft.dispatchEvent(l.PlayerEvent.CueExit,n)}},t.prototype.Wu=function(t){for(var e=0,i=this.st;e<i.length;e++){var n=i[e];!n.subtitleId||t&&n.subtitleId!==t||this.Vu(n.subtitleId,n)}},t.prototype.removeSubtitle=function(t){if(this.nt.hasOwnProperty(t)){this.nt[t].textTrack.mode!==r.Disabled&&this.disableSubtitle(t),this.nt[t].textTrack.mode=r.Disabled;var e=this.nt[t];delete this.nt[t],this.ft.dispatchEvent(l.PlayerEvent.SubtitleRemoved,{subtitle:y(e)})}},t.prototype.signalSourceChange=function(){this.gt&&this.gt.textTracks&&"function"==typeof this.gt.textTracks.addEventListener&&this.gt.textTracks.removeEventListener("addtrack",this.Yu),this.removeAll()},t.prototype.removeAll=function(){for(var t in this.et.logger.debug("removing all subtitle tracks"),this.qt.forEach(function(t){return(0,p.clearTimeoutIfDefined)(t)}),this.qt=[],this.Wu(),this.nt)this.nt.hasOwnProperty(t)&&(this.nt[t].textTrack.mode=r.Disabled,this.nt[t].textTrack.removeEventListener("cuechange",this.Ft));this.nt={},this.st=[],this.kt=1,this.lt=0},t.prototype.addSubtitle=function(t){if("function"!=typeof this.gt.addTextTrack)return this.et.logger.warn("adding subtitles not supported!"),Promise.reject();this.nt.hasOwnProperty(t.id)&&(this.et.logger.debug("re-adding subtitle "+t.id),this.removeSubtitle(t.id));var e=t.url?v.URLHelper.toFullUrl(function(t){return"https:"===location.protocol?t.replace(T,"//"):t}(t.url.trim())):null,i={id:t.id,url:e,kind:t.kind,lang:t.lang,label:t.label,textTrack:null,isFragmented:!1,isSideloaded:!0,loadPromise:null,metadata:t.metadata};return this.nt[t.id]=i,this.nt[t.id].textTrack=this.gt.addTextTrack(t.kind,t.label),this.nt[t.id].textTrack.mode=r.Disabled,this.nt[t.id].textTrack.addEventListener("cuechange",this.Ft),this.Xu(i)},t.prototype.Xu=function(t){var e=this;return t.url?(this.et.logger.debug("loading "+t.url),this.jt=this.Ct(t.id),t.loadPromise=this.jt.load(t.url).catch(function(t){return e.et.logger.debug("Error while loading subtitles ",t)}).then(function(){if(!e.getAvailableSubtitles().find(function(e){return e.id===t.id}))throw"subtitle adding failed"})):(this.et.logger.log("No url was provided for an external subtitle, nothing will be loaded."),t.loadPromise=Promise.resolve(),this.ft.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:y(t)})),t.loadPromise},t.prototype.Zu=function(t){for(var e,i,n=this,o=t.track,s=t.isFragmented&&o.kind===a.Subtitle||!1,u=0,d=Object.keys(this.nt);u<d.length;u++){var c=d[u],h=this.nt[c];if(h.textTrack===o&&h.isSideloaded)return void this.et.logger.insane("track "+o.label+" has already been added externally")}switch(o.kind){case a.Subtitle:e=o.id||"sub".concat(this.lt),i=o.label||"Subtitles (".concat(this.lt,")"),this.lt++;break;case a.ForcedSubtitle:e=o.id||"fsub".concat(this.lt),i=o.label||"Subtitles (".concat(this.lt,")) (Forced)"),this.lt++;break;case a.Caption:e="CC".concat(this.kt),i=o.label||"Captions (CC ".concat(this.kt,")"),this.kt++;break;default:return void this.au(o)}this.et.logger.debug("adding ".concat(o.kind," text track ").concat(e)),this.nt[e]={id:e,url:null,kind:o.kind,lang:o.language||"unknown",label:i,textTrack:o,isFragmented:s,isSideloaded:!1,loadPromise:Promise.resolve()},(i=this.cu(this.nt[e]))&&"string"==typeof i&&(this.nt[e].label=i),this.rt.push(o),o.addEventListener("cuechange",this.Ft),o.kind!==a.ForcedSubtitle&&(this.ut?this.ft.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:y(this.nt[e])}):this.et.logger.debug('Delaying SubtitleAdded event until source is loaded track id="'.concat(e,'" label="').concat(this.nt[e].label,'"'))),o.mode=r.Disabled;var f=window.setTimeout(function(){n.rt=n.rt.filter(function(t){return t!==o}),Object.keys(n.nt).map(function(t){return n.nt[t]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)&&t.textTrack.mode===r.Disabled}).forEach(function(t){n.vt?t.textTrack.mode=r.Showing:t.textTrack.mode=r.Hidden})},0);this.qt.push(f),this.bu()&&this.iu()},t.prototype.au=function(t){this.et.settings.HLS_PARSE_NATIVE_METADATA&&(this.mt.push(t),t.mode=r.Hidden,t.addEventListener("cuechange",this.Dt))},t.prototype.bu=function(){var t=Object.keys(this.nt).length;return this.gt.textTracks.length===t},t.prototype.cu=function(t){var e={kind:t.kind,id:t.id,label:t.label,lang:t.lang};return this.du()(e)},t.prototype.du=function(){var t=this.et.sourceContext,e=t&&t.source&&t.source.labeling;return e&&e[this.type]&&e[this.type].subtitles?"function"!=typeof e[this.type].subtitles?this.eu:e[this.type].subtitles:this.eu},t.prototype.fu=function(t){var e;return(null===(e=Object.values(this.nt).find(function(e){return e.textTrack===t}))||void 0===e?void 0:e.id)||null},t.prototype.gu=function(){for(var t=0,e=this.gt.textTracks;t<e.length;t++){var i=e[t];if((i.mode===r.Showing||i.mode===r.Hidden)&&i.kind!==a.Metadata&&i.kind!==a.ForcedSubtitle)return[i,this.fu(i)]}return[void 0,void 0]},t.prototype.enableNative=function(){var t=this;Object.keys(this.nt).map(function(e){return t.nt[e]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)}).forEach(function(t){return t.textTrack.mode=r.Showing}),this.pt=!0},t.prototype.disableNative=function(){var t=this;Object.keys(this.nt).map(function(e){return t.nt[e]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)}).forEach(function(t){return t.textTrack.mode=r.Hidden}),this.pt=!1},t.prototype.seek=function(){var t=this;Object.keys(this.nt).map(function(e){return t.nt[e]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)}).forEach(function(t){var e=t.textTrack.mode;t.textTrack.mode=r.Disabled,t.textTrack.mode=e})},t.prototype.hu=function(){var t,e,i,n=this.gt.audioTracks,r=b.ModuleManager.get(g.ModuleName.Subtitles).LanguageComparer.isEqualIsoLanguage;if(this.ht)i=null===(t=this.nt[this.ht])||void 0===t?void 0:t.lang;else{if(!n)return;var o=h.ArrayHelper.toArray(n).find(function(t){return t.enabled});i=null==o?void 0:o.language}i=null!==(e=null!=i?i:navigator.language)&&void 0!==e?e:navigator.userLanguage;var s=Object.values(this.nt).filter(function(t){return t.kind===a.ForcedSubtitle}),u=s.find(function(t){return r(t.lang,i)});return null!=u?u:s[0]},t.prototype.ku=function(t){var e=this,i=Object.keys(this.nt).some(function(i){return i===t&&e.nt[i].enabled});return t&&!this.vt&&!i},t.prototype.mu=function(){var t=this,e=function(t){var e=n({},t);return delete e.loadPromise,delete e.textTrack,n({},e)};this.nu().forEach(function(i){t.disableSubtitle(i.id),t.ft.dispatchEvent(l.PlayerEvent.SubtitleDisabled,{subtitle:e(i)})}),this.ou().forEach(function(i){t.ft.dispatchEvent(l.PlayerEvent.SubtitleEnabled,{subtitle:e(i)})})},t.prototype.nu=function(){var t=this.gt.textTracks;return Object.values(this.nt).filter(function(t){return t.enabled}).filter(function(e){var i=x(t,e);return i&&i.mode===r.Disabled})},t.prototype.ou=function(){var t=this.gt.textTracks;return Object.values(this.nt).filter(function(t){return!t.enabled}).filter(function(e){var i=x(t,e);return i&&i.mode!==r.Disabled})},t.prototype.dispose=function(){var t;this.removeAll(),this.ft.off(l.PlayerEvent.SourceLoaded,this.wt),this.ft=null,this.st=null,this.nt=null,this.mt=null,null===(t=this.gt.audioTracks)||void 0===t||t.removeEventListener("change",this.ju),this.gt&&this.gt.textTracks&&"function"==typeof this.gt.textTracks.addEventListener&&(this.gt.textTracks.removeEventListener("addtrack",this.Yu),this.gt.textTracks.removeEventListener("change",this.lu)),this.jt&&this.jt.dispose(),this.jt=null},t}();function x(t,e){for(var i=0,n=t;i<n.length;i++){var r=n[i];if(r===e.textTrack)return r}}e.TextTrackController=k},52364:function(t,e){var i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},i.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.TextTrackCueHelper=e.CEA_608_MAX_LINE_LENGTH=void 0,e.CEA_608_MAX_LINE_LENGTH=32;var n=function(){function t(){}return t.cueListToArray=function(t){for(var e=[],i=0;i<t.length;i++)e.push(t[i]);return e},t.sortEqualStartTimeByLineFn=function(t,e){if("line"in t&&"line"in e&&t.startTime===e.startTime){if(t.line<e.line)return-1;if(t.line>e.line)return 1}return 0},t.sortByStartTimeFn=function(t,e){return t.startTime<e.startTime?-1:t.startTime>e.startTime?1:0},t.sort=function(e){return e.sort(t.sortByStartTimeFn),e.sort(t.sortEqualStartTimeByLineFn),e},t.getTagIndexRanges=function(t){for(var e,i=RegExp("<[^>]*>","g"),n=[];e=i.exec(t);){var r=e[0];n.push({start:e.index,end:e.index+r.length-1})}return n},t.splitCea608Cue=function(i){for(var n=e.CEA_608_MAX_LINE_LENGTH-i.position.column,r=i.text,a=t.getTagIndexRanges(r),o=[],s=0,u=0,l=!1,d=0,c=0;c<r.length;){if(c===r.length-1){o.push(r.substring(s));break}if(a.length>0&&c===a[0].start&&(l=!0),l);else if(u++," "===r[c]&&(d=c),u>=n&&d>s){c=d+1;var h=r.substring(s,c);h&&o.push(h),s=c,u=1}l&&a.length>0&&c===a[0].end&&(l=!1,a.shift()),c++}var f=t.createCueEvents(o,i);return t.adjustCea608CaptionPositioning(f),f},t.createCueEvents=function(t,e){var n=t.length-1;return t.map(function(t){var r=i({},e);return r.text=t,r.position={column:r.position.column,row:r.position.row-n},n--,r})},t.adjustCea608CaptionPositioning=function(t){var e=Math.max.apply(Math,t.map(function(t){return t.position.row})),i=Math.min.apply(Math,t.map(function(t){return t.position.row}));if(e>14){var n=14-e;t.forEach(function(t){return t.position.row+=n})}if(i<0){var r=0-i;t.forEach(function(t){return t.position.row+=r})}},t}();e.TextTrackCueHelper=n}},function(t){return function(){return t(91444)}()}])});
18
18
  })();
@@ -9,10 +9,10 @@
9
9
  * This software includes open-source components. See THIRD_PARTY_NOTICES
10
10
  * in the distribution for details.
11
11
  *
12
- * Bitmovin Player Version 8.280.0
12
+ * Bitmovin Player Version 8.281.0
13
13
  *
14
14
  ****************************************************************************/
15
15
 
16
16
  (function() {
17
- "use strict";!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["subtitles-native"]=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player["subtitles-native"]=e())}(self,function(){return(self.webpackChunkbitmovin_player=self.webpackChunkbitmovin_player||[]).push([[826],{91444:function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.NativeSubtitlesModuleDefinition=void 0;var r=i(62756),n=i(43931);e.NativeSubtitlesModuleDefinition={name:r.ModuleName.SubtitlesNative,module:function(){return{TextTrackController:n.TextTrackController}},dependencies:[r.ModuleName.Subtitles]},e.default=e.NativeSubtitlesModuleDefinition},43931:function(t,e,i){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,i=1,r=arguments.length;i<r;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.TextTrackController=void 0;var n,a,o,s=i(25926),u=i(4224),l=i(3714),d=i(4129),c=i(29669),h=i(74853),f=i(15487),p=i(88844),v=i(58313),b=i(88052),q=i(62756),T=i(52364);!function(t){t.Showing="showing",t.Hidden="hidden",t.Disabled="disabled"}(n||(n={})),function(t){t.Subtitle="subtitles",t.ForcedSubtitle="forced",t.Caption="captions",t.Metadata="metadata"}(a||(a={})),function(t){t.ID3="org.id3",t.DATERANGE="com.apple.quicktime.HLS",t.EMSG="https://aomedia.org/emsg/ID3"}(o||(o={}));var m=new RegExp("^(?:[a-z]+:)?//","i"),y=function(t){var e={id:t.id,lang:t.lang,label:t.label,kind:t.kind,isFragmented:t.isFragmented,isSideloaded:t.isSideloaded,enabled:t.textTrack&&t.textTrack.mode!==n.Disabled,forced:t.kind===a.ForcedSubtitle};return t.url&&(e.url=t.url),t.metadata&&(e.metadata=t.metadata),e},g=function(){function t(t,e,i,a){var s=this;this.rr=function(){s.pr=!0,s.sr()},this.yr=function(t){var e=t.currentTarget.activeCues,i={frames:[]};for(var n in e)if(e[n].type===o.ID3&&void 0!==e[n].value){var a=e[n].value;h.ArrayHelper.isArrayBuffer(a.data)&&((a=r({},a)).data=h.ArrayHelper.getArray(new Uint8Array(a.data))),i[a.key]=a.data,i.frames.push(a),s.or&&s.zr(e[n],t.currentTarget)}i.frames.length&&s.Qq.dispatchEvent(l.PlayerEvent.Metadata,{metadataType:l.MetadataType.ID3,metadata:i})},this.Ar=function(t){var e=t.target;if(e.activeCues&&e.activeCues.length>0){var i=T.TextTrackCueHelper.cueListToArray(e.activeCues),r=s.Qr(e);T.TextTrackCueHelper.sort(i).forEach(function(t){return s.Cr(r,t)})}},this.Jr=function(t){var e=window.setTimeout(function(){return s.Kr(t)},0);s.bq.push(e)},this.Pr=function(){return null},this.Tr=function(){var t;s.Sq?s.Tq&&s.disableSubtitle(s.Tq):(s.Tq=null===(t=s.Sr())||void 0===t?void 0:t.id,s.Tq&&s.enableSubtitle(s.Tq,!0))},this.Ur=function(){s.disableSubtitle(s.Tq),s.Tr()},this.Wr=function(){var t=s.Rr(),e=t[0],i=t[1];if(s.Vr(i))return s.disableSubtitle(i),void s.Tr();i||(s.Sq=void 0),s.Tr(),s.qr&&s.Xr(),i&&e&&e.mode!==n.Hidden&&!s.cq.includes(e)&&s.enableSubtitle(i)},this.Pq=t,this.Qq=t.eventHandler,this.Rq=e,this.type=a,this.Xq=[],this.Yq={},this.Vq=1,this.Wq=0,this.aq=!1,this.bq=[],this.cq=[],this.dq=[],this.Uq=null,this.or=(0,f.isSafariPlatform18orNewer)(),this.pr=!1,i.hasOwnProperty("style")&&i.style.hasOwnProperty("nativeSubtitles")?this.Zq=!!i.style.nativeSubtitles:this.Zq=!1,e.audioTracks&&e.audioTracks.addEventListener("change",this.Ur),e.textTracks&&"function"==typeof e.textTracks.addEventListener&&(e.textTracks.addEventListener("addtrack",this.Jr),e.textTracks.addEventListener("change",this.Wr)),this.Qq.one(l.PlayerEvent.SourceLoaded,this.rr,!0)}return Object.defineProperty(t.prototype,"qr",{get:function(){return this.aq||this.Zq},enumerable:!1,configurable:!0}),t.prototype.getAvailableSubtitles=function(){return Object.values(this.Yq||{}).filter(function(t){return t.kind!==a.ForcedSubtitle}).map(y)},t.prototype.sr=function(){var t=this;this.getAvailableSubtitles().filter(function(t){return!t.isSideloaded}).forEach(function(e){return t.Qq.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:e})})},t.prototype.enableSubtitle=function(t,e){void 0===e&&(e=!1);var i=this.Yq[t];return i?(e||(this.Sq=t),i.textTrack&&(this.Zq||this.aq?i.textTrack.mode=n.Showing:i.textTrack.mode=n.Hidden),i.enabled?Promise.resolve(!1):(i.enabled=!0,i.textTrack?i.loadPromise.then(function(){return!0},function(){return!1}):Promise.resolve(!0))):Promise.resolve(!1)},t.prototype.disableSubtitle=function(t){var e=this.Yq[t];return!!e&&(e.textTrack&&(e.textTrack.mode=n.Disabled),e.enabled=!1,this.Hr(t),!0)},t.prototype.tr=function(t){var e,i;return window.VTTCue?new window.VTTCue(t.start,t.end,null!==(e=t.html)&&void 0!==e?e:t.text):window.TextTrackCue?new TextTrackCue(t.start,t.end,null!==(i=t.html)&&void 0!==i?i:t.text):void 0},t.prototype.ur=function(t,e){var i;if((null===(i=this.Yq)||void 0===i?void 0:i[e])&&t){for(var n=b.ModuleManager.get(q.ModuleName.Subtitles).SubtitleParserFactory.createInstance(this.Pq,t).parse(t),a=0;a<n.length;a++)this.Qq.dispatchEvent(l.PlayerEvent.CueParsed,r(r({subtitleId:e},n[a]),{periodId:null})),this.Yq[e].textTrack.addCue(this.tr(n[a]));this.Qq.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:y(this.Yq[e])})}},t.prototype.vr=function(t,e){var i=e.body;i&&this.ur(i.trim(),t)},t.prototype.wr=function(t,e,i){this.removeSubtitle(t),this.Qq.dispatchEvent(l.PlayerEvent.Warning,new s.PlayerWarning(u.WarningCode.NETWORK_COULD_NOT_LOAD_SUBTITLE))},t.prototype.xr=function(t){var e=this;return new d.DefaultContentLoader(this.Pq,{maxRetries:this.Pq.settings.MAX_RETRIES,retryDelay:this.Pq.settings.RETRY_DELAY,onSuccess:function(i){return e.vr(t,i)},onFailure:function(i,r){return e.wr(t,i,r)},requestType:c.HttpRequestType.MEDIA_SUBTITLES})},t.prototype.zr=function(t,e){try{e.removeCue(t)}catch(t){t.name}},t.prototype.Br=function(t,e){var i=b.ModuleManager.get(q.ModuleName.Subtitles).HtmlTransformer,r=i.htmlToText,n=i.stripHtmlTags,a=(b.ModuleManager.get(q.ModuleName.SubtitlesWebVTT,!1)||{}).extractVttProperties,o={subtitleId:t,text:r(e.text),start:e.startTime,end:e.endTime},s=[o];if("subtitles"===e.track.kind)o.html=function(t){var e=(0,b.ModuleManager.get(q.ModuleName.Subtitles).HtmlTransformer.prepareHtml)(t);return e.startsWith("<span>")?e:"<span>".concat(e,"</span>")}(e.text),window.VTTCue&&(e instanceof VTTCue&&a?o.vtt=a(e):VTTCue);else if("captions"===e.track.kind){o.position=function(t){var e=80/15,i=t.line-10,r=t.position-10;return i-=i%e,r-=r%2.5,{row:i=Math.round(i/e),column:r=Math.round(r/2.5)}}(e);var u=n(o.text);o.position.column+u.length>T.CEA_608_MAX_LINE_LENGTH-1&&(s=T.TextTrackCueHelper.splitCea608Cue(o))}return s},t.prototype.Cr=function(t,e){var i=this;if(e){var r=Object.values(this.Yq).find(function(t){return t.textTrack===e.track});if(function(t,e,i){if(i){var r=b.ModuleManager.get(q.ModuleName.Subtitles).HtmlTransformer,n=r.stripAwayHtmlBreakPoints,a=r.replaceHtmlBreakPointsWithNewLine;t&&i.isSideloaded&&(e.text=a(e.text)),t||i.isSideloaded||(e.text=n(e.text))}}(this.Zq||this.aq,e,r),!this.Zq&&!this.aq){var n=this.Br(t,e);n.forEach(function(r){i.Er(r)?i.Qq.dispatchEvent(l.PlayerEvent.CueUpdate,r):i.Fr(t,e,r)}),this.Dr(t,n)}}},t.prototype.Dr=function(t,e){var i=this,r=this.dq.filter(function(i){return!e.find(function(t){return i.start===t.start&&i.text===t.text&&i.subtitleId===t.subtitleId})&&i.end===1/0&&i.subtitleId===t});r.length>0&&r.forEach(function(e){i.Gr(t,e)})},t.prototype.Er=function(t){var e=this,i=this.dq.find(function(i){var r=i.start===t.start,n=i.text===t.text,a=!t.end||i.end===1/0||i.end===e.Rq.duration||i.end===t.end;return r&&n&&a});return!!i&&(i.end=t.end,!0)},t.prototype.Fr=function(t,e,i){var r=this;this.dq.push(i),e.onexit=function(){r.Br(t,e).forEach(function(e){return r.Gr(t,e)})},this.Qq.dispatchEvent(l.PlayerEvent.CueEnter,i)},t.prototype.Gr=function(t,e){var i=this.dq.find(function(i){return i.subtitleId===t&&i.start===e.start&&i.end===e.end&&i.text===e.text});if(i){this.dq=this.dq.filter(function(t){return t!==i});var r={subtitleId:t,text:i.text,start:i.start,end:i.end};i.position&&(r.position=i.position),this.Qq.dispatchEvent(l.PlayerEvent.CueExit,r)}},t.prototype.Hr=function(t){for(var e=0,i=this.dq;e<i.length;e++){var r=i[e];!r.subtitleId||t&&r.subtitleId!==t||this.Gr(r.subtitleId,r)}},t.prototype.removeSubtitle=function(t){if(this.Yq.hasOwnProperty(t)){this.Yq[t].textTrack.mode!==n.Disabled&&this.disableSubtitle(t),this.Yq[t].textTrack.mode=n.Disabled;var e=this.Yq[t];delete this.Yq[t],this.Qq.dispatchEvent(l.PlayerEvent.SubtitleRemoved,{subtitle:y(e)})}},t.prototype.signalSourceChange=function(){this.Rq&&this.Rq.textTracks&&"function"==typeof this.Rq.textTracks.addEventListener&&this.Rq.textTracks.removeEventListener("addtrack",this.Jr),this.removeAll()},t.prototype.removeAll=function(){for(var t in this.bq.forEach(function(t){return(0,p.clearTimeoutIfDefined)(t)}),this.bq=[],this.Hr(),this.Yq)this.Yq.hasOwnProperty(t)&&(this.Yq[t].textTrack.mode=n.Disabled,this.Yq[t].textTrack.removeEventListener("cuechange",this.Ar));this.Yq={},this.dq=[],this.Vq=1,this.Wq=0},t.prototype.addSubtitle=function(t){if("function"!=typeof this.Rq.addTextTrack)return Promise.reject();this.Yq.hasOwnProperty(t.id)&&this.removeSubtitle(t.id);var e=t.url?v.URLHelper.toFullUrl(function(t){return"https:"===location.protocol?t.replace(m,"//"):t}(t.url.trim())):null,i={id:t.id,url:e,kind:t.kind,lang:t.lang,label:t.label,textTrack:null,isFragmented:!1,isSideloaded:!0,loadPromise:null,metadata:t.metadata};return this.Yq[t.id]=i,this.Yq[t.id].textTrack=this.Rq.addTextTrack(t.kind,t.label),this.Yq[t.id].textTrack.mode=n.Disabled,this.Yq[t.id].textTrack.addEventListener("cuechange",this.Ar),this.Ir(i)},t.prototype.Ir=function(t){var e=this;return t.url?(this.Uq=this.xr(t.id),t.loadPromise=this.Uq.load(t.url).catch(function(t){}).then(function(){if(!e.getAvailableSubtitles().find(function(e){return e.id===t.id}))throw"subtitle adding failed"})):(t.loadPromise=Promise.resolve(),this.Qq.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:y(t)})),t.loadPromise},t.prototype.Kr=function(t){for(var e,i,r=this,o=t.track,s=t.isFragmented&&o.kind===a.Subtitle||!1,u=0,d=Object.keys(this.Yq);u<d.length;u++){var c=d[u],h=this.Yq[c];if(h.textTrack===o&&h.isSideloaded)return}switch(o.kind){case a.Subtitle:e=o.id||"sub".concat(this.Wq),i=o.label||"Subtitles (".concat(this.Wq,")"),this.Wq++;break;case a.ForcedSubtitle:e=o.id||"fsub".concat(this.Wq),i=o.label||"Subtitles (".concat(this.Wq,")) (Forced)"),this.Wq++;break;case a.Caption:e="CC".concat(this.Vq),i=o.label||"Captions (CC ".concat(this.Vq,")"),this.Vq++;break;default:return void this.Lr(o)}this.Yq[e]={id:e,url:null,kind:o.kind,lang:o.language||"unknown",label:i,textTrack:o,isFragmented:s,isSideloaded:!1,loadPromise:Promise.resolve()},(i=this.Nr(this.Yq[e]))&&"string"==typeof i&&(this.Yq[e].label=i),this.cq.push(o),o.addEventListener("cuechange",this.Ar),o.kind!==a.ForcedSubtitle&&this.pr&&this.Qq.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:y(this.Yq[e])}),o.mode=n.Disabled;var f=window.setTimeout(function(){r.cq=r.cq.filter(function(t){return t!==o}),Object.keys(r.Yq).map(function(t){return r.Yq[t]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)&&t.textTrack.mode===n.Disabled}).forEach(function(t){r.qr?t.textTrack.mode=n.Showing:t.textTrack.mode=n.Hidden})},0);this.bq.push(f),this.Mr()&&this.Tr()},t.prototype.Lr=function(t){this.Pq.settings.HLS_PARSE_NATIVE_METADATA&&(this.Xq.push(t),t.mode=n.Hidden,t.addEventListener("cuechange",this.yr))},t.prototype.Mr=function(){var t=Object.keys(this.Yq).length;return this.Rq.textTracks.length===t},t.prototype.Nr=function(t){var e={kind:t.kind,id:t.id,label:t.label,lang:t.lang};return this.Or()(e)},t.prototype.Or=function(){var t=this.Pq.sourceContext,e=t&&t.source&&t.source.labeling;return e&&e[this.type]&&e[this.type].subtitles?"function"!=typeof e[this.type].subtitles?this.Pr:e[this.type].subtitles:this.Pr},t.prototype.Qr=function(t){var e;return(null===(e=Object.values(this.Yq).find(function(e){return e.textTrack===t}))||void 0===e?void 0:e.id)||null},t.prototype.Rr=function(){for(var t=0,e=this.Rq.textTracks;t<e.length;t++){var i=e[t];if((i.mode===n.Showing||i.mode===n.Hidden)&&i.kind!==a.Metadata&&i.kind!==a.ForcedSubtitle)return[i,this.Qr(i)]}return[void 0,void 0]},t.prototype.enableNative=function(){var t=this;Object.keys(this.Yq).map(function(e){return t.Yq[e]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)}).forEach(function(t){return t.textTrack.mode=n.Showing}),this.aq=!0},t.prototype.disableNative=function(){var t=this;Object.keys(this.Yq).map(function(e){return t.Yq[e]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)}).forEach(function(t){return t.textTrack.mode=n.Hidden}),this.aq=!1},t.prototype.seek=function(){var t=this;Object.keys(this.Yq).map(function(e){return t.Yq[e]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)}).forEach(function(t){var e=t.textTrack.mode;t.textTrack.mode=n.Disabled,t.textTrack.mode=e})},t.prototype.Sr=function(){var t,e,i,r=this.Rq.audioTracks,n=b.ModuleManager.get(q.ModuleName.Subtitles).LanguageComparer.isEqualIsoLanguage;if(this.Sq)i=null===(t=this.Yq[this.Sq])||void 0===t?void 0:t.lang;else{if(!r)return;var o=h.ArrayHelper.toArray(r).find(function(t){return t.enabled});i=null==o?void 0:o.language}i=null!==(e=null!=i?i:navigator.language)&&void 0!==e?e:navigator.userLanguage;var s=Object.values(this.Yq).filter(function(t){return t.kind===a.ForcedSubtitle}),u=s.find(function(t){return n(t.lang,i)});return null!=u?u:s[0]},t.prototype.Vr=function(t){var e=this,i=Object.keys(this.Yq).some(function(i){return i===t&&e.Yq[i].enabled});return t&&!this.qr&&!i},t.prototype.Xr=function(){var t=this,e=function(t){var e=r({},t);return delete e.loadPromise,delete e.textTrack,r({},e)};this.Yr().forEach(function(i){t.disableSubtitle(i.id),t.Qq.dispatchEvent(l.PlayerEvent.SubtitleDisabled,{subtitle:e(i)})}),this.Zr().forEach(function(i){t.Qq.dispatchEvent(l.PlayerEvent.SubtitleEnabled,{subtitle:e(i)})})},t.prototype.Yr=function(){var t=this.Rq.textTracks;return Object.values(this.Yq).filter(function(t){return t.enabled}).filter(function(e){var i=k(t,e);return i&&i.mode===n.Disabled})},t.prototype.Zr=function(){var t=this.Rq.textTracks;return Object.values(this.Yq).filter(function(t){return!t.enabled}).filter(function(e){var i=k(t,e);return i&&i.mode!==n.Disabled})},t.prototype.dispose=function(){var t;this.removeAll(),this.Qq.off(l.PlayerEvent.SourceLoaded,this.rr),this.Qq=null,this.dq=null,this.Yq=null,this.Xq=null,null===(t=this.Rq.audioTracks)||void 0===t||t.removeEventListener("change",this.Ur),this.Rq&&this.Rq.textTracks&&"function"==typeof this.Rq.textTracks.addEventListener&&(this.Rq.textTracks.removeEventListener("addtrack",this.Jr),this.Rq.textTracks.removeEventListener("change",this.Wr)),this.Uq&&this.Uq.dispose(),this.Uq=null},t}();function k(t,e){for(var i=0,r=t;i<r.length;i++){var n=r[i];if(n===e.textTrack)return n}}e.TextTrackController=g},52364:function(t,e){var i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,i=1,r=arguments.length;i<r;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},i.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.TextTrackCueHelper=e.CEA_608_MAX_LINE_LENGTH=void 0,e.CEA_608_MAX_LINE_LENGTH=32;var r=function(){function t(){}return t.cueListToArray=function(t){for(var e=[],i=0;i<t.length;i++)e.push(t[i]);return e},t.sortEqualStartTimeByLineFn=function(t,e){if("line"in t&&"line"in e&&t.startTime===e.startTime){if(t.line<e.line)return-1;if(t.line>e.line)return 1}return 0},t.sortByStartTimeFn=function(t,e){return t.startTime<e.startTime?-1:t.startTime>e.startTime?1:0},t.sort=function(e){return e.sort(t.sortByStartTimeFn),e.sort(t.sortEqualStartTimeByLineFn),e},t.getTagIndexRanges=function(t){for(var e,i=RegExp("<[^>]*>","g"),r=[];e=i.exec(t);){var n=e[0];r.push({start:e.index,end:e.index+n.length-1})}return r},t.splitCea608Cue=function(i){for(var r=e.CEA_608_MAX_LINE_LENGTH-i.position.column,n=i.text,a=t.getTagIndexRanges(n),o=[],s=0,u=0,l=!1,d=0,c=0;c<n.length;){if(c===n.length-1){o.push(n.substring(s));break}if(a.length>0&&c===a[0].start&&(l=!0),l);else if(u++," "===n[c]&&(d=c),u>=r&&d>s){c=d+1;var h=n.substring(s,c);h&&o.push(h),s=c,u=1}l&&a.length>0&&c===a[0].end&&(l=!1,a.shift()),c++}var f=t.createCueEvents(o,i);return t.adjustCea608CaptionPositioning(f),f},t.createCueEvents=function(t,e){var r=t.length-1;return t.map(function(t){var n=i({},e);return n.text=t,n.position={column:n.position.column,row:n.position.row-r},r--,n})},t.adjustCea608CaptionPositioning=function(t){var e=Math.max.apply(Math,t.map(function(t){return t.position.row})),i=Math.min.apply(Math,t.map(function(t){return t.position.row}));if(e>14){var r=14-e;t.forEach(function(t){return t.position.row+=r})}if(i<0){var n=0-i;t.forEach(function(t){return t.position.row+=n})}},t}();e.TextTrackCueHelper=r}},function(t){return function(){return t(91444)}()}])});
17
+ "use strict";!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["subtitles-native"]=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player["subtitles-native"]=e())}(self,function(){return(self.webpackChunkbitmovin_player=self.webpackChunkbitmovin_player||[]).push([[826],{91444:function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.NativeSubtitlesModuleDefinition=void 0;var n=i(62756),r=i(43931);e.NativeSubtitlesModuleDefinition={name:n.ModuleName.SubtitlesNative,module:function(){return{TextTrackController:r.TextTrackController}},dependencies:[n.ModuleName.Subtitles]},e.default=e.NativeSubtitlesModuleDefinition},43931:function(t,e,i){var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},n.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.TextTrackController=void 0;var r,u,a,o=i(25926),s=i(4224),l=i(3714),d=i(4129),c=i(29669),h=i(74853),v=i(15487),f=i(88844),p=i(58313),b=i(88052),m=i(62756),T=i(52364);!function(t){t.Showing="showing",t.Hidden="hidden",t.Disabled="disabled"}(r||(r={})),function(t){t.Subtitle="subtitles",t.ForcedSubtitle="forced",t.Caption="captions",t.Metadata="metadata"}(u||(u={})),function(t){t.ID3="org.id3",t.DATERANGE="com.apple.quicktime.HLS",t.EMSG="https://aomedia.org/emsg/ID3"}(a||(a={}));var y=new RegExp("^(?:[a-z]+:)?//","i"),g=function(t){var e={id:t.id,lang:t.lang,label:t.label,kind:t.kind,isFragmented:t.isFragmented,isSideloaded:t.isSideloaded,enabled:t.textTrack&&t.textTrack.mode!==r.Disabled,forced:t.kind===u.ForcedSubtitle};return t.url&&(e.url=t.url),t.metadata&&(e.metadata=t.metadata),e},k=function(){function t(t,e,i,u){var o=this;this.Du=function(){o.Bu=!0,o.Eu()},this.Ku=function(t){var e=t.currentTarget.activeCues,i={frames:[]};for(var r in e)if(e[r].type===a.ID3&&void 0!==e[r].value){var u=e[r].value;h.ArrayHelper.isArrayBuffer(u.data)&&((u=n({},u)).data=h.ArrayHelper.getArray(new Uint8Array(u.data))),i[u.key]=u.data,i.frames.push(u),o.Au&&o.Lu(e[r],t.currentTarget)}i.frames.length&&o.mu.dispatchEvent(l.PlayerEvent.Metadata,{metadataType:l.MetadataType.ID3,metadata:i})},this.Mu=function(t){var e=t.target;if(e.activeCues&&e.activeCues.length>0){var i=T.TextTrackCueHelper.cueListToArray(e.activeCues),n=o.mv(e);T.TextTrackCueHelper.sort(i).forEach(function(t){return o.Ou(n,t)})}},this.fv=function(t){var e=window.setTimeout(function(){return o.gv(t)},0);o.xu.push(e)},this.lv=function(){return null},this.pv=function(){var t;o.ou?o.pu&&o.disableSubtitle(o.pu):(o.pu=null===(t=o.ov())||void 0===t?void 0:t.id,o.pu&&o.enableSubtitle(o.pu,!0))},this.qv=function(){o.disableSubtitle(o.pu),o.pv()},this.sv=function(){var t=o.nv(),e=t[0],i=t[1];if(o.rv(i))return o.disableSubtitle(i),void o.pv();i||(o.ou=void 0),o.pv(),o.Cu&&o.tv(),i&&e&&e.mode!==r.Hidden&&!o.yu.includes(e)&&o.enableSubtitle(i)},this.lu=t,this.mu=t.eventHandler,this.nu=e,this.type=u,this.tu=[],this.uu={},this.ru=1,this.su=0,this.wu=!1,this.xu=[],this.yu=[],this.zu=[],this.qu=null,this.Au=(0,v.isSafariPlatform18orNewer)(),this.Bu=!1,i.hasOwnProperty("style")&&i.style.hasOwnProperty("nativeSubtitles")?this.vu=!!i.style.nativeSubtitles:this.vu=!1,e.audioTracks&&e.audioTracks.addEventListener("change",this.qv),e.textTracks&&"function"==typeof e.textTracks.addEventListener&&(e.textTracks.addEventListener("addtrack",this.fv),e.textTracks.addEventListener("change",this.sv)),this.mu.one(l.PlayerEvent.SourceLoaded,this.Du,!0)}return Object.defineProperty(t.prototype,"Cu",{get:function(){return this.wu||this.vu},enumerable:!1,configurable:!0}),t.prototype.getAvailableSubtitles=function(){return Object.values(this.uu||{}).filter(function(t){return t.kind!==u.ForcedSubtitle}).map(g)},t.prototype.Eu=function(){var t=this;this.getAvailableSubtitles().filter(function(t){return!t.isSideloaded}).forEach(function(e){return t.mu.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:e})})},t.prototype.enableSubtitle=function(t,e){void 0===e&&(e=!1);var i=this.uu[t];return i?(e||(this.ou=t),i.textTrack&&(this.vu||this.wu?i.textTrack.mode=r.Showing:i.textTrack.mode=r.Hidden),i.enabled?Promise.resolve(!1):(i.enabled=!0,i.textTrack?i.loadPromise.then(function(){return!0},function(){return!1}):Promise.resolve(!0))):Promise.resolve(!1)},t.prototype.disableSubtitle=function(t){var e=this.uu[t];return!!e&&(e.textTrack&&(e.textTrack.mode=r.Disabled),e.enabled=!1,this.dv(t),!0)},t.prototype.Fu=function(t){var e,i;return window.VTTCue?new window.VTTCue(t.start,t.end,null!==(e=t.html)&&void 0!==e?e:t.text):window.TextTrackCue?new TextTrackCue(t.start,t.end,null!==(i=t.html)&&void 0!==i?i:t.text):void 0},t.prototype.Gu=function(t,e){var i;if((null===(i=this.uu)||void 0===i?void 0:i[e])&&t){for(var r=b.ModuleManager.get(m.ModuleName.Subtitles).SubtitleParserFactory.createInstance(this.lu,t).parse(t),u=0;u<r.length;u++)this.mu.dispatchEvent(l.PlayerEvent.CueParsed,n(n({subtitleId:e},r[u]),{periodId:null})),this.uu[e].textTrack.addCue(this.Fu(r[u]));this.mu.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:g(this.uu[e])})}},t.prototype.Hu=function(t,e){var i=e.body;i&&this.Gu(i.trim(),t)},t.prototype.Iu=function(t,e,i){this.removeSubtitle(t),this.mu.dispatchEvent(l.PlayerEvent.Warning,new o.PlayerWarning(s.WarningCode.NETWORK_COULD_NOT_LOAD_SUBTITLE))},t.prototype.Ju=function(t){var e=this;return new d.DefaultContentLoader(this.lu,{maxRetries:this.lu.settings.MAX_RETRIES,retryDelay:this.lu.settings.RETRY_DELAY,onSuccess:function(i){return e.Hu(t,i)},onFailure:function(i,n){return e.Iu(t,i,n)},requestType:c.HttpRequestType.MEDIA_SUBTITLES})},t.prototype.Lu=function(t,e){try{e.removeCue(t)}catch(t){t.name}},t.prototype.Nu=function(t,e){var i=b.ModuleManager.get(m.ModuleName.Subtitles).HtmlTransformer,n=i.htmlToText,r=i.stripHtmlTags,u=(b.ModuleManager.get(m.ModuleName.SubtitlesWebVTT,!1)||{}).extractVttProperties,a={subtitleId:t,text:n(e.text),start:e.startTime,end:e.endTime},o=[a];if("subtitles"===e.track.kind)a.html=function(t){var e=(0,b.ModuleManager.get(m.ModuleName.Subtitles).HtmlTransformer.prepareHtml)(t);return e.startsWith("<span>")?e:"<span>".concat(e,"</span>")}(e.text),window.VTTCue&&(e instanceof VTTCue&&u?a.vtt=u(e):VTTCue);else if("captions"===e.track.kind){a.position=function(t){var e=80/15,i=t.line-10,n=t.position-10;return i-=i%e,n-=n%2.5,{row:i=Math.round(i/e),column:n=Math.round(n/2.5)}}(e);var s=r(a.text);a.position.column+s.length>T.CEA_608_MAX_LINE_LENGTH-1&&(o=T.TextTrackCueHelper.splitCea608Cue(a))}return o},t.prototype.Ou=function(t,e){var i=this;if(e){var n=Object.values(this.uu).find(function(t){return t.textTrack===e.track});if(function(t,e,i){if(i){var n=b.ModuleManager.get(m.ModuleName.Subtitles).HtmlTransformer,r=n.stripAwayHtmlBreakPoints,u=n.replaceHtmlBreakPointsWithNewLine;t&&i.isSideloaded&&(e.text=u(e.text)),t||i.isSideloaded||(e.text=r(e.text))}}(this.vu||this.wu,e,n),!this.vu&&!this.wu){var r=this.Nu(t,e);r.forEach(function(n){i.Qu(n)?i.mu.dispatchEvent(l.PlayerEvent.CueUpdate,n):i.Ru(t,e,n)}),this.Pu(t,r)}}},t.prototype.Pu=function(t,e){var i=this,n=this.zu.filter(function(i){return!e.find(function(t){return i.start===t.start&&i.text===t.text&&i.subtitleId===t.subtitleId})&&i.end===1/0&&i.subtitleId===t});n.length>0&&n.forEach(function(e){i.cv(t,e)})},t.prototype.Qu=function(t){var e=this,i=this.zu.find(function(i){var n=i.start===t.start,r=i.text===t.text,u=!t.end||i.end===1/0||i.end===e.nu.duration||i.end===t.end;return n&&r&&u});return!!i&&(i.end=t.end,!0)},t.prototype.Ru=function(t,e,i){var n=this;this.zu.push(i),e.onexit=function(){n.Nu(t,e).forEach(function(e){return n.cv(t,e)})},this.mu.dispatchEvent(l.PlayerEvent.CueEnter,i)},t.prototype.cv=function(t,e){var i=this.zu.find(function(i){return i.subtitleId===t&&i.start===e.start&&i.end===e.end&&i.text===e.text});if(i){this.zu=this.zu.filter(function(t){return t!==i});var n={subtitleId:t,text:i.text,start:i.start,end:i.end};i.position&&(n.position=i.position),this.mu.dispatchEvent(l.PlayerEvent.CueExit,n)}},t.prototype.dv=function(t){for(var e=0,i=this.zu;e<i.length;e++){var n=i[e];!n.subtitleId||t&&n.subtitleId!==t||this.cv(n.subtitleId,n)}},t.prototype.removeSubtitle=function(t){if(this.uu.hasOwnProperty(t)){this.uu[t].textTrack.mode!==r.Disabled&&this.disableSubtitle(t),this.uu[t].textTrack.mode=r.Disabled;var e=this.uu[t];delete this.uu[t],this.mu.dispatchEvent(l.PlayerEvent.SubtitleRemoved,{subtitle:g(e)})}},t.prototype.signalSourceChange=function(){this.nu&&this.nu.textTracks&&"function"==typeof this.nu.textTracks.addEventListener&&this.nu.textTracks.removeEventListener("addtrack",this.fv),this.removeAll()},t.prototype.removeAll=function(){for(var t in this.xu.forEach(function(t){return(0,f.clearTimeoutIfDefined)(t)}),this.xu=[],this.dv(),this.uu)this.uu.hasOwnProperty(t)&&(this.uu[t].textTrack.mode=r.Disabled,this.uu[t].textTrack.removeEventListener("cuechange",this.Mu));this.uu={},this.zu=[],this.ru=1,this.su=0},t.prototype.addSubtitle=function(t){if("function"!=typeof this.nu.addTextTrack)return Promise.reject();this.uu.hasOwnProperty(t.id)&&this.removeSubtitle(t.id);var e=t.url?p.URLHelper.toFullUrl(function(t){return"https:"===location.protocol?t.replace(y,"//"):t}(t.url.trim())):null,i={id:t.id,url:e,kind:t.kind,lang:t.lang,label:t.label,textTrack:null,isFragmented:!1,isSideloaded:!0,loadPromise:null,metadata:t.metadata};return this.uu[t.id]=i,this.uu[t.id].textTrack=this.nu.addTextTrack(t.kind,t.label),this.uu[t.id].textTrack.mode=r.Disabled,this.uu[t.id].textTrack.addEventListener("cuechange",this.Mu),this.ev(i)},t.prototype.ev=function(t){var e=this;return t.url?(this.qu=this.Ju(t.id),t.loadPromise=this.qu.load(t.url).catch(function(t){}).then(function(){if(!e.getAvailableSubtitles().find(function(e){return e.id===t.id}))throw"subtitle adding failed"})):(t.loadPromise=Promise.resolve(),this.mu.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:g(t)})),t.loadPromise},t.prototype.gv=function(t){for(var e,i,n=this,a=t.track,o=t.isFragmented&&a.kind===u.Subtitle||!1,s=0,d=Object.keys(this.uu);s<d.length;s++){var c=d[s],h=this.uu[c];if(h.textTrack===a&&h.isSideloaded)return}switch(a.kind){case u.Subtitle:e=a.id||"sub".concat(this.su),i=a.label||"Subtitles (".concat(this.su,")"),this.su++;break;case u.ForcedSubtitle:e=a.id||"fsub".concat(this.su),i=a.label||"Subtitles (".concat(this.su,")) (Forced)"),this.su++;break;case u.Caption:e="CC".concat(this.ru),i=a.label||"Captions (CC ".concat(this.ru,")"),this.ru++;break;default:return void this.hv(a)}this.uu[e]={id:e,url:null,kind:a.kind,lang:a.language||"unknown",label:i,textTrack:a,isFragmented:o,isSideloaded:!1,loadPromise:Promise.resolve()},(i=this.jv(this.uu[e]))&&"string"==typeof i&&(this.uu[e].label=i),this.yu.push(a),a.addEventListener("cuechange",this.Mu),a.kind!==u.ForcedSubtitle&&this.Bu&&this.mu.dispatchEvent(l.PlayerEvent.SubtitleAdded,{subtitle:g(this.uu[e])}),a.mode=r.Disabled;var v=window.setTimeout(function(){n.yu=n.yu.filter(function(t){return t!==a}),Object.keys(n.uu).map(function(t){return n.uu[t]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)&&t.textTrack.mode===r.Disabled}).forEach(function(t){n.Cu?t.textTrack.mode=r.Showing:t.textTrack.mode=r.Hidden})},0);this.xu.push(v),this.iv()&&this.pv()},t.prototype.hv=function(t){this.lu.settings.HLS_PARSE_NATIVE_METADATA&&(this.tu.push(t),t.mode=r.Hidden,t.addEventListener("cuechange",this.Ku))},t.prototype.iv=function(){var t=Object.keys(this.uu).length;return this.nu.textTracks.length===t},t.prototype.jv=function(t){var e={kind:t.kind,id:t.id,label:t.label,lang:t.lang};return this.kv()(e)},t.prototype.kv=function(){var t=this.lu.sourceContext,e=t&&t.source&&t.source.labeling;return e&&e[this.type]&&e[this.type].subtitles?"function"!=typeof e[this.type].subtitles?this.lv:e[this.type].subtitles:this.lv},t.prototype.mv=function(t){var e;return(null===(e=Object.values(this.uu).find(function(e){return e.textTrack===t}))||void 0===e?void 0:e.id)||null},t.prototype.nv=function(){for(var t=0,e=this.nu.textTracks;t<e.length;t++){var i=e[t];if((i.mode===r.Showing||i.mode===r.Hidden)&&i.kind!==u.Metadata&&i.kind!==u.ForcedSubtitle)return[i,this.mv(i)]}return[void 0,void 0]},t.prototype.enableNative=function(){var t=this;Object.keys(this.uu).map(function(e){return t.uu[e]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)}).forEach(function(t){return t.textTrack.mode=r.Showing}),this.wu=!0},t.prototype.disableNative=function(){var t=this;Object.keys(this.uu).map(function(e){return t.uu[e]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)}).forEach(function(t){return t.textTrack.mode=r.Hidden}),this.wu=!1},t.prototype.seek=function(){var t=this;Object.keys(this.uu).map(function(e){return t.uu[e]}).filter(function(t){return t.enabled&&Boolean(t.textTrack)}).forEach(function(t){var e=t.textTrack.mode;t.textTrack.mode=r.Disabled,t.textTrack.mode=e})},t.prototype.ov=function(){var t,e,i,n=this.nu.audioTracks,r=b.ModuleManager.get(m.ModuleName.Subtitles).LanguageComparer.isEqualIsoLanguage;if(this.ou)i=null===(t=this.uu[this.ou])||void 0===t?void 0:t.lang;else{if(!n)return;var a=h.ArrayHelper.toArray(n).find(function(t){return t.enabled});i=null==a?void 0:a.language}i=null!==(e=null!=i?i:navigator.language)&&void 0!==e?e:navigator.userLanguage;var o=Object.values(this.uu).filter(function(t){return t.kind===u.ForcedSubtitle}),s=o.find(function(t){return r(t.lang,i)});return null!=s?s:o[0]},t.prototype.rv=function(t){var e=this,i=Object.keys(this.uu).some(function(i){return i===t&&e.uu[i].enabled});return t&&!this.Cu&&!i},t.prototype.tv=function(){var t=this,e=function(t){var e=n({},t);return delete e.loadPromise,delete e.textTrack,n({},e)};this.uv().forEach(function(i){t.disableSubtitle(i.id),t.mu.dispatchEvent(l.PlayerEvent.SubtitleDisabled,{subtitle:e(i)})}),this.vv().forEach(function(i){t.mu.dispatchEvent(l.PlayerEvent.SubtitleEnabled,{subtitle:e(i)})})},t.prototype.uv=function(){var t=this.nu.textTracks;return Object.values(this.uu).filter(function(t){return t.enabled}).filter(function(e){var i=x(t,e);return i&&i.mode===r.Disabled})},t.prototype.vv=function(){var t=this.nu.textTracks;return Object.values(this.uu).filter(function(t){return!t.enabled}).filter(function(e){var i=x(t,e);return i&&i.mode!==r.Disabled})},t.prototype.dispose=function(){var t;this.removeAll(),this.mu.off(l.PlayerEvent.SourceLoaded,this.Du),this.mu=null,this.zu=null,this.uu=null,this.tu=null,null===(t=this.nu.audioTracks)||void 0===t||t.removeEventListener("change",this.qv),this.nu&&this.nu.textTracks&&"function"==typeof this.nu.textTracks.addEventListener&&(this.nu.textTracks.removeEventListener("addtrack",this.fv),this.nu.textTracks.removeEventListener("change",this.sv)),this.qu&&this.qu.dispose(),this.qu=null},t}();function x(t,e){for(var i=0,n=t;i<n.length;i++){var r=n[i];if(r===e.textTrack)return r}}e.TextTrackController=k},52364:function(t,e){var i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},i.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.TextTrackCueHelper=e.CEA_608_MAX_LINE_LENGTH=void 0,e.CEA_608_MAX_LINE_LENGTH=32;var n=function(){function t(){}return t.cueListToArray=function(t){for(var e=[],i=0;i<t.length;i++)e.push(t[i]);return e},t.sortEqualStartTimeByLineFn=function(t,e){if("line"in t&&"line"in e&&t.startTime===e.startTime){if(t.line<e.line)return-1;if(t.line>e.line)return 1}return 0},t.sortByStartTimeFn=function(t,e){return t.startTime<e.startTime?-1:t.startTime>e.startTime?1:0},t.sort=function(e){return e.sort(t.sortByStartTimeFn),e.sort(t.sortEqualStartTimeByLineFn),e},t.getTagIndexRanges=function(t){for(var e,i=RegExp("<[^>]*>","g"),n=[];e=i.exec(t);){var r=e[0];n.push({start:e.index,end:e.index+r.length-1})}return n},t.splitCea608Cue=function(i){for(var n=e.CEA_608_MAX_LINE_LENGTH-i.position.column,r=i.text,u=t.getTagIndexRanges(r),a=[],o=0,s=0,l=!1,d=0,c=0;c<r.length;){if(c===r.length-1){a.push(r.substring(o));break}if(u.length>0&&c===u[0].start&&(l=!0),l);else if(s++," "===r[c]&&(d=c),s>=n&&d>o){c=d+1;var h=r.substring(o,c);h&&a.push(h),o=c,s=1}l&&u.length>0&&c===u[0].end&&(l=!1,u.shift()),c++}var v=t.createCueEvents(a,i);return t.adjustCea608CaptionPositioning(v),v},t.createCueEvents=function(t,e){var n=t.length-1;return t.map(function(t){var r=i({},e);return r.text=t,r.position={column:r.position.column,row:r.position.row-n},n--,r})},t.adjustCea608CaptionPositioning=function(t){var e=Math.max.apply(Math,t.map(function(t){return t.position.row})),i=Math.min.apply(Math,t.map(function(t){return t.position.row}));if(e>14){var n=14-e;t.forEach(function(t){return t.position.row+=n})}if(i<0){var r=0-i;t.forEach(function(t){return t.position.row+=r})}},t}();e.TextTrackCueHelper=n}},function(t){return function(){return t(91444)}()}])});
18
18
  })();
@@ -9,10 +9,10 @@
9
9
  * This software includes open-source components. See THIRD_PARTY_NOTICES
10
10
  * in the distribution for details.
11
11
  *
12
- * Bitmovin Player Version 8.280.0
12
+ * Bitmovin Player Version 8.281.0
13
13
  *
14
14
  ****************************************************************************/
15
15
 
16
16
  (function() {
17
- "use strict";!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["subtitles-ttml"]=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player["subtitles-ttml"]=e())}(self,function(){return(self.webpackChunkbitmovin_player=self.webpackChunkbitmovin_player||[]).push([[840],{90942:function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.TTMLSubtitlesModuleDefinition=void 0;var r=n(62756),i=n(95021);e.TTMLSubtitlesModuleDefinition={name:r.ModuleName.SubtitlesTTML,module:function(){return{TTMLParser:i.TTMLParser}},dependencies:[r.ModuleName.Subtitles]},e.default=e.TTMLSubtitlesModuleDefinition},95021:function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.TTMLParser=void 0;var r=n(76444),i=n(31207),o=function(){function t(t){this.Yt=t}return t.prototype.parse=function(t,e){var n=this;void 0===e&&(e=0);var o=/xmlns:(\S+)="http:\/\/www.w3.org\/ns\/ttml"/.exec(t),a=null!=o?t.replace(new RegExp("(<[/]?)(".concat(o[1],":)([\\s\\S]+?>)"),"g"),"$1$3"):t,u=(new DOMParser).parseFromString(a,"application/xml"),l=(0,r.getFirstElementByTagName)(u,"tt"),s=(0,r.getFirstElementByTagName)(l,"body");if(!l||!s)return[];e&&!isNaN(e)||(e=0);var c=(0,r.extractImages)(l),f=(0,i.getStylingInfo)(l),p=(0,r.getLayoutInfo)(l),g=(0,i.parseBodyStyle)(s,f);return(0,r.splitUpTimedElements)(s).map(function(t){return(0,i.applyStyling)(t,f,c,t.element),(0,r.redistributeLineBreaks)(t.element),(0,i.applyBodyStyle)(t,g),(0,r.getSubtitleCue)({timedElement:t,layouts:p,baseOffset:e,styles:f},n.Yt.logger)})},t}();e.TTMLParser=o},32148:function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.parseAttributes=function(t){var e=new Map;return(0,i.iterableToArray)(t.attributes).forEach(function(t){return e.set(o(t),t.value)}),e},e.getQualifiedAttributeName=function(t,e){var n=(0,i.iterableToArray)(t).find(function(t){return function(t){return null!=t.localName?t.localName:null!=t.name?o(t):""}(t)===e});return n?n.name:""},e.processAttribute=function(t,e,n,i){var o=n.includes("-")?(0,r.kebabCaseToCamelCase)(n):n,a=t.get(o);if(void 0!==a){var u=i(a);!u||"string"==typeof u&&""===u||e.set(n,u)}};var r=n(20649),i=n(76444);function o(t){var e=t.name;return e.includes(":")?e.split(":")[1]:e}},76444:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)},i=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.LayoutStyleProperties=e.LayoutInfoEntryKeys=void 0,e.iterableToArray=p,e.redistributeLineBreaks=function t(e){var n=p(e.children),r=n.filter(function(t){return"br"===t.tagName}),i=n.filter(function(t){return"span"===t.tagName});if(r.length>0&&i.length>0){var o=0;for(r.forEach(function(t){var e;return null===(e=t.parentElement)||void 0===e?void 0:e.removeChild(t)});r.length>0;){var a=r.shift();if(a&&(i[o].nextSibling?e.insertBefore(a,i[o].nextSibling):e.appendChild(a)),++o>=i.length)break}r.forEach(function(t){return e.appendChild(t)})}n.forEach(t)},e.getSubtitleCue=function(t,e){var n,r,i=t.timedElement,a=t.layouts,s=t.baseOffset,f=t.styles,p=i.end?m(i.end):NaN,v=i.dur?m(i.dur):NaN,y=i.begin?m(i.begin):NaN,T=b(i.element),h=function(t,e,n){var r=Boolean(t)&&n.has(t),i=n.get(t),a=(r&&i instanceof Map?function(t){var e=t.get(o.StyleIds);return Array.isArray(e)?e:[]}(i):[]).map(function(t){return(0,c.getCSSFromStyleID)(t,e)}).join("");return a+(i&&i instanceof Map?d(i):"")+(r&&i instanceof Map?g(i):"")}(T,f,a),S=y+s,A=isFinite(p)?p+s:S+v,E=u.ModuleManager.get(l.ModuleName.Subtitles).HtmlTransformer.htmlToText,L=(T?function(t){var e;return t.innerHTML?t.innerHTML:t.parentNode&&null!==(e=t.parentNode.innerHTML)&&void 0!==e?e:""}(i.element):function(t){var e;return null!==(e=t.outerHTML)&&void 0!==e?e:""}(i.element)).replace(/<br><\/br>/g,"<br>").replace(/[\r\n]+\s*/g,""),M={start:S,end:A,text:L?E(L):null!==(r=null===(n=i.element.textContent)||void 0===n?void 0:n.trim())&&void 0!==r?r:"",region:T,regionStyle:h,html:L};return i.backgroundImageSource&&(M.image=i.backgroundImageSource),(p<0||y<0||v<0)&&e.debug("could not parse time string for TTML subtitle cue"),M},e.extractLayoutStylesCss=g,e.extractLayoutPositionStylesCss=d,e.extractImages=function(t){var e=h(t,"head"),n=h(e,"metadata");return n?p(n.getElementsByTagNameNS("*","image")).filter(function(t){var e;return t.hasAttribute("xml:id")&&(null===(e=t.prefix)||void 0===e?void 0:e.includes("smpte"))}).map(function(t){var e,n,r,i;return{mimeType:null!==(n=null===(e=t.getAttribute("imagetype"))||void 0===e?void 0:e.toLowerCase())&&void 0!==n?n:"png",id:"#"+t.getAttribute("xml:id"),base64:null!==(i=null===(r=t.textContent)||void 0===r?void 0:r.trim())&&void 0!==i?i:""}}):[]},e.getLayoutInfo=function(t){var e=new Map;if(!t)return e;var n=(0,s.parseAttributes)(t),u=r({},f),l=h(t,"head"),g=h(l,"layout"),d=g?p(g.getElementsByTagName("region")):[];if(!d||0===d.length)return e.set("cellResolutionRows",u.rows),e.set("cellResolutionColumns",u.columns),e;var m=n.get("cellResolution");if(m){var b=m.split(" "),y=parseInt(b[0],10),T=parseInt(b[1],10);isFinite(y)&&y>0&&(u.columns=y),isFinite(T)&&T>0&&(u.rows=T)}var S=h(l,"styling"),A=S?p(S.getElementsByTagName("style")):[];return d.forEach(function(t){var n=t.getAttribute("xml:id")||t.getAttribute("id");n&&e.set(n,function(t,e,n){var r=new Map,u=(0,s.parseAttributes)(t);if(r.set(o.CellResolutionRows,e.rows),r.set(o.CellResolutionColumns,e.columns),u.has("style")){var l=u.get("style"),f=l?l.split(" "):[];r.set(o.StyleIds,f),function(t,e){var n=t.get(o.StyleIds);function r(e,n){if((e.getAttribute("xml:id")||e.getAttribute("id"))===n){v(e.getAttribute("tts:origin"),e.getAttribute("tts:extent"),t);var r=(0,s.parseAttributes)(e);Object.values(a).forEach(function(e){(0,s.processAttribute)(r,t,e,function(t){return t})})}}n&&(Array.isArray(n)?n.forEach(function(t){e.forEach(function(e){return r(e,t)})}):e.forEach(function(t){return r(t,n)}))}(r,n)}return function(t,e,n){var r=t.getElementsByTagName("style");r.length&&(p(r).forEach(function(t){(0,s.parseAttributes)(t).forEach(function(t,e){n.set(e,t)})}),i(i([],c.COLOR_STYLE_ATTRIBUTES,!0),c.BASE_STYLE_ATTRIBUTES,!0).forEach(function(t){(0,s.processAttribute)(n,e,t,function(t){return t})}))}(t,r,u),v(u.get("origin"),u.get("extent"),r),Object.values(a).forEach(function(t){(0,s.processAttribute)(u,r,t,function(t){return t})}),r}(t,u,A))}),e},e.splitUpTimedElements=function(t){if(!t||t.children.length<1)return[];var e=u.ModuleManager.get(l.ModuleName.Subtitles).createHtmlElement;return y(t).map(function(n){var r=e("div"),i=(0,s.parseAttributes)(n),o=function(t,e){for(var n=[],r=t,i=function(t){return t.parentElement||t.parentNode};r&&i(r)&&i(r)!==e;)n.unshift(i(r)),r=i(r);return n}(n,t).reduce(function(t,e){return t.appendChild(e.cloneNode(!1))},r);return r.children[0]&&T(r.children[0]),o.appendChild(n),{end:i.get("end"),dur:i.get("dur"),begin:i.get("begin"),element:r.children[0]}})},e.getFirstElementByTagName=h;var o,a,u=n(88052),l=n(62756),s=n(32148),c=n(31207);!function(t){t.CellResolutionRows="cellResolutionRows",t.CellResolutionColumns="cellResolutionColumns",t.Top="top",t.Left="left",t.Width="width",t.Height="height",t.StyleIds="styleIDs"}(o||(e.LayoutInfoEntryKeys=o={})),function(t){t.DisplayAling="displayAlign",t.Padding="padding",t.WritingMode="writingMode",t.ShowBackground="showBackground",t.Overflow="overflow"}(a||(e.LayoutStyleProperties=a={}));var f={rows:15,columns:40};function p(t){for(var e=[],n=0;n<t.length;n++)e.push(t[n]);return e}function g(t){return i(i(i([],c.COLOR_STYLE_ATTRIBUTES,!0),c.BASE_STYLE_ATTRIBUTES,!0),Object.values(a),!0).filter(function(e){return t.has(e)}).map(function(e){var n=t.get(e),r=Array.isArray(n)?"":"".concat(n);return r?Object.values(c.TTMLSpecificAttributes).some(function(t){return t.toString()===e.toString()})?(0,c.getCssFromTtmlSpecificAttribute)(e,r):(0,c.getCssFromCommonAttribute)(e,r):""}).join("")}function d(t){return[o.Top,o.Left,o.Height,o.Width].map(function(e){return"".concat(e,":").concat(t.get(e),";")}).join("")}function m(t){var e=t.match(/^(\d+):(\d+):(\d+)((?:\.)(\d+)$)?/),n=e?function(t){var e=3600*parseInt(t[1]),n=60*parseInt(t[2]),r=parseInt(t[3]),i=0;return t[5]&&(i=.001*parseInt(t[5])),e+n+r+i}(e):function(t){var e=t.charAt(t.length-1);return"h"===e?3600*parseFloat(t.slice(0,-1)):"m"===e?60*parseFloat(t.slice(0,-1)):"s"===e?"m"===t.charAt(t.length-2)?parseFloat(t.slice(0,-2))/1e3:parseFloat(t.slice(0,-1)):NaN}(t);return isFinite(n)?n:-1}function b(t){var e=(0,s.parseAttributes)(t).get("region");if(e)return e;for(var n=t.children,r=0;r<n.length;r++){var i=b(n[r]);if(i)return i}return""}function v(t,e,n){if(t){var r=t.split(" ");n.set(o.Top,r[1]),n.set(o.Left,r[0])}if(e){var i=e.split(" ");n.set(o.Width,i[0]),n.set(o.Height,i[1])}}function y(t){var e=function(t){var e=(0,s.parseAttributes)(t);return e.has("begin")&&(e.has("end")||e.has("dur"))}(t),n=p(t.children).flatMap(y).filter(Boolean);return n.length>0?n:e?[t]:[]}function T(t){["begin","dur","end"].map(function(e){return(0,s.getQualifiedAttributeName)(t.attributes,e)}).filter(function(t){return Boolean(t)}).forEach(function(e){return t.removeAttribute(e)}),p(t.children).forEach(T)}function h(t,e){if(!t)return null;var n=t.getElementsByTagName(e);return n.length>0?n[0]:null}},31207:function(t,e,n){var r;Object.defineProperty(e,"__esModule",{value:!0}),e.TTMLSpecificAttributesToCSS=e.TTMLSpecificAttributes=e.COLOR_STYLE_ATTRIBUTES=e.BASE_STYLE_ATTRIBUTES=void 0,e.applyStyling=function t(e,n,r,i){void 0===i&&(i=e.element);var u=function(t,e){var n="",r=t.getAttribute("style");return r&&(n+=r.split(" ").map(function(t){return d(t,e)}).join(";").replace(/;;+/g,";")),n+=m(y(t))}(i,n);u.length>0&&i.setAttribute("style",u),(0,l.iterableToArray)(i.children).forEach(function(i){return t(e,n,r,i)}),function(t,e,n){var r=e.getAttribute("smpte:backgroundImage"),i=r?n.find(function(t){return t.id===r}):null;if(i){var u=o.ModuleManager.get(a.ModuleName.Subtitles).createHtmlElement("img"),l="data:image/".concat(i.mimeType,";base64,").concat(i.base64);u.setAttribute("style","width:100%"),u.setAttribute("src",l),t.backgroundImageSource=l,e.appendChild(u)}}(e,i,r)},e.getStylingInfo=function(t){var e=new Map,n=(0,l.getFirstElementByTagName)(t,"head"),r=(0,l.getFirstElementByTagName)(n,"styling");return r?((0,l.iterableToArray)(r.getElementsByTagName("style")).forEach(function(t){var n=t.getAttribute("xml:id")||t.getAttribute("id");n&&e.set(n,y(t))}),e):e},e.applyBodyStyle=function(t,e){if(e){var n=t.element.getAttribute("style");t.element.setAttribute("style",n?n+e:e)}},e.parseBodyStyle=function(t,e){var n=t.getAttribute("style"),r=y(t),i=n?d(n,e):"";return T(r).reduce(function(t,e){return"".concat(t).concat(e,":").concat(r.get(e),";")},i)},e.getCssFromCommonAttribute=function(t,e){return t===l.LayoutStyleProperties.Padding?"box-sizing:border-box;".concat(t,":").concat(e,";"):"".concat(t,":").concat(e,";")},e.getCssFromTtmlSpecificAttribute=function(t,n){var r=Object.values(i).find(function(e){return e===t});if(r){var o=e.TTMLSpecificAttributesToCSS[r],a=o.values[n];return o&&a?o.prefix+"".concat(o.cssProperty,":").concat(a,";"):""}return""},e.getCSSColorFromTTML=g,e.getCSSFromStyleID=d;var i,o=n(88052),a=n(62756),u=n(32148),l=n(76444),s=new RegExp("^#([0-9a-fA-F]{3,8})$"),c=16,f=5,p=9;function g(t){var e=0,n=0,r=0,i=1;if(s.test(t)){if(t.length===f)return e=parseInt(t.slice(1,2),c),n=parseInt(t.slice(2,3),c),r=parseInt(t.slice(3,4),c),i=parseInt(t.slice(4),c),"rgba(".concat(e,",").concat(n,",").concat(r,",").concat(i,")");if(t.length===p)return e=parseInt(t.slice(1,3),c),n=parseInt(t.slice(3,5),c),r=parseInt(t.slice(5,7),c),i=parseInt(t.slice(7),c),"rgba(".concat(e,",").concat(n,",").concat(r,",").concat(i,")")}return t}function d(t,e){var n=e.get(t);return n instanceof Map?m(n):n?"".concat(t,":").concat(n):""}function m(t){var e=T(t).filter(function(t){return["cellResolutionRows","cellResolutionColumns"].indexOf(t)<0}).map(function(e){return"".concat(e,":").concat(t.get(e))}).join(";");return""===e?e:"".concat(e,";")}function b(t){return t.replace(/(default)|(monospace(Sans)?Serif)/g,"monospace").replace(/(sansSerif)|(proportional(Sans)?Serif)/g,"sans-serif")}function v(t){return"wrap"===t?"break-word":"normal"}function y(t){var n=new Map,r=(0,u.parseAttributes)(t);return e.BASE_STYLE_ATTRIBUTES.forEach(function(t){(0,u.processAttribute)(r,n,t,function(t){return t})}),e.COLOR_STYLE_ATTRIBUTES.forEach(function(t){(0,u.processAttribute)(r,n,t,g)}),(0,u.processAttribute)(r,n,"font-family",b),(0,u.processAttribute)(r,n,"word-wrap",v),n}function T(t){var e=[];return t.forEach(function(t,n){return e.push(n)}),e}e.BASE_STYLE_ATTRIBUTES=["font-size","line-height","text-align","unicode-bidi","font-weight","direction","text-decoration","font-style","multiRowAlign","linePadding"],e.COLOR_STYLE_ATTRIBUTES=["color","background-color"],function(t){t.DISPLAY_ALIGN="displayAlign"}(i||(e.TTMLSpecificAttributes=i={})),e.TTMLSpecificAttributesToCSS=((r={})[i.DISPLAY_ALIGN]={prefix:"display:flex;justify-content:center;",cssProperty:"align-items",values:{before:"flex-start",center:"center",after:"flex-end"}},r)}},function(t){return function(){return t(90942)}()}])});
17
+ "use strict";!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["subtitles-ttml"]=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player["subtitles-ttml"]=e())}(self,function(){return(self.webpackChunkbitmovin_player=self.webpackChunkbitmovin_player||[]).push([[840],{90942:function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.TTMLSubtitlesModuleDefinition=void 0;var r=n(62756),i=n(95021);e.TTMLSubtitlesModuleDefinition={name:r.ModuleName.SubtitlesTTML,module:function(){return{TTMLParser:i.TTMLParser}},dependencies:[r.ModuleName.Subtitles]},e.default=e.TTMLSubtitlesModuleDefinition},95021:function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.TTMLParser=void 0;var r=n(76444),i=n(31207),o=function(){function t(t){this.dt=t}return t.prototype.parse=function(t,e){var n=this;void 0===e&&(e=0);var o=/xmlns:(\S+)="http:\/\/www.w3.org\/ns\/ttml"/.exec(t),a=null!=o?t.replace(new RegExp("(<[/]?)(".concat(o[1],":)([\\s\\S]+?>)"),"g"),"$1$3"):t,u=(new DOMParser).parseFromString(a,"application/xml"),l=(0,r.getFirstElementByTagName)(u,"tt"),s=(0,r.getFirstElementByTagName)(l,"body");if(!l||!s)return[];e&&!isNaN(e)||(e=0);var c=(0,r.extractImages)(l),f=(0,i.getStylingInfo)(l),p=(0,r.getLayoutInfo)(l),d=(0,i.parseBodyStyle)(s,f);return(0,r.splitUpTimedElements)(s).map(function(t){return(0,i.applyStyling)(t,f,c,t.element),(0,r.redistributeLineBreaks)(t.element),(0,i.applyBodyStyle)(t,d),(0,r.getSubtitleCue)({timedElement:t,layouts:p,baseOffset:e,styles:f},n.dt.logger)})},t}();e.TTMLParser=o},32148:function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.parseAttributes=function(t){var e=new Map;return(0,i.iterableToArray)(t.attributes).forEach(function(t){return e.set(o(t),t.value)}),e},e.getQualifiedAttributeName=function(t,e){var n=(0,i.iterableToArray)(t).find(function(t){return function(t){return null!=t.localName?t.localName:null!=t.name?o(t):""}(t)===e});return n?n.name:""},e.processAttribute=function(t,e,n,i){var o=n.includes("-")?(0,r.kebabCaseToCamelCase)(n):n,a=t.get(o);if(void 0!==a){var u=i(a);!u||"string"==typeof u&&""===u||e.set(n,u)}};var r=n(20649),i=n(76444);function o(t){var e=t.name;return e.includes(":")?e.split(":")[1]:e}},76444:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)},i=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.LayoutStyleProperties=e.LayoutInfoEntryKeys=void 0,e.iterableToArray=p,e.redistributeLineBreaks=function t(e){var n=p(e.children),r=n.filter(function(t){return"br"===t.tagName}),i=n.filter(function(t){return"span"===t.tagName});if(r.length>0&&i.length>0){var o=0;for(r.forEach(function(t){var e;return null===(e=t.parentElement)||void 0===e?void 0:e.removeChild(t)});r.length>0;){var a=r.shift();if(a&&(i[o].nextSibling?e.insertBefore(a,i[o].nextSibling):e.appendChild(a)),++o>=i.length)break}r.forEach(function(t){return e.appendChild(t)})}n.forEach(t)},e.getSubtitleCue=function(t,e){var n,r,i=t.timedElement,a=t.layouts,s=t.baseOffset,f=t.styles,p=i.end?m(i.end):NaN,v=i.dur?m(i.dur):NaN,y=i.begin?m(i.begin):NaN,T=b(i.element),h=function(t,e,n){var r=Boolean(t)&&n.has(t),i=n.get(t),a=(r&&i instanceof Map?function(t){var e=t.get(o.StyleIds);return Array.isArray(e)?e:[]}(i):[]).map(function(t){return(0,c.getCSSFromStyleID)(t,e)}).join("");return a+(i&&i instanceof Map?g(i):"")+(r&&i instanceof Map?d(i):"")}(T,f,a),S=y+s,A=isFinite(p)?p+s:S+v,E=u.ModuleManager.get(l.ModuleName.Subtitles).HtmlTransformer.htmlToText,L=(T?function(t){var e;return t.innerHTML?t.innerHTML:t.parentNode&&null!==(e=t.parentNode.innerHTML)&&void 0!==e?e:""}(i.element):function(t){var e;return null!==(e=t.outerHTML)&&void 0!==e?e:""}(i.element)).replace(/<br><\/br>/g,"<br>").replace(/[\r\n]+\s*/g,""),M={start:S,end:A,text:L?E(L):null!==(r=null===(n=i.element.textContent)||void 0===n?void 0:n.trim())&&void 0!==r?r:"",region:T,regionStyle:h,html:L};return i.backgroundImageSource&&(M.image=i.backgroundImageSource),(p<0||y<0||v<0)&&e.debug("could not parse time string for TTML subtitle cue"),M},e.extractLayoutStylesCss=d,e.extractLayoutPositionStylesCss=g,e.extractImages=function(t){var e=h(t,"head"),n=h(e,"metadata");return n?p(n.getElementsByTagNameNS("*","image")).filter(function(t){var e;return t.hasAttribute("xml:id")&&(null===(e=t.prefix)||void 0===e?void 0:e.includes("smpte"))}).map(function(t){var e,n,r,i;return{mimeType:null!==(n=null===(e=t.getAttribute("imagetype"))||void 0===e?void 0:e.toLowerCase())&&void 0!==n?n:"png",id:"#"+t.getAttribute("xml:id"),base64:null!==(i=null===(r=t.textContent)||void 0===r?void 0:r.trim())&&void 0!==i?i:""}}):[]},e.getLayoutInfo=function(t){var e=new Map;if(!t)return e;var n=(0,s.parseAttributes)(t),u=r({},f),l=h(t,"head"),d=h(l,"layout"),g=d?p(d.getElementsByTagName("region")):[];if(!g||0===g.length)return e.set("cellResolutionRows",u.rows),e.set("cellResolutionColumns",u.columns),e;var m=n.get("cellResolution");if(m){var b=m.split(" "),y=parseInt(b[0],10),T=parseInt(b[1],10);isFinite(y)&&y>0&&(u.columns=y),isFinite(T)&&T>0&&(u.rows=T)}var S=h(l,"styling"),A=S?p(S.getElementsByTagName("style")):[];return g.forEach(function(t){var n=t.getAttribute("xml:id")||t.getAttribute("id");n&&e.set(n,function(t,e,n){var r=new Map,u=(0,s.parseAttributes)(t);if(r.set(o.CellResolutionRows,e.rows),r.set(o.CellResolutionColumns,e.columns),u.has("style")){var l=u.get("style"),f=l?l.split(" "):[];r.set(o.StyleIds,f),function(t,e){var n=t.get(o.StyleIds);function r(e,n){if((e.getAttribute("xml:id")||e.getAttribute("id"))===n){v(e.getAttribute("tts:origin"),e.getAttribute("tts:extent"),t);var r=(0,s.parseAttributes)(e);Object.values(a).forEach(function(e){(0,s.processAttribute)(r,t,e,function(t){return t})})}}n&&(Array.isArray(n)?n.forEach(function(t){e.forEach(function(e){return r(e,t)})}):e.forEach(function(t){return r(t,n)}))}(r,n)}return function(t,e,n){var r=t.getElementsByTagName("style");r.length&&(p(r).forEach(function(t){(0,s.parseAttributes)(t).forEach(function(t,e){n.set(e,t)})}),i(i([],c.COLOR_STYLE_ATTRIBUTES,!0),c.BASE_STYLE_ATTRIBUTES,!0).forEach(function(t){(0,s.processAttribute)(n,e,t,function(t){return t})}))}(t,r,u),v(u.get("origin"),u.get("extent"),r),Object.values(a).forEach(function(t){(0,s.processAttribute)(u,r,t,function(t){return t})}),r}(t,u,A))}),e},e.splitUpTimedElements=function(t){if(!t||t.children.length<1)return[];var e=u.ModuleManager.get(l.ModuleName.Subtitles).createHtmlElement;return y(t).map(function(n){var r=e("div"),i=(0,s.parseAttributes)(n),o=function(t,e){for(var n=[],r=t,i=function(t){return t.parentElement||t.parentNode};r&&i(r)&&i(r)!==e;)n.unshift(i(r)),r=i(r);return n}(n,t).reduce(function(t,e){return t.appendChild(e.cloneNode(!1))},r);return r.children[0]&&T(r.children[0]),o.appendChild(n),{end:i.get("end"),dur:i.get("dur"),begin:i.get("begin"),element:r.children[0]}})},e.getFirstElementByTagName=h;var o,a,u=n(88052),l=n(62756),s=n(32148),c=n(31207);!function(t){t.CellResolutionRows="cellResolutionRows",t.CellResolutionColumns="cellResolutionColumns",t.Top="top",t.Left="left",t.Width="width",t.Height="height",t.StyleIds="styleIDs"}(o||(e.LayoutInfoEntryKeys=o={})),function(t){t.DisplayAling="displayAlign",t.Padding="padding",t.WritingMode="writingMode",t.ShowBackground="showBackground",t.Overflow="overflow"}(a||(e.LayoutStyleProperties=a={}));var f={rows:15,columns:40};function p(t){for(var e=[],n=0;n<t.length;n++)e.push(t[n]);return e}function d(t){return i(i(i([],c.COLOR_STYLE_ATTRIBUTES,!0),c.BASE_STYLE_ATTRIBUTES,!0),Object.values(a),!0).filter(function(e){return t.has(e)}).map(function(e){var n=t.get(e),r=Array.isArray(n)?"":"".concat(n);return r?Object.values(c.TTMLSpecificAttributes).some(function(t){return t.toString()===e.toString()})?(0,c.getCssFromTtmlSpecificAttribute)(e,r):(0,c.getCssFromCommonAttribute)(e,r):""}).join("")}function g(t){return[o.Top,o.Left,o.Height,o.Width].map(function(e){return"".concat(e,":").concat(t.get(e),";")}).join("")}function m(t){var e=t.match(/^(\d+):(\d+):(\d+)((?:\.)(\d+)$)?/),n=e?function(t){var e=3600*parseInt(t[1]),n=60*parseInt(t[2]),r=parseInt(t[3]),i=0;return t[5]&&(i=.001*parseInt(t[5])),e+n+r+i}(e):function(t){var e=t.charAt(t.length-1);return"h"===e?3600*parseFloat(t.slice(0,-1)):"m"===e?60*parseFloat(t.slice(0,-1)):"s"===e?"m"===t.charAt(t.length-2)?parseFloat(t.slice(0,-2))/1e3:parseFloat(t.slice(0,-1)):NaN}(t);return isFinite(n)?n:-1}function b(t){var e=(0,s.parseAttributes)(t).get("region");if(e)return e;for(var n=t.children,r=0;r<n.length;r++){var i=b(n[r]);if(i)return i}return""}function v(t,e,n){if(t){var r=t.split(" ");n.set(o.Top,r[1]),n.set(o.Left,r[0])}if(e){var i=e.split(" ");n.set(o.Width,i[0]),n.set(o.Height,i[1])}}function y(t){var e=function(t){var e=(0,s.parseAttributes)(t);return e.has("begin")&&(e.has("end")||e.has("dur"))}(t),n=p(t.children).flatMap(y).filter(Boolean);return n.length>0?n:e?[t]:[]}function T(t){["begin","dur","end"].map(function(e){return(0,s.getQualifiedAttributeName)(t.attributes,e)}).filter(function(t){return Boolean(t)}).forEach(function(e){return t.removeAttribute(e)}),p(t.children).forEach(T)}function h(t,e){if(!t)return null;var n=t.getElementsByTagName(e);return n.length>0?n[0]:null}},31207:function(t,e,n){var r;Object.defineProperty(e,"__esModule",{value:!0}),e.TTMLSpecificAttributesToCSS=e.TTMLSpecificAttributes=e.COLOR_STYLE_ATTRIBUTES=e.BASE_STYLE_ATTRIBUTES=void 0,e.applyStyling=function t(e,n,r,i){void 0===i&&(i=e.element);var u=function(t,e){var n="",r=t.getAttribute("style");return r&&(n+=r.split(" ").map(function(t){return g(t,e)}).join(";").replace(/;;+/g,";")),n+=m(y(t))}(i,n);u.length>0&&i.setAttribute("style",u),(0,l.iterableToArray)(i.children).forEach(function(i){return t(e,n,r,i)}),function(t,e,n){var r=e.getAttribute("smpte:backgroundImage"),i=r?n.find(function(t){return t.id===r}):null;if(i){var u=o.ModuleManager.get(a.ModuleName.Subtitles).createHtmlElement("img"),l="data:image/".concat(i.mimeType,";base64,").concat(i.base64);u.setAttribute("style","width:100%"),u.setAttribute("src",l),t.backgroundImageSource=l,e.appendChild(u)}}(e,i,r)},e.getStylingInfo=function(t){var e=new Map,n=(0,l.getFirstElementByTagName)(t,"head"),r=(0,l.getFirstElementByTagName)(n,"styling");return r?((0,l.iterableToArray)(r.getElementsByTagName("style")).forEach(function(t){var n=t.getAttribute("xml:id")||t.getAttribute("id");n&&e.set(n,y(t))}),e):e},e.applyBodyStyle=function(t,e){if(e){var n=t.element.getAttribute("style");t.element.setAttribute("style",n?n+e:e)}},e.parseBodyStyle=function(t,e){var n=t.getAttribute("style"),r=y(t),i=n?g(n,e):"";return T(r).reduce(function(t,e){return"".concat(t).concat(e,":").concat(r.get(e),";")},i)},e.getCssFromCommonAttribute=function(t,e){return t===l.LayoutStyleProperties.Padding?"box-sizing:border-box;".concat(t,":").concat(e,";"):"".concat(t,":").concat(e,";")},e.getCssFromTtmlSpecificAttribute=function(t,n){var r=Object.values(i).find(function(e){return e===t});if(r){var o=e.TTMLSpecificAttributesToCSS[r],a=o.values[n];return o&&a?o.prefix+"".concat(o.cssProperty,":").concat(a,";"):""}return""},e.getCSSColorFromTTML=d,e.getCSSFromStyleID=g;var i,o=n(88052),a=n(62756),u=n(32148),l=n(76444),s=new RegExp("^#([0-9a-fA-F]{3,8})$"),c=16,f=5,p=9;function d(t){var e=0,n=0,r=0,i=1;if(s.test(t)){if(t.length===f)return e=parseInt(t.slice(1,2),c),n=parseInt(t.slice(2,3),c),r=parseInt(t.slice(3,4),c),i=parseInt(t.slice(4),c),"rgba(".concat(e,",").concat(n,",").concat(r,",").concat(i,")");if(t.length===p)return e=parseInt(t.slice(1,3),c),n=parseInt(t.slice(3,5),c),r=parseInt(t.slice(5,7),c),i=parseInt(t.slice(7),c),"rgba(".concat(e,",").concat(n,",").concat(r,",").concat(i,")")}return t}function g(t,e){var n=e.get(t);return n instanceof Map?m(n):n?"".concat(t,":").concat(n):""}function m(t){var e=T(t).filter(function(t){return["cellResolutionRows","cellResolutionColumns"].indexOf(t)<0}).map(function(e){return"".concat(e,":").concat(t.get(e))}).join(";");return""===e?e:"".concat(e,";")}function b(t){return t.replace(/(default)|(monospace(Sans)?Serif)/g,"monospace").replace(/(sansSerif)|(proportional(Sans)?Serif)/g,"sans-serif")}function v(t){return"wrap"===t?"break-word":"normal"}function y(t){var n=new Map,r=(0,u.parseAttributes)(t);return e.BASE_STYLE_ATTRIBUTES.forEach(function(t){(0,u.processAttribute)(r,n,t,function(t){return t})}),e.COLOR_STYLE_ATTRIBUTES.forEach(function(t){(0,u.processAttribute)(r,n,t,d)}),(0,u.processAttribute)(r,n,"font-family",b),(0,u.processAttribute)(r,n,"word-wrap",v),n}function T(t){var e=[];return t.forEach(function(t,n){return e.push(n)}),e}e.BASE_STYLE_ATTRIBUTES=["font-size","line-height","text-align","unicode-bidi","font-weight","direction","text-decoration","font-style","multiRowAlign","linePadding"],e.COLOR_STYLE_ATTRIBUTES=["color","background-color"],function(t){t.DISPLAY_ALIGN="displayAlign"}(i||(e.TTMLSpecificAttributes=i={})),e.TTMLSpecificAttributesToCSS=((r={})[i.DISPLAY_ALIGN]={prefix:"display:flex;justify-content:center;",cssProperty:"align-items",values:{before:"flex-start",center:"center",after:"flex-end"}},r)}},function(t){return function(){return t(90942)}()}])});
18
18
  })();