/*! * artplayer-plugin-multiple-subtitles.js v1.1.0 * Github: https://github.com/zhw2590582/ArtPlayer * (c) 2017-2025 Harvey Zack * Released under the MIT License. */ !function(e,t,r,n,o,i,a,s){var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof c[n]&&c[n],l=u.i||{},f=u.cache||{},p="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,r){if(!f[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof c[n]&&c[n];if(!r&&i)return i(t,!0);if(u)return u(t,!0);if(p&&"string"==typeof t)return p(t);var a=Error("Cannot find module '"+t+"'");throw a.code="MODULE_NOT_FOUND",a}l.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},l.cache={};var s=f[t]=new d.Module(t);e[t][0].call(s.exports,l,s,s.exports,c)}return f[t].exports;function l(e){var t=l.resolve(e);return!1===t?{}:d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.require=p,this.exports={}},d.modules=e,d.cache=f,d.parent=u,d.distDir=void 0,d.publicUrl=void 0,d.devServer=void 0,d.i=l,d.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(d,"root",{get:function(){return c[n]}}),c[n]=d;for(var h=0;h0&&void 0!==arguments[0]?arguments[0]:[],n=function(e){for(var t=new(0,l.WebVTTParser)().parse("","metadata"),r=0;r').concat(u.value,"")}}(n=t.cues).push.apply(n,(0,c._)(o.cues))}return t}(t),o=h.serialize(n.cues);URL.revokeObjectURL(v);var i=URL.createObjectURL(new Blob([o],{type:"text/vtt"}));v=i,e.option.subtitle.escape=!1,e.subtitle.init((0,s._)((0,a._)({},e.option.subtitle),{url:i,type:"vtt",onVttLoad:r}))}return(0,u._)(this,function(a){switch(a.label){case 0:return r=(t=e.constructor.utils).unescape,o=t.getExt,i=t.srtToVtt,p=t.assToVtt,d=new(0,l.WebVTTParser),h=new(0,l.WebVTTSerializer),[4,Promise.all(n.map(function(e){return function(e,t){return f.apply(this,arguments)}(e,{getExt:o,srtToVtt:i,assToVtt:p})}))];case 1:return m=a.sent().map(function(e,t){var r=d.parse(e,"metadata");return r.url=n[t].url,r.name=n[t].name,r}),v="",_(m),[2,{name:"multipleSubtitles",tracks:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return _(e.map(function(e){return m.find(function(t){return t.name===e})}))},reset:function(){return _(m)}}]}})}),function(e){return t.apply(this,arguments)}}"undefined"!=typeof window&&(window.artplayerPluginMultipleSubtitles=p)},{"@swc/helpers/_/_async_to_generator":"eONSn","@swc/helpers/_/_object_spread":"9agdF","@swc/helpers/_/_object_spread_props":"gJNH2","@swc/helpers/_/_to_consumable_array":"iwLF0","@swc/helpers/_/_ts_generator":"6Xyd0","./parser":"8YYw5","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],eONSn:[function(e,t,r,n){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");function i(e,t,r,n,o,i,a){try{var s=e[i](a),c=s.value}catch(e){r(e);return}s.done?t(c):Promise.resolve(c).then(n,o)}function a(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function s(e){i(a,n,o,s,c,"next",e)}function c(e){i(a,n,o,s,c,"throw",e)}s(void 0)})}}o.defineInteropFlag(r),o.export(r,"_",function(){return a})},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],iWrD0:[function(e,t,r,n){r.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},r.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.exportAll=function(e,t){return Object.keys(e).forEach(function(r){"default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[r]}})}),t},r.export=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:r})}},{}],"9agdF":[function(e,t,r,n){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"_",function(){return a});var i=e("./_define_property.js");function a(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=Array(t);rt.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,n=Object.getOwnPropertySymbols(e);ot.indexOf(n[o])&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function l(e,t,r,n){var o,a=arguments.length,s=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if(("undefined"==typeof Reflect?"undefined":(0,i._)(Reflect))==="object"&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(a<3?o(s):a>3?o(t,r,s):o(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s}function f(e,t){return function(r,n){t(r,n,e)}}function p(e,t,r,n,o,a){function s(e){if(void 0!==e&&"function"!=typeof e)throw TypeError("Function expected");return e}for(var c,u=n.kind,l="getter"===u?"get":"setter"===u?"set":"value",f=!t&&e?n.static?e:e.prototype:null,p=t||(f?Object.getOwnPropertyDescriptor(f,n.name):{}),d=!1,h=r.length-1;h>=0;h--){var m={};for(var v in n)m[v]="access"===v?{}:n[v];for(var v in n.access)m.access[v]=n.access[v];m.addInitializer=function(e){if(d)throw TypeError("Cannot add initializers after decoration has completed");a.push(s(e||null))};var _=(0,r[h])("accessor"===u?{get:p.get,set:p.set}:p[l],m);if("accessor"===u){if(void 0===_)continue;if(null===_||(void 0===_?"undefined":(0,i._)(_))!=="object")throw TypeError("Object expected");(c=s(_.get))&&(p.get=c),(c=s(_.set))&&(p.set=c),(c=s(_.init))&&o.unshift(c)}else(c=s(_))&&("field"===u?o.unshift(c):p[l]=c)}f&&Object.defineProperty(f,n.name,p),d=!0}function d(e,t,r){for(var n=arguments.length>2,o=0;o0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function w(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function x(){for(var e=[],t=0;t1||s(e,t)})},t&&(n[e]=t(n[e])))}function s(e,t){try{var r;(r=o[e](t)).value instanceof P?Promise.resolve(r.value.v).then(c,u):l(i[0][2],r)}catch(e){l(i[0][3],e)}}function c(e){s("next",e)}function u(e){s("throw",e)}function l(e,t){e(t),i.shift(),i.length&&s(i[0][0],i[0][1])}}function I(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:P(e[n](t)),done:!1}:o?o(t):t}:o}}function E(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=j(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,o){var i,a,s;i=n,a=o,s=(t=e[r](t)).done,Promise.resolve(t.value).then(function(e){i({value:e,done:s})},a)})}}}function D(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var F=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},A=function(e){return(A=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t})(e)};function k(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=A(e),n=0;n","&lrm":"‎","&rlm":"‏"," ":" "}),this.entities=t,this.parse=function(r,o){r=r.replace(/\0/g,"�");var a=Date.now(),s=0,c=r.split(/\r\n|\r|\n/),u=!1,l=[],f=[],p=[];function d(e,t){p.push({message:e,line:s+1,col:t})}var h=c[s],m=h.length,v="WEBVTT",_=0,y=v.length;for("\uFEFF"===h[0]&&(_=1,y+=1),(my&&" "!==h[y]&&" "!==h[y])&&d('No valid signature. (File needs to start with "WEBVTT".)'),s++;""!=c[s]&&void 0!=c[s];){if(d("No blank line after the signature."),-1!=c[s].indexOf("--\x3e")){u=!0;break}s++}for(;void 0!=c[s];){for(;!u&&""==c[s];)s++;if(!u&&void 0==c[s])break;var g=Object.assign({},e,{id:"",startTime:0,endTime:0,pauseOnExit:!1,direction:"horizontal",snapToLines:!0,linePosition:"auto",lineAlign:"start",textPosition:"auto",positionAlign:"auto",size:100,alignment:"center",text:"",tree:null}),b=!0;if(-1==c[s].indexOf("--\x3e")){if(g.id=c[s],/^NOTE($|[ \t])/.test(g.id)){for(s++;""!=c[s]&&void 0!=c[s];)-1!=c[s].indexOf("--\x3e")&&d("Cannot have timestamp in a comment."),s++;continue}if(/^STYLE($|[ \t])/.test(g.id)){var j=[],w=!1;for(s++;""!=c[s]&&void 0!=c[s];)-1!=c[s].indexOf("--\x3e")&&(d("Cannot have timestamp in a style block."),w=!0),j.push(c[s]),s++;if(f.length){d("Style blocks cannot appear after the first cue.");continue}w||l.push(j.join("\n"));continue}if(""==c[++s]||void 0==c[s]){d("Cue identifier cannot be standalone.");continue}if(-1==c[s].indexOf("--\x3e")){b=!1,d("Cue identifier needs to be followed by timestamp.");continue}}u=!1;var x=new n(c[s],d),O=0;if(f.length>0&&(O=f[f.length-1].startTime),b&&!x.parse(g,O)){for(g=null,s++;""!=c[s]&&void 0!=c[s];){if(-1!=c[s].indexOf("--\x3e")){u=!0;break}s++}continue}for(s++;""!=c[s]&&void 0!=c[s];){if(-1!=c[s].indexOf("--\x3e")){d("Blank line missing before cue."),u=!0;break}""!=g.text&&(g.text+="\n"),g.text+=c[s],s++}var T=new i(g.text,d,o,t);g.tree=T.parse(g.startTime,g.endTime),f.push(g)}return f.sort(function(e,t){return e.startTimet.startTime?1:e.endTime>t.endTime?-1:+(e.endTime2||parseInt(t,10)>59)&&(c="hours"),":"!=e[o])return void i("No time unit separator found.");if(o++,2!=(r=s(/\d/)).length)return void i("Must be exactly two digits.");if("hours"==c||":"==e[o]){if(":"!=e[o])return void i("No seconds found or minutes is greater than 59.");if(o++,2!=(n=s(/\d/)).length)return void i("Must be exactly two digits.")}else{if(2!=t.length)return void i("Must be exactly two digits.");n=r,r=t,t="0"}return"."!=e[o]?void i('No decimal separator (".") found.'):(o++,3!=(a=s(/\d/)).length)?void i("Milliseconds must be given in three digits."):parseInt(r,10)>59?void i("You cannot have more than 59 minutes."):parseInt(n,10)>59?void i("You cannot have more than 59 seconds."):3600*parseInt(t,10)+60*parseInt(r,10)+parseInt(n,10)+parseInt(a,10)/1e3}this.parse=function(t,s){return(a(r),t.startTime=c(),void 0==t.startTime)?void 0:(t.startTime"!=e[++o])?void i("No valid timestamp separator found."):(o++,n.test(e[o])&&i("'--\x3e' not separated from timestamp by whitespace."),a(r),t.endTime=c(),void 0!=t.endTime)?(t.endTime<=t.startTime&&i("End timestamp is not greater than start timestamp."),n.test(e[o]),a(r),!function(e,t){for(var n=e.split(r),o=[],a=0;a100)){i("Line position cannot be >100%.");continue}if(""===p||isNaN(p)||!isFinite(p)){i("Line position needs to be a number");continue}if(void 0!==f){if(!["start","center","end"].includes(f)){i("Line alignment needs to be one of start, center or end");continue}t.lineAlign=f}t.snapToLines=!d,t.linePosition=parseFloat(p),parseFloat(p).toString()!==p&&(t.nonSerializable=!0)}else if("position"==c){if(/,/.test(u)){var l=u.split(",");u=l[0];var h=l[1]}if("%"!=u[u.length-1]){i("Text position must be a percentage.");continue}if(parseInt(u,10)>100||0>parseInt(u,10)){i("Text position needs to be between 0 and 100%.");continue}if(""===(p=u.slice(0,u.length-1))||isNaN(p)||!isFinite(p)){i("Line position needs to be a number");continue}if(void 0!==h){if(!["line-left","center","line-right"].includes(h)){i("Position alignment needs to be one of line-left, center or line-right");continue}t.positionAlign=h}t.textPosition=parseFloat(p)}else if("size"==c){if("%"!=u[u.length-1]){i("Size must be a percentage.");continue}if(parseInt(u,10)>100){i("Size cannot be >100%.");continue}var m=u.slice(0,u.length-1);if(void 0===m||""===m||isNaN(m)){i("Size needs to be a number"),m=100;continue}if((m=parseFloat(m))<0||m>100){i("Size needs to be between 0 and 100%.");continue}t.size=m}else if("align"==c){var v=["start","center","end","left","right"];if(-1==v.indexOf(u)){i("Alignment can only be set to one of "+v.join(", ")+".");continue}t.alignment=u}else i("Invalid setting.")}}(e.substring(o),t),!0):void 0},this.parseTimestamp=function(){var t=c();return void 0!=e[o]?void i("Timestamp must not have trailing characters."):t}},i=function(e,t,r,i){this.entities=i;var a=this,e=e,s=0,c=function(e){"metadata"!=r&&t(e,s+1)};this.parse=function(t,u){var l={children:[]},f=l,p=[];function d(e){f.children.push({type:"object",name:e[1],classes:e[2],children:[],parent:f}),f=f.children[f.children.length-1]}for(;void 0!=e[s];){var h=function(){for(var t="data",r="",n="",o=[];void 0!=e[s-1]||0==s;){var u=e[s];if("data"==t)if("&"==u)n=u,t="escape";else if("<"==u&&""==r)t="tag";else{if("<"==u||void 0==u)return["text",r];r+=u}else if("escape"==t)if("<"==u||void 0==u){c("Incorrect escape.");var l=void 0;return(l=n.match(/^&#([0-9]+)$/))?r+=String.fromCharCode(l[1]):a.entities[n]?r+=a.entities[n]:r+=n,["text",r]}else if("&"==u)c("Incorrect escape."),r+=n,n=u;else if(/[a-z#0-9]/i.test(u))n+=u;else if(";"==u){var f=void 0;(f=n.match(/^&#(x?[0-9]+)$/))?r+=String.fromCharCode("0"+f[1]):a.entities[n+u]?r+=a.entities[n+u]:(f=Object.keys(i).find(function(e){return n.startsWith(e)}))?r+=a.entities[f]+n.slice(f.length)+u:(c("Incorrect escape."),r+=n+";"),t="data"}else c("Incorrect escape."),r+=n+u,t="data";else if("tag"==t)if(" "==u||"\n"==u||"\f"==u||" "==u)t="start tag annotation";else if("."==u)t="start tag class";else if("/"==u)t="end tag";else if(/\d/.test(u))r=u,t="timestamp tag";else{if(">"==u||void 0==u)return">"==u&&s++,["start tag","",[],""];r=u,t="start tag"}else if("start tag"==t)if(" "==u||"\f"==u||" "==u)t="start tag annotation";else if("\n"==u)n=u,t="start tag annotation";else if("."==u)t="start tag class";else{if(">"==u||void 0==u)return">"==u&&s++,["start tag",r,[],""];r+=u}else if("start tag class"==t)if(" "==u||"\f"==u||" "==u)n&&o.push(n),n="",t="start tag annotation";else if("\n"==u)n&&o.push(n),n=u,t="start tag annotation";else if("."==u)n&&o.push(n),n="";else{if(">"==u||void 0==u)return">"==u&&s++,n&&o.push(n),["start tag",r,o,""];n+=u}else if("start tag annotation"==t)if(">"==u||void 0==u)return">"==u&&s++,["start tag",r,o,n=n.split(/[\u0020\t\f\r\n]+/).filter(function(e){if(e)return!0}).join(" ")];else n+=u;else if("end tag"==t)if(">"==u||void 0==u)return">"==u&&s++,["end tag",r];else r+=u;else if("timestamp tag"==t)if(">"==u||void 0==u)return">"==u&&s++,["timestamp",r];else r+=u;else c("Never happens.");s++}}();if("text"==h[0])f.children.push({type:"text",value:h[1],parent:f});else if("start tag"==h[0]){"chapters"==r&&c("Start tags not allowed in chapter title text.");var m=h[1];"v"!=m&&"lang"!=m&&""!=h[3]&&c("Onlyandcan have an annotation."),"c"==m||"i"==m||"b"==m||"u"==m||"ruby"==m||"rt"==m&&"ruby"==f.name?d(h):"v"==m?(function(e){for(var t=f;t;){if("v"==t.name)return!0;t=t.parent}}(0)&&c("cannot be nested inside itself."),d(h),f.value=h[3],h[3]||c("requires an annotation.")):"lang"==m?(d(h),f.value=h[3]):c("Incorrect start tag.")}else if("end tag"==h[0])"chapters"==r&&c("End tags not allowed in chapter title text."),h[1]==f.name?f=f.parent:"ruby"==h[1]&&"rt"==f.name?f=f.parent.parent:c("Incorrect end tag.");else if("timestamp"==h[0]){"chapters"==r&&c("Timestamp not allowed in chapter title text.");var v=new n(h[1],c).parseTimestamp();void 0!=v&&((v<=t||v>=u)&&c("Timestamp must be between start timestamp and end timestamp."),p.length>0&&p[p.length-1]>=v&&c("Timestamp must be greater than any previous timestamp."),f.children.push({type:"timestamp",value:v,parent:f}),p.push(v))}}for(;f.parent;)"v"!=f.name&&c("Required end tag missing."),f=f.parent;return function e(t){var r=(0,o._)({},t);return t.children&&(r.children=t.children.map(e)),r.parent&&delete r.parent,r}(l)}},a=function(){function t(e){var t=("00"+1e3*(e-Math.floor(e)).toFixed(3)).slice(-3),r=0,n=0,o=0;return e>=3600&&(r=Math.floor(e/3600)),n=Math.floor((e-3600*r)/60),o=Math.floor(e-3600*r-60*n),(r?r+":":"")+(""+n).padStart(2,"0")+":"+(""+o).padStart(2,"0")+"."+t}this.serialize=function(r,n){var o="WEBVTT\n\n";if(n)for(var i=0;i/g,">");else if("object"==i.type){if(n+="<"+i.name,i.classes)for(var a=0;a"}else"timestamp"==i.type?n+="<"+t(i.value)+">":n+="<"+i.value+">"}return n}(r.tree.children)+"\n\n"}(r[i]);return o}};function s(e){e.WebVTTParser=t,e.WebVTTCueTimingsAndSettingsParser=n,e.WebVTTCueTextParser=i,e.WebVTTSerializer=a}"undefined"!=typeof window&&s(window),s(r)}()},{"@swc/helpers/_/_object_spread":"9agdF"}]},["2hz0c"],"2hz0c","parcelRequire4dc0",{});