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S,GAGf,IAAK,IAAIzM,EAAI,EAAGA,EAAIgoB,EAAW/nB,OAAQD,IAAK,CACxC,MAAM8mB,EAAQkB,EAAWhoB,GACnBkoB,EAAgB,GAChBL,EAAoBJ,EAAsBX,EAAOmB,GACvD,GAAIJ,EAAkB5nB,OAAS,EAC3B,IAAK,IAAIkB,EAAI,EAAGA,EAAI0mB,EAAkB5nB,OAAQkB,IAAK,CAC/C,MAAM2mB,EAAmBD,EAAkB1mB,GAC3C+mB,EAAcrmB,KAAK,CACflC,MAAO8T,KAAKc,IAAIuS,EAAMnnB,MAAOmoB,EAAiBnoB,OAC9CU,IAAKoT,KAAKE,IAAImT,EAAMzmB,IAAKynB,EAAiBznB,MAElD,CAEJ,GAA6B,IAAzB6nB,EAAcjoB,OACdwM,EAAO5K,KAAKilB,OAEX,CACD,IAAIqB,EAAYrB,EAAMnnB,MACtB,IAAK,IAAIwB,EAAI,EAAGA,EAAI+mB,EAAcjoB,OAAQkB,IAClC+mB,EAAc/mB,GAAGxB,MAAQwoB,GACzB1b,EAAO5K,KAAK,CAAElC,MAAOwoB,EAAW9nB,IAAK6nB,EAAc/mB,GAAGxB,QAE1DwoB,EAAYD,EAAc/mB,GAAGd,IAE7B8nB,EAAYrB,EAAMzmB,KAClBoM,EAAO5K,KAAK,CAAElC,MAAOwoB,EAAW9nB,IAAKymB,EAAMzmB,KAEnD,CACJ,CACA,OAAOoM,CACX,C","sources":["webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/features/add_features.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/features/features_object.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/features/index.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/sami/html.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/features/list/html_sami_parser.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/html/apply_default_ttml_paragraph_style.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/compat/add_class_name.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/html/generate_css_test_outline.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/html/ttml_color_to_css_color.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/html/create_element.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/html/apply_font_size.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/html/apply_extent.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/html/apply_padding.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/html/apply_origin.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/html/apply_line_height.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/html/parse_cue.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/html/index.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/html/parse_ttml_to_div.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/features/list/html_ttml_parser.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/webvtt/html/create_default_style_elements.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/webvtt/html/parse_style_block.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/webvtt/html/create_styled_element.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/webvtt/html/create_style_attribute.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/webvtt/html/to_html.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/webvtt/html/convert_payload_to_html.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/webvtt/html/index.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/webvtt/html/parse_webvtt_to_div.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/webvtt/get_style_blocks.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/features/list/html_vtt_parser.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/compat/on_height_width_change.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/main_thread/text_displayer/html/utils.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/main_thread/text_displayer/html/text_track_cues_store.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/main_thread/text_displayer/html/update_proportional_elements.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/main_thread/text_displayer/html/html_text_displayer.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/main_thread/text_displayer/html/index.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/main_thread/text_displayer/html/html_parsers.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/main_thread/text_displayer/manual_time_ranges.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/get_styling.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/time_parsing.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/get_time_delimiters.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/get_parameters.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/parse_ttml.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/resolve_styles_inheritance.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/regexps.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/ttml/xml_utils.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/webvtt/get_cue_blocks.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/webvtt/parse_timestamp.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/webvtt/parse_cue_block.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/parsers/texttracks/webvtt/utils.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/utils/array_includes.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/utils/object_values.js","webpack://@canalplus/oneplayer/../../node_modules/rx-player/dist/es2017/utils/ranges.js"],"sourcesContent":["/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIE OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport isNullOrUndefined from \"../utils/is_null_or_undefined\";\nimport features from \"./features_object\";\n/**\n * @param {Array.} featureFuncList\n */\nexport default function addFeatures(featureFuncList) {\n for (const addFeature of featureFuncList) {\n if (typeof addFeature === \"function\") {\n addFeature(features);\n }\n else if (!isNullOrUndefined(addFeature) &&\n typeof addFeature._addFeature === \"function\") {\n addFeature._addFeature(features);\n }\n else {\n throw new Error(\"Unrecognized feature\");\n }\n }\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Initial features object, with no feature activated by default.\n * @type {Object}\n */\nconst features = {\n dashParsers: { wasm: null, native: null, fastJs: null },\n createDebugElement: null,\n directfile: null,\n decrypt: null,\n htmlTextDisplayer: null,\n htmlTextTracksParsers: {},\n mainThreadMediaSourceInit: null,\n multithread: null,\n nativeTextDisplayer: null,\n nativeTextTracksParsers: {},\n transports: {},\n};\nexport default features;\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * File allowing feature-switching.\n *\n * Every optional feature is included here.\n * They all should subsequently be accessed in the code through the exported\n * `features` object.\n *\n * The then exported features object will be used dynamically to know which\n * features are activated.\n *\n * This also lazy-feature loading, where this exported object can be updated\n * at runtime, to allow some new features even if the player instance has\n * already have been instanciated.\n */\nimport addFeatures from \"./add_features\";\nimport features from \"./features_object\";\nexport default features;\nexport { addFeatures };\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// __VERY__ simple SAMI parser, based on ugly-but-working REGEXP:\n// - the text, start and end times are correctly parsed.\n// - only text for the given language is parsed.\n// - only the CSS style associated to the P element is set.\n// - we should be safe for any XSS.\n// The language indicated to the parser should be present in the CSS and the\n// corresponding Class should be on the P elements. If we fail to find the\n// language in a \"lang\" property of a CSS class, the parser will throw.\n/**\n * /!\\ This file is feature-switchable.\n * It always should be imported through the `features` object.\n */\nimport isNonEmptyString from \"../../../utils/is_non_empty_string\";\nimport isNullOrUndefined from \"../../../utils/is_null_or_undefined\";\nconst HTML_ENTITIES = /&#([0-9]+);/g;\nconst BR = /
/gi;\nconst STYLE = /]*>([\\s\\S]*?)<\\/style[^>]*>/i;\nconst PARAG = /\\s*

]+))?>(.*)/i;\nconst START = /]+?start=\"?([0-9]*)\"?[^0-9]/i;\n/**\n * Returns classnames for every languages.\n * @param {string} str\n * @returns {Object}\n */\nfunction getClassNameByLang(str) {\n const ruleRe = /\\.(\\S+)\\s*{([^}]*)}/gi;\n const langs = {};\n let m = ruleRe.exec(str);\n while (m !== null) {\n const name = m[1];\n const lang = getCSSProperty(m[2], \"lang\");\n if (!isNullOrUndefined(name) && !isNullOrUndefined(lang)) {\n langs[lang] = name;\n }\n m = ruleRe.exec(str);\n }\n return langs;\n}\n/**\n * Returns the rules defined for the P element.\n * Empty string if not found.\n * @param {string} str - The entire styling part.\n * @returns {string}\n */\nfunction getPCSSRules(str) {\n const pRuleRegex = /p\\s*{([^}]*)}/gi;\n const rule = pRuleRegex.exec(str);\n if (rule === null) {\n return \"\";\n }\n return rule[1];\n}\n/**\n * @param {string} str - entire CSS rule\n * @param {string} name - name of the property\n * @returns {string|null} - value of the property. Null if not found.\n */\nfunction getCSSProperty(str, name) {\n const matches = new RegExp(\"\\\\s*\" + name + \":\\\\s*(\\\\S+);\", \"i\").exec(str);\n return Array.isArray(matches) ? matches[1] : null;\n}\n/**\n * @param {string} text\n * @returns {string}\n */\nfunction decodeEntities(text) {\n return text.replace(HTML_ENTITIES, (_, $1) => String.fromCharCode(Number($1)));\n}\n/**\n * Because sami is not really html... we have to use\n * some kind of regular expressions to parse it...\n * the cthulhu way :)\n * The specification being quite clunky, this parser\n * may not work for every sami input.\n *\n * @param {string} smi\n * @param {Number} timeOffset\n * @param {string} lang\n */\nfunction parseSami(smi, timeOffset, lang) {\n const syncOpen = /]/gi;\n const syncClose = /]|<\\/body>/gi;\n const subs = [];\n const styleMatches = STYLE.exec(smi);\n const css = Array.isArray(styleMatches) ? styleMatches[1] : \"\";\n let up;\n let to;\n // FIXME Is that wanted?\n // previously written as let to = SyncClose.exec(smi); but never used\n syncClose.exec(smi);\n const langs = getClassNameByLang(css);\n const pCSS = getPCSSRules(css);\n let klass;\n if (isNonEmptyString(lang)) {\n klass = langs[lang];\n if (klass === undefined) {\n throw new Error(`sami: could not find lang ${lang} in CSS`);\n }\n }\n while (true) {\n up = syncOpen.exec(smi);\n to = syncClose.exec(smi);\n if (up === null && to === null) {\n break;\n }\n if (up === null || to === null || up.index >= to.index) {\n throw new Error(\"parse error\");\n }\n const str = smi.slice(up.index, to.index);\n const tim = START.exec(str);\n if (!Array.isArray(tim)) {\n throw new Error(\"parse error (sync time attribute)\");\n }\n const start = +tim[1];\n if (isNaN(start)) {\n throw new Error(\"parse error (sync time attribute NaN)\");\n }\n appendToSubs(str.split(\"\\n\"), start / 1000);\n }\n return subs;\n function appendToSubs(lines, start) {\n let i = lines.length;\n while (--i >= 0) {\n const paragraphInfos = PARAG.exec(lines[i]);\n if (!Array.isArray(paragraphInfos)) {\n continue;\n }\n const [, className, txt] = paragraphInfos;\n if (klass !== className) {\n continue;\n }\n if (txt === \" \") {\n subs[subs.length - 1].end = start;\n }\n else {\n const wrapperEl = document.createElement(\"DIV\");\n wrapperEl.className = \"rxp-texttrack-region\";\n const divEl = document.createElement(\"DIV\");\n divEl.className = \"rxp-texttrack-div\";\n divEl.style.position = \"absolute\";\n divEl.style.bottom = \"0\";\n divEl.style.width = \"100%\";\n divEl.style.color = \"#fff\";\n divEl.style.textShadow =\n \"-1px -1px 0 #000,\" +\n \"1px -1px 0 #000,\" +\n \"-1px 1px 0 #000,\" +\n \"1px 1px 0 #000\";\n const pEl = document.createElement(\"div\");\n pEl.className = \"rxp-texttrack-p\";\n if (isNonEmptyString(pCSS)) {\n pEl.style.cssText = pCSS;\n }\n const textEls = txt.split(BR);\n for (let j = 0; j < textEls.length; j++) {\n if (j !== 0) {\n pEl.appendChild(document.createElement(\"BR\"));\n }\n const spanEl = document.createElement(\"SPAN\");\n spanEl.className = \"rxp-texttrack-span\";\n spanEl.textContent = decodeEntities(textEls[j]);\n pEl.appendChild(spanEl);\n }\n divEl.appendChild(pEl);\n wrapperEl.appendChild(divEl);\n subs.push({\n element: wrapperEl,\n start: start + timeOffset,\n end: -1 /* Will be updated on a following iteration */,\n });\n }\n }\n }\n}\nexport default parseSami;\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport HTMLTextDisplayer from \"../../main_thread/text_displayer/html\";\nimport samiParser from \"../../parsers/texttracks/sami/html\";\n/**\n * Add ability to parse SAMI text tracks in an HTML textrack mode.\n * @param {Object} features\n */\nfunction addHTMLSAMIFeature(features) {\n features.htmlTextTracksParsers.sami = samiParser;\n features.htmlTextDisplayer = HTMLTextDisplayer;\n}\nexport { addHTMLSAMIFeature as HTML_SAMI_PARSER };\nexport default addHTMLSAMIFeature;\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Return true if no style has been already declared and no conflict is\n * detected with current cue style.\n *\n * No position, orientation and dimension style should have been set to\n * avoid any conflict.\n * @param {object} paragraphStyle\n * @returns {boolean}\n */\nexport function shouldApplyDefaultTTMLStyle(paragraphStyle) {\n return (paragraphStyle.extent === undefined &&\n paragraphStyle.origin === undefined &&\n paragraphStyle.displayAlign === undefined &&\n paragraphStyle.display === undefined &&\n paragraphStyle.textAlign === undefined &&\n paragraphStyle.fontSize === undefined);\n}\n/**\n * Apply a default style to TTML cue.\n *\n * The default style propose to set the cue at the bottom, centered\n * and lightly spaced apart from the edges :\n *\n * -----------------------------------------------\n * | |\n * | |\n * | |\n * | |\n * | |\n * | |\n * | subtitle is displayed |\n * | here |\n * -----------------------------------------------\n *\n * @param {Object} cue\n * TODO This code can be seen as risky because we might not predict every\n * possible styles that can enter in conflict.\n * A better solution should be found in the future\n */\nexport function applyDefaultTTMLStyle(paragraphStyle) {\n paragraphStyle.extent = \"70% 20%\";\n paragraphStyle.fontSize = \"1c\";\n paragraphStyle.origin = \"15% 80%\";\n paragraphStyle.displayAlign = \"before\";\n paragraphStyle.textAlign = \"center\";\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nlet hasClassList;\n/**\n * Add className to an HTMLElement. Do nothing if the className was already\n * added.\n * @param {HTMLElement} elt\n * @param {string} className\n */\nexport default function addClassName(elt, className) {\n if (hasClassList === undefined) {\n hasClassList =\n elt.classList !== undefined &&\n // eslint-disable-next-line @typescript-eslint/unbound-method\n typeof elt.classList.add === \"function\";\n }\n if (hasClassList) {\n elt.classList.add(className);\n }\n else {\n const classNamesWithSpaces = \" \" + elt.className + \" \";\n if (classNamesWithSpaces.indexOf(\" \" + className + \" \") < 0) {\n elt.className += \" \" + className;\n }\n }\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport isNonEmptyString from \"../../../../utils/is_non_empty_string\";\n/**\n * Try to replicate the textOutline TTML style property into CSS.\n *\n * We mock it throught the text-shadow property, translating the TTML thickness\n * into blur radius and the blur-radius into... nothing.\n *\n * @param {string} color\n * @param {string|number} thickness\n * @returns {string}\n */\nexport default function generateCSSTextOutline(color, thickness) {\n let thick = thickness;\n if (isNonEmptyString(thickness) && thickness.trim().endsWith(\"%\")) {\n // As em and % are basically equivalent in CSS\n // (they both are relative to the font-size\n // of the current element)\n // We convert the non supported % into the supported em\n thick = thickness.trim().slice(0, -1);\n thick = (parseInt(thick, 10) / 100).toString() + \"em\";\n }\n return (`-1px -1px ${thick} ${color},` +\n `1px -1px ${thick} ${color},` +\n `-1px 1px ${thick} ${color},` +\n `1px 1px ${thick} ${color}`);\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport isNullOrUndefined from \"../../../../utils/is_null_or_undefined\";\nimport { REGXP_4_HEX_COLOR, REGXP_8_HEX_COLOR, REGXP_RGBA_COLOR, REGXP_RGB_COLOR, } from \"../regexps\";\n/**\n * Translate a color indicated in TTML-style to a CSS-style color.\n * @param {string} color\n * @returns {string} color\n */\nexport default function ttmlColorToCSSColor(color) {\n // TODO check all possible color fomats\n let regRes;\n regRes = REGXP_8_HEX_COLOR.exec(color);\n if (!isNullOrUndefined(regRes)) {\n return (\"rgba(\" +\n String(parseInt(regRes[1], 16)) +\n \",\" +\n String(parseInt(regRes[2], 16)) +\n \",\" +\n String(parseInt(regRes[3], 16)) +\n \",\" +\n String(parseInt(regRes[4], 16) / 255) +\n \")\");\n }\n regRes = REGXP_4_HEX_COLOR.exec(color);\n if (!isNullOrUndefined(regRes)) {\n return (\"rgba(\" +\n String(parseInt(regRes[1] + regRes[1], 16)) +\n \",\" +\n String(parseInt(regRes[2] + regRes[2], 16)) +\n \",\" +\n String(parseInt(regRes[3] + regRes[3], 16)) +\n \",\" +\n String(parseInt(regRes[4] + regRes[4], 16) / 255) +\n \")\");\n }\n regRes = REGXP_RGB_COLOR.exec(color);\n if (!isNullOrUndefined(regRes)) {\n return (\"rgb(\" +\n String(+regRes[1]) +\n \",\" +\n String(+regRes[2]) +\n \",\" +\n String(+regRes[3]) +\n \")\");\n }\n regRes = REGXP_RGBA_COLOR.exec(color);\n if (!isNullOrUndefined(regRes)) {\n return (\"rgba(\" +\n String(+regRes[1]) +\n \",\" +\n String(+regRes[2]) +\n \",\" +\n String(+regRes[3]) +\n \",\" +\n String(+regRes[4] / 255) +\n \")\");\n }\n return color;\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport addClassName from \"../../../../compat/add_class_name\";\nimport isNonEmptyString from \"../../../../utils/is_non_empty_string\";\nimport objectAssign from \"../../../../utils/object_assign\";\nimport { getStylingAttributes } from \"../get_styling\";\nimport { getParentDivElements, isLineBreakElement, isSpanElement } from \"../xml_utils\";\nimport applyExtent from \"./apply_extent\";\nimport applyFontSize from \"./apply_font_size\";\nimport applyLineHeight from \"./apply_line_height\";\nimport applyOrigin from \"./apply_origin\";\nimport applyPadding from \"./apply_padding\";\nimport generateCSSTextOutline from \"./generate_css_test_outline\";\nimport ttmlColorToCSSColor from \"./ttml_color_to_css_color\";\n// Styling which can be applied to from any level upper.\n// Added here as an optimization\nconst SPAN_LEVEL_ATTRIBUTES = [\n \"color\",\n \"direction\",\n \"display\",\n \"fontFamily\",\n \"fontSize\",\n \"fontStyle\",\n \"fontWeight\",\n \"textDecoration\",\n \"textOutline\",\n \"unicodeBidi\",\n \"visibility\",\n \"wrapOption\",\n];\n// TODO\n// tts:showBackground (applies to region)\n// tts:zIndex (applies to region)\n/**\n * Apply style set for a singular text span of the current cue.\n * @param {HTMLElement} element - The text span\n * @param {Object} style - The style to apply\n */\nfunction applyTextStyle(element, style, shouldTrimWhiteSpace) {\n // applies to span\n const color = style.color;\n if (isNonEmptyString(color)) {\n element.style.color = ttmlColorToCSSColor(color);\n }\n // applies to body, div, p, region, span\n const backgroundColor = style.backgroundColor;\n if (isNonEmptyString(backgroundColor)) {\n element.style.backgroundColor = ttmlColorToCSSColor(backgroundColor);\n }\n // applies to span\n const textOutline = style.textOutline;\n if (isNonEmptyString(textOutline)) {\n const outlineData = textOutline.trim().replace(/\\s+/g, \" \").split(\" \");\n const len = outlineData.length;\n if (len === 3) {\n const outlineColor = ttmlColorToCSSColor(outlineData[0]);\n const thickness = outlineData[1];\n element.style.textShadow = generateCSSTextOutline(outlineColor, thickness);\n }\n else if (isNonEmptyString(color) && len === 1) {\n const thickness = outlineData[0];\n element.style.textShadow = generateCSSTextOutline(color, thickness);\n }\n else if (len === 2) {\n const isFirstArgAColor = /^[#A-Z]/i.test(outlineData[0]);\n const isFirstArgANumber = /^[0-9]/.test(outlineData[0]);\n // XOR-ing to be sure we get what we have\n if (isFirstArgAColor !== isFirstArgANumber) {\n if (isFirstArgAColor) {\n const outlineColor = ttmlColorToCSSColor(outlineData[0]);\n const thickness = outlineData[1];\n element.style.textShadow = generateCSSTextOutline(outlineColor, thickness);\n }\n else if (isNonEmptyString(color)) {\n const thickness = outlineData[0];\n element.style.textShadow = generateCSSTextOutline(color, thickness);\n }\n }\n }\n }\n // applies to span\n const textDecoration = style.textDecoration;\n if (isNonEmptyString(textDecoration)) {\n switch (textDecoration) {\n case \"noUnderline\":\n case \"noLineThrough\":\n case \"noOverline\":\n element.style.textDecoration = \"none\";\n break;\n case \"lineThrough\":\n element.style.textDecoration = \"line-through\";\n break;\n default:\n element.style.textDecoration = textDecoration;\n break;\n }\n }\n // applies to span\n const fontFamily = style.fontFamily;\n if (isNonEmptyString(fontFamily)) {\n switch (fontFamily) {\n case \"proportionalSansSerif\":\n element.style.fontFamily = \"Arial, Helvetica, Liberation Sans, sans-serif\";\n break;\n // TODO monospace or sans-serif or font with both?\n case \"monospaceSansSerif\":\n case \"sansSerif\":\n element.style.fontFamily = \"sans-serif\";\n break;\n case \"monospaceSerif\":\n case \"default\":\n element.style.fontFamily = \"Courier New, Liberation Mono, monospace\";\n break;\n // TODO font with both?\n case \"proportionalSerif\":\n element.style.fontFamily = \"serif\";\n break;\n default:\n element.style.fontFamily = fontFamily;\n }\n }\n // applies to span\n const fontStyle = style.fontStyle;\n if (isNonEmptyString(fontStyle)) {\n element.style.fontStyle = fontStyle;\n }\n // applies to span\n const fontWeight = style.fontWeight;\n if (isNonEmptyString(fontWeight)) {\n element.style.fontWeight = fontWeight;\n }\n // applies to span\n const fontSize = style.fontSize;\n if (isNonEmptyString(fontSize)) {\n applyFontSize(element, fontSize);\n }\n else {\n addClassName(element, \"proportional-style\");\n element.setAttribute(\"data-proportional-font-size\", \"1\");\n }\n // applies to p, span\n const direction = style.direction;\n if (isNonEmptyString(direction)) {\n element.style.direction = direction;\n }\n // applies to p, span\n const unicodeBidi = style.unicodeBidi;\n if (isNonEmptyString(unicodeBidi)) {\n switch (unicodeBidi) {\n case \"bidiOverride\":\n element.style.unicodeBidi = \"bidi-override\";\n break;\n case \"embed\":\n element.style.unicodeBidi = \"embed\";\n break;\n default:\n element.style.unicodeBidi = \"normal\";\n }\n }\n // applies to body, div, p, region, span\n const visibility = style.visibility;\n if (isNonEmptyString(visibility)) {\n element.style.visibility = visibility;\n }\n // applies to body, div, p, region, span\n const display = style.display;\n if (display === \"none\") {\n element.style.display = \"none\";\n }\n // applies to body, div, p, region, span\n const wrapOption = style.wrapOption;\n if (wrapOption === \"noWrap\") {\n if (shouldTrimWhiteSpace) {\n element.style.whiteSpace = \"nowrap\";\n }\n else {\n element.style.whiteSpace = \"pre\";\n }\n }\n else if (shouldTrimWhiteSpace) {\n element.style.whiteSpace = \"normal\";\n }\n else {\n element.style.whiteSpace = \"pre-wrap\";\n }\n}\n/**\n * Apply style for the general text track div.\n * @param {HTMLElement} element - The

the style will be applied on.\n * @param {Object} style - The general style object of the paragraph.\n */\nfunction applyGeneralStyle(element, style) {\n // Set default text color. It can be overrided by text element color.\n element.style.color = \"white\";\n element.style.position = \"absolute\";\n // applies to tt, region\n const extent = style.extent;\n if (isNonEmptyString(extent)) {\n applyExtent(element, extent);\n }\n // applies to region\n const writingMode = style.writingMode;\n if (isNonEmptyString(writingMode)) {\n // TODO\n }\n // applies to region\n const overflow = style.overflow;\n element.style.overflow = isNonEmptyString(overflow) ? overflow : \"hidden\";\n // applies to region\n const padding = style.padding;\n if (isNonEmptyString(padding)) {\n applyPadding(element, padding);\n }\n // applies to region\n const origin = style.origin;\n if (isNonEmptyString(origin)) {\n applyOrigin(element, origin);\n }\n // applies to region\n const displayAlign = style.displayAlign;\n if (isNonEmptyString(displayAlign)) {\n element.style.display = \"flex\";\n element.style.flexDirection = \"column\";\n switch (displayAlign) {\n case \"before\":\n element.style.justifyContent = \"flex-start\";\n break;\n case \"center\":\n element.style.justifyContent = \"center\";\n break;\n case \"after\":\n element.style.justifyContent = \"flex-end\";\n break;\n }\n }\n // applies to region\n const opacity = style.opacity;\n if (isNonEmptyString(opacity)) {\n element.style.opacity = opacity;\n }\n // applies to body, div, p, region, span\n const visibility = style.visibility;\n if (isNonEmptyString(visibility)) {\n element.style.visibility = visibility;\n }\n // applies to body, div, p, region, span\n const display = style.display;\n if (display === \"none\") {\n element.style.display = \"none\";\n }\n}\n/**\n * Apply style set for a

element\n * @param {HTMLElement} element - The

element\n * @param {Object} style - The general style object of the paragraph.\n */\nfunction applyPStyle(element, style) {\n element.style.margin = \"0px\";\n // Set on it the default font-size, more specific font sizes may then be set\n // on children elements.\n // Doing this on the parent

elements seems to fix some CSS issues we had\n // with too large inner line breaks spacing when the text track element was\n // too small, for some reasons.\n addClassName(element, \"proportional-style\");\n element.setAttribute(\"data-proportional-font-size\", \"1\");\n // applies to body, div, p, region, span\n const paragraphBackgroundColor = style.backgroundColor;\n if (isNonEmptyString(paragraphBackgroundColor)) {\n element.style.backgroundColor = ttmlColorToCSSColor(paragraphBackgroundColor);\n }\n // applies to p\n const lineHeight = style.lineHeight;\n if (isNonEmptyString(lineHeight)) {\n applyLineHeight(element, lineHeight);\n }\n // applies to p\n const textAlign = style.textAlign;\n if (isNonEmptyString(textAlign)) {\n switch (textAlign) {\n case \"center\":\n element.style.textAlign = \"center\";\n break;\n case \"left\":\n case \"start\":\n // TODO check what start means (difference with left, writing direction?)\n element.style.textAlign = \"left\";\n break;\n case \"right\":\n case \"end\":\n // TODO check what end means (difference with right, writing direction?)\n element.style.textAlign = \"right\";\n break;\n }\n }\n}\n/**\n * Creates span of text for the given #text element, with the right style.\n *\n * TODO create text elements as string? Might help performances.\n * @param {Element} el - the #text element, which text content should be\n * displayed\n * @param {Object} style - the style object for the given text\n * @param {Boolean} shouldTrimWhiteSpace - True if the space should be\n * trimmed.\n * @returns {HTMLElement}\n */\nfunction createTextElement(el, style, shouldTrimWhiteSpace) {\n const textElement = document.createElement(\"span\");\n let textContent = el.textContent === null ? \"\" : el.textContent;\n if (shouldTrimWhiteSpace) {\n // 1. Trim leading and trailing whitespace.\n // 2. Collapse multiple spaces into one.\n let trimmed = textContent.trim();\n trimmed = trimmed.replace(/\\s+/g, \" \");\n textContent = trimmed;\n }\n const textNode = document.createTextNode(textContent);\n textElement.appendChild(textNode);\n textElement.className = \"rxp-texttrack-span\";\n applyTextStyle(textElement, style, shouldTrimWhiteSpace);\n return textElement;\n}\n/**\n * Generate every text elements to display in a given paragraph.\n * @param {Element} paragraph - The

tag.\n * @param {Array.} regions\n * @param {Array.} styles\n * @param {Object} paragraphStyle - The general style object of the paragraph.\n * @param {Boolean} shouldTrimWhiteSpace\n * @returns {Array.}\n */\nfunction generateTextContent(paragraph, regions, styles, paragraphStyle, shouldTrimWhiteSpace) {\n /**\n * Recursive function, taking a node in argument and returning the\n * corresponding array of HTMLElement in order.\n * @param {Node} node - the node in question\n * @param {Object} style - the current state of the style for the node.\n * /!\\ The style object can be mutated, provide a copy of it.\n * @param {Array.} spans - The spans parent of this node.\n * @param {Boolean} shouldTrimWhiteSpaceFromParent - True if the space should be\n * trimmed by default. From the parent xml:space parameter.\n * @returns {Array.}\n */\n function loop(node, style, spans, shouldTrimWhiteSpaceFromParent) {\n const childNodes = node.childNodes;\n const elements = [];\n for (let i = 0; i < childNodes.length; i++) {\n const currentNode = childNodes[i];\n if (currentNode.nodeName === \"#text\") {\n const { backgroundColor } = getStylingAttributes([\"backgroundColor\"], spans, styles, regions);\n if (isNonEmptyString(backgroundColor)) {\n style.backgroundColor = backgroundColor;\n }\n else {\n style.backgroundColor = \"\";\n }\n const el = createTextElement(currentNode, style, shouldTrimWhiteSpaceFromParent);\n elements.push(el);\n }\n else if (isLineBreakElement(currentNode)) {\n const br = document.createElement(\"BR\");\n elements.push(br);\n }\n else if (isSpanElement(currentNode) &&\n currentNode.nodeType === Node.ELEMENT_NODE &&\n currentNode.childNodes.length > 0) {\n const spaceAttribute = currentNode.getAttribute(\"xml:space\");\n const shouldTrimWhiteSpaceOnSpan = isNonEmptyString(spaceAttribute)\n ? spaceAttribute === \"default\"\n : shouldTrimWhiteSpaceFromParent;\n // compute the new applyable style\n const newStyle = objectAssign({}, style, getStylingAttributes(SPAN_LEVEL_ATTRIBUTES, [currentNode], styles, regions));\n elements.push(...loop(currentNode, newStyle, [currentNode, ...spans], shouldTrimWhiteSpaceOnSpan));\n }\n }\n return elements;\n }\n return loop(paragraph, objectAssign({}, paragraphStyle), [], shouldTrimWhiteSpace);\n}\n/**\n * @param {Element} paragraph\n * @param {Element} body\n * @param {Array.} regions\n * @param {Array.} styles\n * @param {Object} paragraphStyle\n * @param {Object}\n * @returns {HTMLElement}\n */\nexport default function createElement(paragraph, body, regions, styles, paragraphStyle, { cellResolution, shouldTrimWhiteSpace, }) {\n const divs = getParentDivElements(paragraph);\n const parentElement = document.createElement(\"DIV\");\n parentElement.className = \"rxp-texttrack-region\";\n parentElement.setAttribute(\"data-resolution-columns\", String(cellResolution.columns));\n parentElement.setAttribute(\"data-resolution-rows\", String(cellResolution.rows));\n applyGeneralStyle(parentElement, paragraphStyle);\n if (body !== null) {\n // applies to body, div, p, region, span\n const { bodyBackgroundColor } = getStylingAttributes([\"backgroundColor\"], [...divs, body], styles, regions);\n if (isNonEmptyString(bodyBackgroundColor)) {\n parentElement.style.backgroundColor = ttmlColorToCSSColor(bodyBackgroundColor);\n }\n }\n const pElement = document.createElement(\"p\");\n pElement.className = \"rxp-texttrack-p\";\n applyPStyle(pElement, paragraphStyle);\n const textContent = generateTextContent(paragraph, regions, styles, paragraphStyle, shouldTrimWhiteSpace);\n for (let i = 0; i < textContent.length; i++) {\n pElement.appendChild(textContent[i]);\n }\n // NOTE:\n // The following code is for the inclusion of div elements. This has no\n // advantage for now, and might only with future evolutions.\n // (This is only an indication of what the base of the code could look like).\n // if (divs.length) {\n // let container = parentElement;\n // for (let i = divs.length - 1; i >= 0; i--) {\n // // TODO manage style at div level?\n // // They are: visibility, display and backgroundColor\n // // All these do not have any difference if applied to the

element\n // // instead of the div.\n // // The advantage might only be for multiple

elements dispatched\n // // in multiple div Which we do not manage anyway for now.\n // const divEl = document.createElement(\"DIV\");\n // divEl.className = \"rxp-texttrack-div\";\n // container.appendChild(divEl);\n // container = divEl;\n // }\n // container.appendChild(pElement);\n // parentElement.appendChild(container);\n // } else {\n // parentElement.appendChild(pElement);\n // }\n parentElement.appendChild(pElement);\n return parentElement;\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport addClassName from \"../../../../compat/add_class_name\";\nimport log from \"../../../../log\";\nimport { REGXP_LENGTH } from \"../regexps\";\n/**\n * Apply `tts:fontSize` styling to an HTML element.\n * @param {HTMLElement} element\n * @param {string} fontSize\n */\nexport default function applyFontSize(element, fontSize) {\n const trimmedFontSize = fontSize.trim();\n const splittedFontSize = trimmedFontSize.split(\" \");\n if (splittedFontSize.length === 0) {\n return;\n }\n const firstFontSize = REGXP_LENGTH.exec(splittedFontSize[0]);\n if (firstFontSize === null) {\n return;\n }\n if (firstFontSize[2] === \"px\" || firstFontSize[2] === \"em\") {\n element.style.fontSize = firstFontSize[1] + firstFontSize[2];\n }\n else if (firstFontSize[2] === \"c\") {\n element.style.position = \"relative\";\n addClassName(element, \"proportional-style\");\n element.setAttribute(\"data-proportional-font-size\", firstFontSize[1]);\n }\n else if (firstFontSize[2] === \"%\") {\n const toNum = Number(firstFontSize[1]);\n if (isNaN(toNum)) {\n log.warn('TTML Parser: could not parse fontSize value \"' +\n firstFontSize[1] +\n '\" into a number');\n }\n else {\n element.style.position = \"relative\";\n addClassName(element, \"proportional-style\");\n element.setAttribute(\"data-proportional-font-size\", String(toNum / 100));\n }\n }\n else {\n log.warn(\"TTML Parser: unhandled fontSize unit:\", firstFontSize[2]);\n }\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport addClassName from \"../../../../compat/add_class_name\";\nimport log from \"../../../../log\";\nimport { REGXP_LENGTH } from \"../regexps\";\n/**\n * Apply `tts:extent` styling to an HTML element.\n * @param {HTMLElement} element\n * @param {string} extent\n */\nexport default function applyExtent(element, extent) {\n const trimmedExtent = extent.trim();\n if (trimmedExtent === \"auto\") {\n return;\n }\n const splittedExtent = trimmedExtent.split(\" \");\n if (splittedExtent.length !== 2) {\n return;\n }\n const firstExtent = REGXP_LENGTH.exec(splittedExtent[0]);\n const secondExtent = REGXP_LENGTH.exec(splittedExtent[1]);\n if (firstExtent !== null && secondExtent !== null) {\n if (firstExtent[2] === \"px\" || firstExtent[2] === \"%\" || firstExtent[2] === \"em\") {\n element.style.width = firstExtent[1] + firstExtent[2];\n }\n else if (firstExtent[2] === \"c\") {\n addClassName(element, \"proportional-style\");\n element.setAttribute(\"data-proportional-width\", firstExtent[1]);\n }\n else {\n log.warn(\"TTML Parser: unhandled extent unit:\", firstExtent[2]);\n }\n if (secondExtent[2] === \"px\" || secondExtent[2] === \"%\" || secondExtent[2] === \"em\") {\n const toNum = Number(secondExtent[1]);\n if (secondExtent[2] === \"%\" && !isNaN(toNum) && (toNum < 0 || toNum > 100)) {\n element.style.width = \"80%\";\n }\n else {\n element.style.height = secondExtent[1] + secondExtent[2];\n }\n }\n else if (secondExtent[2] === \"c\") {\n addClassName(element, \"proportional-style\");\n element.setAttribute(\"data-proportional-height\", secondExtent[1]);\n }\n else {\n log.warn(\"TTML Parser: unhandled extent unit:\", secondExtent[2]);\n }\n }\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport addClassName from \"../../../../compat/add_class_name\";\nimport log from \"../../../../log\";\nimport { REGXP_LENGTH } from \"../regexps\";\n/**\n * @param {HTMLElement} element\n * @param {string} padding\n */\nexport default function applyPadding(element, padding) {\n const trimmedPadding = padding.trim();\n const splittedPadding = trimmedPadding.split(\" \");\n if (splittedPadding.length < 1) {\n return;\n }\n const firstPadding = REGXP_LENGTH.exec(splittedPadding[0]);\n if (firstPadding === null) {\n return;\n }\n if (firstPadding[2] === \"px\" || firstPadding[2] === \"%\" || firstPadding[2] === \"em\") {\n const firstPaddingValue = firstPadding[1] + firstPadding[2];\n if (splittedPadding.length === 1) {\n element.style.padding = firstPaddingValue;\n }\n else if (splittedPadding.length === 2) {\n element.style.paddingTop = firstPaddingValue;\n element.style.paddingBottom = firstPaddingValue;\n }\n else {\n element.style.paddingTop = firstPaddingValue;\n }\n }\n else if (firstPadding[2] === \"c\") {\n addClassName(element, \"proportional-style\");\n if (splittedPadding.length === 1) {\n element.setAttribute(\"data-proportional-padding-top\", firstPadding[1]);\n element.setAttribute(\"data-proportional-padding-bottom\", firstPadding[1]);\n element.setAttribute(\"data-proportional-padding-left\", firstPadding[1]);\n element.setAttribute(\"data-proportional-padding-right\", firstPadding[1]);\n }\n else if (splittedPadding.length === 2) {\n element.setAttribute(\"data-proportional-padding-top\", firstPadding[1]);\n element.setAttribute(\"data-proportional-padding-bottom\", firstPadding[1]);\n }\n else {\n element.setAttribute(\"data-proportional-padding-top\", firstPadding[1]);\n }\n }\n else {\n log.warn(\"TTML Parser: unhandled padding unit:\", firstPadding[2]);\n }\n if (splittedPadding.length === 1) {\n return;\n }\n const secondPadding = REGXP_LENGTH.exec(splittedPadding[1]);\n if (secondPadding === null) {\n return;\n }\n if (secondPadding[2] === \"px\" ||\n secondPadding[2] === \"%\" ||\n secondPadding[2] === \"em\") {\n const secondPaddingValue = secondPadding[1] + secondPadding[2];\n if (splittedPadding.length < 4) {\n element.style.paddingLeft = secondPaddingValue;\n element.style.paddingRight = secondPaddingValue;\n }\n else {\n element.style.paddingRight = secondPaddingValue;\n }\n }\n else if (secondPadding[2] === \"c\") {\n addClassName(element, \"proportional-style\");\n if (splittedPadding.length < 4) {\n element.setAttribute(\"data-proportional-padding-left\", secondPadding[1]);\n element.setAttribute(\"data-proportional-padding-right\", secondPadding[1]);\n }\n else {\n element.setAttribute(\"data-proportional-padding-right\", secondPadding[1]);\n }\n }\n else {\n log.warn(\"TTML Parser: unhandled padding unit:\", secondPadding[2]);\n }\n if (splittedPadding.length === 2) {\n return;\n }\n const thirdPadding = REGXP_LENGTH.exec(splittedPadding[2]);\n if (thirdPadding === null) {\n return;\n }\n if (thirdPadding[2] === \"px\" || thirdPadding[2] === \"%\" || thirdPadding[2] === \"em\") {\n const thirdPaddingValue = thirdPadding[1] + thirdPadding[2];\n element.style.paddingBottom = thirdPaddingValue;\n }\n else if (thirdPadding[2] === \"c\") {\n addClassName(element, \"proportional-style\");\n element.setAttribute(\"data-proportional-padding-bottom\", thirdPadding[1]);\n }\n else {\n log.warn(\"TTML Parser: unhandled padding unit:\", thirdPadding[2]);\n }\n if (splittedPadding.length === 3) {\n return;\n }\n const fourthPadding = REGXP_LENGTH.exec(splittedPadding[3]);\n if (fourthPadding === null) {\n return;\n }\n if (fourthPadding[2] === \"px\" ||\n fourthPadding[2] === \"%\" ||\n fourthPadding[2] === \"em\") {\n const fourthPaddingValue = fourthPadding[1] + fourthPadding[2];\n element.style.paddingLeft = fourthPaddingValue;\n }\n else if (fourthPadding[2] === \"c\") {\n addClassName(element, \"proportional-style\");\n element.setAttribute(\"data-proportional-padding-left\", fourthPadding[1]);\n }\n else {\n log.warn(\"TTML Parser: unhandled padding unit:\", fourthPadding[2]);\n }\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport addClassName from \"../../../../compat/add_class_name\";\nimport log from \"../../../../log\";\nimport { REGXP_LENGTH } from \"../regexps\";\n/**\n * @param {HTMLElement} element\n * @param {string} origin\n */\nexport default function applyOrigin(element, origin) {\n const trimmedOrigin = origin.trim();\n if (trimmedOrigin === \"auto\") {\n return;\n }\n const splittedOrigin = trimmedOrigin.split(\" \");\n if (splittedOrigin.length !== 2) {\n return;\n }\n const firstOrigin = REGXP_LENGTH.exec(splittedOrigin[0]);\n const secondOrigin = REGXP_LENGTH.exec(splittedOrigin[1]);\n if (firstOrigin !== null && secondOrigin !== null) {\n if (firstOrigin[2] === \"px\" || firstOrigin[2] === \"%\" || firstOrigin[2] === \"em\") {\n element.style.left = firstOrigin[1] + firstOrigin[2];\n }\n else if (firstOrigin[2] === \"c\") {\n addClassName(element, \"proportional-style\");\n element.setAttribute(\"data-proportional-left\", firstOrigin[1]);\n }\n else {\n log.warn(\"TTML Parser: unhandled origin unit:\", firstOrigin[2]);\n }\n if (secondOrigin[2] === \"px\" || secondOrigin[2] === \"%\" || secondOrigin[2] === \"em\") {\n const toNum = Number(secondOrigin[1]);\n if (secondOrigin[2] === \"%\" && !isNaN(toNum) &&\n (toNum < 0 || toNum > 100)) {\n element.style.bottom = \"5%\";\n element.style.left = \"10%\";\n }\n else {\n element.style.top = secondOrigin[1] + secondOrigin[2];\n }\n }\n else if (secondOrigin[2] === \"c\") {\n addClassName(element, \"proportional-style\");\n element.setAttribute(\"data-proportional-top\", secondOrigin[1]);\n }\n else {\n log.warn(\"TTML Parser: unhandled origin unit:\", secondOrigin[2]);\n }\n }\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport log from \"../../../../log\";\nimport { REGXP_LENGTH } from \"../regexps\";\n/**\n * @param {HTMLElement} _element\n * @param {string} lineHeight\n */\nexport default function applyLineHeight(_element, lineHeight) {\n const trimmedLineHeight = lineHeight.trim();\n const splittedLineHeight = trimmedLineHeight.split(\" \");\n if (trimmedLineHeight === \"auto\") {\n return;\n }\n const firstLineHeight = REGXP_LENGTH.exec(splittedLineHeight[0]);\n if (firstLineHeight === null) {\n return;\n }\n if (firstLineHeight[2] === \"px\" ||\n firstLineHeight[2] === \"%\" ||\n firstLineHeight[2] === \"em\") {\n // element.style.lineHeight = firstLineHeight[1] + firstLineHeight[2];\n }\n else if (firstLineHeight[2] === \"c\") {\n // addClassName(element, \"proportional-style\");\n // element.setAttribute(\"data-proportional-line-height\", firstLineHeight[1]);\n }\n else {\n log.warn(\"TTML Parser: unhandled lineHeight unit:\", firstLineHeight[2]);\n }\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport getTimeDelimiters from \"../get_time_delimiters\";\nimport createElement from \"./create_element\";\n/**\n * @param {Object} parsedCue\n * @returns {Object|null}\n */\nexport default function parseCue(parsedCue) {\n const { paragraph, ttParams, body, regionStyles, idStyles, paragraphStyle, timeOffset, shouldTrimWhiteSpace, } = parsedCue;\n // Disregard empty elements:\n // TTML allows for empty elements like

.\n // If paragraph has neither time attributes, nor\n // non-whitespace text, don't try to make a cue out of it.\n if (!paragraph.hasAttribute(\"begin\") &&\n !paragraph.hasAttribute(\"end\") &&\n /^\\s*$/.test(paragraph.textContent === null ? \"\" : paragraph.textContent)) {\n return null;\n }\n const { cellResolution } = ttParams;\n const { start, end } = getTimeDelimiters(paragraph, ttParams);\n const element = createElement(paragraph, body, regionStyles, idStyles, paragraphStyle, {\n cellResolution,\n shouldTrimWhiteSpace,\n });\n return { start: start + timeOffset, end: end + timeOffset, element };\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * /!\\ This file is feature-switchable.\n * It always should be imported through the `features` object.\n */\nimport parseTTMLStringToDIV from \"./parse_ttml_to_div\";\nexport default parseTTMLStringToDIV;\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport parseTtml from \"../parse_ttml\";\nimport { applyDefaultTTMLStyle, shouldApplyDefaultTTMLStyle, } from \"./apply_default_ttml_paragraph_style\";\nimport parseCue from \"./parse_cue\";\n/**\n * Create array of objects which should represent the given TTML text track.\n * These objects have the following structure\n * - start {Number}: start time, in seconds, at which the cue should\n * be displayed\n * - end {Number}: end time, in seconds, at which the cue should\n * be displayed\n * - element {HTMLElement}:
element representing the cue, with the\n * right style. This div should then be appended to an element having\n * the exact size of the wanted region the text track provide cues for.\n *\n * TODO TTML parsing is still pretty heavy on the CPU.\n * Optimizations have been done, principally to avoid using too much XML APIs,\n * but we can still do better.\n * @param {string} str\n * @param {number} timeOffset\n */\nexport default function parseTTMLToDiv(str, timeOffset) {\n const parsedCues = parseTtml(str, timeOffset);\n const cues = [];\n for (const parsedCue of parsedCues) {\n const { paragraphStyle } = parsedCue;\n if (shouldApplyDefaultTTMLStyle(paragraphStyle)) {\n applyDefaultTTMLStyle(paragraphStyle);\n }\n const cue = parseCue(parsedCue);\n if (cue !== null) {\n cues.push(cue);\n }\n }\n return cues;\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport HTMLTextDisplayer from \"../../main_thread/text_displayer/html\";\nimport ttmlParser from \"../../parsers/texttracks/ttml/html\";\n/**\n * Add ability to parse TTML text tracks in an HTML textrack mode.\n * @param {Object} features\n */\nfunction addHTMLTTMLFeature(features) {\n features.htmlTextTracksParsers.ttml = ttmlParser;\n features.htmlTextDisplayer = HTMLTextDisplayer;\n}\nexport { addHTMLTTMLFeature as HTML_TTML_PARSER };\nexport default addHTMLTTMLFeature;\n","/**\n * Creates default classes defined in the W3 specification\n *\n * https://www.w3.org/TR/webvtt1/#default-classes\n */\nconst colorMap = {\n white: \"#ffffff\",\n lime: \"#00ff00\",\n cyan: \"#00ffff\",\n red: \"#ff0000\",\n yellow: \"#ffff00\",\n magenta: \"#ff00ff\",\n blue: \"#0000ff\",\n black: \"#000000\",\n};\nexport default function createDefaultStyleElements() {\n return Object.keys(colorMap).reduce((result, key) => {\n result[key] = `color: ${colorMap[key]};`;\n result[`bg_${key}`] = `background-color: ${colorMap[key]};`;\n return result;\n }, {});\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport isNonEmptyString from \"../../../../utils/is_non_empty_string\";\nimport createDefaultStyleElements from \"./create_default_style_elements\";\n/**\n * Parse style element from WebVTT.\n * @param {Array.>} styleBlocks\n * @return {Object}\n */\nexport default function parseStyleBlocks(styleBlocks) {\n const classes = createDefaultStyleElements();\n let global = \"\";\n styleBlocks.forEach((styleBlock) => {\n if (styleBlock.length >= 2) {\n for (let index = 1; index < styleBlock.length; index++) {\n let line = styleBlock[index];\n if (Array.isArray(/::cue {/.exec(line))) {\n line = styleBlock[++index];\n while (isNonEmptyString(line) &&\n !(Array.isArray(/}/.exec(line)) || line.length === 0)) {\n global += line;\n line = styleBlock[++index];\n }\n }\n else {\n const classNames = [];\n let cueClassLine = /::cue\\(\\.?(.*?)\\)(?:,| {)/.exec(line);\n while (isNonEmptyString(line) && Array.isArray(cueClassLine)) {\n classNames.push(cueClassLine[1]);\n line = styleBlock[++index];\n cueClassLine = /::cue\\(\\.?(.*?)\\)(?:,| {)/.exec(line);\n }\n let styleContent = \"\";\n while (isNonEmptyString(line) &&\n !(Array.isArray(/}/.exec(line)) || line.length === 0)) {\n styleContent += line;\n line = styleBlock[++index];\n }\n classNames.forEach((className) => {\n const styleElement = classes[className];\n if (styleElement === undefined) {\n classes[className] = styleContent;\n }\n else {\n classes[className] += styleContent;\n }\n });\n }\n }\n }\n });\n return { classes, global };\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport arrayIncludes from \"../../../../utils/array_includes\";\nimport isNonEmptyString from \"../../../../utils/is_non_empty_string\";\n/**\n * Construct an HTMLElement/TextNode representing the given node and apply\n * the right styling on it.\n * @param {Node} baseNode\n * @param {Array.} styleElements\n * @param {Array.} styleClasses\n * @returns {Node}\n */\nexport default function createStyledElement(baseNode, styleElements) {\n const HTMLTags = [\"u\", \"i\", \"b\"];\n const authorizedNodeNames = [\"u\", \"i\", \"b\", \"c\", \"#text\"];\n const mainNodeName = baseNode.nodeName.toLowerCase().split(\".\")[0];\n let nodeWithStyle;\n if (arrayIncludes(authorizedNodeNames, mainNodeName)) {\n if (mainNodeName === \"#text\") {\n const linifiedText = baseNode.wholeText.split(\"\\n\");\n nodeWithStyle = document.createElement(\"span\");\n for (let i = 0; i < linifiedText.length; i++) {\n if (i > 0) {\n nodeWithStyle.appendChild(document.createElement(\"br\"));\n }\n if (linifiedText[i].length > 0) {\n const textNode = document.createTextNode(linifiedText[i]);\n nodeWithStyle.appendChild(textNode);\n }\n }\n }\n else {\n const nodeClasses = baseNode.nodeName.toLowerCase().split(\".\");\n const styleContents = [];\n nodeClasses.forEach((nodeClass) => {\n if (isNonEmptyString(styleElements[nodeClass])) {\n styleContents.push(styleElements[nodeClass]);\n }\n });\n if (styleContents.length !== 0) {\n // If style must be applied\n const attr = document.createAttribute(\"style\");\n styleContents.forEach((styleContent) => {\n attr.value += styleContent;\n });\n const nameClass = arrayIncludes(HTMLTags, mainNodeName) ? mainNodeName : \"span\";\n nodeWithStyle = document.createElement(nameClass);\n nodeWithStyle.setAttributeNode(attr);\n }\n else {\n // If style mustn't be applied. Rebuild element with tag name\n const elementTag = !arrayIncludes(HTMLTags, mainNodeName) ? \"span\" : mainNodeName;\n nodeWithStyle = document.createElement(elementTag);\n }\n for (let j = 0; j < baseNode.childNodes.length; j++) {\n const child = createStyledElement(baseNode.childNodes[j], styleElements);\n nodeWithStyle.appendChild(child);\n }\n }\n }\n else {\n nodeWithStyle = document.createElement(\"span\");\n for (let j = 0; j < baseNode.childNodes.length; j++) {\n const child = createStyledElement(baseNode.childNodes[j], styleElements);\n nodeWithStyle.appendChild(child);\n }\n }\n return nodeWithStyle;\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport objectValues from \"../../../../utils/object_values\";\n/**\n * Construct a DOM attribute reflecting given cue settings\n * @param {Partial>} settings\n * @returns {Attr}\n */\nexport default function createStyleAttribute(settings) {\n const pAttr = document.createAttribute(\"style\");\n pAttr.value = getAttrValue(settings);\n return pAttr;\n}\nconst getAttrValue = (settings) => {\n const hasSettings = settings !== undefined && objectValues(settings).length !== 0;\n if (!hasSettings) {\n return \"text-align:center\";\n }\n const xPositioning = getPositioningX(settings);\n const yPositioning = getPositioningY(settings);\n return (\"position: absolute;\" +\n \"margin: 0;\" +\n `transform: translate(${xPositioning.offset}%,${yPositioning.offset}%);` +\n `width: ${getSizePercentage(settings.size)}%;` +\n `left: ${xPositioning.position}%;` +\n `top: ${yPositioning.position !== null ? `${yPositioning.position}%` : \"auto\"};` +\n `text-align: ${getAlignValue(settings.align)};`);\n};\nvar PositionAlignment;\n(function (PositionAlignment) {\n PositionAlignment[\"LINE_LEFT\"] = \"line-left\";\n PositionAlignment[\"CENTER\"] = \"center\";\n PositionAlignment[\"LINE_RIGHT\"] = \"line-right\";\n})(PositionAlignment || (PositionAlignment = {}));\nvar Align;\n(function (Align) {\n Align[\"LEFT\"] = \"left\";\n Align[\"CENTER\"] = \"center\";\n Align[\"RIGHT\"] = \"right\";\n})(Align || (Align = {}));\nvar LineAlignment;\n(function (LineAlignment) {\n LineAlignment[\"START\"] = \"start\";\n LineAlignment[\"CENTER\"] = \"center\";\n LineAlignment[\"END\"] = \"end\";\n})(LineAlignment || (LineAlignment = {}));\nconst getPositioningX = (settings) => {\n return {\n position: getXPositionPercentage(settings),\n offset: getXOffsetPercentage(settings),\n };\n};\nconst getXPositionPercentage = (settings) => {\n const positionPercentage = getPercentageValue(settings.position);\n if (positionPercentage !== null) {\n return positionPercentage;\n }\n const align = getAlignValue(settings.align);\n const alignMap = {\n [Align.LEFT]: 0,\n [Align.CENTER]: 50,\n [Align.RIGHT]: 100,\n };\n return alignMap[align];\n};\nconst getXOffsetPercentage = (settings) => {\n const getPositionAlignment = (positionSetting) => {\n const positionRegex = /,(line-left|line-right|center)/;\n const matches = positionRegex.exec(positionSetting);\n if (!Array.isArray(matches) || matches.length < 2) {\n return null;\n }\n return matches[1];\n };\n const positionAlignmentMap = {\n [PositionAlignment.LINE_LEFT]: 0,\n [PositionAlignment.CENTER]: -50,\n [PositionAlignment.LINE_RIGHT]: -100,\n };\n const positionAlignment = settings.position !== undefined ? getPositionAlignment(settings.position) : null;\n if (positionAlignment !== null) {\n return positionAlignmentMap[positionAlignment];\n }\n const alignMap = {\n [Align.LEFT]: 0,\n [Align.CENTER]: -50,\n [Align.RIGHT]: -100,\n };\n const align = settings.align !== undefined ? getAlignValue(settings.align) : Align.CENTER;\n return alignMap[align];\n};\nconst getPositioningY = (settings) => {\n return {\n position: getYPositionPercentage(settings.line),\n offset: getYOffsetPercentage(settings.line),\n };\n};\nconst getYPositionPercentage = (lineSetting) => {\n return getPercentageValue(lineSetting);\n};\nconst getYOffsetPercentage = (lineSetting) => {\n const getLineAlignment = (line) => {\n const positionRegex = /,(start|center|end)/;\n const matches = positionRegex.exec(line);\n if (!Array.isArray(matches) || matches.length < 2) {\n return null;\n }\n return matches[1];\n };\n const lineAlignmentMap = {\n [LineAlignment.START]: 0,\n [LineAlignment.CENTER]: -50,\n [LineAlignment.END]: -100,\n };\n if (lineSetting === undefined) {\n return lineAlignmentMap[LineAlignment.START];\n }\n const lineAlignment = getLineAlignment(lineSetting);\n return lineAlignment !== null\n ? lineAlignmentMap[lineAlignment]\n : lineAlignmentMap[LineAlignment.START];\n};\nconst getAlignValue = (alignSetting) => {\n switch (alignSetting) {\n case \"left\":\n case \"start\":\n return \"left\";\n case \"right\":\n case \"end\":\n return \"right\";\n default:\n return \"center\";\n }\n};\nconst getSizePercentage = (sizeSetting) => {\n const defaultSize = 100;\n return getPercentageValueOrDefault(sizeSetting, defaultSize);\n};\nconst getPercentageValueOrDefault = (percentageString, defaultValue) => {\n const value = getPercentageValue(percentageString);\n return value !== null ? value : defaultValue;\n};\nconst getPercentageValue = (percentageString) => {\n if (percentageString === undefined) {\n return null;\n }\n const percentageValueRegex = /^([\\d.]+)%/;\n const matches = percentageValueRegex.exec(percentageString);\n if (!Array.isArray(matches) || matches.length < 2) {\n return null;\n }\n return parseInt(matches[1], 10);\n};\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport isNonEmptyString from \"../../../../utils/is_non_empty_string\";\nimport convertPayloadToHTML from \"./convert_payload_to_html\";\nimport createStyleAttribute from \"./create_style_attribute\";\n/**\n * Parse cue block into an object with the following properties:\n * - start {number}: start time at which the cue should be displayed\n * - end {number}: end time at which the cue should be displayed\n * - element {HTMLElement}: the cue text, translated into an HTMLElement\n *\n * Returns undefined if the cue block could not be parsed.\n * @param {Object} cueObj\n * @param {Number} cueObj.start\n * @param {Number} cueObj.end\n * @param {Object} cueObj.settings;\n * @param {string|undefined} cueObj.header\n * @param {Array.} cueObj.payload\n * @param {Object} styling\n * @param {Object} styling.classes\n * @param {string|undefined} styling.global\n * @returns {Object|undefined}\n */\nexport default function toHTML(cueObj, styling) {\n const { start, end, settings, header, payload } = cueObj;\n const region = document.createElement(\"div\");\n const regionAttr = document.createAttribute(\"style\");\n regionAttr.value =\n \"width:100%;\" +\n \"height:100%;\" +\n \"display:flex;\" +\n \"flex-direction:column;\" +\n \"justify-content:flex-end;\" +\n \"align-items:center;\";\n region.setAttributeNode(regionAttr);\n // Get content, format and apply style.\n const pElement = document.createElement(\"p\");\n const pAttr = createStyleAttribute(settings);\n pElement.setAttributeNode(pAttr);\n const spanElement = document.createElement(\"span\");\n const attr = document.createAttribute(\"style\");\n // set color and background-color default values, as indicated in:\n // https://www.w3.org/TR/webvtt1/#applying-css-properties\n attr.value = \"background-color:rgba(0,0,0,0.8);\" + \"color:white;\";\n spanElement.setAttributeNode(attr);\n const { global, classes } = styling;\n const localStyle = isNonEmptyString(header) ? classes[header] : undefined;\n const styles = [global, localStyle].filter((s) => s !== undefined).join(\"\");\n attr.value += styles;\n spanElement.setAttributeNode(attr);\n convertPayloadToHTML(payload.join(\"\\n\"), classes).forEach((element) => {\n spanElement.appendChild(element);\n });\n region.appendChild(pElement);\n pElement.appendChild(spanElement);\n return { start, end, element: region };\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport createStyledElement from \"./create_styled_element\";\n/**\n * @param {string} text\n * @param {Array.} styleElements\n * @returns {Array.}\n */\nexport default function convertPayloadToHTML(text, styleElements) {\n const filteredText = text\n // Remove timestamp tags\n .replace(/<[0-9]{2}:[0-9]{2}.[0-9]{3}>/, \"\")\n // Remove tag content or attributes (e.g. => )\n .replace(/<([u,i,b,c])(\\..*?)?(?: .*?)?>(.*?)<\\/\\1>/g, \"<$1$2>$3\");\n const parsedWebVTT = new DOMParser().parseFromString(filteredText, \"text/html\");\n const nodes = parsedWebVTT.body.childNodes;\n const styledElements = [];\n for (let i = 0; i < nodes.length; i++) {\n styledElements.push(createStyledElement(nodes[i], styleElements));\n }\n return styledElements;\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * /!\\ This file is feature-switchable.\n * It always should be imported through the `features` object.\n */\nimport parseWebVTTToDiv from \"./parse_webvtt_to_div\";\nexport default parseWebVTTToDiv;\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport getCueBlocks from \"../get_cue_blocks\";\nimport getStyleBlocks from \"../get_style_blocks\";\nimport parseCueBlock from \"../parse_cue_block\";\nimport { getFirstLineAfterHeader } from \"../utils\";\nimport parseStyleBlocks from \"./parse_style_block\";\nimport toHTML from \"./to_html\";\n/**\n * Parse WebVTT from text. Returns an array with:\n * - start : start of current cue, in seconds\n * - end : end of current cue, in seconds\n * - content : HTML formatted cue.\n *\n * Global style is parsed and applied to div element.\n * Specific style is parsed and applied to class element.\n *\n * @throws Error - Throws if the given WebVTT string is invalid.\n * @param {string} text - The whole webvtt subtitles to parse\n * @param {Number} timeOffset - Offset to add to start and end times, in seconds\n * @return {Array.}\n */\nexport default function parseWebVTT(text, timeOffset) {\n const newLineChar = /\\r\\n|\\n|\\r/g; // CRLF|LF|CR\n const linified = text.split(newLineChar);\n const cuesArray = [];\n if (/^WEBVTT( |\\t|\\n|\\r|$)/.exec(linified[0]) === null) {\n throw new Error(\"Can't parse WebVTT: Invalid File.\");\n }\n const firstLineAfterHeader = getFirstLineAfterHeader(linified);\n const styleBlocks = getStyleBlocks(linified, firstLineAfterHeader);\n const cueBlocks = getCueBlocks(linified, firstLineAfterHeader);\n const styles = parseStyleBlocks(styleBlocks);\n for (let i = 0; i < cueBlocks.length; i++) {\n const cueObject = parseCueBlock(cueBlocks[i], timeOffset);\n if (cueObject !== null) {\n const htmlCue = toHTML(cueObject, styles);\n cuesArray.push(htmlCue);\n }\n }\n return cuesArray;\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport isNonEmptyString from \"../../../utils/is_non_empty_string\";\nimport { isStartOfStyleBlock } from \"./utils\";\n/**\n * Get cue blocks from a WebVTT file.\n * @param {Array.} linified - Whole WebVTT file. Each new element in\n * this array is a new line.\n * @param {number} headerOffset - index of the first line after the header.\n * Used to avoid taking the header into consideration.\n * @returns {Array.>}\n */\nexport default function getStyleBlocks(linified, headerOffset) {\n const styleBlocks = [];\n for (let i = headerOffset; i < linified.length; i++) {\n //\n if (isStartOfStyleBlock(linified, i)) {\n const startOfStyleBlock = i;\n i++;\n // continue incrementing i until either:\n // - empty line\n // - end of file\n while (isNonEmptyString(linified[i])) {\n i++;\n }\n const styleBlock = linified.slice(startOfStyleBlock, i);\n styleBlocks.push(styleBlock);\n }\n else if (isNonEmptyString(linified[i])) {\n // continue incrementing i until either:\n // - empty line\n // - end\n while (isNonEmptyString(linified[i])) {\n i++;\n }\n }\n }\n return styleBlocks;\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport HTMLTextDisplayer from \"../../main_thread/text_displayer/html\";\nimport vttParser from \"../../parsers/texttracks/webvtt/html\";\n/**\n * Add ability to parse WebVTT text tracks in an HTML textrack mode.\n * @param {Object} features\n */\nfunction addHTMLVTTFeature(features) {\n features.htmlTextTracksParsers.vtt = vttParser;\n features.htmlTextDisplayer = HTMLTextDisplayer;\n}\nexport { addHTMLVTTFeature as HTML_VTT_PARSER };\nexport default addHTMLVTTFeature;\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport log from \"../log\";\nimport globalScope from \"../utils/global_scope\";\nimport SharedReference from \"../utils/reference\";\nconst _ResizeObserver = globalScope.ResizeObserver;\n/**\n * Emit the current height and width of the given `element` each time it\n * changes.\n *\n * On some browsers, we might not be able to rely on a native API to know when\n * it changes, the `interval` argument allow us to provide us an inverval in\n * milliseconds at which we should query that element's size.\n * @param {HTMLElement} element\n * @param {number} interval\n * @returns {Object}\n */\nexport default function onHeightWidthChange(element, interval, cancellationSignal) {\n const { height: initHeight, width: initWidth } = element.getBoundingClientRect();\n const ref = new SharedReference({\n height: initHeight,\n width: initWidth,\n }, cancellationSignal);\n let lastHeight = initHeight;\n let lastWidth = initWidth;\n if (_ResizeObserver !== undefined) {\n const resizeObserver = new _ResizeObserver((entries) => {\n if (entries.length === 0) {\n log.error(\"Compat: Resized but no observed element.\");\n return;\n }\n const entry = entries[0];\n const { height, width } = entry.contentRect;\n if (height !== lastHeight || width !== lastWidth) {\n lastHeight = height;\n lastWidth = width;\n ref.setValue({ height, width });\n }\n });\n resizeObserver.observe(element);\n cancellationSignal.register(() => {\n resizeObserver.disconnect();\n });\n }\n else {\n const intervalId = setInterval(() => {\n const { height, width } = element.getBoundingClientRect();\n if (height !== lastHeight || width !== lastWidth) {\n lastHeight = height;\n lastWidth = width;\n ref.setValue({ height, width });\n }\n }, interval);\n cancellationSignal.register(() => {\n clearInterval(intervalId);\n });\n }\n return ref;\n}\n","/**\n * Maximum time difference, in seconds, between two text segment's start times\n * and/or end times for them to be considered the same.\n *\n * For example for two segments s1 and s2 which have a start time respectively\n * of st1 and st2 and end time of et1 and et2:\n * - if both the absolute difference between st1 and st2 AND the one between\n * et1 and et2 is inferior or equal to the MAX_DELTA_BUFFER_TIME, s1 and s2\n * are considered to target the exact same time. As a consequence, if s2 is\n * added after s1 in the buffer, s1 will be completely replaced by it and\n * vice-versa.\n * - if only one of the two (absolute difference between st1 and st2 OR et1\n * and et2) is inferior to the MAX_DELTA_BUFFER_TIME then the last added\n * is not completely considered the same. It WILL still replace - either\n * partially or completely (depending on the sign of the other difference) -\n * the previously added segment.\n * - if both differences are strictly superior to the MAX_DELTA_BUFFER_TIME,\n * then they are not considered to have the same start nor the same end.\n * They can still overlap however, and MIGHT thus still replace partially\n * or completely each other.\n *\n * Setting a value too low might lead to two segments targeting the same time,\n * both being present in the buffer. In worst case scenarios, this could lead\n * to indicate that an unwanted text track is still here (theorically though,\n * this is a case that should never happen for reasons that might be too long\n * to explain here).\n *\n * Setting a value too high might lead to two segments targeting different times\n * to be wrongly believed to target the same time. In worst case scenarios, this\n * could lead to wanted text tracks being removed.\n *\n * When comparing 2 segments s1 and s2, you may want to take into account the duration\n * of the segments:\n * - if s1 is [0, 2] and s2 is [0, 2.1] s1 and s2 can be considered as nearly equal as\n * there is a relative difference of: (2.1-2) / 2 = 5%;\n * Formula: (end_s1 - end_s2) / duration_s2 = relative_difference\n * - if s1 is [0, 0.04] and s2 is [0.04, 0.08] s1 and s2 may not considered as nearly\n * equal as there is a relative difference of: (0.04-0.08) / 0.04 = 100%\n *\n * To compare relatively to the duration of a segment you can provide and additional\n * parameter \"delta\" that remplace MAX_DELTA_BUFFER_TIME.\n * If parameter \"delta\" is higher than MAX_DELTA_BUFFER_TIME, MAX_DELTA_BUFFER_TIME\n * is used instead of delta. This ensure that segments are nearly equal when comparing\n * relatively AND absolutely.\n *\n * @type Number\n */\nconst MAX_DELTA_BUFFER_TIME = 0.2;\n/**\n * @see MAX_DELTA_BUFFER_TIME\n * @param {Number} a\n * @param {Number} b\n * @param {Number} delta\n * @returns {Boolean}\n */\nexport function areNearlyEqual(a, b, delta = MAX_DELTA_BUFFER_TIME) {\n return Math.abs(a - b) <= Math.min(delta, MAX_DELTA_BUFFER_TIME);\n}\nconst EPSILON = 5e-2; // 5%\n/**\n * Check if two cues start are almost the same.\n * It should depend on there relative length:\n *\n * [0, 2] and [2, 4] start are NOT equals\n * [0, 2] and [0, 4] start are equals\n * [0, 0.1] and [0.101, 2] start are NOT equals\n * [0, 2] and [0.01, 4] start are equals\n * [0, 100] and [1, 200] start are NOT equals\n * @see MAX_DELTA_BUFFER_TIME\n * @param {Number} firstCue the existing cue\n * @param {Number} secondCue the cue that we test if it follow firstCue\n * @returns {Boolean}\n */\nexport function areCuesStartNearlyEqual(firstCue, secondCue) {\n const firstCueDuration = firstCue.end - firstCue.start;\n const secondCueDuration = secondCue.end - secondCue.start;\n const diffBetweenStart = Math.abs(firstCue.start - secondCue.start);\n const minDuration = Math.min(firstCueDuration, secondCueDuration, MAX_DELTA_BUFFER_TIME);\n return diffBetweenStart / minDuration <= EPSILON; // ratio diff/ minduration is bellow 5%\n}\n/**\n * Get all cues which have data before the given time.\n * @param {Object} cues\n * @param {Number} time\n * @returns {Array.}\n */\nexport function getCuesBefore(cues, time) {\n for (let i = cues.length - 1; i >= 0; i--) {\n const cue = cues[i];\n if (cue.start < time) {\n return cues.slice(0, i + 1);\n }\n }\n return [];\n}\n/**\n * Get all cues which have data after the given time.\n * @param {Object} cues\n * @param {Number} time\n * @returns {Array.}\n */\nexport function getCuesAfter(cues, time) {\n for (let i = 0; i < cues.length; i++) {\n const cue = cues[i];\n if (cue.end > time) {\n return cues.slice(i, cues.length);\n }\n }\n return [];\n}\n/**\n * @param {Object} cuesInfos\n * @param {Number} start\n * @param {Number} end\n * @returns {Array.}\n */\nexport function removeCuesInfosBetween(cuesInfos, start, end) {\n const endCuesInfos1 = Math.max(cuesInfos.start, start);\n const cues1 = getCuesBefore(cuesInfos.cues, start);\n const cuesInfos1 = {\n start: cuesInfos.start,\n end: endCuesInfos1,\n cues: cues1,\n };\n const startCuesInfos2 = Math.min(end, cuesInfos.end);\n const cues2 = getCuesAfter(cuesInfos.cues, end);\n const cuesInfos2 = {\n start: startCuesInfos2,\n end: cuesInfos.end,\n cues: cues2,\n };\n return [cuesInfos1, cuesInfos2];\n}\n","import assert from \"../../../utils/assert\";\nimport { areNearlyEqual, getCuesAfter, getCuesBefore, removeCuesInfosBetween, areCuesStartNearlyEqual, } from \"./utils\";\n/**\n * first or last IHTMLCue in a group can have a slighlty different start\n * or end time than the start or end time of the ICuesGroup due to parsing\n * approximation.\n * DELTA_CUES_GROUP defines the tolerance level when comparing the start/end\n * of a IHTMLCue to the start/end of a ICuesGroup.\n * Having this value too high may lead to have unwanted subtitle displayed\n * Having this value too low may lead to have subtitles not displayed\n */\nconst DELTA_CUES_GROUP = 1e-3;\n/**\n * segment_duration / RELATIVE_DELTA_RATIO = relative_delta\n *\n * relative_delta is the tolerance to determine if two segements are the same\n */\nconst RELATIVE_DELTA_RATIO = 5;\n/**\n * Manage a buffer of text track cues.\n * Allows to add, remove and recuperate cues at given times.\n * @class TextTrackCuesStore\n */\nexport default class TextTrackCuesStore {\n constructor() {\n this._cuesBuffer = [];\n }\n isEmpty() {\n return this._cuesBuffer.length === 0;\n }\n /**\n * Get corresponding cue(s) for the given time.\n * A cue is an object with three properties:\n * - start {Number}: start time for which the cue should be displayed.\n * - end {Number}: end time for which the cue should be displayed.\n * - element {HTMLElement}: The cue to diplay\n *\n * We do not mutate individual cue here.\n * That is, if the ``get`` method returns the same cue's reference than a\n * previous ``get`` call, its properties are guaranteed to have the exact same\n * values than before, if you did not mutate it on your side.\n * The inverse is true, if the values are the same than before, the reference\n * will stay the same (this is useful to easily check if the DOM should be\n * updated, for example).\n *\n * @param {Number} time\n * @returns {Array.} - The cues that need to be displayed at that\n * time.\n */\n get(time) {\n const cuesBuffer = this._cuesBuffer;\n const ret = [];\n // begins at the end as most of the time the player will ask for the last\n // CuesGroup\n for (let cueIdx = cuesBuffer.length - 1; cueIdx >= 0; cueIdx--) {\n const segment = cuesBuffer[cueIdx];\n if (time < segment.end && time >= segment.start) {\n const cues = segment.cues;\n for (const cue of cues) {\n if (time >= cue.start && time < cue.end) {\n ret.push(cue.element);\n }\n }\n // first or last IHTMLCue in a group can have a slighlty different start\n // or end time than the start or end time of the ICuesGroup due to parsing\n // approximation.\n // Add a tolerance of 1ms to fix this issue\n if (ret.length === 0 && cues.length > 0) {\n for (const cue of cues) {\n if (areNearlyEqual(time, cue.start, DELTA_CUES_GROUP) ||\n areNearlyEqual(time, cue.end, DELTA_CUES_GROUP)) {\n ret.push(cue.element);\n }\n }\n }\n return ret;\n }\n }\n return [];\n }\n /**\n * Remove cue from a certain range of time.\n * @param {Number} from\n * @param {Number} _to\n */\n remove(from, _to) {\n if (0 /* __ENVIRONMENT__.CURRENT_ENV */ === 1 /* __ENVIRONMENT__.DEV */) {\n assert(from >= 0);\n assert(_to >= 0);\n assert(_to > from);\n }\n const to = Math.max(from, _to);\n const cuesBuffer = this._cuesBuffer;\n for (let cueIdx = 0; cueIdx < cuesBuffer.length; cueIdx++) {\n if (cuesBuffer[cueIdx].end > from) {\n // this cuesInfos is concerned by the remove\n const startCuesInfos = cuesBuffer[cueIdx];\n if (startCuesInfos.start >= to) {\n // our cuesInfos is strictly after this interval, we have nothing to do\n return;\n }\n if (startCuesInfos.end >= to) {\n // our cuesInfos ends after `to`, we have to keep the end of it\n if (from <= startCuesInfos.start) {\n // from -> to only remove the start of startCuesInfos\n startCuesInfos.cues = getCuesAfter(startCuesInfos.cues, to);\n startCuesInfos.start = to;\n }\n else {\n // from -> to is in the middle part of startCuesInfos\n const [cuesInfos1, cuesInfos2] = removeCuesInfosBetween(startCuesInfos, from, to);\n this._cuesBuffer[cueIdx] = cuesInfos1;\n cuesBuffer.splice(cueIdx + 1, 0, cuesInfos2);\n }\n // No cuesInfos can be concerned after this one, we can quit\n return;\n }\n // Else remove all part after `from`\n if (startCuesInfos.start >= from) {\n // all the segment is concerned\n cuesBuffer.splice(cueIdx, 1);\n cueIdx--; // one less element, we have to decrement the loop\n }\n else {\n // only the end is concerned\n startCuesInfos.cues = getCuesBefore(startCuesInfos.cues, from);\n startCuesInfos.end = Math.max(from, startCuesInfos.start);\n }\n }\n }\n }\n /**\n * Insert new cues in our text buffer.\n * cues is an array of objects with three properties:\n * - start {Number}: start time for which the cue should be displayed.\n * - end {Number}: end time for which the cue should be displayed.\n * - element {HTMLElement}: The cue to diplay\n *\n * @param {Array.} cues - CuesGroups, array of objects with the\n * following properties:\n * - start {Number}: the time at which the cue will start to be displayed\n * - end {Number}: the time at which the cue will end to be displayed\n * - cue {HTMLElement}: The cue\n * @param {Number} start - Start time at which the CuesGroup applies.\n * This is different than the start of the first cue to display in it, this\n * has more to do with the time at which the _text segment_ starts.\n * @param {Number} end - End time at which the CuesGroup applies.\n * This is different than the end of the last cue to display in it, this\n * has more to do with the time at which the _text segment_ ends.\n *\n * TODO add securities to ensure that:\n * - the start of a CuesGroup is inferior or equal to the start of the first\n * cue in it\n * - the end of a CuesGroup is superior or equal to the end of the last\n * cue in it\n * If those requirements are not met, we could delete some cues when adding\n * a CuesGroup before/after. Find a solution.\n */\n insert(cues, start, end) {\n const cuesBuffer = this._cuesBuffer;\n const cuesInfosToInsert = { start, end, cues };\n // it's preferable to have a delta depending on the duration of the segment\n // if the delta is one fifth of the length of the segment:\n // a segment of [0, 2] is the \"same\" segment as [0, 2.1]\n // but [0, 0.04] is not the \"same\" segement as [0,04, 0.08]\n const relativeDelta = Math.abs(start - end) / RELATIVE_DELTA_RATIO;\n /**\n * Called when we found the index of the next cue relative to the cue we\n * want to insert (that is a cue starting after its start or at the same\n * time but ending strictly after its end).\n * Will insert the cue at the right place and update the next cue\n * accordingly.\n * @param {number} indexOfNextCue\n */\n function onIndexOfNextCueFound(indexOfNextCue) {\n const nextCue = cuesBuffer[indexOfNextCue];\n if (nextCue === undefined || // no cue\n areNearlyEqual(cuesInfosToInsert.end, nextCue.end, relativeDelta)) {\n // samey end\n // ours: |AAAAA|\n // the current one: |BBBBB|\n // Result: |AAAAA|\n cuesBuffer[indexOfNextCue] = cuesInfosToInsert;\n }\n else if (nextCue.start >= cuesInfosToInsert.end) {\n // Either\n // ours: |AAAAA|\n // the current one: |BBBBBB|\n // Result: |AAAAA| |BBBBBB|\n // Or:\n // ours: |AAAAA|\n // the current one: |BBBBBB|\n // Result: |AAAAA|BBBBBB|\n // Add ours before\n cuesBuffer.splice(indexOfNextCue, 0, cuesInfosToInsert);\n }\n else {\n // Either\n // ours: |AAAAA|\n // the current one: |BBBBBBBB|\n // Result: |AAAAABBB|\n // Or:\n // ours: |AAAAA|\n // the current one: |BBBBB|\n // Result: |AAAAABBB|\n nextCue.cues = getCuesAfter(nextCue.cues, cuesInfosToInsert.end);\n nextCue.start = cuesInfosToInsert.end;\n cuesBuffer.splice(indexOfNextCue, 0, cuesInfosToInsert);\n }\n }\n for (let cueIdx = 0; cueIdx < cuesBuffer.length; cueIdx++) {\n let cuesInfos = cuesBuffer[cueIdx];\n if (start < cuesInfos.end) {\n if (areCuesStartNearlyEqual(cuesInfosToInsert, cuesInfos)) {\n if (areNearlyEqual(end, cuesInfos.end, relativeDelta)) {\n // exact same segment\n // ours: |AAAAA|\n // the current one: |BBBBB|\n // Result: |AAAAA|\n // Which means:\n // 1. replace the current cue with ours\n cuesBuffer[cueIdx] = cuesInfosToInsert;\n return;\n }\n else if (end < cuesInfos.end) {\n // our cue overlaps with the current one:\n // ours: |AAAAA|\n // the current one: |BBBBBBBB|\n // Result: |AAAAABBB|\n // Which means:\n // 1. remove some cues at the start of the current one\n // 2. update start of current one\n // 3. add ours before the current one\n cuesInfos.cues = getCuesAfter(cuesInfos.cues, end);\n cuesInfos.start = end;\n cuesBuffer.splice(cueIdx, 0, cuesInfosToInsert);\n return;\n }\n // our cue goes beyond the current one:\n // ours: |AAAAAAA|\n // the current one: |BBBB|...\n // Result: |AAAAAAA|\n // Here we have to delete any cuesInfos which end before ours end,\n // and see about the following one.\n do {\n cuesBuffer.splice(cueIdx, 1);\n cuesInfos = cuesBuffer[cueIdx];\n } while (cuesInfos !== undefined && end > cuesInfos.end);\n onIndexOfNextCueFound(cueIdx);\n return;\n }\n else if (start < cuesInfos.start) {\n if (end < cuesInfos.start) {\n // our cue goes strictly before the current one:\n // ours: |AAAAAAA|\n // the current one: |BBBB|\n // Result: |AAAAAAA| |BBBB|\n // Which means:\n // - add ours before the current one\n cuesBuffer.splice(cueIdx, 0, cuesInfosToInsert);\n return;\n }\n else if (areNearlyEqual(end, cuesInfos.start, relativeDelta)) {\n // our cue goes just before the current one:\n // ours: |AAAAAAA|\n // the current one: |BBBB|\n // Result: |AAAAAAA|BBBB|\n // Which means:\n // - update start time of the current one to be sure\n // - add ours before the current one\n cuesInfos.start = end;\n cuesBuffer.splice(cueIdx, 0, cuesInfosToInsert);\n return;\n }\n else if (areNearlyEqual(end, cuesInfos.end, relativeDelta)) {\n // ours: |AAAAAAA|\n // the current one: |BBBB|\n // Result: |AAAAAAA|\n // Replace\n cuesBuffer.splice(cueIdx, 1, cuesInfosToInsert);\n return;\n }\n else if (end < cuesInfos.end) {\n // ours: |AAAAAAA|\n // the current one: |BBBBB|\n // Result: |AAAAAAABB|\n cuesInfos.cues = getCuesAfter(cuesInfos.cues, end);\n cuesInfos.start = end;\n cuesBuffer.splice(cueIdx, 0, cuesInfosToInsert);\n return;\n }\n // ours: |AAAAAAA|\n // the current one: |BBB|...\n // Result: |AAAAAAA|...\n do {\n cuesBuffer.splice(cueIdx, 1);\n cuesInfos = cuesBuffer[cueIdx];\n } while (cuesInfos !== undefined && end > cuesInfos.end);\n onIndexOfNextCueFound(cueIdx);\n return;\n }\n // else -> start > cuesInfos.start\n if (areNearlyEqual(cuesInfos.end, end, relativeDelta)) {\n // ours: |AAAAAA|\n // the current one: |BBBBBBBB|\n // Result: |BBAAAAAA|\n cuesInfos.cues = getCuesBefore(cuesInfos.cues, start);\n cuesInfos.end = start;\n cuesBuffer.splice(cueIdx + 1, 0, cuesInfosToInsert);\n return;\n }\n else if (cuesInfos.end > end) {\n // ours: |AAAAAA|\n // the current one: |BBBBBBBBBBB|\n // Result: |BBAAAAAABBB|\n const [cuesInfos1, cuesInfos2] = removeCuesInfosBetween(cuesInfos, start, end);\n this._cuesBuffer[cueIdx] = cuesInfos1;\n cuesBuffer.splice(cueIdx + 1, 0, cuesInfosToInsert);\n cuesBuffer.splice(cueIdx + 2, 0, cuesInfos2);\n return;\n }\n else {\n // ours: |AAAAAA|\n // the current one: |BBBBB|...\n // Result: |BBAAAAAA|...\n cuesInfos.cues = getCuesBefore(cuesInfos.cues, start);\n cuesInfos.end = start;\n const nextCueIdx = cueIdx + 1;\n cuesInfos = cuesBuffer[nextCueIdx];\n while (cuesInfos !== undefined && end > cuesInfos.end) {\n cuesBuffer.splice(nextCueIdx, 1);\n cuesInfos = cuesBuffer[nextCueIdx];\n }\n onIndexOfNextCueFound(nextCueIdx);\n return;\n }\n }\n }\n if (cuesBuffer.length > 0) {\n const lastCue = cuesBuffer[cuesBuffer.length - 1];\n if (areNearlyEqual(lastCue.end, start, relativeDelta)) {\n // Match the end of the previous cue to the start of the following one\n // if they are close enough. If there is a small gap between two segments\n // it can lead to having no subtitles for a short time, this is noticeable when\n // two successive segments displays the same text, making it diseappear\n // and reappear quickly, which gives the impression of blinking\n //\n // ours: |AAAAA|\n // the current one: |BBBBB|...\n // Result: |BBBBBBBAAAAA|\n lastCue.end = start;\n }\n }\n // no cues group has the end after our current start.\n // These cues should be the last one\n cuesBuffer.push(cuesInfosToInsert);\n }\n}\n","/**\n * Update size of element which are proportional to the current text track\n * element.\n * Returns `true` if at least a single styling information is proportional,\n * `false` otherwise.\n * @param {number} currentHeight\n * @param {number} currentWidth\n * @param {Object} resolution\n * @param {HTMLElement} textTrackElement\n * @returns {boolean}\n */\nexport default function updateProportionalElements(currentHeight, currentWidth, resolution, textTrackElement) {\n const cellUnit = [currentWidth / resolution.columns, currentHeight / resolution.rows];\n const proportElts = textTrackElement.getElementsByClassName(\"proportional-style\");\n for (let eltIdx = 0; eltIdx < proportElts.length; eltIdx++) {\n const elt = proportElts[eltIdx];\n if (elt instanceof HTMLElement) {\n const fontSizeVal = elt.getAttribute(\"data-proportional-font-size\");\n if (fontSizeVal !== null && !isNaN(+fontSizeVal)) {\n elt.style.fontSize = String(+fontSizeVal * cellUnit[1]) + \"px\";\n }\n const widthVal = elt.getAttribute(\"data-proportional-width\");\n if (widthVal !== null && !isNaN(+widthVal)) {\n elt.style.width = String(+widthVal * cellUnit[0]) + \"px\";\n }\n const heightVal = elt.getAttribute(\"data-proportional-height\");\n if (heightVal !== null && !isNaN(+heightVal)) {\n elt.style.height = String(+heightVal * cellUnit[1]) + \"px\";\n }\n const lineHeightVal = elt.getAttribute(\"data-proportional-line-height\");\n if (lineHeightVal !== null && !isNaN(+lineHeightVal)) {\n elt.style.lineHeight = String(+lineHeightVal * cellUnit[1]) + \"px\";\n }\n const leftVal = elt.getAttribute(\"data-proportional-left\");\n if (leftVal !== null && !isNaN(+leftVal)) {\n elt.style.left = String(+leftVal * cellUnit[0]) + \"px\";\n }\n const topVal = elt.getAttribute(\"data-proportional-top\");\n if (topVal !== null && !isNaN(+topVal)) {\n elt.style.top = String(+topVal * cellUnit[1]) + \"px\";\n }\n const paddingTopVal = elt.getAttribute(\"data-proportional-padding-top\");\n if (paddingTopVal !== null && !isNaN(+paddingTopVal)) {\n elt.style.paddingTop = String(+paddingTopVal * cellUnit[1]) + \"px\";\n }\n const paddingBottomVal = elt.getAttribute(\"data-proportional-padding-bottom\");\n if (paddingBottomVal !== null && !isNaN(+paddingBottomVal)) {\n elt.style.paddingBottom = String(+paddingBottomVal * cellUnit[1]) + \"px\";\n }\n const paddingLeftVal = elt.getAttribute(\"data-proportional-padding-left\");\n if (paddingLeftVal !== null && !isNaN(+paddingLeftVal)) {\n elt.style.paddingLeft = String(+paddingLeftVal * cellUnit[0]) + \"px\";\n }\n const paddingRightVal = elt.getAttribute(\"data-proportional-padding-right\");\n if (paddingRightVal !== null && !isNaN(+paddingRightVal)) {\n elt.style.paddingRight = String(+paddingRightVal * cellUnit[0]) + \"px\";\n }\n }\n }\n return proportElts.length > 0;\n}\n","import { onEnded, onSeeked, onSeeking } from \"../../../compat/event_listeners\";\nimport onHeightWidthChange from \"../../../compat/on_height_width_change\";\nimport config from \"../../../config\";\nimport log from \"../../../log\";\nimport { convertToRanges } from \"../../../utils/ranges\";\nimport TaskCanceller from \"../../../utils/task_canceller\";\nimport ManualTimeRanges from \"../manual_time_ranges\";\nimport parseTextTrackToElements from \"./html_parsers\";\nimport TextTrackCuesStore from \"./text_track_cues_store\";\nimport updateProportionalElements from \"./update_proportional_elements\";\n/**\n * @param {Element} element\n * @param {Element} child\n */\nfunction safelyRemoveChild(element, child) {\n try {\n element.removeChild(child);\n }\n catch (_error) {\n log.warn(\"HTD: Can't remove text track: not in the element.\");\n }\n}\n/**\n * @param {HTMLElement} element\n * @returns {Object|null}\n */\nfunction getElementResolution(element) {\n const strRows = element.getAttribute(\"data-resolution-rows\");\n const strColumns = element.getAttribute(\"data-resolution-columns\");\n if (strRows === null || strColumns === null) {\n return null;\n }\n const rows = parseInt(strRows, 10);\n const columns = parseInt(strColumns, 10);\n if (rows === null || columns === null) {\n return null;\n }\n return { rows, columns };\n}\n/**\n * TextDisplayer implementation which display buffered TextTracks in the given\n * HTML element.\n * @class HTMLTextDisplayer\n */\nexport default class HTMLTextDisplayer {\n /**\n * @param {HTMLMediaElement} videoElement\n * @param {HTMLElement} textTrackElement\n */\n constructor(videoElement, textTrackElement) {\n log.debug(\"HTD: Creating HTMLTextDisplayer\");\n this._buffered = new ManualTimeRanges();\n this._videoElement = videoElement;\n this._textTrackElement = textTrackElement;\n this._sizeUpdateCanceller = new TaskCanceller();\n this._subtitlesIntervalCanceller = new TaskCanceller();\n this._buffer = new TextTrackCuesStore();\n this._currentCues = [];\n this._isAutoRefreshing = false;\n }\n /**\n * Push text segment to the HTMLTextDisplayer.\n * @param {Object} infos\n * @returns {Object}\n */\n pushTextData(infos) {\n var _a, _b;\n log.debug(\"HTD: Appending new html text tracks\");\n const { timestampOffset, appendWindow, chunk } = infos;\n if (chunk === null) {\n return convertToRanges(this._buffered);\n }\n const { start: startTime, end: endTime, data: dataString, type, language } = chunk;\n const appendWindowStart = (_a = appendWindow[0]) !== null && _a !== void 0 ? _a : 0;\n const appendWindowEnd = (_b = appendWindow[1]) !== null && _b !== void 0 ? _b : Infinity;\n const cues = parseTextTrackToElements(type, dataString, timestampOffset, language);\n if (appendWindowStart !== 0 && appendWindowEnd !== Infinity) {\n // Removing before window start\n let i = 0;\n while (i < cues.length && cues[i].end <= appendWindowStart) {\n i++;\n }\n cues.splice(0, i);\n i = 0;\n while (i < cues.length && cues[i].start < appendWindowStart) {\n cues[i].start = appendWindowStart;\n i++;\n }\n // Removing after window end\n i = cues.length - 1;\n while (i >= 0 && cues[i].start >= appendWindowEnd) {\n i--;\n }\n cues.splice(i, cues.length);\n i = cues.length - 1;\n while (i >= 0 && cues[i].end > appendWindowEnd) {\n cues[i].end = appendWindowEnd;\n i--;\n }\n }\n let start;\n if (startTime !== undefined) {\n start = Math.max(appendWindowStart, startTime);\n }\n else {\n if (cues.length <= 0) {\n log.warn(\"HTD: Current text tracks have no cues nor start time. Aborting\");\n return convertToRanges(this._buffered);\n }\n log.warn(\"HTD: No start time given. Guessing from cues.\");\n start = cues[0].start;\n }\n let end;\n if (endTime !== undefined) {\n end = Math.min(appendWindowEnd, endTime);\n }\n else {\n if (cues.length <= 0) {\n log.warn(\"HTD: Current text tracks have no cues nor end time. Aborting\");\n return convertToRanges(this._buffered);\n }\n log.warn(\"HTD: No end time given. Guessing from cues.\");\n end = cues[cues.length - 1].end;\n }\n if (end <= start) {\n log.warn(\"HTD: Invalid text track appended: \", \"the start time is inferior or equal to the end time.\");\n return convertToRanges(this._buffered);\n }\n this._buffer.insert(cues, start, end);\n this._buffered.insert(start, end);\n if (!this._isAutoRefreshing && !this._buffer.isEmpty()) {\n this.autoRefreshSubtitles(this._subtitlesIntervalCanceller.signal);\n }\n return convertToRanges(this._buffered);\n }\n /**\n * Remove buffered data.\n * @param {number} start - start position, in seconds\n * @param {number} end - end position, in seconds\n * @returns {Object}\n */\n removeBuffer(start, end) {\n log.debug(\"HTD: Removing html text track data\", start, end);\n this._buffer.remove(start, end);\n this._buffered.remove(start, end);\n if (this._isAutoRefreshing && this._buffer.isEmpty()) {\n this.refreshSubtitles();\n this._isAutoRefreshing = false;\n this._subtitlesIntervalCanceller.cancel();\n this._subtitlesIntervalCanceller = new TaskCanceller();\n }\n return convertToRanges(this._buffered);\n }\n /**\n * Returns the currently buffered data, in a TimeRanges object.\n * @returns {TimeRanges}\n */\n getBufferedRanges() {\n return convertToRanges(this._buffered);\n }\n reset() {\n log.debug(\"HTD: Resetting HTMLTextDisplayer\");\n this.stop();\n this._subtitlesIntervalCanceller = new TaskCanceller();\n }\n stop() {\n if (this._subtitlesIntervalCanceller.isUsed()) {\n return;\n }\n log.debug(\"HTD: Stopping HTMLTextDisplayer\");\n this._disableCurrentCues();\n this._buffer.remove(0, Infinity);\n this._buffered.remove(0, Infinity);\n this._isAutoRefreshing = false;\n this._subtitlesIntervalCanceller.cancel();\n }\n /**\n * Remove the current cue from being displayed.\n */\n _disableCurrentCues() {\n this._sizeUpdateCanceller.cancel();\n if (this._currentCues.length > 0) {\n for (const cue of this._currentCues) {\n safelyRemoveChild(this._textTrackElement, cue.element);\n }\n this._currentCues = [];\n }\n }\n /**\n * Display a new Cue. If one was already present, it will be replaced.\n * @param {HTMLElement} elements\n */\n _displayCues(elements) {\n const nothingChanged = this._currentCues.length === elements.length &&\n this._currentCues.every((current, index) => current.element === elements[index]);\n if (nothingChanged) {\n return;\n }\n // Remove and re-display everything\n // TODO More intelligent handling\n this._sizeUpdateCanceller.cancel();\n for (const cue of this._currentCues) {\n safelyRemoveChild(this._textTrackElement, cue.element);\n }\n this._currentCues = [];\n for (const element of elements) {\n const resolution = getElementResolution(element);\n this._currentCues.push({ element, resolution });\n this._textTrackElement.appendChild(element);\n }\n const proportionalCues = this._currentCues.filter((cue) => cue.resolution !== null);\n if (proportionalCues.length > 0) {\n this._sizeUpdateCanceller = new TaskCanceller();\n this._sizeUpdateCanceller.linkToSignal(this._subtitlesIntervalCanceller.signal);\n const { TEXT_TRACK_SIZE_CHECKS_INTERVAL } = config.getCurrent();\n // update propertionally-sized elements periodically\n const heightWidthRef = onHeightWidthChange(this._textTrackElement, TEXT_TRACK_SIZE_CHECKS_INTERVAL, this._sizeUpdateCanceller.signal);\n heightWidthRef.onUpdate(({ height, width }) => {\n for (const cue of proportionalCues) {\n const { resolution, element } = cue;\n updateProportionalElements(height, width, resolution, element);\n }\n }, {\n clearSignal: this._sizeUpdateCanceller.signal,\n emitCurrentValue: true,\n });\n }\n }\n /**\n * Auto-refresh the display of subtitles according to the media element's\n * position and events.\n * @param {Object} cancellationSignal\n */\n autoRefreshSubtitles(cancellationSignal) {\n if (this._isAutoRefreshing || cancellationSignal.isCancelled()) {\n return;\n }\n let autoRefreshCanceller = null;\n const { MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL } = config.getCurrent();\n const stopAutoRefresh = () => {\n this._isAutoRefreshing = false;\n if (autoRefreshCanceller !== null) {\n autoRefreshCanceller.cancel();\n autoRefreshCanceller = null;\n }\n };\n const startAutoRefresh = () => {\n stopAutoRefresh();\n this._isAutoRefreshing = true;\n autoRefreshCanceller = new TaskCanceller();\n autoRefreshCanceller.linkToSignal(cancellationSignal);\n const intervalId = setInterval(() => this.refreshSubtitles(), MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL);\n autoRefreshCanceller.signal.register(() => {\n clearInterval(intervalId);\n });\n this.refreshSubtitles();\n };\n onSeeking(this._videoElement, () => {\n stopAutoRefresh();\n this._disableCurrentCues();\n }, cancellationSignal);\n onSeeked(this._videoElement, startAutoRefresh, cancellationSignal);\n onEnded(this._videoElement, startAutoRefresh, cancellationSignal);\n startAutoRefresh();\n }\n /**\n * Refresh current subtitles according to the current media element's\n * position.\n */\n refreshSubtitles() {\n const { MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL } = config.getCurrent();\n let time;\n if (this._videoElement.paused || this._videoElement.playbackRate <= 0) {\n time = this._videoElement.currentTime;\n }\n else {\n // to spread the time error, we divide the regular chosen interval.\n time = Math.max(this._videoElement.currentTime +\n MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL / 1000 / 2, 0);\n }\n const cues = this._buffer.get(time);\n if (cues.length === 0) {\n this._disableCurrentCues();\n }\n else {\n this._displayCues(cues);\n }\n }\n}\n/*\n * The following ugly code is here to provide a compile-time check that an\n * `IHTMLTextTracksBufferSegmentData` (type of data pushed to a\n * `HTMLTextDisplayer`) can be derived from a `ITextTrackSegmentData`\n * (text track data parsed from a segment).\n *\n * It doesn't correspond at all to real code that will be called. This is just\n * a hack to tell TypeScript to perform that check.\n */\nif (0 /* __ENVIRONMENT__.CURRENT_ENV */ === 1 /* __ENVIRONMENT__.DEV */) {\n // @ts-expect-error: uncalled function just for type-checking\n function _checkType(input) {\n function checkEqual(_arg) {\n /* nothing */\n }\n checkEqual(input);\n }\n}\n","import HTMLTextDisplayer from \"./html_text_displayer\";\nexport default HTMLTextDisplayer;\n","import features from \"../../../features\";\nimport log from \"../../../log\";\n/**\n * Convert text track data into timed HTML Cues.\n * @param {string} type - Text track format wanted\n * @param {string} data - Text track data\n * @param {Number} timestampOffset - offset to apply to every timed text\n * @param {string} [language] - language of the text tracks\n * @returns {Array.}\n * @throws Error - Throw if no parser is found for the given type\n */\nexport default function parseTextTrackToElements(type, data, timestampOffset, language) {\n log.debug(\"HTSB: Finding parser for html text tracks:\", type);\n const parser = features.htmlTextTracksParsers[type];\n if (typeof parser !== \"function\") {\n throw new Error(\"no parser found for the given text track\");\n }\n log.debug(\"HTSB: Parser found, parsing...\");\n const parsed = parser(data, timestampOffset, language);\n log.debug(\"HTTB: Parsed successfully!\", parsed.length);\n return parsed;\n}\n","import assert from \"../../utils/assert\";\nimport { insertInto, keepRangeIntersection } from \"../../utils/ranges\";\n/**\n * Simulate TimeRanges as returned by SourceBuffer.prototype.buffered.\n * Add an \"insert\" and \"remove\" methods to manually update it.\n * @class ManualTimeRanges\n */\nexport default class ManualTimeRanges {\n constructor() {\n this._ranges = [];\n this.length = 0;\n }\n insert(start, end) {\n if (0 /* __ENVIRONMENT__.CURRENT_ENV */ === 1 /* __ENVIRONMENT__.DEV */) {\n assert(start >= 0, \"invalid start time\");\n assert(end - start > 0, \"invalid end time\");\n }\n insertInto(this._ranges, { start, end });\n this.length = this._ranges.length;\n }\n remove(start, end) {\n if (0 /* __ENVIRONMENT__.CURRENT_ENV */ === 1 /* __ENVIRONMENT__.DEV */) {\n assert(start >= 0, \"invalid start time\");\n assert(end - start > 0, \"invalid end time\");\n }\n const rangesToIntersect = [];\n if (start > 0) {\n rangesToIntersect.push({ start: 0, end: start });\n }\n if (end < Infinity) {\n rangesToIntersect.push({ start: end, end: Infinity });\n }\n this._ranges = keepRangeIntersection(this._ranges, rangesToIntersect);\n this.length = this._ranges.length;\n }\n start(index) {\n if (index >= this._ranges.length) {\n throw new Error(\"INDEX_SIZE_ERROR\");\n }\n return this._ranges[index].start;\n }\n end(index) {\n if (index >= this._ranges.length) {\n throw new Error(\"INDEX_SIZE_ERROR\");\n }\n return this._ranges[index].end;\n }\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport arrayFind from \"../../../utils/array_find\";\nimport arrayIncludes from \"../../../utils/array_includes\";\nimport isNonEmptyString from \"../../../utils/is_non_empty_string\";\nimport startsWith from \"../../../utils/starts_with\";\n/**\n * Retrieve the attributes given in arguments in the given nodes and their\n * associated style(s)/region.\n * The first notion of the attribute encountered will be taken (by looping\n * through the given nodes in order).\n *\n * TODO manage IDREFS (plural) for styles and regions, that is, multiple one\n * @param {Array.} attributes\n * @param {Array.} nodes\n * @param {Array.} styles\n * @param {Array.} regions\n * @returns {Object}\n */\nexport function getStylingAttributes(attributes, nodes, styles, regions) {\n const currentStyle = {};\n const leftAttributes = attributes.slice();\n for (let i = 0; i <= nodes.length - 1; i++) {\n const node = nodes[i];\n if (node !== undefined) {\n let styleID;\n let regionID;\n // 1. the style is directly set on a \"tts:\" attribute\n if (node.nodeType === Node.ELEMENT_NODE) {\n const element = node;\n for (let j = 0; j <= element.attributes.length - 1; j++) {\n const attribute = element.attributes[j];\n const name = attribute.name;\n if (name === \"style\") {\n styleID = attribute.value;\n }\n else if (name === \"region\") {\n regionID = attribute.value;\n }\n else {\n const nameWithoutTTS = name.substring(4);\n if (arrayIncludes(leftAttributes, nameWithoutTTS)) {\n currentStyle[nameWithoutTTS] = attribute.value;\n leftAttributes.splice(j, 1);\n if (leftAttributes.length === 0) {\n return currentStyle;\n }\n }\n }\n }\n }\n // 2. the style is referenced on a \"style\" attribute\n if (isNonEmptyString(styleID)) {\n const style = arrayFind(styles, (x) => x.id === styleID);\n if (style !== undefined) {\n for (let j = 0; j <= leftAttributes.length - 1; j++) {\n const attribute = leftAttributes[j];\n if (!isNonEmptyString(currentStyle[attribute])) {\n if (isNonEmptyString(style.style[attribute])) {\n currentStyle[attribute] = style.style[attribute];\n leftAttributes.splice(j, 1);\n if (leftAttributes.length === 0) {\n return currentStyle;\n }\n j--;\n }\n }\n }\n }\n }\n // 3. the node reference a region (which can have a value for the\n // corresponding style)\n if (isNonEmptyString(regionID)) {\n const region = arrayFind(regions, (x) => x.id === regionID);\n if (region !== undefined) {\n for (let j = 0; j <= leftAttributes.length - 1; j++) {\n const attribute = leftAttributes[j];\n if (!isNonEmptyString(currentStyle[attribute])) {\n if (isNonEmptyString(region.style[attribute])) {\n currentStyle[attribute] = region.style[attribute];\n leftAttributes.splice(j, 1);\n if (leftAttributes.length === 0) {\n return currentStyle;\n }\n j--;\n }\n }\n }\n }\n }\n }\n }\n return currentStyle;\n}\n/**\n * Returns the styling directly linked to an element.\n * @param {Node} node\n * @returns {Object}\n */\nexport function getStylingFromElement(node) {\n if (node.nodeType !== Node.ELEMENT_NODE) {\n return {};\n }\n const element = node;\n const currentStyle = {};\n for (let i = 0; i <= element.attributes.length - 1; i++) {\n const styleAttribute = element.attributes[i];\n if (startsWith(styleAttribute.name, \"tts\")) {\n const nameWithoutTTS = styleAttribute.name.substring(4);\n currentStyle[nameWithoutTTS] = styleAttribute.value;\n }\n }\n return currentStyle;\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { REGXP_TIME_COLON, REGXP_TIME_COLON_FRAMES, REGXP_TIME_COLON_MS, REGXP_TIME_FRAMES, REGXP_TIME_HMS, REGXP_TIME_TICK, } from \"./regexps\";\n/**\n * Parses a TTML time into seconds.\n * @param {string} text\n * @param {Object} ttParams\n * @returns {Number|undefined}\n */\nfunction parseTime(text, ttParams) {\n if (REGXP_TIME_COLON_FRAMES.test(text)) {\n return parseColonTimeWithFrames(ttParams, text);\n }\n else if (REGXP_TIME_COLON.test(text)) {\n return parseTimeFromRegExp(REGXP_TIME_COLON, text);\n }\n else if (REGXP_TIME_COLON_MS.test(text)) {\n return parseTimeFromRegExp(REGXP_TIME_COLON_MS, text);\n }\n else if (REGXP_TIME_FRAMES.test(text)) {\n return parseFramesTime(ttParams, text);\n }\n else if (REGXP_TIME_TICK.test(text)) {\n return parseTickTime(ttParams, text);\n }\n else if (REGXP_TIME_HMS.test(text)) {\n return parseTimeFromRegExp(REGXP_TIME_HMS, text);\n }\n}\n/**\n * Parses a TTML time in frame format\n * @param {Object} ttParams\n * @param {string} text\n * @returns {Number}\n */\nfunction parseFramesTime(ttParams, text) {\n // 75f or 75.5f\n // (We cast as we're sure the regexp is respected here)\n const results = REGXP_TIME_FRAMES.exec(text);\n const frames = Number(results[1]);\n return frames / ttParams.frameRate;\n}\n/**\n * Parses a TTML time in tick format\n * @param {Object} ttParams\n * @param {string} text\n * @returns {Number}\n */\nfunction parseTickTime(ttParams, text) {\n // 50t or 50.5t\n // (We cast as we're sure the regexp is respected here)\n const results = REGXP_TIME_TICK.exec(text);\n const ticks = Number(results[1]);\n return ticks / ttParams.tickRate;\n}\n/**\n * Parses a TTML colon formatted time containing frames\n * @param {Object} ttParams\n * @param {string} text\n * @returns {Number}\n */\nfunction parseColonTimeWithFrames(ttParams, text) {\n // 01:02:43:07 (\"07\" is frames) or 01:02:43:07.1 (subframes)\n // (We cast as we're sure the regexp is respected here)\n const results = REGXP_TIME_COLON_FRAMES.exec(text);\n const hours = Number(results[1]);\n const minutes = Number(results[2]);\n let seconds = Number(results[3]);\n let frames = Number(results[4]);\n let subframes = Number(results[5]);\n if (isNaN(subframes)) {\n subframes = 0;\n }\n frames += subframes / ttParams.subFrameRate;\n seconds += frames / ttParams.frameRate;\n return seconds + minutes * 60 + hours * 3600;\n}\n/**\n * Parses a TTML time with a given regex. Expects regex to be some\n * sort of a time-matcher to match hours, minutes, seconds and milliseconds\n *\n * @param {RegExp} regex\n * @param {string} text\n * @returns {number|null}\n */\nfunction parseTimeFromRegExp(regex, text) {\n const results = regex.exec(text);\n if (results === null || results[0] === \"\") {\n return null;\n }\n // This capture is optional, but will still be in the array as undefined,\n // default to 0.\n let hours = Number(results[1]);\n if (isNaN(hours)) {\n hours = 0;\n }\n let minutes = Number(results[2]);\n if (isNaN(minutes)) {\n minutes = 0;\n }\n let seconds = Number(results[3]);\n if (isNaN(seconds)) {\n seconds = 0;\n }\n let milliseconds = Number(results[4]);\n if (isNaN(milliseconds)) {\n milliseconds = 0;\n }\n return milliseconds / 1000 + seconds + minutes * 60 + hours * 3600;\n}\nexport default parseTime;\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport isNonEmptyString from \"../../../utils/is_non_empty_string\";\nimport isNullOrUndefined from \"../../../utils/is_null_or_undefined\";\nimport parseTime from \"./time_parsing\";\n/**\n * Get start and end time of an element.\n * @param {Element} element\n * @param {Object} ttParams\n * @returns {Object}\n */\nexport default function getTimeDelimiters(element, ttParams) {\n const beginAttr = element.getAttribute(\"begin\");\n const durationAttr = element.getAttribute(\"dur\");\n const endAttr = element.getAttribute(\"end\");\n const start = isNonEmptyString(beginAttr) ? parseTime(beginAttr, ttParams) : null;\n const duration = isNonEmptyString(durationAttr)\n ? parseTime(durationAttr, ttParams)\n : null;\n const parsedEnd = isNonEmptyString(endAttr) ? parseTime(endAttr, ttParams) : null;\n if (isNullOrUndefined(start) ||\n (isNullOrUndefined(parsedEnd) && isNullOrUndefined(duration))) {\n throw new Error(\"Invalid text cue\");\n }\n const end = isNullOrUndefined(parsedEnd) ? start + duration : parsedEnd;\n return { start, end };\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport log from \"../../../log\";\nimport isNonEmptyString from \"../../../utils/is_non_empty_string\";\nconst CELL_RESOLUTION_REGEXP = /(\\d+) (\\d+)/;\n/**\n * Returns global parameters from a TTML Document\n * @param {Element} tt - node\n * @throws Error - Throws if the spacing style is invalid.\n * @returns {Object}\n */\nexport default function getParameters(tt) {\n const parsedFrameRate = tt.getAttribute(\"ttp:frameRate\");\n const parsedSubFrameRate = tt.getAttribute(\"ttp:subFramRate\");\n const parsedTickRate = tt.getAttribute(\"ttp:tickRate\");\n const parsedFrameRateMultiplier = tt.getAttribute(\"ttp:frameRateMultiplier\");\n const parsedSpaceStyle = tt.getAttribute(\"xml:space\");\n const parsedCellResolution = tt.getAttribute(\"ttp:cellResolution\");\n let cellResolution = {\n columns: 32,\n rows: 15,\n };\n if (parsedCellResolution !== null) {\n const extractedData = CELL_RESOLUTION_REGEXP.exec(parsedCellResolution);\n if (extractedData === null || extractedData.length < 3) {\n log.warn(\"TTML Parser: Invalid cellResolution\");\n }\n else {\n const columns = parseInt(extractedData[1], 10);\n const rows = parseInt(extractedData[2], 10);\n if (isNaN(columns) || isNaN(rows)) {\n log.warn(\"TTML Parser: Invalid cellResolution\");\n }\n else {\n cellResolution = { columns, rows };\n }\n }\n }\n if (isNonEmptyString(parsedSpaceStyle) &&\n parsedSpaceStyle !== \"default\" &&\n parsedSpaceStyle !== \"preserve\") {\n throw new Error(\"Invalid spacing style\");\n }\n let nbFrameRate = Number(parsedFrameRate);\n if (isNaN(nbFrameRate) || nbFrameRate <= 0) {\n nbFrameRate = 30;\n }\n let nbSubFrameRate = Number(parsedSubFrameRate);\n if (isNaN(nbSubFrameRate) || nbSubFrameRate <= 0) {\n nbSubFrameRate = 1;\n }\n let nbTickRate = Number(parsedTickRate);\n if (isNaN(nbTickRate) || nbTickRate <= 0) {\n nbTickRate = undefined;\n }\n let frameRate = nbFrameRate;\n const subFrameRate = nbSubFrameRate !== null && nbSubFrameRate !== void 0 ? nbSubFrameRate : 1;\n const spaceStyle = parsedSpaceStyle !== null && parsedSpaceStyle !== void 0 ? parsedSpaceStyle : \"default\";\n const tickRate = nbTickRate !== null && nbTickRate !== void 0 ? nbTickRate : nbFrameRate * nbSubFrameRate;\n if (parsedFrameRateMultiplier !== null) {\n const multiplierResults = /^(\\d+) (\\d+)$/g.exec(parsedFrameRateMultiplier);\n if (multiplierResults !== null) {\n const numerator = Number(multiplierResults[1]);\n const denominator = Number(multiplierResults[2]);\n const multiplierNum = numerator / denominator;\n frameRate = nbFrameRate * multiplierNum;\n }\n }\n return { cellResolution, tickRate, frameRate, subFrameRate, spaceStyle };\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport arrayFind from \"../../../utils/array_find\";\nimport isNonEmptyString from \"../../../utils/is_non_empty_string\";\nimport objectAssign from \"../../../utils/object_assign\";\nimport getParameters from \"./get_parameters\";\nimport { getStylingAttributes, getStylingFromElement } from \"./get_styling\";\nimport resolveStylesInheritance from \"./resolve_styles_inheritance\";\nimport { getParentDivElements, getBodyNode, getRegionNodes, getStyleNodes, getTextNodes, } from \"./xml_utils\";\nconst STYLE_ATTRIBUTES = [\n \"align\",\n \"backgroundColor\",\n \"color\",\n \"direction\",\n \"display\",\n \"displayAlign\",\n \"extent\",\n \"fontFamily\",\n \"fontSize\",\n \"fontStyle\",\n \"fontWeight\",\n \"lineHeight\",\n \"opacity\",\n \"origin\",\n \"overflow\",\n \"padding\",\n \"textAlign\",\n \"textDecoration\",\n \"textOutline\",\n \"unicodeBidi\",\n \"visibility\",\n \"wrapOption\",\n \"writingMode\",\n // Not managed anywhere for now\n // \"showBackground\",\n // \"zIndex\",\n];\n/**\n * Create array of objects which should represent the given TTML text track.\n * TODO TTML parsing is still pretty heavy on the CPU.\n * Optimizations have been done, principally to avoid using too much XML APIs,\n * but we can still do better.\n * @param {string} str\n * @param {Number} timeOffset\n * @returns {Array.}\n */\nexport default function parseTTMLString(str, timeOffset) {\n const cues = [];\n const xml = new DOMParser().parseFromString(str, \"text/xml\");\n if (xml !== null && xml !== undefined) {\n const tts = xml.getElementsByTagName(\"tt\");\n let tt = tts[0];\n if (tt === undefined) {\n // EBU-TT sometimes namespaces tt, by \"tt:\"\n // Just catch all namespaces to play it safe\n const namespacedTT = xml.getElementsByTagNameNS(\"*\", \"tt\");\n tt = namespacedTT[0];\n if (tt === undefined) {\n throw new Error(\"invalid XML\");\n }\n }\n const body = getBodyNode(tt);\n const styleNodes = getStyleNodes(tt);\n const regionNodes = getRegionNodes(tt);\n const paragraphNodes = getTextNodes(tt);\n const ttParams = getParameters(tt);\n // construct idStyles array based on the xml as an optimization\n const idStyles = [];\n for (let i = 0; i <= styleNodes.length - 1; i++) {\n const styleNode = styleNodes[i];\n if (styleNode instanceof Element) {\n const styleID = styleNode.getAttribute(\"xml:id\");\n if (styleID !== null) {\n const subStyles = styleNode.getAttribute(\"style\");\n const extendsStyles = subStyles === null ? [] : subStyles.split(\" \");\n idStyles.push({\n id: styleID,\n style: getStylingFromElement(styleNode),\n extendsStyles,\n });\n }\n }\n }\n resolveStylesInheritance(idStyles);\n // construct regionStyles array based on the xml as an optimization\n const regionStyles = [];\n for (let i = 0; i <= regionNodes.length - 1; i++) {\n const regionNode = regionNodes[i];\n if (regionNode instanceof Element) {\n const regionID = regionNode.getAttribute(\"xml:id\");\n if (regionID !== null) {\n let regionStyle = getStylingFromElement(regionNode);\n const associatedStyleID = regionNode.getAttribute(\"style\");\n if (isNonEmptyString(associatedStyleID)) {\n const style = arrayFind(idStyles, (x) => x.id === associatedStyleID);\n if (style !== undefined) {\n regionStyle = objectAssign({}, style.style, regionStyle);\n }\n }\n regionStyles.push({\n id: regionID,\n style: regionStyle,\n // already handled\n extendsStyles: [],\n });\n }\n }\n }\n // Computing the style takes a lot of ressources.\n // To avoid too much re-computation, let's compute the body style right\n // now and do the rest progressively.\n // TODO Compute corresponding CSS style here (as soon as we now the TTML\n // style) to speed up the process even more.\n const bodyStyle = getStylingAttributes(STYLE_ATTRIBUTES, body !== null ? [body] : [], idStyles, regionStyles);\n const bodySpaceAttribute = body !== null ? body.getAttribute(\"xml:space\") : undefined;\n const shouldTrimWhiteSpaceOnBody = bodySpaceAttribute === \"default\" || ttParams.spaceStyle === \"default\";\n for (let i = 0; i < paragraphNodes.length; i++) {\n const paragraph = paragraphNodes[i];\n if (paragraph instanceof Element) {\n const divs = getParentDivElements(paragraph);\n const paragraphStyle = objectAssign({}, bodyStyle, getStylingAttributes(STYLE_ATTRIBUTES, [paragraph, ...divs], idStyles, regionStyles));\n const paragraphSpaceAttribute = paragraph.getAttribute(\"xml:space\");\n const shouldTrimWhiteSpace = isNonEmptyString(paragraphSpaceAttribute)\n ? paragraphSpaceAttribute === \"default\"\n : shouldTrimWhiteSpaceOnBody;\n const cue = {\n paragraph,\n timeOffset,\n idStyles,\n regionStyles,\n body,\n paragraphStyle,\n ttParams,\n shouldTrimWhiteSpace,\n };\n if (cue !== null) {\n cues.push(cue);\n }\n }\n }\n }\n return cues;\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport log from \"../../../log\";\nimport arrayFindIndex from \"../../../utils/array_find_index\";\nimport arrayIncludes from \"../../../utils/array_includes\";\nimport objectAssign from \"../../../utils/object_assign\";\n/**\n * Transform all styles inheriting from other styles to the same styles but with\n * the inheritance removed (by resolving those inheritance here).\n *\n * Note that the original style object is directly mutated with every\n * inheritance they had resolved and removed.\n *\n * To make a pseudo-code analogy this would be equivalent to transform those\n * two classes:\n * ```\n * class A {\n * methodA() {}\n * }\n *\n * class B extends A {\n * method B() {}\n * }\n * ```\n * into the same two classes without inheritance:\n * ```\n * class A {\n * methodA() {}\n * }\n * class B {\n * methodA() {} // inherited from class A\n * methodB() {}\n * }\n * ```\n *\n * Doing this here allows to simplify further treatment of those styles.\n * @param {Array.} styles\n */\nexport default function resolveStylesInheritance(styles) {\n // keep track of all the indexes parsed to avoid infinite loops\n const recursivelyBrowsedIndexes = [];\n function resolveStyleInheritance(styleElt, index) {\n recursivelyBrowsedIndexes.push(index);\n for (const extendedStyleID of styleElt.extendsStyles) {\n const extendedStyleIndex = arrayFindIndex(styles, (x) => x.id === extendedStyleID);\n if (extendedStyleIndex < 0) {\n log.warn(\"TTML Parser: unknown style inheritance: \" + extendedStyleID);\n }\n else {\n const extendedStyle = styles[extendedStyleIndex];\n if (arrayIncludes(recursivelyBrowsedIndexes, extendedStyleIndex)) {\n log.warn(\"TTML Parser: infinite style inheritance loop avoided\");\n }\n else {\n resolveStyleInheritance(extendedStyle, extendedStyleIndex);\n }\n styleElt.style = objectAssign({}, extendedStyle.style, styleElt.style);\n }\n }\n styleElt.extendsStyles.length = 0;\n }\n for (let i = 0; i < styles.length; i++) {\n resolveStyleInheritance(styles[i], i);\n recursivelyBrowsedIndexes.length = 0; // reset\n }\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// examples: 00:00:40:07 (7 frames) or 00:00:40:07.1 (7 frames, 1 subframe)\nconst REGXP_TIME_COLON_FRAMES = /^(\\d{2,}):(\\d{2}):(\\d{2}):(\\d{2})\\.?(\\d+)?$/;\n// examples: 00:00:40:07 (7 frames) or 00:00:40:07.1 (7 frames, 1 subframe)\nconst REGXP_TIME_COLON = /^(?:(\\d{2,}):)?(\\d{2}):(\\d{2})$/;\n// examples: 01:02:43.0345555 or 02:43.03\nconst REGXP_TIME_COLON_MS = /^(?:(\\d{2,}):)?(\\d{2}):(\\d{2}\\.\\d{2,})$/;\n// examples: 75f or 75.5f\nconst REGXP_TIME_FRAMES = /^(\\d*\\.?\\d*)f$/;\n// examples: 50t or 50.5t\nconst REGXP_TIME_TICK = /^(\\d*\\.?\\d*)t$/;\n// examples: 3.45h, 3m or 4.20s\nconst REGXP_TIME_HMS = /^(?:(\\d*\\.?\\d*)h)?(?:(\\d*\\.?\\d*)m)?(?:(\\d*\\.?\\d*)s)?(?:(\\d*\\.?\\d*)ms)?$/;\n// examples: 50% 10%\nconst REGXP_PERCENT_VALUES = /^(\\d{1,2}|100)% (\\d{1,2}|100)%$/;\nconst REGXP_LENGTH = /^((?:\\+|\\-)?\\d*(?:\\.\\d+)?)(px|em|c|%|rh|rw)$/;\nconst REGXP_8_HEX_COLOR = /^#([0-9A-f]{2})([0-9A-f]{2})([0-9A-f]{2})([0-9A-f]{2})$/;\nconst REGXP_4_HEX_COLOR = /^#([0-9A-f])([0-9A-f])([0-9A-f])([0-9A-f])$/;\nconst REGXP_RGB_COLOR = /^rgb\\( *(\\d+) *, *(\\d+) *, *(\\d+) *\\)/;\nconst REGXP_RGBA_COLOR = /^rgba\\( *(\\d+) *, *(\\d+) *, *(\\d+) *, *(\\d+) *\\)/;\nexport { REGXP_4_HEX_COLOR, REGXP_8_HEX_COLOR, REGXP_RGB_COLOR, REGXP_RGBA_COLOR, REGXP_LENGTH, REGXP_PERCENT_VALUES, REGXP_TIME_COLON, REGXP_TIME_COLON_FRAMES, REGXP_TIME_COLON_MS, REGXP_TIME_FRAMES, REGXP_TIME_HMS, REGXP_TIME_TICK, };\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport isNullOrUndefined from \"../../../utils/is_null_or_undefined\";\n/**\n * Returns the parent elements which have the given tagName, by order of\n * closeness relative to our element.\n * @param {Element|Node} element\n * @param {string} tagName\n * @returns {Array.}\n */\nexport function getParentElementsByTagName(element, tagName) {\n if (!(element.parentNode instanceof Element)) {\n return [];\n }\n function constructArray(_element) {\n const elements = [];\n if (_element.tagName.toLowerCase() === tagName.toLowerCase()) {\n elements.push(_element);\n }\n const parentNode = _element.parentNode;\n if (parentNode instanceof Element) {\n elements.push(...constructArray(parentNode));\n }\n return elements;\n }\n return constructArray(element.parentNode);\n}\n/**\n * Returns the parent elements which have the given tagName, by order of\n * closeness relative to our element.\n * @param {Element|Node} element\n * @returns {Array.}\n */\nexport function getParentDivElements(element) {\n let divs = getParentElementsByTagName(element, \"div\");\n if (divs.length === 0) {\n const ttDivs = getParentElementsByTagName(element, \"tt:div\");\n if (ttDivs.length > 0) {\n divs = ttDivs;\n }\n }\n return divs;\n}\n/**\n * Returns the first notion of the attribute encountered in the list of elemnts\n * given.\n * @param {string} attribute\n * @param {Array.} elements\n * @returns {string|undefined}\n */\nexport function getAttributeInElements(attribute, elements) {\n for (let i = 0; i <= elements.length - 1; i++) {\n const element = elements[i];\n if (element !== undefined) {\n const directAttrValue = element.getAttribute(attribute);\n if (!isNullOrUndefined(directAttrValue)) {\n return directAttrValue;\n }\n }\n }\n}\n/**\n * @param {Element} tt\n * @returns {Element}\n */\nexport function getBodyNode(tt) {\n const bodyNodes = tt.getElementsByTagName(\"body\");\n if (bodyNodes.length > 0) {\n return bodyNodes[0];\n }\n const namespacedBodyNodes = tt.getElementsByTagName(\"tt:body\");\n if (namespacedBodyNodes.length > 0) {\n return namespacedBodyNodes[0];\n }\n return null;\n}\n/**\n * @param {Element} tt - node\n * @returns {Array.}\n */\nexport function getStyleNodes(tt) {\n const styleNodes = tt.getElementsByTagName(\"style\");\n if (styleNodes.length > 0) {\n return styleNodes;\n }\n const namespacedStyleNodes = tt.getElementsByTagName(\"tt:style\");\n if (namespacedStyleNodes.length > 0) {\n return namespacedStyleNodes;\n }\n return styleNodes;\n}\n/**\n * @param {Element} tt - node\n * @returns {Array.}\n */\nexport function getRegionNodes(tt) {\n const regionNodes = tt.getElementsByTagName(\"region\");\n if (regionNodes.length > 0) {\n return regionNodes;\n }\n const namespacedRegionNodes = tt.getElementsByTagName(\"tt:region\");\n if (namespacedRegionNodes.length > 0) {\n return namespacedRegionNodes;\n }\n return regionNodes;\n}\n/**\n * @param {Element} tt - node\n * @returns {Array.}\n */\nexport function getTextNodes(tt) {\n const pNodes = tt.getElementsByTagName(\"p\");\n if (pNodes.length > 0) {\n return pNodes;\n }\n const namespacedPNodes = tt.getElementsByTagName(\"tt:p\");\n if (namespacedPNodes.length > 0) {\n return namespacedPNodes;\n }\n return pNodes;\n}\n/**\n * Returns true if the given node corresponds to a TTML line break element.\n * @param {Node} node\n * @returns {boolean}\n */\nexport function isLineBreakElement(node) {\n return node.nodeName === \"br\" || node.nodeName === \"tt:br\";\n}\n/**\n * Returns true if the given node corresponds to a TTML span element.\n * @param {Node} node\n * @returns {boolean}\n */\nexport function isSpanElement(node) {\n return node.nodeName === \"span\" || node.nodeName === \"tt:span\";\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport isNonEmptyString from \"../../../utils/is_non_empty_string\";\nimport { findEndOfCueBlock, isStartOfCueBlock } from \"./utils\";\n/**\n * Get cue blocks from a WebVTT file.\n * @param {Array.} linified - Whole WebVTT file. Each new element in\n * this array is a new line.\n * @param {number} headerOffset - index of the first line after the header.\n * Used to avoid taking the header into consideration.\n * @returns {Array.>}\n */\nexport default function getCueBlocks(linified, headerOffset) {\n const cueBlocks = [];\n for (let i = headerOffset; i < linified.length; i++) {\n if (isStartOfCueBlock(linified, i)) {\n const endOfCue = findEndOfCueBlock(linified, i);\n cueBlocks.push(linified.slice(i, endOfCue));\n i = endOfCue;\n }\n else if (isNonEmptyString(linified[i])) {\n // continue incrementing i until either:\n // - empty line\n // - end\n while (isNonEmptyString(linified[i])) {\n i++;\n }\n }\n }\n return cueBlocks;\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport isNonEmptyString from \"../../../utils/is_non_empty_string\";\n/**\n * Parse a single webvtt timestamp into seconds\n * @param {string} timestampString\n * @returns {Number|undefined}\n */\nexport default function parseTimestamp(timestampString) {\n const splittedTS = timestampString.split(\":\").reverse();\n if (isNonEmptyString(splittedTS[2]) || isNonEmptyString(splittedTS[1])) {\n const hours = isNonEmptyString(splittedTS[2]) ? parseInt(splittedTS[2], 10) : 0;\n const minutes = parseInt(splittedTS[1], 10);\n const seconds = parseFloat(splittedTS[0].replace(\",\", \".\"));\n if (isNaN(hours) || isNaN(minutes) || isNaN(seconds)) {\n return undefined;\n }\n return hours * 60 * 60 + minutes * 60 + seconds;\n }\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport parseTimestamp from \"./parse_timestamp\";\n/**\n * Parse the settings part of a cue, into key-value object.\n * @param {string} settingsString\n * @returns {Object}\n */\nfunction parseSettings(settingsString) {\n const splittedSettings = settingsString.split(/ |\\t/);\n return splittedSettings.reduce((acc, setting) => {\n const splittedSetting = setting.split(\":\");\n if (splittedSetting.length === 2) {\n acc[splittedSetting[0]] = splittedSetting[1];\n }\n return acc;\n }, {});\n}\n/**\n * Parse the line containing the timestamp and settings in a cue.\n * The returned object has the following properties:\n * - start {Number}: start of the cue, in seconds\n * - end {Number}: end of the cue, in seconds\n * - settings {Object}: settings for the cue as a key-value object.\n * @param {string} timeString\n * @returns {Object|null}\n */\nfunction parseTimeAndSettings(timeString) {\n // RegExp for the timestamps + settings line.\n // Capture groups:\n // 1 -> start timestamp\n // 2 -> end timestamp\n // 3 - settings\n const lineRegex = /^([\\d:.]+)[ |\\t]+-->[ |\\t]+([\\d:.]+)[ |\\t]*(.*)$/;\n const matches = lineRegex.exec(timeString);\n if (matches === null) {\n return null;\n }\n const start = parseTimestamp(matches[1]);\n const end = parseTimestamp(matches[2]);\n if (start === undefined || end === undefined) {\n return null;\n }\n const settings = parseSettings(matches[3]);\n return { start, end, settings };\n}\n/**\n * Parse cue block into a cue object which contains:\n * - start {number}: the start of the cue as a timestamp in seconds\n * - end {number}: the end of the cue as a timestamp in seconds\n * - header {string|undefined}: The optional cue identifier\n * - payload {Array.}: the payload of the cue\n * @param {Array.} cueLines\n * @param {Number} timeOffset\n * @returns {Object}\n */\nexport default function parseCueBlock(cueLines, timeOffset) {\n const timingRegexp = /-->/;\n let timeString;\n let payload;\n let header;\n if (!timingRegexp.test(cueLines[0])) {\n if (!timingRegexp.test(cueLines[1])) {\n // not a cue\n return null;\n }\n header = cueLines[0];\n timeString = cueLines[1];\n payload = cueLines.slice(2, cueLines.length);\n }\n else {\n timeString = cueLines[0];\n payload = cueLines.slice(1, cueLines.length);\n }\n const timeAndSettings = parseTimeAndSettings(timeString);\n if (timeAndSettings === null) {\n return null;\n }\n const { start, end, settings } = timeAndSettings;\n return {\n start: start + timeOffset,\n end: end + timeOffset,\n settings,\n payload,\n header,\n };\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport isNonEmptyString from \"../../../utils/is_non_empty_string\";\n/**\n * Returns first line after the WEBVTT header.\n * That is, the line after the first blank line after the first line!\n * @param {Array.} linified\n * @returns {Number}\n */\nfunction getFirstLineAfterHeader(linified) {\n let i = 0;\n while (i < linified.length) {\n if (linified[i] === \"\") {\n return i + 1;\n }\n i++;\n }\n return i;\n}\n/**\n * Returns true if the given line looks like the beginning of a Style block.\n * @param {string} text\n * @returns {Boolean}\n */\nfunction isStartOfStyleBlock(lines, index) {\n return (typeof lines[index] === \"string\" &&\n /^STYLE( .*)?$/g.test(lines[index]) &&\n // A cue identifer can also contain \"STYLE\". Check that we have no timings\n // on the second line\n (lines[index + 1] === undefined || lines[index + 1].indexOf(\"-->\") < 0));\n}\n/**\n * Returns true if the given line looks like the beginning of a comment block.\n * @param {string} text\n * @returns {Boolean}\n */\nfunction isStartOfNoteBlock(lines, index) {\n return (typeof lines[index] === \"string\" &&\n /^NOTE( .*)?$/g.test(lines[index]) &&\n // A cue identifer can also contain \"NOTE\". Check that we have no timings\n // on the second line\n (lines[index + 1] === undefined || lines[index + 1].indexOf(\"-->\") < 0));\n}\n/**\n * Returns true if the given line looks like the beginning of a region block.\n * @param {string} text\n * @returns {Boolean}\n */\nfunction isStartOfRegionBlock(lines, index) {\n return (typeof lines[index] === \"string\" &&\n /^REGION( .*)?$/g.test(lines[index]) &&\n // A cue identifer can also contain \"REGION\". Check that we have no timings\n // on the second line\n (lines[index + 1] === undefined || lines[index + 1].indexOf(\"-->\") < 0));\n}\n/**\n * Returns true if the line given looks like the beginning of a cue.\n * You should provide to this function only lines following \"empty\" lines.\n * @param {Array.} lines\n * @param {number} index\n * @returns {Boolean}\n */\nfunction isStartOfCueBlock(lines, index) {\n // checked cases:\n // - empty lines\n // - start of a comment\n // - start of a region\n // - start of a style\n // Anything else whose first or second line is a timestamp line is a cue.\n const firstLine = lines[index];\n if (firstLine === undefined ||\n firstLine === \"\" ||\n isStartOfStyleBlock(lines, index) ||\n isStartOfRegionBlock(lines, index) ||\n isStartOfNoteBlock(lines, index)) {\n return false;\n }\n if (firstLine.indexOf(\"-->\") >= 0) {\n return true;\n }\n const secondLine = lines[index + 1];\n return secondLine !== undefined && secondLine.indexOf(\"-->\") >= 0;\n}\n/**\n * Find end of current WebVTT cue block.\n * @param {Array} linified\n * @param {number} startOfCueBlock\n * @returns {number}\n */\nfunction findEndOfCueBlock(linified, startOfCueBlock) {\n let firstEmptyLineIndex = startOfCueBlock + 1;\n // continue incrementing i until either:\n // - empty line\n // - end\n while (isNonEmptyString(linified[firstEmptyLineIndex])) {\n firstEmptyLineIndex++;\n }\n return firstEmptyLineIndex;\n}\nexport { getFirstLineAfterHeader, isStartOfCueBlock, isStartOfNoteBlock, isStartOfRegionBlock, isStartOfStyleBlock, findEndOfCueBlock, };\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Array.prototype.includes ponyfill.\n * Returns ``true`` if the given array ``arr`` contains the element\n * ``searchElement``. false ``otherwise``.\n *\n * Inspired from MDN polyfill, but ponyfilled instead\n *\n * @example\n * ```js\n * arrayIncludes([1, 2, 3], 3);\n * // => true\n *\n * arrayIncludes([1, 2, 3], 7);\n * // => false\n *\n * const obj = { a: 4 };\n * arrayIncludes([obj, { b: 7 }, { a: 3 }], obj);\n * // => true\n *\n * // does not perform deep equality\n * arrayIncludes([{ a: 4 }, { b: 7 }, { a: 3 }], { a: 4 });\n * // => false\n *\n * // the third argument state the starting index. 0 if not set.\n *\n * arrayIncludes([1, 2, 3], 2, 1);\n * // => true\n *\n * arrayIncludes([1, 2, 3], 2, 2);\n * // => false\n * ```\n *\n * @param {Array} arr\n * @param {*} searchElement\n * @param {number} [fromIndex]\n * @returns {boolean}\n */\nexport default function arrayIncludes(arr, searchElement, fromIndex) {\n // eslint-disable-next-line no-restricted-properties, @typescript-eslint/unbound-method\n if (typeof Array.prototype.includes === \"function\") {\n // eslint-disable-next-line no-restricted-properties\n return arr.includes(searchElement, fromIndex);\n }\n const len = arr.length >>> 0;\n if (len === 0) {\n return false;\n }\n const n = fromIndex | 0;\n let k = n >= 0 ? Math.min(n, len - 1) : Math.max(len + n, 0);\n const areTheSame = (x, y) => x === y ||\n // Viva las JavaScriptas!\n (typeof x === \"number\" && typeof y === \"number\" && isNaN(x) && isNaN(y));\n while (k < len) {\n if (areTheSame(arr[k], searchElement)) {\n return true;\n }\n k++;\n }\n return false;\n}\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @param {Object|Array} o\n * @returns {Array.<*>}\n */\nfunction objectValues(o) {\n return Object.keys(o).map((k) => o[k]);\n}\n// eslint-disable-next-line @typescript-eslint/unbound-method, no-restricted-properties\nexport default typeof Object.values === \"function\" ? Object.values : objectValues;\nexport { objectValues };\n","/**\n * Copyright 2015 CANAL+ Group\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * This file contains functions helping with TimeRanges management.\n *\n * For simplicity/performance reasons, many of those work with a simplified\n * \"Range\" object, which is an object with two keys:\n * - start {Number}\n * - end {Number}\n *\n * Those two corresponds to what is returned by the start and end methods of a\n * TimeRanges Object.\n *\n * You can convert from TimeRanges to Range object(s) with the getRange/\n * convertToRanges methods.\n */\n// Factor for rounding errors\nconst EPSILON = 1 / 60;\n/**\n * Check equality with a tolerance of EPSILON.\n * Used for various functions with this sort of tolerance regarding the\n * start/end of contiguous ranges.\n * @param {Number} a\n * @param {Number} b\n * @returns {Boolean}\n */\nfunction nearlyEqual(a, b) {\n return Math.abs(a - b) < EPSILON;\n}\n/**\n * Construct a new range which will have, as start/end, the min/max\n * of both the range given, and the given bitrate.\n * @param {Object} range1\n * @param {Object} range2\n * @returns {Object}\n */\nfunction createRangeUnion(range1, range2) {\n const start = Math.min(range1.start, range2.start);\n const end = Math.max(range1.end, range2.end);\n return { start, end };\n}\n/**\n * Clean array ranges from \"empty\" ranges.\n * That is, range objects which have their start equal to their end.\n * /!\\ Mutate the array of ranges.\n * @param {Array} ranges\n * @returns {Array}\n */\nfunction removeEmptyRanges(ranges) {\n for (let index = 0; index < ranges.length; index++) {\n const range = ranges[index];\n if (range.start === range.end) {\n ranges.splice(index--, 1);\n }\n }\n return ranges;\n}\n/**\n * /!\\ Mutate the array of ranges.\n * @param {Array} ranges\n * @returns {Array}\n */\nfunction mergeContiguousRanges(ranges) {\n for (let index = 1; index < ranges.length; index++) {\n const prevRange = ranges[index - 1];\n const currRange = ranges[index];\n if (areRangesNearlyContiguous(prevRange, currRange)) {\n const unionRange = createRangeUnion(prevRange, currRange);\n ranges.splice(--index, 2, unionRange);\n }\n }\n return ranges;\n}\n/**\n * True if range1 is considered _after_ range2.\n * @param {Object} range1\n * @param {Object} range2\n * @returns {Boolean}\n */\nfunction isAfter(range1, range2) {\n return range1.start >= range2.end;\n}\n/**\n * True if range1 is considered _before_ range2.\n * @param {Object} range1\n * @param {Object} range2\n * @returns {Boolean}\n */\nfunction isBefore(range1, range2) {\n return range1.end <= range2.start;\n}\n/**\n * Returns true if the time given can be considered as part of any of the given\n * ranges.\n * @param {Array.} ranges\n * @param {number} time\n * @returns {boolean}\n */\nfunction isTimeInRanges(ranges, time) {\n for (let i = 0; i < ranges.length; i++) {\n if (isTimeInRange(ranges[i], time)) {\n return true;\n }\n }\n return false;\n}\n/**\n * Returns true if the time given can be considered as part of the given range.\n * @param {Object} range1\n * @param {Number} Time\n * @returns {Boolean}\n */\nfunction isTimeInRange({ start, end }, time) {\n return start <= time && time < end;\n}\n/**\n * Returns true if the two ranges given are overlapping.\n * @param {Object} range1\n * @param {Object} range2\n * @returns {Boolean}\n */\nfunction areRangesOverlapping(range1, range2) {\n return (isTimeInRange(range1, range2.start) ||\n (range1.start < range2.end && range2.end < range1.end) ||\n isTimeInRange(range2, range1.start));\n}\n/**\n * Returns true if the two ranges given can be considered contiguous.\n * @param {Object} range1\n * @param {Object} range2\n * @returns {Boolean}\n */\nfunction areRangesNearlyContiguous(range1, range2) {\n return nearlyEqual(range2.start, range1.end) || nearlyEqual(range2.end, range1.start);\n}\n/**\n * Convert from a TimeRanges object to an array of Ranges.\n * @param {TimeRanges} timeRanges\n * @returns {Array.}\n */\nfunction convertToRanges(timeRanges) {\n const ranges = [];\n for (let i = 0; i < timeRanges.length; i++) {\n ranges.push({ start: timeRanges.start(i), end: timeRanges.end(i) });\n }\n return ranges;\n}\n/**\n * Get range object of a specific time in a TimeRanges object.\n * @param {TimeRanges} timeRanges\n * @returns {Object}\n */\nfunction getBufferedTimeRange(timeRanges, time) {\n for (let i = timeRanges.length - 1; i >= 0; i--) {\n const start = timeRanges.start(i);\n if (time >= start) {\n const end = timeRanges.end(i);\n if (time < end) {\n return { start, end };\n }\n }\n }\n return null;\n}\n/**\n * Get range object of a specific time in a `IRange` object.\n * @param {Array.} ranges\n * @returns {Object}\n */\nfunction getRange(ranges, time) {\n for (let i = ranges.length - 1; i >= 0; i--) {\n const start = ranges[i].start;\n if (time >= start) {\n const end = ranges[i].end;\n if (time < end) {\n return ranges[i];\n }\n }\n }\n return null;\n}\n/**\n * Get gap from a specific time until the start of the next Range.\n * @param {TimeRanges} timeRanges\n * @param {Number} time\n * @returns {Number}\n */\nfunction getNextBufferedTimeRangeGap(timeRanges, time) {\n const len = timeRanges.length;\n for (let i = 0; i < len; i++) {\n const start = timeRanges.start(i);\n if (time < start) {\n return start - time;\n }\n }\n return Infinity;\n}\n/**\n * @param {TimeRanges} timeRanges\n * @param {Number} time\n * @returns {Object} - Object with two properties:\n * - outerRanges {Array.}: every ranges which does not contain the\n * given time.\n * - innerRange {Object|null}: the range which contain the given time.\n */\nfunction getInnerAndOuterRangesFromBufferedTimeRanges(timeRanges, time) {\n let innerRange = null;\n const outerRanges = [];\n for (let i = 0; i < timeRanges.length; i++) {\n const start = timeRanges.start(i);\n const end = timeRanges.end(i);\n if (time < start || time >= end) {\n outerRanges.push({ start, end });\n }\n else {\n innerRange = { start, end };\n }\n }\n return { outerRanges, innerRange };\n}\n/**\n * @param {Array.} ranges\n * @param {Number} time\n * @returns {Object} - Object with two properties:\n * - outerRanges {Array.}: every ranges which does not contain the\n * given time.\n * - innerRange {Object|null}: the range which contain the given time.\n */\nfunction getInnerAndOuterRanges(ranges, time) {\n let innerRange = null;\n const outerRanges = [];\n for (let i = 0; i < ranges.length; i++) {\n const start = ranges[i].start;\n const end = ranges[i].end;\n if (time < start || time >= end) {\n outerRanges.push({ start, end });\n }\n else {\n innerRange = { start, end };\n }\n }\n return { outerRanges, innerRange };\n}\n/**\n * Get \"size\" (difference between end and start) of the TimeRange containing the\n * given time. 0 if the range is not found.\n * @param {TimeRanges} timeRanges\n * @param {Number} currentTime\n * @returns {Number}\n */\nfunction getSizeOfBufferedTimeRange(timeRanges, currentTime) {\n const range = getBufferedTimeRange(timeRanges, currentTime);\n return range !== null ? range.end - range.start : 0;\n}\n/**\n * Get \"currently played\" (difference between time given and start) of the\n * range containing the given time. 0 if the range is not found.\n * @param {TimeRanges} timeRanges\n * @param {Number} currentTime\n * @returns {Number}\n */\nfunction getPlayedSizeOfBufferedTimeRange(timeRanges, currentTime) {\n const range = getBufferedTimeRange(timeRanges, currentTime);\n return range !== null ? currentTime - range.start : 0;\n}\n/**\n * Get \"left to play\" (difference between end and time given) of the range\n * containing the given time. Infinity if the range is not found.\n * @param {TimeRanges} timeRanges\n * @param {Number} currentTime\n * @returns {Number}\n */\nfunction getLeftSizeOfBufferedTimeRange(timeRanges, currentTime) {\n const range = getBufferedTimeRange(timeRanges, currentTime);\n return range !== null ? range.end - currentTime : Infinity;\n}\n/**\n * Get \"size\" (difference between end and start) of the range containing the\n * given time. 0 if the range is not found.\n * @param {Array.} ranges\n * @param {Number} currentTime\n * @returns {Number}\n */\nfunction getSizeOfRange(ranges, currentTime) {\n const range = getRange(ranges, currentTime);\n return range !== null ? range.end - range.start : 0;\n}\n/**\n * Get \"currently played\" (difference between time given and start) of the\n * range containing the given time. 0 if the range is not found.\n * @param {Array.} ranges\n * @param {Number} currentTime\n * @returns {Number}\n */\nfunction getPlayedSizeOfRange(ranges, currentTime) {\n const range = getRange(ranges, currentTime);\n return range !== null ? currentTime - range.start : 0;\n}\n/**\n * Get \"left to play\" (difference between end and time given) of the range\n * containing the given time. Infinity if the range is not found.\n * @param {Array.} ranges\n * @param {Number} currentTime\n * @returns {Number}\n */\nfunction getLeftSizeOfRange(ranges, currentTime) {\n const range = getRange(ranges, currentTime);\n return range !== null ? range.end - currentTime : Infinity;\n}\n/**\n * Insert a range object into an array of ranges objects, at the right place.\n * /!\\ Mutate the array of ranges.\n * @param {Array.} ranges\n * @param {Object} rangeToAddArg\n * @returns {Array.}\n */\nfunction insertInto(ranges, rangeToAddArg) {\n if (rangeToAddArg.start === rangeToAddArg.end) {\n return ranges;\n }\n let rangeToAdd = rangeToAddArg;\n // For each present range check if we need to:\n // - In case we are overlapping or contiguous:\n // - if added range has the same bitrate as the overlapped or\n // contiguous one, we can merge themcurrentRange\n // - if added range has a different bitrate we need to insert it\n // in place\n // - Need to insert in place, we we are completely, not overlapping\n // and not contiguous in between two ranges.\n let index = 0;\n for (; index < ranges.length; index++) {\n const range = ranges[index];\n const overlapping = areRangesOverlapping(rangeToAdd, range);\n const contiguous = areRangesNearlyContiguous(rangeToAdd, range);\n // We assume ranges are ordered and two ranges can not be\n // completely overlapping.\n if (overlapping || contiguous) {\n rangeToAdd = createRangeUnion(rangeToAdd, range);\n ranges.splice(index--, 1);\n }\n else {\n // Check the case for which there is no more to do\n if (index === 0) {\n if (isBefore(rangeToAdd, ranges[0])) {\n // First index, and we are completely before that range (and\n // not contiguous, nor overlapping). We just need to be\n // inserted here.\n break;\n }\n }\n else {\n if (isBefore(ranges[index - 1], rangeToAdd) && isBefore(rangeToAdd, range)) {\n // We are exactly after the current previous range, and\n // before the current range, while not overlapping with none\n // of them. Insert here.\n break;\n }\n }\n }\n }\n // Now that we are sure we don't overlap with any range, just add it.\n ranges.splice(index, 0, rangeToAdd);\n return mergeContiguousRanges(removeEmptyRanges(ranges));\n}\n/**\n * Returns range, from a range objects array overlapping with a range given\n * in argument. null if none is found.\n * @param {Object} range\n * @param {Array.} ranges\n * @returns {Array.}\n */\nfunction findOverlappingRanges(range, ranges) {\n const resultingRanges = [];\n for (let i = 0; i < ranges.length; i++) {\n if (areRangesOverlapping(range, ranges[i])) {\n resultingRanges.push(ranges[i]);\n }\n }\n return resultingRanges;\n}\n/**\n * Returns only the intersection between the two ranges, from the first\n * ranges argument given.\n * @param {Array.} ranges1\n * @param {Array.} ranges2\n * @returns {Array.}\n */\nfunction keepRangeIntersection(ranges1, ranges2) {\n const result = [];\n for (let i = 0; i < ranges1.length; i++) {\n const range = ranges1[i];\n const overlappingRanges = findOverlappingRanges(range, ranges2);\n if (overlappingRanges.length > 0) {\n for (let j = 0; j < overlappingRanges.length; j++) {\n const overlappingRange = overlappingRanges[j];\n result.push({\n start: Math.max(range.start, overlappingRange.start),\n end: Math.min(range.end, overlappingRange.end),\n });\n }\n }\n }\n return result;\n}\n/**\n * Exclude from the `baseRanges` everything that is in `rangesToExclude`.\n * Example:\n *\n * Let's say we have the following base ranges:\n * |==========| |===============| |======| |==========|\n *\n * From which we want to \"exclude\" the following ranges:\n * |=========| |==| |===| |=====|\n *\n * We will obtain the first ranges from which we remove the second ranges:\n * -----------------------------------------------------------------------\n * |==========| |===============| |======| |==========|\n * |=========| |==| |===| |=====|\n * _______________________________________________________________________\n * |\n * |\n * V\n * -----------------------------------------------------------------------\n * |==| |======| |==| |====| |==========|\n * -----------------------------------------------------------------------\n *\n * @param {Array.}\n */\nfunction excludeFromRanges(baseRanges, rangesToExclude) {\n const result = [];\n // For every range in `baseRanges`, find overlapping ranges with\n // `rangesToExclude` and remove them.\n for (let i = 0; i < baseRanges.length; i++) {\n const range = baseRanges[i];\n const intersections = [];\n const overlappingRanges = findOverlappingRanges(range, rangesToExclude);\n if (overlappingRanges.length > 0) {\n for (let j = 0; j < overlappingRanges.length; j++) {\n const overlappingRange = overlappingRanges[j];\n intersections.push({\n start: Math.max(range.start, overlappingRange.start),\n end: Math.min(range.end, overlappingRange.end),\n });\n }\n }\n if (intersections.length === 0) {\n result.push(range);\n }\n else {\n let lastStart = range.start;\n for (let j = 0; j < intersections.length; j++) {\n if (intersections[j].start > lastStart) {\n result.push({ start: lastStart, end: intersections[j].start });\n }\n lastStart = intersections[j].end;\n }\n if (lastStart < range.end) {\n result.push({ start: lastStart, end: range.end });\n }\n }\n }\n return result;\n}\n/**\n * Returns `true` if the given `time` is available in the TimeRanges object\n * given.\n * Returns `false` otherwise.\n * @param {TimeRanges} ranges\n * @param {Number} time\n * @returns {boolean}\n */\nfunction isTimeInTimeRanges(ranges, time) {\n for (let i = 0; i < ranges.length; i++) {\n if (ranges.start(i) <= time && time < ranges.end(i)) {\n return true;\n }\n }\n return false;\n}\nexport { convertToRanges, excludeFromRanges, getInnerAndOuterRangesFromBufferedTimeRanges, getInnerAndOuterRanges, getLeftSizeOfRange, getNextBufferedTimeRangeGap, getSizeOfBufferedTimeRange, getPlayedSizeOfBufferedTimeRange, getLeftSizeOfBufferedTimeRange, getPlayedSizeOfRange, getBufferedTimeRange, getRange, getSizeOfRange, insertInto, isAfter, isBefore, isTimeInTimeRanges, isTimeInRange, isTimeInRanges, keepRangeIntersection, mergeContiguousRanges, removeEmptyRanges, };\n"],"names":["addFeatures","featureFuncList","addFeature","features","isNullOrUndefined","_addFeature","Error","dashParsers","wasm","native","fastJs","createDebugElement","directfile","decrypt","htmlTextDisplayer","htmlTextTracksParsers","mainThreadMediaSourceInit","multithread","nativeTextDisplayer","nativeTextTracksParsers","transports","HTML_ENTITIES","BR","STYLE","PARAG","START","getCSSProperty","str","name","matches","RegExp","exec","Array","isArray","smi","timeOffset","lang","syncOpen","syncClose","subs","styleMatches","css","up","to","langs","ruleRe","m","getClassNameByLang","pCSS","rule","getPCSSRules","klass","isNonEmptyString","undefined","index","slice","tim","start","isNaN","appendToSubs","split","lines","i","length","paragraphInfos","className","txt","end","wrapperEl","document","createElement","divEl","style","position","bottom","width","color","textShadow","pEl","cssText","textEls","j","appendChild","spanEl","textContent","replace","_","$1","String","fromCharCode","Number","push","element","addHTMLSAMIFeature","sami","samiParser","HTMLTextDisplayer","shouldApplyDefaultTTMLStyle","paragraphStyle","extent","origin","displayAlign","display","textAlign","fontSize","applyDefaultTTMLStyle","hasClassList","addClassName","elt","classList","add","indexOf","generateCSSTextOutline","thickness","thick","trim","endsWith","parseInt","toString","ttmlColorToCSSColor","regRes","REGXP_8_HEX_COLOR","REGXP_4_HEX_COLOR","REGXP_RGB_COLOR","REGXP_RGBA_COLOR","SPAN_LEVEL_ATTRIBUTES","applyTextStyle","shouldTrimWhiteSpace","backgroundColor","textOutline","outlineData","len","outlineColor","isFirstArgAColor","test","textDecoration","fontFamily","fontStyle","fontWeight","splittedFontSize","firstFontSize","REGXP_LENGTH","setAttribute","toNum","log","warn","applyFontSize","direction","unicodeBidi","visibility","wrapOption","whiteSpace","applyGeneralStyle","trimmedExtent","splittedExtent","firstExtent","secondExtent","height","applyExtent","writingMode","overflow","padding","splittedPadding","firstPadding","firstPaddingValue","paddingTop","paddingBottom","secondPadding","secondPaddingValue","paddingLeft","paddingRight","thirdPadding","thirdPaddingValue","fourthPadding","fourthPaddingValue","applyPadding","trimmedOrigin","splittedOrigin","firstOrigin","secondOrigin","left","top","applyOrigin","flexDirection","justifyContent","opacity","applyPStyle","margin","paragraphBackgroundColor","lineHeight","_element","trimmedLineHeight","splittedLineHeight","firstLineHeight","applyLineHeight","createTextElement","el","textElement","trimmed","textNode","createTextNode","paragraph","body","regions","styles","cellResolution","divs","getParentDivElements","parentElement","columns","rows","bodyBackgroundColor","getStylingAttributes","pElement","loop","node","spans","shouldTrimWhiteSpaceFromParent","childNodes","elements","currentNode","nodeName","isLineBreakElement","br","isSpanElement","nodeType","Node","ELEMENT_NODE","spaceAttribute","getAttribute","shouldTrimWhiteSpaceOnSpan","newStyle","objectAssign","generateTextContent","parseCue","parsedCue","ttParams","regionStyles","idStyles","hasAttribute","getTimeDelimiters","parsedCues","parseTtml","cues","cue","addHTMLTTMLFeature","ttml","ttmlParser","colorMap","white","lime","cyan","red","yellow","magenta","blue","black","parseStyleBlocks","styleBlocks","classes","Object","keys","reduce","result","key","global","forEach","styleBlock","line","classNames","cueClassLine","styleContent","createStyledElement","baseNode","styleElements","HTMLTags","mainNodeName","toLowerCase","nodeWithStyle","arrayIncludes","linifiedText","wholeText","nodeClasses","styleContents","nodeClass","attr","createAttribute","value","nameClass","setAttributeNode","elementTag","child","getAttrValue","settings","objectValues","xPositioning","getPositioningX","yPositioning","getPositioningY","offset","getSizePercentage","size","getAlignValue","align","PositionAlignment","Align","LineAlignment","getXPositionPercentage","getXOffsetPercentage","positionPercentage","getPercentageValue","LEFT","CENTER","RIGHT","positionAlignmentMap","LINE_LEFT","LINE_RIGHT","positionAlignment","positionSetting","getPositionAlignment","getYPositionPercentage","getYOffsetPercentage","lineSetting","lineAlignmentMap","END","lineAlignment","getLineAlignment","alignSetting","sizeSetting","getPercentageValueOrDefault","percentageString","defaultValue","toHTML","cueObj","styling","header","payload","region","regionAttr","pAttr","createStyleAttribute","spanElement","filter","s","join","text","filteredText","nodes","DOMParser","parseFromString","styledElements","convertPayloadToHTML","linified","cuesArray","firstLineAfterHeader","getFirstLineAfterHeader","headerOffset","isStartOfStyleBlock","startOfStyleBlock","getStyleBlocks","cueBlocks","getCueBlocks","cueObject","parseCueBlock","htmlCue","addHTMLVTTFeature","vtt","vttParser","_ResizeObserver","globalScope","ResizeObserver","areNearlyEqual","a","b","delta","Math","abs","min","areCuesStartNearlyEqual","firstCue","secondCue","firstCueDuration","secondCueDuration","getCuesBefore","time","getCuesAfter","removeCuesInfosBetween","cuesInfos","endCuesInfos1","max","cues1","cuesInfos1","startCuesInfos2","cues2","TextTrackCuesStore","constructor","this","_cuesBuffer","isEmpty","get","cuesBuffer","ret","cueIdx","segment","remove","from","_to","startCuesInfos","cuesInfos2","splice","insert","cuesInfosToInsert","relativeDelta","onIndexOfNextCueFound","indexOfNextCue","nextCue","nextCueIdx","lastCue","updateProportionalElements","currentHeight","currentWidth","resolution","textTrackElement","cellUnit","proportElts","getElementsByClassName","eltIdx","HTMLElement","fontSizeVal","widthVal","heightVal","lineHeightVal","leftVal","topVal","paddingTopVal","paddingBottomVal","paddingLeftVal","paddingRightVal","safelyRemoveChild","removeChild","_error","getElementResolution","strRows","strColumns","videoElement","debug","_buffered","ManualTimeRanges","_videoElement","_textTrackElement","_sizeUpdateCanceller","TaskCanceller","_subtitlesIntervalCanceller","_buffer","_currentCues","_isAutoRefreshing","pushTextData","infos","_a","_b","timestampOffset","appendWindow","chunk","convertToRanges","startTime","endTime","data","dataString","type","language","appendWindowStart","appendWindowEnd","Infinity","parser","parsed","parseTextTrackToElements","autoRefreshSubtitles","signal","removeBuffer","refreshSubtitles","cancel","getBufferedRanges","reset","stop","isUsed","_disableCurrentCues","_displayCues","every","current","proportionalCues","linkToSignal","TEXT_TRACK_SIZE_CHECKS_INTERVAL","config","getCurrent","interval","cancellationSignal","initHeight","initWidth","getBoundingClientRect","ref","SharedReference","lastHeight","lastWidth","resizeObserver","entries","error","entry","contentRect","setValue","observe","register","disconnect","intervalId","setInterval","clearInterval","onHeightWidthChange","onUpdate","clearSignal","emitCurrentValue","isCancelled","autoRefreshCanceller","MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL","stopAutoRefresh","startAutoRefresh","onSeeking","onSeeked","onEnded","paused","playbackRate","currentTime","_ranges","insertInto","rangesToIntersect","keepRangeIntersection","attributes","currentStyle","leftAttributes","styleID","regionID","attribute","nameWithoutTTS","substring","arrayFind","x","id","getStylingFromElement","styleAttribute","startsWith","parseTimeFromRegExp","regex","results","hours","minutes","seconds","milliseconds","REGXP_TIME_COLON_FRAMES","frames","subframes","subFrameRate","frameRate","parseColonTimeWithFrames","REGXP_TIME_COLON","REGXP_TIME_COLON_MS","REGXP_TIME_FRAMES","parseFramesTime","REGXP_TIME_TICK","tickRate","parseTickTime","REGXP_TIME_HMS","beginAttr","durationAttr","endAttr","parseTime","duration","parsedEnd","CELL_RESOLUTION_REGEXP","STYLE_ATTRIBUTES","parseTTMLString","xml","tt","getElementsByTagName","getElementsByTagNameNS","getBodyNode","styleNodes","getStyleNodes","regionNodes","getRegionNodes","paragraphNodes","getTextNodes","parsedFrameRate","parsedSubFrameRate","parsedTickRate","parsedFrameRateMultiplier","parsedSpaceStyle","parsedCellResolution","extractedData","nbFrameRate","nbSubFrameRate","nbTickRate","spaceStyle","multiplierResults","getParameters","styleNode","Element","subStyles","extendsStyles","recursivelyBrowsedIndexes","resolveStyleInheritance","styleElt","extendedStyleID","extendedStyleIndex","arrayFindIndex","extendedStyle","resolveStylesInheritance","regionNode","regionStyle","associatedStyleID","bodyStyle","shouldTrimWhiteSpaceOnBody","paragraphSpaceAttribute","REGXP_PERCENT_VALUES","getParentElementsByTagName","tagName","parentNode","constructArray","ttDivs","bodyNodes","namespacedBodyNodes","namespacedStyleNodes","namespacedRegionNodes","pNodes","namespacedPNodes","isStartOfCueBlock","endOfCue","findEndOfCueBlock","parseTimestamp","timestampString","splittedTS","reverse","parseFloat","cueLines","timingRegexp","timeString","timeAndSettings","acc","setting","splittedSetting","parseTimeAndSettings","firstLine","isStartOfRegionBlock","isStartOfNoteBlock","secondLine","startOfCueBlock","firstEmptyLineIndex","arr","searchElement","fromIndex","prototype","includes","n","k","y","areTheSame","o","map","values","EPSILON","nearlyEqual","createRangeUnion","range1","range2","isBefore","isTimeInRange","areRangesOverlapping","areRangesNearlyContiguous","timeRanges","ranges","getBufferedTimeRange","getRange","getNextBufferedTimeRangeGap","getInnerAndOuterRanges","innerRange","outerRanges","getLeftSizeOfBufferedTimeRange","range","getLeftSizeOfRange","rangeToAddArg","rangeToAdd","overlapping","contiguous","prevRange","currRange","unionRange","mergeContiguousRanges","removeEmptyRanges","findOverlappingRanges","resultingRanges","ranges1","ranges2","overlappingRanges","overlappingRange","excludeFromRanges","baseRanges","rangesToExclude","intersections","lastStart"],"sourceRoot":""}