You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

2 lines
316 KiB

/*! For license information please see video.js.LICENSE.txt */
(()=>{var e={8608:(e,t,n)=>{"use strict";var r=n(4663),i=n(1413),s=i(r("String.prototype.indexOf"));e.exports=function(e,t){var n=r(e,!!t);return"function"==typeof n&&s(e,".prototype.")>-1?i(n):n}},1413:(e,t,n)=>{"use strict";var r=n(4672),i=n(4663),s=n(7319),a=i("%TypeError%"),o=i("%Function.prototype.apply%"),l=i("%Function.prototype.call%"),c=i("%Reflect.apply%",!0)||r.call(l,o),u=i("%Object.defineProperty%",!0),h=i("%Math.max%");if(u)try{u({},"a",{value:1})}catch(e){u=null}e.exports=function(e){if("function"!=typeof e)throw new a("a function is required");var t=c(r,l,arguments);return s(t,1+h(0,e.length-(arguments.length-1)),!0)};var d=function(){return c(r,o,arguments)};u?u(e.exports,"apply",{value:d}):e.exports.apply=d},8531:(e,t,n)=>{"use strict";var r=n(3219)(),i=n(4663),s=r&&i("%Object.defineProperty%",!0);if(s)try{s({},"a",{value:1})}catch(e){s=!1}var a=i("%SyntaxError%"),o=i("%TypeError%"),l=n(8337);e.exports=function(e,t,n){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new o("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new o("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new o("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new o("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new o("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new o("`loose`, if provided, must be a boolean");var r=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,c=arguments.length>5?arguments[5]:null,u=arguments.length>6&&arguments[6],h=!!l&&l(e,t);if(s)s(e,t,{configurable:null===c&&h?h.configurable:!c,enumerable:null===r&&h?h.enumerable:!r,value:n,writable:null===i&&h?h.writable:!i});else{if(!u&&(r||i||c))throw new a("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=n}}},9309:(e,t,n)=>{"use strict";const r=n(5176),i=n(2085),s=n(4715);e.exports={XMLParser:i,XMLValidator:r,XMLBuilder:s}},7256:(e,t)=>{"use strict";const n=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",r="["+n+"]["+n+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*",i=new RegExp("^"+r+"$");t.isExist=function(e){return void 0!==e},t.isEmptyObject=function(e){return 0===Object.keys(e).length},t.merge=function(e,t,n){if(t){const r=Object.keys(t),i=r.length;for(let s=0;s<i;s++)e[r[s]]="strict"===n?[t[r[s]]]:t[r[s]]}},t.getValue=function(e){return t.isExist(e)?e:""},t.isName=function(e){return!(null==i.exec(e))},t.getAllMatches=function(e,t){const n=[];let r=t.exec(e);for(;r;){const i=[];i.startIndex=t.lastIndex-r[0].length;const s=r.length;for(let e=0;e<s;e++)i.push(r[e]);n.push(i),r=t.exec(e)}return n},t.nameRegexp=r},5176:(e,t,n)=>{"use strict";const r=n(7256),i={allowBooleanAttributes:!1,unpairedTags:[]};function s(e){return" "===e||"\t"===e||"\n"===e||"\r"===e}function a(e,t){const n=t;for(;t<e.length;t++)if("?"!=e[t]&&" "!=e[t]);else{const r=e.substr(n,t-n);if(t>5&&"xml"===r)return p("InvalidXml","XML declaration allowed only at the start of the document.",m(e,t));if("?"==e[t]&&">"==e[t+1]){t++;break}}return t}function o(e,t){if(e.length>t+5&&"-"===e[t+1]&&"-"===e[t+2]){for(t+=3;t<e.length;t++)if("-"===e[t]&&"-"===e[t+1]&&">"===e[t+2]){t+=2;break}}else if(e.length>t+8&&"D"===e[t+1]&&"O"===e[t+2]&&"C"===e[t+3]&&"T"===e[t+4]&&"Y"===e[t+5]&&"P"===e[t+6]&&"E"===e[t+7]){let n=1;for(t+=8;t<e.length;t++)if("<"===e[t])n++;else if(">"===e[t]&&(n--,0===n))break}else if(e.length>t+9&&"["===e[t+1]&&"C"===e[t+2]&&"D"===e[t+3]&&"A"===e[t+4]&&"T"===e[t+5]&&"A"===e[t+6]&&"["===e[t+7])for(t+=8;t<e.length;t++)if("]"===e[t]&&"]"===e[t+1]&&">"===e[t+2]){t+=2;break}return t}t.validate=function(e,t){t=Object.assign({},i,t);const n=[];let l=!1,c=!1;"\ufeff"===e[0]&&(e=e.substr(1));for(let i=0;i<e.length;i++)if("<"===e[i]&&"?"===e[i+1]){if(i+=2,i=a(e,i),i.err)return i}else{if("<"!==e[i]){if(s(e[i]))continue;return p("InvalidChar","char '"+e[i]+"' is not expected.",m(e,i))}{let g=i;if(i++,"!"===e[i]){i=o(e,i);continue}{let y=!1;"/"===e[i]&&(y=!0,i++);let b="";for(;i<e.length&&">"!==e[i]&&" "!==e[i]&&"\t"!==e[i]&&"\n"!==e[i]&&"\r"!==e[i];i++)b+=e[i];if(b=b.trim(),"/"===b[b.length-1]&&(b=b.substring(0,b.length-1),i--),h=b,!r.isName(h)){let t;return t=0===b.trim().length?"Invalid space after '<'.":"Tag '"+b+"' is an invalid name.",p("InvalidTag",t,m(e,i))}const v=u(e,i);if(!1===v)return p("InvalidAttr","Attributes for '"+b+"' have open quote.",m(e,i));let w=v.value;if(i=v.index,"/"===w[w.length-1]){const n=i-w.length;w=w.substring(0,w.length-1);const r=d(w,t);if(!0!==r)return p(r.err.code,r.err.msg,m(e,n+r.err.line));l=!0}else if(y){if(!v.tagClosed)return p("InvalidTag","Closing tag '"+b+"' doesn't have proper closing.",m(e,i));if(w.trim().length>0)return p("InvalidTag","Closing tag '"+b+"' can't have attributes or invalid starting.",m(e,g));{const t=n.pop();if(b!==t.tagName){let n=m(e,t.tagStartPos);return p("InvalidTag","Expected closing tag '"+t.tagName+"' (opened in line "+n.line+", col "+n.col+") instead of closing tag '"+b+"'.",m(e,g))}0==n.length&&(c=!0)}}else{const r=d(w,t);if(!0!==r)return p(r.err.code,r.err.msg,m(e,i-w.length+r.err.line));if(!0===c)return p("InvalidXml","Multiple possible root nodes found.",m(e,i));-1!==t.unpairedTags.indexOf(b)||n.push({tagName:b,tagStartPos:g}),l=!0}for(i++;i<e.length;i++)if("<"===e[i]){if("!"===e[i+1]){i++,i=o(e,i);continue}if("?"!==e[i+1])break;if(i=a(e,++i),i.err)return i}else if("&"===e[i]){const t=f(e,i);if(-1==t)return p("InvalidChar","char '&' is not expected.",m(e,i));i=t}else if(!0===c&&!s(e[i]))return p("InvalidXml","Extra text at the end",m(e,i));"<"===e[i]&&i--}}}var h;return l?1==n.length?p("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",m(e,n[0].tagStartPos)):!(n.length>0)||p("InvalidXml","Invalid '"+JSON.stringify(n.map((e=>e.tagName)),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):p("InvalidXml","Start tag expected.",1)};const l='"',c="'";function u(e,t){let n="",r="",i=!1;for(;t<e.length;t++){if(e[t]===l||e[t]===c)""===r?r=e[t]:r!==e[t]||(r="");else if(">"===e[t]&&""===r){i=!0;break}n+=e[t]}return""===r&&{value:n,index:t,tagClosed:i}}const h=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function d(e,t){const n=r.getAllMatches(e,h),i={};for(let e=0;e<n.length;e++){if(0===n[e][1].length)return p("InvalidAttr","Attribute '"+n[e][2]+"' has no space in starting.",y(n[e]));if(void 0!==n[e][3]&&void 0===n[e][4])return p("InvalidAttr","Attribute '"+n[e][2]+"' is without value.",y(n[e]));if(void 0===n[e][3]&&!t.allowBooleanAttributes)return p("InvalidAttr","boolean attribute '"+n[e][2]+"' is not allowed.",y(n[e]));const r=n[e][2];if(!g(r))return p("InvalidAttr","Attribute '"+r+"' is an invalid name.",y(n[e]));if(i.hasOwnProperty(r))return p("InvalidAttr","Attribute '"+r+"' is repeated.",y(n[e]));i[r]=1}return!0}function f(e,t){if(";"===e[++t])return-1;if("#"===e[t])return function(e,t){let n=/\d/;for("x"===e[t]&&(t++,n=/[\da-fA-F]/);t<e.length;t++){if(";"===e[t])return t;if(!e[t].match(n))break}return-1}(e,++t);let n=0;for(;t<e.length;t++,n++)if(!(e[t].match(/\w/)&&n<20)){if(";"===e[t])break;return-1}return t}function p(e,t,n){return{err:{code:e,msg:t,line:n.line||n,col:n.col}}}function g(e){return r.isName(e)}function m(e,t){const n=e.substring(0,t).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function y(e){return e.startIndex+e[1].length}},4715:(e,t,n)=>{"use strict";const r=n(7063),i={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[]};function s(e){this.options=Object.assign({},i,e),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=p),this.processTextOrObjNode=o,this.options.format?(this.indentate=f,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine=""),this.options.suppressEmptyNode?(this.buildTextNode=d,this.buildObjNode=c):(this.buildTextNode=u,this.buildObjNode=l),this.buildTextValNode=u,this.buildObjectNode=l,this.replaceEntitiesValue=h,this.buildAttrPairStr=a}function a(e,t){return t=this.options.attributeValueProcessor(e,""+t),t=this.replaceEntitiesValue(t),this.options.suppressBooleanAttributes&&"true"===t?" "+e:" "+e+'="'+t+'"'}function o(e,t,n){const r=this.j2x(e,n+1);return void 0!==e[this.options.textNodeName]&&1===Object.keys(e).length?this.buildTextNode(e[this.options.textNodeName],t,r.attrStr,n):this.buildObjNode(r.val,t,r.attrStr,n)}function l(e,t,n,r){let i="</"+t+this.tagEndChar,s="";return"?"===t[0]&&(s="?",i=""),n&&-1===e.indexOf("<")?this.indentate(r)+"<"+t+n+s+">"+e+i:!1!==this.options.commentPropName&&t===this.options.commentPropName&&0===s.length?this.indentate(r)+`\x3c!--${e}--\x3e`+this.newLine:this.indentate(r)+"<"+t+n+s+this.tagEndChar+e+this.indentate(r)+i}function c(e,t,n,r){return""!==e?this.buildObjectNode(e,t,n,r):"?"===t[0]?this.indentate(r)+"<"+t+n+"?"+this.tagEndChar:this.indentate(r)+"<"+t+n+"/"+this.tagEndChar}function u(e,t,n,r){if(!1!==this.options.cdataPropName&&t===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${e}]]>`+this.newLine;if(!1!==this.options.commentPropName&&t===this.options.commentPropName)return this.indentate(r)+`\x3c!--${e}--\x3e`+this.newLine;{let i=this.options.tagValueProcessor(t,e);return i=this.replaceEntitiesValue(i),""===i&&-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode?this.indentate(r)+"<"+t+this.tagEndChar:this.indentate(r)+"<"+t+"/"+this.tagEndChar:this.indentate(r)+"<"+t+n+">"+i+"</"+t+this.tagEndChar}}function h(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){const n=this.options.entities[t];e=e.replace(n.regex,n.val)}return e}function d(e,t,n,r){return""===e&&-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode?this.indentate(r)+"<"+t+this.tagEndChar:this.indentate(r)+"<"+t+"/"+this.tagEndChar:""!==e?this.buildTextValNode(e,t,n,r):"?"===t[0]?this.indentate(r)+"<"+t+n+"?"+this.tagEndChar:this.indentate(r)+"<"+t+n+"/"+this.tagEndChar}function f(e){return this.options.indentBy.repeat(e)}function p(e){return!!e.startsWith(this.options.attributeNamePrefix)&&e.substr(this.attrPrefixLen)}s.prototype.build=function(e){return this.options.preserveOrder?r(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0).val)},s.prototype.j2x=function(e,t){let n="",r="";for(let i in e)if(void 0===e[i]);else if(null===e[i])"?"===i[0]?r+=this.indentate(t)+"<"+i+"?"+this.tagEndChar:r+=this.indentate(t)+"<"+i+"/"+this.tagEndChar;else if(e[i]instanceof Date)r+=this.buildTextNode(e[i],i,"",t);else if("object"!=typeof e[i]){const s=this.isAttribute(i);if(s)n+=this.buildAttrPairStr(s,""+e[i]);else if(i===this.options.textNodeName){let t=this.options.tagValueProcessor(i,""+e[i]);r+=this.replaceEntitiesValue(t)}else r+=this.buildTextNode(e[i],i,"",t)}else if(Array.isArray(e[i])){const n=e[i].length;for(let s=0;s<n;s++){const n=e[i][s];void 0===n||(null===n?"?"===i[0]?r+=this.indentate(t)+"<"+i+"?"+this.tagEndChar:r+=this.indentate(t)+"<"+i+"/"+this.tagEndChar:r+="object"==typeof n?this.processTextOrObjNode(n,i,t):this.buildTextNode(n,i,"",t))}}else if(this.options.attributesGroupName&&i===this.options.attributesGroupName){const t=Object.keys(e[i]),r=t.length;for(let s=0;s<r;s++)n+=this.buildAttrPairStr(t[s],""+e[i][t[s]])}else r+=this.processTextOrObjNode(e[i],i,t);return{attrStr:n,val:r}},e.exports=s},7063:e=>{function t(e,a,o,l){let c="",u="";a.format&&a.indentBy.length>0&&(u="\n"+a.indentBy.repeat(l));for(let h=0;h<e.length;h++){const d=e[h],f=n(d);let p="";if(p=0===o.length?f:`${o}.${f}`,f===a.textNodeName){let e=d[f];i(p,a)||(e=a.tagValueProcessor(f,e),e=s(e,a)),c+=u+e;continue}if(f===a.cdataPropName){c+=u+`<![CDATA[${d[f][0][a.textNodeName]}]]>`;continue}if(f===a.commentPropName){c+=u+`\x3c!--${d[f][0][a.textNodeName]}--\x3e`;continue}if("?"===f[0]){const e=r(d[":@"],a),t="?xml"===f?"":u;let n=d[f][0][a.textNodeName];n=0!==n.length?" "+n:"",c+=t+`<${f}${n}${e}?>`;continue}let g=u+`<${f}${r(d[":@"],a)}`,m=t(d[f],a,p,l+1);-1!==a.unpairedTags.indexOf(f)?a.suppressUnpairedNode?c+=g+">":c+=g+"/>":m&&0!==m.length||!a.suppressEmptyNode?c+=g+`>${m}${u}</${f}>`:c+=g+"/>"}return c}function n(e){const t=Object.keys(e);for(let e=0;e<t.length;e++){const n=t[e];if(":@"!==n)return n}}function r(e,t){let n="";if(e&&!t.ignoreAttributes)for(let r in e){let i=t.attributeValueProcessor(r,e[r]);i=s(i,t),!0===i&&t.suppressBooleanAttributes?n+=` ${r.substr(t.attributeNamePrefix.length)}`:n+=` ${r.substr(t.attributeNamePrefix.length)}="${i}"`}return n}function i(e,t){let n=(e=e.substr(0,e.length-t.textNodeName.length-1)).substr(e.lastIndexOf(".")+1);for(let r in t.stopNodes)if(t.stopNodes[r]===e||t.stopNodes[r]==="*."+n)return!0;return!1}function s(e,t){if(e&&e.length>0&&t.processEntities)for(let n=0;n<t.entities.length;n++){const r=t.entities[n];e=e.replace(r.regex,r.val)}return e}e.exports=function(e,n){return t(e,n,"",0)}},6436:e=>{const t=RegExp("^\\s([a-zA-z0-0]+)[ \t](['\"])([^&]+)\\2");function n(e,n){const r=t.exec(e);r&&(n[r[1]]={regx:RegExp(`&${r[1]};`,"g"),val:r[3]})}e.exports=function(e,t){const r={};if("O"!==e[t+3]||"C"!==e[t+4]||"T"!==e[t+5]||"Y"!==e[t+6]||"P"!==e[t+7]||"E"!==e[t+8])throw new Error("Invalid Tag instead of DOCTYPE");{t+=9;let i=1,s=!1,a=!1,o=!1,l="";for(;t<e.length;t++)if("<"===e[t]){if(s&&"!"===e[t+1]&&"E"===e[t+2]&&"N"===e[t+3]&&"T"===e[t+4]&&"I"===e[t+5]&&"T"===e[t+6]&&"Y"===e[t+7])t+=7,a=!0;else if(s&&"!"===e[t+1]&&"E"===e[t+2]&&"L"===e[t+3]&&"E"===e[t+4]&&"M"===e[t+5]&&"E"===e[t+6]&&"N"===e[t+7]&&"T"===e[t+8])t+=8;else{if("!"!==e[t+1]||"-"!==e[t+2]||"-"!==e[t+3])throw new Error("Invalid DOCTYPE");o=!0}i++,l=""}else if(">"===e[t]){if(o){if("-"!==e[t-1]||"-"!==e[t-2])throw new Error("Invalid XML comment in DOCTYPE");o=!1}else a&&(n(l,r),a=!1);if(i--,0===i)break}else"["===e[t]?s=!0:l+=e[t];if(0!==i)throw new Error("Unclosed DOCTYPE")}return{entities:r,i:t}}},686:(e,t)=>{const n={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1};t.buildOptions=function(e){return Object.assign({},n,e)},t.defaultOptions=n},361:(e,t,n)=>{"use strict";const r=n(7256),i=n(5475),s=n(6436),a=n(5326);function o(e){const t=Object.keys(e);for(let n=0;n<t.length;n++){const r=t[n];this.lastEntities[r]={regex:new RegExp("&"+r+";","g"),val:e[r]}}}function l(e,t,n,r,i,s,a){if(void 0!==e&&(this.options.trimValues&&!r&&(e=e.trim()),e.length>0)){a||(e=this.replaceEntitiesValue(e));const r=this.options.tagValueProcessor(t,e,n,i,s);return null==r?e:typeof r!=typeof e||r!==e?r:this.options.trimValues||e.trim()===e?v(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function c(e){if(this.options.removeNSPrefix){const t=e.split(":"),n="/"===e.charAt(0)?"/":"";if("xmlns"===t[0])return"";2===t.length&&(e=n+t[1])}return e}"<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)".replace(/NAME/g,r.nameRegexp);const u=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function h(e,t){if(!this.options.ignoreAttributes&&"string"==typeof e){const n=r.getAllMatches(e,u),i=n.length,s={};for(let e=0;e<i;e++){const r=this.resolveNameSpace(n[e][1]);let i=n[e][4];const a=this.options.attributeNamePrefix+r;if(r.length)if(void 0!==i){this.options.trimValues&&(i=i.trim()),i=this.replaceEntitiesValue(i);const e=this.options.attributeValueProcessor(r,i,t);s[a]=null==e?i:typeof e!=typeof i||e!==i?e:v(i,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[a]=!0)}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){const e={};return e[this.options.attributesGroupName]=s,e}return s}}const d=function(e){e=e.replace(/\r\n?/g,"\n");const t=new i("!xml");let n=t,r="",a="";for(let o=0;o<e.length;o++)if("<"===e[o])if("/"===e[o+1]){const t=m(e,">",o,"Closing Tag is not closed.");let i=e.substring(o+2,t).trim();if(this.options.removeNSPrefix){const e=i.indexOf(":");-1!==e&&(i=i.substr(e+1))}n&&(r=this.saveTextToParentTag(r,n,a)),a=a.substr(0,a.lastIndexOf(".")),n=this.tagsNodeStack.pop(),r="",o=t}else if("?"===e[o+1]){let t=y(e,o,!1,"?>");if(!t)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,a),this.options.ignoreDeclaration&&"?xml"===t.tagName||this.options.ignorePiTags);else{const e=new i(t.tagName);e.add(this.options.textNodeName,""),t.tagName!==t.tagExp&&t.attrExpPresent&&(e[":@"]=this.buildAttributesMap(t.tagExp,a)),n.addChild(e)}o=t.closeIndex+1}else if("!--"===e.substr(o+1,3)){const t=m(e,"--\x3e",o+4,"Comment is not closed.");if(this.options.commentPropName){const i=e.substring(o+4,t-2);r=this.saveTextToParentTag(r,n,a),n.add(this.options.commentPropName,[{[this.options.textNodeName]:i}])}o=t}else if("!D"===e.substr(o+1,2)){const t=s(e,o);this.docTypeEntities=t.entities,o=t.i}else if("!["===e.substr(o+1,2)){const t=m(e,"]]>",o,"CDATA is not closed.")-2,i=e.substring(o+9,t);if(r=this.saveTextToParentTag(r,n,a),this.options.cdataPropName)n.add(this.options.cdataPropName,[{[this.options.textNodeName]:i}]);else{let e=this.parseTextData(i,n.tagname,a,!0,!1,!0);e||(e=""),n.add(this.options.textNodeName,e)}o=t+2}else{let s=y(e,o,this.options.removeNSPrefix),l=s.tagName,c=s.tagExp,u=s.attrExpPresent,h=s.closeIndex;n&&r&&"!xml"!==n.tagname&&(r=this.saveTextToParentTag(r,n,a,!1)),l!==t.tagname&&(a+=a?"."+l:l);const d=n;if(d&&-1!==this.options.unpairedTags.indexOf(d.tagname)&&(n=this.tagsNodeStack.pop()),this.isItStopNode(this.options.stopNodes,a,l)){let t="";if(c.length>0&&c.lastIndexOf("/")===c.length-1)o=s.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(l))o=s.closeIndex;else{const n=this.readStopNodeData(e,l,h+1);if(!n)throw new Error(`Unexpected end of ${l}`);o=n.i,t=n.tagContent}const r=new i(l);l!==c&&u&&(r[":@"]=this.buildAttributesMap(c,a)),t&&(t=this.parseTextData(t,l,a,!0,u,!0,!0)),a=a.substr(0,a.lastIndexOf(".")),r.add(this.options.textNodeName,t),n.addChild(r)}else{if(c.length>0&&c.lastIndexOf("/")===c.length-1){"/"===l[l.length-1]?(l=l.substr(0,l.length-1),c=l):c=c.substr(0,c.length-1);const e=new i(l);l!==c&&u&&(e[":@"]=this.buildAttributesMap(c,a)),a=a.substr(0,a.lastIndexOf(".")),n.addChild(e)}else{const e=new i(l);this.tagsNodeStack.push(n),l!==c&&u&&(e[":@"]=this.buildAttributesMap(c,a)),n.addChild(e),n=e}r="",o=h}}else r+=e[o];return t.child},f=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){const n=this.docTypeEntities[t];e=e.replace(n.regx,n.val)}for(let t in this.lastEntities){const n=this.lastEntities[t];e=e.replace(n.regex,n.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){const n=this.htmlEntities[t];e=e.replace(n.regex,n.val)}}return e};function p(e,t,n,r){return e&&(void 0===r&&(r=0===Object.keys(t.child).length),void 0!==(e=this.parseTextData(e,t.tagname,n,!1,!!t[":@"]&&0!==Object.keys(t[":@"]).length,r))&&""!==e&&t.add(this.options.textNodeName,e),e=""),e}function g(e,t,n){const r="*."+n;for(const n in e){const i=e[n];if(r===i||t===i)return!0}return!1}function m(e,t,n,r){const i=e.indexOf(t,n);if(-1===i)throw new Error(r);return i+t.length-1}function y(e,t,n,r=">"){const i=function(e,t,n=">"){let r,i="";for(let s=t;s<e.length;s++){let t=e[s];if(r)t===r&&(r="");else if('"'===t||"'"===t)r=t;else if(t===n[0]){if(!n[1])return{data:i,index:s};if(e[s+1]===n[1])return{data:i,index:s}}else"\t"===t&&(t=" ");i+=t}}(e,t+1,r);if(!i)return;let s=i.data;const a=i.index,o=s.search(/\s/);let l=s,c=!0;if(-1!==o&&(l=s.substr(0,o).replace(/\s\s*$/,""),s=s.substr(o+1)),n){const e=l.indexOf(":");-1!==e&&(l=l.substr(e+1),c=l!==i.data.substr(e+1))}return{tagName:l,tagExp:s,closeIndex:a,attrExpPresent:c}}function b(e,t,n){const r=n;for(;n<e.length;n++)if("<"===e[n]&&"/"===e[n+1]){const i=m(e,">",n,`${t} is not closed`);if(e.substring(n+2,i).trim()===t)return{tagContent:e.substring(r,n),i};n=i}}function v(e,t,n){if(t&&"string"==typeof e){const t=e.trim();return"true"===t||"false"!==t&&a(e,n)}return r.isExist(e)?e:""}e.exports=class{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={amp:{regex:/&(amp|#38|#x26);/g,val:"&"},apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"}},this.addExternalEntities=o,this.parseXml=d,this.parseTextData=l,this.resolveNameSpace=c,this.buildAttributesMap=h,this.isItStopNode=g,this.replaceEntitiesValue=f,this.readStopNodeData=b,this.saveTextToParentTag=p}}},2085:(e,t,n)=>{const{buildOptions:r}=n(686),i=n(361),{prettify:s}=n(9046),a=n(5176);e.exports=class{constructor(e){this.externalEntities={},this.options=r(e)}parse(e,t){if("string"==typeof e);else{if(!e.toString)throw new Error("XML data is accepted in String or Bytes[] form.");e=e.toString()}if(t){!0===t&&(t={});const n=a.validate(e,t);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const n=new i(this.options);n.addExternalEntities(this.externalEntities);const r=n.parseXml(e);return this.options.preserveOrder||void 0===r?r:s(r,this.options)}addEntity(e,t){if(-1!==t.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==e.indexOf("&")||-1!==e.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");this.externalEntities[e]=t}}},9046:(e,t)=>{"use strict";function n(e,t,a){let o;const l={};for(let c=0;c<e.length;c++){const u=e[c],h=r(u);let d="";if(d=void 0===a?h:a+"."+h,h===t.textNodeName)void 0===o?o=u[h]:o+=""+u[h];else{if(void 0===h)continue;if(u[h]){let e=n(u[h],t,d);const r=s(e,t);u[":@"]?i(e,u[":@"],d,t):1!==Object.keys(e).length||void 0===e[t.textNodeName]||t.alwaysCreateTextNode?0===Object.keys(e).length&&(t.alwaysCreateTextNode?e[t.textNodeName]="":e=""):e=e[t.textNodeName],void 0!==l[h]?(Array.isArray(l[h])||(l[h]=[l[h]]),l[h].push(e)):t.isArray(h,d,r)?l[h]=[e]:l[h]=e}}}return"string"==typeof o?o.length>0&&(l[t.textNodeName]=o):void 0!==o&&(l[t.textNodeName]=o),l}function r(e){const t=Object.keys(e);for(let e=0;e<t.length;e++){const n=t[e];if(":@"!==n)return n}}function i(e,t,n,r){if(t){const i=Object.keys(t),s=i.length;for(let a=0;a<s;a++){const s=i[a];r.isArray(s,n+"."+s,!0,!0)?e[s]=[t[s]]:e[s]=t[s]}}}function s(e,t){const n=Object.keys(e).length;return!!(0===n||1===n&&e[t.textNodeName])}t.prettify=function(e,t){return n(e,t)}},5475:e=>{"use strict";e.exports=class{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){this.child.push({[e]:t})}addChild(e){e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child})}}},3351:e=>{"use strict";var t=Object.prototype.toString,n=Math.max,r=function(e,t){for(var n=[],r=0;r<e.length;r+=1)n[r]=e[r];for(var i=0;i<t.length;i+=1)n[i+e.length]=t[i];return n};e.exports=function(e){var i=this;if("function"!=typeof i||"[object Function]"!==t.apply(i))throw new TypeError("Function.prototype.bind called on incompatible "+i);for(var s,a=function(e,t){for(var n=[],r=1,i=0;r<e.length;r+=1,i+=1)n[i]=e[r];return n}(arguments),o=n(0,i.length-a.length),l=[],c=0;c<o;c++)l[c]="$"+c;if(s=Function("binder","return function ("+function(e,t){for(var n="",r=0;r<e.length;r+=1)n+=e[r],r+1<e.length&&(n+=",");return n}(l)+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof s){var t=i.apply(this,r(a,arguments));return Object(t)===t?t:this}return i.apply(e,r(a,arguments))})),i.prototype){var u=function(){};u.prototype=i.prototype,s.prototype=new u,u.prototype=null}return s}},4672:(e,t,n)=>{"use strict";var r=n(3351);e.exports=Function.prototype.bind||r},4663:(e,t,n)=>{"use strict";var r,i=SyntaxError,s=Function,a=TypeError,o=function(e){try{return s('"use strict"; return ('+e+").constructor;")()}catch(e){}},l=Object.getOwnPropertyDescriptor;if(l)try{l({},"")}catch(e){l=null}var c=function(){throw new a},u=l?function(){try{return c}catch(e){try{return l(arguments,"callee").get}catch(e){return c}}}():c,h=n(4573)(),d=n(8912)(),f=Object.getPrototypeOf||(d?function(e){return e.__proto__}:null),p={},g="undefined"!=typeof Uint8Array&&f?f(Uint8Array):r,m={"%AggregateError%":"undefined"==typeof AggregateError?r:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?r:ArrayBuffer,"%ArrayIteratorPrototype%":h&&f?f([][Symbol.iterator]()):r,"%AsyncFromSyncIteratorPrototype%":r,"%AsyncFunction%":p,"%AsyncGenerator%":p,"%AsyncGeneratorFunction%":p,"%AsyncIteratorPrototype%":p,"%Atomics%":"undefined"==typeof Atomics?r:Atomics,"%BigInt%":"undefined"==typeof BigInt?r:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?r:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?r:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?r:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?r:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?r:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?r:FinalizationRegistry,"%Function%":s,"%GeneratorFunction%":p,"%Int8Array%":"undefined"==typeof Int8Array?r:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?r:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?r:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":h&&f?f(f([][Symbol.iterator]())):r,"%JSON%":"object"==typeof JSON?JSON:r,"%Map%":"undefined"==typeof Map?r:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&h&&f?f((new Map)[Symbol.iterator]()):r,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?r:Promise,"%Proxy%":"undefined"==typeof Proxy?r:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?r:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?r:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&h&&f?f((new Set)[Symbol.iterator]()):r,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?r:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":h&&f?f(""[Symbol.iterator]()):r,"%Symbol%":h?Symbol:r,"%SyntaxError%":i,"%ThrowTypeError%":u,"%TypedArray%":g,"%TypeError%":a,"%Uint8Array%":"undefined"==typeof Uint8Array?r:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?r:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?r:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?r:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?r:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?r:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?r:WeakSet};if(f)try{null.error}catch(e){var y=f(f(e));m["%Error.prototype%"]=y}var b=function e(t){var n;if("%AsyncFunction%"===t)n=o("async function () {}");else if("%GeneratorFunction%"===t)n=o("function* () {}");else if("%AsyncGeneratorFunction%"===t)n=o("async function* () {}");else if("%AsyncGenerator%"===t){var r=e("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&f&&(n=f(i.prototype))}return m[t]=n,n},v={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},w=n(4672),S=n(2907),E=w.call(Function.call,Array.prototype.concat),x=w.call(Function.apply,Array.prototype.splice),k=w.call(Function.call,String.prototype.replace),O=w.call(Function.call,String.prototype.slice),_=w.call(Function.call,RegExp.prototype.exec),C=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,T=/\\(\\)?/g,A=function(e,t){var n,r=e;if(S(v,r)&&(r="%"+(n=v[r])[0]+"%"),S(m,r)){var s=m[r];if(s===p&&(s=b(r)),void 0===s&&!t)throw new a("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:n,name:r,value:s}}throw new i("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new a("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new a('"allowMissing" argument must be a boolean');if(null===_(/^%?[^%]*%?$/,e))throw new i("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=function(e){var t=O(e,0,1),n=O(e,-1);if("%"===t&&"%"!==n)throw new i("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==t)throw new i("invalid intrinsic syntax, expected opening `%`");var r=[];return k(e,C,(function(e,t,n,i){r[r.length]=n?k(i,T,"$1"):t||e})),r}(e),r=n.length>0?n[0]:"",s=A("%"+r+"%",t),o=s.name,c=s.value,u=!1,h=s.alias;h&&(r=h[0],x(n,E([0,1],h)));for(var d=1,f=!0;d<n.length;d+=1){var p=n[d],g=O(p,0,1),y=O(p,-1);if(('"'===g||"'"===g||"`"===g||'"'===y||"'"===y||"`"===y)&&g!==y)throw new i("property names with quotes must have matching quotes");if("constructor"!==p&&f||(u=!0),S(m,o="%"+(r+="."+p)+"%"))c=m[o];else if(null!=c){if(!(p in c)){if(!t)throw new a("base intrinsic for "+e+" exists, but the property is not available.");return}if(l&&d+1>=n.length){var b=l(c,p);c=(f=!!b)&&"get"in b&&!("originalValue"in b.get)?b.get:c[p]}else f=S(c,p),c=c[p];f&&!u&&(m[o]=c)}}return c}},3452:(e,t,n)=>{var r;r="undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{},e.exports=r},8337:(e,t,n)=>{"use strict";var r=n(4663)("%Object.getOwnPropertyDescriptor%",!0);if(r)try{r([],"length")}catch(e){r=null}e.exports=r},3219:(e,t,n)=>{"use strict";var r=n(4663)("%Object.defineProperty%",!0),i=function(){if(r)try{return r({},"a",{value:1}),!0}catch(e){return!1}return!1};i.hasArrayLengthDefineBug=function(){if(!i())return null;try{return 1!==r([],"length",{value:1}).length}catch(e){return!0}},e.exports=i},8912:e=>{"use strict";var t={foo:{}},n=Object;e.exports=function(){return{__proto__:t}.foo===t.foo&&!({__proto__:null}instanceof n)}},4573:(e,t,n)=>{"use strict";var r="undefined"!=typeof Symbol&&Symbol,i=n(4283);e.exports=function(){return"function"==typeof r&&"function"==typeof Symbol&&"symbol"==typeof r("foo")&&"symbol"==typeof Symbol("bar")&&i()}},4283:e=>{"use strict";e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),n=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(e,t);if(42!==i.value||!0!==i.enumerable)return!1}return!0}},2907:(e,t,n)=>{"use strict";var r=Function.prototype.call,i=Object.prototype.hasOwnProperty,s=n(4672);e.exports=s.call(r,i)},9427:(e,t,n)=>{"use strict";var r=n(1020),i=r.ValidatorResult,s=r.SchemaError,a={ignoreProperties:{id:!0,default:!0,description:!0,title:!0,additionalItems:!0,then:!0,else:!0,$schema:!0,$ref:!0,extends:!0}},o=a.validators={};function l(e,t,n,r,i){var s=t.throwError,a=t.throwAll;t.throwError=!1,t.throwAll=!1;var o=this.validateSchema(e,i,t,n);return t.throwError=s,t.throwAll=a,!o.valid&&r instanceof Function&&r(o),o.valid}function c(e,t){if(Object.hasOwnProperty.call(e,t))return e[t];if(t in e)for(;e=Object.getPrototypeOf(e);)if(Object.propertyIsEnumerable.call(e,t))return e[t]}function u(e,t,n,r,i,s){if(this.types.object(e)&&(!t.properties||void 0===t.properties[i]))if(!1===t.additionalProperties)s.addError({name:"additionalProperties",argument:i,message:"is not allowed to have the additional property "+JSON.stringify(i)});else{var a=t.additionalProperties||{};"function"==typeof n.preValidateProperty&&n.preValidateProperty(e,i,a,n,r);var o=this.validateSchema(e[i],a,n,r.makeChild(a,i));o.instance!==s.instance[i]&&(s.instance[i]=o.instance),s.importErrors(o)}}o.type=function(e,t,n,r){if(void 0===e)return null;var s=new i(e,t,n,r),a=Array.isArray(t.type)?t.type:[t.type];if(!a.some(this.testType.bind(this,e,t,n,r))){var o=a.map((function(e){if(e){var t=e.$id||e.id;return t?"<"+t+">":e+""}}));s.addError({name:"type",argument:o,message:"is not of a type(s) "+o})}return s},o.anyOf=function(e,t,n,r){if(void 0===e)return null;var a=new i(e,t,n,r),o=new i(e,t,n,r);if(!Array.isArray(t.anyOf))throw new s("anyOf must be an array");if(!t.anyOf.some(l.bind(this,e,n,r,(function(e){o.importErrors(e)})))){var c=t.anyOf.map((function(e,t){var n=e.$id||e.id;return n?"<"+n+">":e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+t+"]"}));n.nestedErrors&&a.importErrors(o),a.addError({name:"anyOf",argument:c,message:"is not any of "+c.join(",")})}return a},o.allOf=function(e,t,n,r){if(void 0===e)return null;if(!Array.isArray(t.allOf))throw new s("allOf must be an array");var a=new i(e,t,n,r),o=this;return t.allOf.forEach((function(t,i){var s=o.validateSchema(e,t,n,r);if(!s.valid){var l=t.$id||t.id||t.title&&JSON.stringify(t.title)||t.$ref&&"<"+t.$ref+">"||"[subschema "+i+"]";a.addError({name:"allOf",argument:{id:l,length:s.errors.length,valid:s},message:"does not match allOf schema "+l+" with "+s.errors.length+" error[s]:"}),a.importErrors(s)}})),a},o.oneOf=function(e,t,n,r){if(void 0===e)return null;if(!Array.isArray(t.oneOf))throw new s("oneOf must be an array");var a=new i(e,t,n,r),o=new i(e,t,n,r),c=t.oneOf.filter(l.bind(this,e,n,r,(function(e){o.importErrors(e)}))).length,u=t.oneOf.map((function(e,t){return e.$id||e.id||e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+t+"]"}));return 1!==c&&(n.nestedErrors&&a.importErrors(o),a.addError({name:"oneOf",argument:u,message:"is not exactly one from "+u.join(",")})),a},o.if=function(e,t,n,s){if(void 0===e)return null;if(!r.isSchema(t.if))throw new Error('Expected "if" keyword to be a schema');var a,o=l.call(this,e,n,s,null,t.if),c=new i(e,t,n,s);if(o){if(void 0===t.then)return;if(!r.isSchema(t.then))throw new Error('Expected "then" keyword to be a schema');a=this.validateSchema(e,t.then,n,s.makeChild(t.then)),c.importErrors(a)}else{if(void 0===t.else)return;if(!r.isSchema(t.else))throw new Error('Expected "else" keyword to be a schema');a=this.validateSchema(e,t.else,n,s.makeChild(t.else)),c.importErrors(a)}return c},o.propertyNames=function(e,t,n,a){if(this.types.object(e)){var o=new i(e,t,n,a),l=void 0!==t.propertyNames?t.propertyNames:{};if(!r.isSchema(l))throw new s('Expected "propertyNames" to be a schema (object or boolean)');for(var u in e)if(void 0!==c(e,u)){var h=this.validateSchema(u,l,n,a.makeChild(l));o.importErrors(h)}return o}},o.properties=function(e,t,n,r){if(this.types.object(e)){var a=new i(e,t,n,r),o=t.properties||{};for(var l in o){var u=o[l];if(void 0!==u){if(null===u)throw new s('Unexpected null, expected schema in "properties"');"function"==typeof n.preValidateProperty&&n.preValidateProperty(e,l,u,n,r);var h=c(e,l),d=this.validateSchema(h,u,n,r.makeChild(u,l));d.instance!==a.instance[l]&&(a.instance[l]=d.instance),a.importErrors(d)}}return a}},o.patternProperties=function(e,t,n,r){if(this.types.object(e)){var a=new i(e,t,n,r),o=t.patternProperties||{};for(var l in e){var c=!0;for(var h in o){var d=o[h];if(void 0!==d){if(null===d)throw new s('Unexpected null, expected schema in "patternProperties"');try{var f=new RegExp(h,"u")}catch(e){f=new RegExp(h)}if(f.test(l)){c=!1,"function"==typeof n.preValidateProperty&&n.preValidateProperty(e,l,d,n,r);var p=this.validateSchema(e[l],d,n,r.makeChild(d,l));p.instance!==a.instance[l]&&(a.instance[l]=p.instance),a.importErrors(p)}}}c&&u.call(this,e,t,n,r,l,a)}return a}},o.additionalProperties=function(e,t,n,r){if(this.types.object(e)){if(t.patternProperties)return null;var s=new i(e,t,n,r);for(var a in e)u.call(this,e,t,n,r,a,s);return s}},o.minProperties=function(e,t,n,r){if(this.types.object(e)){var s=new i(e,t,n,r);return Object.keys(e).length>=t.minProperties||s.addError({name:"minProperties",argument:t.minProperties,message:"does not meet minimum property length of "+t.minProperties}),s}},o.maxProperties=function(e,t,n,r){if(this.types.object(e)){var s=new i(e,t,n,r);return Object.keys(e).length<=t.maxProperties||s.addError({name:"maxProperties",argument:t.maxProperties,message:"does not meet maximum property length of "+t.maxProperties}),s}},o.items=function(e,t,n,r){var s=this;if(this.types.array(e)&&void 0!==t.items){var a=new i(e,t,n,r);return e.every((function(e,i){if(Array.isArray(t.items))var o=void 0===t.items[i]?t.additionalItems:t.items[i];else o=t.items;if(void 0===o)return!0;if(!1===o)return a.addError({name:"items",message:"additionalItems not permitted"}),!1;var l=s.validateSchema(e,o,n,r.makeChild(o,i));return l.instance!==a.instance[i]&&(a.instance[i]=l.instance),a.importErrors(l),!0})),a}},o.contains=function(e,t,n,s){var a=this;if(this.types.array(e)&&void 0!==t.contains){if(!r.isSchema(t.contains))throw new Error('Expected "contains" keyword to be a schema');var o=new i(e,t,n,s);return!1===e.some((function(e,r){return 0===a.validateSchema(e,t.contains,n,s.makeChild(t.contains,r)).errors.length}))&&o.addError({name:"contains",argument:t.contains,message:"must contain an item matching given schema"}),o}},o.minimum=function(e,t,n,r){if(this.types.number(e)){var s=new i(e,t,n,r);return t.exclusiveMinimum&&!0===t.exclusiveMinimum?e>t.minimum||s.addError({name:"minimum",argument:t.minimum,message:"must be greater than "+t.minimum}):e>=t.minimum||s.addError({name:"minimum",argument:t.minimum,message:"must be greater than or equal to "+t.minimum}),s}},o.maximum=function(e,t,n,r){if(this.types.number(e)){var s=new i(e,t,n,r);return t.exclusiveMaximum&&!0===t.exclusiveMaximum?e<t.maximum||s.addError({name:"maximum",argument:t.maximum,message:"must be less than "+t.maximum}):e<=t.maximum||s.addError({name:"maximum",argument:t.maximum,message:"must be less than or equal to "+t.maximum}),s}},o.exclusiveMinimum=function(e,t,n,r){if("boolean"!=typeof t.exclusiveMinimum&&this.types.number(e)){var s=new i(e,t,n,r);return e>t.exclusiveMinimum||s.addError({name:"exclusiveMinimum",argument:t.exclusiveMinimum,message:"must be strictly greater than "+t.exclusiveMinimum}),s}},o.exclusiveMaximum=function(e,t,n,r){if("boolean"!=typeof t.exclusiveMaximum&&this.types.number(e)){var s=new i(e,t,n,r);return e<t.exclusiveMaximum||s.addError({name:"exclusiveMaximum",argument:t.exclusiveMaximum,message:"must be strictly less than "+t.exclusiveMaximum}),s}};var h=function(e,t,n,a,o,l){if(this.types.number(e)){var c=t[o];if(0==c)throw new s(o+" cannot be zero");var u=new i(e,t,n,a),h=r.getDecimalPlaces(e),d=r.getDecimalPlaces(c),f=Math.max(h,d),p=Math.pow(10,f);return Math.round(e*p)%Math.round(c*p)!=0&&u.addError({name:o,argument:c,message:l+JSON.stringify(c)}),u}};function d(e,t,n){var i,s=n.length;for(i=t+1;i<s;i++)if(r.deepCompareStrict(e,n[i]))return!1;return!0}o.multipleOf=function(e,t,n,r){return h.call(this,e,t,n,r,"multipleOf","is not a multiple of (divisible by) ")},o.divisibleBy=function(e,t,n,r){return h.call(this,e,t,n,r,"divisibleBy","is not divisible by (multiple of) ")},o.required=function(e,t,n,r){var s=new i(e,t,n,r);return void 0===e&&!0===t.required?s.addError({name:"required",message:"is required"}):this.types.object(e)&&Array.isArray(t.required)&&t.required.forEach((function(t){void 0===c(e,t)&&s.addError({name:"required",argument:t,message:"requires property "+JSON.stringify(t)})})),s},o.pattern=function(e,t,n,r){if(this.types.string(e)){var s=new i(e,t,n,r),a=t.pattern;try{var o=new RegExp(a,"u")}catch(e){o=new RegExp(a)}return e.match(o)||s.addError({name:"pattern",argument:t.pattern,message:"does not match pattern "+JSON.stringify(t.pattern.toString())}),s}},o.format=function(e,t,n,s){if(void 0!==e){var a=new i(e,t,n,s);return a.disableFormat||r.isFormat(e,t.format,this)||a.addError({name:"format",argument:t.format,message:"does not conform to the "+JSON.stringify(t.format)+" format"}),a}},o.minLength=function(e,t,n,r){if(this.types.string(e)){var s=new i(e,t,n,r),a=e.match(/[\uDC00-\uDFFF]/g);return e.length-(a?a.length:0)>=t.minLength||s.addError({name:"minLength",argument:t.minLength,message:"does not meet minimum length of "+t.minLength}),s}},o.maxLength=function(e,t,n,r){if(this.types.string(e)){var s=new i(e,t,n,r),a=e.match(/[\uDC00-\uDFFF]/g);return e.length-(a?a.length:0)<=t.maxLength||s.addError({name:"maxLength",argument:t.maxLength,message:"does not meet maximum length of "+t.maxLength}),s}},o.minItems=function(e,t,n,r){if(this.types.array(e)){var s=new i(e,t,n,r);return e.length>=t.minItems||s.addError({name:"minItems",argument:t.minItems,message:"does not meet minimum length of "+t.minItems}),s}},o.maxItems=function(e,t,n,r){if(this.types.array(e)){var s=new i(e,t,n,r);return e.length<=t.maxItems||s.addError({name:"maxItems",argument:t.maxItems,message:"does not meet maximum length of "+t.maxItems}),s}},o.uniqueItems=function(e,t,n,r){if(!0===t.uniqueItems&&this.types.array(e)){var s=new i(e,t,n,r);return e.every(d)||s.addError({name:"uniqueItems",message:"contains duplicate item"}),s}},o.dependencies=function(e,t,n,r){if(this.types.object(e)){var s=new i(e,t,n,r);for(var a in t.dependencies)if(void 0!==e[a]){var o=t.dependencies[a],l=r.makeChild(o,a);if("string"==typeof o&&(o=[o]),Array.isArray(o))o.forEach((function(t){void 0===e[t]&&s.addError({name:"dependencies",argument:l.propertyPath,message:"property "+t+" not found, required by "+l.propertyPath})}));else{var c=this.validateSchema(e,o,n,l);s.instance!==c.instance&&(s.instance=c.instance),c&&c.errors.length&&(s.addError({name:"dependencies",argument:l.propertyPath,message:"does not meet dependency required by "+l.propertyPath}),s.importErrors(c))}}return s}},o.enum=function(e,t,n,a){if(void 0===e)return null;if(!Array.isArray(t.enum))throw new s("enum expects an array",t);var o=new i(e,t,n,a);return t.enum.some(r.deepCompareStrict.bind(null,e))||o.addError({name:"enum",argument:t.enum,message:"is not one of enum values: "+t.enum.map(String).join(",")}),o},o.const=function(e,t,n,s){if(void 0===e)return null;var a=new i(e,t,n,s);return r.deepCompareStrict(t.const,e)||a.addError({name:"const",argument:t.const,message:"does not exactly match expected constant: "+t.const}),a},o.not=o.disallow=function(e,t,n,r){var s=this;if(void 0===e)return null;var a=new i(e,t,n,r),o=t.not||t.disallow;return o?(Array.isArray(o)||(o=[o]),o.forEach((function(i){if(s.testType(e,t,n,r,i)){var o=i&&(i.$id||i.id)||i;a.addError({name:"not",argument:o,message:"is of prohibited type "+o})}})),a):null},e.exports=a},1020:(e,t,n)=>{"use strict";var r=n(8526),i=t.ValidationError=function(e,t,n,r,i,s){if(Array.isArray(r)?(this.path=r,this.property=r.reduce((function(e,t){return e+h(t)}),"instance")):void 0!==r&&(this.property=r),e&&(this.message=e),n){var a=n.$id||n.id;this.schema=a||n}void 0!==t&&(this.instance=t),this.name=i,this.argument=s,this.stack=this.toString()};i.prototype.toString=function(){return this.property+" "+this.message};var s=t.ValidatorResult=function(e,t,n,r){this.instance=e,this.schema=t,this.options=n,this.path=r.path,this.propertyPath=r.propertyPath,this.errors=[],this.throwError=n&&n.throwError,this.throwFirst=n&&n.throwFirst,this.throwAll=n&&n.throwAll,this.disableFormat=n&&!0===n.disableFormat};function a(e,t){return t+": "+e.toString()+"\n"}function o(e){Error.captureStackTrace&&Error.captureStackTrace(this,o),this.instance=e.instance,this.schema=e.schema,this.options=e.options,this.errors=e.errors}s.prototype.addError=function(e){var t;if("string"==typeof e)t=new i(e,this.instance,this.schema,this.path);else{if(!e)throw new Error("Missing error detail");if(!e.message)throw new Error("Missing error message");if(!e.name)throw new Error("Missing validator type");t=new i(e.message,this.instance,this.schema,this.path,e.name,e.argument)}if(this.errors.push(t),this.throwFirst)throw new o(this);if(this.throwError)throw t;return t},s.prototype.importErrors=function(e){"string"==typeof e||e&&e.validatorType?this.addError(e):e&&e.errors&&(this.errors=this.errors.concat(e.errors))},s.prototype.toString=function(e){return this.errors.map(a).join("")},Object.defineProperty(s.prototype,"valid",{get:function(){return!this.errors.length}}),e.exports.ValidatorResultError=o,o.prototype=new Error,o.prototype.constructor=o,o.prototype.name="Validation Error";var l=t.SchemaError=function e(t,n){this.message=t,this.schema=n,Error.call(this,t),Error.captureStackTrace(this,e)};l.prototype=Object.create(Error.prototype,{constructor:{value:l,enumerable:!1},name:{value:"SchemaError",enumerable:!1}});var c=t.SchemaContext=function(e,t,n,r,i){this.schema=e,this.options=t,Array.isArray(n)?(this.path=n,this.propertyPath=n.reduce((function(e,t){return e+h(t)}),"instance")):this.propertyPath=n,this.base=r,this.schemas=i};c.prototype.resolve=function(e){return r.resolve(this.base,e)},c.prototype.makeChild=function(e,t){var n=void 0===t?this.path:this.path.concat([t]),i=e.$id||e.id,s=r.resolve(this.base,i||""),a=new c(e,this.options,n,s,Object.create(this.schemas));return i&&!a.schemas[s]&&(a.schemas[s]=e),a};var u=t.FORMAT_REGEXPS={"date-time":/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])[tT ](2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])(\.\d+)?([zZ]|[+-]([0-5][0-9]):(60|[0-5][0-9]))$/,date:/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])$/,time:/^(2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])$/,duration:/P(T\d+(H(\d+M(\d+S)?)?|M(\d+S)?|S)|\d+(D|M(\d+D)?|Y(\d+M(\d+D)?)?)(T\d+(H(\d+M(\d+S)?)?|M(\d+S)?|S))?|\d+W)/i,email:/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/,"idn-email":/^("(?:[!#-\[\]-\u{10FFFF}]|\\[\t -\u{10FFFF}])*"|[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}](?:\.?[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}])*)@([!#-'*+\-/-9=?A-Z\^-\u{10FFFF}](?:\.?[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}])*|\[[!-Z\^-\u{10FFFF}]*\])$/u,"ip-address":/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,ipv6:/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,uri:/^[a-zA-Z][a-zA-Z0-9+.-]*:[^\s]*$/,"uri-reference":/^(((([A-Za-z][+\-.0-9A-Za-z]*(:%[0-9A-Fa-f]{2}|:[!$&-.0-;=?-Z_a-z~]|[/?])|\?)(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*|([A-Za-z][+\-.0-9A-Za-z]*:?)?)|([A-Za-z][+\-.0-9A-Za-z]*:)?\/((%[0-9A-Fa-f]{2}|\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~])+|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~]+)?|[.0-:A-Fa-f]+)\])?)(:\d*)?[/?]|[!$&-.0-;=?-Z_a-z~])(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*|(\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~])+|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~]+)?|[.0-:A-Fa-f]+)\])?)(:\d*)?)?))#(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*|(([A-Za-z][+\-.0-9A-Za-z]*)?%[0-9A-Fa-f]{2}|[!$&-.0-9;=@_~]|[A-Za-z][+\-.0-9A-Za-z]*[!$&-*,;=@_~])(%[0-9A-Fa-f]{2}|[!$&-.0-9;=@-Z_a-z~])*((([/?](%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*)?#|[/?])(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*)?|([A-Za-z][+\-.0-9A-Za-z]*(:%[0-9A-Fa-f]{2}|:[!$&-.0-;=?-Z_a-z~]|[/?])|\?)(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*|([A-Za-z][+\-.0-9A-Za-z]*:)?\/((%[0-9A-Fa-f]{2}|\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~])+|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~]+)?|[.0-:A-Fa-f]+)\])?)(:\d*)?[/?]|[!$&-.0-;=?-Z_a-z~])(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*|\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~])+(:\d*)?|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~]+)?|[.0-:A-Fa-f]+)\])?:\d*|\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~]+)?|[.0-:A-Fa-f]+)\])?)?|[A-Za-z][+\-.0-9A-Za-z]*:?)?$/,iri:/^[a-zA-Z][a-zA-Z0-9+.-]*:[^\s]*$/,"iri-reference":/^(((([A-Za-z][+\-.0-9A-Za-z]*(:%[0-9A-Fa-f]{2}|:[!$&-.0-;=?-Z_a-z~-\u{10FFFF}]|[/?])|\?)(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~-\u{10FFFF}])*|([A-Za-z][+\-.0-9A-Za-z]*:?)?)|([A-Za-z][+\-.0-9A-Za-z]*:)?\/((%[0-9A-Fa-f]{2}|\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~-\u{10FFFF}])+|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~-\u{10FFFF}]+)?|[.0-:A-Fa-f]+)\])?)(:\d*)?[/?]|[!$&-.0-;=?-Z_a-z~-\u{10FFFF}])(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~-\u{10FFFF}])*|(\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~-\u{10FFFF}])+|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~-\u{10FFFF}]+)?|[.0-:A-Fa-f]+)\])?)(:\d*)?)?))#(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~-\u{10FFFF}])*|(([A-Za-z][+\-.0-9A-Za-z]*)?%[0-9A-Fa-f]{2}|[!$&-.0-9;=@_~-\u{10FFFF}]|[A-Za-z][+\-.0-9A-Za-z]*[!$&-*,;=@_~-\u{10FFFF}])(%[0-9A-Fa-f]{2}|[!$&-.0-9;=@-Z_a-z~-\u{10FFFF}])*((([/?](%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~-\u{10FFFF}])*)?#|[/?])(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~-\u{10FFFF}])*)?|([A-Za-z][+\-.0-9A-Za-z]*(:%[0-9A-Fa-f]{2}|:[!$&-.0-;=?-Z_a-z~-\u{10FFFF}]|[/?])|\?)(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~-\u{10FFFF}])*|([A-Za-z][+\-.0-9A-Za-z]*:)?\/((%[0-9A-Fa-f]{2}|\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~-\u{10FFFF}])+|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~-\u{10FFFF}]+)?|[.0-:A-Fa-f]+)\])?)(:\d*)?[/?]|[!$&-.0-;=?-Z_a-z~-\u{10FFFF}])(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~-\u{10FFFF}])*|\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~-\u{10FFFF}])+(:\d*)?|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~-\u{10FFFF}]+)?|[.0-:A-Fa-f]+)\])?:\d*|\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~-\u{10FFFF}]+)?|[.0-:A-Fa-f]+)\])?)?|[A-Za-z][+\-.0-9A-Za-z]*:?)?$/u,uuid:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,"uri-template":/(%[0-9a-f]{2}|[!#$&(-;=?@\[\]_a-z~]|\{[!#&+,./;=?@|]?(%[0-9a-f]{2}|[0-9_a-z])(\.?(%[0-9a-f]{2}|[0-9_a-z]))*(:[1-9]\d{0,3}|\*)?(,(%[0-9a-f]{2}|[0-9_a-z])(\.?(%[0-9a-f]{2}|[0-9_a-z]))*(:[1-9]\d{0,3}|\*)?)*\})*/iu,"json-pointer":/^(\/([\x00-\x2e0-@\[-}\x7f]|~[01])*)*$/iu,"relative-json-pointer":/^\d+(#|(\/([\x00-\x2e0-@\[-}\x7f]|~[01])*)*)$/iu,hostname:/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,"host-name":/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,"utc-millisec":function(e){return"string"==typeof e&&parseFloat(e)===parseInt(e,10)&&!isNaN(e)},regex:function(e){var t=!0;try{new RegExp(e)}catch(e){t=!1}return t},style:/[\r\n\t ]*[^\r\n\t ][^:]*:[\r\n\t ]*[^\r\n\t ;]*[\r\n\t ]*;?/,color:/^(#?([0-9A-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/,phone:/^\+(?:[0-9] ?){6,14}[0-9]$/,alpha:/^[a-zA-Z]+$/,alphanumeric:/^[a-zA-Z0-9]+$/};u.regexp=u.regex,u.pattern=u.regex,u.ipv4=u["ip-address"],t.isFormat=function(e,t,n){if("string"==typeof e&&void 0!==u[t]){if(u[t]instanceof RegExp)return u[t].test(e);if("function"==typeof u[t])return u[t](e)}else if(n&&n.customFormats&&"function"==typeof n.customFormats[t])return n.customFormats[t](e);return!0};var h=t.makeSuffix=function(e){return(e=e.toString()).match(/[.\s\[\]]/)||e.match(/^[\d]/)?e.match(/^\d+$/)?"["+e+"]":"["+JSON.stringify(e)+"]":"."+e};function d(e,t,n,r){"object"==typeof n?t[r]=g(e[r],n):-1===e.indexOf(n)&&t.push(n)}function f(e,t,n){t[n]=e[n]}function p(e,t,n,r){"object"==typeof t[r]&&t[r]&&e[r]?n[r]=g(e[r],t[r]):n[r]=t[r]}function g(e,t){var n=Array.isArray(t),r=n&&[]||{};return n?(e=e||[],r=r.concat(e),t.forEach(d.bind(null,e,r))):(e&&"object"==typeof e&&Object.keys(e).forEach(f.bind(null,e,r)),Object.keys(t).forEach(p.bind(null,e,t,r))),r}function m(e){return"/"+encodeURIComponent(e).replace(/~/g,"%7E")}t.deepCompareStrict=function e(t,n){if(typeof t!=typeof n)return!1;if(Array.isArray(t))return!!Array.isArray(n)&&t.length===n.length&&t.every((function(r,i){return e(t[i],n[i])}));if("object"==typeof t){if(!t||!n)return t===n;var r=Object.keys(t),i=Object.keys(n);return r.length===i.length&&r.every((function(r){return e(t[r],n[r])}))}return t===n},e.exports.deepMerge=g,t.objectGetPath=function(e,t){for(var n,r=t.split("/").slice(1);"string"==typeof(n=r.shift());){var i=decodeURIComponent(n.replace(/~0/,"~").replace(/~1/g,"/"));if(!(i in e))return;e=e[i]}return e},t.encodePath=function(e){return e.map(m).join("")},t.getDecimalPlaces=function(e){var t=0;if(isNaN(e))return t;"number"!=typeof e&&(e=Number(e));var n=e.toString().split("e");if(2===n.length){if("-"!==n[1][0])return t;t=Number(n[1].slice(1))}var r=n[0].split(".");return 2===r.length&&(t+=r[1].length),t},t.isSchema=function(e){return"object"==typeof e&&e||"boolean"==typeof e}},4445:(e,t,n)=>{"use strict";n(6719);n(1020).ValidatorResult,n(1020).ValidatorResultError,n(1020).ValidationError,n(1020).SchemaError,n(3107),n(3107).R},3107:(e,t,n)=>{"use strict";var r=n(8526),i=n(1020);function s(e,t){this.id=e,this.ref=t}e.exports.R=function(e,t){function n(e,t){if(t&&"object"==typeof t)if(t.$ref){var s=r.resolve(e,t.$ref);c[s]=c[s]?c[s]+1:0}else{var u=t.$id||t.id,h=u?r.resolve(e,u):e;if(h){if(h.indexOf("#")<0&&(h+="#"),l[h]){if(!i.deepCompareStrict(l[h],t))throw new Error("Schema <"+h+"> already exists with different definition");return l[h]}l[h]=t,"#"==h[h.length-1]&&(l[h.substring(0,h.length-1)]=t)}a(h+"/items",Array.isArray(t.items)?t.items:[t.items]),a(h+"/extends",Array.isArray(t.extends)?t.extends:[t.extends]),n(h+"/additionalItems",t.additionalItems),o(h+"/properties",t.properties),n(h+"/additionalProperties",t.additionalProperties),o(h+"/definitions",t.definitions),o(h+"/patternProperties",t.patternProperties),o(h+"/dependencies",t.dependencies),a(h+"/disallow",t.disallow),a(h+"/allOf",t.allOf),a(h+"/anyOf",t.anyOf),a(h+"/oneOf",t.oneOf),n(h+"/not",t.not)}}function a(e,t){if(Array.isArray(t))for(var r=0;r<t.length;r++)n(e+"/"+r,t[r])}function o(e,t){if(t&&"object"==typeof t)for(var r in t)n(e+"/"+r,t[r])}var l={},c={};return n(e,t),new s(l,c)}},6719:(e,t,n)=>{"use strict";var r=n(8526),i=n(9427),s=n(1020),a=n(3107).R,o=s.ValidatorResult,l=s.ValidatorResultError,c=s.SchemaError,u=s.SchemaContext,h=function e(){this.customFormats=Object.create(e.prototype.customFormats),this.schemas={},this.unresolvedRefs=[],this.types=Object.create(f),this.attributes=Object.create(i.validators)};function d(e){var t="string"==typeof e?e:e.$ref;return"string"==typeof t&&t}h.prototype.customFormats={},h.prototype.schemas=null,h.prototype.types=null,h.prototype.attributes=null,h.prototype.unresolvedRefs=null,h.prototype.addSchema=function(e,t){var n=this;if(!e)return null;var r=a(t||"/",e),i=t||e.$id||e.id;for(var s in r.id)this.schemas[s]=r.id[s];for(var s in r.ref)this.unresolvedRefs.push(s);return this.unresolvedRefs=this.unresolvedRefs.filter((function(e){return void 0===n.schemas[e]})),this.schemas[i]},h.prototype.addSubSchemaArray=function(e,t){if(Array.isArray(t))for(var n=0;n<t.length;n++)this.addSubSchema(e,t[n])},h.prototype.addSubSchemaObject=function(e,t){if(t&&"object"==typeof t)for(var n in t)this.addSubSchema(e,t[n])},h.prototype.setSchemas=function(e){this.schemas=e},h.prototype.getSchema=function(e){return this.schemas[e]},h.prototype.validate=function(e,t,n,i){if("boolean"!=typeof t&&"object"!=typeof t||null===t)throw new c("Expected `schema` to be an object or boolean");n||(n={});var s,h=t.$id||t.id,d=r.resolve(n.base||"/",h||"");if(!i){(i=new u(t,n,[],d,Object.create(this.schemas))).schemas[d]||(i.schemas[d]=t);var f=a(d,t);for(var p in f.id){var g=f.id[p];i.schemas[p]=g}}if(n.required&&void 0===e)return(s=new o(e,t,n,i)).addError("is required, but is undefined"),s;if(!(s=this.validateSchema(e,t,n,i)))throw new Error("Result undefined");if(n.throwAll&&s.errors.length)throw new l(s);return s},h.prototype.validateSchema=function(e,t,n,r){var a=new o(e,t,n,r);if("boolean"==typeof t)!0===t?t={}:!1===t&&(t={type:[]});else if(!t)throw new Error("schema is undefined");if(t.extends)if(Array.isArray(t.extends)){var l={schema:t,ctx:r};t.extends.forEach(this.schemaTraverser.bind(this,l)),t=l.schema,l.schema=null,l.ctx=null,l=null}else t=s.deepMerge(t,this.superResolve(t.extends,r));var h=d(t);if(h){var f=this.resolve(t,h,r),p=new u(f.subschema,n,r.path,f.switchSchema,r.schemas);return this.validateSchema(e,f.subschema,n,p)}var g=n&&n.skipAttributes||[];for(var m in t)if(!i.ignoreProperties[m]&&g.indexOf(m)<0){var y=null,b=this.attributes[m];if(b)y=b.call(this,e,t,n,r);else if(!1===n.allowUnknownAttributes)throw new c("Unsupported attribute: "+m,t);y&&a.importErrors(y)}if("function"==typeof n.rewrite){var v=n.rewrite.call(this,e,t,n,r);a.instance=v}return a},h.prototype.schemaTraverser=function(e,t){e.schema=s.deepMerge(e.schema,this.superResolve(t,e.ctx))},h.prototype.superResolve=function(e,t){var n=d(e);return n?this.resolve(e,n,t).subschema:e},h.prototype.resolve=function(e,t,n){if(t=n.resolve(t),n.schemas[t])return{subschema:n.schemas[t],switchSchema:t};var i=r.parse(t),a=i&&i.hash,o=a&&a.length&&t.substr(0,t.length-a.length);if(!o||!n.schemas[o])throw new c("no such schema <"+t+">",e);var l=s.objectGetPath(n.schemas[o],a.substr(1));if(void 0===l)throw new c("no such schema "+a+" located in <"+o+">",e);return{subschema:l,switchSchema:t}},h.prototype.testType=function(e,t,n,r,i){if(void 0!==i){if(null===i)throw new c('Unexpected null in "type" keyword');if("function"==typeof this.types[i])return this.types[i].call(this,e);if(i&&"object"==typeof i){var s=this.validateSchema(e,i,n,r);return void 0===s||!(s&&s.errors.length)}return!0}};var f=h.prototype.types={};f.string=function(e){return"string"==typeof e},f.number=function(e){return"number"==typeof e&&isFinite(e)},f.integer=function(e){return"number"==typeof e&&e%1==0},f.boolean=function(e){return"boolean"==typeof e},f.array=function(e){return Array.isArray(e)},f.null=function(e){return null===e},f.date=function(e){return e instanceof Date},f.any=function(e){return!0},f.object=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&!(e instanceof Date)},e.exports=h},201:(e,t,n)=>{var r="function"==typeof Map&&Map.prototype,i=Object.getOwnPropertyDescriptor&&r?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,s=r&&i&&"function"==typeof i.get?i.get:null,a=r&&Map.prototype.forEach,o="function"==typeof Set&&Set.prototype,l=Object.getOwnPropertyDescriptor&&o?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,c=o&&l&&"function"==typeof l.get?l.get:null,u=o&&Set.prototype.forEach,h="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,d="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,f="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,p=Boolean.prototype.valueOf,g=Object.prototype.toString,m=Function.prototype.toString,y=String.prototype.match,b=String.prototype.slice,v=String.prototype.replace,w=String.prototype.toUpperCase,S=String.prototype.toLowerCase,E=RegExp.prototype.test,x=Array.prototype.concat,k=Array.prototype.join,O=Array.prototype.slice,_=Math.floor,C="function"==typeof BigInt?BigInt.prototype.valueOf:null,T=Object.getOwnPropertySymbols,A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,P="function"==typeof Symbol&&"object"==typeof Symbol.iterator,F="function"==typeof Symbol&&Symbol.toStringTag&&(Symbol.toStringTag,1)?Symbol.toStringTag:null,N=Object.prototype.propertyIsEnumerable,L=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function R(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||E.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-_(-e):_(e);if(r!==e){var i=String(r),s=b.call(t,i.length+1);return v.call(i,n,"$&_")+"."+v.call(v.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return v.call(t,n,"$&_")}var I=n(6553),j=I.custom,M=V(j)?j:null;function D(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function $(e){return v.call(String(e),/"/g,"&quot;")}function B(e){return!("[object Array]"!==q(e)||F&&"object"==typeof e&&F in e)}function U(e){return!("[object RegExp]"!==q(e)||F&&"object"==typeof e&&F in e)}function V(e){if(P)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!A)return!1;try{return A.call(e),!0}catch(e){}return!1}e.exports=function e(t,r,i,o){var l=r||{};if(z(l,"quoteStyle")&&"single"!==l.quoteStyle&&"double"!==l.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(z(l,"maxStringLength")&&("number"==typeof l.maxStringLength?l.maxStringLength<0&&l.maxStringLength!==1/0:null!==l.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var g=!z(l,"customInspect")||l.customInspect;if("boolean"!=typeof g&&"symbol"!==g)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(z(l,"indent")&&null!==l.indent&&"\t"!==l.indent&&!(parseInt(l.indent,10)===l.indent&&l.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(z(l,"numericSeparator")&&"boolean"!=typeof l.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var w=l.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return Z(t,l);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var E=String(t);return w?R(t,E):E}if("bigint"==typeof t){var _=String(t)+"n";return w?R(t,_):_}var T=void 0===l.depth?5:l.depth;if(void 0===i&&(i=0),i>=T&&T>0&&"object"==typeof t)return B(t)?"[Array]":"[Object]";var j,H=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=k.call(Array(e.indent+1)," ")}return{base:n,prev:k.call(Array(t+1),n)}}(l,i);if(void 0===o)o=[];else if(W(o,t)>=0)return"[Circular]";function X(t,n,r){if(n&&(o=O.call(o)).push(n),r){var s={depth:l.depth};return z(l,"quoteStyle")&&(s.quoteStyle=l.quoteStyle),e(t,s,i+1,o)}return e(t,l,i+1,o)}if("function"==typeof t&&!U(t)){var ee=function(e){if(e.name)return e.name;var t=y.call(m.call(e),/^function\s*([\w$]+)/);return t?t[1]:null}(t),te=Q(t,X);return"[Function"+(ee?": "+ee:" (anonymous)")+"]"+(te.length>0?" { "+k.call(te,", ")+" }":"")}if(V(t)){var ne=P?v.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):A.call(t);return"object"!=typeof t||P?ne:K(ne)}if((j=t)&&"object"==typeof j&&("undefined"!=typeof HTMLElement&&j instanceof HTMLElement||"string"==typeof j.nodeName&&"function"==typeof j.getAttribute)){for(var re="<"+S.call(String(t.nodeName)),ie=t.attributes||[],se=0;se<ie.length;se++)re+=" "+ie[se].name+"="+D($(ie[se].value),"double",l);return re+=">",t.childNodes&&t.childNodes.length&&(re+="..."),re+"</"+S.call(String(t.nodeName))+">"}if(B(t)){if(0===t.length)return"[]";var ae=Q(t,X);return H&&!function(e){for(var t=0;t<e.length;t++)if(W(e[t],"\n")>=0)return!1;return!0}(ae)?"["+J(ae,H)+"]":"[ "+k.call(ae,", ")+" ]"}if(function(e){return!("[object Error]"!==q(e)||F&&"object"==typeof e&&F in e)}(t)){var oe=Q(t,X);return"cause"in Error.prototype||!("cause"in t)||N.call(t,"cause")?0===oe.length?"["+String(t)+"]":"{ ["+String(t)+"] "+k.call(oe,", ")+" }":"{ ["+String(t)+"] "+k.call(x.call("[cause]: "+X(t.cause),oe),", ")+" }"}if("object"==typeof t&&g){if(M&&"function"==typeof t[M]&&I)return I(t,{depth:T-i});if("symbol"!==g&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!s||!e||"object"!=typeof e)return!1;try{s.call(e);try{c.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var le=[];return a&&a.call(t,(function(e,n){le.push(X(n,t,!0)+" => "+X(e,t))})),Y("Map",s.call(t),le,H)}if(function(e){if(!c||!e||"object"!=typeof e)return!1;try{c.call(e);try{s.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var ce=[];return u&&u.call(t,(function(e){ce.push(X(e,t))})),Y("Set",c.call(t),ce,H)}if(function(e){if(!h||!e||"object"!=typeof e)return!1;try{h.call(e,h);try{d.call(e,d)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return G("WeakMap");if(function(e){if(!d||!e||"object"!=typeof e)return!1;try{d.call(e,d);try{h.call(e,h)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return G("WeakSet");if(function(e){if(!f||!e||"object"!=typeof e)return!1;try{return f.call(e),!0}catch(e){}return!1}(t))return G("WeakRef");if(function(e){return!("[object Number]"!==q(e)||F&&"object"==typeof e&&F in e)}(t))return K(X(Number(t)));if(function(e){if(!e||"object"!=typeof e||!C)return!1;try{return C.call(e),!0}catch(e){}return!1}(t))return K(X(C.call(t)));if(function(e){return!("[object Boolean]"!==q(e)||F&&"object"==typeof e&&F in e)}(t))return K(p.call(t));if(function(e){return!("[object String]"!==q(e)||F&&"object"==typeof e&&F in e)}(t))return K(X(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===n.g)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==q(e)||F&&"object"==typeof e&&F in e)}(t)&&!U(t)){var ue=Q(t,X),he=L?L(t)===Object.prototype:t instanceof Object||t.constructor===Object,de=t instanceof Object?"":"null prototype",fe=!he&&F&&Object(t)===t&&F in t?b.call(q(t),8,-1):de?"Object":"",pe=(he||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(fe||de?"["+k.call(x.call([],fe||[],de||[]),": ")+"] ":"");return 0===ue.length?pe+"{}":H?pe+"{"+J(ue,H)+"}":pe+"{ "+k.call(ue,", ")+" }"}return String(t)};var H=Object.prototype.hasOwnProperty||function(e){return e in this};function z(e,t){return H.call(e,t)}function q(e){return g.call(e)}function W(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}function Z(e,t){if(e.length>t.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return Z(b.call(e,0,t.maxStringLength),t)+r}return D(v.call(v.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,X),"single",t)}function X(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+w.call(t.toString(16))}function K(e){return"Object("+e+")"}function G(e){return e+" { ? }"}function Y(e,t,n,r){return e+" ("+t+") {"+(r?J(n,r):k.call(n,", "))+"}"}function J(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+k.call(e,","+n)+"\n"+t.prev}function Q(e,t){var n=B(e),r=[];if(n){r.length=e.length;for(var i=0;i<e.length;i++)r[i]=z(e,i)?t(e[i],e):""}var s,a="function"==typeof T?T(e):[];if(P){s={};for(var o=0;o<a.length;o++)s["$"+a[o]]=a[o]}for(var l in e)z(e,l)&&(n&&String(Number(l))===l&&l<e.length||P&&s["$"+l]instanceof Symbol||(E.call(/[^\w$]/,l)?r.push(t(l,e)+": "+t(e[l],e)):r.push(l+": "+t(e[l],e))));if("function"==typeof T)for(var c=0;c<a.length;c++)N.call(e,a[c])&&r.push("["+t(a[c])+"]: "+t(e[a[c]],e));return r}},2565:(e,t,n)=>{"use strict";var r=n(3298),i=/[\/\?<>\\:\*\|"]/g,s=/[\x00-\x1f\x80-\x9f]/g,a=/^\.+$/,o=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,l=/[\. ]+$/;function c(e,t){if("string"!=typeof e)throw new Error("Input must be string");var n=e.replace(i,t).replace(s,t).replace(a,t).replace(o,t).replace(l,t);return r(n,255)}e.exports=function(e,t){var n=t&&t.replacement||"",r=c(e,n);return""===n?r:c(r,"")}},7319:(e,t,n)=>{"use strict";var r=n(4663),i=n(8531),s=n(3219)(),a=n(8337),o=r("%TypeError%"),l=r("%Math.floor%");e.exports=function(e,t){if("function"!=typeof e)throw new o("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||l(t)!==t)throw new o("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],r=!0,c=!0;if("length"in e&&a){var u=a(e,"length");u&&!u.configurable&&(r=!1),u&&!u.writable&&(c=!1)}return(r||c||!n)&&(s?i(e,"length",t,!0,!0):i(e,"length",t)),e}},8959:(e,t,n)=>{"use strict";var r=n(4663),i=n(8608),s=n(201),a=r("%TypeError%"),o=r("%WeakMap%",!0),l=r("%Map%",!0),c=i("WeakMap.prototype.get",!0),u=i("WeakMap.prototype.set",!0),h=i("WeakMap.prototype.has",!0),d=i("Map.prototype.get",!0),f=i("Map.prototype.set",!0),p=i("Map.prototype.has",!0),g=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n};e.exports=function(){var e,t,n,r={assert:function(e){if(!r.has(e))throw new a("Side channel does not contain "+s(e))},get:function(r){if(o&&r&&("object"==typeof r||"function"==typeof r)){if(e)return c(e,r)}else if(l){if(t)return d(t,r)}else if(n)return function(e,t){var n=g(e,t);return n&&n.value}(n,r)},has:function(r){if(o&&r&&("object"==typeof r||"function"==typeof r)){if(e)return h(e,r)}else if(l){if(t)return p(t,r)}else if(n)return function(e,t){return!!g(e,t)}(n,r);return!1},set:function(r,i){o&&r&&("object"==typeof r||"function"==typeof r)?(e||(e=new o),u(e,r,i)):l?(t||(t=new l),f(t,r,i)):(n||(n={key:{},next:null}),function(e,t,n){var r=g(e,t);r?r.value=n:e.next={key:t,next:e.next,value:n}}(n,r,i))}};return r}},5326:e=>{const t=/^[-+]?0x[a-fA-F0-9]+$/,n=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt),!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const r={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};e.exports=function(e,i={}){if(i=Object.assign({},r,i),!e||"string"!=typeof e)return e;let s=e.trim();if(void 0!==i.skipLike&&i.skipLike.test(s))return e;if(i.hex&&t.test(s))return Number.parseInt(s,16);{const t=n.exec(s);if(t){const n=t[1],r=t[2];let o=(a=t[3])&&-1!==a.indexOf(".")?("."===(a=a.replace(/0+$/,""))?a="0":"."===a[0]?a="0"+a:"."===a[a.length-1]&&(a=a.substr(0,a.length-1)),a):a;const l=t[4]||t[6];if(!i.leadingZeros&&r.length>0&&n&&"."!==s[2])return e;if(!i.leadingZeros&&r.length>0&&!n&&"."!==s[1])return e;{const t=Number(s),a=""+t;return-1!==a.search(/[eE]/)||l?i.eNotation?t:e:-1!==s.indexOf(".")?"0"===a&&""===o||a===o||n&&a==="-"+o?t:e:r?o===a||n+o===a?t:e:s===a||s===n+a?t:e}}return e}var a}},3298:(e,t,n)=>{"use strict";var r=n(2815),i=n(2875);e.exports=r.bind(null,i)},2815:e=>{"use strict";function t(e){return e>=55296&&e<=56319}function n(e){return e>=56320&&e<=57343}e.exports=function(e,r,i){if("string"!=typeof r)throw new Error("Input must be string");for(var s,a,o=r.length,l=0,c=0;c<o;c+=1){if(s=r.charCodeAt(c),a=r[c],t(s)&&n(r.charCodeAt(c+1))&&(a+=r[c+=1]),(l+=e(a))===i)return r.slice(0,c+1);if(l>i)return r.slice(0,c-a.length+1)}return r}},9177:function(e,t,n){var r;e=n.nmd(e),function(i){t&&t.nodeType,e&&e.nodeType;var s="object"==typeof n.g&&n.g;s.global!==s&&s.window!==s&&s.self;var a,o=2147483647,l=36,c=26,u=38,h=700,d=/^xn--/,f=/[^\x20-\x7E]/,p=/[\x2E\u3002\uFF0E\uFF61]/g,g={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},m=l-1,y=Math.floor,b=String.fromCharCode;function v(e){throw new RangeError(g[e])}function w(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function S(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+w((e=e.replace(p,".")).split("."),t).join(".")}function E(e){for(var t,n,r=[],i=0,s=e.length;i<s;)(t=e.charCodeAt(i++))>=55296&&t<=56319&&i<s?56320==(64512&(n=e.charCodeAt(i++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),i--):r.push(t);return r}function x(e){return w(e,(function(e){var t="";return e>65535&&(t+=b((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+b(e)})).join("")}function k(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function O(e,t,n){var r=0;for(e=n?y(e/h):e>>1,e+=y(e/t);e>m*c>>1;r+=l)e=y(e/m);return y(r+(m+1)*e/(e+u))}function _(e){var t,n,r,i,s,a,u,h,d,f,p,g=[],m=e.length,b=0,w=128,S=72;for((n=e.lastIndexOf("-"))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&v("not-basic"),g.push(e.charCodeAt(r));for(i=n>0?n+1:0;i<m;){for(s=b,a=1,u=l;i>=m&&v("invalid-input"),((h=(p=e.charCodeAt(i++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:l)>=l||h>y((o-b)/a))&&v("overflow"),b+=h*a,!(h<(d=u<=S?1:u>=S+c?c:u-S));u+=l)a>y(o/(f=l-d))&&v("overflow"),a*=f;S=O(b-s,t=g.length+1,0==s),y(b/t)>o-w&&v("overflow"),w+=y(b/t),b%=t,g.splice(b++,0,w)}return x(g)}function C(e){var t,n,r,i,s,a,u,h,d,f,p,g,m,w,S,x=[];for(g=(e=E(e)).length,t=128,n=0,s=72,a=0;a<g;++a)(p=e[a])<128&&x.push(b(p));for(r=i=x.length,i&&x.push("-");r<g;){for(u=o,a=0;a<g;++a)(p=e[a])>=t&&p<u&&(u=p);for(u-t>y((o-n)/(m=r+1))&&v("overflow"),n+=(u-t)*m,t=u,a=0;a<g;++a)if((p=e[a])<t&&++n>o&&v("overflow"),p==t){for(h=n,d=l;!(h<(f=d<=s?1:d>=s+c?c:d-s));d+=l)S=h-f,w=l-f,x.push(b(k(f+S%w,0))),h=y(S/w);x.push(b(k(h,0))),s=O(n,m,r==i),n=0,++r}++n,++t}return x.join("")}a={version:"1.4.1",ucs2:{decode:E,encode:x},decode:_,encode:C,toASCII:function(e){return S(e,(function(e){return f.test(e)?"xn--"+C(e):e}))},toUnicode:function(e){return S(e,(function(e){return d.test(e)?_(e.slice(4).toLowerCase()):e}))}},void 0===(r=function(){return a}.call(t,n,t,e))||(e.exports=r)}()},7032:e=>{"use strict";var t=String.prototype.replace,n=/%20/g,r="RFC3986";e.exports={default:r,formatters:{RFC1738:function(e){return t.call(e,n,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:r}},3184:(e,t,n)=>{"use strict";var r=n(1645),i=n(5610),s=n(7032);e.exports={formats:s,parse:i,stringify:r}},5610:(e,t,n)=>{"use strict";var r=n(8206),i=Object.prototype.hasOwnProperty,s=Array.isArray,a={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:r.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},o=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},l=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},c=function(e,t,n,r){if(e){var s=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,a=/(\[[^[\]]*])/g,o=n.depth>0&&/(\[[^[\]]*])/.exec(s),c=o?s.slice(0,o.index):s,u=[];if(c){if(!n.plainObjects&&i.call(Object.prototype,c)&&!n.allowPrototypes)return;u.push(c)}for(var h=0;n.depth>0&&null!==(o=a.exec(s))&&h<n.depth;){if(h+=1,!n.plainObjects&&i.call(Object.prototype,o[1].slice(1,-1))&&!n.allowPrototypes)return;u.push(o[1])}return o&&u.push("["+s.slice(o.index)+"]"),function(e,t,n,r){for(var i=r?t:l(t,n),s=e.length-1;s>=0;--s){var a,o=e[s];if("[]"===o&&n.parseArrays)a=[].concat(i);else{a=n.plainObjects?Object.create(null):{};var c="["===o.charAt(0)&&"]"===o.charAt(o.length-1)?o.slice(1,-1):o,u=parseInt(c,10);n.parseArrays||""!==c?!isNaN(u)&&o!==c&&String(u)===c&&u>=0&&n.parseArrays&&u<=n.arrayLimit?(a=[])[u]=i:"__proto__"!==c&&(a[c]=i):a={0:i}}i=a}return i}(u,t,n,r)}};e.exports=function(e,t){var n=function(e){if(!e)return a;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?a.charset:e.charset;return{allowDots:void 0===e.allowDots?a.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:a.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:a.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:a.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:a.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:a.comma,decoder:"function"==typeof e.decoder?e.decoder:a.decoder,delimiter:"string"==typeof e.delimiter||r.isRegExp(e.delimiter)?e.delimiter:a.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:a.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:a.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:a.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:a.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:a.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var u="string"==typeof e?function(e,t){var n,c={__proto__:null},u=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,h=t.parameterLimit===1/0?void 0:t.parameterLimit,d=u.split(t.delimiter,h),f=-1,p=t.charset;if(t.charsetSentinel)for(n=0;n<d.length;++n)0===d[n].indexOf("utf8=")&&("utf8=%E2%9C%93"===d[n]?p="utf-8":"utf8=%26%2310003%3B"===d[n]&&(p="iso-8859-1"),f=n,n=d.length);for(n=0;n<d.length;++n)if(n!==f){var g,m,y=d[n],b=y.indexOf("]="),v=-1===b?y.indexOf("="):b+1;-1===v?(g=t.decoder(y,a.decoder,p,"key"),m=t.strictNullHandling?null:""):(g=t.decoder(y.slice(0,v),a.decoder,p,"key"),m=r.maybeMap(l(y.slice(v+1),t),(function(e){return t.decoder(e,a.decoder,p,"value")}))),m&&t.interpretNumericEntities&&"iso-8859-1"===p&&(m=o(m)),y.indexOf("[]=")>-1&&(m=s(m)?[m]:m),i.call(c,g)?c[g]=r.combine(c[g],m):c[g]=m}return c}(e,n):e,h=n.plainObjects?Object.create(null):{},d=Object.keys(u),f=0;f<d.length;++f){var p=d[f],g=c(p,u[p],n,"string"==typeof e);h=r.merge(h,g,n)}return!0===n.allowSparse?h:r.compact(h)}},1645:(e,t,n)=>{"use strict";var r=n(8959),i=n(8206),s=n(7032),a=Object.prototype.hasOwnProperty,o={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},l=Array.isArray,c=Array.prototype.push,u=function(e,t){c.apply(e,l(t)?t:[t])},h=Date.prototype.toISOString,d=s.default,f={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:i.encode,encodeValuesOnly:!1,format:d,formatter:s.formatters[d],indices:!1,serializeDate:function(e){return h.call(e)},skipNulls:!1,strictNullHandling:!1},p={},g=function e(t,n,s,a,o,c,h,d,g,m,y,b,v,w,S,E){for(var x,k=t,O=E,_=0,C=!1;void 0!==(O=O.get(p))&&!C;){var T=O.get(t);if(_+=1,void 0!==T){if(T===_)throw new RangeError("Cyclic object value");C=!0}void 0===O.get(p)&&(_=0)}if("function"==typeof d?k=d(n,k):k instanceof Date?k=y(k):"comma"===s&&l(k)&&(k=i.maybeMap(k,(function(e){return e instanceof Date?y(e):e}))),null===k){if(o)return h&&!w?h(n,f.encoder,S,"key",b):n;k=""}if("string"==typeof(x=k)||"number"==typeof x||"boolean"==typeof x||"symbol"==typeof x||"bigint"==typeof x||i.isBuffer(k))return h?[v(w?n:h(n,f.encoder,S,"key",b))+"="+v(h(k,f.encoder,S,"value",b))]:[v(n)+"="+v(String(k))];var A,P=[];if(void 0===k)return P;if("comma"===s&&l(k))w&&h&&(k=i.maybeMap(k,h)),A=[{value:k.length>0?k.join(",")||null:void 0}];else if(l(d))A=d;else{var F=Object.keys(k);A=g?F.sort(g):F}for(var N=a&&l(k)&&1===k.length?n+"[]":n,L=0;L<A.length;++L){var R=A[L],I="object"==typeof R&&void 0!==R.value?R.value:k[R];if(!c||null!==I){var j=l(k)?"function"==typeof s?s(N,R):N:N+(m?"."+R:"["+R+"]");E.set(t,_);var M=r();M.set(p,E),u(P,e(I,j,s,a,o,c,"comma"===s&&w&&l(k)?null:h,d,g,m,y,b,v,w,S,M))}}return P};e.exports=function(e,t){var n,i=e,c=function(e){if(!e)return f;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||f.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=s.default;if(void 0!==e.format){if(!a.call(s.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=s.formatters[n],i=f.filter;return("function"==typeof e.filter||l(e.filter))&&(i=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:f.addQueryPrefix,allowDots:void 0===e.allowDots?f.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:f.charsetSentinel,delimiter:void 0===e.delimiter?f.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:f.encode,encoder:"function"==typeof e.encoder?e.encoder:f.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:f.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:f.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:f.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:f.strictNullHandling}}(t);"function"==typeof c.filter?i=(0,c.filter)("",i):l(c.filter)&&(n=c.filter);var h,d=[];if("object"!=typeof i||null===i)return"";h=t&&t.arrayFormat in o?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var p=o[h];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var m="comma"===p&&t&&t.commaRoundTrip;n||(n=Object.keys(i)),c.sort&&n.sort(c.sort);for(var y=r(),b=0;b<n.length;++b){var v=n[b];c.skipNulls&&null===i[v]||u(d,g(i[v],v,p,m,c.strictNullHandling,c.skipNulls,c.encode?c.encoder:null,c.filter,c.sort,c.allowDots,c.serializeDate,c.format,c.formatter,c.encodeValuesOnly,c.charset,y))}var w=d.join(c.delimiter),S=!0===c.addQueryPrefix?"?":"";return c.charsetSentinel&&("iso-8859-1"===c.charset?S+="utf8=%26%2310003%3B&":S+="utf8=%E2%9C%93&"),w.length>0?S+w:""}},8206:(e,t,n)=>{"use strict";var r=n(7032),i=Object.prototype.hasOwnProperty,s=Array.isArray,a=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),o=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r<e.length;++r)void 0!==e[r]&&(n[r]=e[r]);return n};e.exports={arrayToObject:o,assign:function(e,t){return Object.keys(t).reduce((function(e,n){return e[n]=t[n],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],n=[],r=0;r<t.length;++r)for(var i=t[r],a=i.obj[i.prop],o=Object.keys(a),l=0;l<o.length;++l){var c=o[l],u=a[c];"object"==typeof u&&null!==u&&-1===n.indexOf(u)&&(t.push({obj:a,prop:c}),n.push(u))}return function(e){for(;e.length>1;){var t=e.pop(),n=t.obj[t.prop];if(s(n)){for(var r=[],i=0;i<n.length;++i)void 0!==n[i]&&r.push(n[i]);t.obj[t.prop]=r}}}(t),e},decode:function(e,t,n){var r=e.replace(/\+/g," ");if("iso-8859-1"===n)return r.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(r)}catch(e){return r}},encode:function(e,t,n,i,s){if(0===e.length)return e;var o=e;if("symbol"==typeof e?o=Symbol.prototype.toString.call(e):"string"!=typeof e&&(o=String(e)),"iso-8859-1"===n)return escape(o).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var l="",c=0;c<o.length;++c){var u=o.charCodeAt(c);45===u||46===u||95===u||126===u||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||s===r.RFC1738&&(40===u||41===u)?l+=o.charAt(c):u<128?l+=a[u]:u<2048?l+=a[192|u>>6]+a[128|63&u]:u<55296||u>=57344?l+=a[224|u>>12]+a[128|u>>6&63]+a[128|63&u]:(c+=1,u=65536+((1023&u)<<10|1023&o.charCodeAt(c)),l+=a[240|u>>18]+a[128|u>>12&63]+a[128|u>>6&63]+a[128|63&u])}return l},isBuffer:function(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(s(e)){for(var n=[],r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)},merge:function e(t,n,r){if(!n)return t;if("object"!=typeof n){if(s(t))t.push(n);else{if(!t||"object"!=typeof t)return[t,n];(r&&(r.plainObjects||r.allowPrototypes)||!i.call(Object.prototype,n))&&(t[n]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(n);var a=t;return s(t)&&!s(n)&&(a=o(t,r)),s(t)&&s(n)?(n.forEach((function(n,s){if(i.call(t,s)){var a=t[s];a&&"object"==typeof a&&n&&"object"==typeof n?t[s]=e(a,n,r):t.push(n)}else t[s]=n})),t):Object.keys(n).reduce((function(t,s){var a=n[s];return i.call(t,s)?t[s]=e(t[s],a,r):t[s]=a,t}),a)}}},8526:(e,t,n)=>{"use strict";var r=n(9177);function i(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,o=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,l=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(l),u=["%","/","?",";","#"].concat(c),h=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,f=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,p={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=n(3184);function b(e,t,n){if(e&&"object"==typeof e&&e instanceof i)return e;var r=new i;return r.parse(e,t,n),r}i.prototype.parse=function(e,t,n){if("string"!=typeof e)throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),a=-1!==i&&i<e.indexOf("#")?"?":"#",l=e.split(a);l[0]=l[0].replace(/\\/g,"/");var b=e=l.join(a);if(b=b.trim(),!n&&1===e.split("#").length){var v=o.exec(b);if(v)return this.path=b,this.href=b,this.pathname=v[1],v[2]?(this.search=v[2],this.query=t?y.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var w=s.exec(b);if(w){var S=(w=w[0]).toLowerCase();this.protocol=S,b=b.substr(w.length)}if(n||w||b.match(/^\/\/[^@/]+@[^@/]+/)){var E="//"===b.substr(0,2);!E||w&&g[w]||(b=b.substr(2),this.slashes=!0)}if(!g[w]&&(E||w&&!m[w])){for(var x,k,O=-1,_=0;_<h.length;_++)-1!==(C=b.indexOf(h[_]))&&(-1===O||C<O)&&(O=C);for(-1!==(k=-1===O?b.lastIndexOf("@"):b.lastIndexOf("@",O))&&(x=b.slice(0,k),b=b.slice(k+1),this.auth=decodeURIComponent(x)),O=-1,_=0;_<u.length;_++){var C;-1!==(C=b.indexOf(u[_]))&&(-1===O||C<O)&&(O=C)}-1===O&&(O=b.length),this.host=b.slice(0,O),b=b.slice(O),this.parseHost(),this.hostname=this.hostname||"";var T="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!T)for(var A=this.hostname.split(/\./),P=(_=0,A.length);_<P;_++){var F=A[_];if(F&&!F.match(d)){for(var N="",L=0,R=F.length;L<R;L++)F.charCodeAt(L)>127?N+="x":N+=F[L];if(!N.match(d)){var I=A.slice(0,_),j=A.slice(_+1),M=F.match(f);M&&(I.push(M[1]),j.unshift(M[2])),j.length&&(b="/"+j.join(".")+b),this.hostname=I.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=r.toASCII(this.hostname));var D=this.port?":"+this.port:"",$=this.hostname||"";this.host=$+D,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==b[0]&&(b="/"+b))}if(!p[S])for(_=0,P=c.length;_<P;_++){var B=c[_];if(-1!==b.indexOf(B)){var U=encodeURIComponent(B);U===B&&(U=escape(B)),b=b.split(B).join(U)}}var V=b.indexOf("#");-1!==V&&(this.hash=b.substr(V),b=b.slice(0,V));var H=b.indexOf("?");if(-1!==H?(this.search=b.substr(H),this.query=b.substr(H+1),t&&(this.query=y.parse(this.query)),b=b.slice(0,H)):t&&(this.search="",this.query={}),b&&(this.pathname=b),m[S]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){D=this.pathname||"";var z=this.search||"";this.path=D+z}return this.href=this.format(),this},i.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,s="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&"object"==typeof this.query&&Object.keys(this.query).length&&(s=y.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||m[t])&&!1!==i?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),t+i+(n=n.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+r},i.prototype.resolve=function(e){return this.resolveObject(b(e,!1,!0)).format()},i.prototype.resolveObject=function(e){if("string"==typeof e){var t=new i;t.parse(e,!1,!0),e=t}for(var n=new i,r=Object.keys(this),s=0;s<r.length;s++){var a=r[s];n[a]=this[a]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var o=Object.keys(e),l=0;l<o.length;l++){var c=o[l];"protocol"!==c&&(n[c]=e[c])}return m[n.protocol]&&n.hostname&&!n.pathname&&(n.pathname="/",n.path=n.pathname),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!m[e.protocol]){for(var u=Object.keys(e),h=0;h<u.length;h++){var d=u[h];n[d]=e[d]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||g[e.protocol])n.pathname=e.pathname;else{for(var f=(e.pathname||"").split("/");f.length&&!(e.host=f.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==f[0]&&f.unshift(""),f.length<2&&f.unshift(""),n.pathname=f.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var p=n.pathname||"",y=n.search||"";n.path=p+y}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var b=n.pathname&&"/"===n.pathname.charAt(0),v=e.host||e.pathname&&"/"===e.pathname.charAt(0),w=v||b||n.host&&e.pathname,S=w,E=n.pathname&&n.pathname.split("/")||[],x=(f=e.pathname&&e.pathname.split("/")||[],n.protocol&&!m[n.protocol]);if(x&&(n.hostname="",n.port=null,n.host&&(""===E[0]?E[0]=n.host:E.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===f[0]?f[0]=e.host:f.unshift(e.host)),e.host=null),w=w&&(""===f[0]||""===E[0])),v)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,E=f;else if(f.length)E||(E=[]),E.pop(),E=E.concat(f),n.search=e.search,n.query=e.query;else if(null!=e.search)return x&&(n.host=E.shift(),n.hostname=n.host,(T=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=T.shift(),n.hostname=T.shift(),n.host=n.hostname)),n.search=e.search,n.query=e.query,null===n.pathname&&null===n.search||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!E.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var k=E.slice(-1)[0],O=(n.host||e.host||E.length>1)&&("."===k||".."===k)||""===k,_=0,C=E.length;C>=0;C--)"."===(k=E[C])?E.splice(C,1):".."===k?(E.splice(C,1),_++):_&&(E.splice(C,1),_--);if(!w&&!S)for(;_--;_)E.unshift("..");!w||""===E[0]||E[0]&&"/"===E[0].charAt(0)||E.unshift(""),O&&"/"!==E.join("/").substr(-1)&&E.push("");var T,A=""===E[0]||E[0]&&"/"===E[0].charAt(0);return x&&(n.hostname=A?"":E.length?E.shift():"",n.host=n.hostname,(T=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=T.shift(),n.hostname=T.shift(),n.host=n.hostname)),(w=w||n.host&&E.length)&&!A&&E.unshift(""),E.length>0?n.pathname=E.join("/"):(n.pathname=null,n.path=null),null===n.pathname&&null===n.search||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},i.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)},t.parse=b,t.resolve=function(e,t){return b(e,!1,!0).resolve(t)},t.resolveObject=function(e,t){return e?b(e,!1,!0).resolveObject(t):t},t.format=function(e){return"string"==typeof e&&(e=b(e)),e instanceof i?e.format():i.prototype.format.call(e)},t.Url=i},2875:e=>{"use strict";function t(e){return e>=55296&&e<=56319}function n(e){return e>=56320&&e<=57343}e.exports=function(e){if("string"!=typeof e)throw new Error("Input must be string");for(var r=e.length,i=0,s=null,a=null,o=0;o<r;o++)n(s=e.charCodeAt(o))?null!=a&&t(a)?i+=1:i+=3:s<=127?i+=1:s>=128&&s<=2047?i+=2:s>=2048&&s<=65535&&(i+=3),a=s;return i}},462:(e,t,n)=>{e.exports={WebVTT:n(5115).WebVTT,VTTCue:n(4747).VTTCue,VTTRegion:n(1271).VTTRegion}},5115:function(){!function(e){function t(e,t){return void 0===t&&(t=1),"rgba("+[parseInt(e.substring(0,2),16),parseInt(e.substring(2,4),16),parseInt(e.substring(4,6),16),t].join(",")+")"}var n=1;function r(e,r,s){switch(s){case"webvtt.font.color":case"webvtt.font.opacity":var a=Services.prefs.getCharPref("webvtt.font.color"),o=Services.prefs.getIntPref("webvtt.font.opacity")/100;i.fontSet=t(a,o);break;case"webvtt.font.scale":n=Services.prefs.getIntPref("webvtt.font.scale")/100;break;case"webvtt.bg.color":case"webvtt.bg.opacity":var l=Services.prefs.getCharPref("webvtt.bg.color"),c=Services.prefs.getIntPref("webvtt.bg.opacity")/100;i.backgroundSet=t(l,c);break;case"webvtt.edge.color":case"webvtt.edge.type":var u=Services.prefs.getIntPref("webvtt.edge.type"),h=Services.prefs.getCharPref("webvtt.edge.color");i.edgeSet=["","0px 0px ","4px 4px 4px ","-2px -2px ","2px 2px "][u]+t(h)}}if("undefined"!=typeof Services){var i={};["webvtt.font.color","webvtt.font.opacity","webvtt.font.scale","webvtt.bg.color","webvtt.bg.opacity","webvtt.edge.color","webvtt.edge.type"].forEach((function(e){r(0,0,e),Services.prefs.addObserver(e,r,!1)}))}var s=Object.create||function(){function e(){}return function(t){if(1!==arguments.length)throw new Error("Object.create shim only accepts one parameter.");return e.prototype=t,new e}}();function a(e,t){this.name="ParsingError",this.code=e.code,this.message=t||e.message}function o(e){function t(e,t,n,r){return 3600*(0|e)+60*(0|t)+(0|n)+(0|r)/1e3}var n=e.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return n?n[3]?t(n[1],n[2],n[3].replace(":",""),n[4]):n[1]>59?t(n[1],n[2],0,n[4]):t(0,n[1],n[2],n[4]):null}function l(){this.values=s(null)}function c(e,t,n,r){var i=r?e.split(r):[e];for(var s in i)if("string"==typeof i[s]){var a=i[s].split(n);2===a.length&&t(a[0],a[1])}}function u(e,t,n){var r=e;function i(){var t=o(e);if(null===t)throw new a(a.Errors.BadTimeStamp,"Malformed timestamp: "+r);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function s(){e=e.replace(/^\s+/,"")}if(s(),t.startTime=i(),s(),"--\x3e"!==e.substr(0,3))throw new a(a.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '--\x3e'): "+r);e=e.substr(3),s(),t.endTime=i(),s(),function(e,t){var r=new l;c(e,(function(e,t){switch(e){case"region":for(var i=n.length-1;i>=0;i--)if(n[i].id===t){r.set(e,n[i].region);break}break;case"vertical":r.alt(e,t,["rl","lr"]);break;case"line":var s=t.split(","),a=s[0];r.integer(e,a),r.percent(e,a)&&r.set("snapToLines",!1),r.alt(e,a,["auto"]),2===s.length&&r.alt("lineAlign",s[1],["start","middle","end"]);break;case"position":s=t.split(","),r.percent(e,s[0]),2===s.length&&r.alt("positionAlign",s[1],["start","middle","end"]);break;case"size":r.percent(e,t);break;case"align":r.alt(e,t,["start","middle","end","left","right"])}}),/:/,/\s/),t.region=r.get("region",null),t.vertical=r.get("vertical",""),t.line=r.get("line","auto"),t.lineAlign=r.get("lineAlign","start"),t.snapToLines=r.get("snapToLines",!0),t.size=r.get("size",100),t.align=r.get("align","middle"),t.position=r.get("position","auto"),t.positionAlign=r.get("positionAlign",{start:"start",left:"start",middle:"middle",end:"end",right:"end"},t.align)}(e,t)}a.prototype=s(Error.prototype),a.prototype.constructor=a,a.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}},l.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,n){return n?this.has(e)?this.values[e]:t[n]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,n){for(var r=0;r<n.length;++r)if(t===n[r]){this.set(e,t);break}},integer:function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},percent:function(e,t){return!!(t.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(t=parseFloat(t))>=0&&t<=100)&&(this.set(e,t),!0)}};var h={"&amp;":"&","&lt;":"<","&gt;":">","&lrm;":"‎","&rlm;":"‏","&nbsp;":" "},d={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},f={v:"title",lang:"lang"},p={rt:"ruby"};function g(e,t){function n(){if(!t)return null;var e,n=t.match(/^([^<]*)(<[^>]+>?)?/);return e=n[1]?n[1]:n[2],t=t.substr(e.length),e}function r(e){return h[e]}function i(e){for(;b=e.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)e=e.replace(b[0],r);return e}function s(e,t){return!p[t.localName]||p[t.localName]===e.localName}function a(t,n){var r=d[t];if(!r)return null;var i=e.document.createElement(r);i.localName=r;var s=f[t];return s&&n&&(i[s]=n.trim()),i}for(var l,c=e.document.createElement("div"),u=c,g=[];null!==(l=n());)if("<"!==l[0])u.appendChild(e.document.createTextNode(i(l)));else{if("/"===l[1]){g.length&&g[g.length-1]===l.substr(2).replace(">","")&&(g.pop(),u=u.parentNode);continue}var m,y=o(l.substr(1,l.length-2));if(y){m=e.document.createProcessingInstruction("timestamp",y),u.appendChild(m);continue}var b=l.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!b)continue;if(!(m=a(b[1],b[3])))continue;if(!s(u,m))continue;b[2]&&(m.className=b[2].substr(1).replace("."," ")),g.push(b[1]),u.appendChild(m),u=m}return c}var m=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function y(e){for(var t=0;t<m.length;t++){var n=m[t];if(e>=n[0]&&e<=n[1])return!0}return!1}function b(){}function v(e,t,n){var r="undefined"!=typeof navigator&&/MSIE\s8\.0/.test(navigator.userAgent),s="rgba(255, 255, 255, 1)",a="rgba(0, 0, 0, 0.8)",o="";void 0!==i&&(s=i.fontSet,a=i.backgroundSet,o=i.edgeSet),r&&(s="rgb(255, 255, 255)",a="rgb(0, 0, 0)"),b.call(this),this.cue=t,this.cueDiv=g(e,t.text);var l={color:s,backgroundColor:a,textShadow:o,position:"relative",left:0,right:0,top:0,bottom:0,display:"inline"};r||(l.writingMode=""===t.vertical?"horizontal-tb":"lr"===t.vertical?"vertical-lr":"vertical-rl",l.unicodeBidi="plaintext"),this.applyStyles(l,this.cueDiv),this.div=e.document.createElement("div"),l={textAlign:"middle"===t.align?"center":t.align,font:n.font,whiteSpace:"pre-line",position:"absolute"},r||(l.direction=function(e){var t=[],n="";if(!e||!e.childNodes)return"ltr";function r(e,t){for(var n=t.childNodes.length-1;n>=0;n--)e.push(t.childNodes[n])}function i(e){if(!e||!e.length)return null;var t=e.pop(),n=t.textContent||t.innerText;if(n){var s=n.match(/^.*(\n|\r)/);return s?(e.length=0,s[0]):n}return"ruby"===t.tagName?i(e):t.childNodes?(r(e,t),i(e)):void 0}for(r(t,e);n=i(t);)for(var s=0;s<n.length;s++)if(y(n.charCodeAt(s)))return"rtl";return"ltr"}(this.cueDiv),l.writingMode=""===t.vertical?"horizontal-tb":"lr"===t.vertical?"vertical-lr":"vertical-rl".stylesunicodeBidi="plaintext"),this.applyStyles(l),this.div.appendChild(this.cueDiv);var c=0;switch(t.positionAlign){case"start":c=t.position;break;case"middle":c=t.position-t.size/2;break;case"end":c=t.position-t.size}""===t.vertical?this.applyStyles({left:this.formatStyle(c,"%"),width:this.formatStyle(t.size,"%")}):this.applyStyles({top:this.formatStyle(c,"%"),height:this.formatStyle(t.size,"%")}),this.move=function(e){this.applyStyles({top:this.formatStyle(e.top,"px"),bottom:this.formatStyle(e.bottom,"px"),left:this.formatStyle(e.left,"px"),right:this.formatStyle(e.right,"px"),height:this.formatStyle(e.height,"px"),width:this.formatStyle(e.width,"px")})}}function w(e){var t,n,r,i,s="undefined"!=typeof navigator&&/MSIE\s8\.0/.test(navigator.userAgent);if(e.div){n=e.div.offsetHeight,r=e.div.offsetWidth,i=e.div.offsetTop;var a=(a=e.div.childNodes)&&(a=a[0])&&a.getClientRects&&a.getClientRects();e=e.div.getBoundingClientRect(),t=a?Math.max(a[0]&&a[0].height||0,e.height/a.length):0}this.left=e.left,this.right=e.right,this.top=e.top||i,this.height=e.height||n,this.bottom=e.bottom||i+(e.height||n),this.width=e.width||r,this.lineHeight=void 0!==t?t:e.lineHeight,s&&!this.lineHeight&&(this.lineHeight=13)}function S(e,t,n,r){var i=new w(t),s=t.cue,a=function(e){if("number"==typeof e.line&&(e.snapToLines||e.line>=0&&e.line<=100))return e.line;if(!e.track||!e.track.textTrackList||!e.track.textTrackList.mediaElement)return-1;for(var t=e.track,n=t.textTrackList,r=0,i=0;i<n.length&&n[i]!==t;i++)"showing"===n[i].mode&&r++;return-1*++r}(s),o=[];if(s.snapToLines){var l;switch(s.vertical){case"":o=["+y","-y"],l="height";break;case"rl":o=["+x","-x"],l="width";break;case"lr":o=["-x","+x"],l="width"}var c=i.lineHeight,u=c*Math.round(a),h=n[l]+c,d=o[0];Math.abs(u)>h&&(u=u<0?-1:1,u*=Math.ceil(h/c)*c),a<0&&(u+=""===s.vertical?n.height:n.width,o=o.reverse()),i.move(d,u)}else{var f=i.lineHeight/n.height*100;switch(s.lineAlign){case"middle":a-=f/2;break;case"end":a-=f}switch(s.vertical){case"":t.applyStyles({top:t.formatStyle(a,"%")});break;case"rl":t.applyStyles({left:t.formatStyle(a,"%")});break;case"lr":t.applyStyles({right:t.formatStyle(a,"%")})}o=["+y","-x","+x","-y"],i=new w(t)}var p=function(e,t){for(var i,s=new w(e),a=1,o=0;o<t.length;o++){for(;e.overlapsOppositeAxis(n,t[o])||e.within(n)&&e.overlapsAny(r);)e.move(t[o]);if(e.within(n))return e;var l=e.intersectPercentage(n);a>l&&(i=new w(e),a=l),e=new w(s)}return i||s}(i,o);t.move(p.toCSSCompatValues(n))}function E(){}b.prototype.applyStyles=function(e,t){for(var n in t=t||this.div,e)e.hasOwnProperty(n)&&(t.style[n]=e[n])},b.prototype.formatStyle=function(e,t){return 0===e?0:e+t},v.prototype=s(b.prototype),v.prototype.constructor=v,w.prototype.move=function(e,t){switch(t=void 0!==t?t:this.lineHeight,e){case"+x":this.left+=t,this.right+=t;break;case"-x":this.left-=t,this.right-=t;break;case"+y":this.top+=t,this.bottom+=t;break;case"-y":this.top-=t,this.bottom-=t}},w.prototype.overlaps=function(e){return this.left<e.right&&this.right>e.left&&this.top<e.bottom&&this.bottom>e.top},w.prototype.overlapsAny=function(e){for(var t=0;t<e.length;t++)if(this.overlaps(e[t]))return!0;return!1},w.prototype.within=function(e){return this.top>=e.top&&this.bottom<=e.bottom&&this.left>=e.left&&this.right<=e.right},w.prototype.overlapsOppositeAxis=function(e,t){switch(t){case"+x":return this.left<e.left;case"-x":return this.right>e.right;case"+y":return this.top<e.top;case"-y":return this.bottom>e.bottom}},w.prototype.intersectPercentage=function(e){return Math.max(0,Math.min(this.right,e.right)-Math.max(this.left,e.left))*Math.max(0,Math.min(this.bottom,e.bottom)-Math.max(this.top,e.top))/(this.height*this.width)},w.prototype.toCSSCompatValues=function(e){return{top:this.top-e.top,bottom:e.bottom-this.bottom,left:this.left-e.left,right:e.right-this.right,height:this.height,width:this.width}},w.getSimpleBoxPosition=function(e){var t=e.div?e.div.offsetHeight:e.tagName?e.offsetHeight:0,n=e.div?e.div.offsetWidth:e.tagName?e.offsetWidth:0,r=e.div?e.div.offsetTop:e.tagName?e.offsetTop:0;return{left:(e=e.div?e.div.getBoundingClientRect():e.tagName?e.getBoundingClientRect():e).left,right:e.right,top:e.top||r,height:e.height||t,bottom:e.bottom||r+(e.height||t),width:e.width||n}},E.StringDecoder=function(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}},E.convertCueToDOMTree=function(e,t){return e&&t?g(e,t):null},E.processCues=function(e,t,r){if(!e||!t||!r)return null;for(;r.firstChild;)r.removeChild(r.firstChild);var i=e.document.createElement("div");if(i.style.position="absolute",i.style.left="0",i.style.right="0",i.style.top="0",i.style.bottom="0",i.style.margin="1.5%",r.appendChild(i),function(e){for(var t=0;t<e.length;t++)if(e[t].hasBeenReset||!e[t].displayState)return!0;return!1}(t)){var s=[],a=w.getSimpleBoxPosition(i),o={font:Math.round(.05*a.height*100)/100*n+"px sans-serif"};!function(){for(var n,r,l=0;l<t.length;l++)r=t[l],n=new v(e,r,o),i.appendChild(n.div),S(0,n,a,s),r.displayState=n.div,s.push(w.getSimpleBoxPosition(n))}()}else for(var l=0;l<t.length;l++)i.appendChild(t[l].displayState)},E.Parser=function(e,t){this.window=e,this.state="INITIAL",this.buffer="",this.decoder=t||new TextDecoder("utf8"),this.regionList=[]},E.Parser.prototype={reportOrThrowError:function(e){if(!(e instanceof a))throw e;this.onparsingerror&&this.onparsingerror(e)},parse:function(e){var t=this;function n(){for(var e=t.buffer,n=0;n<e.length&&"\r"!==e[n]&&"\n"!==e[n];)++n;var r=e.substr(0,n);return"\r"===e[n]&&++n,"\n"===e[n]&&++n,t.buffer=e.substr(n),r}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var r;if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var i=(r=n()).match(/^WEBVTT([ \t].*)?$/);if(!i||!i[0])throw new a(a.Errors.BadSignature);t.state="HEADER"}for(var s=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(s?s=!1:r=n(),t.state){case"HEADER":/:/.test(r)?c(r,(function(e,n){"Region"===e&&function(e){var n=new l;if(c(e,(function(e,t){switch(e){case"id":n.set(e,t);break;case"width":n.percent(e,t);break;case"lines":n.integer(e,t);break;case"regionanchor":case"viewportanchor":var r=t.split(",");if(2!==r.length)break;var i=new l;if(i.percent("x",r[0]),i.percent("y",r[1]),!i.has("x")||!i.has("y"))break;n.set(e+"X",i.get("x")),n.set(e+"Y",i.get("y"));break;case"scroll":n.alt(e,t,["up"])}}),/=/,/\s/),n.has("id")){var r=new t.window.VTTRegion;r.width=n.get("width",100),r.lines=n.get("lines",3),r.regionAnchorX=n.get("regionanchorX",0),r.regionAnchorY=n.get("regionanchorY",100),r.viewportAnchorX=n.get("viewportanchorX",0),r.viewportAnchorY=n.get("viewportanchorY",100),r.scroll=n.get("scroll",""),t.onregion&&t.onregion(r),t.regionList.push({id:n.get("id"),region:r})}}(n)}),/:/):r||(t.state="ID");continue;case"NOTE":r||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(r)){t.state="NOTE";break}if(!r)continue;if(t.cue=new t.window.VTTCue(0,0,""),t.state="CUE",-1===r.indexOf("--\x3e")){t.cue.id=r;continue}case"CUE":try{u(r,t.cue,t.regionList)}catch(e){t.reportOrThrowError(e),t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var o=-1!==r.indexOf("--\x3e");if(!r||o&&(s=!0)){t.oncue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}t.cue.text&&(t.cue.text+="\n"),t.cue.text+=r;continue;case"BADCUE":r||(t.state="ID");continue}}}catch(e){t.reportOrThrowError(e),"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this},flush:function(){var e=this;try{if(e.buffer+=e.decoder.decode(),(e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state)throw new a(a.Errors.BadSignature)}catch(t){e.reportOrThrowError(t)}return e.onflush&&e.onflush(),this}},e.WebVTT=E}(this)},4747:function(e,t,n){var r;e.exports&&(this.VTTCue=this.VTTCue||n(1300).VTTCue),(r=this).VTTCue.prototype.toJSON=function(){var e={},t=this;return Object.keys(this).forEach((function(n){"getCueAsHTML"!==n&&"hasBeenReset"!==n&&"displayState"!==n&&(e[n]=t[n])})),e},r.VTTCue.create=function(e){if(!e.hasOwnProperty("startTime")||!e.hasOwnProperty("endTime")||!e.hasOwnProperty("text"))throw new Error("You must at least have start time, end time, and text.");var t=new r.VTTCue(e.startTime,e.endTime,e.text);for(var n in e)t.hasOwnProperty(n)&&(t[n]=e[n]);return t},r.VTTCue.fromJSON=function(e){return this.create(JSON.parse(e))}},1300:function(){!function(e){var t={"":!0,lr:!0,rl:!0},n={start:!0,middle:!0,end:!0,left:!0,right:!0};function r(e){return"string"==typeof e&&!!n[e.toLowerCase()]&&e.toLowerCase()}function i(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}function s(e,n,s){var a=this,o=/MSIE\s8\.0/.test(navigator.userAgent),l={};o?a=document.createElement("custom"):l.enumerable=!0,a.hasBeenReset=!1;var c="",u=!1,h=e,d=n,f=s,p=null,g="",m=!0,y="auto",b="start",v=50,w="middle",S=50,E="middle";if(Object.defineProperty(a,"id",i({},l,{get:function(){return c},set:function(e){c=""+e}})),Object.defineProperty(a,"pauseOnExit",i({},l,{get:function(){return u},set:function(e){u=!!e}})),Object.defineProperty(a,"startTime",i({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"endTime",i({},l,{get:function(){return d},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");d=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"text",i({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),Object.defineProperty(a,"region",i({},l,{get:function(){return p},set:function(e){p=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"vertical",i({},l,{get:function(){return g},set:function(e){var n=function(e){return"string"==typeof e&&!!t[e.toLowerCase()]&&e.toLowerCase()}(e);if(!1===n)throw new SyntaxError("An invalid or illegal string was specified.");g=n,this.hasBeenReset=!0}})),Object.defineProperty(a,"snapToLines",i({},l,{get:function(){return m},set:function(e){m=!!e,this.hasBeenReset=!0}})),Object.defineProperty(a,"line",i({},l,{get:function(){return y},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"lineAlign",i({},l,{get:function(){return b},set:function(e){var t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");b=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"position",i({},l,{get:function(){return v},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"positionAlign",i({},l,{get:function(){return w},set:function(e){var t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");w=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"size",i({},l,{get:function(){return S},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");S=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"align",i({},l,{get:function(){return E},set:function(e){var t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),a.displayState=void 0,o)return a}s.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)},e.VTTCue=e.VTTCue||s}(this)},1271:function(e,t,n){var r;e.exports&&(this.VTTRegion=n(8591).VTTRegion),(r=this).VTTRegion.create=function(e){var t=new r.VTTRegion;for(var n in e)t.hasOwnProperty(n)&&(t[n]=e[n]);return t},r.VTTRegion.fromJSON=function(e){return this.create(JSON.parse(e))}},8591:function(){!function(e){var t={"":!0,up:!0};function n(e){return"number"==typeof e&&e>=0&&e<=100}e.VTTRegion=e.VTTRegion||function(){var e=100,r=3,i=0,s=100,a=0,o=100,l="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return e},set:function(t){if(!n(t))throw new Error("Width must be between 0 and 100.");e=t}},lines:{enumerable:!0,get:function(){return r},set:function(e){if("number"!=typeof e)throw new TypeError("Lines must be set to a number.");r=e}},regionAnchorY:{enumerable:!0,get:function(){return s},set:function(e){if(!n(e))throw new Error("RegionAnchorX must be between 0 and 100.");s=e}},regionAnchorX:{enumerable:!0,get:function(){return i},set:function(e){if(!n(e))throw new Error("RegionAnchorY must be between 0 and 100.");i=e}},viewportAnchorY:{enumerable:!0,get:function(){return o},set:function(e){if(!n(e))throw new Error("ViewportAnchorY must be between 0 and 100.");o=e}},viewportAnchorX:{enumerable:!0,get:function(){return a},set:function(e){if(!n(e))throw new Error("ViewportAnchorX must be between 0 and 100.");a=e}},scroll:{enumerable:!0,get:function(){return l},set:function(e){var n=function(e){return"string"==typeof e&&!!t[e.toLowerCase()]&&e.toLowerCase()}(e);if(!1===n)throw new SyntaxError("An invalid or illegal string was specified.");l=n}}})}}(this)},6553:()=>{}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(s.exports,s,s.exports,n),s.loaded=!0,s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";var e;function t(t,n,r,s){let a=n;for(let o=n;o>=0&&(a=o,!i(t,a,n,r,s,e.backward));--o);let o=a;for(let a=n;a<=t.length-1&&(o=a,!i(t,o,n,r,s,e.forward));++a);return t.slice(a,o+1)}function r(t,n,r){if(r===e.forward){for(let e=0;e<t.length;++e)if(t[e].start>=n)return e}else for(let e=t.length-1;e>=0;--e)if(t[e].start<=n)return e}function i(t,n,r,i,s,a){let o;return o=a==e.forward?n+1<t.length?t[n+1]:null:n-1>=0?t[n-1]:null,Math.abs(r-n)>=i&&(null===o||Math.abs(o.start-t[r].start)>=s)}function s(e,t,n,r,i,s){const a=e[t];return Math.abs(s-t)<=n||Math.abs(a.start-i)<=r}function a(e){const t=e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,((e,t)=>(t?"-":"")+e.toLowerCase()));return t.startsWith("webkit-")||t.startsWith("moz-")||t.startsWith("ms-")||t.startsWith("o-")?`-${t}`:t}function o(e){const t=function({subtitleColor:e,subtitleSize:t,subtitleThickness:n,subtitleOutlineThickness:r,subtitleOutlineColor:i,subtitleShadowThickness:s,subtitleShadowColor:a,subtitleBackgroundOpacity:o,subtitleBackgroundColor:l,subtitleFontFamily:c,subtitleCustomStyles:u}){const h={color:e,fontSize:`${t}px`,fontWeight:String(n)};if(r>0){const e=r,t=i;h.WebkitTextStroke=`${t} ${e}px`}if(s>0&&(h.textShadow=`0 0 ${s}px ${a}, 0 0 ${s}px ${a}, 0 0 ${s}px ${a}, 0 0 ${s}px ${a}`),o>0){const e=o,t=l,{r:n,g:r,b:i}=(d=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t))?{r:parseInt(d[1],16),g:parseInt(d[2],16),b:parseInt(d[3],16)}:{r:255,g:255,b:255};h.backgroundColor=`rgba(${n}, ${r}, ${i}, ${e})`}var d;c&&c.length>0&&(h.fontFamily=c);for(const e of u){let t;t=e.key.startsWith("webkit")||e.key.startsWith("moz")||e.key.startsWith("ms")||/^o[A-Z].*/.test(e.key)?e.key.charAt(0).toUpperCase()+e.key.slice(1):e.key,h[t]=e.value}return h}(e),n=[];for(const[e,r]of Object.entries(t))n.push(`${a(e)}: ${r} !important`);return n.join(";")}function l(e,t){return 0===t?e:`${e} (${function(e,t=!1){const n=Math.floor(e/1e3);let r;r=t?Math.round(e/1e3%60*10)/10:n%60;const i=Math.floor(n/60)%60,s=Math.floor(n/3600);return s>0?s+"h"+String(i).padStart(2,"0")+"m"+String(r).padStart(2,"0")+"s":i+"m"+String(r).padStart(2,"0")+"s"}(t)})`}n(2565),function(e){e[e.forward=0]="forward",e[e.backward=1]="backward"}(e||(e={}));const c=async(e,t,n,r)=>new Promise(((i,s)=>{const a=new Image;a.onload=async()=>{const r=document.createElement("canvas"),o=window.devicePixelRatio,l=n.width*o,c=n.height*o;r.width=l,r.height=c;const u=r.getContext("2d");if(u.drawImage(a,n.left*o,n.top*o,l,c,0,0,l,c),e>0||t>0)try{await((e,t,n,r)=>new Promise(((i,s)=>{const a=n<=0?1:n/e.width,o=r<=0?1:r/e.height,l=Math.min(1,Math.min(a,o));if(l<1){const n=e.width*l,r=e.height*l;createImageBitmap(e,{resizeWidth:n,resizeHeight:r,resizeQuality:"high"}).then((s=>{e.width=n,e.height=r,t.drawImage(s,0,0),i(e)})).catch((e=>s(e)))}else i(e)})))(r,u,e,t),i(r.toDataURL("image/jpeg"))}catch(e){console.error("Failed to crop and resize image: "+e),s(e)}else i(r.toDataURL("image/jpeg"))},a.src=r}));var u,h,d;!function(e){e[e.none=0]="none",e[e.showAnkiDialog=1]="showAnkiDialog",e[e.updateLastCard=2]="updateLastCard"}(u||(u={})),function(e){e[e.atStart=1]="atStart",e[e.atEnd=2]="atEnd"}(h||(h={})),function(e){e[e.normal=1]="normal",e[e.condensed=2]="condensed",e[e.autoPause=3]="autoPause",e[e.fastForward=4]="fastForward"}(d||(d={}));class f{willStopShowing(e){e.end!==this.lastWillStopShowing?.end&&(this.onWillStopShowing?.(),this.lastWillStopShowing=e)}startedShowing(e){e.start!==this.lastStartedShowing?.start&&(this.onStartedShowing?.(),this.lastStartedShowing=e)}clear(){this.lastStartedShowing=void 0,this.lastWillStopShowing=void 0}}class p{constructor(){this._cachedContentElements={},this._empty=!0}get empty(){return this._empty}clear(){this.offscreenElement?.remove(),this.offscreenElement=void 0,this._cachedContentElements={},this._empty=!0}add(e,t){const n=document.createElement("div");n.innerHTML=`${t}\n`,this._cachedContentElements[e]=n,this._offscreenElement().appendChild(n),this._empty=!1}return(e){this._offscreenElement().appendChild(e)}get(e,t){let n=this._cachedContentElements[e];if(!n){if(void 0===t)throw new Error(`Cached html not found for key ${e}`);n=document.createElement("div"),n.innerHTML=t(),this._cachedContentElements[e]=n,this._offscreenElement().appendChild(n)}return n}_offscreenElement(){if(this.offscreenElement)return this.offscreenElement;const e=document.createElement("div");return e.className="asbplayer-offscreen",document.body.append(e),this.offscreenElement=e,e}}const g=Object.keys({ankiConnectUrl:!0,deck:!0,noteType:!0,sentenceField:!0,definitionField:!0,audioField:!0,imageField:!0,wordField:!0,sourceField:!0,urlField:!0,customAnkiFields:!0,tags:!0,preferMp3:!0,audioPaddingStart:!0,audioPaddingEnd:!0,maxImageWidth:!0,maxImageHeight:!0,surroundingSubtitlesCountRadius:!0,surroundingSubtitlesTimeRadius:!0});var m;!function(e){e.noSubtitleList="noSubtitleList",e.app="app"}(m||(m={}));const y=(navigator.userAgentData?.platform??navigator.platform)?.toUpperCase()?.indexOf("MAC")>-1,b={ankiConnectUrl:"http://127.0.0.1:8765",deck:"",noteType:"",sentenceField:"",definitionField:"",audioField:"",imageField:"",wordField:"",sourceField:"",urlField:"",subtitleSize:36,subtitleColor:"#ffffff",subtitleThickness:700,subtitleOutlineThickness:0,subtitleOutlineColor:"#000000",subtitleShadowThickness:2,subtitleShadowColor:"#000000",subtitleBackgroundColor:"#000000",subtitleBackgroundOpacity:.5,subtitleFontFamily:"",subtitlePreview:"アあ安Aa",subtitlePositionOffset:75,subtitleAlignment:"bottom",audioPaddingStart:0,audioPaddingEnd:500,maxImageWidth:0,maxImageHeight:0,surroundingSubtitlesCountRadius:2,surroundingSubtitlesTimeRadius:1e4,autoPausePreference:h.atEnd,fastForwardModePlaybackRate:2.7,keyBindSet:{togglePlay:{keys:"space"},toggleAutoPause:{keys:y?"⇧+P":"shift+P"},toggleCondensedPlayback:{keys:y?"⇧+O":"shift+O"},toggleFastForwardPlayback:{keys:y?"⇧+F":"shift+F"},toggleSubtitles:{keys:"down"},toggleVideoSubtitleTrack1:{keys:"1"},toggleVideoSubtitleTrack2:{keys:"2"},toggleVideoSubtitleTrack3:{keys:"3"},toggleAsbplayerSubtitleTrack1:{keys:"W+1"},toggleAsbplayerSubtitleTrack2:{keys:"W+2"},toggleAsbplayerSubtitleTrack3:{keys:"W+3"},seekBackward:{keys:"A"},seekForward:{keys:"D"},seekToPreviousSubtitle:{keys:"left"},seekToNextSubtitle:{keys:"right"},seekToBeginningOfCurrentSubtitle:{keys:"up"},adjustOffsetToPreviousSubtitle:{keys:y?"⇧+left":"ctrl+left"},adjustOffsetToNextSubtitle:{keys:y?"⇧+right":"ctrl+right"},decreaseOffset:{keys:y?"⇧+⌃+right":"ctrl+shift+right"},increaseOffset:{keys:y?"⇧+⌃+left":"ctrl+shift+left"},resetOffset:{keys:y?"⇧+⌃+down":"ctrl+shift+down"},copySubtitle:{keys:y?"⇧+⌃+Z":"ctrl+shift+Z"},ankiExport:{keys:y?"⇧+⌃+X":"ctrl+shift+X"},updateLastCard:{keys:y?"⇧+⌃+U":"ctrl+shift+U"},takeScreenshot:{keys:y?"⇧+⌃+V":"ctrl+shift+V"},decreasePlaybackRate:{keys:y?"⇧+⌃+[":"ctrl+shift+["},increasePlaybackRate:{keys:y?"⇧+⌃+]":"ctrl+shift+]"},toggleSidePanel:{keys:"`"}},preferMp3:!0,miningHistoryStorageLimit:25,preCacheSubtitleDom:!0,clickToMineDefaultAction:u.showAnkiDialog,themeType:"dark",copyToClipboardOnMine:!1,rememberSubtitleOffset:!0,lastSubtitleOffset:0,autoCopyCurrentSubtitle:!1,subtitleRegexFilter:"",subtitleRegexFilterTextReplacement:"",language:"en",customAnkiFields:{},tags:[],imageBasedSubtitleScaleFactor:1,subtitleCustomStyles:[],streamingAppUrl:"https://killergerbah.github.io/asbplayer",streamingDisplaySubtitles:!0,streamingRecordMedia:!0,streamingTakeScreenshot:!0,streamingCleanScreenshot:!0,streamingCropScreenshot:!0,streamingSubsDragAndDrop:!0,streamingAutoSync:!1,streamingLastLanguagesSynced:{},streamingCondensedPlaybackMinimumSkipIntervalMs:1e3,streamingScreenshotDelay:1e3,streamingSubtitleListPreference:m.noSubtitleList};Object.fromEntries(Object.entries(b).map((([e,t])=>{if("string"==typeof t)return[e,e=>e];if("boolean"==typeof t)return[e,e=>"true"===e];if("number"==typeof t)return[e,e=>Number(e)];if("keyBindSet"===e)return[e,e=>{const t=JSON.parse(e);for(const e of Object.keys(b.keyBindSet)){const n=e;void 0===t[n]&&(t[n]=b.keyBindSet[n])}return t}];if("object"==typeof t)return[e,e=>JSON.parse(e)];throw new Error("Could not determine deserializer for setting")})));class v{constructor(e){this._storage=e}async getAll(){return this.get(Object.keys(b))}async getSingle(e){return(await this.get([e]))[e]}async get(e){let t={};for(const n of e)t[n]=b[n];const n=await this._storage.get(t),r={};for(const e in t)r[e]=n[e]??b[e];return r}async set(e){await this._storage.set(e)}}n(4445);const w=["en","es","de","ja","pl","pt_BR","zh_CN"];function S(e){const t=e.toLowerCase().trim().split(/\s*;\s*/);return"banner"===t[0]?{name:t[0],delay:1*t[1]||0,leftToRight:1*t[2]||0,fadeAwayWidth:1*t[3]||0}:/^scroll\s/.test(t[0])?{name:t[0],y1:Math.min(1*t[1],1*t[2]),y2:Math.max(1*t[1],1*t[2]),delay:1*t[3]||0,fadeAwayHeight:1*t[4]||0}:null}function E(e){return e?e.toLowerCase().replace(/([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)/g," $1 ").replace(/([mnlbspc])/g," $1 ").trim().replace(/\s+/g," ").split(/\s(?=[mnlbspc])/).map((e=>e.split(" ").filter(((e,t)=>!(t&&Number.isNaN(1*e)))))):[]}const x=["b","i","u","s","fsp","k","K","kf","ko","kt","fe","q","p","pbo","a","an","fscx","fscy","fax","fay","frx","fry","frz","fr","be","blur","bord","xbord","ybord","shad","xshad","yshad"].map((e=>({name:e,regex:new RegExp(`^${e}-?\\d`)})));function k(e){const t={};for(let n=0;n<x.length;n++){const{name:r,regex:i}=x[n];if(i.test(e))return t[r]=1*e.slice(r.length),t}if(/^fn/.test(e))t.fn=e.slice(2);else if(/^r/.test(e))t.r=e.slice(1);else if(/^fs[\d+-]/.test(e))t.fs=e.slice(2);else if(/^\d?c&?H?[0-9a-f]+|^\d?c$/i.test(e)){const[,n,r]=e.match(/^(\d?)c&?H?(\w*)/);t[`c${n||1}`]=r&&`000000${r}`.slice(-6)}else if(/^\da&?H?[0-9a-f]+/i.test(e)){const[,n,r]=e.match(/^(\d)a&?H?(\w\w)/);t[`a${n}`]=r}else if(/^alpha&?H?[0-9a-f]+/i.test(e))[,t.alpha]=e.match(/^alpha&?H?([0-9a-f]+)/i),t.alpha=`00${t.alpha}`.slice(-2);else if(/^(?:pos|org|move|fad|fade)\(/.test(e)){const[,n,r]=e.match(/^(\w+)\((.*?)\)?$/);t[n]=r.trim().split(/\s*,\s*/).map(Number)}else if(/^i?clip/.test(e)){const n=e.match(/^i?clip\((.*?)\)?$/)[1].trim().split(/\s*,\s*/);t.clip={inverse:/iclip/.test(e),scale:1,drawing:null,dots:null},1===n.length&&(t.clip.drawing=E(n[0])),2===n.length&&(t.clip.scale=1*n[0],t.clip.drawing=E(n[1])),4===n.length&&(t.clip.dots=n.map(Number))}else if(/^t\(/.test(e)){const n=e.match(/^t\((.*?)\)?$/)[1].trim().replace(/\\.*/,(e=>e.replace(/,/g,"\n"))).split(/\s*,\s*/);if(!n[0])return t;t.t={t1:0,t2:0,accel:1,tags:n[n.length-1].replace(/\n/g,",").split("\\").slice(1).map(k)},2===n.length&&(t.t.accel=1*n[0]),3===n.length&&(t.t.t1=1*n[0],t.t.t2=1*n[1]),4===n.length&&(t.t.t1=1*n[0],t.t.t2=1*n[1],t.t.accel=1*n[2])}return t}function O(e){const t=[];let n=0,r="";for(let i=0;i<e.length;i++){const s=e[i];"("===s&&n++,")"===s&&n--,n<0&&(n=0),n||"\\"!==s?r+=s:(r&&t.push(r),r="")}return t.push(r),t.map(k)}function _(e){const t=e.split(/{([^{}]*?)}/),n=[];t[0].length&&n.push({tags:[],text:t[0],drawing:[]});for(let e=1;e<t.length;e+=2){const r=O(t[e]),i=r.reduce(((e,t)=>void 0===t.p?e:!!t.p),!1);n.push({tags:r,text:i?"":t[e+1],drawing:i?E(t[e+1]):[]})}return{raw:e,combined:n.map((e=>e.text)).join(""),parsed:n}}function C(e){const t=e.split(":");return 3600*t[0]+60*t[1]+1*t[2]}function T(e,t){let n=e.split(",");if(n.length>t.length){const e=n.slice(t.length-1).join();n=n.slice(0,t.length-1),n.push(e)}const r={};for(let e=0;e<n.length;e++){const i=t[e],s=n[e].trim();switch(i){case"Layer":case"MarginL":case"MarginR":case"MarginV":r[i]=1*s;break;case"Start":case"End":r[i]=C(s);break;case"Effect":r[i]=S(s);break;case"Text":r[i]=_(s);break;default:r[i]=s}}return r}function A(e){return e.match(/Format\s*:\s*(.*)/i)[1].split(/\s*,\s*/)}const P=Object.assign||function(e,...t){for(let n=0;n<t.length;n++){if(!t[n])continue;const r=Object.keys(t[n]);for(let i=0;i<r.length;i++)e[r[i]]=t[n][r[i]]}return e};function F(e,t){const n=e.match(/Style\s*:\s*(.*)/i)[1].split(/\s*,\s*/);return P({},...t.map(((e,t)=>({[e]:n[t]}))))}function N(e){const t={type:null,prev:null,next:null,points:[]};/[mnlbs]/.test(e[0])&&(t.type=e[0].toUpperCase().replace("N","L").replace("B","C"));for(let n=e.length-!(1&e.length),r=1;r<n;r+=2)t.points.push({x:1*e[r],y:1*e[r+1]});return t}function L(e){return!(!e.points.length||!e.type||/C|S/.test(e.type)&&e.points.length<3)}function R(e){return e.map((({type:e,points:t})=>e+t.map((({x:e,y:t})=>`${e},${t}`)).join(","))).join("")}function I(e){const t=[];let n=0;for(;n<e.length;){const r=e[n],i=N(r);if(L(i)){if("S"===i.type){const{x:e,y:r}=(t[n-1]||{points:[{x:0,y:0}]}).points.slice(-1)[0];i.points.unshift({x:e,y:r})}n&&(i.prev=t[n-1].type,t[n-1].next=i.type),t.push(i),n++}else{if(n&&"S"===t[n-1].type){const e={p:i.points,c:t[n-1].points.slice(0,3)};t[n-1].points=t[n-1].points.concat((e[r[0]]||[]).map((({x:e,y:t})=>({x:e,y:t}))))}e.splice(n,1)}}const r=[].concat(...t.map((({type:e,points:t,prev:n,next:r})=>"S"===e?function(e,t,n){const r=[],i=[0,2/3,1/3,0],s=[0,1/3,2/3,0],a=[0,1/6,2/3,1/6],o=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3];let l=[e[e.length-1].x,e[0].x,e[1].x,e[2].x],c=[e[e.length-1].y,e[0].y,e[1].y,e[2].y];r.push({type:"M"===t?"M":"L",points:[{x:o(a,l),y:o(a,c)}]});for(let t=3;t<e.length;t++)l=[e[t-3].x,e[t-2].x,e[t-1].x,e[t].x],c=[e[t-3].y,e[t-2].y,e[t-1].y,e[t].y],r.push({type:"C",points:[{x:o(i,l),y:o(i,c)},{x:o(s,l),y:o(s,c)},{x:o(a,l),y:o(a,c)}]});if("L"===n||"C"===n){const t=e[e.length-1];r.push({type:"L",points:[{x:t.x,y:t.y}]})}return r}(t,n,r):{type:e,points:t})));return P({instructions:r,d:R(r)},function(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;return[].concat(...e.map((({points:e})=>e))).forEach((({x:e,y:s})=>{t=Math.min(t,e),n=Math.min(n,s),r=Math.max(r,e),i=Math.max(i,s)})),{minX:t,minY:n,width:r-t,height:i-n}}(t))}const j=["fs","clip","c1","c2","c3","c4","a1","a2","a3","a4","alpha","fscx","fscy","fax","fay","frx","fry","frz","fr","be","blur","bord","xbord","ybord","shad","xshad","yshad"];function M(e,t,n={}){let r=e[t];if(void 0===r)return null;if("pos"===t||"org"===t)return 2===r.length?{[t]:{x:r[0],y:r[1]}}:null;if("move"===t){const[e,t,n,i,s=0,a=0]=r;return 4===r.length||6===r.length?{move:{x1:e,y1:t,x2:n,y2:i,t1:s,t2:a}}:null}if("fad"===t||"fade"===t){if(2===r.length){const[e,t]=r;return{fade:{type:"fad",t1:e,t2:t}}}if(7===r.length){const[e,t,n,i,s,a,o]=r;return{fade:{type:"fade",a1:e,a2:t,a3:n,t1:i,t2:s,t3:a,t4:o}}}return null}if("clip"===t){const{inverse:e,scale:t,drawing:n,dots:i}=r;if(n)return{clip:{inverse:e,scale:t,drawing:I(n),dots:i}};if(i){const[r,s,a,o]=i;return{clip:{inverse:e,scale:t,drawing:n,dots:{x1:r,y1:s,x2:a,y2:o}}}}return null}if(/^[xy]?(bord|shad)$/.test(t)&&(r=Math.max(r,0)),"bord"===t)return{xbord:r,ybord:r};if("shad"===t)return{xshad:r,yshad:r};if(/^c\d$/.test(t))return{[t]:r||n[t]};if("alpha"===t)return{a1:r,a2:r,a3:r,a4:r};if("fr"===t)return{frz:r};if("fs"===t)return{fs:/^\+|-/.test(r)?(1*r>-10?1+r/10:1)*n.fs:1*r};if("K"===t)return{kf:r};if("t"===t){const{t1:e,accel:t,tags:i}=r,s=r.t2||1e3*(n.end-n.start),a={};return i.forEach((e=>{const t=Object.keys(e)[0];~j.indexOf(t)&&("clip"!==t||e[t].dots)&&P(a,M(e,t,n))})),{t:{t1:e,t2:s,accel:t,tag:a}}}return{[t]:r}}const D=[null,1,2,3,null,7,8,9,null,4,5,6],$=["r","a","an","pos","org","move","fade","fad","clip"];function B({styles:e,style:t,parsed:n,start:r,end:i}){let s,a,o,l,c,u;const h=[];let d={style:t,fragments:[]},f={};for(let g=0;g<n.length;g++){const{tags:m,text:y,drawing:b}=n[g];let v;for(let e=0;e<m.length;e++){const t=m[e];v=void 0===t.r?v:t.r}const w={tag:void 0===v?(p=f,JSON.parse(JSON.stringify(P({},p,{k:void 0,kf:void 0,ko:void 0,kt:void 0})))):{},text:y,drawing:b.length?I(b):null};for(let n=0;n<m.length;n++){const h=m[n];s=s||D[h.a||0]||h.an,a=a||M(h,"pos"),o=o||M(h,"org"),l=l||M(h,"move"),c=c||M(h,"fade")||M(h,"fad"),u=M(h,"clip")||u;const d=Object.keys(h)[0];if(d&&!~$.indexOf(d)){const n=e[t].tag,{c1:s,c2:a,c3:o,c4:l}=n,c=M(h,d,{start:r,end:i,c1:s,c2:a,c3:o,c4:l,fs:f.fs||n.fs});"t"===d?(w.tag.t=w.tag.t||[],w.tag.t.push(c.t)):P(w.tag,c)}}if(f=w.tag,void 0!==v&&(h.push(d),d={style:e[v]?v:t,fragments:[]}),w.text||w.drawing){const e=d.fragments[d.fragments.length-1]||{};e.text&&w.text&&!Object.keys(w.tag).length?e.text+=w.text:d.fragments.push(w)}}var p;return h.push(d),P({alignment:s,slices:h},a,o,l,c,u)}function U({styles:e,dialogues:t}){let n=1/0;const r=[];for(let i=0;i<t.length;i++){const s=t[i];if(s.Start>=s.End)continue;e[s.Style]||(s.Style="Default");const a=e[s.Style].style,o=B({styles:e,style:s.Style,parsed:s.Text.parsed,start:s.Start,end:s.End}),l=o.alignment||a.Alignment;n=Math.min(n,s.Layer),r.push(P({layer:s.Layer,start:s.Start,end:s.End,style:s.Style,name:s.Name,margin:{left:s.MarginL||a.MarginL,right:s.MarginR||a.MarginR,vertical:s.MarginV||a.MarginV},effect:s.Effect},o,{alignment:l}))}for(let e=0;e<r.length;e++)r[e].layer-=n;return r.sort(((e,t)=>e.start-t.start||e.end-t.end))}const V={Name:"Default",Fontname:"Arial",Fontsize:"20",PrimaryColour:"&H00FFFFFF&",SecondaryColour:"&H000000FF&",OutlineColour:"&H00000000&",BackColour:"&H00000000&",Bold:"0",Italic:"0",Underline:"0",StrikeOut:"0",ScaleX:"100",ScaleY:"100",Spacing:"0",Angle:"0",BorderStyle:"1",Outline:"2",Shadow:"2",Alignment:"2",MarginL:"10",MarginR:"10",MarginV:"10",Encoding:"1"};function H(e){if(/^(&|H|&H)[0-9a-f]{6,}/i.test(e)){const[,t,n]=e.match(/&?H?([0-9a-f]{2})?([0-9a-f]{6})/i);return[t||"00",n]}const t=parseInt(e,10);if(!Number.isNaN(t)){const e=-2147483648;if(t<e)return["00","000000"];const n=e<=t&&t<=2147483647?`00000000${(t<0?t+4294967296:t).toString(16)}`.slice(-8):String(t).slice(0,8);return[n.slice(0,2),n.slice(2)]}return["00","000000"]}const z=class{endOfLine="\r\n";numericTimestamps=!1;constructor(e){null!=e&&(this.endOfLine=e.endOfLine??"\r\n",this.numericTimestamps=e.numericTimestamps??!1)}timestampToSeconds(e){const[t,n]=e.split(","),r=parseInt(n),[i,s,a]=t.split(":").map((e=>parseInt(e))),o=.001*r+a+60*s+3600*i;return Math.round(1e3*o)/1e3}secondsToTimestamp(e){const t=new Date(0,0,0,0,0,0,e),n=t.getHours(),r=t.getMinutes(),i=t.getSeconds(),s=Math.floor(e-(36e5*n+6e4*r+1e3*i));function a(e,t=2){return e.toString().padStart(t,"0")}return`${a(n)}:${a(r)}:${a(i)},${a(s,3)}`}correctFormat(e){const t=e.replace(".",","),[n,r]=t.split(","),i=this.fixedStrDigit(3,r),[s,a,o]=n.split(":");return`${this.fixedStrDigit(2,s,!1)}:${this.fixedStrDigit(2,a,!1)}:${this.fixedStrDigit(2,o,!1)},${i}`}fixedStrDigit(e,t,n=!0){return t.length===e?t:t.length>e?t.slice(0,e):n?t.padEnd(e,"0"):t.padStart(e,"0")}tryComma(e){const t=(e=e.replace(/\r/g,"")).split(/(\d+)\n(\d{1,2}:\d{2}:\d{2},\d{1,3}) --> (\d{1,2}:\d{2}:\d{2},\d{1,3})/g);return t.shift(),t}tryDot(e){const t=(e=e.replace(/\r/g,"")).split(/(\d+)\n(\d{1,2}:\d{2}:\d{2}\.\d{1,3}) --> (\d{1,2}:\d{2}:\d{2}\.\d{1,3})/g);return t.shift(),t}fromSrt(e){const t=e;let n=this.tryComma(t);0===n.length&&(n=this.tryDot(t));const r=[];for(let e=0;e<n.length;e+=4){let t=this.correctFormat(n[e+1].trim()),i=this.correctFormat(n[e+2].trim());this.numericTimestamps&&(t=this.timestampToSeconds(t),i=this.timestampToSeconds(i));const s={id:n[e].trim(),startTime:t,endTime:i,text:n[e+3].trim()};r.push(s)}return r}toSrt(e){const t=this.endOfLine;let n="";for(let r=0;r<e.length;r++){const i=e[r];let s=i.startTime,a=i.endTime;"number"==typeof s&&(s=this.secondsToTimestamp(s)),"number"==typeof a&&(a=this.secondsToTimestamp(a)),n+=i.id+t+s+" --\x3e "+a+t+i.text.replace("\n",t)+t+t}return n}};var q=n(462),W=n(9309);const Z=RegExp("</?([^>]*)>","ig"),X=RegExp(/\\[nN]/,"ig"),K=document.createElement("div");class G{constructor({regexFilter:e,regexFilterTextReplacement:t,pgsWorkerFactory:n}){let r;try{r=""===e.trim()?void 0:new RegExp(e,"g")}catch(e){r=void 0}this._textFilter=void 0===r?void 0:{regex:r,replacement:t},this._pgsWorkerFactory=n}async subtitles(e,t){return(await Promise.all(e.map(((e,n)=>this._subtitles(e,!0===t?0:n))))).flatMap((e=>e)).filter((e=>void 0!==e.textImage||""!==e.text)).sort(((e,t)=>e.start-t.start))}async _subtitles(e,t){if(e.name.endsWith(".srt"))return new z({numericTimestamps:!0}).fromSrt(await e.text()).map((e=>({start:Math.floor(1e3*e.startTime),end:Math.floor(1e3*e.endTime),text:this._filterText(e.text).replace(Z,""),track:t})));if(e.name.endsWith(".vtt")||e.name.endsWith(".nfvtt"))return new Promise((async(n,r)=>{const i=e.name.endsWith(".nfvtt"),s=new q.WebVTT.Parser(window,q.WebVTT.StringDecoder()),a=[];s.oncue=e=>{if(e.text=this._filterText(e.text).replace(Z,""),i){const t=e.text.split("\n"),n=[];for(const e of t)n.push(this._fixRTL(e));e.text=n.join("\n")}a.push(e)},s.onflush=()=>n(a.map((e=>({start:Math.floor(1e3*e.startTime),end:Math.floor(1e3*e.endTime),text:e.text,track:t})))),s.parse(await e.text()),s.flush()}));if(e.name.endsWith(".ass"))return function(e,t={}){const n=function(e){const t={info:{},styles:{format:[],style:[]},events:{format:[],comment:[],dialogue:[]}},n=e.split(/\r?\n/);let r=0;for(let e=0;e<n.length;e++){const i=n[e].trim();if(!/^;/.test(i)&&(/^\[Script Info\]/i.test(i)?r=1:/^\[V4\+? Styles\]/i.test(i)?r=2:/^\[Events\]/i.test(i)?r=3:/^\[.*\]/.test(i)&&(r=0),0!==r)){if(1===r&&/:/.test(i)){const[,e,n]=i.match(/(.*?)\s*:\s*(.*)/);t.info[e]=n}if(2===r&&(/^Format\s*:/i.test(i)&&(t.styles.format=A(i)),/^Style\s*:/i.test(i)&&t.styles.style.push(F(i,t.styles.format))),3===r&&(/^Format\s*:/i.test(i)&&(t.events.format=A(i)),/^(?:Comment|Dialogue)\s*:/i.test(i))){const[,e,n]=i.match(/^(\w+?)\s*:\s*(.*)/i);t.events[e.toLowerCase()].push(T(n,t.events.format))}}}return t}(e),r=function({info:e,style:t,defaultStyle:n}){const r={},i=[P({},V,n,{Name:"Default"})].concat(t);for(let t=0;t<i.length;t++){const n=i[t];/^(\*+)Default$/.test(n.Name)&&(n.Name="Default"),Object.keys(n).forEach((e=>{"Name"===e||"Fontname"===e||/Colour/.test(e)||(n[e]*=1)}));const[s,a]=H(n.PrimaryColour),[o,l]=H(n.SecondaryColour),[c,u]=H(n.OutlineColour),[h,d]=H(n.BackColour),f={fn:n.Fontname,fs:n.Fontsize,c1:a,a1:s,c2:l,a2:o,c3:u,a3:c,c4:d,a4:h,b:Math.abs(n.Bold),i:Math.abs(n.Italic),u:Math.abs(n.Underline),s:Math.abs(n.StrikeOut),fscx:n.ScaleX,fscy:n.ScaleY,fsp:n.Spacing,frz:n.Angle,xbord:n.Outline,ybord:n.Outline,xshad:n.Shadow,yshad:n.Shadow,fe:n.Encoding,q:/^[0-3]$/.test(e.WrapStyle)?1*e.WrapStyle:2};r[n.Name]={style:n,tag:f}}return r}({info:n.info,style:n.styles.style,defaultStyle:t.defaultStyle||{}});return{info:n.info,width:1*n.info.PlayResX||null,height:1*n.info.PlayResY||null,collisions:n.info.Collisions||"Normal",styles:r,dialogues:U({styles:r,dialogues:n.events.dialogue})}}(await e.text(),{}).dialogues.map((e=>({start:Math.round(1e3*e.start),end:Math.round(1e3*e.end),text:this._filterText(e.slices.flatMap((e=>e.fragments.map((e=>e.text)))).join("")).replace(X,"\n"),track:t})));if(e.name.endsWith(".ytxml")){const n=await e.text(),r=this._xmlParser().parse(n);if(0===Object.keys(r).length)return[];const i=r.transcript.text,s=[];for(let e=0,n=i.length;e<n;e++){const n=i[e];if(!("#text"in n)||!("@_dur"in n)||!("@_start"in n))continue;const r=parseFloat(n["@_start"]);s.push({start:Math.floor(1e3*r),end:Math.floor(1e3*(r+parseFloat(n["@_dur"]))),text:this._filterText(this._decodeHTML(String(n["#text"])).replace(Z,"")),track:t})}return s}if(e.name.endsWith(".sup"))return await this._parsePgs(e,t);if(e.name.endsWith(".dfxp")||e.name.endsWith("ttml2")){const n=await e.text(),r=(new DOMParser).parseFromString(n,"application/xml"),i=this._xmlNodePath(r.documentElement,["body","div"]),s=[];for(let e=0,n=i.length;e<n;e++){const n=i[e],r=n.getAttribute("begin"),a=n.getAttribute("end");null!==r&&null!==a&&s.push({text:this._filterText(n.textContent??""),start:this._parseTtmlTimestamp(r),end:this._parseTtmlTimestamp(a),track:t})}return s}throw new Error("Unsupported subtitle file format")}_parsePgs(e,t){const n=[];return new Promise((async(r,i)=>{const s=await this._pgsWorkerFactory();s.onmessage=async e=>{switch(e.data.command){case"subtitle":const a={...e.data.subtitle,track:t},o=e.data.imageBlob;a.textImage.dataUrl=await this._blobToDataUrl(o),n.push(a);break;case"finished":s.terminate(),r(n);break;case"error":s.terminate(),i(e.data.error)}},s.onerror=e=>{const t=e?.error??new Error("PGS decoding failed: "+e?.message);i(t),s.terminate()};const a=document.createElement("canvas").transferControlToOffscreen(),o=await e.stream();s.postMessage({fileStream:o,canvas:a},[o,a])}))}_blobToDataUrl(e){return new Promise(((t,n)=>{var r=new FileReader;r.readAsDataURL(e),r.onloadend=()=>{t(r.result)}}))}_parseTtmlTimestamp(e){const t=e.split(":");return Math.floor(1e3*parseFloat(t[t.length-1]))+6e4*(t.length<2?0:Number(t[t.length-2]))+36e5*(t.length<3?0:Number(t[t.length-3]))}_xmlNodePath(e,t){if(0===t.length){const t=[];for(let n=0;n<e.children.length;++n){const r=e.children[n];t.push(r)}return t}for(let n=0;n<e.children.length;++n){const r=e.children[n];if(this._dropTagNamespace(r.tagName)===t[0])return this._xmlNodePath(r,t.slice(1))}throw new Error("Failied to parse XML path")}_dropTagNamespace(e){const t=e.lastIndexOf(":");return-1!==t?e.substring(t+1):e}_fixRTL(e){const t=e.indexOf("&lrm;"),n=e.indexOf("&rlm;");let r="";return t>-1?(r=e.substring(0,t)+"‪"+e.substring(t+5)+"‬",this._fixRTL(r)):n>-1?(r=e.substring(0,n)+"‫"+e.substring(n+5)+"‬",this._fixRTL(r)):e}_decodeHTML(e){return K.innerHTML=e,K.textContent??K.innerText}_xmlParser(){return void 0===this.xmlParser&&(this.xmlParser=new W.XMLParser({ignoreAttributes:!1})),this.xmlParser}_filterText(e){return void 0===this._textFilter?e:e.replace(this._textFilter.regex,this._textFilter.replacement).trim()}subtitlesToSrt(e){const t=new z({numericTimestamps:!0}),n=e.map(((e,t)=>({id:String(t),startTime:e.start,endTime:e.end,text:e.text})));return t.toSrt(n)}async filesToSrt(e){return this.subtitlesToSrt(await this.subtitles(e))}}class Y{async get(e){return await chrome.storage.local.get(e)}async set(e){await chrome.storage.local.set(e)}}new v(new Y);const J=(new v(new Y),async e=>await ee(e)??await Q(e)??await Q("en")),Q=async e=>{for(const t of w)if(e===t)return{lang:e,strings:await(await fetch(chrome.runtime.getURL(`asbplayer-locales/${e}.json`))).json()}},ee=async e=>{const t=(e=>`locStrings-${e}`)(e),n=(await chrome.storage.local.get(t))[t];if(void 0!==n)return{lang:e,strings:n}};class te{constructor(e,t){this.frame=e,this.fetchOptions=t,this.bindPromise=void 0}async bind(){return this.bindPromise=this.bindPromise||this._bindClient(),this.bindPromise}updateState(e){if(!this.frameId)throw new Error("Attempted to update state when frame is not ready");this.frame.contentWindow?.postMessage({sender:"asbplayer-video",message:{command:"sendClientMessage",message:{command:"updateState",state:e},frameId:this.frameId}},"*")}sendMessage(e){if(!this.frameId)throw new Error("Attempted to send message when frame is not ready");this.frame.contentWindow?.postMessage({sender:"asbplayer-video",message:{command:"sendClientMessage",message:e,frameId:this.frameId}},"*")}onMessage(e){this.serverMessageListener=e}unbind(){this.windowMessageListener&&(window.removeEventListener("message",this.windowMessageListener),this.windowMessageListener=void 0),this.serverMessageListener=void 0}_bindClient(){return new Promise(((e,t)=>{let n=!1;this.windowMessageListener=t=>{if(t.source!==this.frame.contentWindow||"asbplayer-frame"!==t.data.sender)return;const r=t.data.message;switch(r.command){case"ready":this.frameId=t.data.message.frameId,n=!0,e();break;case"onServerMessage":"http-post"===r.message.command?this._resolveHttpPost(r.message):this.serverMessageListener&&this.serverMessageListener(r.message)}},setTimeout((()=>{n||(t(new Error("Timed out waiting for frame to be ready")),this.windowMessageListener&&(window.removeEventListener("message",this.windowMessageListener),this.windowMessageListener=void 0))}),1e4),window.addEventListener("message",this.windowMessageListener)}))}_resolveHttpPost(e){if(void 0===this.fetchOptions)return;if(void 0===this.fetchOptions.allowedFetchUrl||e.url!==this.fetchOptions.allowedFetchUrl)return;let t;const n={command:"http-post",url:e.url,body:e.body,messageId:e.messageId};t=void 0===this.fetchOptions.videoSrc?{sender:"asbplayer-video-tab",message:n}:{sender:"asbplayer-video",message:n,src:this.fetchOptions.videoSrc},chrome.runtime.sendMessage(t,(t=>{const n=t?{...t,messageId:e.messageId}:{error:chrome.runtime.lastError?.message,messageId:e.messageId};this.frame.contentWindow?.postMessage({sender:"asbplayer-video",message:{command:"sendClientMessage",message:n,frameId:this.frameId}},"*")}))}}class ne{constructor(e){this._language="en",this._dirty=!0,this._bound=!1,this._html=e}set fetchOptions(e){this._dirty=this._dirty||this._fetchOptions?.allowedFetchUrl!==e.allowedFetchUrl||this._fetchOptions?.videoSrc!==e.videoSrc,this._fetchOptions=e}set language(e){this._dirty=this._dirty||this._language!==e,this._language=e}get hidden(){return void 0===this._frame||this._frame.classList.contains("asbplayer-hide")}get bound(){return this._bound}async bind(){return await this._init()}async client(){return await this._init(),this._client}async _init(){if(!this._dirty)return!1;this._dirty=!1,this._bound=!0,this._client?.unbind(),this._frame?.remove(),this._frame=document.createElement("iframe"),this._frame.className="asbplayer-ui-frame",this._frame.style.colorScheme="normal",this._client=new te(this._frame,this._fetchOptions),document.body.appendChild(this._frame);const e=this._frame.contentDocument;return e.open(),e.write(await this._html(this._language)),e.close(),await this._client.bind(),!0}show(){this._frame?.classList.remove("asbplayer-hide")}hide(){this._frame?.classList.add("asbplayer-hide"),this._frame?.blur()}unbind(){this._dirty=!0,this._client?.unbind(),this._frame?.remove()}}class re{constructor(e){this._context=e,this._frame=new ne((async e=>`<!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <title>asbplayer - Request Active Tab Permission</title>\n </head>\n <body>\n <div id="root" style="width:100%;height:100vh;"></div>\n <script type="application/json" id="loc">${JSON.stringify(await J(e))}<\/script>\n <script src="${chrome.runtime.getURL("./active-tab-permission-request-ui.js")}"><\/script>\n </body>\n </html>`))}onPermissionGranted(){this._client?.updateState({permissionGranted:!0})}async show(){this._frame.language=await this._context.settings.getSingle("language");const e=await this._frame.bind();this._client?.unbind(),this._client=await this._frame.client(),e&&this._client.onMessage((e=>{"close"===e.command&&(this._frame.hide(),this._notifyRequesting(!1))})),this._frame.show(),this._client.updateState({themeType:await this._context.settings.getSingle("themeType")}),this._context.pause(),this._notifyRequesting(!0)}_notifyRequesting(e){const t={sender:"asbplayer-video",message:{command:"requesting-active-tab-permission",requesting:e},src:this._context.video.src};chrome.runtime.sendMessage(t)}unbind(){this._client?.unbind()}}async function ie(e){const t=await(await fetch(chrome.runtime.getURL("./mp3-encoder-worker.js"))).text();return`<!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <title>asbplayer - Anki</title>\n </head>\n <body>\n <div id="root" style="width:100%;height:100vh;"></div>\n <script type="application/json" id="loc">${JSON.stringify(await J(e))}<\/script>\n <script id="mp3-encoder-worker" type="javascript/worker">${t}<\/script>\n <script src="${chrome.runtime.getURL("./anki-ui.js")}"><\/script>\n </body>\n </html>`}class se{constructor(){this.frame=new ne(ie)}get ankiSettings(){return this._ankiSettings}set ankiSettings(e){this._ankiSettings=e,this.frame?.bound&&this.frame.client().then((t=>t.sendMessage({command:"ankiSettings",value:e})))}get showing(){return!this.frame.hidden}async show(e,t,n,r,i){if(!this._ankiSettings)throw new Error("Unable to show Anki UI because settings are missing.");this._prepareShow(e);const s=await this._client(e),a=e.url,o=await e.settings.getSingle("themeType"),c={type:"initial",open:!0,canRerecord:!0,settingsProvider:this._ankiSettings,source:l(e.subtitleFileName(),t.start),url:a,subtitle:t,surroundingSubtitles:n,image:r,audio:i,themeType:o,dialogRequestedTimestamp:1e3*e.video.currentTime};s.updateState(c)}async showAfterRerecord(e,t){if(!this._ankiSettings)throw new Error("Unable to show Anki UI after rerecording because anki settings are undefined");this._prepareShow(e);const n=await this._client(e),r=await e.settings.getSingle("themeType"),i={...t,type:"resume",open:!0,canRerecord:!0,settingsProvider:this._ankiSettings,themeType:r,dialogRequestedTimestamp:1e3*e.video.currentTime};n.updateState(i)}async showAfterRetakingScreenshot(e,t){if(!this._ankiSettings)throw new Error("Unable to show Anki UI after retaking screenshot because anki settings are undefined");this._prepareShow(e);const n=await this._client(e),r=await e.settings.getSingle("themeType"),i={...t,type:"resume",open:!0,canRerecord:!0,settingsProvider:this._ankiSettings,themeType:r};n.updateState(i)}async requestRewind(e){(await this._client(e)).sendMessage({command:"rewind"})}_prepareShow(e){e.pause(),document.activeElement&&(this.activeElement=document.activeElement),document.fullscreenElement&&(this.fullscreenElement=document.fullscreenElement,document.exitFullscreen()),e.keyBindings.unbind(),e.subtitleController.forceHideSubtitles=!0}async _client(e){this.frame.fetchOptions={videoSrc:e.video.src,allowedFetchUrl:this._ankiSettings.ankiConnectUrl},this.frame.language=await e.settings.getSingle("language");const t=await this.frame.bind(),n=await this.frame.client();return t&&(this.focusInListener=e=>{void 0===this.frame||this.frame.hidden||n.sendMessage({command:"focus"})},window.addEventListener("focusin",this.focusInListener),n.onMessage((t=>{switch(t.command){case"openSettings":const n={sender:"asbplayer-video",message:{command:"open-asbplayer-settings"},src:e.video.src};return void chrome.runtime.sendMessage(n);case"copy-to-clipboard":const r={sender:"asbplayer-video",message:{command:"copy-to-clipboard",dataUrl:t.dataUrl},src:e.video.src};return void chrome.runtime.sendMessage(r)}if(e.keyBindings.bind(e),e.subtitleController.forceHideSubtitles=!1,this.frame?.hide(),this.fullscreenElement&&(this.fullscreenElement.requestFullscreen(),this.fullscreenElement=void 0),this.activeElement){const e=this.activeElement;"function"==typeof e.focus&&e.focus(),this.activeElement=void 0}else window.focus();switch(t.command){case"resume":const n=t;if(e.ankiUiSavedState=n.uiState,n.cardExported&&0!==n.uiState.dialogRequestedTimestamp){const t=n.uiState.dialogRequestedTimestamp/1e3;e.video.currentTime!==t&&e.seek(t),e.play()}else e.play();break;case"rewind":const r=t;e.ankiUiSavedState=r.uiState,e.pause(),e.seek(r.uiState.subtitle.start/1e3);break;case"rerecord":const i=t;e.rerecord(i.recordStart,i.recordEnd,i.uiState);break;default:console.error("Unknown message received from bridge: "+t.command)}}))),this.frame.show(),n}unbind(){this.frame.unbind(),this.focusInListener&&(window.removeEventListener("focusin",this.focusInListener),this.focusInListener=void 0)}}class ae{constructor(e){this.video=e,this.elements=[]}show(){for(const e of this.elements)e.classList.remove("asbplayer-hide")}hide(){this._garbageCollectElements(),this._findElements();for(const e of this.elements)e.classList.add("asbplayer-hide");return new Promise(((e,t)=>{setTimeout((()=>e(void 0)),0)}))}_garbageCollectElements(){this.elements=this.elements.filter((e=>document.body.contains(e)))}_findElements(){for(const e of this._samplePoints())for(const t of this._path(document.elementFromPoint(e.x,e.y)))t&&!this._contains(this.elements,t)&&this.elements.push(t)}*_samplePoints(){const e=this.video.getBoundingClientRect(),t=e.width/25,n=e.height/25,r=e.width+e.x,i=e.height+e.y;for(let s=e.x;s<=r;s+=t)for(let a=e.y;a<=i;a+=n){const o={x:this._withNoise(s,t/2,e.x,r),y:this._withNoise(a,n/2,e.y,i)};yield o}}_withNoise(e,t,n,r){return Math.min(r,Math.max(n,e+(Math.random()*t*2-t)))}*_path(e){if(!e||e.contains(this.video))return;let t=e;for(yield t;;){const e=t.parentElement;if(!e||e.contains(this.video))break;t=e,yield t}}_contains(e,t){for(const n of e)if(n.isSameNode(t))return!0;return!1}}class oe{constructor(e){this.video=e}element(){if(this.imageElement)return this.imageElement;const e=document.createElement("div");e.classList.add("asbplayer-image-container"),e.classList.add("asbplayer-hide");const t=document.createElement("img");return t.classList.add("asbplayer-image"),t.src=chrome.runtime.getURL("assets/image.png"),this._applyImageContainerStyles(t,e),e.appendChild(t),document.body.appendChild(e),this.imageElementStylesInterval=setInterval((()=>this._applyImageContainerStyles(t,e)),1e3),this.imageElement=e,this.imageElement}_applyImageContainerStyles(e,t){const n=this.video.getBoundingClientRect(),r=.9*Math.min(window.innerWidth,n.width),i=.9*Math.min(window.innerHeight,n.height);t.style.top=n.top+window.scrollY+.05*n.height+"px",t.style.left=n.left+.05*n.width+"px",t.style.width=r+"px",t.style.height=i+"px";const s=Math.min(1,Math.min(r/300,i/300)),a=300*s,o=300*s,l=(i-o)/2,c=(r-a)/2;e.style.top=l+"px",e.style.left=c+"px",e.style.width=a+"px",e.style.height=o+"px"}remove(){this.imageElementStylesInterval&&(clearInterval(this.imageElementStylesInterval),this.imageElementStylesInterval=void 0),this.imageElement&&(this.imageElement.remove(),this.imageElement=void 0)}}class le{constructor(e){this.dragEnterElement=null,this.bodyDragEnterElement=null,this.video=e,this.imageElement=new oe(e),this.bound=!1}bind(e){if(this.bound)return;this.dropListener=async t=>{if(t.preventDefault(),this.dragEnterElement=null,this.imageElement.element().classList.add("asbplayer-hide"),this.imageElement.element().classList.remove("asbplayer-image-fade-in"),this._dragElement().classList.remove("asbplayer-drag-zone-dragging"),this._dragElement().classList.add("asbplayer-hide"),!t.dataTransfer?.files||0===t.dataTransfer?.files.length)return;const n=[];for(let e=0;e<t.dataTransfer.files.length;++e){const r=t.dataTransfer.files[e],i=r.name.lastIndexOf(".");if(-1===i)return!1;const s=r.name.substring(i+1,r.name.length);"ass"!==s&&"srt"!==s&&"vtt"!==s&&"sup"!==s&&"dfxp"!==s&&"ttml2"!==s||n.push(r)}e.loadSubtitles(n,!1)},this.dragOverListener=e=>e.preventDefault(),this.dragEnterListener=e=>{e.preventDefault(),this.dragEnterElement=e.target,this.imageElement.element().classList.add("asbplayer-drag-image"),this.imageElement.element().classList.remove("asbplayer-hide"),this.imageElement.element().classList.add("asbplayer-image-fade-in")},this.dragLeaveListener=e=>{e.preventDefault(),this.dragEnterElement===e.target&&(this.imageElement.element().classList.add("asbplayer-hide"),this.imageElement.element().classList.remove("asbplayer-image-fade-in"),this._dragElement().classList.remove("asbplayer-drag-zone-dragging"),this._dragElement().classList.add("asbplayer-hide"))},this.bodyDropListener=e=>{e.preventDefault(),this.imageElement.element().classList.add("asbplayer-hide"),this.imageElement.element().classList.remove("asbplayer-image-fade-in"),this._dragElement().classList.remove("asbplayer-drag-zone-dragging"),this._dragElement().classList.add("asbplayer-hide")},this.bodyDragOverListener=e=>e.preventDefault(),this.bodyDragEnterListener=e=>{e.preventDefault(),this.bodyDragEnterElement=e.target,this._dragElement().classList.add("asbplayer-drag-zone-dragging"),this._dragElement().classList.remove("asbplayer-hide")},this.bodyDragLeaveListener=e=>{e.preventDefault(),this.bodyDragEnterElement===e.target&&(this.imageElement.element().classList.add("asbplayer-hide"),this.imageElement.element().classList.remove("asbplayer-image-fade-in"),this._dragElement().classList.remove("asbplayer-drag-zone-dragging"),this._dragElement().classList.add("asbplayer-hide"))};const t=this._dragElement();t.addEventListener("drop",this.dropListener),t.addEventListener("dragover",this.dragOverListener),t.addEventListener("dragenter",this.dragEnterListener),t.addEventListener("dragleave",this.dragLeaveListener),document.body.addEventListener("drop",this.bodyDropListener),document.body.addEventListener("dragover",this.bodyDragOverListener),document.body.addEventListener("dragenter",this.bodyDragEnterListener),document.body.addEventListener("dragleave",this.bodyDragLeaveListener),this.bound=!0}_dragElement(){if(this.dragElement)return this.dragElement;const e=document.createElement("div");return e.classList.add("asbplayer-drag-zone-initial"),this.dragElement=e,this._applyDragElementStyles(e),document.body.appendChild(e),this.dragElementStylesInterval=setInterval((()=>this._applyDragElementStyles(e)),1e3),this.dragElement}_applyDragElementStyles(e){const t=this.video.getBoundingClientRect();e.style.top=t.top+window.scrollY+.05*t.height+"px",e.style.left=t.left+.05*t.width+"px",e.style.height=.9*Math.min(window.innerHeight,t.height)+"px",e.style.width=.9*Math.min(window.innerWidth,t.width)+"px"}unbind(){this.dropListener&&(this.dragElement?.removeEventListener("drop",this.dropListener,!0),this.dropListener=void 0),this.dragOverListener&&(this.dragElement?.removeEventListener("dragover",this.dragOverListener,!0),this.dragOverListener=void 0),this.dragEnterListener&&(this.dragElement?.removeEventListener("dragenter",this.dragEnterListener,!0),this.dragEnterListener=void 0),this.dragLeaveListener&&(this.dragElement?.removeEventListener("dragleave",this.dragLeaveListener,!0),this.dragLeaveListener=void 0),this.bodyDropListener&&(document.body.removeEventListener("drop",this.bodyDropListener),this.bodyDropListener=void 0),this.bodyDragOverListener&&(document.body.removeEventListener("dragover",this.bodyDragOverListener),this.bodyDragOverListener=void 0),this.bodyDragEnterListener&&(document.body.removeEventListener("dragenter",this.bodyDragEnterListener),this.bodyDragEnterListener=void 0),this.bodyDragLeaveListener&&(document.body.removeEventListener("dragleave",this.bodyDragLeaveListener),this.bodyDragLeaveListener=void 0),this.dragElementStylesInterval&&(clearInterval(this.dragElementStylesInterval),this.dragElementStylesInterval=void 0),this.dragElement&&(this.dragElement.remove(),this.dragElement=void 0),this.imageElement.remove(),this.dragEnterElement=null,this.bound=!1}}const ce=class e{constructor(e,t){this.low=e,this.high=t}clone(){return new e(this.low,this.high)}get max(){return this.clone()}less_than(e){return this.low<e.low||this.low==e.low&&this.high<e.high}equal_to(e){return this.low==e.low&&this.high==e.high}intersect(e){return!this.not_intersect(e)}not_intersect(e){return this.high<e.low||e.high<this.low}merge(t){return new e(void 0===this.low?t.low:Math.min(this.low,t.low),void 0===this.high?t.high:Math.max(this.high,t.high))}output(){return[this.low,this.high]}static comparable_max(e,t){return e.merge(t)}static comparable_less_than(e,t){return e<t}};class ue{constructor(e=void 0,t=void 0,n=null,r=null,i=null,s=1){this.left=n,this.right=r,this.parent=i,this.color=s,this.item={key:e,value:t},e&&e instanceof Array&&2==e.length&&(Number.isNaN(e[0])||Number.isNaN(e[1])||(this.item.key=new ce(Math.min(e[0],e[1]),Math.max(e[0],e[1])))),this.max=this.item.key?this.item.key.max:void 0}isNil(){return void 0===this.item.key&&void 0===this.item.value&&null===this.left&&null===this.right&&1===this.color}less_than(e){if(this.item.value===this.item.key&&e.item.value===e.item.key)return this.item.key.less_than(e.item.key);{let t=this.item.value&&e.item.value&&this.item.value.less_than?this.item.value.less_than(e.item.value):this.item.value<e.item.value;return this.item.key.less_than(e.item.key)||this.item.key.equal_to(e.item.key)&&t}}equal_to(e){if(this.item.value===this.item.key&&e.item.value===e.item.key)return this.item.key.equal_to(e.item.key);{let t=this.item.value&&e.item.value&&this.item.value.equal_to?this.item.value.equal_to(e.item.value):this.item.value==e.item.value;return this.item.key.equal_to(e.item.key)&&t}}intersect(e){return this.item.key.intersect(e.item.key)}copy_data(e){this.item.key=e.item.key,this.item.value=e.item.value}update_max(){if(this.max=this.item.key?this.item.key.max:void 0,this.right&&this.right.max){const e=this.item.key.constructor.comparable_max;this.max=e(this.max,this.right.max)}if(this.left&&this.left.max){const e=this.item.key.constructor.comparable_max;this.max=e(this.max,this.left.max)}}not_intersect_left_subtree(e){return(0,this.item.key.constructor.comparable_less_than)(void 0!==this.left.max.high?this.left.max.high:this.left.max,e.item.key.low)}not_intersect_right_subtree(e){const t=this.item.key.constructor.comparable_less_than;let n=void 0!==this.right.max.low?this.right.max.low:this.right.item.key.low;return t(e.item.key.high,n)}}class he{constructor(){this.root=null,this.nil_node=new ue}get size(){let e=0;return this.tree_walk(this.root,(()=>e++)),e}get keys(){let e=[];return this.tree_walk(this.root,(t=>e.push(t.item.key.output?t.item.key.output():t.item.key))),e}get values(){let e=[];return this.tree_walk(this.root,(t=>e.push(t.item.value))),e}get items(){let e=[];return this.tree_walk(this.root,(t=>e.push({key:t.item.key.output?t.item.key.output():t.item.key,value:t.item.value}))),e}isEmpty(){return null==this.root||this.root==this.nil_node}clear(){this.root=null}insert(e,t=e){if(void 0===e)return;let n=new ue(e,t,this.nil_node,this.nil_node,null,0);return this.tree_insert(n),this.recalc_max(n),n}exist(e,t=e){let n=new ue(e,t);return!!this.tree_search(this.root,n)}remove(e,t=e){let n=new ue(e,t),r=this.tree_search(this.root,n);return r&&this.tree_delete(r),r}search(e,t=((e,t)=>e===t?t.output():e)){let n=new ue(e),r=[];return this.tree_search_interval(this.root,n,r),r.map((e=>t(e.item.value,e.item.key)))}intersect_any(e){let t=new ue(e);return this.tree_find_any_interval(this.root,t)}forEach(e){this.tree_walk(this.root,(t=>e(t.item.key,t.item.value)))}map(e){const t=new he;return this.tree_walk(this.root,(n=>t.insert(n.item.key,e(n.item.value,n.item.key)))),t}recalc_max(e){let t=e;for(;null!=t.parent;)t.parent.update_max(),t=t.parent}tree_insert(e){let t=this.root,n=null;if(null==this.root||this.root==this.nil_node)this.root=e;else{for(;t!=this.nil_node;)n=t,t=e.less_than(t)?t.left:t.right;e.parent=n,e.less_than(n)?n.left=e:n.right=e}this.insert_fixup(e)}insert_fixup(e){let t,n;for(t=e;t!=this.root&&0==t.parent.color;)t.parent==t.parent.parent.left?(n=t.parent.parent.right,0==n.color?(t.parent.color=1,n.color=1,t.parent.parent.color=0,t=t.parent.parent):(t==t.parent.right&&(t=t.parent,this.rotate_left(t)),t.parent.color=1,t.parent.parent.color=0,this.rotate_right(t.parent.parent))):(n=t.parent.parent.left,0==n.color?(t.parent.color=1,n.color=1,t.parent.parent.color=0,t=t.parent.parent):(t==t.parent.left&&(t=t.parent,this.rotate_right(t)),t.parent.color=1,t.parent.parent.color=0,this.rotate_left(t.parent.parent)));this.root.color=1}tree_delete(e){let t,n;t=e.left==this.nil_node||e.right==this.nil_node?e:this.tree_successor(e),n=t.left!=this.nil_node?t.left:t.right,n.parent=t.parent,t==this.root?this.root=n:(t==t.parent.left?t.parent.left=n:t.parent.right=n,t.parent.update_max()),this.recalc_max(n),t!=e&&(e.copy_data(t),e.update_max(),this.recalc_max(e)),1==t.color&&this.delete_fixup(n)}delete_fixup(e){let t,n=e;for(;n!=this.root&&null!=n.parent&&1==n.color;)n==n.parent.left?(t=n.parent.right,0==t.color&&(t.color=1,n.parent.color=0,this.rotate_left(n.parent),t=n.parent.right),1==t.left.color&&1==t.right.color?(t.color=0,n=n.parent):(1==t.right.color&&(t.color=0,t.left.color=1,this.rotate_right(t),t=n.parent.right),t.color=n.parent.color,n.parent.color=1,t.right.color=1,this.rotate_left(n.parent),n=this.root)):(t=n.parent.left,0==t.color&&(t.color=1,n.parent.color=0,this.rotate_right(n.parent),t=n.parent.left),1==t.left.color&&1==t.right.color?(t.color=0,n=n.parent):(1==t.left.color&&(t.color=0,t.right.color=1,this.rotate_left(t),t=n.parent.left),t.color=n.parent.color,n.parent.color=1,t.left.color=1,this.rotate_right(n.parent),n=this.root));n.color=1}tree_search(e,t){if(null!=e&&e!=this.nil_node)return t.equal_to(e)?e:t.less_than(e)?this.tree_search(e.left,t):this.tree_search(e.right,t)}tree_search_interval(e,t,n){null!=e&&e!=this.nil_node&&(e.left==this.nil_node||e.not_intersect_left_subtree(t)||this.tree_search_interval(e.left,t,n),e.intersect(t)&&n.push(e),e.right==this.nil_node||e.not_intersect_right_subtree(t)||this.tree_search_interval(e.right,t,n))}tree_find_any_interval(e,t){let n=!1;return null!=e&&e!=this.nil_node&&(e.left==this.nil_node||e.not_intersect_left_subtree(t)||(n=this.tree_find_any_interval(e.left,t)),n||(n=e.intersect(t)),n||e.right==this.nil_node||e.not_intersect_right_subtree(t)||(n=this.tree_find_any_interval(e.right,t))),n}local_minimum(e){let t=e;for(;null!=t.left&&t.left!=this.nil_node;)t=t.left;return t}local_maximum(e){let t=e;for(;null!=t.right&&t.right!=this.nil_node;)t=t.right;return t}tree_successor(e){let t,n,r;if(e.right!=this.nil_node)t=this.local_minimum(e.right);else{for(n=e,r=e.parent;null!=r&&r.right==n;)n=r,r=r.parent;t=r}return t}rotate_left(e){let t=e.right;e.right=t.left,t.left!=this.nil_node&&(t.left.parent=e),t.parent=e.parent,e==this.root?this.root=t:e==e.parent.left?e.parent.left=t:e.parent.right=t,t.left=e,e.parent=t,null!=e&&e!=this.nil_node&&e.update_max(),t=e.parent,null!=t&&t!=this.nil_node&&t.update_max()}rotate_right(e){let t=e.left;e.left=t.right,t.right!=this.nil_node&&(t.right.parent=e),t.parent=e.parent,e==this.root?this.root=t:e==e.parent.left?e.parent.left=t:e.parent.right=t,t.right=e,e.parent=t,null!=e&&e!=this.nil_node&&e.update_max(),t=e.parent,null!=t&&t!=this.nil_node&&t.update_max()}tree_walk(e,t){null!=e&&e!=this.nil_node&&(this.tree_walk(e.left,t),t(e),this.tree_walk(e.right,t))}testRedBlackProperty(){let e=!0;return this.tree_walk(this.root,(function(t){0==t.color&&(1==t.left.color&&1==t.right.color||(e=!1))})),e}testBlackHeightProperty(e){let t=0,n=0,r=0;if(1==e.color&&t++,n=e.left!=this.nil_node?this.testBlackHeightProperty(e.left):1,r=e.right!=this.nil_node?this.testBlackHeightProperty(e.right):1,n!=r)throw new Error("Red-black height property violated");return t+=n,t}}const de=he;class fe{constructor(e,t={}){if(this.tree=new de,this.options=t,t.returnLastShown||t.returnNextToShow){let t;this.gapsTree=new de,e.length>0&&e[0].start>0&&this.gapsTree.insert([0,e[0].start-1],e[0]);for(const n of e)this.tree.insert([n.start,n.end],n),void 0!==t&&t.end<n.start&&this.gapsTree.insert([t.end+1,n.start-1],t),t=n}else for(const t of e)this.tree.insert([t.start,t.end],t)}static empty(){return fe.emptySubtitleCollection}subtitlesAt(e){const t=[e,e],n=this.tree.search(t);let r,i,s,a;if(0===n.length){if(void 0!==this.gapsTree){const e=[];if(r=this.gapsTree.search(t,((t,n)=>(e.push(n),t))),r.length>0&&this.options.returnNextToShow){const t=e[0].high+1;i=this.tree.search([t,t])}}}else if(void 0!==this.options.showingCheckRadiusMs)for(const t of n)if(void 0===a&&t.end<e+this.options.showingCheckRadiusMs&&(a=t),void 0===s&&e-this.options.showingCheckRadiusMs<t.start&&(s=t),void 0!==s&&void 0!==a)break;return{showing:n,lastShown:r,nextToShow:i,startedShowing:s,willStopShowing:a}}}function pe(e){return pe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},pe(e)}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function me(e){var t=function(e,t){if("object"!==pe(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==pe(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===pe(t)?t:String(t)}function ye(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,me(r.key),r)}}function be(e,t,n){return t&&ye(e.prototype,t),n&&ye(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function ve(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function we(e,t){return we=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},we(e,t)}function Se(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&we(e,t)}function Ee(e,t){if(t&&("object"===pe(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return ve(e)}function xe(e){return xe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},xe(e)}function ke(e,t,n){return(t=me(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Oe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ce(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_e(Object(n),!0).forEach((function(t){ke(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_e(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}fe.emptySubtitleCollection=new fe([]);var Te={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},Ae=new(function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ge(this,e),this.init(t,n)}return be(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||Te,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,n,r){return r&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(n).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,Ce(Ce({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}()),Pe=function(){function e(){ge(this,e),this.observers={}}return be(e,[{key:"on",value:function(e,t){var n=this;return e.split(" ").forEach((function(e){n.observers[e]=n.observers[e]||[],n.observers[e].push(t)})),this}},{key:"off",value:function(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter((function(e){return e!==t})):delete this.observers[e])}},{key:"emit",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.observers[e]&&[].concat(this.observers[e]).forEach((function(e){e.apply(void 0,n)})),this.observers["*"]&&[].concat(this.observers["*"]).forEach((function(t){t.apply(t,[e].concat(n))}))}}]),e}();function Fe(){var e,t,n=new Promise((function(n,r){e=n,t=r}));return n.resolve=e,n.reject=t,n}function Ne(e){return null==e?"":""+e}function Le(e,t,n){function r(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function i(){return!e||"string"==typeof e}for(var s="string"!=typeof t?[].concat(t):t.split(".");s.length>1;){if(i())return{};var a=r(s.shift());!e[a]&&n&&(e[a]=new n),e=Object.prototype.hasOwnProperty.call(e,a)?e[a]:{}}return i()?{}:{obj:e,k:r(s.shift())}}function Re(e,t,n){var r=Le(e,t,Object);r.obj[r.k]=n}function Ie(e,t){var n=Le(e,t),r=n.obj,i=n.k;if(r)return r[i]}function je(e,t,n){for(var r in t)"__proto__"!==r&&"constructor"!==r&&(r in e?"string"==typeof e[r]||e[r]instanceof String||"string"==typeof t[r]||t[r]instanceof String?n&&(e[r]=t[r]):je(e[r],t[r],n):e[r]=t[r]);return e}function Me(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var De={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function $e(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return De[e]})):e}var Be="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,Ue=[" ",",","?","!",";"];function Ve(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(e){if(e[t])return e[t];for(var r=t.split(n),i=e,s=0;s<r.length;++s){if(!i)return;if("string"==typeof i[r[s]]&&s+1<r.length)return;if(void 0===i[r[s]]){for(var a=2,o=r.slice(s,s+a).join(n),l=i[o];void 0===l&&r.length>s+a;)a++,l=i[o=r.slice(s,s+a).join(n)];if(void 0===l)return;if(null===l)return null;if(t.endsWith(o)){if("string"==typeof l)return l;if(o&&"string"==typeof l[o])return l[o]}var c=r.slice(s+a).join(n);return c?Ve(l,c,n):void 0}i=i[r[s]]}return i}}function He(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ze(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?He(Object(n),!0).forEach((function(t){ke(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):He(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var qe=function(e){Se(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=xe(t);if(n){var i=xe(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return Ee(this,e)});function i(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return ge(this,i),t=r.call(this),Be&&Pe.call(ve(t)),t.data=e||{},t.options=n,void 0===t.options.keySeparator&&(t.options.keySeparator="."),void 0===t.options.ignoreJSONStructure&&(t.options.ignoreJSONStructure=!0),t}return be(i,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,s=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure,a=[e,t];n&&"string"!=typeof n&&(a=a.concat(n)),n&&"string"==typeof n&&(a=a.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(a=e.split("."));var o=Ie(this.data,a);return o||!s||"string"!=typeof n?o:Ve(this.data&&this.data[e]&&this.data[e][t],n,i)}},{key:"addResource",value:function(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},s=this.options.keySeparator;void 0===s&&(s=".");var a=[e,t];n&&(a=a.concat(s?n.split(s):n)),e.indexOf(".")>-1&&(r=t,t=(a=e.split("."))[1]),this.addNamespaces(t),Re(this.data,a,r),i.silent||this.emit("added",e,t,n,r)}},{key:"addResources",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var i in n)"string"!=typeof n[i]&&"[object Array]"!==Object.prototype.toString.apply(n[i])||this.addResource(e,t,i,n[i],{silent:!0});r.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,r,i){var s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},a=[e,t];e.indexOf(".")>-1&&(r=n,n=t,t=(a=e.split("."))[1]),this.addNamespaces(t);var o=Ie(this.data,a)||{};r?je(o,n,i):o=ze(ze({},o),n),Re(this.data,a,o),s.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?ze(ze({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find((function(e){return t[e]&&Object.keys(t[e]).length>0}))}},{key:"toJSON",value:function(){return this.data}}]),i}(Pe),We={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,r,i){var s=this;return e.forEach((function(e){s.processors[e]&&(t=s.processors[e].process(t,n,r,i))})),t}};function Ze(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Xe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ze(Object(n),!0).forEach((function(t){ke(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ze(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ke={},Ge=function(e){Se(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=xe(t);if(n){var i=xe(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return Ee(this,e)});function i(e){var t,n,s,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ge(this,i),t=r.call(this),Be&&Pe.call(ve(t)),n=e,s=ve(t),["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"].forEach((function(e){n[e]&&(s[e]=n[e])})),t.options=a,void 0===t.options.keySeparator&&(t.options.keySeparator="."),t.logger=Ae.create("translator"),t}return be(i,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");var r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,i=t.ns||this.options.defaultNS||[],s=n&&e.indexOf(n)>-1,a=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||function(e,t,n){t=t||"",n=n||"";var r=Ue.filter((function(e){return t.indexOf(e)<0&&n.indexOf(e)<0}));if(0===r.length)return!0;var i=new RegExp("(".concat(r.map((function(e){return"?"===e?"\\?":e})).join("|"),")")),s=!i.test(e);if(!s){var a=e.indexOf(n);a>0&&!i.test(e.substring(0,a))&&(s=!0)}return s}(e,n,r));if(s&&!a){var o=e.match(this.interpolator.nestingRegexp);if(o&&o.length>0)return{key:e,namespaces:i};var l=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(l[0])>-1)&&(i=l.shift()),e=l.join(r)}return"string"==typeof i&&(i=[i]),{key:e,namespaces:i}}},{key:"translate",value:function(e,t,n){var r=this;if("object"!==pe(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var s=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,a=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=this.extractFromKey(e[e.length-1],t),l=o.key,c=o.namespaces,u=c[c.length-1],h=t.lng||this.language,d=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h&&"cimode"===h.toLowerCase()){if(d){var f=t.nsSeparator||this.options.nsSeparator;return s?{res:"".concat(u).concat(f).concat(l),usedKey:l,exactUsedKey:l,usedLng:h,usedNS:u}:"".concat(u).concat(f).concat(l)}return s?{res:l,usedKey:l,exactUsedKey:l,usedLng:h,usedNS:u}:l}var p=this.resolve(e,t),g=p&&p.res,m=p&&p.usedKey||l,y=p&&p.exactUsedKey||l,b=Object.prototype.toString.apply(g),v=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject;if(w&&g&&"string"!=typeof g&&"boolean"!=typeof g&&"number"!=typeof g&&["[object Number]","[object Function]","[object RegExp]"].indexOf(b)<0&&("string"!=typeof v||"[object Array]"!==b)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var S=this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,g,Xe(Xe({},t),{},{ns:c})):"key '".concat(l," (").concat(this.language,")' returned an object instead of string.");return s?(p.res=S,p):S}if(a){var E="[object Array]"===b,x=E?[]:{},k=E?y:m;for(var O in g)if(Object.prototype.hasOwnProperty.call(g,O)){var _="".concat(k).concat(a).concat(O);x[O]=this.translate(_,Xe(Xe({},t),{joinArrays:!1,ns:c})),x[O]===_&&(x[O]=g[O])}g=x}}else if(w&&"string"==typeof v&&"[object Array]"===b)(g=g.join(v))&&(g=this.extendTranslation(g,e,t,n));else{var C=!1,T=!1,A=void 0!==t.count&&"string"!=typeof t.count,P=i.hasDefaultValue(t),F=A?this.pluralResolver.getSuffix(h,t.count,t):"",N=t["defaultValue".concat(F)]||t.defaultValue;!this.isValidLookup(g)&&P&&(C=!0,g=N),this.isValidLookup(g)||(T=!0,g=l);var L=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&T?void 0:g,R=P&&N!==g&&this.options.updateMissing;if(T||C||R){if(this.logger.log(R?"updateKey":"missingKey",h,u,l,R?N:g),a){var I=this.resolve(l,Xe(Xe({},t),{},{keySeparator:!1}));I&&I.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var j=[],M=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&M&&M[0])for(var D=0;D<M.length;D++)j.push(M[D]);else"all"===this.options.saveMissingTo?j=this.languageUtils.toResolveHierarchy(t.lng||this.language):j.push(t.lng||this.language);var $=function(e,n,i){var s=P&&i!==g?i:L;r.options.missingKeyHandler?r.options.missingKeyHandler(e,u,n,s,R,t):r.backendConnector&&r.backendConnector.saveMissing&&r.backendConnector.saveMissing(e,u,n,s,R,t),r.emit("missingKey",e,u,n,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?j.forEach((function(e){r.pluralResolver.getSuffixes(e,t).forEach((function(n){$([e],l+n,t["defaultValue".concat(n)]||N)}))})):$(j,l,N))}g=this.extendTranslation(g,e,t,p,n),T&&g===l&&this.options.appendNamespaceToMissingKey&&(g="".concat(u,":").concat(l)),(T||C)&&this.options.parseMissingKeyHandler&&(g="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(u,":").concat(l):l,C?g:void 0):this.options.parseMissingKeyHandler(g))}return s?(p.res=g,p):g}},{key:"extendTranslation",value:function(e,t,n,r,i){var s=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,Xe(Xe({},this.options.interpolation.defaultVariables),n),r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init(Xe(Xe({},n),{interpolation:Xe(Xe({},this.options.interpolation),n.interpolation)}));var a,o="string"==typeof e&&(n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(o){var l=e.match(this.interpolator.nestingRegexp);a=l&&l.length}var c=n.replace&&"string"!=typeof n.replace?n.replace:n;if(this.options.interpolation.defaultVariables&&(c=Xe(Xe({},this.options.interpolation.defaultVariables),c)),e=this.interpolator.interpolate(e,c,n.lng||this.language,n),o){var u=e.match(this.interpolator.nestingRegexp);a<(u&&u.length)&&(n.nest=!1)}!n.lng&&"v1"!==this.options.compatibilityAPI&&r&&r.res&&(n.lng=r.usedLng),!1!==n.nest&&(e=this.interpolator.nest(e,(function(){for(var e=arguments.length,r=new Array(e),a=0;a<e;a++)r[a]=arguments[a];return i&&i[0]===r[0]&&!n.context?(s.logger.warn("It seems you are nesting recursively key: ".concat(r[0]," in key: ").concat(t[0])),null):s.translate.apply(s,r.concat([t]))}),n)),n.interpolation&&this.interpolator.reset()}var h=n.postProcess||this.options.postProcess,d="string"==typeof h?[h]:h;return null!=e&&d&&d.length&&!1!==n.applyPostProcessor&&(e=We.handle(d,e,t,this.options&&this.options.postProcessPassResolved?Xe({i18nResolved:r},n):n,this)),e}},{key:"resolve",value:function(e){var t,n,r,i,s,a=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((function(e){if(!a.isValidLookup(t)){var l=a.extractFromKey(e,o),c=l.key;n=c;var u=l.namespaces;a.options.fallbackNS&&(u=u.concat(a.options.fallbackNS));var h=void 0!==o.count&&"string"!=typeof o.count,d=h&&!o.ordinal&&0===o.count&&a.pluralResolver.shouldUseIntlApi(),f=void 0!==o.context&&("string"==typeof o.context||"number"==typeof o.context)&&""!==o.context,p=o.lngs?o.lngs:a.languageUtils.toResolveHierarchy(o.lng||a.language,o.fallbackLng);u.forEach((function(e){a.isValidLookup(t)||(s=e,!Ke["".concat(p[0],"-").concat(e)]&&a.utils&&a.utils.hasLoadedNamespace&&!a.utils.hasLoadedNamespace(s)&&(Ke["".concat(p[0],"-").concat(e)]=!0,a.logger.warn('key "'.concat(n,'" for languages "').concat(p.join(", "),'" won\'t get resolved as namespace "').concat(s,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),p.forEach((function(n){if(!a.isValidLookup(t)){i=n;var s,l=[c];if(a.i18nFormat&&a.i18nFormat.addLookupKeys)a.i18nFormat.addLookupKeys(l,c,n,e,o);else{var u;h&&(u=a.pluralResolver.getSuffix(n,o.count,o));var p="".concat(a.options.pluralSeparator,"zero");if(h&&(l.push(c+u),d&&l.push(c+p)),f){var g="".concat(c).concat(a.options.contextSeparator).concat(o.context);l.push(g),h&&(l.push(g+u),d&&l.push(g+p))}}for(;s=l.pop();)a.isValidLookup(t)||(r=s,t=a.getResource(n,e,s,o))}})))}))}})),{res:t,usedKey:n,exactUsedKey:r,usedLng:i,usedNS:s}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}}],[{key:"hasDefaultValue",value:function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&"defaultValue"===t.substring(0,12)&&void 0!==e[t])return!0;return!1}}]),i}(Pe);function Ye(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Je=function(){function e(t){ge(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ae.create("languageUtils")}return be(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map((function(e){return e.toLowerCase()})):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=Ye(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=Ye(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=Ye(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,n=this;return e?(e.forEach((function(e){if(!t){var r=n.formatLanguageCode(e);n.options.supportedLngs&&!n.isSupportedCode(r)||(t=r)}})),!t&&this.options.supportedLngs&&e.forEach((function(e){if(!t){var r=n.getLanguagePartFromCode(e);if(n.isSupportedCode(r))return t=r;t=n.options.supportedLngs.find((function(e){return e===r?e:e.indexOf("-")<0&&r.indexOf("-")<0?void 0:0===e.indexOf(r)?e:void 0}))}})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,r=this.getFallbackCodes(t||this.options.fallbackLng||[],e),i=[],s=function(e){e&&(n.isSupportedCode(e)?i.push(e):n.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&s(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&s(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&s(this.getLanguagePartFromCode(e))):"string"==typeof e&&s(this.formatLanguageCode(e)),r.forEach((function(e){i.indexOf(e)<0&&s(n.formatLanguageCode(e))})),i}}]),e}(),Qe=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],et={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},tt=["v1","v2","v3"],nt={zero:0,one:1,two:2,few:3,many:4,other:5},rt=function(){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ge(this,e),this.languageUtils=t,this.options=r,this.logger=Ae.create("pluralResolver"),this.options.compatibilityJSON&&"v4"!==this.options.compatibilityJSON||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=(n={},Qe.forEach((function(e){e.lngs.forEach((function(t){n[t]={numbers:e.nr,plurals:et[e.fc]}}))})),n)}return be(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,t);return this.shouldUseIntlApi()?n&&n.resolvedOptions().pluralCategories.length>1:n&&n.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,n).map((function(e){return"".concat(t).concat(e)}))}},{key:"getSuffixes",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.getRule(e,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort((function(e,t){return nt[e]-nt[t]})).map((function(e){return"".concat(t.options.prepend).concat(e)})):r.numbers.map((function(r){return t.getSuffix(e,r,n)})):[]}},{key:"getSuffix",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.getRule(e,n);return r?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(r.select(t)):this.getSuffixRetroCompatible(r,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var n=this,r=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),i=e.numbers[r];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===i?i="plural":1===i&&(i=""));var s=function(){return n.options.prepend&&i.toString()?n.options.prepend+i.toString():i.toString()};return"v1"===this.options.compatibilityJSON?1===i?"":"number"==typeof i?"_plural_".concat(i.toString()):s():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?s():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}},{key:"shouldUseIntlApi",value:function(){return!tt.includes(this.options.compatibilityJSON)}}]),e}();function it(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function st(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?it(Object(n),!0).forEach((function(t){ke(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function at(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=function(e,t,n){var r=Ie(e,n);return void 0!==r?r:Ie(t,n)}(e,t,n);return!s&&i&&"string"==typeof n&&void 0===(s=Ve(e,n,r))&&(s=Ve(t,n,r)),s}var ot=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};ge(this,e),this.logger=Ae.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return be(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:$e,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?Me(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?Me(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?Me(t.nestingPrefix):t.nestingPrefixEscaped||Me("$t("),this.nestingSuffix=t.nestingSuffix?Me(t.nestingSuffix):t.nestingSuffixEscaped||Me(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,r){var i,s,a,o=this,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function c(e){return e.replace(/\$/g,"$$$$")}var u=function(e){if(e.indexOf(o.formatSeparator)<0){var i=at(t,l,e,o.options.keySeparator,o.options.ignoreJSONStructure);return o.alwaysFormat?o.format(i,void 0,n,st(st(st({},r),t),{},{interpolationkey:e})):i}var s=e.split(o.formatSeparator),a=s.shift().trim(),c=s.join(o.formatSeparator).trim();return o.format(at(t,l,a,o.options.keySeparator,o.options.ignoreJSONStructure),c,n,st(st(st({},r),t),{},{interpolationkey:a}))};this.resetRegExp();var h=r&&r.missingInterpolationHandler||this.options.missingInterpolationHandler,d=r&&r.interpolation&&void 0!==r.interpolation.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return c(e)}},{regex:this.regexp,safeValue:function(e){return o.escapeValue?c(o.escape(e)):c(e)}}].forEach((function(t){for(a=0;i=t.regex.exec(e);){var n=i[1].trim();if(void 0===(s=u(n)))if("function"==typeof h){var l=h(e,i,r);s="string"==typeof l?l:""}else if(r&&Object.prototype.hasOwnProperty.call(r,n))s="";else{if(d){s=i[0];continue}o.logger.warn("missed to pass in variable ".concat(n," for interpolating ").concat(e)),s=""}else"string"==typeof s||o.useRawValueToEscape||(s=Ne(s));var c=t.safeValue(s);if(e=e.replace(i[0],c),d?(t.regex.lastIndex+=s.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,++a>=o.maxReplaces)break}})),e}},{key:"nest",value:function(e,t){var n,r,i,s=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function o(e,t){var n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;var r=e.split(new RegExp("".concat(n,"[ ]*{"))),s="{".concat(r[1]);e=r[0];var a=(s=this.interpolate(s,i)).match(/'/g),o=s.match(/"/g);(a&&a.length%2==0&&!o||o.length%2!=0)&&(s=s.replace(/'/g,'"'));try{i=JSON.parse(s),t&&(i=st(st({},t),i))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(n).concat(s)}return delete i.defaultValue,e}for(;n=this.nestingRegexp.exec(e);){var l=[];(i=(i=st({},a)).replace&&"string"!=typeof i.replace?i.replace:i).applyPostProcessor=!1,delete i.defaultValue;var c=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){var u=n[1].split(this.formatSeparator).map((function(e){return e.trim()}));n[1]=u.shift(),l=u,c=!0}if((r=t(o.call(this,n[1].trim(),i),i))&&n[0]===e&&"string"!=typeof r)return r;"string"!=typeof r&&(r=Ne(r)),r||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),r=""),c&&(r=l.reduce((function(e,t){return s.format(e,t,a.lng,st(st({},a),{},{interpolationkey:n[1].trim()}))}),r.trim())),e=e.replace(n[0],r),this.regexp.lastIndex=0}return e}}]),e}();function lt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ct(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?lt(Object(n),!0).forEach((function(t){ke(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ut(e){var t={};return function(n,r,i){var s=r+JSON.stringify(i),a=t[s];return a||(a=e(r,i),t[s]=a),a(n)}}var ht=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};ge(this,e),this.logger=Ae.create("formatter"),this.options=t,this.formats={number:ut((function(e,t){var n=new Intl.NumberFormat(e,ct({},t));return function(e){return n.format(e)}})),currency:ut((function(e,t){var n=new Intl.NumberFormat(e,ct(ct({},t),{},{style:"currency"}));return function(e){return n.format(e)}})),datetime:ut((function(e,t){var n=new Intl.DateTimeFormat(e,ct({},t));return function(e){return n.format(e)}})),relativetime:ut((function(e,t){var n=new Intl.RelativeTimeFormat(e,ct({},t));return function(e){return n.format(e,t.range||"day")}})),list:ut((function(e,t){var n=new Intl.ListFormat(e,ct({},t));return function(e){return n.format(e)}}))},this.init(t)}return be(e,[{key:"init",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=ut(t)}},{key:"format",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return t.split(this.formatSeparator).reduce((function(e,t){var s=function(e){var t=e.toLowerCase().trim(),n={};if(e.indexOf("(")>-1){var r=e.split("(");t=r[0].toLowerCase().trim();var i=r[1].substring(0,r[1].length-1);"currency"===t&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):"relativetime"===t&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach((function(e){if(e){var t=function(e){if(Array.isArray(e))return e}(s=e.split(":"))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(s)||function(e,t){if(e){if("string"==typeof e)return Oe(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Oe(e,t):void 0}}(s)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),r=t[0],i=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");n[r.trim()]||(n[r.trim()]=i),"false"===i&&(n[r.trim()]=!1),"true"===i&&(n[r.trim()]=!0),isNaN(i)||(n[r.trim()]=parseInt(i,10))}var s}))}return{formatName:t,formatOptions:n}}(t),a=s.formatName,o=s.formatOptions;if(r.formats[a]){var l=e;try{var c=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},u=c.locale||c.lng||i.locale||i.lng||n;l=r.formats[a](e,u,ct(ct(ct({},o),i),c))}catch(e){r.logger.warn(e)}return l}return r.logger.warn("there was no format function for ".concat(a)),e}),e)}}]),e}();function dt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ft(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?dt(Object(n),!0).forEach((function(t){ke(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var pt=function(e){Se(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=xe(t);if(n){var i=xe(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return Ee(this,e)});function i(e,t,n){var s,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return ge(this,i),s=r.call(this),Be&&Pe.call(ve(s)),s.backend=e,s.store=t,s.services=n,s.languageUtils=n.languageUtils,s.options=a,s.logger=Ae.create("backendConnector"),s.waitingReads=[],s.maxParallelReads=a.maxParallelReads||10,s.readingCalls=0,s.maxRetries=a.maxRetries>=0?a.maxRetries:5,s.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,s.state={},s.queue=[],s.backend&&s.backend.init&&s.backend.init(n,a.backend,a),s}return be(i,[{key:"queueLoad",value:function(e,t,n,r){var i=this,s={},a={},o={},l={};return e.forEach((function(e){var r=!0;t.forEach((function(t){var o="".concat(e,"|").concat(t);!n.reload&&i.store.hasResourceBundle(e,t)?i.state[o]=2:i.state[o]<0||(1===i.state[o]?void 0===a[o]&&(a[o]=!0):(i.state[o]=1,r=!1,void 0===a[o]&&(a[o]=!0),void 0===s[o]&&(s[o]=!0),void 0===l[t]&&(l[t]=!0)))})),r||(o[e]=!0)})),(Object.keys(s).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(s),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}},{key:"loaded",value:function(e,t,n){var r=e.split("|"),i=r[0],s=r[1];t&&this.emit("failedLoading",i,s,t),n&&this.store.addResourceBundle(i,s,n),this.state[e]=t?-1:2;var a={};this.queue.forEach((function(n){!function(e,t,n,r){var i=Le(e,t,Object),s=i.obj,a=i.k;s[a]=s[a]||[],s[a].push(n)}(n.loaded,[i],s),function(e,t){void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)}(n,e),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach((function(e){a[e]||(a[e]={});var t=n.loaded[e];t.length&&t.forEach((function(t){void 0===a[e][t]&&(a[e][t]=!0)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit("loaded",a),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads)this.waitingReads.push({lng:e,ns:t,fcName:n,tried:i,wait:s,callback:a});else{this.readingCalls++;var o=function(o,l){if(r.readingCalls--,r.waitingReads.length>0){var c=r.waitingReads.shift();r.read(c.lng,c.ns,c.fcName,c.tried,c.wait,c.callback)}o&&l&&i<r.maxRetries?setTimeout((function(){r.read.call(r,e,t,n,i+1,2*s,a)}),s):a(o,l)},l=this.backend[n].bind(this.backend);if(2!==l.length)return l(e,t,o);try{var c=l(e,t);c&&"function"==typeof c.then?c.then((function(e){return o(null,e)})).catch(o):o(null,c)}catch(e){o(e)}}}},{key:"prepareLoading",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var s=this.queueLoad(e,t,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach((function(e){n.loadOne(e)}))}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(function(r,a){r&&t.logger.warn("".concat(n,"loading namespace ").concat(s," for language ").concat(i," failed"),r),!r&&a&&t.logger.log("".concat(n,"loaded namespace ").concat(s," for language ").concat(i),a),t.loaded(e,r,a)}))}},{key:"saveMissing",value:function(e,t,n,r,i){var s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:function(){};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t))this.logger.warn('did not save key "'.concat(n,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");else if(null!=n&&""!==n){if(this.backend&&this.backend.create){var o=ft(ft({},s),{},{isUpdate:i}),l=this.backend.create.bind(this.backend);if(l.length<6)try{var c;(c=5===l.length?l(e,t,n,r,o):l(e,t,n,r))&&"function"==typeof c.then?c.then((function(e){return a(null,e)})).catch(a):a(null,c)}catch(e){a(e)}else l(e,t,n,r,a,o)}e&&e[0]&&this.store.addResource(e[0],t,n,r)}}}]),i}(Pe);function gt(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===pe(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===pe(e[2])||"object"===pe(e[3])){var n=e[3]||e[2];Object.keys(n).forEach((function(e){t[e]=n[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,n,r){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function mt(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function yt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function bt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?yt(Object(n),!0).forEach((function(t){ke(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function vt(){}var wt=function(e){Se(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=xe(t);if(n){var i=xe(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return Ee(this,e)});function i(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;if(ge(this,i),e=r.call(this),Be&&Pe.call(ve(e)),e.options=mt(n),e.services={},e.logger=Ae,e.modules={external:[]},t=ve(e),Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach((function(e){"function"==typeof t[e]&&(t[e]=t[e].bind(t))})),s&&!e.isInitialized&&!n.isClone){if(!e.options.initImmediate)return e.init(n,s),Ee(e,ve(e));setTimeout((function(){e.init(n,s)}),0)}return e}return be(i,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(n=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var r=gt();function i(e){return e?"function"==typeof e?new e:e:null}if(this.options=bt(bt(bt({},r),this.options),mt(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=bt(bt({},r.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){var s;this.modules.logger?Ae.init(i(this.modules.logger),this.options):Ae.init(null,this.options),this.modules.formatter?s=this.modules.formatter:"undefined"!=typeof Intl&&(s=ht);var a=new Je(this.options);this.store=new qe(this.options.resources,this.options);var o=this.services;o.logger=Ae,o.resourceStore=this.store,o.languageUtils=a,o.pluralResolver=new rt(a,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!s||this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format||(o.formatter=i(s),o.formatter.init(o,this.options),this.options.interpolation.format=o.formatter.format.bind(o.formatter)),o.interpolator=new ot(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new pt(i(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];e.emit.apply(e,[t].concat(r))})),this.modules.languageDetector&&(o.languageDetector=i(this.modules.languageDetector),o.languageDetector.init&&o.languageDetector.init(o,this.options.detection,this.options)),this.modules.i18nFormat&&(o.i18nFormat=i(this.modules.i18nFormat),o.i18nFormat.init&&o.i18nFormat.init(this)),this.translator=new Ge(this.services,this.options),this.translator.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];e.emit.apply(e,[t].concat(r))})),this.modules.external.forEach((function(t){t.init&&t.init(e)}))}if(this.format=this.options.interpolation.format,n||(n=vt),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var l=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);l.length>0&&"dev"!==l[0]&&(this.options.lng=l[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments)}})),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments),e}}));var c=Fe(),u=function(){var t=function(t,r){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),c.resolve(r),n(t,r)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),c}},{key:"loadResources",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:vt,r="string"==typeof e?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r&&"cimode"===r.toLowerCase())return n();var i=[],s=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach((function(e){i.indexOf(e)<0&&i.push(e)}))};r?s(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((function(e){return s(e)})),this.options.preload&&this.options.preload.forEach((function(e){return s(e)})),this.services.backendConnector.load(i,this.options.ns,(function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),n(e)}))}else n(null)}},{key:"reloadResources",value:function(e,t,n){var r=Fe();return e||(e=this.languages),t||(t=this.options.ns),n||(n=vt),this.services.backendConnector.reload(e,t,(function(e){r.resolve(),n(e)})),r}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&We.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var n=this.languages[t];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}},{key:"changeLanguage",value:function(e,t){var n=this;this.isLanguageChangingTo=e;var r=Fe();this.emit("languageChanging",e);var i=function(e){n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.resolvedLanguage=void 0,n.setResolvedLanguage(e)},s=function(s){e||s||!n.services.languageDetector||(s=[]);var a="string"==typeof s?s:n.services.languageUtils.getBestMatchFromCodes(s);a&&(n.language||i(a),n.translator.language||n.translator.changeLanguage(a),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage&&n.services.languageDetector.cacheUserLanguage(a)),n.loadResources(a,(function(e){!function(e,s){s?(i(s),n.translator.changeLanguage(s),n.isLanguageChangingTo=void 0,n.emit("languageChanged",s),n.logger.log("languageChanged",s)):n.isLanguageChangingTo=void 0,r.resolve((function(){return n.t.apply(n,arguments)})),t&&t(e,(function(){return n.t.apply(n,arguments)}))}(e,a)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(e):s(this.services.languageDetector.detect()),r}},{key:"getFixedT",value:function(e,t,n){var r=this,i=function e(t,i){var s;if("object"!==pe(i)){for(var a=arguments.length,o=new Array(a>2?a-2:0),l=2;l<a;l++)o[l-2]=arguments[l];s=r.options.overloadTranslationOptionHandler([t,i].concat(o))}else s=bt({},i);s.lng=s.lng||e.lng,s.lngs=s.lngs||e.lngs,s.ns=s.ns||e.ns,s.keyPrefix=s.keyPrefix||n||e.keyPrefix;var c,u=r.options.keySeparator||".";return c=s.keyPrefix&&Array.isArray(t)?t.map((function(e){return"".concat(s.keyPrefix).concat(u).concat(e)})):s.keyPrefix?"".concat(s.keyPrefix).concat(u).concat(t):t,r.t(c,s)};return"string"==typeof e?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=n,i}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var r=this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,s=this.languages[this.languages.length-1];if("cimode"===r.toLowerCase())return!0;var a=function(e,n){var r=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===r||2===r};if(n.precheck){var o=n.precheck(this,a);if(void 0!==o)return o}return!(!this.hasResourceBundle(r,e)&&this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages)&&(!a(r,e)||i&&!a(s,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,r=Fe();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((function(e){n.options.ns.indexOf(e)<0&&n.options.ns.push(e)})),this.loadResources((function(e){r.resolve(),t&&t(e)})),r):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=Fe();"string"==typeof e&&(e=[e]);var r=this.options.preload||[],i=e.filter((function(e){return r.indexOf(e)<0}));return i.length?(this.options.preload=r.concat(i),this.loadResources((function(e){n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";var t=this.services&&this.services.languageUtils||new Je(gt());return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:vt,r=bt(bt(bt({},this.options),t),{isClone:!0}),s=new i(r);return void 0===t.debug&&void 0===t.prefix||(s.logger=s.logger.clone(t)),["store","services","language"].forEach((function(t){s[t]=e[t]})),s.services=bt({},this.services),s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s.translator=new Ge(s.services,s.options),s.translator.on("*",(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];s.emit.apply(s,[e].concat(n))})),s.init(r,n),s.translator.options=s.options,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),i}(Pe);ke(wt,"createInstance",(function(){return new wt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}));var St,Et=wt.createInstance();Et.createInstance=wt.createInstance,Et.createInstance,Et.dir,Et.init,Et.loadResources,Et.reloadResources,Et.use,Et.changeLanguage,Et.getFixedT,Et.t,Et.exists,Et.setDefaultNamespace,Et.hasLoadedNamespace,Et.loadNamespaces,Et.loadLanguages,function(e){e[e.bottom=0]="bottom",e[e.top=1]="top"}(St||(St={}));class xt{constructor({targetElement:e,nonFullscreenContainerClassName:t,nonFullscreenContentClassName:n,fullscreenContainerClassName:r,fullscreenContentClassName:i,offsetAnchor:s,contentPositionOffset:a}){this.domCache=new p,this.offsetAnchor=St.bottom,this.targetElement=e,this.nonFullscreenContainerClassName=t,this.nonFullscreenContentClassName=n,this.fullscreenContainerClassName=r,this.fullscreenContentClassName=i,this.offsetAnchor=s,this.contentPositionOffset=a??75}uncacheHtml(){this.domCache.clear()}cacheHtml(e,t){this.domCache.add(e,t)}setHtml(e){document.fullscreenElement?this._displayFullscreenContentElementsWithHtml(e):this._displayNonFullscreenContentElementsWithHtml(e)}_displayNonFullscreenContentElementsWithHtml(e){this._displayNonFullscreenContentElements(e.map((e=>this._cachedContentElement(e.html,e.key))))}_displayNonFullscreenContentElements(e){for(const t of e)t.className=this.nonFullscreenContentClassName;this._setChildren(this._nonFullscreenContainerElement(),e)}_displayFullscreenContentElementsWithHtml(e){this._displayFullscreenContentElements(e.map((e=>this._cachedContentElement(e.html,e.key))))}_displayFullscreenContentElements(e){for(const t of e)t.className=this.fullscreenContentClassName;this._setChildren(this._fullscreenContainerElement(),e)}_nonFullscreenContainerElement(){if(this.nonFullscreenContainerElement)return this.nonFullscreenContainerElement;const e=document.createElement("div");e.className=this.nonFullscreenContainerClassName,this._applyContainerStyles(e),document.body.appendChild(e);const t=()=>{document.fullscreenElement?e.style.display="none":(e.style.display="",this.fullscreenContainerElement&&this._transferChildren(this.fullscreenContainerElement,e))};return t(),this.nonFullscreenElementFullscreenChangeListener=e=>t(),this.nonFullscreenStylesInterval=setInterval((()=>this._applyContainerStyles(e)),1e3),this.nonFullscreenElementFullscreenPollingInterval=setInterval((()=>t()),1e3),document.addEventListener("fullscreenchange",this.nonFullscreenElementFullscreenChangeListener),this.nonFullscreenContainerElement=e,e}_fullscreenContainerElement(){if(this.fullscreenContainerElement)return this.fullscreenContainerElement;const e=document.createElement("div");e.className=this.fullscreenContainerClassName,this._applyContainerStyles(e),this._findFullscreenParentElement(e).appendChild(e),e.style.display="none";const t=this,n=()=>{document.fullscreenElement?("none"===e.style.display&&(e.style.display="",e.remove(),t._findFullscreenParentElement(e).appendChild(e)),this.nonFullscreenContainerElement&&this._transferChildren(this.nonFullscreenContainerElement,e)):document.fullscreenElement||(e.style.display="none")};return n(),this.fullscreenElementFullscreenChangeListener=e=>n(),this.fullscreenStylesInterval=setInterval((()=>this._applyContainerStyles(e)),1e3),this.fullscreenElementFullscreenPollingInterval=setInterval((()=>n()),1e3),document.addEventListener("fullscreenchange",this.fullscreenElementFullscreenChangeListener),this.fullscreenContainerElement=e,this.fullscreenContainerElement}_findFullscreenParentElement(e){const t=e.cloneNode(!0);t.innerHTML="&nbsp;";let n,r=this.targetElement.parentElement;if(!r)return document.body;do{const e=r.getBoundingClientRect();if(e.height>0&&(void 0===n||e.height>=n.getBoundingClientRect().height)&&this._clickable(r,t)){n=r;break}r=r.parentElement}while(r&&!r.isSameNode(document.body.parentElement));return n||document.body}_transferChildren(e,t){if(e)for(;e.firstChild;)t.appendChild(e.firstChild)}_setChildren(e,t){for(;e.firstChild;)this.domCache.return(e.lastChild);for(const n of t)e.appendChild(n)}_cachedContentElement(e,t){return void 0===t?(this.defaultContentElement||(this.defaultContentElement=document.createElement("div")),this.defaultContentElement.innerHTML=e(),this.defaultContentElement):this.domCache.get(t,e)}appendHtml(e){document.fullscreenElement?this._appendHtml(`${e}\n`,this.fullscreenContentClassName,this._fullscreenContainerElement()):this._appendHtml(`${e}\n`,this.nonFullscreenContentClassName,this._nonFullscreenContainerElement())}_appendHtml(e,t,n){const r=document.createElement("br"),i=document.createElement("div");i.innerHTML=e,i.className=t,n.appendChild(r),n.appendChild(i)}refresh(){this.fullscreenContainerElement&&this._applyContainerStyles(this.fullscreenContainerElement),this.nonFullscreenContainerElement&&this._applyContainerStyles(this.nonFullscreenContainerElement)}hide(){this.nonFullscreenElementFullscreenChangeListener&&document.removeEventListener("fullscreenchange",this.nonFullscreenElementFullscreenChangeListener),this.nonFullscreenStylesInterval&&clearInterval(this.nonFullscreenStylesInterval),this.nonFullscreenElementFullscreenPollingInterval&&clearInterval(this.nonFullscreenElementFullscreenPollingInterval),this.fullscreenElementFullscreenChangeListener&&document.removeEventListener("fullscreenchange",this.fullscreenElementFullscreenChangeListener),this.fullscreenStylesInterval&&clearInterval(this.fullscreenStylesInterval),this.fullscreenElementFullscreenPollingInterval&&clearInterval(this.fullscreenElementFullscreenPollingInterval),this.defaultContentElement?.remove(),this.defaultContentElement=void 0,this.nonFullscreenContainerElement?.remove(),this.nonFullscreenContainerElement=void 0,this.fullscreenContainerElement?.remove(),this.fullscreenContainerElement=void 0}_applyContainerStyles(e){const t=this.targetElement.getBoundingClientRect();e.style.left=t.left+t.width/2+"px",e.style.maxWidth=t.width+"px",this.offsetAnchor===St.bottom?(e.style.top=t.top+t.height+window.scrollY-this.contentPositionOffset+"px",e.style.bottom=""):(e.style.top=t.top+window.scrollY+this.contentPositionOffset+"px",e.style.bottom="")}_clickable(e,t){e.appendChild(t);const n=t.getBoundingClientRect(),r=document.elementFromPoint(n.x,n.y),i=t.isSameNode(r)||t.contains(r);return t.remove(),i}dispose(){this.hide(),this.domCache.clear()}}class kt{constructor({targetElement:e,nonFullscreenContainerClassName:t,nonFullscreenContentClassName:n,fullscreenContainerClassName:r,fullscreenContentClassName:i,offsetAnchor:s,contentPositionOffset:a}){this.offsetAnchor=St.bottom,this.targetElement=e,this.nonFullscreenContainerClassName=t,this.nonFullscreenContentClassName=n,this.fullscreenContainerClassName=r,this.fullscreenContentClassName=i,this.offsetAnchor=s,this.contentPositionOffset=a??75}uncacheHtml(){}cacheHtml(e,t){}setHtml(e){const t=`${e.map((e=>e.html())).join("\n")}\n`;this._nonFullscreenContentElement().innerHTML=t,this._fullscreenContentElement().innerHTML=t}appendHtml(e){const t=this._nonFullscreenContentElement().innerHTML,n=t&&t.length>0?t+"<br>"+e:e;this._nonFullscreenContentElement().innerHTML=`${n}\n`,this._fullscreenContentElement().innerHTML=`${n}\n`}refresh(){this.fullscreenContainerElement&&this._applyContainerStyles(this.fullscreenContainerElement),this.nonFullscreenContainerElement&&this._applyContainerStyles(this.nonFullscreenContainerElement)}hide(){this.nonFullscreenContentElement&&(this.nonFullscreenElementFullscreenChangeListener&&document.removeEventListener("fullscreenchange",this.nonFullscreenElementFullscreenChangeListener),this.nonFullscreenStylesInterval&&clearInterval(this.nonFullscreenStylesInterval),this.nonFullscreenElementFullscreenPollingInterval&&clearInterval(this.nonFullscreenElementFullscreenPollingInterval),this.nonFullscreenContentElement.remove(),this.nonFullscreenContainerElement?.remove(),this.nonFullscreenContainerElement=void 0,this.nonFullscreenContentElement=void 0),this.fullscreenContentElement&&(this.fullscreenElementFullscreenChangeListener&&document.removeEventListener("fullscreenchange",this.fullscreenElementFullscreenChangeListener),this.fullscreenStylesInterval&&clearInterval(this.fullscreenStylesInterval),this.fullscreenElementFullscreenPollingInterval&&clearInterval(this.fullscreenElementFullscreenPollingInterval),this.fullscreenContentElement.remove(),this.fullscreenContainerElement?.remove(),this.fullscreenContainerElement=void 0,this.fullscreenContentElement=void 0)}_nonFullscreenContentElement(){if(this.nonFullscreenContentElement)return this.nonFullscreenContentElement;const e=document.createElement("div"),t=document.createElement("div");function n(){document.fullscreenElement?t.style.display="none":t.style.display=""}return t.appendChild(e),t.className=this.nonFullscreenContainerClassName,e.className=this.nonFullscreenContentClassName,this._applyContainerStyles(t),document.body.appendChild(t),n(),this.nonFullscreenElementFullscreenChangeListener=e=>n(),this.nonFullscreenStylesInterval=setInterval((()=>this._applyContainerStyles(t)),1e3),this.nonFullscreenElementFullscreenPollingInterval=setInterval((()=>n()),1e3),document.addEventListener("fullscreenchange",this.nonFullscreenElementFullscreenChangeListener),this.nonFullscreenContentElement=e,this.nonFullscreenContainerElement=t,this.nonFullscreenContentElement}_applyContainerStyles(e){const t=this.targetElement.getBoundingClientRect();e.style.left=t.left+t.width/2+"px",e.style.maxWidth=t.width+"px",this.offsetAnchor===St.bottom?(e.style.top=t.top+t.height+window.scrollY-this.contentPositionOffset+"px",e.style.bottom=""):(e.style.top=t.top+window.scrollY+this.contentPositionOffset+"px",e.style.bottom="")}_fullscreenContentElement(){if(this.fullscreenContentElement)return this.fullscreenContentElement;const e=document.createElement("div"),t=document.createElement("div");t.appendChild(e),t.className=this.fullscreenContainerClassName,e.className=this.fullscreenContentClassName,this._applyContainerStyles(t),this._findFullscreenParentElement(t).appendChild(t),t.style.display="none";const n=this;function r(){document.fullscreenElement&&"none"===t.style.display?(t.style.display="",t.remove(),n._findFullscreenParentElement(t).appendChild(t)):document.fullscreenElement||(t.style.display="none")}return r(),this.fullscreenElementFullscreenChangeListener=e=>r(),this.fullscreenStylesInterval=setInterval((()=>this._applyContainerStyles(t)),1e3),this.fullscreenElementFullscreenPollingInterval=setInterval((()=>r()),1e3),document.addEventListener("fullscreenchange",this.fullscreenElementFullscreenChangeListener),this.fullscreenContentElement=e,this.fullscreenContainerElement=t,this.fullscreenContentElement}_findFullscreenParentElement(e){const t=e.cloneNode(!0);t.innerHTML="&nbsp;";let n,r=this.targetElement.parentElement;if(!r)return document.body;do{const e=r.getBoundingClientRect();if(e.height>0&&(void 0===n||e.height>=n.getBoundingClientRect().height)&&this._clickable(r,t)){n=r;break}r=r.parentElement}while(r&&!r.isSameNode(document.body.parentElement));return n||document.body}_clickable(e,t){e.appendChild(t);const n=t.getBoundingClientRect(),r=document.elementFromPoint(n.x,n.y),i=t.isSameNode(r)||t.contains(r);return t.remove(),i}dispose(){this.hide()}}class Ot{constructor(e,t){this.autoPauseContext=new f,this.video=e,this.settings=t,this._subtitleAlignment="bottom",this._preCacheDom=!1;const{subtitlesElementOverlay:n,notificationElementOverlay:r}=this._overlays(this._subtitleAlignment,this._preCacheDom);this.subtitlesElementOverlay=n,this.notificationElementOverlay=r,this._subtitles=[],this.subtitleCollection=new fe([]),this.showingSubtitles=[],this.disabledSubtitleTracks={},this._forceHideSubtitles=!1,this._displaySubtitles=!0,this.lastLoadedMessageTimestamp=0,this.lastOffsetChangeTimestamp=0,this.showingOffset=void 0,this.surroundingSubtitlesCountRadius=1,this.surroundingSubtitlesTimeRadius=5e3,this.showingLoadedMessage=!1,this.autoCopyCurrentSubtitle=!1}get subtitles(){return this._subtitles}set subtitles(e){this._subtitles=e,this.subtitleCollection=new fe(e,{showingCheckRadiusMs:150,returnNextToShow:!0}),this.autoPauseContext.clear()}get preCacheDom(){return this._preCacheDom}set preCacheDom(e){this._preCacheDom!==e&&(this._resetOverlays(this._subtitleAlignment,e),this._preCacheDom=e)}cacheHtml(){if(!(this.subtitlesElementOverlay instanceof xt))return;this.subtitlesElementOverlay.uncacheHtml();const e=this._buildSubtitlesHtml(this.subtitles);for(const t of e)this.subtitlesElementOverlay.cacheHtml(t.key,t.html())}set subtitlePositionOffset(e){this.subtitlesElementOverlay.contentPositionOffset=e}setSubtitleSettings(e){const t=o(e);t!==this.subtitleStyles&&(this.subtitleStyles=t,this.cacheHtml()),this.subtitleSettings=e}set subtitleAlignment(e){if(this._subtitleAlignment===e)return;const{subtitleOverlayParams:t,notificationOverlayParams:n}=this._elementOverlayParams(e);this._applyElementOverlayParams(this.subtitlesElementOverlay,t),this._applyElementOverlayParams(this.notificationElementOverlay,n),this.subtitlesElementOverlay.hide(),this.notificationElementOverlay.hide(),this._subtitleAlignment=e}_applyElementOverlayParams(e,t){e.offsetAnchor=t.offsetAnchor,e.fullscreenContainerClassName=t.fullscreenContainerClassName,e.fullscreenContentClassName=t.fullscreenContentClassName,e.nonFullscreenContainerClassName=t.nonFullscreenContainerClassName,e.nonFullscreenContentClassName=t.nonFullscreenContentClassName}set displaySubtitles(e){this._displaySubtitles=e,this.showingSubtitles=void 0}set forceHideSubtitles(e){this._forceHideSubtitles=e,this.showingSubtitles=void 0}_resetOverlays(e,t,n=!1){this.subtitlesElementOverlay.dispose(),this.notificationElementOverlay.dispose();const{subtitlesElementOverlay:r,notificationElementOverlay:i}=this._overlays(e,t);r.contentPositionOffset=this.subtitlesElementOverlay.contentPositionOffset,i.contentPositionOffset=this.notificationElementOverlay.contentPositionOffset,this.subtitlesElementOverlay=r,this.notificationElementOverlay=i,n||this.cacheHtml()}_overlays(e,t){const{subtitleOverlayParams:n,notificationOverlayParams:r}=this._elementOverlayParams(e);return t?{subtitlesElementOverlay:new xt(n),notificationElementOverlay:new xt(r)}:{subtitlesElementOverlay:new kt(n),notificationElementOverlay:new kt(r)}}_elementOverlayParams(e){let t,n;switch(e){case"bottom":t={targetElement:this.video,nonFullscreenContainerClassName:"asbplayer-subtitles-container-bottom",nonFullscreenContentClassName:"asbplayer-subtitles",fullscreenContainerClassName:"asbplayer-subtitles-container-bottom",fullscreenContentClassName:"asbplayer-fullscreen-subtitles",offsetAnchor:St.bottom},n={targetElement:this.video,nonFullscreenContainerClassName:"asbplayer-notification-container-top",nonFullscreenContentClassName:"asbplayer-notification",fullscreenContainerClassName:"asbplayer-notification-container-top",fullscreenContentClassName:"asbplayer-notification",offsetAnchor:St.top};break;case"top":t={targetElement:this.video,nonFullscreenContainerClassName:"asbplayer-subtitles-container-top",nonFullscreenContentClassName:"asbplayer-subtitles",fullscreenContainerClassName:"asbplayer-subtitles-container-top",fullscreenContentClassName:"asbplayer-fullscreen-subtitles",offsetAnchor:St.top},n={targetElement:this.video,nonFullscreenContainerClassName:"asbplayer-notification-container-bottom",nonFullscreenContentClassName:"asbplayer-notification",fullscreenContainerClassName:"asbplayer-notification-container-bottom",fullscreenContentClassName:"asbplayer-notification",offsetAnchor:St.bottom}}return{subtitleOverlayParams:t,notificationOverlayParams:n}}bind(){this.subtitlesInterval=setInterval((()=>{if(this.lastLoadedMessageTimestamp>0&&Date.now()-this.lastLoadedMessageTimestamp<1e3)return;if(this.showingLoadedMessage&&(this._setSubtitlesHtml([{html:()=>""}]),this.showingLoadedMessage=!1),0===this.subtitles.length)return;const e=this.lastOffsetChangeTimestamp>0&&Date.now()-this.lastOffsetChangeTimestamp<1e3,t=e?this._computeOffset():0,n=1e3*this.video.currentTime;let r=[];const i=this.subtitleCollection.subtitlesAt(n);r=i.showing.filter((e=>this._trackEnabled(e))).sort(((e,t)=>e.track-t.track)),this.onSlice?.(i),i.willStopShowing&&this._trackEnabled(i.willStopShowing)&&this.autoPauseContext.willStopShowing(i.willStopShowing),i.startedShowing&&this._trackEnabled(i.startedShowing)&&this.autoPauseContext.startedShowing(i.startedShowing),i.nextToShow&&i.nextToShow.length>0&&this.onNextToShow?.(i.nextToShow[0]);const s=void 0===this.showingSubtitles||!this._arrayEquals(r,this.showingSubtitles,((e,t)=>e.index===t.index));s&&(this.showingSubtitles=r,this._autoCopyToClipboard(r));const a=e&&t!==this.showingOffset||!e&&void 0!==this.showingOffset;!e&&!this._displaySubtitles||this._forceHideSubtitles?this.subtitlesElementOverlay.hide():(s||a)&&(this._renderSubtitles(r),e?(this._appendSubtitlesHtml(this._buildTextHtml(this._formatOffset(t))),this.showingOffset=t):this.showingOffset=void 0)}),100)}_renderSubtitles(e){this._setSubtitlesHtml(this._buildSubtitlesHtml(e))}_autoCopyToClipboard(e){if(this.autoCopyCurrentSubtitle&&e.length>0&&document.hasFocus()){const t=e.map((e=>e.text)).filter((e=>""!==e)).join("\n");if(""!==t){const e={sender:"asbplayer-video",message:{command:"copy-to-clipboard",dataUrl:`data:,${encodeURIComponent(t)}`},src:this.video.src};chrome.runtime.sendMessage(e)}}}_trackEnabled(e){return void 0===e.track||!this.disabledSubtitleTracks[e.track]}_buildSubtitlesHtml(e){return e.map((e=>({html:()=>e.textImage?`\n<div style="max-width:${(this.subtitleSettings?.imageBasedSubtitleScaleFactor??1)*this.video.getBoundingClientRect().width/e.textImage.screen.width*e.textImage.image.width}px;">\n <img\n style="width:100%;"\n alt="subtitle"\n src="${e.textImage.dataUrl}"\n />\n</div>\n`:this._buildTextHtml(e.text),key:String(e.index)})))}_buildTextHtml(e){return`<span style="${this._subtitleStyles()}">${e}</span>`}unbind(){this.subtitlesInterval&&(clearInterval(this.subtitlesInterval),this.subtitlesInterval=void 0),this.notificationElementOverlayHideTimeout&&(clearTimeout(this.notificationElementOverlayHideTimeout),this.notificationElementOverlayHideTimeout=void 0),this.subtitlesElementOverlay.dispose(),this.notificationElementOverlay.dispose()}refresh(){this.subtitlesElementOverlay.refresh(),this.notificationElementOverlay.refresh()}currentSubtitle(){const e=1e3*this.video.currentTime;let n=null,r=null;for(let t=0;t<this.subtitles.length;++t){const i=this.subtitles[t];if(e>=i.start&&e<i.end&&(void 0===i.track||!this.disabledSubtitleTracks[i.track])){n=i,r=t;break}}return null===n||null===r?[null,null]:[n,t(this.subtitles,r,this.surroundingSubtitlesCountRadius,this.surroundingSubtitlesTimeRadius)]}offset(e,t=!1){if(this.subtitles&&0!==this.subtitles.length){if(this.subtitles=this.subtitles.map((t=>({text:t.text,textImage:t.textImage,start:t.originalStart+e,originalStart:t.originalStart,end:t.originalEnd+e,originalEnd:t.originalEnd,track:t.track,index:t.index}))),this.lastOffsetChangeTimestamp=Date.now(),!t){const t={sender:"asbplayer-video",message:{command:"offset",value:e},src:this.video.src};chrome.runtime.sendMessage(t)}this.settings.getSingle("rememberSubtitleOffset").then((t=>{t&&this.settings.set({lastSubtitleOffset:e})}))}}_computeOffset(){if(!this.subtitles||0===this.subtitles.length)return 0;const e=this.subtitles[0];return e.start-e.originalStart}_formatOffset(e){const t=Math.floor(e);return t>=0?"+"+t+" ms":t+" ms"}notification(e,t){const n=Et.t(e,t??{});this.notificationElementOverlay.setHtml([{html:()=>this._buildTextHtml(n)}]),this.notificationElementOverlayHideTimeout&&clearTimeout(this.notificationElementOverlayHideTimeout),this.notificationElementOverlayHideTimeout=setTimeout((()=>{this.notificationElementOverlay.hide(),this.notificationElementOverlayHideTimeout=void 0}),3e3)}showLoadedMessage(e){if(!this.subtitleFileNames)return;let t;const n=this._nonEmptySubtitleNames(e);if(t=0===n.length?this.subtitleFileNames[0]:n.join("<br>"),this.subtitles.length>0){const e=this.subtitles[0].start-this.subtitles[0].originalStart;0!==e&&(t+=`<br>${this._formatOffset(e)}`)}this._setSubtitlesHtml([{html:()=>this._buildTextHtml(t)}]),this.showingLoadedMessage=!0,this.lastLoadedMessageTimestamp=Date.now()}_nonEmptySubtitleNames(e){if(0===e.length)return[];const t=[];for(let n=0;n<e.length;n++)t.push(this.subtitleFileNames[e[n]]);return t}_setSubtitlesHtml(e){this.subtitlesElementOverlay.setHtml(e)}_appendSubtitlesHtml(e){this.subtitlesElementOverlay.appendHtml(e)}_subtitleStyles(){return this.subtitleStyles?this.subtitleStyles:this.subtitleSettings?(this.subtitleStyles=o(this.subtitleSettings),this.subtitleStyles):""}_arrayEquals(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!n(e[r],t[r]))return!1;return!0}}function _t(e){let t="";const n=new Uint8Array(e),r=n.byteLength;for(let e=0;e<r;++e)t+=String.fromCharCode(n[e]);return window.btoa(t)}const Ct=JSON.parse('{"L":[{"host":"www\\\\.netflix\\\\.com","script":"netflix-page.js","path":"watch","autoSync":{"enabled":true}},{"host":"www\\\\.youtube\\\\.com","script":"youtube-page.js","path":"watch","autoSync":{"enabled":true}},{"host":"tver\\\\.jp","script":"tver-page.js","path":"episodes","autoSync":{"enabled":true}},{"host":"www\\\\.b-ch\\\\.com","script":"bandai-channel-page.js","path":"titles","autoSync":{"enabled":true}},{"host":"www\\\\.amazon\\\\..+","script":"amazon-prime-page.js","path":".*","autoSync":{"enabled":true,"videoSrc":"^blob:.+"},"ignore":{"class":"tst-video-overlay-player-html5","style":{"display":"none"}}},{"host":"www\\\\.hulu\\\\..+","script":"hulu-page.js","path":"watch","autoSync":{"enabled":true,"elementId":"content-video-player"}},{"host":"www\\\\.disneyplus\\\\..+","script":"disney-plus-page.js","path":"video","autoSync":{"enabled":true}},{"host":"video.unext.jp","script":"unext-page.js","path":"play","autoSync":{"enabled":false}}]}');function Tt(){const e=new URL(window.location.href);for(const t of Ct.L)if(new RegExp(t.host).test(e.host))return new At(t,e)}class At{constructor(e,t){this.config=e,this.url=t}loadScripts(){const e=document.createElement("script");e.src=chrome.runtime.getURL(`pages/${this.config.script}`),e.onload=()=>e.remove(),(document.head||document.documentElement).appendChild(e)}shouldIgnore(e){if(void 0===this.config.ignore)return!1;if(void 0!==this.config.ignore.class&&e.classList.contains(this.config.ignore.class))return!0;if(void 0!==this.config.ignore.style)for(const t of Object.keys(this.config.ignore.style))if(e.style[t]===this.config.ignore.style[t])return!0;return!1}canAutoSync(e){return this.config.autoSync.enabled&&(void 0===this.config.autoSync.elementId||e.id===this.config.autoSync.elementId)&&(void 0===this.config.autoSync.videoSrc||new RegExp(this.config.autoSync.videoSrc).test(e.src))}isVideoPage(){return new RegExp(this.config.path).test(this.url.pathname)}}var Pt=function(){function e(){this.listeners={}}var t=e.prototype;return t.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},t.off=function(e,t){if(!this.listeners[e])return!1;var n=this.listeners[e].indexOf(t);return this.listeners[e]=this.listeners[e].slice(0),this.listeners[e].splice(n,1),n>-1},t.trigger=function(e){var t=this.listeners[e];if(t)if(2===arguments.length)for(var n=t.length,r=0;r<n;++r)t[r].call(this,arguments[1]);else for(var i=Array.prototype.slice.call(arguments,1),s=t.length,a=0;a<s;++a)t[a].apply(this,i)},t.dispose=function(){this.listeners={}},t.pipe=function(e){this.on("data",(function(t){e.push(t)}))},e}();function Ft(){return Ft=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ft.apply(this,arguments)}var Nt=n(3452),Lt=n.n(Nt);function Rt(e){for(var t,n=(t=e,Lt().atob?Lt().atob(t):Buffer.from(t,"base64").toString("binary")),r=new Uint8Array(n.length),i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r}class It extends Pt{constructor(){super(),this.buffer=""}push(e){let t;for(this.buffer+=e,t=this.buffer.indexOf("\n");t>-1;t=this.buffer.indexOf("\n"))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}}const jt=String.fromCharCode(9),Mt=function(e){const t=/([0-9.]*)?@?([0-9.]*)?/.exec(e||""),n={};return t[1]&&(n.length=parseInt(t[1],10)),t[2]&&(n.offset=parseInt(t[2],10)),n},Dt=function(e){const t={};if(!e)return t;const n=e.split(new RegExp('(?:^|,)((?:[^=]*)=(?:"[^"]*"|[^,]*))'));let r,i=n.length;for(;i--;)""!==n[i]&&(r=/([^=]*)=(.*)/.exec(n[i]).slice(1),r[0]=r[0].replace(/^\s+|\s+$/g,""),r[1]=r[1].replace(/^\s+|\s+$/g,""),r[1]=r[1].replace(/^['"](.*)['"]$/g,"$1"),t[r[0]]=r[1]);return t};class $t extends Pt{constructor(){super(),this.customParsers=[],this.tagMappers=[]}push(e){let t,n;0!==(e=e.trim()).length&&("#"===e[0]?this.tagMappers.reduce(((t,n)=>{const r=n(e);return r===e?t:t.concat([r])}),[e]).forEach((e=>{for(let t=0;t<this.customParsers.length;t++)if(this.customParsers[t].call(this,e))return;if(0===e.indexOf("#EXT"))if(e=e.replace("\r",""),t=/^#EXTM3U/.exec(e),t)this.trigger("data",{type:"tag",tagType:"m3u"});else{if(t=/^#EXTINF:([0-9\.]*)?,?(.*)?$/.exec(e),t)return n={type:"tag",tagType:"inf"},t[1]&&(n.duration=parseFloat(t[1])),t[2]&&(n.title=t[2]),void this.trigger("data",n);if(t=/^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(e),t)return n={type:"tag",tagType:"targetduration"},t[1]&&(n.duration=parseInt(t[1],10)),void this.trigger("data",n);if(t=/^#EXT-X-VERSION:([0-9.]*)?/.exec(e),t)return n={type:"tag",tagType:"version"},t[1]&&(n.version=parseInt(t[1],10)),void this.trigger("data",n);if(t=/^#EXT-X-MEDIA-SEQUENCE:(\-?[0-9.]*)?/.exec(e),t)return n={type:"tag",tagType:"media-sequence"},t[1]&&(n.number=parseInt(t[1],10)),void this.trigger("data",n);if(t=/^#EXT-X-DISCONTINUITY-SEQUENCE:(\-?[0-9.]*)?/.exec(e),t)return n={type:"tag",tagType:"discontinuity-sequence"},t[1]&&(n.number=parseInt(t[1],10)),void this.trigger("data",n);if(t=/^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(e),t)return n={type:"tag",tagType:"playlist-type"},t[1]&&(n.playlistType=t[1]),void this.trigger("data",n);if(t=/^#EXT-X-BYTERANGE:(.*)?$/.exec(e),t)return n=Ft(Mt(t[1]),{type:"tag",tagType:"byterange"}),void this.trigger("data",n);if(t=/^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(e),t)return n={type:"tag",tagType:"allow-cache"},t[1]&&(n.allowed=!/NO/.test(t[1])),void this.trigger("data",n);if(t=/^#EXT-X-MAP:(.*)$/.exec(e),t){if(n={type:"tag",tagType:"map"},t[1]){const e=Dt(t[1]);e.URI&&(n.uri=e.URI),e.BYTERANGE&&(n.byterange=Mt(e.BYTERANGE))}this.trigger("data",n)}else if(t=/^#EXT-X-STREAM-INF:(.*)$/.exec(e),t){if(n={type:"tag",tagType:"stream-inf"},t[1]){if(n.attributes=Dt(t[1]),n.attributes.RESOLUTION){const e=n.attributes.RESOLUTION.split("x"),t={};e[0]&&(t.width=parseInt(e[0],10)),e[1]&&(t.height=parseInt(e[1],10)),n.attributes.RESOLUTION=t}n.attributes.BANDWIDTH&&(n.attributes.BANDWIDTH=parseInt(n.attributes.BANDWIDTH,10)),n.attributes["FRAME-RATE"]&&(n.attributes["FRAME-RATE"]=parseFloat(n.attributes["FRAME-RATE"])),n.attributes["PROGRAM-ID"]&&(n.attributes["PROGRAM-ID"]=parseInt(n.attributes["PROGRAM-ID"],10))}this.trigger("data",n)}else{if(t=/^#EXT-X-MEDIA:(.*)$/.exec(e),t)return n={type:"tag",tagType:"media"},t[1]&&(n.attributes=Dt(t[1])),void this.trigger("data",n);if(t=/^#EXT-X-ENDLIST/.exec(e),t)this.trigger("data",{type:"tag",tagType:"endlist"});else if(t=/^#EXT-X-DISCONTINUITY/.exec(e),t)this.trigger("data",{type:"tag",tagType:"discontinuity"});else{if(t=/^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(e),t)return n={type:"tag",tagType:"program-date-time"},t[1]&&(n.dateTimeString=t[1],n.dateTimeObject=new Date(t[1])),void this.trigger("data",n);if(t=/^#EXT-X-KEY:(.*)$/.exec(e),t)return n={type:"tag",tagType:"key"},t[1]&&(n.attributes=Dt(t[1]),n.attributes.IV&&("0x"===n.attributes.IV.substring(0,2).toLowerCase()&&(n.attributes.IV=n.attributes.IV.substring(2)),n.attributes.IV=n.attributes.IV.match(/.{8}/g),n.attributes.IV[0]=parseInt(n.attributes.IV[0],16),n.attributes.IV[1]=parseInt(n.attributes.IV[1],16),n.attributes.IV[2]=parseInt(n.attributes.IV[2],16),n.attributes.IV[3]=parseInt(n.attributes.IV[3],16),n.attributes.IV=new Uint32Array(n.attributes.IV))),void this.trigger("data",n);if(t=/^#EXT-X-START:(.*)$/.exec(e),t)return n={type:"tag",tagType:"start"},t[1]&&(n.attributes=Dt(t[1]),n.attributes["TIME-OFFSET"]=parseFloat(n.attributes["TIME-OFFSET"]),n.attributes.PRECISE=/YES/.test(n.attributes.PRECISE)),void this.trigger("data",n);if(t=/^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(e),t)return n={type:"tag",tagType:"cue-out-cont"},t[1]?n.data=t[1]:n.data="",void this.trigger("data",n);if(t=/^#EXT-X-CUE-OUT:(.*)?$/.exec(e),t)return n={type:"tag",tagType:"cue-out"},t[1]?n.data=t[1]:n.data="",void this.trigger("data",n);if(t=/^#EXT-X-CUE-IN:(.*)?$/.exec(e),t)return n={type:"tag",tagType:"cue-in"},t[1]?n.data=t[1]:n.data="",void this.trigger("data",n);if(t=/^#EXT-X-SKIP:(.*)$/.exec(e),t&&t[1])return n={type:"tag",tagType:"skip"},n.attributes=Dt(t[1]),n.attributes.hasOwnProperty("SKIPPED-SEGMENTS")&&(n.attributes["SKIPPED-SEGMENTS"]=parseInt(n.attributes["SKIPPED-SEGMENTS"],10)),n.attributes.hasOwnProperty("RECENTLY-REMOVED-DATERANGES")&&(n.attributes["RECENTLY-REMOVED-DATERANGES"]=n.attributes["RECENTLY-REMOVED-DATERANGES"].split(jt)),void this.trigger("data",n);if(t=/^#EXT-X-PART:(.*)$/.exec(e),t&&t[1])return n={type:"tag",tagType:"part"},n.attributes=Dt(t[1]),["DURATION"].forEach((function(e){n.attributes.hasOwnProperty(e)&&(n.attributes[e]=parseFloat(n.attributes[e]))})),["INDEPENDENT","GAP"].forEach((function(e){n.attributes.hasOwnProperty(e)&&(n.attributes[e]=/YES/.test(n.attributes[e]))})),n.attributes.hasOwnProperty("BYTERANGE")&&(n.attributes.byterange=Mt(n.attributes.BYTERANGE)),void this.trigger("data",n);if(t=/^#EXT-X-SERVER-CONTROL:(.*)$/.exec(e),t&&t[1])return n={type:"tag",tagType:"server-control"},n.attributes=Dt(t[1]),["CAN-SKIP-UNTIL","PART-HOLD-BACK","HOLD-BACK"].forEach((function(e){n.attributes.hasOwnProperty(e)&&(n.attributes[e]=parseFloat(n.attributes[e]))})),["CAN-SKIP-DATERANGES","CAN-BLOCK-RELOAD"].forEach((function(e){n.attributes.hasOwnProperty(e)&&(n.attributes[e]=/YES/.test(n.attributes[e]))})),void this.trigger("data",n);if(t=/^#EXT-X-PART-INF:(.*)$/.exec(e),t&&t[1])return n={type:"tag",tagType:"part-inf"},n.attributes=Dt(t[1]),["PART-TARGET"].forEach((function(e){n.attributes.hasOwnProperty(e)&&(n.attributes[e]=parseFloat(n.attributes[e]))})),void this.trigger("data",n);if(t=/^#EXT-X-PRELOAD-HINT:(.*)$/.exec(e),t&&t[1])return n={type:"tag",tagType:"preload-hint"},n.attributes=Dt(t[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach((function(e){if(n.attributes.hasOwnProperty(e)){n.attributes[e]=parseInt(n.attributes[e],10);const t="BYTERANGE-LENGTH"===e?"length":"offset";n.attributes.byterange=n.attributes.byterange||{},n.attributes.byterange[t]=n.attributes[e],delete n.attributes[e]}})),void this.trigger("data",n);if(t=/^#EXT-X-RENDITION-REPORT:(.*)$/.exec(e),t&&t[1])return n={type:"tag",tagType:"rendition-report"},n.attributes=Dt(t[1]),["LAST-MSN","LAST-PART"].forEach((function(e){n.attributes.hasOwnProperty(e)&&(n.attributes[e]=parseInt(n.attributes[e],10))})),void this.trigger("data",n);this.trigger("data",{type:"tag",data:e.slice(4)})}}}else this.trigger("data",{type:"comment",text:e.slice(1)})})):this.trigger("data",{type:"uri",uri:e}))}addParser({expression:e,customType:t,dataParser:n,segment:r}){"function"!=typeof n&&(n=e=>e),this.customParsers.push((i=>{if(e.exec(i))return this.trigger("data",{type:"custom",data:n(i),customType:t,segment:r}),!0}))}addTagMapper({expression:e,map:t}){this.tagMappers.push((n=>e.test(n)?t(n):n))}}const Bt=function(e){const t={};return Object.keys(e).forEach((function(n){var r;t[(r=n,r.toLowerCase().replace(/-(\w)/g,(e=>e[1].toUpperCase())))]=e[n]})),t},Ut=function(e){const{serverControl:t,targetDuration:n,partTargetDuration:r}=e;if(!t)return;const i="#EXT-X-SERVER-CONTROL",s="holdBack",a="partHoldBack",o=n&&3*n,l=r&&2*r;n&&!t.hasOwnProperty(s)&&(t[s]=o,this.trigger("info",{message:`${i} defaulting HOLD-BACK to targetDuration * 3 (${o}).`})),o&&t[s]<o&&(this.trigger("warn",{message:`${i} clamping HOLD-BACK (${t[s]}) to targetDuration * 3 (${o})`}),t[s]=o),r&&!t.hasOwnProperty(a)&&(t[a]=3*r,this.trigger("info",{message:`${i} defaulting PART-HOLD-BACK to partTargetDuration * 3 (${t[a]}).`})),r&&t[a]<l&&(this.trigger("warn",{message:`${i} clamping PART-HOLD-BACK (${t[a]}) to partTargetDuration * 2 (${l}).`}),t[a]=l)};class Vt extends Pt{constructor(){super(),this.lineStream=new It,this.parseStream=new $t,this.lineStream.pipe(this.parseStream);const e=this,t=[];let n,r,i={},s=!1;const a=function(){},o={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}};let l=0;this.manifest={allowCache:!0,discontinuityStarts:[],segments:[]};let c=0,u=0;this.on("end",(()=>{i.uri||!i.parts&&!i.preloadHints||(!i.map&&n&&(i.map=n),!i.key&&r&&(i.key=r),i.timeline||"number"!=typeof l||(i.timeline=l),this.manifest.preloadSegment=i)})),this.parseStream.on("data",(function(h){let d,f;({tag(){({version(){h.version&&(this.manifest.version=h.version)},"allow-cache"(){this.manifest.allowCache=h.allowed,"allowed"in h||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange(){const e={};"length"in h&&(i.byterange=e,e.length=h.length,"offset"in h||(h.offset=c)),"offset"in h&&(i.byterange=e,e.offset=h.offset),c=e.offset+e.length},endlist(){this.manifest.endList=!0},inf(){"mediaSequence"in this.manifest||(this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"})),"discontinuitySequence"in this.manifest||(this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"})),h.duration>0&&(i.duration=h.duration),0===h.duration&&(i.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=t},key(){if(h.attributes)if("NONE"!==h.attributes.METHOD)if(h.attributes.URI){if("com.apple.streamingkeydelivery"===h.attributes.KEYFORMAT)return this.manifest.contentProtection=this.manifest.contentProtection||{},void(this.manifest.contentProtection["com.apple.fps.1_0"]={attributes:h.attributes});if("com.microsoft.playready"===h.attributes.KEYFORMAT)return this.manifest.contentProtection=this.manifest.contentProtection||{},void(this.manifest.contentProtection["com.microsoft.playready"]={uri:h.attributes.URI});if("urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"===h.attributes.KEYFORMAT)return-1===["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(h.attributes.METHOD)?void this.trigger("warn",{message:"invalid key method provided for Widevine"}):("SAMPLE-AES-CENC"===h.attributes.METHOD&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),"data:text/plain;base64,"!==h.attributes.URI.substring(0,23)?void this.trigger("warn",{message:"invalid key URI provided for Widevine"}):h.attributes.KEYID&&"0x"===h.attributes.KEYID.substring(0,2)?(this.manifest.contentProtection=this.manifest.contentProtection||{},void(this.manifest.contentProtection["com.widevine.alpha"]={attributes:{schemeIdUri:h.attributes.KEYFORMAT,keyId:h.attributes.KEYID.substring(2)},pssh:Rt(h.attributes.URI.split(",")[1])})):void this.trigger("warn",{message:"invalid key ID provided for Widevine"}));h.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),r={method:h.attributes.METHOD||"AES-128",uri:h.attributes.URI},void 0!==h.attributes.IV&&(r.iv=h.attributes.IV)}else this.trigger("warn",{message:"ignoring key declaration without URI"});else r=null;else this.trigger("warn",{message:"ignoring key declaration without attribute list"})},"media-sequence"(){isFinite(h.number)?this.manifest.mediaSequence=h.number:this.trigger("warn",{message:"ignoring invalid media sequence: "+h.number})},"discontinuity-sequence"(){isFinite(h.number)?(this.manifest.discontinuitySequence=h.number,l=h.number):this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+h.number})},"playlist-type"(){/VOD|EVENT/.test(h.playlistType)?this.manifest.playlistType=h.playlistType:this.trigger("warn",{message:"ignoring unknown playlist type: "+h.playlist})},map(){n={},h.uri&&(n.uri=h.uri),h.byterange&&(n.byterange=h.byterange),r&&(n.key=r)},"stream-inf"(){this.manifest.playlists=t,this.manifest.mediaGroups=this.manifest.mediaGroups||o,h.attributes?(i.attributes||(i.attributes={}),Ft(i.attributes,h.attributes)):this.trigger("warn",{message:"ignoring empty stream-inf attributes"})},media(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||o,!(h.attributes&&h.attributes.TYPE&&h.attributes["GROUP-ID"]&&h.attributes.NAME))return void this.trigger("warn",{message:"ignoring incomplete or missing media group"});const e=this.manifest.mediaGroups[h.attributes.TYPE];e[h.attributes["GROUP-ID"]]=e[h.attributes["GROUP-ID"]]||{},d=e[h.attributes["GROUP-ID"]],f={default:/yes/i.test(h.attributes.DEFAULT)},f.default?f.autoselect=!0:f.autoselect=/yes/i.test(h.attributes.AUTOSELECT),h.attributes.LANGUAGE&&(f.language=h.attributes.LANGUAGE),h.attributes.URI&&(f.uri=h.attributes.URI),h.attributes["INSTREAM-ID"]&&(f.instreamId=h.attributes["INSTREAM-ID"]),h.attributes.CHARACTERISTICS&&(f.characteristics=h.attributes.CHARACTERISTICS),h.attributes.FORCED&&(f.forced=/yes/i.test(h.attributes.FORCED)),d[h.attributes.NAME]=f},discontinuity(){l+=1,i.discontinuity=!0,this.manifest.discontinuityStarts.push(t.length)},"program-date-time"(){void 0===this.manifest.dateTimeString&&(this.manifest.dateTimeString=h.dateTimeString,this.manifest.dateTimeObject=h.dateTimeObject),i.dateTimeString=h.dateTimeString,i.dateTimeObject=h.dateTimeObject},targetduration(){!isFinite(h.duration)||h.duration<0?this.trigger("warn",{message:"ignoring invalid target duration: "+h.duration}):(this.manifest.targetDuration=h.duration,Ut.call(this,this.manifest))},start(){h.attributes&&!isNaN(h.attributes["TIME-OFFSET"])?this.manifest.start={timeOffset:h.attributes["TIME-OFFSET"],precise:h.attributes.PRECISE}:this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"})},"cue-out"(){i.cueOut=h.data},"cue-out-cont"(){i.cueOutCont=h.data},"cue-in"(){i.cueIn=h.data},skip(){this.manifest.skip=Bt(h.attributes),this.warnOnMissingAttributes_("#EXT-X-SKIP",h.attributes,["SKIPPED-SEGMENTS"])},part(){s=!0;const e=this.manifest.segments.length,t=Bt(h.attributes);i.parts=i.parts||[],i.parts.push(t),t.byterange&&(t.byterange.hasOwnProperty("offset")||(t.byterange.offset=u),u=t.byterange.offset+t.byterange.length);const n=i.parts.length-1;this.warnOnMissingAttributes_(`#EXT-X-PART #${n} for segment #${e}`,h.attributes,["URI","DURATION"]),this.manifest.renditionReports&&this.manifest.renditionReports.forEach(((e,t)=>{e.hasOwnProperty("lastPart")||this.trigger("warn",{message:`#EXT-X-RENDITION-REPORT #${t} lacks required attribute(s): LAST-PART`})}))},"server-control"(){const e=this.manifest.serverControl=Bt(h.attributes);e.hasOwnProperty("canBlockReload")||(e.canBlockReload=!1,this.trigger("info",{message:"#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false"})),Ut.call(this,this.manifest),e.canSkipDateranges&&!e.hasOwnProperty("canSkipUntil")&&this.trigger("warn",{message:"#EXT-X-SERVER-CONTROL lacks required attribute CAN-SKIP-UNTIL which is required when CAN-SKIP-DATERANGES is set"})},"preload-hint"(){const e=this.manifest.segments.length,t=Bt(h.attributes),n=t.type&&"PART"===t.type;i.preloadHints=i.preloadHints||[],i.preloadHints.push(t),t.byterange&&(t.byterange.hasOwnProperty("offset")||(t.byterange.offset=n?u:0,n&&(u=t.byterange.offset+t.byterange.length)));const r=i.preloadHints.length-1;if(this.warnOnMissingAttributes_(`#EXT-X-PRELOAD-HINT #${r} for segment #${e}`,h.attributes,["TYPE","URI"]),t.type)for(let n=0;n<i.preloadHints.length-1;n++){const s=i.preloadHints[n];s.type&&s.type===t.type&&this.trigger("warn",{message:`#EXT-X-PRELOAD-HINT #${r} for segment #${e} has the same TYPE ${t.type} as preload hint #${n}`})}},"rendition-report"(){const e=Bt(h.attributes);this.manifest.renditionReports=this.manifest.renditionReports||[],this.manifest.renditionReports.push(e);const t=this.manifest.renditionReports.length-1,n=["LAST-MSN","URI"];s&&n.push("LAST-PART"),this.warnOnMissingAttributes_(`#EXT-X-RENDITION-REPORT #${t}`,h.attributes,n)},"part-inf"(){this.manifest.partInf=Bt(h.attributes),this.warnOnMissingAttributes_("#EXT-X-PART-INF",h.attributes,["PART-TARGET"]),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),Ut.call(this,this.manifest)}}[h.tagType]||a).call(e)},uri(){i.uri=h.uri,t.push(i),this.manifest.targetDuration&&!("duration"in i)&&(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),i.duration=this.manifest.targetDuration),r&&(i.key=r),i.timeline=l,n&&(i.map=n),u=0,i={}},comment(){},custom(){h.segment?(i.custom=i.custom||{},i.custom[h.customType]=h.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[h.customType]=h.data)}})[h.type].call(e)}))}warnOnMissingAttributes_(e,t,n){const r=[];n.forEach((function(e){t.hasOwnProperty(e)||r.push(e)})),r.length&&this.trigger("warn",{message:`${e} lacks required attribute(s): ${r.join(", ")}`})}push(e){this.lineStream.push(e)}end(){this.lineStream.push("\n"),this.trigger("end")}addParser(e){this.parseStream.addParser(e)}addTagMapper(e){this.parseStream.addTagMapper(e)}}async function Ht(e){return`<!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <title>asbplayer - Video Data Sync</title>\n </head>\n <body>\n <div id="root" style="width:100%;height:100vh;"></div>\n <script type="application/json" id="loc">${JSON.stringify(await J(e))}<\/script>\n <script src="${chrome.runtime.getURL("./video-data-sync-ui.js")}"><\/script>\n </body>\n </html>`}class zt{constructor(e,t){this._autoSyncing=!1,this._waitingForSubtitles=!1,this._context=e,this._settings=t,this._videoSelectBound=!1,this._imageElement=new oe(e.video),this._doneListener,this._autoSync=!1,this._lastLanguagesSynced={},this._emptySubtitle={language:"",url:"-",label:Et.t("extension.videoDataSync.emptySubtitleTrack"),extension:"srt"},this._boundFunction,this._domain=new URL(window.location.href).host,this._frame=new ne(Ht)}get lastLanguageSynced(){return this._lastLanguagesSynced[this._domain]??[]}set lastLanguageSynced(e){this._lastLanguagesSynced[this._domain]=e}bindVideoSelect(e){if(this._videoSelectBound)throw new Error("Video select container already bound");const t=this._imageElement.element();t.classList.remove("asbplayer-hide"),t.classList.add("asbplayer-mouse-over-image"),t.addEventListener("click",(t=>{t.preventDefault(),this._doneListener=e,this.show({userRequested:!0,openedFromMiningCommand:!1})})),this._videoSelectBound=!0}unbind(){this._boundFunction&&document.removeEventListener("asbplayer-synced-data",this._boundFunction,!1),this._boundFunction=void 0,this._syncedData=void 0,this.unbindVideoSelect()}unbindVideoSelect(){this._imageElement.remove(),this._frame.unbind(),this._wasPaused=void 0,this._videoSelectBound=!1,this._doneListener=void 0}updateSettings({streamingAutoSync:e,streamingLastLanguagesSynced:t}){this._autoSync=e,this._lastLanguagesSynced=t}requestSubtitles(){if(this._context.subSyncAvailable&&Tt()?.isVideoPage()){if(this._syncedData=void 0,!this._boundFunction){let e=!0;this._boundFunction=t=>{const n=t.detail,r=e&&void 0!==n.subtitles;this._waitingForSubtitles=void 0===n.subtitles,this._setSyncedData(n,r),r&&(e=!1)},document.addEventListener("asbplayer-synced-data",this._boundFunction,!1)}document.dispatchEvent(new CustomEvent("asbplayer-get-synced-data")),this._waitingForSubtitles=!0}}async show({userRequested:e,openedFromMiningCommand:t}){if(!e&&void 0===this._syncedData?.subtitles)return;const n=this._syncedData?.subtitles??[],r=this._matchLastSyncedWithAvailableTracks(),i=r.autoSelectedTracks;if(!r.completeMatch||e||this._syncedData?.error){const e=r.completeMatch,s=await this._context.settings.getSingle("themeType");let a=this._syncedData?{open:!0,isLoading:void 0===this._syncedData.subtitles,suggestedName:this._syncedData.basename,selectedSubtitle:["-"],subtitles:n,error:this._syncedData.error,themeType:s,openedFromMiningCommand:t,defaultCheckboxState:e}:{open:!0,isLoading:this._context.subSyncAvailable&&this._waitingForSubtitles,suggestedName:"",selectedSubtitle:["-"],error:"",showSubSelect:!0,subtitles:n,themeType:s,openedFromMiningCommand:t,defaultCheckboxState:e};a.selectedSubtitle=i.map((e=>e.url||"-"));const o=await this._client();this._prepareShow(),o.updateState(a)}else if(!this._autoSyncing){this._autoSyncing=!0;try{await this._syncData(i)&&this._doneListener&&this._doneListener()}finally{this._autoSyncing=!1}}}_matchLastSyncedWithAvailableTracks(){const e=this._syncedData?.subtitles??[];let t={autoSelectedTracks:[this._emptySubtitle,this._emptySubtitle,this._emptySubtitle],completeMatch:!1};if(e.length||""!==this.lastLanguageSynced.join("")){let n=0;for(let r=0;r<this.lastLanguageSynced.length;r++){const i=this.lastLanguageSynced[r];for(let s=0;s<e.length;s++){if(""===i){n++;break}if(i===e[s].language){t.autoSelectedTracks[r]=e[s],n++;break}}}n===this.lastLanguageSynced.length&&(t.completeMatch=!0)}else t.completeMatch=!0;return t}_defaultVideoName(e,t){return"-"===t.url?e??"":e?`${e} - ${t.label}`:t.label}_setSyncedData(e,t){this._syncedData=e,t&&this._canAutoSync()&&this.show({userRequested:!1,openedFromMiningCommand:!1})}_canAutoSync(){const e=Tt();return void 0===e?this._autoSync??!1:!0===this._autoSync&&e.canAutoSync(this._context.video)}async _client(){this._frame.language=await this._settings.getSingle("language");const e=await this._frame.bind(),t=await this._frame.client();return e&&t.onMessage((async e=>{let t=!0;if("confirm"===e.command){const n=e;n.shouldRememberTrackChoices&&(this.lastLanguageSynced=n.data.map((e=>e.language)),await this._context.settings.set({streamingLastLanguagesSynced:this._lastLanguagesSynced}).catch((()=>{})));const r=n.data;t=await this._syncDataArray(r)}else if("openFile"===e.command){const n=e.subtitles;try{this._syncSubtitles(n,!1),t=!0}catch(e){e instanceof Error&&this._reportError(e.message)}}t&&(this._context.keyBindings.bind(this._context),this._context.subtitleController.forceHideSubtitles=!1,this._frame?.hide(),this._fullscreenElement&&(this._fullscreenElement.requestFullscreen(),this._fullscreenElement=void 0),this._activeElement?("function"==typeof this._activeElement.focus&&this._activeElement.focus(),this._activeElement=void 0):window.focus(),this._wasPaused||this._context.play(),this._wasPaused=void 0,this._doneListener&&this._doneListener())})),this._frame.show(),t}_prepareShow(){this._wasPaused=this._wasPaused??this._context.video.paused,this._context.pause(),document.fullscreenElement&&(this._fullscreenElement=document.fullscreenElement,document.exitFullscreen()),document.activeElement&&(this._activeElement=document.activeElement),this._context.keyBindings.unbind(),this._context.subtitleController.forceHideSubtitles=!0}async _syncData(e){try{let t=[];for(let n=0;n<e.length;n++){const{extension:r,url:i,m3U8BaseUrl:s}=e[n],a=await this._subtitlesForUrl(this._defaultVideoName(this._syncedData?.basename,e[n]),r,i,s);void 0!==a&&t.push(...a)}return this._syncSubtitles(t,e.some((e=>void 0!==e.m3U8BaseUrl))),!0}catch(e){return void 0!==e.message&&this._reportError(`Data Sync failed: ${e.message}`),!1}}async _syncDataArray(e){try{let t=[];for(let n=0;n<e.length;n++){const{name:r,extension:i,subtitleUrl:s,m3U8BaseUrl:a}=e[n],o=await this._subtitlesForUrl(r,i,s,a);void 0!==o&&t.push(...o)}return this._syncSubtitles(t,e.some((e=>void 0!==e.m3U8BaseUrl))),!0}catch(e){return void 0!==e.message&&this._reportError(`Data Sync failed: ${e.message}`),!1}}async _syncSubtitles(e,t){if(await this._settings.getSingle("streamingSubtitleListPreference")===m.app){const n={sender:"asbplayer-video",message:{command:"sync",subtitles:e,flatten:t},src:this._context.video.src};chrome.runtime.sendMessage(n)}else{const n=await Promise.all(e.map((async e=>new File([await(await fetch("data:text/plain;base64,"+e.base64)).blob()],e.name))));this._context.loadSubtitles(n,t)}}async _subtitlesForUrl(e,t,n,r){if("-"===n)return[{name:`${e}.${t}`,base64:""}];const i=await fetch(n).catch((e=>{this._reportError(e.message)}));if(i){if("m3u8"===t){const t=await fetch(n),i=new Vt;if(i.push(await t.text()),i.end(),!i.manifest.segments||0===i.manifest.segments.length)return;const s=i.manifest.segments[0].uri,a=s.substring(s.lastIndexOf(".")+1),o=i.manifest.segments.filter((e=>!e.discontinuity&&e.uri)).map((e=>fetch(`${r}/${e.uri}`))),l=[];for(const t of o){const n=await t;if(!n.ok)throw new Error(`Subtitle Retrieval failed with Status ${n.status}/${n.statusText}...`);l.push({name:`${e}.${a}`,base64:_t(await n.arrayBuffer())})}return l}if(!i.ok)throw new Error(`Subtitle Retrieval failed with Status ${i.status}/${i.statusText}...`);return[{name:`${e}.${t}`,base64:i?_t(await i.arrayBuffer()):""}]}}async _reportError(e){const t=await this._client(),n=await this._context.settings.getSingle("themeType");this._prepareShow();const r=this._syncedData?.subtitles??[];let i=[this._emptySubtitle,this._emptySubtitle,this._emptySubtitle];for(let e=0;e<this.lastLanguageSynced.length;e++){const t=this.lastLanguageSynced[e];for(let n=0;n<r.length;n++)if(t===r[n].language){i[e]=r[n];break}}return t.updateState({open:!0,isLoading:!1,showSubSelect:!0,subtitles:this._syncedData?.subtitles||[],selectedSubtitle:i.map((e=>e.url))||"-",error:e,themeType:n})}}let qt;const Wt={};var Zt="undefined"!=typeof navigator&&navigator.userAgent.toLowerCase().indexOf("firefox")>0;function Xt(e,t,n,r){e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on".concat(t),(function(){n(window.event)}))}function Kt(e,t){for(var n=t.slice(0,t.length-1),r=0;r<n.length;r++)n[r]=e[n[r].toLowerCase()];return n}function Gt(e){"string"!=typeof e&&(e="");for(var t=(e=e.replace(/\s/g,"")).split(","),n=t.lastIndexOf("");n>=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}for(var Yt={backspace:8,"⌫":8,tab:9,clear:12,enter:13,"↩":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":Zt?173:189,"=":Zt?61:187,";":Zt?59:186,"'":222,"[":219,"]":221,"\\":220},Jt={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},Qt={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},en={16:!1,18:!1,17:!1,91:!1},tn={},nn=1;nn<20;nn++)Yt["f".concat(nn)]=111+nn;var rn=[],sn=!1,an="all",on=[],ln=function(e){return Yt[e.toLowerCase()]||Jt[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)};function cn(e){an=e||"all"}function un(){return an||"all"}var hn=function(e){var t=e.key,n=e.scope,r=e.method,i=e.splitKey,s=void 0===i?"+":i;Gt(t).forEach((function(e){var t=e.split(s),i=t.length,a=t[i-1],o="*"===a?"*":ln(a);if(tn[o]){n||(n=un());var l=i>1?Kt(Jt,t):[];tn[o]=tn[o].filter((function(e){return!((!r||e.method===r)&&e.scope===n&&function(e,t){for(var n=e.length>=t.length?e:t,r=e.length>=t.length?t:e,i=!0,s=0;s<n.length;s++)-1===r.indexOf(n[s])&&(i=!1);return i}(e.mods,l))}))}}))};function dn(e,t,n,r){var i;if(t.element===r&&(t.scope===n||"all"===t.scope)){for(var s in i=t.mods.length>0,en)Object.prototype.hasOwnProperty.call(en,s)&&(!en[s]&&t.mods.indexOf(+s)>-1||en[s]&&-1===t.mods.indexOf(+s))&&(i=!1);(0!==t.mods.length||en[16]||en[18]||en[17]||en[91])&&!i&&"*"!==t.shortcut||!1===t.method(e,t)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}function fn(e,t){var n=tn["*"],r=e.keyCode||e.which||e.charCode;if(pn.filter.call(this,e)){if(93!==r&&224!==r||(r=91),-1===rn.indexOf(r)&&229!==r&&rn.push(r),["ctrlKey","altKey","shiftKey","metaKey"].forEach((function(t){var n=Qt[t];e[t]&&-1===rn.indexOf(n)?rn.push(n):!e[t]&&rn.indexOf(n)>-1?rn.splice(rn.indexOf(n),1):"metaKey"===t&&e[t]&&3===rn.length&&(e.ctrlKey||e.shiftKey||e.altKey||(rn=rn.slice(rn.indexOf(n))))})),r in en){for(var i in en[r]=!0,Jt)Jt[i]===r&&(pn[i]=!0);if(!n)return}for(var s in en)Object.prototype.hasOwnProperty.call(en,s)&&(en[s]=e[Qt[s]]);e.getModifierState&&(!e.altKey||e.ctrlKey)&&e.getModifierState("AltGraph")&&(-1===rn.indexOf(17)&&rn.push(17),-1===rn.indexOf(18)&&rn.push(18),en[17]=!0,en[18]=!0);var a=un();if(n)for(var o=0;o<n.length;o++)n[o].scope===a&&("keydown"===e.type&&n[o].keydown||"keyup"===e.type&&n[o].keyup)&&dn(e,n[o],a,t);if(r in tn)for(var l=0;l<tn[r].length;l++)if(("keydown"===e.type&&tn[r][l].keydown||"keyup"===e.type&&tn[r][l].keyup)&&tn[r][l].key){for(var c=tn[r][l],u=c.splitKey,h=c.key.split(u),d=[],f=0;f<h.length;f++)d.push(ln(h[f]));d.sort().join("")===rn.sort().join("")&&dn(e,c,a,t)}}}function pn(e,t,n){rn=[];var r=Gt(e),i=[],s="all",a=document,o=0,l=!1,c=!0,u="+",h=!1;for(void 0===n&&"function"==typeof t&&(n=t),"[object Object]"===Object.prototype.toString.call(t)&&(t.scope&&(s=t.scope),t.element&&(a=t.element),t.keyup&&(l=t.keyup),void 0!==t.keydown&&(c=t.keydown),void 0!==t.capture&&(h=t.capture),"string"==typeof t.splitKey&&(u=t.splitKey)),"string"==typeof t&&(s=t);o<r.length;o++)i=[],(e=r[o].split(u)).length>1&&(i=Kt(Jt,e)),(e="*"===(e=e[e.length-1])?"*":ln(e))in tn||(tn[e]=[]),tn[e].push({keyup:l,keydown:c,scope:s,mods:i,shortcut:r[o],method:n,key:r[o],splitKey:u,element:a});void 0!==a&&!function(e){return on.indexOf(e)>-1}(a)&&window&&(on.push(a),Xt(a,"keydown",(function(e){fn(e,a)}),h),sn||(sn=!0,Xt(window,"focus",(function(){rn=[]}),h)),Xt(a,"keyup",(function(e){fn(e,a),function(e){var t=e.keyCode||e.which||e.charCode,n=rn.indexOf(t);if(n>=0&&rn.splice(n,1),e.key&&"meta"===e.key.toLowerCase()&&rn.splice(0,rn.length),93!==t&&224!==t||(t=91),t in en)for(var r in en[t]=!1,Jt)Jt[r]===t&&(pn[r]=!1)}(e)}),h))}var gn={getPressedKeyString:function(){return rn.map((function(e){return t=e,Object.keys(Yt).find((function(e){return Yt[e]===t}))||function(e){return Object.keys(Jt).find((function(t){return Jt[t]===e}))}(e)||String.fromCharCode(e);var t}))},setScope:cn,getScope:un,deleteScope:function(e,t){var n,r;for(var i in e||(e=un()),tn)if(Object.prototype.hasOwnProperty.call(tn,i))for(n=tn[i],r=0;r<n.length;)n[r].scope===e?n.splice(r,1):r++;un()===e&&cn(t||"all")},getPressedKeyCodes:function(){return rn.slice(0)},isPressed:function(e){return"string"==typeof e&&(e=ln(e)),-1!==rn.indexOf(e)},filter:function(e){var t=e.target||e.srcElement,n=t.tagName,r=!0;return!t.isContentEditable&&("INPUT"!==n&&"TEXTAREA"!==n&&"SELECT"!==n||t.readOnly)||(r=!1),r},trigger:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";Object.keys(tn).forEach((function(n){var r=tn[n].find((function(n){return n.scope===t&&n.shortcut===e}));r&&r.method&&r.method()}))},unbind:function(e){if(void 0===e)Object.keys(tn).forEach((function(e){return delete tn[e]}));else if(Array.isArray(e))e.forEach((function(e){e.key&&hn(e)}));else if("object"==typeof e)e.key&&hn(e);else if("string"==typeof e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var i=n[0],s=n[1];"function"==typeof i&&(s=i,i=""),hn({key:e,scope:i,method:s,splitKey:"+"})}},keyMap:Yt,modifier:Jt,modifierMap:Qt};for(var mn in gn)Object.prototype.hasOwnProperty.call(gn,mn)&&(pn[mn]=gn[mn]);if("undefined"!=typeof window){var yn=window.hotkeys;pn.noConflict=function(e){return e&&window.hotkeys===pn&&(window.hotkeys=yn),pn},window.hotkeys=pn}class bn{constructor(e){this.keyBindSet=e}bindCopy(e,t,n,r=!1){const i=this.keyBindSet.copySubtitle.keys;if(!i)return()=>{};const s=this.copyHandler(e,t,n);return this._bind(i,r,s)}copyHandler(e,t,n){return r=>{if(t())return;const i=n();i&&e(r,i)}}bindAnkiExport(e,t,n=!1){const r=this.keyBindSet.ankiExport.keys;if(!r)return()=>{};const i=this.ankiExportHandler(e,t);return this._bind(r,n,i)}ankiExportHandler(e,t){return n=>{t()||e(n)}}bindUpdateLastCard(e,t,n=!1){const r=this.keyBindSet.updateLastCard.keys;if(!r)return()=>{};const i=this.updateLastCardHandler(e,t);return this._bind(r,n,i)}updateLastCardHandler(e,t){return n=>{t()||e(n)}}bindTakeScreenshot(e,t,n=!1){const r=this.keyBindSet.takeScreenshot.keys;if(!r)return()=>{};const i=this.updateLastCardHandler(e,t);return this._bind(r,n,i)}takeScreenshotHandler(e,t){return n=>{t()||e(n)}}bindSeekToSubtitle(e,t,n,r,i=!1){const s=(i,s)=>{if(t())return;const a=r();if(!a||0===a.length)return;const o=this._adjacentSubtitle(s,n(),a);null!==o&&o.start>=0&&o.end>=0&&e(i,o)},a=this.keyBindSet.seekToPreviousSubtitle.keys,o=this.keyBindSet.seekToNextSubtitle.keys;let l,c;return a&&(l=this._bind(a,i,(e=>s(e,!1)))),o&&(c=this._bind(o,i,(e=>s(e,!0)))),()=>{l?.(),c?.()}}bindSeekToBeginningOfCurrentSubtitle(e,t,n,r,i=!1){const s=this.keyBindSet.seekToBeginningOfCurrentSubtitle.keys;return s?this._bind(s,i,(i=>{if(t())return;const s=r();if(!s||0===s.length)return;const a=this._currentSubtitle(n(),s);void 0!==a&&a.start>=0&&a.end>=0&&e(i,a)})):()=>{}}_currentSubtitle(e,t){const n=e;let r,i=Number.MAX_SAFE_INTEGER;for(let e=0;e<t.length;++e){const s=t[e];if(s.start<0||s.end<0)continue;const a=n-s.start;n>=s.start&&n<s.end&&a<i&&(r=s,i=a)}return r}bindSeekBackwardOrForward(e,t,n=!1){const r=(n,r)=>{t()||e(n,r)},i=this.keyBindSet.seekBackward.keys,s=this.keyBindSet.seekForward.keys;let a,o;return i&&(a=this._bind(i,n,(e=>r(e,!1)))),s&&(o=this._bind(s,n,(e=>r(e,!0)))),()=>{a?.(),o?.()}}bindOffsetToSubtitle(e,t,n,r,i=!1){const s=(i,s)=>{if(t())return;const a=r();if(!a||0===a.length)return;const o=n(),l=this._adjacentSubtitle(s,o,a);if(null!==l){const t=l.originalStart;e(i,o-t)}},a=this.keyBindSet.adjustOffsetToPreviousSubtitle.keys,o=this.keyBindSet.adjustOffsetToNextSubtitle.keys;let l,c;return a&&(l=this._bind(a,i,(e=>s(e,!1)))),o&&(c=this._bind(o,i,(e=>s(e,!0)))),()=>{l?.(),c?.()}}_adjacentSubtitle(e,t,n){const r=t;let i=-1,s=Number.MAX_SAFE_INTEGER;for(let t=0;t<n.length;++t){const a=n[t],o=e?a.start-r:r-a.start;s<=o||(e&&r<a.start?(s=o,i=t):!e&&r>a.start&&(s=o,i=r<a.end?Math.max(0,t-1):t))}return-1!==i?n[i]:null}bindAdjustOffset(e,t,n,r=!1){const i=(r,i)=>{if(t())return;const s=n();if(!s||0===s.length)return;const a=s[0].start-s[0].originalStart;e(r,a+(i?100:-100))},s=this.keyBindSet.decreaseOffset.keys,a=this.keyBindSet.increaseOffset.keys,o=s?this._bind(s,r,(e=>i(e,!1))):()=>{},l=a?this._bind(a,r,(e=>i(e,!0))):()=>{};return()=>{o(),l()}}bindResetOffet(e,t,n){const r=this.keyBindSet.resetOffset.keys;return r?this._bind(r,n??!1,(n=>{t()||e(n)})):()=>{}}bindAdjustPlaybackRate(e,t,n=!1){const r=(n,r)=>{t()||e(n,r)},i=this.keyBindSet.increasePlaybackRate.keys,s=this.keyBindSet.decreasePlaybackRate.keys;let a,o;return s&&(a=this._bind(s,n,(e=>r(e,!1)))),i&&(o=this._bind(i,n,(e=>r(e,!0)))),()=>{a?.(),o?.()}}bindToggleSubtitles(e,t,n=!1){const r=this.keyBindSet.toggleSubtitles.keys;return r?this._bind(r,n,(n=>{t()||e(n)})):()=>{}}bindToggleSubtitleTrackInVideo(e,t,n=!1){const r=[this.keyBindSet.toggleVideoSubtitleTrack1.keys,this.keyBindSet.toggleVideoSubtitleTrack2.keys,this.keyBindSet.toggleVideoSubtitleTrack3.keys].filter((e=>e));if(0===r.length)return()=>{};const i=(n,r)=>{t()||e(n,r)};let s=[];for(let e=0;e<r.length;++e){const t=t=>i(t,e),a=r[e]?this._bind(r[e],n,t):()=>{};s.push(a)}return()=>{for(let e=0;e<r.length;++e)(0,s[e])()}}bindToggleSubtitleTrackInList(e,t,n=!1){const r=[this.keyBindSet.toggleAsbplayerSubtitleTrack1.keys,this.keyBindSet.toggleAsbplayerSubtitleTrack2.keys,this.keyBindSet.toggleAsbplayerSubtitleTrack3.keys].filter((e=>e));if(0===r.length)return()=>{};const i=(n,r)=>{t()||e(n,r)};let s=[];for(let e=0;e<9;++e){const t=t=>i(t,e),a=r[e]?this._bind(r[e],n,t):()=>{};s.push(a)}return()=>{for(let e=0;e<9;++e)(0,s[e])()}}bindPlay(e,t,n=!1){const r=this.keyBindSet.togglePlay.keys;return r?this._bind(r,n,(n=>{t()||e(n)})):()=>{}}bindAutoPause(e,t,n=!1){const r=this.keyBindSet.toggleAutoPause.keys;return r?this._bind(r,n,(n=>{t()||e(n)})):()=>{}}bindCondensedPlayback(e,t,n=!1){const r=this.keyBindSet.toggleCondensedPlayback.keys;return r?this._bind(r,n,(n=>{t()||e(n)})):()=>{}}bindFastForwardPlayback(e,t,n=!1){const r=this.keyBindSet.toggleFastForwardPlayback.keys;return r?this._bind(r,n,(n=>{t()||e(n)})):()=>{}}bindToggleSidePanel(e,t,n=!1){const r=this.keyBindSet.toggleSidePanel.keys;return r?this._bind(r,n,(n=>{t()||e(n)})):()=>{}}_bind(e,t,n){const r=e=>{"keydown"===e.type?n(e):"keyup"===e.type&&(e.preventDefault(),e.stopImmediatePropagation())};return pn(e,{capture:t,keydown:!0,keyup:!0},r),()=>pn.unbind(e,r)}}class vn{constructor(){this._unbindPlay=!1,this._unbindAutoPause=!1,this._unbindCondensedPlayback=!1,this._unbindFastForwardPlayback=!1,this._unbindSeekToSubtitle=!1,this._unbindSeekToBeginningOfCurrentSubtitle=!1,this._unbindSeekBackwardOrForward=!1,this._unbindToggleSubtitles=!1,this._unbindToggleSubtitleTrackInVideo=!1,this._unbindToggleSubtitleTrackInList=!1,this._unbindOffsetToSubtitle=!1,this._unbindAdjustOffset=!1,this._unbindResetOffset=!1,this._unbindAdjustPlaybackRate=!1,this._bound=!1}setKeyBindSet(e,t){this._keyBinder=new bn(t),this.unbind(),this.bind(e)}bind(e){this._keyBinder&&(this._bound&&this.unbind(),this._unbindPlay=this._keyBinder.bindPlay((t=>{t.preventDefault(),t.stopImmediatePropagation(),e.video.paused?e.play():e.pause()}),(()=>!1),!0),this._unbindAutoPause=this._keyBinder.bindAutoPause((t=>{t.preventDefault(),t.stopImmediatePropagation(),e.playMode=e.playMode===d.autoPause?d.normal:d.autoPause}),(()=>!e.subtitleController.subtitles||0===e.subtitleController.subtitles.length),!0),this._unbindCondensedPlayback=this._keyBinder.bindCondensedPlayback((t=>{t.preventDefault(),t.stopImmediatePropagation(),e.playMode=e.playMode===d.condensed?d.normal:d.condensed}),(()=>!e.subtitleController.subtitles||0===e.subtitleController.subtitles.length),!0),this._unbindFastForwardPlayback=this._keyBinder.bindFastForwardPlayback((t=>{t.preventDefault(),t.stopImmediatePropagation(),e.playMode=e.playMode===d.fastForward?d.normal:d.fastForward}),(()=>!e.subtitleController.subtitles||0===e.subtitleController.subtitles.length),!0),this._unbindSeekToSubtitle=this._keyBinder.bindSeekToSubtitle(((t,n)=>{t.preventDefault(),t.stopImmediatePropagation(),e.seek(n.start/1e3)}),(()=>!1),(()=>1e3*e.video.currentTime),(()=>e.subtitleController.subtitles),!0),this._unbindSeekBackwardOrForward=this._keyBinder.bindSeekBackwardOrForward(((t,n)=>{t.preventDefault(),t.stopImmediatePropagation(),n?e.seek(Math.min(e.video.duration,e.video.currentTime+10)):e.seek(Math.max(0,e.video.currentTime-10))}),(()=>!1),!0),this._unbindSeekToBeginningOfCurrentSubtitle=this._keyBinder.bindSeekToBeginningOfCurrentSubtitle(((t,n)=>{t.preventDefault(),t.stopImmediatePropagation(),e.seek(n.start/1e3)}),(()=>!1),(()=>1e3*e.video.currentTime),(()=>e.subtitleController.subtitles),!0),this._unbindToggleSubtitles=this._keyBinder.bindToggleSubtitles((t=>{t.preventDefault(),t.stopImmediatePropagation();const n={sender:"asbplayer-video",message:{command:"toggle-subtitles"},src:e.video.src};chrome.runtime.sendMessage(n)}),(()=>!e.subtitleController.subtitles||0===e.subtitleController.subtitles.length),!0),this._unbindToggleSubtitleTrackInVideo=this._keyBinder.bindToggleSubtitleTrackInVideo(((t,n)=>{t.preventDefault(),t.stopImmediatePropagation(),e.subtitleController.disabledSubtitleTracks[n]=!e.subtitleController.disabledSubtitleTracks[n]}),(()=>!e.subtitleController.subtitles||0===e.subtitleController.subtitles.length),!0),this._unbindToggleSubtitleTrackInList=this._keyBinder.bindToggleSubtitleTrackInList(((t,n)=>{t.preventDefault(),t.stopImmediatePropagation();const r={sender:"asbplayer-video",message:{command:"toggleSubtitleTrackInList",track:n},src:e.video.src};chrome.runtime.sendMessage(r)}),(()=>!e.subtitleController.subtitles||0===e.subtitleController.subtitles.length),!0),this._unbindOffsetToSubtitle=this._keyBinder.bindOffsetToSubtitle(((t,n)=>{t.preventDefault(),t.stopImmediatePropagation(),e.subtitleController.offset(n)}),(()=>!1),(()=>1e3*e.video.currentTime),(()=>e.subtitleController.subtitles),!0),this._unbindAdjustOffset=this._keyBinder.bindAdjustOffset(((t,n)=>{t.preventDefault(),t.stopImmediatePropagation(),e.subtitleController.offset(n)}),(()=>!1),(()=>e.subtitleController.subtitles),!0),this._unbindResetOffset=this._keyBinder.bindResetOffet((t=>{t.preventDefault(),t.stopImmediatePropagation(),e.subtitleController.offset(0)}),(()=>!1),!0),this._unbindAdjustPlaybackRate=this._keyBinder.bindAdjustPlaybackRate(((t,n)=>{t.preventDefault(),t.stopImmediatePropagation(),e.video.playbackRate=n?Math.min(5,Math.round(10*e.video.playbackRate+1)/10):Math.max(.1,Math.round(10*e.video.playbackRate-1)/10)}),(()=>!1),!0),this._bound=!0)}unbind(){this._unbindPlay&&(this._unbindPlay(),this._unbindPlay=!1),this._unbindAutoPause&&(this._unbindAutoPause(),this._unbindAutoPause=!1),this._unbindCondensedPlayback&&(this._unbindCondensedPlayback(),this._unbindCondensedPlayback=!1),this._unbindFastForwardPlayback&&(this._unbindFastForwardPlayback(),this._unbindFastForwardPlayback=!1),this._unbindSeekToSubtitle&&(this._unbindSeekToSubtitle(),this._unbindSeekToSubtitle=!1),this._unbindSeekToBeginningOfCurrentSubtitle&&(this._unbindSeekToBeginningOfCurrentSubtitle(),this._unbindSeekToBeginningOfCurrentSubtitle=!1),this._unbindSeekBackwardOrForward&&(this._unbindSeekBackwardOrForward(),this._unbindSeekBackwardOrForward=!1),this._unbindToggleSubtitles&&(this._unbindToggleSubtitles(),this._unbindToggleSubtitles=!1),this._unbindToggleSubtitleTrackInVideo&&(this._unbindToggleSubtitleTrackInVideo(),this._unbindToggleSubtitleTrackInVideo=!1),this._unbindToggleSubtitleTrackInList&&(this._unbindToggleSubtitleTrackInList(),this._unbindToggleSubtitleTrackInList=!1),this._unbindOffsetToSubtitle&&(this._unbindOffsetToSubtitle(),this._unbindOffsetToSubtitle=!1),this._unbindAdjustOffset&&(this._unbindAdjustOffset(),this._unbindAdjustOffset=!1),this._unbindResetOffset&&(this._unbindResetOffset(),this._unbindResetOffset=!1),this._unbindAdjustPlaybackRate&&(this._unbindAdjustPlaybackRate(),this._unbindAdjustPlaybackRate=!1),this._bound=!1}}let wn=!1;document.addEventListener("asbplayer-netflix-enabled",(e=>{wn=e.detail})),document.dispatchEvent(new CustomEvent("asbplayer-query-netflix"));class Sn{constructor(e,t,n){this.subscribed=!1,this._playMode=d.normal,this.condensedPlaybackMinimumSkipIntervalMs=1e3,this.fastForwardPlaybackMinimumGapMs=600,this.fastForwardModePlaybackRate=2.7,this.imageDelay=0,this.video=e,this.subSyncAvailable=t,this.settings=new v(new Y),this.subtitleController=new Ot(e,this.settings),this.videoDataSyncController=new zt(this,this.settings),this.controlsController=new ae(e),this.dragController=new le(e),this.keyBindings=new vn,this.ankiUiController=new se,this.requestActiveTabPermissionController=new re(this),this.recordMedia=!0,this.takeScreenshot=!0,this.cleanScreenshot=!0,this.audioPaddingStart=0,this.audioPaddingEnd=500,this.maxImageWidth=0,this.maxImageHeight=0,this.autoPausePreference=h.atEnd,this.copyToClipboardOnMine=!1,this._synced=!1,this.recordingMedia=!1,this.recordingMediaWithScreenshot=!1,this.frameId=n}get synced(){return this._synced}get url(){return window.location!==window.parent.location?document.referrer:document.location.href}get playMode(){return this._playMode}set playMode(e){const t=()=>{this.subtitleController.onNextToShow=void 0,this.subtitleController.notification("info.disabledCondensedPlayback")},n=()=>{this.subtitleController.onSlice=void 0,this.video.playbackRate=1,this.subtitleController.notification("info.disabledFastForwardPlayback")};switch(e){case d.autoPause:this.subtitleController.autoPauseContext.onStartedShowing=()=>{this.recordingMedia||this.autoPausePreference!==h.atStart||this.pause()},this.subtitleController.autoPauseContext.onWillStopShowing=()=>{this.recordingMedia||this.autoPausePreference!==h.atEnd||this.pause()},this.subtitleController.notification("info.enabledAutoPause");break;case d.condensed:this._playMode===d.fastForward&&n();let r=!1;this.subtitleController.onNextToShow=async e=>{try{if(this.recordingMedia||r||this.video.paused||e.start-1e3*this.video.currentTime<=this.condensedPlaybackMinimumSkipIntervalMs)return;r=!0,this.seek(e.start/1e3),await this.play(),r=!1}finally{r=!1}},this.subtitleController.notification("info.enabledCondensedPlayback");break;case d.fastForward:this._playMode===d.condensed&&t(),this.subtitleController.onSlice=async e=>{const t=e=>e&&Math.abs(e-1e3*this.video.currentTime)>this.fastForwardPlaybackMinimumGapMs;0===e.showing.length&&t(Math.max.apply(void 0,(e?.lastShown||[]).map((e=>e.end))))&&t(Math.min.apply(void 0,(e?.nextToShow||[]).map((e=>e.start))))?this.video.playbackRate=this.fastForwardModePlaybackRate:this.video.playbackRate=1},this.subtitleController.notification("info.enabledFastForwardPlayback");break;case d.normal:this._playMode===d.autoPause?(this.subtitleController.autoPauseContext.onStartedShowing=void 0,this.subtitleController.autoPauseContext.onWillStopShowing=void 0,this.subtitleController.notification("info.disabledAutoPause")):this._playMode===d.condensed?t():this._playMode===d.fastForward&&n();break;default:console.error("Unknown play mode "+e)}this._playMode=e}subtitleFileName(e=0){return this.subtitleController.subtitleFileNames?.[e]??""}get _imageCaptureParams(){const e=this.video.getBoundingClientRect();return{maxWidth:this.maxImageWidth,maxHeight:this.maxImageHeight,rect:{left:e.left,top:e.top,width:e.width,height:e.height},frameId:this.frameId}}bind(){let e=!1;4===this.video.readyState?(this._bind(),e=!0):this.video.addEventListener("canplay",(t=>{e||(this._bind(),e=!0);const n={sender:"asbplayer-video",message:{command:"readyState",value:4},src:this.video.src};chrome.runtime.sendMessage(n)}))}_bind(){this._notifyReady(),this._subscribe(),this._refreshSettings().then((()=>{this.videoDataSyncController.requestSubtitles()})),this.subtitleController.bind(),this.dragController.bind(this)}_notifyReady(){const e={sender:"asbplayer-video",message:{command:"ready",duration:this.video.duration,currentTime:this.video.currentTime,paused:this.video.paused,audioTracks:void 0,selectedAudioTrack:void 0,playbackRate:this.video.playbackRate},src:this.video.src};chrome.runtime.sendMessage(e)}_subscribe(){this.playListener=e=>{const t={sender:"asbplayer-video",message:{command:"play",echo:!1},src:this.video.src};chrome.runtime.sendMessage(t)},this.pauseListener=e=>{const t={sender:"asbplayer-video",message:{command:"pause",echo:!1},src:this.video.src};chrome.runtime.sendMessage(t)},this.seekedListener=e=>{const t={sender:"asbplayer-video",message:{command:"currentTime",value:this.video.currentTime,echo:!1},src:this.video.src};chrome.runtime.sendMessage(t),this.subtitleController.autoPauseContext.clear()},this.playbackRateListener=e=>{const t={sender:"asbplayer-video",message:{command:"playbackRate",value:this.video.playbackRate,echo:!1},src:this.video.src};chrome.runtime.sendMessage(t),this._synced&&this._playMode!==d.fastForward&&this.subtitleController.notification("info.playbackRate",{rate:this.video.playbackRate.toFixed(1)})},this.video.addEventListener("play",this.playListener),this.video.addEventListener("pause",this.pauseListener),this.video.addEventListener("seeked",this.seekedListener),this.video.addEventListener("ratechange",this.playbackRateListener),this.subSyncAvailable&&(this.videoChangeListener=()=>{this.videoDataSyncController.requestSubtitles()},this.video.addEventListener("loadedmetadata",this.videoChangeListener)),this.heartbeatInterval=setInterval((()=>{const e={sender:"asbplayer-video",message:{command:"heartbeat",subscribed:this.subscribed,synced:this._synced,syncedTimestamp:this._syncedTimestamp},src:this.video.src};chrome.runtime.sendMessage(e)}),1e3),window.addEventListener("beforeunload",(e=>{this.heartbeatInterval&&clearInterval(this.heartbeatInterval)})),this.listener=(e,t,n)=>{if("asbplayer-extension-to-video"===e.sender&&e.src===this.video.src){switch(e.message.command){case"init":this._notifyReady();break;case"ready":break;case"play":this.play();break;case"pause":this.pause();break;case"currentTime":const t=e.message;this.seek(t.value);break;case"close":break;case"subtitles":const r=e.message,i=r.value;this._updateSubtitles(i.map(((e,t)=>({...e,index:t}))),r.names||[r.name]);break;case"request-subtitles":n({subtitles:this.subtitleController.subtitles,subtitleFileNames:this.subtitleController.subtitleFileNames??[]});break;case"offset":const s=e.message;this.subtitleController.offset(s.value,!0);break;case"playbackRate":const a=e.message;this.video.playbackRate=a.value;break;case"subtitleSettings":case"ankiSettings":case"miscSettings":break;case"settings-updated":this._refreshSettings();break;case"copy-subtitle":const o=e.message;if(this._synced)if(void 0!==o.subtitle&&void 0!==o.surroundingSubtitles)this._copySubtitle(o.postMineAction,o.subtitle,o.surroundingSubtitles);else if(this.subtitleController.subtitles.length>0){const[e,t]=this.subtitleController.currentSubtitle();null!==e&&null!==t&&this._copySubtitle(o.postMineAction,e,t)}else this._toggleRecordingMedia(o.postMineAction);break;case"toggle-recording":this._synced&&this._toggleRecordingMedia(u.showAnkiDialog);break;case"card-updated":const c=e.message;this.subtitleController.notification("info.updatedCard",{result:e.message.cardName}),this.ankiUiSavedState={subtitle:c.subtitle,surroundingSubtitles:c.surroundingSubtitles,text:"",definition:"",image:c.image,audio:c.audio,word:c.cardName,source:l(this.subtitleFileName(),c.subtitle.start),url:c.url??"",customFieldValues:{},timestampInterval:[c.subtitle.start,c.subtitle.end],initialTimestampInterval:[c.subtitle.start,c.subtitle.end],lastAppliedTimestampIntervalToText:[c.subtitle.start,c.subtitle.end],lastAppliedTimestampIntervalToAudio:[c.subtitle.start,c.subtitle.end],dialogRequestedTimestamp:1e3*this.video.currentTime};break;case"card-saved":const h=e.message;this.subtitleController.notification("info.copiedSubtitle",{text:h.text});case"recording-finished":this.recordingMedia=!1,this.recordingMediaStartedTimestamp=void 0;break;case"show-anki-ui":const d=e.message;this.ankiUiController.show(this,d.subtitle,d.surroundingSubtitles,d.image,d.audio);break;case"show-anki-ui-after-rerecord":const f=e.message;this.ankiUiController.showAfterRerecord(this,f.uiState);break;case"take-screenshot":this._synced&&(this.ankiUiController.showing?this.ankiUiController.requestRewind(this):this._takeScreenshot());break;case"screenshot-taken":const p=e.message;this.subtitleController.forceHideSubtitles=!1,p.ankiUiState&&this.ankiUiController.showAfterRetakingScreenshot(this,p.ankiUiState),this.controlsController.show();break;case"alert":break;case"request-active-tab-permission":this.requestActiveTabPermissionController.show(),this.recordingMedia=!1;break;case"granted-active-tab-permission":this.requestActiveTabPermissionController.onPermissionGranted()}if("messageId"in e.message){const t={sender:"asbplayer-video",message:{command:"ack-message",messageId:e.message.messageId},src:this.video.src};chrome.runtime.sendMessage(t)}}},chrome.runtime.onMessage.addListener(this.listener),this.subscribed=!0}async _refreshSettings(){const e=await this.settings.getAll();var t;this.recordMedia=e.streamingRecordMedia,this.takeScreenshot=e.streamingTakeScreenshot&&("number"!=typeof this.video.webkitVideoDecodedByteCount||this.video.webkitVideoDecodedByteCount>0),this.cleanScreenshot=e.streamingTakeScreenshot&&e.streamingCleanScreenshot,this.subtitleController.displaySubtitles=e.streamingDisplaySubtitles,this.subtitleController.subtitlePositionOffset=e.subtitlePositionOffset,this.subtitleController.subtitleAlignment=e.subtitleAlignment,this.subtitleController.refresh(),this.videoDataSyncController.updateSettings(e),this.keyBindings.setKeyBindSet(this,e.keyBindSet),this.condensedPlaybackMinimumSkipIntervalMs=e.streamingCondensedPlaybackMinimumSkipIntervalMs,this.fastForwardModePlaybackRate=e.fastForwardModePlaybackRate,this.imageDelay=e.streamingScreenshotDelay,this.subtitleController.setSubtitleSettings(e),this.subtitleController.refresh(),this.ankiUiController.ankiSettings=(t=e,Object.fromEntries(g.map((e=>[e,t[e]])))),this.audioPaddingStart=e.audioPaddingStart,this.audioPaddingEnd=e.audioPaddingEnd,this.maxImageWidth=e.maxImageWidth,this.maxImageHeight=e.maxImageHeight,this.subtitleController.surroundingSubtitlesCountRadius=e.surroundingSubtitlesCountRadius,this.subtitleController.surroundingSubtitlesTimeRadius=e.surroundingSubtitlesTimeRadius,this.copyToClipboardOnMine=e.copyToClipboardOnMine,this.autoPausePreference=e.autoPausePreference,this.keyBindings.setKeyBindSet(this,e.keyBindSet),this.subtitleController.autoCopyCurrentSubtitle=e.autoCopyCurrentSubtitle,this.subtitleController.preCacheDom=e.preCacheSubtitleDom,e.streamingSubsDragAndDrop?this.dragController.bind(this):this.dragController.unbind(),await(async e=>{if(qt){if(await qt,!(e in Wt)){const t=await J(e);Et.addResourceBundle(t.lang,"translation",t.strings),Wt[e]=t.lang}const t=Wt[e];Et.language!==t&&Et.changeLanguage(t)}else qt=new Promise((async(t,n)=>{try{const n=await J(e);Et.init({resources:{[n.lang]:{translation:n.strings}},lng:n.lang,fallbackLng:n.lang,debug:!1,ns:"translation",defaultNS:"translation",interpolation:{escapeValue:!1}}),Wt[e]=n.lang,t()}catch(e){n(e)}})),await qt})(e.language)}unbind(){this.playListener&&(this.video.removeEventListener("play",this.playListener),this.playListener=void 0),this.pauseListener&&(this.video.removeEventListener("pause",this.pauseListener),this.pauseListener=void 0),this.seekedListener&&(this.video.removeEventListener("seeked",this.seekedListener),this.seekedListener=void 0),this.playbackRateListener&&(this.video.removeEventListener("ratechange",this.playbackRateListener),this.playbackRateListener=void 0),this.videoChangeListener&&(this.video.removeEventListener("loadedmetadata",this.videoChangeListener),this.videoChangeListener=void 0),this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=void 0),this.listener&&(chrome.runtime.onMessage.removeListener(this.listener),this.listener=void 0),this.subtitleController.unbind(),this.dragController.unbind(),this.keyBindings.unbind(),this.videoDataSyncController.unbind(),this.subscribed=!1;const e={sender:"asbplayer-video",message:{command:"video-disappeared"},src:this.video.src};chrome.runtime.sendMessage(e)}async _takeScreenshot(){if(!this.takeScreenshot)return;await this._prepareScreenshot();const e={sender:"asbplayer-video",message:{command:"take-screenshot",ankiUiState:this.ankiUiSavedState,...this._imageCaptureParams,subtitleFileName:this.subtitleFileName(),mediaTimestamp:1e3*this.video.currentTime},src:this.video.src};chrome.runtime.sendMessage(e),this.ankiUiSavedState=void 0}async _copySubtitle(e,t,n){if(this.copyToClipboardOnMine&&navigator.clipboard.writeText(t.text),this.takeScreenshot&&await this._prepareScreenshot(),this.recordMedia){this.recordingMedia=!0,this.recordingMediaStartedTimestamp=1e3*this.video.currentTime;const e=Math.max(0,t.start-this.audioPaddingStart);this.seek(e/1e3),await this.play()}const r={sender:"asbplayer-video",message:{command:"record-media-and-forward-subtitle",subtitle:t,surroundingSubtitles:n,record:this.recordMedia,screenshot:this.takeScreenshot,url:this.url,mediaTimestamp:1e3*this.video.currentTime,subtitleFileName:this.subtitleFileName(t.track),postMineAction:e,audioPaddingStart:this.audioPaddingStart,audioPaddingEnd:this.audioPaddingEnd,imageDelay:this.imageDelay,playbackRate:this.video.playbackRate,...this._imageCaptureParams},src:this.video.src};chrome.runtime.sendMessage(r)}async _toggleRecordingMedia(e){if(this.recordingMedia){const t=1e3*this.video.currentTime,n={sender:"asbplayer-video",message:{command:"stop-recording-media",postMineAction:e,startTimestamp:this.recordingMediaStartedTimestamp,endTimestamp:t,playbackRate:this.video.playbackRate,screenshot:this.recordingMediaWithScreenshot,videoDuration:1e3*this.video.duration,url:this.url,subtitleFileName:this.subtitleFileName(),...this._imageCaptureParams,...this._surroundingSubtitlesAroundInterval(this.recordingMediaStartedTimestamp,t)},src:this.video.src};chrome.runtime.sendMessage(n)}else{this.ankiUiSavedState=void 0,this.takeScreenshot&&await this._prepareScreenshot();const t=1e3*this.video.currentTime;this.recordMedia&&(this.recordingMedia=!0,this.recordingMediaStartedTimestamp=t,this.recordingMediaWithScreenshot=this.takeScreenshot);const n={sender:"asbplayer-video",message:{command:"start-recording-media",mediaTimestamp:t,record:this.recordMedia,postMineAction:e,screenshot:this.takeScreenshot,url:this.url,subtitleFileName:this.subtitleFileName(),imageDelay:this.imageDelay,...this._imageCaptureParams},src:this.video.src};chrome.runtime.sendMessage(n)}}_surroundingSubtitlesAroundInterval(t,n){return function(t,n,i,a,o){if(0===t.length)return{};let l=0;const c=r(t,n,e.forward)??t.length-1;for(let e=0;e<t.length&&(l=e,!s(t,e,a,o,n,c));++e);let u=t.length-1;const h=r(t,i,e.backward)??0;for(let e=t.length-1;e>=0&&(u=e,!s(t,e,a,o,i,h));--e);return u<=l?{}:{surroundingSubtitles:t.slice(l,u+1),subtitle:t[c]}}(this.subtitleController.subtitles,t,n,this.ankiUiController.ankiSettings.surroundingSubtitlesCountRadius,this.ankiUiController.ankiSettings.surroundingSubtitlesTimeRadius)}async _prepareScreenshot(){this.cleanScreenshot&&(this.subtitleController.forceHideSubtitles=!0,await this.controlsController.hide())}async rerecord(e,t,n){const r=0===this.subtitleController.subtitles.length,i=r?0:this.audioPaddingStart,s=r?0:this.audioPaddingEnd;this.recordingMedia=!0,this.recordingMediaStartedTimestamp=1e3*this.video.currentTime,this.seek(Math.max(0,e-i)/1e3),await this.play();const a={sender:"asbplayer-video",message:{command:"rerecord-media",duration:t-e,uiState:n,audioPaddingStart:i,audioPaddingEnd:s,playbackRate:this.video.playbackRate,timestamp:e,subtitleFileName:this.subtitleFileName()},src:this.video.src};chrome.runtime.sendMessage(a)}seek(e){wn?document.dispatchEvent(new CustomEvent("asbplayer-netflix-seek",{detail:1e3*e})):this.video.currentTime=e}async play(){if(wn)await this._playNetflix();else try{await this.video.play()}catch(e){if(4!==this.video.readyState)return new Promise(((e,t)=>{const n=async t=>{for(let e=0;e<3;++e)try{await this.video.play();break}catch(e){console.error(e)}e(void 0),this.video.removeEventListener("canplay",n)};this.video.addEventListener("canplay",n)}))}}_playNetflix(){return new Promise(((e,t)=>{const n=async t=>{this.video.removeEventListener("play",n),this.video.removeEventListener("playing",n),e(void 0)};this.video.addEventListener("play",n),this.video.addEventListener("playing",n),document.dispatchEvent(new CustomEvent("asbplayer-netflix-play"))}))}pause(){wn?document.dispatchEvent(new CustomEvent("asbplayer-netflix-pause")):this.video.pause()}bindVideoSelect(e){this.videoDataSyncController.bindVideoSelect(e)}unbindVideoSelect(){this.videoDataSyncController.unbindVideoSelect()}showVideoDataDialog(e){this.videoDataSyncController.show({userRequested:!0,openedFromMiningCommand:e})}async cropAndResize(e){const t=this.video.getBoundingClientRect(),n=this.maxImageWidth,r=this.maxImageHeight;return await c(n,r,t,e)}async loadSubtitles(e,t){const{streamingSubtitleListPreference:n,subtitleRegexFilter:r,subtitleRegexFilterTextReplacement:i,rememberSubtitleOffset:s,lastSubtitleOffset:a}=await this.settings.get(["streamingSubtitleListPreference","subtitleRegexFilter","subtitleRegexFilterTextReplacement","rememberSubtitleOffset","lastSubtitleOffset"]);switch(n){case m.noSubtitleList:const n=new G({regexFilter:r,regexFilterTextReplacement:i,pgsWorkerFactory:async()=>{const e=await(await fetch(chrome.runtime.getURL("./pgs-parser-worker.js"))).text(),t=new Blob([e],{type:"application/javascript"});return new Worker(URL.createObjectURL(t))}}),o=s?a:0,l=await n.subtitles(e,t);this._updateSubtitles(l.map(((e,t)=>({start:e.start+o,end:e.end+o,text:e.text,textImage:e.textImage,track:e.track,index:t,originalStart:e.start,originalEnd:e.end}))),e.map((e=>e.name)));break;case m.app:const c={sender:"asbplayer-video",message:{command:"sync",subtitles:await Promise.all(e.map((async e=>{const t=await _t(await e.arrayBuffer());return{name:e.name,base64:t}})))},src:this.video.src};chrome.runtime.sendMessage(c)}}_updateSubtitles(e,t){this.subtitleController.subtitles=e,this.subtitleController.subtitleFileNames=t,this.subtitleController.cacheHtml(),this._playMode===d.normal||e&&0!==e.length||(this.playMode=d.normal);let n=[];for(let t=0;t<e.length;t++)n.includes(e[t].track)||n.push(e[t].track);this.subtitleController.showLoadedMessage(n),this.videoDataSyncController.unbindVideoSelect(),this.ankiUiSavedState=void 0,this._synced=!0,this._syncedTimestamp=Date.now()}}class En{constructor(e){this._settings=new v(new Y),this._bindings=e,this._frame=new ne((async e=>`<!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <title>asbplayer - Video Select</title>\n </head>\n <body>\n <div id="root" style="width:100%;height:100vh;"></div>\n <script type="application/json" id="loc">${JSON.stringify(await J(e))}<\/script>\n <script src="${chrome.runtime.getURL("./video-select-ui.js")}"><\/script>\n </body>\n </html>`))}bind(){this.messageListener=(e,t,n)=>{if("asbplayer-extension-to-video"===e.sender)switch(e.message.command){case"toggle-video-select":this._trigger(!1);break;case"copy-subtitle":case"toggle-recording":case"take-screenshot":void 0===this._bindings.find((e=>e.synced))&&this._trigger(!0);break;case"subtitles":this._hideUi()}},chrome.runtime.onMessage.addListener(this.messageListener)}unbind(){this._frame.unbind(),this.messageListener&&chrome.runtime.onMessage.removeListener(this.messageListener)}async _trigger(e){if(1===this._bindings.length){const t=this._bindings[0];t.subscribed&&t.showVideoDataDialog(e)}else this._bindings.length>1&&this._showUi(e)}async _showUi(e){const t=await chrome.runtime.sendMessage({sender:"asbplayer-foreground",message:{command:"capture-visible-tab"}}),n=this._bindings.map((async e=>({src:e.video.src,imageDataUrl:await e.cropAndResize(t)}))),r=[];for(const e of n)r.push(await e);this._frame.language=await this._settings.getSingle("language");const i=await this._frame.bind(),s=await this._frame.client();i&&s.onMessage((e=>{"confirm"===e.command?(s.updateState({open:!1}),this._frame.hide(),this._bindings.find((t=>t.video.src===e.selectedVideoElementSrc))?.showVideoDataDialog(!1)):"cancel"===e.command&&(s.updateState({open:!1}),this._frame.hide())})),this._frame.show();const a=await this._settings.getSingle("themeType");s.updateState({open:!0,themeType:a,videoElements:r,openedFromMiningCommand:e})}async _hideUi(){this._frame.hidden||((await this._frame.client()).updateState({open:!1}),this._frame.hide())}}var xn,kn=new Uint8Array(16);function On(){if(!xn&&!(xn="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return xn(kn)}const _n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var Cn=[],Tn=0;Tn<256;++Tn)Cn.push((Tn+256).toString(16).substr(1));const An=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(Cn[e[t+0]]+Cn[e[t+1]]+Cn[e[t+2]]+Cn[e[t+3]]+"-"+Cn[e[t+4]]+Cn[e[t+5]]+"-"+Cn[e[t+6]]+Cn[e[t+7]]+"-"+Cn[e[t+8]]+Cn[e[t+9]]+"-"+Cn[e[t+10]]+Cn[e[t+11]]+Cn[e[t+12]]+Cn[e[t+13]]+Cn[e[t+14]]+Cn[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&_n.test(e)}(n))throw TypeError("Stringified UUID is invalid");return n},Pn=function(e,t,n){var r=(e=e||{}).random||(e.rng||On)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return An(r)};class Fn{constructor(){this.frameId=Pn()}bind(){this._windowMessageListener=e=>{"asbplayer-video"===e.data.sender&&e.source===window.parent&&"frameId"===e.data.message.command&&window.parent.postMessage({sender:"asbplayer-video",message:{requestId:e.data.message.requestId,frameId:this.frameId}},"*")},window.addEventListener("message",this._windowMessageListener)}unbind(){this._windowMessageListener&&window.removeEventListener("message",this._windowMessageListener)}}const Nn=e=>new Promise(((t,n)=>{if(!e.contentWindow)return t(void 0);const r=Pn();let i;const s=n=>{n.source===e.contentWindow&&n.data.message?.requestId===r&&"string"==typeof n.data.message?.frameId&&(i&&clearTimeout(i),window.removeEventListener("message",s),t(n.data.message.frameId))};window.addEventListener("message",s),e.contentWindow.postMessage({sender:"asbplayer-video",message:{command:"frameId",requestId:r}},"*"),i=setTimeout((()=>{window.removeEventListener("message",s),t(void 0)}),1e3)}));async function Ln(e){const t=await(await fetch(chrome.runtime.getURL("./mp3-encoder-worker.js"))).text();return`<!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <title>asbplayer - Anki</title>\n </head>\n <body>\n <div id="root" style="width:100%;height:100vh;"></div>\n <script type="application/json" id="loc">${JSON.stringify(await J(e))}<\/script>\n <script id="mp3-encoder-worker" type="javascript/worker">${t}<\/script>\n <script src="${chrome.runtime.getURL("./anki-ui.js")}"><\/script>\n </body>\n </html>`}class Rn{constructor(e){this._frame=new ne(Ln),this._settings=e}async show(e){const{themeType:t,language:n,...r}=await this._settings.get(["themeType","language",...g]),i=await this._client(n,r),s={type:"initial",open:!0,canRerecord:!1,settingsProvider:r,source:l(e.subtitleFileName,e.mediaTimestamp??0),themeType:t,dialogRequestedTimestamp:0,...e};i.updateState(s)}async updateSettings(){const e=await this._settings.get([...g]);this._frame.bound&&this._frame.client().then((t=>t.sendMessage({command:"ankiSettings",value:e})))}async _client(e,t){this._frame.fetchOptions={allowedFetchUrl:t.ankiConnectUrl},this._frame.language=e;const n=await this._frame.bind(),r=await this._frame.client();return n&&r.onMessage((e=>{switch(e.command){case"openSettings":const t={sender:"asbplayer-video-tab",message:{command:"open-asbplayer-settings"}};return void chrome.runtime.sendMessage(t);case"copy-to-clipboard":const n={sender:"asbplayer-video-tab",message:{command:"copy-to-clipboard",dataUrl:e.dataUrl}};return void chrome.runtime.sendMessage(n);case"resume":return void this._frame.hide()}})),this._frame.show(),r}unbind(){this._frame.unbind()}}const In=new Y,jn=new v(In),Mn={},Dn=()=>{const e=document.getElementsByTagName("iframe");for(let t=0;t<e.length;++t){const n=e[t];Object.values(Mn).find((e=>n===e))||Nn(n).then((e=>{e&&(Mn[e]=n)}))}for(const t of Object.keys(Mn)){let n=!1;for(let r=0;r<e.length;++r)e[r].isSameNode(Mn[t])&&(n=!0);n||delete Mn[t]}};let $n;const Bn=()=>{jn.getSingle("keyBindSet").then((e=>{$n?.(),$n=new bn(e).bindToggleSidePanel((e=>{e.preventDefault(),e.stopImmediatePropagation(),chrome.runtime.sendMessage({sender:"asbplayer-video-tab",message:{command:"toggle-side-panel"}})}),(()=>!1),!0)}))},Un=e=>{if(e.src)return!0;for(let t=0,n=e.children.length;t<n;t++){const n=e.children[t];if("SOURCE"===n.tagName&&n.src)return!0}return!1},Vn=()=>{const e=[],t=Tt();let n,r=void 0!==t;window.self!==window.top&&(n=new Fn,n.bind());const i=()=>{const i=document.getElementsByTagName("video");for(let s=0;s<i.length;++s){const a=i[s];if(!(e.filter((e=>e.video.isSameNode(a))).length>0)&&Un(a)&&!t?.shouldIgnore(a)){const t=new Sn(a,r,n?.frameId);t.bind(),e.push(t)}}for(let t=e.length-1;t>=0;--t){const n=e[t];let r=!1;for(let e=0;e<i.length;++e){const t=i[e];if(t.isSameNode(n.video)&&Un(t)){r=!0;break}}r||(e.splice(t,1),n.unbind())}};i(),Dn();const s=setInterval(i,1e3),a=setInterval(Dn,1e4),o=new En(e);o.bind();const l=new Rn(jn),u=window.self===window.top;u&&Bn();const h=(e,t,n)=>{if(u&&"asbplayer-extension-to-video"===e.sender)switch(e.message.command){case"copy-to-clipboard":const t=e.message;fetch(t.dataUrl).then((e=>e.blob())).then((e=>navigator.clipboard.write([new ClipboardItem({[e.type]:e})]).catch(console.error)));break;case"crop-and-resize":const r=e.message;let i=r.rect;if(void 0!==r.frameId){const e=Mn[r.frameId];if(void 0!==e){const t=e.getBoundingClientRect();i={left:i.left+t.left,top:i.top+t.top,width:i.width,height:i.height}}}return c(r.maxWidth,r.maxHeight,i,r.dataUrl).then((e=>n({dataUrl:e}))),!0;case"show-anki-ui":void 0===e.src&&l.show(e.message);break;case"settings-updated":Bn(),l.updateSettings()}};chrome.runtime.onMessage.addListener(h),window.addEventListener("beforeunload",(t=>{for(let t of e)t.unbind();e.length=0,clearInterval(s),clearInterval(a),o.unbind(),n?.unbind(),$n?.(),chrome.runtime.onMessage.removeListener(h)}))};"complete"===document.readyState?Vn():document.addEventListener("readystatechange",(e=>{"complete"===document.readyState&&Vn()}))})()})();