Files
ArtPlayer/docs/compiled/artplayer-plugin-multiple-subtitles.legacy.js
T

7 lines
29 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*!
* artplayer-plugin-multiple-subtitles.js v1.0.0
* Github: https://github.com/zhw2590582/ArtPlayer
* (c) 2017-2024 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,n,r,i){var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},a="function"==typeof o[r]&&o[r],s=a.cache||{},l="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,n){if(!s[t]){if(!e[t]){var i="function"==typeof o[r]&&o[r];if(!n&&i)return i(t,!0);if(a)return a(t,!0);if(l&&"string"==typeof t)return l(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},p.cache={};var f=s[t]=new u.Module(t);e[t][0].call(f.exports,p,f,f.exports,this)}return s[t].exports;function p(e){var t=p.resolve(e);return!1===t?{}:u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=s,u.parent=a,u.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(u,"root",{get:function(){return o[r]}}),o[r]=u;for(var c=0;c<t.length;c++)u(t[c]);if(n){var f=u(n);"object"==typeof exports&&"undefined"!=typeof module?module.exports=f:"function"==typeof define&&define.amd&&define((function(){return f}))}}({"2hz0c":[function(e,t,n){var r=e("@parcel/transformer-js/src/esmodule-helpers.js");r.defineInteropFlag(n);var i=e("@swc/helpers/src/_async_to_generator.mjs"),o=r.interopDefault(i),a=e("@swc/helpers/src/_object_spread.mjs"),s=r.interopDefault(a),l=e("@swc/helpers/src/_object_spread_props.mjs"),u=r.interopDefault(l),c=e("@swc/helpers/src/_to_consumable_array.mjs"),f=r.interopDefault(c),p=e("@swc/helpers/src/_ts_generator.mjs"),d=r.interopDefault(p),m=e("./parser");function h(){return(h=(0,o.default)((function(e,t){var n,r,i,o,a,s;return(0,d.default)(this,(function(l){switch(l.label){case 0:return n=t.getExt,r=t.srtToVtt,i=t.assToVtt,[4,fetch(e.url)];case 1:return[4,l.sent().arrayBuffer()];case 2:switch(o=l.sent(),a=new TextDecoder(e.encoding||"utf-8"),s=a.decode(o),e.type||n(e.url)){case"srt":return[2,r(s)];case"ass":return[2,i(s)];case"vtt":return[2,s];default:return[2,""]}return[2]}}))}))).apply(this,arguments)}function v(e){for(var t=(new(0,m.WebVTTParser)).parse("","metadata"),n=0;n<e.length;n++){var r=e[n];if(!r.updated){r.updated=!0;for(var i=0;i<r.cues.length;i++)for(var o=r.cues[i],a=0;a<o.tree.children.length;a++){var l=o.tree.children[a];l.value='<div class="art-subtitle-'.concat(r.name,'">').concat(l.value,"</div>")}}if(0===t.cues.length)t.cues=(0,f.default)(r.cues);else for(var c=0;c<t.cues.length;c++){var p,d,h=t.cues[c].tree.children,v=null===(p=r.cues[c])||void 0===p||null===(d=p.tree)||void 0===d?void 0:d.children;t.cues[c]=(0,u.default)((0,s.default)({},t.cues[c]),{tree:{children:(0,f.default)(h).concat((0,f.default)(v))}})}}return t}function g(e){var t,n=e.subtitles,r=void 0===n?[]:n;return t=(0,o.default)((function(e){var t,n,i,o,a,l,c,f,p,g;function y(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=v(t),i=c.serialize(r.cues);URL.revokeObjectURL(g);var o=URL.createObjectURL(new Blob([i],{type:"text/vtt"}));g=o,e.option.subtitle.escape=!1,e.subtitle.init((0,u.default)((0,s.default)({},e.option.subtitle),{url:o,type:"vtt",onVttLoad:n}))}return(0,d.default)(this,(function(s){switch(s.label){case 0:return t=e.constructor.utils,n=t.unescape,i=t.getExt,o=t.srtToVtt,a=t.assToVtt,l=new(0,m.WebVTTParser),c=new(0,m.WebVTTSerializer),[4,Promise.all(r.map((function(e){return function(e,t){return h.apply(this,arguments)}(e,{getExt:i,srtToVtt:o,assToVtt:a})})))];case 1:return f=s.sent(),p=f.map((function(e,t){var n=l.parse(e,"metadata");return n.url=r[t].url,n.name=r[t].name,n})),g="",y(p),[2,{name:"multipleSubtitles",tracks:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return y(e.map((function(e){return p.find((function(t){return t.name===e}))})))},reset:function(){return y(p)}}]}}))})),function(e){return t.apply(this,arguments)}}n.default=g,"undefined"!=typeof window&&(window.artplayerPluginMultipleSubtitles=g)},{"@swc/helpers/src/_async_to_generator.mjs":"9vSoD","@swc/helpers/src/_object_spread.mjs":"1LSQ7","@swc/helpers/src/_object_spread_props.mjs":"8IISz","@swc/helpers/src/_to_consumable_array.mjs":"inwWM","@swc/helpers/src/_ts_generator.mjs":"8UZjC","./parser":"8YYw5","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"9vSoD":[function(e,t,n){function r(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(n),n.default=function(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,l,"next",e)}function l(e){r(a,i,o,s,l,"throw",e)}s(void 0)}))}}},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],iWrD0:[function(e,t,n){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach((function(n){"default"===n||"__esModule"===n||t.hasOwnProperty(n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})})),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}],"1LSQ7":[function(e,t,n){var r=e("@parcel/transformer-js/src/esmodule-helpers.js");r.defineInteropFlag(n);var i=e("./_define_property.mjs"),o=r.interopDefault(i);n.default=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){(0,o.default)(e,t,n[t])}))}return e}},{"./_define_property.mjs":"6QNcv","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"6QNcv":[function(e,t,n){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(n),n.default=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"8IISz":[function(e,t,n){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(n),n.default=function(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],inwWM:[function(e,t,n){var r=e("@parcel/transformer-js/src/esmodule-helpers.js");r.defineInteropFlag(n);var i=e("./_array_without_holes.mjs"),o=r.interopDefault(i),a=e("./_iterable_to_array.mjs"),s=r.interopDefault(a),l=e("./_non_iterable_spread.mjs"),u=r.interopDefault(l),c=e("./_unsupported_iterable_to_array.mjs"),f=r.interopDefault(c);n.default=function(e){return(0,o.default)(e)||(0,s.default)(e)||(0,f.default)(e)||(0,u.default)()}},{"./_array_without_holes.mjs":"aPtE3","./_iterable_to_array.mjs":"a510R","./_non_iterable_spread.mjs":"hRgb8","./_unsupported_iterable_to_array.mjs":"jHVd7","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],aPtE3:[function(e,t,n){var r=e("@parcel/transformer-js/src/esmodule-helpers.js");r.defineInteropFlag(n);var i=e("./_array_like_to_array.mjs"),o=r.interopDefault(i);n.default=function(e){if(Array.isArray(e))return(0,o.default)(e)}},{"./_array_like_to_array.mjs":"dhuPI","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],dhuPI:[function(e,t,n){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(n),n.default=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],a510R:[function(e,t,n){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(n),n.default=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],hRgb8:[function(e,t,n){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(n),n.default=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],jHVd7:[function(e,t,n){var r=e("@parcel/transformer-js/src/esmodule-helpers.js");r.defineInteropFlag(n);var i=e("./_array_like_to_array.mjs"),o=r.interopDefault(i);n.default=function(e,t){if(e){if("string"==typeof e)return(0,o.default)(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?(0,o.default)(e,t):void 0}}},{"./_array_like_to_array.mjs":"dhuPI","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"8UZjC":[function(e,t,n){var r=e("@parcel/transformer-js/src/esmodule-helpers.js");r.defineInteropFlag(n),r.export(n,"default",(function(){return i.__generator}));var i=e("tslib")},{tslib:"c0d7h","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],c0d7h:[function(e,t,n){var r=e("@parcel/transformer-js/src/esmodule-helpers.js");r.defineInteropFlag(n),r.export(n,"__extends",(function(){return o})),r.export(n,"__assign",(function(){return a})),r.export(n,"__rest",(function(){return s})),r.export(n,"__decorate",(function(){return l})),r.export(n,"__param",(function(){return u})),r.export(n,"__metadata",(function(){return c})),r.export(n,"__awaiter",(function(){return f})),r.export(n,"__generator",(function(){return p})),r.export(n,"__createBinding",(function(){return d})),r.export(n,"__exportStar",(function(){return m})),r.export(n,"__values",(function(){return h})),r.export(n,"__read",(function(){return v})),r.export(n,"__spread",(function(){return g})),r.export(n,"__spreadArrays",(function(){return y})),r.export(n,"__spreadArray",(function(){return b})),r.export(n,"__await",(function(){return j})),r.export(n,"__asyncGenerator",(function(){return _})),r.export(n,"__asyncDelegator",(function(){return w})),r.export(n,"__asyncValues",(function(){return x})),r.export(n,"__makeTemplateObject",(function(){return O})),r.export(n,"__importStar",(function(){return P})),r.export(n,"__importDefault",(function(){return S})),r.export(n,"__classPrivateFieldGet",(function(){return I})),r.export(n,"__classPrivateFieldSet",(function(){return D})),r.export(n,"__classPrivateFieldIn",(function(){return A}));var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var a=function(){return a=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};function s(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function l(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function u(e,t){return function(n,r){t(n,r,e)}}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function f(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}function p(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}var d=Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]};function m(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||d(t,e,n)}function h(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function g(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(v(arguments[t]));return e}function y(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}function b(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}function j(e){return this instanceof j?(this.v=e,this):new j(e)}function _(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(e,t||[]),o=[];return r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r;function a(e){i[e]&&(r[e]=function(t){return new Promise((function(n,r){o.push([e,t,n,r])>1||s(e,t)}))})}function s(e,t){try{(n=i[e](t)).value instanceof j?Promise.resolve(n.value.v).then(l,u):c(o[0][2],n)}catch(e){c(o[0][3],e)}var n}function l(e){s("next",e)}function u(e){s("throw",e)}function c(e,t){e(t),o.shift(),o.length&&s(o[0][0],o[0][1])}}function w(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:j(e[r](t)),done:"return"===r}:i?i(t):t}:i}}function x(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=h(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,i,(t=e[n](t)).done,t.value)}))}}}function O(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var T=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function P(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&d(t,e,n);return T(t,e),t}function S(e){return e&&e.__esModule?e:{default:e}}function I(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function D(e,t,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(e,n):i?i.value=n:t.set(e,n),n}function A(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}},{"@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"8YYw5":[function(e,t,n){var r=e("@parcel/transformer-js/src/esmodule-helpers.js"),i=e("@swc/helpers/src/_object_spread.mjs"),o=r.interopDefault(i);!function(){var e={direction:"horizontal",snapToLines:!0,linePosition:"auto",lineAlign:"start",textPosition:"auto",positionAlign:"auto",size:100,alignment:"center"},t=function(t){t||(t={"&amp":"&","&lt":"<","&gt":">","&lrm":"‎","&rlm":"‏","&nbsp":" "}),this.entities=t,this.parse=function(n,o){n=n.replace(/\0/g,"�");var a=Date.now(),s=0,l=n.split(/\r\n|\r|\n/),u=!1,c=[],f=[],p=[];function d(e,t){p.push({message:e,line:s+1,col:t})}var m=l[s],h=m.length,v="WEBVTT",g=0,y=v.length;for("\ufeff"===m[0]&&(g=1,y+=1),(h<y||m.indexOf(v)!==0+g||h>y&&" "!==m[y]&&"\t"!==m[y])&&d('No valid signature. (File needs to start with "WEBVTT".)'),s++;""!=l[s]&&null!=l[s];){if(d("No blank line after the signature."),-1!=l[s].indexOf("--\x3e")){u=!0;break}s++}for(;null!=l[s];){for(var b;!u&&""==l[s];)s++;if(!u&&null==l[s])break;b=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});var j=!0;if(-1==l[s].indexOf("--\x3e")){if(b.id=l[s],/^NOTE($|[ \t])/.test(b.id)){for(s++;""!=l[s]&&null!=l[s];)-1!=l[s].indexOf("--\x3e")&&d("Cannot have timestamp in a comment."),s++;continue}if(/^STYLE($|[ \t])/.test(b.id)){var _=[],w=!1;for(s++;""!=l[s]&&null!=l[s];)-1!=l[s].indexOf("--\x3e")&&(d("Cannot have timestamp in a style block."),w=!0),_.push(l[s]),s++;if(f.length){d("Style blocks cannot appear after the first cue.");continue}w||c.push(_.join("\n"));continue}if(""==l[++s]||null==l[s]){d("Cue identifier cannot be standalone.");continue}if(-1==l[s].indexOf("--\x3e")){j=!1,d("Cue identifier needs to be followed by timestamp.");continue}}u=!1;var x=new r(l[s],d),O=0;if(f.length>0&&(O=f[f.length-1].startTime),!j||x.parse(b,O)){for(s++;""!=l[s]&&null!=l[s];){if(-1!=l[s].indexOf("--\x3e")){d("Blank line missing before cue."),u=!0;break}""!=b.text&&(b.text+="\n"),b.text+=l[s],s++}var T=new i(b.text,d,o,t);b.tree=T.parse(b.startTime,b.endTime),f.push(b)}else for(b=null,s++;""!=l[s]&&null!=l[s];){if(-1!=l[s].indexOf("--\x3e")){u=!0;break}s++}}return f.sort((function(e,t){return e.startTime<t.startTime?-1:e.startTime>t.startTime?1:e.endTime>t.endTime?-1:e.endTime<t.endTime?1:0})),{cues:f,errors:p,time:Date.now()-a,styles:c}}},r=function(e,t){var n=/[\u0020\t\f]/,r=/[^\u0020\t\f]/,i=(e=e,0),o=function(e){t(e,i+1)};function a(t){for(;null!=e[i]&&t.test(e[i]);)i++}function s(t){for(var n="";null!=e[i]&&t.test(e[i]);)n+=e[i],i++;return n}function l(){var t,n,r,a,l="minutes";if(null!=e[i])if(/\d/.test(e[i]))if(((t=s(/\d/)).length>2||parseInt(t,10)>59)&&(l="hours"),":"==e[i])if(i++,2==(n=s(/\d/)).length){if("hours"==l||":"==e[i]){if(":"!=e[i])return void o("No seconds found or minutes is greater than 59.");if(i++,2!=(r=s(/\d/)).length)return void o("Must be exactly two digits.")}else{if(2!=t.length)return void o("Must be exactly two digits.");r=n,n=t,t="0"}if("."==e[i])if(i++,3==(a=s(/\d/)).length)if(parseInt(n,10)>59)o("You cannot have more than 59 minutes.");else{if(!(parseInt(r,10)>59))return 3600*parseInt(t,10)+60*parseInt(n,10)+parseInt(r,10)+parseInt(a,10)/1e3;o("You cannot have more than 59 seconds.")}else o("Milliseconds must be given in three digits.");else o('No decimal separator (".") found.')}else o("Must be exactly two digits.");else o("No time unit separator found.");else o("Timestamp must start with a character in the range 0-9.");else o("No timestamp found.")}this.parse=function(t,s){if(a(n),t.startTime=l(),null!=t.startTime)if(t.startTime<s&&o("Start timestamp is not greater than or equal to start timestamp of previous cue."),r.test(e[i])&&o("Timestamp not separated from '--\x3e' by whitespace."),a(n),"-"==e[i])if(i++,"-"==e[i])if(i++,">"==e[i]){if(i++,r.test(e[i])&&o("'--\x3e' not separated from timestamp by whitespace."),a(n),t.endTime=l(),null!=t.endTime)return t.endTime<=t.startTime&&o("End timestamp is not greater than start timestamp."),r.test(e[i])&&!1,a(n),function(e,t){for(var r=e.split(n),i=[],a=0;a<r.length;a++)if(""!=r[a]){var s=r[a].indexOf(":"),l=r[a].slice(0,s),u=r[a].slice(s+1);if(-1!=i.indexOf(l)&&o("Duplicate setting."),i.push(l),""==u)return void o("No value for setting defined.");if("vertical"==l){if("rl"!=u&&"lr"!=u){o("Writing direction can only be set to 'rl' or 'rl'.");continue}t.direction=u}else if("line"==l){if(/,/.test(u)){var c=u.split(",");u=c[0];var f=c[1]}if(!/^[-\d](\d*)(\.\d+)?%?$/.test(u)){o("Line position takes a number or percentage.");continue}if(-1!=u.indexOf("-",1)){o("Line position can only have '-' at the start.");continue}if(-1!=u.indexOf("%")&&u.indexOf("%")!=u.length-1){o("Line position can only have '%' at the end.");continue}if("-"==u[0]&&"%"==u[u.length-1]){o("Line position cannot be a negative percentage.");continue}var p=u,d=!1;if("%"==u[u.length-1]&&(d=!0,p=u.slice(0,u.length-1),parseInt(u,10)>100)){o("Line position cannot be >100%.");continue}if(""===p||isNaN(p)||!isFinite(p)){o("Line position needs to be a number");continue}if(void 0!==f){if(!["start","center","end"].includes(f)){o("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"==l){if(/,/.test(u)){c=u.split(","),u=c[0];var m=c[1]}if("%"!=u[u.length-1]){o("Text position must be a percentage.");continue}if(parseInt(u,10)>100||parseInt(u,10)<0){o("Text position needs to be between 0 and 100%.");continue}if(""===(p=u.slice(0,u.length-1))||isNaN(p)||!isFinite(p)){o("Line position needs to be a number");continue}if(void 0!==m){if(!["line-left","center","line-right"].includes(m)){o("Position alignment needs to be one of line-left, center or line-right");continue}t.positionAlign=m}t.textPosition=parseFloat(p)}else if("size"==l){if("%"!=u[u.length-1]){o("Size must be a percentage.");continue}if(parseInt(u,10)>100){o("Size cannot be >100%.");continue}var h=u.slice(0,u.length-1);if(void 0===h||""===h||isNaN(h)){o("Size needs to be a number"),h=100;continue}if((h=parseFloat(h))<0||h>100){o("Size needs to be between 0 and 100%.");continue}t.size=h}else if("align"==l){var v=["start","center","end","left","right"];if(-1==v.indexOf(u)){o("Alignment can only be set to one of "+v.join(", ")+".");continue}t.alignment=u}else o("Invalid setting.")}}(e.substring(i),t),!0}else o("No valid timestamp separator found.");else o("No valid timestamp separator found.");else o("No valid timestamp separator found.")},this.parseTimestamp=function(){var t=l();if(null==e[i])return t;o("Timestamp must not have trailing characters.")}},i=function(e,t,n,i){this.entities=i;var a=this,s=(e=e,0),l=function(e){"metadata"!=n&&t(e,s+1)};function u(){for(var t="data",n="",r="",o=[];null!=e[s-1]||0==s;){var u=e[s];if("data"==t)if("&"==u)r=u,t="escape";else if("<"==u&&""==n)t="tag";else{if("<"==u||null==u)return["text",n];n+=u}else if("escape"==t){if("<"==u||null==u){l("Incorrect escape.");var c;return(c=r.match(/^&#([0-9]+)$/))?n+=String.fromCharCode(c[1]):a.entities[r]?n+=a.entities[r]:n+=r,["text",n]}if("&"==u)l("Incorrect escape."),n+=r,r=u;else if(/[a-z#0-9]/i.test(u))r+=u;else if(";"==u){var f=void 0;(f=r.match(/^&#(x?[0-9]+)$/))?n+=String.fromCharCode("0"+f[1]):a.entities[r+u]?n+=a.entities[r+u]:(f=Object.keys(i).find((function(e){return r.startsWith(e)})))?n+=a.entities[f]+r.slice(f.length)+u:(l("Incorrect escape."),n+=r+";"),t="data"}else l("Incorrect escape."),n+=r+u,t="data"}else if("tag"==t)if("\t"==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))n=u,t="timestamp tag";else{if(">"==u||null==u)return">"==u&&s++,["start tag","",[],""];n=u,t="start tag"}else if("start tag"==t)if("\t"==u||"\f"==u||" "==u)t="start tag annotation";else if("\n"==u)r=u,t="start tag annotation";else if("."==u)t="start tag class";else{if(">"==u||null==u)return">"==u&&s++,["start tag",n,[],""];n+=u}else if("start tag class"==t)if("\t"==u||"\f"==u||" "==u)r&&o.push(r),r="",t="start tag annotation";else if("\n"==u)r&&o.push(r),r=u,t="start tag annotation";else if("."==u)r&&o.push(r),r="";else{if(">"==u||null==u)return">"==u&&s++,r&&o.push(r),["start tag",n,o,""];r+=u}else if("start tag annotation"==t){if(">"==u||null==u)return">"==u&&s++,["start tag",n,o,r=r.split(/[\u0020\t\f\r\n]+/).filter((function(e){if(e)return!0})).join(" ")];r+=u}else if("end tag"==t){if(">"==u||null==u)return">"==u&&s++,["end tag",n];n+=u}else if("timestamp tag"==t){if(">"==u||null==u)return">"==u&&s++,["timestamp",n];n+=u}else l("Never happens.");s++}}this.parse=function(t,i){var a={children:[]},c=a,f=[];function p(e){c.children.push({type:"object",name:e[1],classes:e[2],children:[],parent:c}),c=c.children[c.children.length-1]}function d(e){for(var t=c;t;){if(t.name==e)return!0;t=t.parent}}for(;null!=e[s];){var m=u();if("text"==m[0])c.children.push({type:"text",value:m[1],parent:c});else if("start tag"==m[0]){"chapters"==n&&l("Start tags not allowed in chapter title text.");var h=m[1];"v"!=h&&"lang"!=h&&""!=m[3]&&l("Only <v> and <lang> can have an annotation."),"c"==h||"i"==h||"b"==h||"u"==h||"ruby"==h||"rt"==h&&"ruby"==c.name?p(m):"v"==h?(d("v")&&l("<v> cannot be nested inside itself."),p(m),c.value=m[3],m[3]||l("<v> requires an annotation.")):"lang"==h?(p(m),c.value=m[3]):l("Incorrect start tag.")}else if("end tag"==m[0])"chapters"==n&&l("End tags not allowed in chapter title text."),m[1]==c.name?c=c.parent:"ruby"==m[1]&&"rt"==c.name?c=c.parent.parent:l("Incorrect end tag.");else if("timestamp"==m[0]){"chapters"==n&&l("Timestamp not allowed in chapter title text.");var v=new r(m[1],l).parseTimestamp();null!=v&&((v<=t||v>=i)&&l("Timestamp must be between start timestamp and end timestamp."),f.length>0&&f[f.length-1]>=v&&l("Timestamp must be greater than any previous timestamp."),c.children.push({type:"timestamp",value:v,parent:c}),f.push(v))}}for(;c.parent;)"v"!=c.name&&l("Required end tag missing."),c=c.parent;return function e(t){var n=(0,o.default)({},t);return t.children&&(n.children=t.children.map(e)),n.parent&&delete n.parent,n}(a)}},a=function(){function t(e){var t,n,r=("00"+1e3*(e-Math.floor(e)).toFixed(3)).slice(-3),i=0;return e>=3600&&(i=Math.floor(e/3600)),t=Math.floor((e-3600*i)/60),n=Math.floor(e-3600*i-60*t),(i?i+":":"")+(""+t).padStart(2,"0")+":"+(""+n).padStart(2,"0")+"."+r}function n(e){for(var r="",i=0;i<e.length;i++){var o=e[i];if("text"==o.type)r+=o.value.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");else if("object"==o.type){if(r+="<"+o.name,o.classes)for(var a=0;a<o.classes.length;a++)r+="."+o.classes[a];o.value&&(r+=" "+o.value),r+=">",o.children&&(r+=n(o.children)),r+="</"+o.name+">"}else"timestamp"==o.type?r+="<"+t(o.value)+">":r+="<"+o.value+">"}return r}function r(r){return(void 0!==r.id?r.id+"\n":"")+t(r.startTime)+" --\x3e "+t(r.endTime)+function(t){var n="",r=Object.keys(e).filter((function(n){return t[n]!==e[n]}));return r.includes("direction")&&(n+=" vertical:"+t.direction),r.includes("alignment")&&(n+=" align:"+t.alignment),r.includes("size")&&(n+=" size:"+t.size+"%"),(r.includes("lineAlign")||r.includes("linePosition"))&&(n+=" line:"+t.linePosition+(t.snapToLines?"":"%")+(t.lineAlign&&t.lineAlign!=e.lineAlign?","+t.lineAlign:"")),(r.includes("textPosition")||r.includes("positionAlign"))&&(n+=" position:"+t.textPosition+"%"+(t.positionAlign&&t.positionAlign!==e.positionAlign?","+t.positionAlign:"")),n}(r)+"\n"+n(r.tree.children)+"\n\n"}this.serialize=function(e,t){var n="WEBVTT\n\n";if(t)for(var i=0;i<t.length;i++)n+="STYLE\n"+t[i]+"\n\n";for(i=0;i<e.length;i++)n+=r(e[i]);return n}};function s(e){e.WebVTTParser=t,e.WebVTTCueTimingsAndSettingsParser=r,e.WebVTTCueTextParser=i,e.WebVTTSerializer=a}"undefined"!=typeof window&&s(window),s(n)}()},{"@swc/helpers/src/_object_spread.mjs":"1LSQ7","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}]},["2hz0c"],"2hz0c","parcelRequire4dc0");