diff --git a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/background.min.js b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/background.min.js index b2cf4e3..e7bb1d8 100644 --- a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/background.min.js +++ b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/background.min.js @@ -1 +1 @@ -(()=>{var e={878:e=>{e.exports={upperBaselinePos:.15,lowerBaselinePos:.85,primaryImageScale:.75,primaryImageOpacity:1,primaryTextScale:.95,primaryTextOpacity:1,primaryTextColor:"#ffffff",secondaryImageScale:.5,secondaryImageOpacity:1,secondaryTextScale:1,secondaryTextStroke:2,secondaryTextOpacity:1,secondaryTextColor:"#ffffff",secondaryLanguageMode:"audio",secondaryLanguageLastUsed:void 0,secondaryLanguageLastUsedIsCaption:void 0}}},t={};function s(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,s),a.exports}(()=>{const e=s(878);let t=Object.assign({},e);function n(t){return Object.keys(e).every((e=>e in t))}function o(){t.primaryImageOpacity=1,t.primaryTextOpacity=1,t.secondaryImageOpacity=1,t.secondaryTextOpacity=1,chrome.storage.local.set({settings:t},(()=>{console.log("Settings: saved into local storage")}))}chrome.storage.local.get(["settings"],(e=>{console.log("Loaded: settings=",e.settings),e.settings&&n(e.settings)?t=e.settings:o()}));let a={};function c(){Object.keys(a).map((e=>a[e])).forEach((e=>{try{e.postMessage({settings:t})}catch(e){console.error("Error: cannot dispatch settings,",e)}}))}chrome.runtime.onConnectExternal.addListener((s=>function(s){const i=s.sender&&s.sender.tab&&s.sender.tab.id;i&&(a[i]=s,console.log(`Connected: ${i} (tab)`),s.postMessage({settings:t}),s.onMessage.addListener((a=>{if(a.settings){console.log("Received from injected agent: settings=",a.settings);let i=Object.assign({},t);i=Object.assign(i,a.settings),n(i)?t=i:(t=Object.assign({},e),s.postMessage({settings:t})),o(),c()}else a.startPlayback?(console.log("Saturate icon"),function(e){chrome.browserAction.setIcon({tabId:e,path:{16:"icon16.png",32:"icon32.png"}})}(i)):a.stopPlayback&&(console.log("Desaturate icon"),function(e){chrome.browserAction.setIcon({tabId:e,path:{16:"icon16-gray.png",32:"icon32-gray.png"}})}(i))})),s.onDisconnect.addListener((()=>{delete a[i],console.log(`Disconnected: ${i} (tab)`)})))}(s))),chrome.runtime.onConnect.addListener((s=>function(s){const a=s.name;console.log(`Connected: ${a} (internal)`),"settings"===a&&(s.postMessage({settings:t}),s.onMessage.addListener((a=>{if(a.settings){console.log("Received: settings=",a.settings);let o=Object.assign({},t);o=Object.assign(o,a.settings),n(o)?t=o:(t=Object.assign({},e),s.postMessage({settings:t}))}else t=Object.assign({},e),s.postMessage({settings:t});o(),c()}))),s.onDisconnect.addListener((()=>{console.log(`Disconnected: ${a} (internal)`)}))}(s)))})()})(); \ No newline at end of file +(()=>{var e={775:e=>{e.exports={upperBaselinePos:.15,lowerBaselinePos:.85,primaryImageScale:.75,primaryImageOpacity:1,primaryTextScale:.95,primaryTextOpacity:1,primaryTextColor:"#ffffff",secondaryImageScale:.5,secondaryImageOpacity:1,secondaryTextScale:1,secondaryTextStroke:2,secondaryTextOpacity:1,secondaryTextColor:"#ffffff",secondaryLanguageMode:"audio",secondaryLanguageLastUsed:void 0,secondaryLanguageLastUsedIsCaption:void 0}}},t={};function s(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,s),a.exports}(()=>{const e=s(775);let t=Object.assign({},e);function n(t){return Object.keys(e).every((e=>e in t))}function o(){t.primaryImageOpacity=1,t.primaryTextOpacity=1,t.secondaryImageOpacity=1,t.secondaryTextOpacity=1,chrome.storage.local.set({settings:t},(()=>{console.log("Settings: saved into local storage")}))}chrome.storage.local.get(["settings"],(e=>{console.log("Loaded: settings=",e.settings),e.settings&&n(e.settings)?t=e.settings:o()}));let a={};function c(){Object.keys(a).map((e=>a[e])).forEach((e=>{try{e.postMessage({settings:t})}catch(e){console.error("Error: cannot dispatch settings,",e)}}))}browser.runtime.onConnectExternal.addListener((s=>function(s){const i=s.sender&&s.sender.tab&&s.sender.tab.id;i&&(a[i]=s,console.log(`Connected: ${i} (tab)`),s.postMessage({settings:t}),s.onMessage.addListener((a=>{if(a.settings){console.log("Received from injected agent: settings=",a.settings);let i=Object.assign({},t);i=Object.assign(i,a.settings),n(i)?t=i:(t=Object.assign({},e),s.postMessage({settings:t})),o(),c()}else a.startPlayback?(console.log("Saturate icon"),function(e){chrome.browserAction.setIcon({tabId:e,path:{16:"icon16.png",32:"icon32.png"}})}(i)):a.stopPlayback&&(console.log("Desaturate icon"),function(e){chrome.browserAction.setIcon({tabId:e,path:{16:"icon16-gray.png",32:"icon32-gray.png"}})}(i))})),s.onDisconnect.addListener((()=>{delete a[i],console.log(`Disconnected: ${i} (tab)`)})))}(s))),browser.runtime.onConnect.addListener((s=>function(s){const a=s.name;console.log(`Connected: ${a} (internal)`),"settings"===a&&(s.postMessage({settings:t}),s.onMessage.addListener((a=>{if(a.settings){console.log("Received: settings=",a.settings);let o=Object.assign({},t);o=Object.assign(o,a.settings),n(o)?t=o:(t=Object.assign({},e),s.postMessage({settings:t}))}else t=Object.assign({},e),s.postMessage({settings:t});o(),c()}))),s.onDisconnect.addListener((()=>{console.log(`Disconnected: ${a} (internal)`)}))}(s)))})()})(); \ No newline at end of file diff --git a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/content.min.js b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/content.min.js index 242d6f2..8d07907 100644 --- a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/content.min.js +++ b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/content.min.js @@ -1 +1 @@ -(()=>{var t={520:t=>{const e="NflxMultiSubs>",n={log:(...t)=>window.console.log(e,...t),warn:(...t)=>window.console.warn(e,...t),error:(...t)=>window.console.error(e,...t),debug:(...t)=>window.console.debug(e,...t)};t.exports=n}},e={};function n(s){var a=e[s];if(void 0!==a)return a.exports;var o=e[s]={exports:{}};return t[s](o,o.exports,n),o.exports}(()=>{const t=n(520);let e;window.addEventListener("load",(()=>{let e=document.createElement("script");e.setAttribute("type","text/javascript"),e.textContent=`(() => {\n window.__nflxMultiSubsExtId = ${JSON.stringify(chrome.runtime.id)};\n })();`,document.body.appendChild(e),["nflxmultisubs.min.js"].forEach((e=>{const n=document.createElement("script");n.setAttribute("type","text/javascript"),n.setAttribute("src",chrome.runtime.getURL(e)),document.head.appendChild(n),t.log(`Injected: ${e}`)}))})),window.addEventListener("message",(t=>{t.data&&"nflxmultisubs"===t.data.namespace&&("connect"===t.data.action?e||(e=browser.runtime.connect(browser.runtime.id),e.onMessage.addListener((t=>{t.settings&&window.postMessage({namespace:"nflxmultisubs",action:"apply-settings",settings:t.settings},"*")}))):"disconnect"===t.data.action?e&&(e.disconnect(),e=null,e.disconnect()):"update-settings"===t.data.action?e&&t.data.settings&&e.postMessage({settings:t.data.settings}):"startPlayback"===t.data.action?e&&e.postMessage({startPlayback:1}):"stopPlayback"===t.data.action&&e&&e.postMessage({stopPlayback:1}))}),!1)})()})(); \ No newline at end of file +(()=>{var t={777:t=>{const e="NflxMultiSubs>",s={log:(...t)=>window.console.log(e,...t),warn:(...t)=>window.console.warn(e,...t),error:(...t)=>window.console.error(e,...t),debug:(...t)=>window.console.debug(e,...t)};t.exports=s}},e={};function s(n){var a=e[n];if(void 0!==a)return a.exports;var o=e[n]={exports:{}};return t[n](o,o.exports,s),o.exports}(()=>{const t=s(777);let e;window.addEventListener("load",(()=>{let e=document.createElement("script");e.setAttribute("type","text/javascript"),e.textContent=`(() => {\n window.__nflxMultiSubsExtId = ${JSON.stringify(browser.runtime.id)};\n })();`,document.body.appendChild(e),["nflxmultisubs.min.js"].forEach((e=>{const s=document.createElement("script");s.setAttribute("type","text/javascript"),s.setAttribute("src",browser.runtime.getURL(e)),document.head.appendChild(s),t.log(`Injected: ${e}`)}))})),window.addEventListener("message",(t=>{t.data&&"nflxmultisubs"===t.data.namespace&&("connect"===t.data.action?e||(e=browser.runtime.connect(browser.runtime.id),e.onMessage.addListener((t=>{t.settings&&window.postMessage({namespace:"nflxmultisubs",action:"apply-settings",settings:t.settings},"*")}))):"disconnect"===t.data.action?e&&(e.disconnect(),e=null,e.disconnect()):"update-settings"===t.data.action?e&&t.data.settings&&e.postMessage({settings:t.data.settings}):"startPlayback"===t.data.action?e&&e.postMessage({startPlayback:1}):"stopPlayback"===t.data.action&&e&&e.postMessage({stopPlayback:1}))}),!1)})()})(); \ No newline at end of file diff --git a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/manifest.json b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/manifest.json index f71998c..4e24903 100644 --- a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/manifest.json +++ b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/manifest.json @@ -1,7 +1,7 @@ { "short_name": "NflxMultiSubs", "description": "Bilingual Subtitles for Netflix", - "version": "2.4.3", + "version": "2.4.4", "name": "NflxMultiSubs", "manifest_version": 2, "author": "WingCH", @@ -16,7 +16,8 @@ ] }, "browser_action": { - "default_icon": "icon-gray.png" + "default_icon": "icon-gray.png", + "default_popup": "settings.html" }, "icons": { "16": "icon16.png", @@ -43,4 +44,4 @@ "web_accessible_resources": [ "nflxmultisubs.min.js" ] -} +} \ No newline at end of file diff --git a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/nflxmultisubs.min.js b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/nflxmultisubs.min.js index 0d3eb92..f3b3053 100644 --- a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/nflxmultisubs.min.js +++ b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/nflxmultisubs.min.js @@ -1,2 +1,2 @@ /*! For license information please see nflxmultisubs.min.js.LICENSE.txt */ -(()=>{var t={733:(t,e,r)=>{t.exports=function t(e,r,i){function n(a,o){if(!r[a]){if(!e[a]){if(s)return s(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[a]={exports:{}};e[a][0].call(u.exports,(function(t){return n(e[a][1][t]||t)}),u,u.exports,t,e,r,i)}return r[a].exports}for(var s=void 0,a=0;a>2,o=(3&e)<<4|r>>4,l=1>6:64,u=2>4,r=(15&a)<<4|(o=s.indexOf(t.charAt(u++)))>>2,i=(3&o)<<6|(l=s.indexOf(t.charAt(u++))),c[h++]=e,64!==o&&(c[h++]=r),64!==l&&(c[h++]=i);return c}},{"./support":30,"./utils":32}],2:[function(t,e,r){"use strict";var i=t("./external"),n=t("./stream/DataWorker"),s=t("./stream/Crc32Probe"),a=t("./stream/DataLengthProbe");function o(t,e,r,i,n){this.compressedSize=t,this.uncompressedSize=e,this.crc32=r,this.compression=i,this.compressedContent=n}o.prototype={getContentWorker:function(){var t=new n(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),e=this;return t.on("end",(function(){if(this.streamInfo.data_length!==e.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),t},getCompressedWorker:function(){return new n(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},o.createWorkerFrom=function(t,e,r){return t.pipe(new s).pipe(new a("uncompressedSize")).pipe(e.compressWorker(r)).pipe(new a("compressedSize")).withStreamInfo("compression",e)},e.exports=o},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,e,r){"use strict";var i=t("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(t){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},r.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,e,r){"use strict";var i=t("./utils"),n=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();e.exports=function(t,e){return void 0!==t&&t.length?"string"!==i.getTypeOf(t)?function(t,e,r,i){var s=n,a=0+r;t^=-1;for(var o=0;o>>8^s[255&(t^e[o])];return-1^t}(0|e,t,t.length):function(t,e,r,i){var s=n,a=0+r;t^=-1;for(var o=0;o>>8^s[255&(t^e.charCodeAt(o))];return-1^t}(0|e,t,t.length):0}},{"./utils":32}],5:[function(t,e,r){"use strict";r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(t,e,r){"use strict";var i;i="undefined"!=typeof Promise?Promise:t("lie"),e.exports={Promise:i}},{lie:37}],7:[function(t,e,r){"use strict";var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,n=t("pako"),s=t("./utils"),a=t("./stream/GenericWorker"),o=i?"uint8array":"array";function l(t,e){a.call(this,"FlateWorker/"+t),this._pako=null,this._pakoAction=t,this._pakoOptions=e,this.meta={}}r.magic="\b\0",s.inherits(l,a),l.prototype.processChunk=function(t){this.meta=t.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(o,t.data),!1)},l.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new n[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},r.compressWorker=function(t){return new l("Deflate",t)},r.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,e,r){"use strict";function i(t,e){var r,i="";for(r=0;r>>=8;return i}function n(t,e,r,n,a,h){var d,c,f=t.file,p=t.compression,m=h!==o.utf8encode,g=s.transformTo("string",h(f.name)),_=s.transformTo("string",o.utf8encode(f.name)),b=f.comment,y=s.transformTo("string",h(b)),v=s.transformTo("string",o.utf8encode(b)),w=_.length!==f.name.length,k=v.length!==b.length,x="",S="",E="",C=f.dir,A=f.date,z={crc32:0,compressedSize:0,uncompressedSize:0};e&&!r||(z.crc32=t.crc32,z.compressedSize=t.compressedSize,z.uncompressedSize=t.uncompressedSize);var I=0;e&&(I|=8),m||!w&&!k||(I|=2048);var O=0,N=0;C&&(O|=16),"UNIX"===a?(N=798,O|=function(t,e){var r=t;return t||(r=e?16893:33204),(65535&r)<<16}(f.unixPermissions,C)):(N=20,O|=function(t){return 63&(t||0)}(f.dosPermissions)),d=A.getUTCHours(),d<<=6,d|=A.getUTCMinutes(),d<<=5,d|=A.getUTCSeconds()/2,c=A.getUTCFullYear()-1980,c<<=4,c|=A.getUTCMonth()+1,c<<=5,c|=A.getUTCDate(),w&&(S=i(1,1)+i(l(g),4)+_,x+="up"+i(S.length,2)+S),k&&(E=i(1,1)+i(l(y),4)+v,x+="uc"+i(E.length,2)+E);var T="";return T+="\n\0",T+=i(I,2),T+=p.magic,T+=i(d,2),T+=i(c,2),T+=i(z.crc32,4),T+=i(z.compressedSize,4),T+=i(z.uncompressedSize,4),T+=i(g.length,2),T+=i(x.length,2),{fileRecord:u.LOCAL_FILE_HEADER+T+g+x,dirRecord:u.CENTRAL_FILE_HEADER+i(N,2)+T+i(y.length,2)+"\0\0\0\0"+i(O,4)+i(n,4)+g+x+y}}var s=t("../utils"),a=t("../stream/GenericWorker"),o=t("../utf8"),l=t("../crc32"),u=t("../signature");function h(t,e,r,i){a.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=e,this.zipPlatform=r,this.encodeFileName=i,this.streamFiles=t,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}s.inherits(h,a),h.prototype.push=function(t){var e=t.meta.percent||0,r=this.entriesCount,i=this._sources.length;this.accumulate?this.contentBuffer.push(t):(this.bytesWritten+=t.data.length,a.prototype.push.call(this,{data:t.data,meta:{currentFile:this.currentFile,percent:r?(e+100*(r-i-1))/r:100}}))},h.prototype.openedSource=function(t){this.currentSourceOffset=this.bytesWritten,this.currentFile=t.file.name;var e=this.streamFiles&&!t.file.dir;if(e){var r=n(t,e,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(t){this.accumulate=!1;var e=this.streamFiles&&!t.file.dir,r=n(t,e,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),e)this.push({data:function(t){return u.DATA_DESCRIPTOR+i(t.crc32,4)+i(t.compressedSize,4)+i(t.uncompressedSize,4)}(t),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var t=this.bytesWritten,e=0;e=this.index;e--)r=(r<<8)+this.byteAt(e);return this.index+=t,r},readString:function(t){return i.transformTo("string",this.readData(t))},readData:function(t){},lastIndexOfSignature:function(t){},readAndCheckSignature:function(t){},readDate:function(){var t=this.readInt(4);return new Date(Date.UTC(1980+(t>>25&127),(t>>21&15)-1,t>>16&31,t>>11&31,t>>5&63,(31&t)<<1))}},e.exports=n},{"../utils":32}],19:[function(t,e,r){"use strict";var i=t("./Uint8ArrayReader");function n(t){i.call(this,t)}t("../utils").inherits(n,i),n.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,e,r){"use strict";var i=t("./DataReader");function n(t){i.call(this,t)}t("../utils").inherits(n,i),n.prototype.byteAt=function(t){return this.data.charCodeAt(this.zero+t)},n.prototype.lastIndexOfSignature=function(t){return this.data.lastIndexOf(t)-this.zero},n.prototype.readAndCheckSignature=function(t){return t===this.readData(4)},n.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./DataReader":18}],21:[function(t,e,r){"use strict";var i=t("./ArrayReader");function n(t){i.call(this,t)}t("../utils").inherits(n,i),n.prototype.readData=function(t){if(this.checkOffset(t),0===t)return new Uint8Array(0);var e=this.data.subarray(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./ArrayReader":17}],22:[function(t,e,r){"use strict";var i=t("../utils"),n=t("../support"),s=t("./ArrayReader"),a=t("./StringReader"),o=t("./NodeBufferReader"),l=t("./Uint8ArrayReader");e.exports=function(t){var e=i.getTypeOf(t);return i.checkSupport(e),"string"!==e||n.uint8array?"nodebuffer"===e?new o(t):n.uint8array?new l(i.transformTo("uint8array",t)):new s(i.transformTo("array",t)):new a(t)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,e,r){"use strict";r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b"},{}],24:[function(t,e,r){"use strict";var i=t("./GenericWorker"),n=t("../utils");function s(t){i.call(this,"ConvertWorker to "+t),this.destType=t}n.inherits(s,i),s.prototype.processChunk=function(t){this.push({data:n.transformTo(this.destType,t.data),meta:t.meta})},e.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(t,e,r){"use strict";var i=t("./GenericWorker"),n=t("../crc32");function s(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(s,i),s.prototype.processChunk=function(t){this.streamInfo.crc32=n(t.data,this.streamInfo.crc32||0),this.push(t)},e.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,e,r){"use strict";var i=t("../utils"),n=t("./GenericWorker");function s(t){n.call(this,"DataLengthProbe for "+t),this.propName=t,this.withStreamInfo(t,0)}i.inherits(s,n),s.prototype.processChunk=function(t){if(t){var e=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=e+t.data.length}n.prototype.processChunk.call(this,t)},e.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(t,e,r){"use strict";var i=t("../utils"),n=t("./GenericWorker");function s(t){n.call(this,"DataWorker");var e=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,t.then((function(t){e.dataIsReady=!0,e.data=t,e.max=t&&t.length||0,e.type=i.getTypeOf(t),e.isPaused||e._tickAndRepeat()}),(function(t){e.error(t)}))}i.inherits(s,n),s.prototype.cleanUp=function(){n.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var t=null,e=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":t=this.data.substring(this.index,e);break;case"uint8array":t=this.data.subarray(this.index,e);break;case"array":case"nodebuffer":t=this.data.slice(this.index,e)}return this.index=e,this.push({data:t,meta:{percent:this.max?this.index/this.max*100:0}})},e.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(t,e,r){"use strict";function i(t){this.name=t||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(t){this.emit("data",t)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(t){this.emit("error",t)}return!0},error:function(t){return!this.isFinished&&(this.isPaused?this.generatedError=t:(this.isFinished=!0,this.emit("error",t),this.previous&&this.previous.error(t),this.cleanUp()),!0)},on:function(t,e){return this._listeners[t].push(e),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(t,e){if(this._listeners[t])for(var r=0;r "+t:t}},e.exports=i},{}],29:[function(t,e,r){"use strict";var i=t("../utils"),n=t("./ConvertWorker"),s=t("./GenericWorker"),a=t("../base64"),o=t("../support"),l=t("../external"),u=null;if(o.nodestream)try{u=t("../nodejs/NodejsStreamOutputAdapter")}catch(t){}function h(t,e,r){var a=e;switch(e){case"blob":case"arraybuffer":a="uint8array";break;case"base64":a="string"}try{this._internalType=a,this._outputType=e,this._mimeType=r,i.checkSupport(a),this._worker=t.pipe(new n(a)),t.lock()}catch(t){this._worker=new s("error"),this._worker.error(t)}}h.prototype={accumulate:function(t){return function(t,e){return new l.Promise((function(r,n){var s=[],o=t._internalType,l=t._outputType,u=t._mimeType;t.on("data",(function(t,r){s.push(t),e&&e(r)})).on("error",(function(t){s=[],n(t)})).on("end",(function(){try{var t=function(t,e,r){switch(t){case"blob":return i.newBlob(i.transformTo("arraybuffer",e),r);case"base64":return a.encode(e);default:return i.transformTo(t,e)}}(l,function(t,e){var r,i=0,n=null,s=0;for(r=0;r>>6:(r<65536?e[a++]=224|r>>>12:(e[a++]=240|r>>>18,e[a++]=128|r>>>12&63),e[a++]=128|r>>>6&63),e[a++]=128|63&r);return e}(t)},r.utf8decode=function(t){return n.nodebuffer?i.transformTo("nodebuffer",t).toString("utf-8"):function(t){var e,r,n,s,a=t.length,l=new Array(2*a);for(e=r=0;e>10&1023,l[r++]=56320|1023&n)}return l.length!==r&&(l.subarray?l=l.subarray(0,r):l.length=r),i.applyFromCharCode(l)}(t=i.transformTo(n.uint8array?"uint8array":"array",t))},i.inherits(u,a),u.prototype.processChunk=function(t){var e=i.transformTo(n.uint8array?"uint8array":"array",t.data);if(this.leftOver&&this.leftOver.length){if(n.uint8array){var s=e;(e=new Uint8Array(s.length+this.leftOver.length)).set(this.leftOver,0),e.set(s,this.leftOver.length)}else e=this.leftOver.concat(e);this.leftOver=null}var a=function(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;0<=r&&128==(192&t[r]);)r--;return r<0||0===r?e:r+o[t[r]]>e?r:e}(e),l=e;a!==e.length&&(n.uint8array?(l=e.subarray(0,a),this.leftOver=e.subarray(a,e.length)):(l=e.slice(0,a),this.leftOver=e.slice(a,e.length))),this.push({data:r.utf8decode(l),meta:t.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=u,i.inherits(h,a),h.prototype.processChunk=function(t){this.push({data:r.utf8encode(t.data),meta:t.meta})},r.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,e,r){"use strict";var i=t("./support"),n=t("./base64"),s=t("./nodejsUtils"),a=t("set-immediate-shim"),o=t("./external");function l(t){return t}function u(t,e){for(var r=0;r>8;this.dir=!!(16&this.externalFileAttributes),0==t&&(this.dosPermissions=63&this.externalFileAttributes),3==t&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(t){if(this.extraFields[1]){var e=i(this.extraFields[1].value);this.uncompressedSize===n.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===n.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===n.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===n.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(t){var e,r,i,n=t.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});t.index+4>>6:(r<65536?e[a++]=224|r>>>12:(e[a++]=240|r>>>18,e[a++]=128|r>>>12&63),e[a++]=128|r>>>6&63),e[a++]=128|63&r);return e},r.buf2binstring=function(t){return l(t,t.length)},r.binstring2buf=function(t){for(var e=new i.Buf8(t.length),r=0,n=e.length;r>10&1023,u[i++]=56320|1023&n)}return l(u,i)},r.utf8border=function(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;0<=r&&128==(192&t[r]);)r--;return r<0||0===r?e:r+a[t[r]]>e?r:e}},{"./common":41}],43:[function(t,e,r){"use strict";e.exports=function(t,e,r,i){for(var n=65535&t|0,s=t>>>16&65535|0,a=0;0!==r;){for(r-=a=2e3>>1:t>>>1;e[r]=t}return e}();e.exports=function(t,e,r,n){var s=i,a=n+r;t^=-1;for(var o=n;o>>8^s[255&(t^e[o])];return-1^t}},{}],46:[function(t,e,r){"use strict";var i,n=t("../utils/common"),s=t("./trees"),a=t("./adler32"),o=t("./crc32"),l=t("./messages"),u=-2,h=258,d=262,c=113;function f(t,e){return t.msg=l[e],e}function p(t){return(t<<1)-(4t.avail_out&&(r=t.avail_out),0!==r&&(n.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))}function _(t,e){s._tr_flush_block(t,0<=t.block_start?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,g(t.strm)}function b(t,e){t.pending_buf[t.pending++]=e}function y(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function v(t,e){var r,i,n=t.max_chain_length,s=t.strstart,a=t.prev_length,o=t.nice_match,l=t.strstart>t.w_size-d?t.strstart-(t.w_size-d):0,u=t.window,c=t.w_mask,f=t.prev,p=t.strstart+h,m=u[s+a-1],g=u[s+a];t.prev_length>=t.good_match&&(n>>=2),o>t.lookahead&&(o=t.lookahead);do{if(u[(r=e)+a]===g&&u[r+a-1]===m&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&sl&&0!=--n);return a<=t.lookahead?a:t.lookahead}function w(t){var e,r,i,s,l,u,h,c,f,p,m=t.w_size;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=m+(m-d)){for(n.arraySet(t.window,t.window,m,m,0),t.match_start-=m,t.strstart-=m,t.block_start-=m,e=r=t.hash_size;i=t.head[--e],t.head[e]=m<=i?i-m:0,--r;);for(e=r=m;i=t.prev[--e],t.prev[e]=m<=i?i-m:0,--r;);s+=m}if(0===t.strm.avail_in)break;if(u=t.strm,h=t.window,c=t.strstart+t.lookahead,p=void 0,(f=s)<(p=u.avail_in)&&(p=f),r=0===p?0:(u.avail_in-=p,n.arraySet(h,u.input,u.next_in,p,c),1===u.state.wrap?u.adler=a(u.adler,h,p,c):2===u.state.wrap&&(u.adler=o(u.adler,h,p,c)),u.next_in+=p,u.total_in+=p,p),t.lookahead+=r,t.lookahead+t.insert>=3)for(l=t.strstart-t.insert,t.ins_h=t.window[l],t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<=3)if(i=s._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<=3&&t.match_length<=t.prev_length){for(n=t.strstart+t.lookahead-3,i=s._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;++t.strstart<=n&&(t.ins_h=(t.ins_h<t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(w(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var i=t.block_start+r;if((0===t.strstart||t.strstart>=i)&&(t.lookahead=t.strstart-i,t.strstart=i,_(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-d&&(_(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(_(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(_(t,!1),t.strm.avail_out),1)})),new S(4,4,8,4,k),new S(4,5,16,8,k),new S(4,6,32,32,k),new S(4,4,16,16,x),new S(8,16,32,32,x),new S(8,16,128,128,x),new S(8,32,128,256,x),new S(32,128,258,1024,x),new S(32,258,258,4096,x)],r.deflateInit=function(t,e){return z(t,e,8,15,8,0)},r.deflateInit2=z,r.deflateReset=A,r.deflateResetKeep=C,r.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?u:(t.state.gzhead=e,0):u},r.deflate=function(t,e){var r,n,a,l;if(!t||!t.state||5>8&255),b(n,n.gzhead.time>>16&255),b(n,n.gzhead.time>>24&255),b(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),b(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(b(n,255&n.gzhead.extra.length),b(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=o(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(b(n,0),b(n,0),b(n,0),b(n,0),b(n,0),b(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),b(n,3),n.status=c);else{var d=8+(n.w_bits-8<<4)<<8;d|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(d|=32),d+=31-d%31,n.status=c,y(n,d),0!==n.strstart&&(y(n,t.adler>>>16),y(n,65535&t.adler)),t.adler=1}if(69===n.status)if(n.gzhead.extra){for(a=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>a&&(t.adler=o(t.adler,n.pending_buf,n.pending-a,a)),g(t),a=n.pending,n.pending!==n.pending_buf_size));)b(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>a&&(t.adler=o(t.adler,n.pending_buf,n.pending-a,a)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=o(t.adler,n.pending_buf,n.pending-a,a)),g(t),a=n.pending,n.pending===n.pending_buf_size)){l=1;break}l=n.gzindexa&&(t.adler=o(t.adler,n.pending_buf,n.pending-a,a)),0===l&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=o(t.adler,n.pending_buf,n.pending-a,a)),g(t),a=n.pending,n.pending===n.pending_buf_size)){l=1;break}l=n.gzindexa&&(t.adler=o(t.adler,n.pending_buf,n.pending-a,a)),0===l&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&g(t),n.pending+2<=n.pending_buf_size&&(b(n,255&t.adler),b(n,t.adler>>8&255),t.adler=0,n.status=c)):n.status=c),0!==n.pending){if(g(t),0===t.avail_out)return n.last_flush=-1,0}else if(0===t.avail_in&&p(e)<=p(r)&&4!==e)return f(t,-5);if(666===n.status&&0!==t.avail_in)return f(t,-5);if(0!==t.avail_in||0!==n.lookahead||0!==e&&666!==n.status){var v=2===n.strategy?function(t,e){for(var r;;){if(0===t.lookahead&&(w(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,r=s._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(_(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(_(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(_(t,!1),0===t.strm.avail_out)?1:2}(n,e):3===n.strategy?function(t,e){for(var r,i,n,a,o=t.window;;){if(t.lookahead<=h){if(w(t),t.lookahead<=h&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&0t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=s._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=s._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(_(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(_(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(_(t,!1),0===t.strm.avail_out)?1:2}(n,e):i[n.level].func(n,e);if(3!==v&&4!==v||(n.status=666),1===v||3===v)return 0===t.avail_out&&(n.last_flush=-1),0;if(2===v&&(1===e?s._tr_align(n):5!==e&&(s._tr_stored_block(n,0,0,!1),3===e&&(m(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),g(t),0===t.avail_out))return n.last_flush=-1,0}return 4!==e?0:n.wrap<=0?1:(2===n.wrap?(b(n,255&t.adler),b(n,t.adler>>8&255),b(n,t.adler>>16&255),b(n,t.adler>>24&255),b(n,255&t.total_in),b(n,t.total_in>>8&255),b(n,t.total_in>>16&255),b(n,t.total_in>>24&255)):(y(n,t.adler>>>16),y(n,65535&t.adler)),g(t),0=r.w_size&&(0===o&&(m(r.head),r.strstart=0,r.block_start=0,r.insert=0),c=new n.Buf8(r.w_size),n.arraySet(c,e,f-r.w_size,r.w_size,0),e=c,f=r.w_size),l=t.avail_in,h=t.next_in,d=t.input,t.avail_in=f,t.next_in=0,t.input=e,w(r);r.lookahead>=3;){for(i=r.strstart,s=r.lookahead-2;r.ins_h=(r.ins_h<>>=v=y>>>24,p-=v,0==(v=y>>>16&255))C[s++]=65535&y;else{if(!(16&v)){if(0==(64&v)){y=m[(65535&y)+(f&(1<>>=v,p-=v),p<15&&(f+=E[i++]<>>=v=y>>>24,p-=v,!(16&(v=y>>>16&255))){if(0==(64&v)){y=g[(65535&y)+(f&(1<>>=v,p-=v,(v=s-a)>3,f&=(1<<(p-=w<<3))-1,t.next_in=i,t.next_out=s,t.avail_in=i>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function h(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function d(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new i.Buf32(852),e.distcode=e.distdyn=new i.Buf32(592),e.sane=1,e.back=-1,0):l}function c(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,d(t)):l}function f(t,e){var r,i;return t&&t.state?(i=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||15=a.wsize?(i.arraySet(a.window,e,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(n<(s=a.wsize-a.wnext)&&(s=n),i.arraySet(a.window,e,r-n,s,a.wnext),(n-=s)?(i.arraySet(a.window,e,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=s,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,r.check=s(r.check,L,2,0),_=g=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&g)<<8)+(g>>8))%31){t.msg="incorrect header check",r.mode=30;break}if(8!=(15&g)){t.msg="unknown compression method",r.mode=30;break}if(_-=4,N=8+(15&(g>>>=4)),0===r.wbits)r.wbits=N;else if(N>r.wbits){t.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(L[0]=255&g,L[1]=g>>>8&255,r.check=s(r.check,L,2,0)),_=g=0,r.mode=3;case 3:for(;_<32;){if(0===p)break t;p--,g+=h[c++]<<_,_+=8}r.head&&(r.head.time=g),512&r.flags&&(L[0]=255&g,L[1]=g>>>8&255,L[2]=g>>>16&255,L[3]=g>>>24&255,r.check=s(r.check,L,4,0)),_=g=0,r.mode=4;case 4:for(;_<16;){if(0===p)break t;p--,g+=h[c++]<<_,_+=8}r.head&&(r.head.xflags=255&g,r.head.os=g>>8),512&r.flags&&(L[0]=255&g,L[1]=g>>>8&255,r.check=s(r.check,L,2,0)),_=g=0,r.mode=5;case 5:if(1024&r.flags){for(;_<16;){if(0===p)break t;p--,g+=h[c++]<<_,_+=8}r.length=g,r.head&&(r.head.extra_len=g),512&r.flags&&(L[0]=255&g,L[1]=g>>>8&255,r.check=s(r.check,L,2,0)),_=g=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(p<(k=r.length)&&(k=p),k&&(r.head&&(N=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),i.arraySet(r.head.extra,h,c,k,N)),512&r.flags&&(r.check=s(r.check,h,k,c)),p-=k,c+=k,r.length-=k),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===p)break t;for(k=0;N=h[c+k++],r.head&&N&&r.length<65536&&(r.head.name+=String.fromCharCode(N)),N&&k>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=12;break;case 10:for(;_<32;){if(0===p)break t;p--,g+=h[c++]<<_,_+=8}t.adler=r.check=u(g),_=g=0,r.mode=11;case 11:if(0===r.havedict)return t.next_out=f,t.avail_out=m,t.next_in=c,t.avail_in=p,r.hold=g,r.bits=_,2;t.adler=r.check=1,r.mode=12;case 12:if(5===e||6===e)break t;case 13:if(r.last){g>>>=7&_,_-=7&_,r.mode=27;break}for(;_<3;){if(0===p)break t;p--,g+=h[c++]<<_,_+=8}switch(r.last=1&g,_-=1,3&(g>>>=1)){case 0:r.mode=14;break;case 1:if(b(r),r.mode=20,6!==e)break;g>>>=2,_-=2;break t;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=30}g>>>=2,_-=2;break;case 14:for(g>>>=7&_,_-=7&_;_<32;){if(0===p)break t;p--,g+=h[c++]<<_,_+=8}if((65535&g)!=(g>>>16^65535)){t.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&g,_=g=0,r.mode=15,6===e)break t;case 15:r.mode=16;case 16:if(k=r.length){if(p>>=5,_-=5,r.ndist=1+(31&g),g>>>=5,_-=5,r.ncode=4+(15&g),g>>>=4,_-=4,286>>=3,_-=3}for(;r.have<19;)r.lens[F[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,B={bits:r.lenbits},T=o(0,r.lens,0,19,r.lencode,0,r.work,B),r.lenbits=B.bits,T){t.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,A=65535&D,!((E=D>>>24)<=_);){if(0===p)break t;p--,g+=h[c++]<<_,_+=8}if(A<16)g>>>=E,_-=E,r.lens[r.have++]=A;else{if(16===A){for(R=E+2;_>>=E,_-=E,0===r.have){t.msg="invalid bit length repeat",r.mode=30;break}N=r.lens[r.have-1],k=3+(3&g),g>>>=2,_-=2}else if(17===A){for(R=E+3;_>>=E)),g>>>=3,_-=3}else{for(R=E+7;_>>=E)),g>>>=7,_-=7}if(r.have+k>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=30;break}for(;k--;)r.lens[r.have++]=N}}if(30===r.mode)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,B={bits:r.lenbits},T=o(1,r.lens,0,r.nlen,r.lencode,0,r.work,B),r.lenbits=B.bits,T){t.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,B={bits:r.distbits},T=o(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,B),r.distbits=B.bits,T){t.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===e)break t;case 20:r.mode=21;case 21:if(6<=p&&258<=m){t.next_out=f,t.avail_out=m,t.next_in=c,t.avail_in=p,r.hold=g,r.bits=_,a(t,w),f=t.next_out,d=t.output,m=t.avail_out,c=t.next_in,h=t.input,p=t.avail_in,g=r.hold,_=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;C=(D=r.lencode[g&(1<>>16&255,A=65535&D,!((E=D>>>24)<=_);){if(0===p)break t;p--,g+=h[c++]<<_,_+=8}if(C&&0==(240&C)){for(z=E,I=C,O=A;C=(D=r.lencode[O+((g&(1<>z)])>>>16&255,A=65535&D,!(z+(E=D>>>24)<=_);){if(0===p)break t;p--,g+=h[c++]<<_,_+=8}g>>>=z,_-=z,r.back+=z}if(g>>>=E,_-=E,r.back+=E,r.length=A,0===C){r.mode=26;break}if(32&C){r.back=-1,r.mode=12;break}if(64&C){t.msg="invalid literal/length code",r.mode=30;break}r.extra=15&C,r.mode=22;case 22:if(r.extra){for(R=r.extra;_>>=r.extra,_-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;C=(D=r.distcode[g&(1<>>16&255,A=65535&D,!((E=D>>>24)<=_);){if(0===p)break t;p--,g+=h[c++]<<_,_+=8}if(0==(240&C)){for(z=E,I=C,O=A;C=(D=r.distcode[O+((g&(1<>z)])>>>16&255,A=65535&D,!(z+(E=D>>>24)<=_);){if(0===p)break t;p--,g+=h[c++]<<_,_+=8}g>>>=z,_-=z,r.back+=z}if(g>>>=E,_-=E,r.back+=E,64&C){t.msg="invalid distance code",r.mode=30;break}r.offset=A,r.extra=15&C,r.mode=24;case 24:if(r.extra){for(R=r.extra;_>>=r.extra,_-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===m)break t;if(k=w-m,r.offset>k){if((k=r.offset-k)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=30;break}x=k>r.wnext?(k-=r.wnext,r.wsize-k):r.wnext-k,k>r.length&&(k=r.length),S=r.window}else S=d,x=f-r.offset,k=r.length;for(mb?(v=F[U+d[S]],B[R+d[S]]):(v=96,0),f=1<>I)+(p-=f)]=y<<24|v<<16|w|0,0!==p;);for(f=1<>=1;if(0!==f?(T&=f-1,T+=f):T=0,S++,0==--D[x]){if(x===C)break;x=e[r+d[S]]}if(A>>7)]}function E(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function C(t,e,r){t.bi_valid>16-r?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<>>=1,r<<=1,0<--e;);return r>>>1}function I(t,e,r){var i,n,s=new Array(16),a=0;for(i=1;i<=l;i++)s[i]=a=a+r[i-1]<<1;for(n=0;n<=e;n++){var o=t[2*n+1];0!==o&&(t[2*n]=z(s[o]++,o))}}function O(t){var e;for(e=0;e>1;1<=r;r--)B(t,s,r);for(n=u;r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],B(t,s,1),i=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=i,s[2*n]=s[2*r]+s[2*i],t.depth[n]=(t.depth[r]>=t.depth[i]?t.depth[r]:t.depth[i])+1,s[2*r+1]=s[2*i+1]=n,t.heap[1]=n++,B(t,s,1),2<=t.heap_len;);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,i,n,s,a,o,u=e.dyn_tree,h=e.max_code,d=e.stat_desc.static_tree,c=e.stat_desc.has_stree,f=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,m=e.stat_desc.max_length,g=0;for(s=0;s<=l;s++)t.bl_count[s]=0;for(u[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<573;r++)m<(s=u[2*u[2*(i=t.heap[r])+1]+1]+1)&&(s=m,g++),u[2*i+1]=s,h>=7;i>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e>>3,(a=t.static_len+3+7>>>3)<=n&&(n=a)):n=a=r+5,r+4<=n&&-1!==e?P(t,e,r,i):4===t.strategy||a===n?(C(t,2+(i?1:0),3),R(t,f,p)):(C(t,4+(i?1:0),3),function(t,e,r,i){var n;for(C(t,e-257,5),C(t,r-1,5),C(t,i-4,4),n=0;n>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(g[r]+s+1)]++,t.dyn_dtree[2*S(e)]++),t.last_lit===t.lit_bufsize-1},r._tr_align=function(t){C(t,2,3),A(t,256,f),function(t){16===t.bi_valid?(E(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):8<=t.bi_valid&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},{"../utils/common":41}],53:[function(t,e,r){"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,e,r){"use strict";e.exports="function"==typeof setImmediate?setImmediate:function(){var t=[].slice.apply(arguments);t.splice(1,0,0),setTimeout.apply(null,t)}},{}]},{},[10])(10)},520:t=>{const e="NflxMultiSubs>",r={log:(...t)=>window.console.log(e,...t),warn:(...t)=>window.console.warn(e,...t),error:(...t)=>window.console.error(e,...t),debug:(...t)=>window.console.debug(e,...t)};t.exports=r},878:t=>{t.exports={upperBaselinePos:.15,lowerBaselinePos:.85,primaryImageScale:.75,primaryImageOpacity:1,primaryTextScale:.95,primaryTextOpacity:1,primaryTextColor:"#ffffff",secondaryImageScale:.5,secondaryImageOpacity:1,secondaryTextScale:1,secondaryTextStroke:2,secondaryTextOpacity:1,secondaryTextColor:"#ffffff",secondaryLanguageMode:"audio",secondaryLanguageLastUsed:void 0,secondaryLanguageLastUsedIsCaption:void 0}},823:t=>{t.exports=class{constructor(){this.keyUpHandler=void 0,this.timer=void 0}activate(){this.keyUpHandler||(this.keyUpHandler=window.addEventListener("keyup",this._keyUpHandler.bind(this)))}deactivate(){this.keyUpHandler&&(window.removeEventListener("keyup",this.keyUpHandler),this.keyUpHandler=null)}_keyUpHandler(t){if(t.ctrlKey||t.altKey||t.shiftKey||t.metaKey)return;if(219!==t.keyCode&&221!==t.keyCode)return;const e=document.querySelector(".watch-video");if(!e)return;const r=e.querySelector("video");if(!r)return;let i=r.playbackRate;219===t.keyCode?i-=.1:221==t.keyCode&&(i+=.1),i=Math.max(Math.min(i,3),.1),r.playbackRate=i;let n=document.querySelector(".nflxmultisubs-playback-rate");n||(n=document.createElement("div"),n.classList.add("nflxmultisubs-playback-rate"),n.style.position="absolute",n.style.top="10%",n.style.right="5%",n.style.fontSize="36px",n.style.fontFamily="sans-serif",n.style.fontWeight="800",n.style.color="white",n.style.display="flex",n.style.alignItems="center",n.style.zIndex=2,e.appendChild(n)),n&&(n.innerHTML=`\n \n ${i.toFixed(1)}x`,this.timer&&clearTimeout(this.timer),n.style.transition="none",n.style.opacity="1",this.timer=setTimeout((()=>{n.style.transition="opacity 2.3s",n.style.opacity="0",this.timer=null}),200))}}}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var s=e[i]={exports:{}};return t[i](s,s.exports,r),s.exports}r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),(()=>{const t=r(520),e=r(733),i=r(878),n=r(823);!function(t){const e=JSON.parse;t.JSON.parse=(...t)=>{const r=e.call(JSON,...t);return r&&r.result&&r.result.movieId&&(r.result.movieId,window.__NflxMultiSubs.updateManifest(r.result)),r}}(window),(()=>{function e(){const e=E();e&&(t.log(`Movie changed, movieId: ${e}`),C.activateManifest(e))}var r;history.pushState=(r=history.pushState,function(t,...i){r.call(history,t,...i),e()}),history.replaceState=(t=>function(r,...i){t.call(history,r,...i),e()})(history.replaceState)})();let s,a,o,l=[],u=.5625,h=Object.assign({},i),d=0;(()=>{if(!a)try{const e=window.__nflxMultiSubsExtId;a=chrome.runtime.connect(e),t.log(`Linked: ${e}`),a.onMessage.addListener((t=>{t.settings&&(h=Object.assign({},t.settings),o&&o.setRenderDirty())}))}catch(e){t.warn("Error: cannot talk to background,",e)}})();class c{constructor(t,e,r,i){this.state="GENESIS",this.active=!1,this.lang=t,this.bcp47=e,this.isCaption=i,this.urls=r,this.extentWidth=void 0,this.extentHeight=void 0,this.lines=void 0,this.lastRenderedIds=void 0}activate(e){return new Promise(((e,r)=>{this.active=!0,"GENESIS"===this.state&&(this.state="LOADING",t.log(`Subtitle "${this.lang}" downloading`),this._download().then((()=>{this.state="READY",t.log(`Subtitle "${this.lang}" loaded`),e(this)})))}))}deactivate(){this.active=!1}render(t,e,r){if(!this.active||"READY"!==this.state||!this.lines)return[];const i=this.lines.filter((e=>e.begin<=t&&t<=e.end)),n=i.map((t=>t.id)).sort().toString();return this.lastRenderedIds!==n||r?(this.lastRenderedIds=n,this._render(i,e)):null}getExtent(){return[this.extentWidth,this.extentHeight]}setExtent(t,e){[this.extentWidth,this.extentHeight]=[t,e]}_download(){return this.urls?(t.debug("Selecting fastest server, candidates: ",this.urls.map((t=>t.substr(0,24)))),Promise.race(this.urls.map((t=>fetch(new Request(t),{method:"HEAD"})))).then((e=>{const r=e.url;return t.debug(`Fastest: ${r.substr(0,24)}`),this._extract(fetch(r))}))):Promise.resolve()}_render(t,e){}_extract(t){}}class f extends c{constructor(){super("Off")}activate(){return this.active=!0,Promise.resolve()}}class p extends c{constructor(...t){super(...t)}_extract(t){return new Promise(((e,r)=>{t.then((t=>t.text())).then((t=>{const r=(new DOMParser).parseFromString(t,"text/xml"),i=[].map.call(r.querySelectorAll("tt > body > div > p"),((t,e)=>{let r="",i=t=>{[].forEach.call(t.childNodes,(t=>{t.nodeType===Node.ELEMENT_NODE?"br"===t.nodeName.toLowerCase()?r+="\n":i(t):t.nodeType===Node.TEXT_NODE&&(r+=t.nodeValue+" ")}))};return i(t),{id:e,begin:parseInt(t.getAttribute("begin"))/1e7,end:parseInt(t.getAttribute("end"))/1e7,text:r}}));this.lines=i,e()}))}))}_render(t,e){const r=Math.ceil(this.extentHeight/30),i=t.map((t=>t.text)).join("\n").split("\n"),n=document.createElementNS("http://www.w3.org/2000/svg","text");return n.setAttributeNS(null,"text-anchor","middle"),n.setAttributeNS(null,"alignment-baseline","hanging"),n.setAttributeNS(null,"dominant-baseline","hanging"),n.setAttributeNS(null,"paint-order","stroke"),n.setAttributeNS(null,"stroke","black"),n.setAttributeNS(null,"stroke-width",1*e.secondaryTextStroke+"px"),n.setAttributeNS(null,"x",.5*this.extentWidth),n.setAttributeNS(null,"y",this.extentHeight*(e.lowerBaselinePos+.01)),n.setAttributeNS(null,"opacity",e.secondaryTextOpacity),n.style.fontSize=r*e.secondaryTextScale+"px",n.style.fontFamily="Arial, Helvetica",n.style.fill=e.secondaryTextColor,n.style.stroke="black",i.forEach(((t,e)=>{const r=document.createElementNS("http://www.w3.org/2000/svg","tspan");r.setAttributeNS(null,"x",.5*this.extentWidth),e>0&&r.setAttributeNS(null,"dy",n.style.fontSize),r.textContent=t,n.appendChild(r)})),[n]}}class m extends c{constructor(...t){super(...t),this.zip=void 0}_extract(t){return new Promise(((r,i)=>{t.then((t=>t.blob())).then((t=>(new e).loadAsync(t))).then((t=>{t.file("manifest_ttml2.xml").async("string").then((e=>{const i=(new DOMParser).parseFromString(e,"text/xml"),n=(t,e)=>{const r=t.getAttributeNames().find((t=>t.split(":").pop().toLowerCase()===e));return t.getAttribute(r)},s=n(i.querySelector("tt"),"extent");[this.extentWidth,this.extentHeight]=s.split(" ").map((t=>parseInt(t)));const a=t=>{const[e,r,i]=/(\d+):(\d+):(\d+(?:\.\d+)?)/.exec(t).slice(1).map(parseFloat);return 3600*e+60*r+i},o=[].map.call(i.querySelectorAll("tt > body > div"),((t,e)=>{t.getAttributeNames().find((t=>"extent"===t.split(":").pop().toLowerCase()));const[r,i]=n(t,"extent").split(" ").map((t=>parseInt(t))),[s,o]=n(t,"origin").split(" ").map((t=>parseInt(t)));return{id:e,width:r,height:i,top:o,left:s,imageName:t.querySelector("image").getAttribute("src"),begin:a(t.getAttribute("begin")),end:a(t.getAttribute("end"))}}));this.lines=o,this.zip=t,r()}))}))}))}_render(t,e){const r=e.secondaryImageScale,i=.5*this.extentHeight,n=this.extentHeight*e.upperBaselinePos,s=this.extentHeight*e.lowerBaselinePos;return t.map((t=>{const a=document.createElementNS("http://www.w3.org/2000/svg","image");return this.zip.file(t.imageName).async("blob").then((o=>{const{left:l,top:u,width:h,height:c}=t,[f,p]=[h*r,c*r],m=l+.5*(h-f),g=u<=i?n+d:s,_=URL.createObjectURL(o);a.setAttributeNS("http://www.w3.org/1999/xlink","href",_),a.setAttributeNS(null,"width",f),a.setAttributeNS(null,"height",p),a.setAttributeNS(null,"x",m),a.setAttributeNS(null,"y",g),a.setAttributeNS(null,"opacity",e.secondaryImageOpacity),a.addEventListener("load",(()=>{URL.revokeObjectURL(_)}))})),a}))}}class g{static build(t){const e=Object.values(t.ttDownloadables).some((t=>t.isImage)),r="closedcaptions"===t.rawTrackType,i=t.languageDescription+(r?" [CC]":""),n=t.language;return e?this._buildImageBased(t,i,n,r):this._buildTextBased(t,i,n,r)}static isNoneTrack(t){if(t.isNoneTrack)return!0;try{if("1"===t.new_track_id.split(";")[4])return!0}catch(t){}return void 0!==t.rank&&t.rank<0}static _buildImageBased(t,e,r,i){const n=Math.max(...Object.values(t.ttDownloadables).map((t=>t.height?t.height:-1))),s=Object.values(t.ttDownloadables).find((t=>t.height===n));let a;return a=s.downloadUrls?Object.values(s.downloadUrls):s.urls.map((t=>t.url)),new m(e,r,a,i)}static _buildTextBased(e,r,i,n){const s=e.ttDownloadables["dfxp-ls-sdh"];if(!s)return t.debug(`Cannot find "dfxp-ls-sdh" for ${r}`),null;let a;return a=s.downloadUrls?Object.values(s.downloadUrls):s.urls.map((t=>t.url)),new p(r,i,a,n)}}const _="nflxmultisubs-subtitle-list",b="selector-audio-subtitle";class y{constructor(t){this.style=this.extractStyle(t),this.elem=document.createElement("div"),this.elem.classList.add(this.style.maindiv,"structural","track-list-subtitles"),this.elem.classList.add(_)}extractStyle(t){let e={maindiv:null,subdiv:null,h3:null,ul:null,li:null,selected:null};const r=t.querySelector(`div[data-uia=${b}]`);try{e.maindiv=r.firstChild.className}catch{}try{e.subdiv=r.querySelector("li div div").className}catch{}try{e.h3=r.querySelector("h3").className}catch{}try{e.ul=r.querySelector("ul").className}catch{}try{e.li=r.querySelector("li").className}catch{}try{e.selected=r.querySelector('li[data-uia*="selected"] svg').className.baseVal}catch{}return e}render(){const t=``,e=`\n \n \n \n `;this.elem.innerHTML=`

Secondary Subtitles

`;const r=document.createElement("ul");l.forEach(((i,n)=>{let s=document.createElement("li");if(s.classList.add(this.style.li),i.active){const r="LOADING"===i.state?e:t;s.classList.add("selected"),s.innerHTML=`
${r}
${i.lang}
`}else s.innerHTML=`
${i.lang}
`,s.addEventListener("click",(()=>{activateSubtitle(n)}));r.classList.add(this.style.ul),r.appendChild(s)}));const i=document.createElement("div");i.style.overflowY="auto",i.style.overflowX="hidden",i.appendChild(r),this.elem.appendChild(i)}}const v=t=>"div"===t.nodeName.toLowerCase()&&t.querySelector(`div[data-uia=${b}]`);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{v(t)&&(t.getElementsByClassName(_).length||(s||(s=new y(t),s.render()),t.style.left="auto",t.style.right="10px",t.querySelector(`div[data-uia=${b}]`).appendChild(s.elem)))})),t.removedNodes.forEach((t=>{v(t)}))}))})).observe(document.body,{attributes:!0,subtree:!0,childList:!0,characterData:!0}),activateSubtitle=t=>{const e=l[t];e&&(l.forEach((t=>t.deactivate())),e.activate().then((()=>{s&&s.render()})),h.secondaryLanguageLastUsed=e.bcp47,h.secondaryLanguageLastUsedIsCaption=e.isCaption,a&&a.postMessage({settings:h})),s&&s.render()};class w{constructor(){}transform(t,e,r){const i=r?"image":"image:not(.nflxmultisubs-scaled)",n=t.querySelectorAll(i);if(n.length>0){const e=t.getAttributeNS(null,"viewBox"),[r,i]=e.split(" ").slice(-2).map((t=>parseInt(t))),s=h,a=.5*i,o=i*s.upperBaselinePos,l=i*s.lowerBaselinePos,u=s.primaryImageScale,c=s.primaryImageOpacity,f=s.primaryTextColor;[].forEach.call(n,(t=>{t.classList.add("nflxmultisubs-scaled");const e=parseInt(t.getAttributeNS(null,"data-orig-x")||t.getAttributeNS(null,"x")),r=parseInt(t.getAttributeNS(null,"data-orig-y")||t.getAttributeNS(null,"y")),i=parseInt(t.getAttributeNS(null,"data-orig-width")||t.getAttributeNS(null,"width")),n=parseInt(t.getAttributeNS(null,"data-orig-height")||t.getAttributeNS(null,"height"));[["x",e],["y",r],["width",i],["height",n]].forEach((e=>{const r=`data-orig-${e[0]}`,i=e[1];t.getAttributeNS(null,r)||t.setAttributeNS(null,r,i)}));const[s,h]=[i*u,n*u],p=e+.5*(i-s);let m;r<=a?o-h<=0?(m=o-h/2,d=h/2):(m=o-h,d=0):(m=l-h,d=0),m=m<=0?10:m,t.setAttributeNS(null,"width",s),t.setAttributeNS(null,"height",h),t.setAttributeNS(null,"x",p),t.setAttributeNS(null,"y",m),t.setAttributeNS(null,"opacity",c),t.setAttributeNS(null,"color",f)}))}}}class k{constructor(){this.lastScaledPrimaryTextContent=void 0}transform(t,e,r){let i=t.parentNode;if(!i.classList.contains("nflxmultisubs-primary-wrapper")){const e=document.createElement("div");e.classList.add("nflxmultisubs-primary-wrapper"),e.style="position:absolute; width:100%; height:100%; top:0; left:0;";const r=document.createElement("style");e.appendChild(r),i.insertBefore(e,t),e.appendChild(t),i=e}const n=t.querySelectorAll(".player-timedtext-text-container"),s=n.item(0);if(!s)return;const a=s.textContent;if(this.lastScaledPrimaryTextContent===a&&!r)return;this.lastScaledPrimaryTextContent=a;const o=i.querySelector("style");if(!o)return;const l=Array.from(s.querySelectorAll("span"));if(!l)return;const u=parseInt(l.find((t=>t.style.fontSize)).style.fontSize);if(!u)return;const d=h,c=d.primaryTextOpacity,f=d.primaryTextColor,p=`.player-timedtext-text-container span {\n font-size: ${u*d.primaryTextScale}px !important;\n opacity: ${c};\n color: ${f} !important;\n }`;o.textContent=p;const m=t.getBoundingClientRect(),[g,_]=[m.width,m.height],b=_*d.lowerBaselinePos,{left:y,top:v,width:w,height:k}=s.getBoundingClientRect(),x=.5*g-.5*w;let S=b-k;S+=e?-120:0,1==n.length&&(o.textContent+=p+"\n"+`\n .player-timedtext-text-container {\n top: ${S}px !important;\n left: ${x}px !important;\n }`)}}class x{constructor(t){this.isRunning=!1,this.isRenderDirty=void 0,this.videoElem=t,this.subtitleWrapperElem=void 0,this.subSvg=void 0,this.primaryImageTransformer=new w,this.primaryTextTransformer=new k}setRenderDirty(){this.isRenderDirty=!0}start(){this.isRunning=!0,window.requestAnimationFrame(this.loop.bind(this)),a&&a.postMessage({startPlayback:1})}stop(){this.isRunning=!1,this._clearSecondarySubtitles(),a&&a.postMessage({stopPlayback:1})}loop(){try{this._loop(),this.isRunning&&window.requestAnimationFrame(this.loop.bind(this))}catch(e){t.error("Fatal: ",e)}}_loop(){const t=document.querySelector("#appMountPoint video");if(!t&&!/netflix\..*\/watch/i.test(window.location.href))return this.stop(),void(window.__NflxMultiSubs.lastMovieId=void 0);if(t&&this.videoElem.src!==t.src)return this.stop(),void window.__NflxMultiSubs.rendererLoopDestroy();const e=this._getControlsActive();this._appendSubtitleWrapper()&&(this._adjustPrimarySubtitles(e,!!this.isRenderDirty),this._renderSecondarySubtitles(),this.subtitleWrapperElem.style.top=e?"-100px":"0",this.isRenderDirty=!1)}_connect(){if(!a)try{const e=window.__nflxMultiSubsExtId;a=chrome.runtime.connect(e),t.log(`Linked: ${e}`),a.onMessage.addListener((t=>{t.settings&&(h=Object.assign({},t.settings),o&&o.setRenderDirty())}))}catch(e){t.warn("Error: cannot talk to background,",e)}}_disconnect(){a&&a.disconnect()&&(a=null)}_getControlsActive(){let t=document.querySelector(".controls"),e=!1;if(!t){if(t=document.querySelector(".PlayerControlsNeo__layout"),!t)return!1;e=!0}return t.style.zIndex||(t.style.zIndex=3),e?!t.classList.contains("PlayerControlsNeo__layout--inactive"):t.classList.contains("active")}_appendSubtitleWrapper(){if(!this.subtitleWrapperElem||!this.subtitleWrapperElem.parentNode){const t=document.querySelector('div[data-uia="video-canvas"]');if(!t)return!1;this.subtitleWrapperElem=(t=>{const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.classList.add("nflxmultisubs-subtitle-svg"),e.style="position:absolute; width:100%; top:0; bottom:0; left:0; right:0;",e.setAttributeNS(null,"width","100%"),e.setAttributeNS(null,"height","100%");const r=document.createElement("div");r.classList.add("nflxmultisubs-subtitle-padding"),r.style=`display:block; content:' '; width:100%; padding-top:${100*u}%;`;const i=document.createElement("div");i.classList.add("nflxmultisubs-subtitle-container"),i.style="position:relative; width:100%; max-height:100%;",i.appendChild(e),i.appendChild(r);const n=document.createElement("div");return n.classList.add("nflxmultisubs-subtitle-wrapper"),n.style="position:absolute; top:0; left:0; width:100%; height:100%; z-index:2; display:flex; align-items:center;",n.appendChild(i),n})(),t.appendChild(this.subtitleWrapperElem)}return!0}_adjustPrimarySubtitles(t,e){const r=document.querySelector(".image-based-subtitles svg");r&&this.primaryImageTransformer.transform(r,t,e);const i=document.querySelector(".player-timedtext");i&&this.primaryTextTransformer.transform(i,t,e)}_clearSecondarySubtitles(){this.subSvg&&this.subSvg.parentNode&&[].forEach.call(this.subSvg.querySelectorAll("*"),(t=>t.parentNode.removeChild(t)))}_renderSecondarySubtitles(){this.subSvg&&this.subSvg.parentNode||(this.subSvg=this.subtitleWrapperElem.querySelector("svg"));const t=this.videoElem.currentTime,e=l.find((t=>t.active));if(!e)return;if(e instanceof p){const t=this.videoElem.getBoundingClientRect();e.setExtent(t.width,t.height)}const r=e.render(t,h,!!this.isRenderDirty);if(r){const[t,i]=e.getExtent();t&&i&&this.subSvg.setAttribute("viewBox",`0 0 ${t} ${i}`),this._clearSecondarySubtitles(),r.forEach((t=>this.subSvg.appendChild(t)))}}}window.addEventListener("resize",(e=>{o&&o.setRenderDirty(),t.log("Resize:",`${window.innerWidth}x${window.innerHeight} (${e.timeStamp})`)}));class S extends class{enumManifest(){}getManifest(t){}saveManifest(t){}}{constructor(...t){super(...t),this.manifests={}}enumManifest(){return this.manifests}getManifest(t){return this.manifests[t]}saveManifest(t){this.manifests[t.movieId]=t}}const E=()=>{if(!/netflix\.com\/watch/i.test(window.location.href))return null;try{const t=/^\/watch\/(\d+)/.exec(window.location.pathname)[1];return parseInt(t)}catch(e){t.error(e)}return null},C=new class{constructor(){this.version="2.3.3",this.lastMovieId=void 0,this.playerUrl=void 0,this.playerVersion=void 0,this.busyWaitTimeout=1e5,this.manifestManager=new S,t.log(`Version: ${this.version}`)}busyWaitVideoElement(){return new Promise(((t,e)=>{let r=0;const i=setInterval((()=>{const e=document.querySelector("#appMountPoint video");e&&(clearInterval(i),t(e)),200*r===this.busyWaitTimeout&&clearInterval(i),r+=1}),200)}))}activateManifest(e){const r=this.manifestManager.getManifest(e);if(!r)return void t.log(`Cannot find manifest: ${e}`);const i=E();i&&(i==r.movieId?this.busyWaitVideoElement().then((i=>{try{E();let n=r.movieId===e;if(!n){const e=i.parentNode.id;t.log(`Note: movieIdInPlayerNode=${e}`),n=e.includes(r.movieId.toString())}if(!n)return void t.log(`Ignored: manifest ${r.movieId} not playing`);if(r.movieId===this.lastMovieId)return;switch(t.log(`Activating manifest ${r.movieId} (last=${this.lastMovieId})`),this.lastMovieId=r.movieId,l=(t=>{const e=new f;return e.activate(),t.filter((t=>!g.isNoneTrack(t))).map((t=>g.build(t))).filter((t=>null!==t)).concat(e)})(r.timedtexttracks),t.log("Language mode: ",h.secondaryLanguageMode),String(h.secondaryLanguageMode)){case"disabled":t.log("Subs disabled.");break;default:case"audio":try{const e=r.audio_tracks.find((t=>1==t.isNative)),i=e?e.language:r.audio_tracks[0].language;t.log(`Default audio track language: ${i}`);const n=l.findIndex((t=>t.bcp47==i));n>=0?(t.log(`Subtitle #${n} auto-enabled to match audio`),activateSubtitle(n)):t.log(i+" subs not available.")}catch(e){t.error("Default audio track not found, ",e)}break;case"last":if(h.secondaryLanguageLastUsed){t.log("Activating last sub language",h.secondaryLanguageLastUsed);try{let e=l.findIndex((t=>t.bcp47==h.secondaryLanguageLastUsed&&t.isCaption==h.secondaryLanguageLastUsedIsCaption));-1==e&&(e=l.findIndex((t=>t.bcp47==h.secondaryLanguageLastUsed))),e>=0?(t.log(`Subtitle #${e} enabled`),activateSubtitle(e)):t.log(h.secondaryLanguageLastUsed+" subs not available.")}catch(e){t.error("Error activating last sub language, ",e)}}else t.log("Last used language is empty, subs disabled.")}try{let{maxWidth:t,maxHeight:e}=r.video_tracks[0];u=e/t}catch(e){t.error("Video ratio not available, ",e)}}catch(e){t.error("Fatal: ",e)}o&&(o.stop(),o=null,t.log("Terminated: old renderer loop")),o||(o=new x(i),o.start(),t.log("Started: renderer loop"));const n=!!document.querySelector("[class*=PlayerControlsNeo]");t.log(`hasNeoStyleControls: ${n}`)})).catch((e=>{t.error("Fatal: ",e)})):t.log(`Different manifest, movieIdInUrl=${i}, manifest.movieId=${r.movieId}`))}updateManifest(e){try{t.log(`Intecerpted manifest: ${e.movieId}`)}catch(e){t.warn("Error:",e)}this.manifestManager.saveManifest(e),this.activateManifest(e.movieId)}rendererLoopDestroy(){const e=E();e&&(t.log(`rendererLoop destroyed, trying to activate: ${e}`),this.lastMovieId=void 0,this.activateManifest(e))}};window.__NflxMultiSubs=C,(new n).activate(),window.addEventListener("keyup",(t=>{if("KeyV"===t.code){const t=document.querySelector(".nflxmultisubs-primary-wrapper"),e=document.querySelector(".nflxmultisubs-subtitle-wrapper");if(!t||!e)return;const r="visible"===window.getComputedStyle(t).visibility||"visible"===window.getComputedStyle(e).visibility;t.style.visibility=e.style.visibility=r?"hidden":"visible"}}),!0)})()})(); \ No newline at end of file +(()=>{var t={710:(t,e,r)=>{t.exports=function t(e,r,i){function n(a,o){if(!r[a]){if(!e[a]){if(s)return s(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[a]={exports:{}};e[a][0].call(u.exports,(function(t){return n(e[a][1][t]||t)}),u,u.exports,t,e,r,i)}return r[a].exports}for(var s=void 0,a=0;a>2,o=(3&e)<<4|r>>4,l=1>6:64,u=2>4,r=(15&a)<<4|(o=s.indexOf(t.charAt(u++)))>>2,i=(3&o)<<6|(l=s.indexOf(t.charAt(u++))),c[h++]=e,64!==o&&(c[h++]=r),64!==l&&(c[h++]=i);return c}},{"./support":30,"./utils":32}],2:[function(t,e,r){"use strict";var i=t("./external"),n=t("./stream/DataWorker"),s=t("./stream/Crc32Probe"),a=t("./stream/DataLengthProbe");function o(t,e,r,i,n){this.compressedSize=t,this.uncompressedSize=e,this.crc32=r,this.compression=i,this.compressedContent=n}o.prototype={getContentWorker:function(){var t=new n(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),e=this;return t.on("end",(function(){if(this.streamInfo.data_length!==e.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),t},getCompressedWorker:function(){return new n(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},o.createWorkerFrom=function(t,e,r){return t.pipe(new s).pipe(new a("uncompressedSize")).pipe(e.compressWorker(r)).pipe(new a("compressedSize")).withStreamInfo("compression",e)},e.exports=o},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,e,r){"use strict";var i=t("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},r.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,e,r){"use strict";var i=t("./utils"),n=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();e.exports=function(t,e){return void 0!==t&&t.length?"string"!==i.getTypeOf(t)?function(t,e,r,i){var s=n,a=0+r;t^=-1;for(var o=0;o>>8^s[255&(t^e[o])];return~t}(0|e,t,t.length):function(t,e,r,i){var s=n,a=0+r;t^=-1;for(var o=0;o>>8^s[255&(t^e.charCodeAt(o))];return~t}(0|e,t,t.length):0}},{"./utils":32}],5:[function(t,e,r){"use strict";r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(t,e,r){"use strict";var i;i="undefined"!=typeof Promise?Promise:t("lie"),e.exports={Promise:i}},{lie:37}],7:[function(t,e,r){"use strict";var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,n=t("pako"),s=t("./utils"),a=t("./stream/GenericWorker"),o=i?"uint8array":"array";function l(t,e){a.call(this,"FlateWorker/"+t),this._pako=null,this._pakoAction=t,this._pakoOptions=e,this.meta={}}r.magic="\b\0",s.inherits(l,a),l.prototype.processChunk=function(t){this.meta=t.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(o,t.data),!1)},l.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new n[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},r.compressWorker=function(t){return new l("Deflate",t)},r.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,e,r){"use strict";function i(t,e){var r,i="";for(r=0;r>>=8;return i}function n(t,e,r,n,a,h){var d,c,f=t.file,p=t.compression,m=h!==o.utf8encode,g=s.transformTo("string",h(f.name)),_=s.transformTo("string",o.utf8encode(f.name)),b=f.comment,y=s.transformTo("string",h(b)),v=s.transformTo("string",o.utf8encode(b)),w=_.length!==f.name.length,k=v.length!==b.length,x="",S="",E="",C=f.dir,A=f.date,z={crc32:0,compressedSize:0,uncompressedSize:0};e&&!r||(z.crc32=t.crc32,z.compressedSize=t.compressedSize,z.uncompressedSize=t.uncompressedSize);var I=0;e&&(I|=8),m||!w&&!k||(I|=2048);var O=0,N=0;C&&(O|=16),"UNIX"===a?(N=798,O|=function(t,e){var r=t;return t||(r=e?16893:33204),(65535&r)<<16}(f.unixPermissions,C)):(N=20,O|=function(t){return 63&(t||0)}(f.dosPermissions)),d=A.getUTCHours(),d<<=6,d|=A.getUTCMinutes(),d<<=5,d|=A.getUTCSeconds()/2,c=A.getUTCFullYear()-1980,c<<=4,c|=A.getUTCMonth()+1,c<<=5,c|=A.getUTCDate(),w&&(S=i(1,1)+i(l(g),4)+_,x+="up"+i(S.length,2)+S),k&&(E=i(1,1)+i(l(y),4)+v,x+="uc"+i(E.length,2)+E);var T="";return T+="\n\0",T+=i(I,2),T+=p.magic,T+=i(d,2),T+=i(c,2),T+=i(z.crc32,4),T+=i(z.compressedSize,4),T+=i(z.uncompressedSize,4),T+=i(g.length,2),T+=i(x.length,2),{fileRecord:u.LOCAL_FILE_HEADER+T+g+x,dirRecord:u.CENTRAL_FILE_HEADER+i(N,2)+T+i(y.length,2)+"\0\0\0\0"+i(O,4)+i(n,4)+g+x+y}}var s=t("../utils"),a=t("../stream/GenericWorker"),o=t("../utf8"),l=t("../crc32"),u=t("../signature");function h(t,e,r,i){a.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=e,this.zipPlatform=r,this.encodeFileName=i,this.streamFiles=t,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}s.inherits(h,a),h.prototype.push=function(t){var e=t.meta.percent||0,r=this.entriesCount,i=this._sources.length;this.accumulate?this.contentBuffer.push(t):(this.bytesWritten+=t.data.length,a.prototype.push.call(this,{data:t.data,meta:{currentFile:this.currentFile,percent:r?(e+100*(r-i-1))/r:100}}))},h.prototype.openedSource=function(t){this.currentSourceOffset=this.bytesWritten,this.currentFile=t.file.name;var e=this.streamFiles&&!t.file.dir;if(e){var r=n(t,e,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(t){this.accumulate=!1;var e=this.streamFiles&&!t.file.dir,r=n(t,e,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),e)this.push({data:function(t){return u.DATA_DESCRIPTOR+i(t.crc32,4)+i(t.compressedSize,4)+i(t.uncompressedSize,4)}(t),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var t=this.bytesWritten,e=0;e=this.index;e--)r=(r<<8)+this.byteAt(e);return this.index+=t,r},readString:function(t){return i.transformTo("string",this.readData(t))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var t=this.readInt(4);return new Date(Date.UTC(1980+(t>>25&127),(t>>21&15)-1,t>>16&31,t>>11&31,t>>5&63,(31&t)<<1))}},e.exports=n},{"../utils":32}],19:[function(t,e,r){"use strict";var i=t("./Uint8ArrayReader");function n(t){i.call(this,t)}t("../utils").inherits(n,i),n.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,e,r){"use strict";var i=t("./DataReader");function n(t){i.call(this,t)}t("../utils").inherits(n,i),n.prototype.byteAt=function(t){return this.data.charCodeAt(this.zero+t)},n.prototype.lastIndexOfSignature=function(t){return this.data.lastIndexOf(t)-this.zero},n.prototype.readAndCheckSignature=function(t){return t===this.readData(4)},n.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./DataReader":18}],21:[function(t,e,r){"use strict";var i=t("./ArrayReader");function n(t){i.call(this,t)}t("../utils").inherits(n,i),n.prototype.readData=function(t){if(this.checkOffset(t),0===t)return new Uint8Array(0);var e=this.data.subarray(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./ArrayReader":17}],22:[function(t,e,r){"use strict";var i=t("../utils"),n=t("../support"),s=t("./ArrayReader"),a=t("./StringReader"),o=t("./NodeBufferReader"),l=t("./Uint8ArrayReader");e.exports=function(t){var e=i.getTypeOf(t);return i.checkSupport(e),"string"!==e||n.uint8array?"nodebuffer"===e?new o(t):n.uint8array?new l(i.transformTo("uint8array",t)):new s(i.transformTo("array",t)):new a(t)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,e,r){"use strict";r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b"},{}],24:[function(t,e,r){"use strict";var i=t("./GenericWorker"),n=t("../utils");function s(t){i.call(this,"ConvertWorker to "+t),this.destType=t}n.inherits(s,i),s.prototype.processChunk=function(t){this.push({data:n.transformTo(this.destType,t.data),meta:t.meta})},e.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(t,e,r){"use strict";var i=t("./GenericWorker"),n=t("../crc32");function s(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(s,i),s.prototype.processChunk=function(t){this.streamInfo.crc32=n(t.data,this.streamInfo.crc32||0),this.push(t)},e.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,e,r){"use strict";var i=t("../utils"),n=t("./GenericWorker");function s(t){n.call(this,"DataLengthProbe for "+t),this.propName=t,this.withStreamInfo(t,0)}i.inherits(s,n),s.prototype.processChunk=function(t){if(t){var e=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=e+t.data.length}n.prototype.processChunk.call(this,t)},e.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(t,e,r){"use strict";var i=t("../utils"),n=t("./GenericWorker");function s(t){n.call(this,"DataWorker");var e=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,t.then((function(t){e.dataIsReady=!0,e.data=t,e.max=t&&t.length||0,e.type=i.getTypeOf(t),e.isPaused||e._tickAndRepeat()}),(function(t){e.error(t)}))}i.inherits(s,n),s.prototype.cleanUp=function(){n.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var t=null,e=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":t=this.data.substring(this.index,e);break;case"uint8array":t=this.data.subarray(this.index,e);break;case"array":case"nodebuffer":t=this.data.slice(this.index,e)}return this.index=e,this.push({data:t,meta:{percent:this.max?this.index/this.max*100:0}})},e.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(t,e,r){"use strict";function i(t){this.name=t||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(t){this.emit("data",t)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(t){this.emit("error",t)}return!0},error:function(t){return!this.isFinished&&(this.isPaused?this.generatedError=t:(this.isFinished=!0,this.emit("error",t),this.previous&&this.previous.error(t),this.cleanUp()),!0)},on:function(t,e){return this._listeners[t].push(e),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(t,e){if(this._listeners[t])for(var r=0;r "+t:t}},e.exports=i},{}],29:[function(t,e,r){"use strict";var i=t("../utils"),n=t("./ConvertWorker"),s=t("./GenericWorker"),a=t("../base64"),o=t("../support"),l=t("../external"),u=null;if(o.nodestream)try{u=t("../nodejs/NodejsStreamOutputAdapter")}catch(t){}function h(t,e,r){var a=e;switch(e){case"blob":case"arraybuffer":a="uint8array";break;case"base64":a="string"}try{this._internalType=a,this._outputType=e,this._mimeType=r,i.checkSupport(a),this._worker=t.pipe(new n(a)),t.lock()}catch(t){this._worker=new s("error"),this._worker.error(t)}}h.prototype={accumulate:function(t){return function(t,e){return new l.Promise((function(r,n){var s=[],o=t._internalType,l=t._outputType,u=t._mimeType;t.on("data",(function(t,r){s.push(t),e&&e(r)})).on("error",(function(t){s=[],n(t)})).on("end",(function(){try{var t=function(t,e,r){switch(t){case"blob":return i.newBlob(i.transformTo("arraybuffer",e),r);case"base64":return a.encode(e);default:return i.transformTo(t,e)}}(l,function(t,e){var r,i=0,n=null,s=0;for(r=0;r>>6:(r<65536?e[a++]=224|r>>>12:(e[a++]=240|r>>>18,e[a++]=128|r>>>12&63),e[a++]=128|r>>>6&63),e[a++]=128|63&r);return e}(t)},r.utf8decode=function(t){return n.nodebuffer?i.transformTo("nodebuffer",t).toString("utf-8"):function(t){var e,r,n,s,a=t.length,l=new Array(2*a);for(e=r=0;e>10&1023,l[r++]=56320|1023&n)}return l.length!==r&&(l.subarray?l=l.subarray(0,r):l.length=r),i.applyFromCharCode(l)}(t=i.transformTo(n.uint8array?"uint8array":"array",t))},i.inherits(u,a),u.prototype.processChunk=function(t){var e=i.transformTo(n.uint8array?"uint8array":"array",t.data);if(this.leftOver&&this.leftOver.length){if(n.uint8array){var s=e;(e=new Uint8Array(s.length+this.leftOver.length)).set(this.leftOver,0),e.set(s,this.leftOver.length)}else e=this.leftOver.concat(e);this.leftOver=null}var a=function(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;0<=r&&128==(192&t[r]);)r--;return r<0||0===r?e:r+o[t[r]]>e?r:e}(e),l=e;a!==e.length&&(n.uint8array?(l=e.subarray(0,a),this.leftOver=e.subarray(a,e.length)):(l=e.slice(0,a),this.leftOver=e.slice(a,e.length))),this.push({data:r.utf8decode(l),meta:t.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=u,i.inherits(h,a),h.prototype.processChunk=function(t){this.push({data:r.utf8encode(t.data),meta:t.meta})},r.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,e,r){"use strict";var i=t("./support"),n=t("./base64"),s=t("./nodejsUtils"),a=t("./external");function o(t){return t}function l(t,e){for(var r=0;r>8;this.dir=!!(16&this.externalFileAttributes),0==t&&(this.dosPermissions=63&this.externalFileAttributes),3==t&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var t=i(this.extraFields[1].value);this.uncompressedSize===n.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===n.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===n.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===n.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(t){var e,r,i,n=t.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});t.index+4>>6:(r<65536?e[a++]=224|r>>>12:(e[a++]=240|r>>>18,e[a++]=128|r>>>12&63),e[a++]=128|r>>>6&63),e[a++]=128|63&r);return e},r.buf2binstring=function(t){return l(t,t.length)},r.binstring2buf=function(t){for(var e=new i.Buf8(t.length),r=0,n=e.length;r>10&1023,u[i++]=56320|1023&n)}return l(u,i)},r.utf8border=function(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;0<=r&&128==(192&t[r]);)r--;return r<0||0===r?e:r+a[t[r]]>e?r:e}},{"./common":41}],43:[function(t,e,r){"use strict";e.exports=function(t,e,r,i){for(var n=65535&t,s=t>>>16&65535,a=0;0!==r;){for(r-=a=2e3>>1:t>>>1;e[r]=t}return e}();e.exports=function(t,e,r,n){var s=i,a=n+r;t^=-1;for(var o=n;o>>8^s[255&(t^e[o])];return~t}},{}],46:[function(t,e,r){"use strict";var i,n=t("../utils/common"),s=t("./trees"),a=t("./adler32"),o=t("./crc32"),l=t("./messages"),u=0,h=0,d=-2,c=2,f=8,p=286,m=30,g=19,_=2*p+1,b=15,y=3,v=258,w=v+y+1,k=42,x=113;function S(t,e){return t.msg=l[e],e}function E(t){return(t<<1)-(4t.avail_out&&(r=t.avail_out),0!==r&&(n.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))}function z(t,e){s._tr_flush_block(t,0<=t.block_start?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,A(t.strm)}function I(t,e){t.pending_buf[t.pending++]=e}function O(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function N(t,e){var r,i,n=t.max_chain_length,s=t.strstart,a=t.prev_length,o=t.nice_match,l=t.strstart>t.w_size-w?t.strstart-(t.w_size-w):0,u=t.window,h=t.w_mask,d=t.prev,c=t.strstart+v,f=u[s+a-1],p=u[s+a];t.prev_length>=t.good_match&&(n>>=2),o>t.lookahead&&(o=t.lookahead);do{if(u[(r=e)+a]===p&&u[r+a-1]===f&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&sl&&0!=--n);return a<=t.lookahead?a:t.lookahead}function T(t){var e,r,i,s,l,u,h,d,c,f,p=t.w_size;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=p+(p-w)){for(n.arraySet(t.window,t.window,p,p,0),t.match_start-=p,t.strstart-=p,t.block_start-=p,e=r=t.hash_size;i=t.head[--e],t.head[e]=p<=i?i-p:0,--r;);for(e=r=p;i=t.prev[--e],t.prev[e]=p<=i?i-p:0,--r;);s+=p}if(0===t.strm.avail_in)break;if(u=t.strm,h=t.window,d=t.strstart+t.lookahead,f=void 0,(c=s)<(f=u.avail_in)&&(f=c),r=0===f?0:(u.avail_in-=f,n.arraySet(h,u.input,u.next_in,f,d),1===u.state.wrap?u.adler=a(u.adler,h,f,d):2===u.state.wrap&&(u.adler=o(u.adler,h,f,d)),u.next_in+=f,u.total_in+=f,f),t.lookahead+=r,t.lookahead+t.insert>=y)for(l=t.strstart-t.insert,t.ins_h=t.window[l],t.ins_h=(t.ins_h<=y&&(t.ins_h=(t.ins_h<=y)if(i=s._tr_tally(t,t.strstart-t.match_start,t.match_length-y),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=y){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<=y&&(t.ins_h=(t.ins_h<=y&&t.match_length<=t.prev_length){for(n=t.strstart+t.lookahead-y,i=s._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-y),t.lookahead-=t.prev_length-1,t.prev_length-=2;++t.strstart<=n&&(t.ins_h=(t.ins_h<t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(T(t),0===t.lookahead&&e===u)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var i=t.block_start+r;if((0===t.strstart||t.strstart>=i)&&(t.lookahead=t.strstart-i,t.strstart=i,z(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-w&&(z(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(z(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(z(t,!1),t.strm.avail_out),1)})),new L(4,4,8,4,B),new L(4,5,16,8,B),new L(4,6,32,32,B),new L(4,4,16,16,R),new L(8,16,32,32,R),new L(8,16,128,128,R),new L(8,32,128,256,R),new L(32,128,258,1024,R),new L(32,258,258,4096,R)],r.deflateInit=function(t,e){return P(t,e,f,15,8,0)},r.deflateInit2=P,r.deflateReset=U,r.deflateResetKeep=F,r.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?d:(t.state.gzhead=e,h):d},r.deflate=function(t,e){var r,n,a,l;if(!t||!t.state||5>8&255),I(n,n.gzhead.time>>16&255),I(n,n.gzhead.time>>24&255),I(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),I(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(I(n,255&n.gzhead.extra.length),I(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=o(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(I(n,0),I(n,0),I(n,0),I(n,0),I(n,0),I(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),I(n,3),n.status=x);else{var c=f+(n.w_bits-8<<4)<<8;c|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(c|=32),c+=31-c%31,n.status=x,O(n,c),0!==n.strstart&&(O(n,t.adler>>>16),O(n,65535&t.adler)),t.adler=1}if(69===n.status)if(n.gzhead.extra){for(a=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>a&&(t.adler=o(t.adler,n.pending_buf,n.pending-a,a)),A(t),a=n.pending,n.pending!==n.pending_buf_size));)I(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>a&&(t.adler=o(t.adler,n.pending_buf,n.pending-a,a)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=o(t.adler,n.pending_buf,n.pending-a,a)),A(t),a=n.pending,n.pending===n.pending_buf_size)){l=1;break}l=n.gzindexa&&(t.adler=o(t.adler,n.pending_buf,n.pending-a,a)),0===l&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=o(t.adler,n.pending_buf,n.pending-a,a)),A(t),a=n.pending,n.pending===n.pending_buf_size)){l=1;break}l=n.gzindexa&&(t.adler=o(t.adler,n.pending_buf,n.pending-a,a)),0===l&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&A(t),n.pending+2<=n.pending_buf_size&&(I(n,255&t.adler),I(n,t.adler>>8&255),t.adler=0,n.status=x)):n.status=x),0!==n.pending){if(A(t),0===t.avail_out)return n.last_flush=-1,h}else if(0===t.avail_in&&E(e)<=E(r)&&4!==e)return S(t,-5);if(666===n.status&&0!==t.avail_in)return S(t,-5);if(0!==t.avail_in||0!==n.lookahead||e!==u&&666!==n.status){var p=2===n.strategy?function(t,e){for(var r;;){if(0===t.lookahead&&(T(t),0===t.lookahead)){if(e===u)return 1;break}if(t.match_length=0,r=s._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(z(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(z(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(z(t,!1),0===t.strm.avail_out)?1:2}(n,e):3===n.strategy?function(t,e){for(var r,i,n,a,o=t.window;;){if(t.lookahead<=v){if(T(t),t.lookahead<=v&&e===u)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=y&&0t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=y?(r=s._tr_tally(t,1,t.match_length-y),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=s._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(z(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(z(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(z(t,!1),0===t.strm.avail_out)?1:2}(n,e):i[n.level].func(n,e);if(3!==p&&4!==p||(n.status=666),1===p||3===p)return 0===t.avail_out&&(n.last_flush=-1),h;if(2===p&&(1===e?s._tr_align(n):5!==e&&(s._tr_stored_block(n,0,0,!1),3===e&&(C(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),A(t),0===t.avail_out))return n.last_flush=-1,h}return 4!==e?h:n.wrap<=0?1:(2===n.wrap?(I(n,255&t.adler),I(n,t.adler>>8&255),I(n,t.adler>>16&255),I(n,t.adler>>24&255),I(n,255&t.total_in),I(n,t.total_in>>8&255),I(n,t.total_in>>16&255),I(n,t.total_in>>24&255)):(O(n,t.adler>>>16),O(n,65535&t.adler)),A(t),0=r.w_size&&(0===o&&(C(r.head),r.strstart=0,r.block_start=0,r.insert=0),f=new n.Buf8(r.w_size),n.arraySet(f,e,p-r.w_size,r.w_size,0),e=f,p=r.w_size),l=t.avail_in,u=t.next_in,c=t.input,t.avail_in=p,t.next_in=0,t.input=e,T(r);r.lookahead>=y;){for(i=r.strstart,s=r.lookahead-(y-1);r.ins_h=(r.ins_h<>>=v=y>>>24,p-=v,0==(v=y>>>16&255))C[s++]=65535&y;else{if(!(16&v)){if(!(64&v)){y=m[(65535&y)+(f&(1<>>=v,p-=v),p<15&&(f+=E[i++]<>>=v=y>>>24,p-=v,!(16&(v=y>>>16&255))){if(!(64&v)){y=g[(65535&y)+(f&(1<>>=v,p-=v,(v=s-a)>3,f&=(1<<(p-=w<<3))-1,t.next_in=i,t.next_out=s,t.avail_in=i>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function p(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function m(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=h,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new i.Buf32(d),e.distcode=e.distdyn=new i.Buf32(c),e.sane=1,e.back=-1,l):u}function g(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,m(t)):u}function _(t,e){var r,i;return t&&t.state?(i=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||15=a.wsize?(i.arraySet(a.window,e,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(n<(s=a.wsize-a.wnext)&&(s=n),i.arraySet(a.window,e,r-n,s,a.wnext),(n-=s)?(i.arraySet(a.window,e,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=s,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,r.check=s(r.check,U,2,0),y=b=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&b)<<8)+(b>>8))%31){t.msg="incorrect header check",r.mode=30;break}if(8!=(15&b)){t.msg="unknown compression method",r.mode=30;break}if(y-=4,B=8+(15&(b>>>=4)),0===r.wbits)r.wbits=B;else if(B>r.wbits){t.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(U[0]=255&b,U[1]=b>>>8&255,r.check=s(r.check,U,2,0)),y=b=0,r.mode=3;case 3:for(;y<32;){if(0===g)break t;g--,b+=d[p++]<>>8&255,U[2]=b>>>16&255,U[3]=b>>>24&255,r.check=s(r.check,U,4,0)),y=b=0,r.mode=4;case 4:for(;y<16;){if(0===g)break t;g--,b+=d[p++]<>8),512&r.flags&&(U[0]=255&b,U[1]=b>>>8&255,r.check=s(r.check,U,2,0)),y=b=0,r.mode=5;case 5:if(1024&r.flags){for(;y<16;){if(0===g)break t;g--,b+=d[p++]<>>8&255,r.check=s(r.check,U,2,0)),y=b=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(g<(S=r.length)&&(S=g),S&&(r.head&&(B=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),i.arraySet(r.head.extra,d,p,S,B)),512&r.flags&&(r.check=s(r.check,d,S,p)),g-=S,p+=S,r.length-=S),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===g)break t;for(S=0;B=d[p+S++],r.head&&B&&r.length<65536&&(r.head.name+=String.fromCharCode(B)),B&&S>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=12;break;case 10:for(;y<32;){if(0===g)break t;g--,b+=d[p++]<>>=7&y,y-=7&y,r.mode=27;break}for(;y<3;){if(0===g)break t;g--,b+=d[p++]<>>=1)){case 0:r.mode=14;break;case 1:if(k(r),r.mode=20,6!==e)break;b>>>=2,y-=2;break t;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=30}b>>>=2,y-=2;break;case 14:for(b>>>=7&y,y-=7&y;y<32;){if(0===g)break t;g--,b+=d[p++]<>>16^65535)){t.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&b,y=b=0,r.mode=15,6===e)break t;case 15:r.mode=16;case 16:if(S=r.length){if(g>>=5,y-=5,r.ndist=1+(31&b),b>>>=5,y-=5,r.ncode=4+(15&b),b>>>=4,y-=4,286>>=3,y-=3}for(;r.have<19;)r.lens[P[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,L={bits:r.lenbits},R=o(0,r.lens,0,19,r.lencode,0,r.work,L),r.lenbits=L.bits,R){t.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,I=65535&F,!((A=F>>>24)<=y);){if(0===g)break t;g--,b+=d[p++]<>>=A,y-=A,r.lens[r.have++]=I;else{if(16===I){for(D=A+2;y>>=A,y-=A,0===r.have){t.msg="invalid bit length repeat",r.mode=30;break}B=r.lens[r.have-1],S=3+(3&b),b>>>=2,y-=2}else if(17===I){for(D=A+3;y>>=A)),b>>>=3,y-=3}else{for(D=A+7;y>>=A)),b>>>=7,y-=7}if(r.have+S>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=30;break}for(;S--;)r.lens[r.have++]=B}}if(30===r.mode)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,L={bits:r.lenbits},R=o(1,r.lens,0,r.nlen,r.lencode,0,r.work,L),r.lenbits=L.bits,R){t.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,L={bits:r.distbits},R=o(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,L),r.distbits=L.bits,R){t.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===e)break t;case 20:r.mode=21;case 21:if(6<=g&&258<=_){t.next_out=m,t.avail_out=_,t.next_in=p,t.avail_in=g,r.hold=b,r.bits=y,a(t,w),m=t.next_out,c=t.output,_=t.avail_out,p=t.next_in,d=t.input,g=t.avail_in,b=r.hold,y=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;z=(F=r.lencode[b&(1<>>16&255,I=65535&F,!((A=F>>>24)<=y);){if(0===g)break t;g--,b+=d[p++]<>O)])>>>16&255,I=65535&F,!(O+(A=F>>>24)<=y);){if(0===g)break t;g--,b+=d[p++]<>>=O,y-=O,r.back+=O}if(b>>>=A,y-=A,r.back+=A,r.length=I,0===z){r.mode=26;break}if(32&z){r.back=-1,r.mode=12;break}if(64&z){t.msg="invalid literal/length code",r.mode=30;break}r.extra=15&z,r.mode=22;case 22:if(r.extra){for(D=r.extra;y>>=r.extra,y-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;z=(F=r.distcode[b&(1<>>16&255,I=65535&F,!((A=F>>>24)<=y);){if(0===g)break t;g--,b+=d[p++]<>O)])>>>16&255,I=65535&F,!(O+(A=F>>>24)<=y);){if(0===g)break t;g--,b+=d[p++]<>>=O,y-=O,r.back+=O}if(b>>>=A,y-=A,r.back+=A,64&z){t.msg="invalid distance code",r.mode=30;break}r.offset=I,r.extra=15&z,r.mode=24;case 24:if(r.extra){for(D=r.extra;y>>=r.extra,y-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===_)break t;if(S=w-_,r.offset>S){if((S=r.offset-S)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=30;break}E=S>r.wnext?(S-=r.wnext,r.wsize-S):r.wnext-S,S>r.length&&(S=r.length),C=r.window}else C=c,E=m-r.offset,S=r.length;for(_b?(v=F[U+d[S]],B[R+d[S]]):(v=96,0),f=1<>I)+(p-=f)]=y<<24|v<<16|w,0!==p;);for(f=1<>=1;if(0!==f?(T&=f-1,T+=f):T=0,S++,0==--L[x]){if(x===C)break;x=e[r+d[S]]}if(A>>7)]}function C(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function A(t,e,r){t.bi_valid>u-r?(t.bi_buf|=e<>u-t.bi_valid,t.bi_valid+=r-u):(t.bi_buf|=e<>>=1,r<<=1,0<--e;);return r>>>1}function O(t,e,r){var i,n,s=new Array(l+1),a=0;for(i=1;i<=l;i++)s[i]=a=a+r[i-1]<<1;for(n=0;n<=e;n++){var o=t[2*n+1];0!==o&&(t[2*n]=I(s[o]++,o))}}function N(t){var e;for(e=0;e>1;1<=r;r--)R(t,s,r);for(n=u;r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],R(t,s,1),i=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=i,s[2*n]=s[2*r]+s[2*i],t.depth[n]=(t.depth[r]>=t.depth[i]?t.depth[r]:t.depth[i])+1,s[2*r+1]=s[2*i+1]=n,t.heap[1]=n++,R(t,s,1),2<=t.heap_len;);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,i,n,s,a,o,u=e.dyn_tree,h=e.max_code,d=e.stat_desc.static_tree,c=e.stat_desc.has_stree,f=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,m=e.stat_desc.max_length,g=0;for(s=0;s<=l;s++)t.bl_count[s]=0;for(u[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<573;r++)m<(s=u[2*u[2*(i=t.heap[r])+1]+1]+1)&&(s=m,g++),u[2*i+1]=s,h>=7;i>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e>>3,(a=t.static_len+3+7>>>3)<=n&&(n=a)):n=a=r+5,r+4<=n&&-1!==e?M(t,e,r,i):4===t.strategy||a===n?(A(t,2+(i?1:0),3),L(t,p,m)):(A(t,4+(i?1:0),3),function(t,e,r,i){var n;for(A(t,e-257,5),A(t,r-1,5),A(t,i-4,4),n=0;n>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(_[r]+s+1)]++,t.dyn_dtree[2*E(e)]++),t.last_lit===t.lit_bufsize-1},r._tr_align=function(t){A(t,2,3),z(t,256,p),function(t){16===t.bi_valid?(C(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):8<=t.bi_valid&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},{"../utils/common":41}],53:[function(t,e,r){"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,e,i){(function(t){!function(t,e){"use strict";if(!t.setImmediate){var r,i,n,s,a=1,o={},l=!1,u=t.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(t);h=h&&h.setTimeout?h:t,r="[object process]"==={}.toString.call(t.process)?function(t){process.nextTick((function(){c(t)}))}:function(){if(t.postMessage&&!t.importScripts){var e=!0,r=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=r,e}}()?(s="setImmediate$"+Math.random()+"$",t.addEventListener?t.addEventListener("message",f,!1):t.attachEvent("onmessage",f),function(e){t.postMessage(s+e,"*")}):t.MessageChannel?((n=new MessageChannel).port1.onmessage=function(t){c(t.data)},function(t){n.port2.postMessage(t)}):u&&"onreadystatechange"in u.createElement("script")?(i=u.documentElement,function(t){var e=u.createElement("script");e.onreadystatechange=function(){c(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):function(t){setTimeout(c,0,t)},h.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),i=0;i{const e="NflxMultiSubs>",r={log:(...t)=>window.console.log(e,...t),warn:(...t)=>window.console.warn(e,...t),error:(...t)=>window.console.error(e,...t),debug:(...t)=>window.console.debug(e,...t)};t.exports=r},775:t=>{t.exports={upperBaselinePos:.15,lowerBaselinePos:.85,primaryImageScale:.75,primaryImageOpacity:1,primaryTextScale:.95,primaryTextOpacity:1,primaryTextColor:"#ffffff",secondaryImageScale:.5,secondaryImageOpacity:1,secondaryTextScale:1,secondaryTextStroke:2,secondaryTextOpacity:1,secondaryTextColor:"#ffffff",secondaryLanguageMode:"audio",secondaryLanguageLastUsed:void 0,secondaryLanguageLastUsedIsCaption:void 0}},527:t=>{t.exports=class{constructor(){this.keyUpHandler=void 0,this.timer=void 0}activate(){this.keyUpHandler||(this.keyUpHandler=window.addEventListener("keydown",this._keyUpHandler.bind(this)))}deactivate(){this.keyUpHandler&&(window.removeEventListener("keydown",this.keyUpHandler),this.keyUpHandler=null)}_keyUpHandler(t){if(!["BracketLeft","BracketRight"].includes(t.code)&&!["[","]"].includes(t.key))return;const e=document.querySelector(".watch-video");if(!e)return;const r=e.querySelector("video");if(!r)return;let i=r.playbackRate;"BracketLeft"===t.code||"["===t.key?i-=.1:"BracketRight"!==t.code&&"]"!==t.key||(i+=.1),i=Math.max(Math.min(i,3),.1),r.playbackRate=i;let n=document.querySelector(".nflxmultisubs-playback-rate");n||(n=document.createElement("div"),n.classList.add("nflxmultisubs-playback-rate"),n.style.position="absolute",n.style.top="10%",n.style.right="5%",n.style.fontSize="36px",n.style.fontFamily="sans-serif",n.style.fontWeight="800",n.style.color="white",n.style.display="flex",n.style.alignItems="center",n.style.zIndex=2,e.appendChild(n)),n&&(n.innerHTML=`\n \n ${i.toFixed(1)}x`,this.timer&&clearTimeout(this.timer),n.style.transition="none",n.style.opacity="1",this.timer=setTimeout((()=>{n.style.transition="opacity 2.3s",n.style.opacity="0",this.timer=null}),200))}}}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var s=e[i]={exports:{}};return t[i](s,s.exports,r),s.exports}r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),(()=>{const t=r(777),e=r(710),i=r(775),n=r(527);!function(t){const e=JSON.parse;t.JSON.parse=(...t)=>{const r=e.call(JSON,...t);return r&&r.result&&r.result.movieId&&(r.result.movieId,window.__NflxMultiSubs.updateManifest(r.result)),r}}(window),(()=>{function e(){const e=A();e&&(t.log(`Movie changed, movieId: ${e}`),z.activateManifest(e))}var r;history.pushState=(r=history.pushState,function(t,...i){r.call(history,t,...i),e()}),history.replaceState=(t=>function(r,...i){t.call(history,r,...i),e()})(history.replaceState)})();let s,a,o,l=[],u=.5625,h=Object.assign({},i),d=0;(()=>{if(!a)try{const e=window.__nflxMultiSubsExtId;a=browser.runtime.connect(e),t.log(`Linked: ${e}`),a.onMessage.addListener((t=>{t.settings&&(h=Object.assign({},t.settings),o&&o.setRenderDirty())}))}catch(e){t.warn("Error: cannot talk to background,",e)}})();class c{constructor(t,e,r,i){this.state="GENESIS",this.active=!1,this.lang=t,this.bcp47=e,this.isCaption=i,this.urls=r,this.extentWidth=void 0,this.extentHeight=void 0,this.lines=void 0,this.lastRenderedIds=void 0}activate(e){return new Promise(((e,r)=>{this.active=!0,"GENESIS"===this.state&&(this.state="LOADING",t.log(`Subtitle "${this.lang}" downloading`),this._download().then((()=>{this.state="READY",t.log(`Subtitle "${this.lang}" loaded`),e(this)})))}))}deactivate(){this.active=!1}render(t,e,r){if(!this.active||"READY"!==this.state||!this.lines)return[];const i=this.lines.filter((e=>e.begin<=t&&t<=e.end)),n=i.map((t=>t.id)).sort().toString();return this.lastRenderedIds!==n||r?(this.lastRenderedIds=n,this._render(i,e)):null}getExtent(){return[this.extentWidth,this.extentHeight]}setExtent(t,e){[this.extentWidth,this.extentHeight]=[t,e]}_download(){return this.urls?(t.debug("Selecting fastest server, candidates: ",this.urls.map((t=>t.substr(0,24)))),Promise.any(this.urls.map((t=>fetch(new Request(t),{method:"HEAD"})))).then((e=>{const r=e.url;return t.debug(`Fastest: ${r.substr(0,24)}`),this._extract(fetch(r))}))):Promise.resolve()}_render(t,e){}_extract(t){}}class f extends c{constructor(){super("Off")}activate(){return this.active=!0,Promise.resolve()}}class p extends c{constructor(...t){super(...t)}activate(){return this.active=!0,Promise.resolve()}}class m extends c{constructor(...t){super(...t)}_extract(t){return new Promise(((e,r)=>{t.then((t=>t.text())).then((t=>{const r=(new DOMParser).parseFromString(t,"text/xml"),i=[].map.call(r.querySelectorAll("tt > body > div > p"),((t,e)=>{let r="",i=t=>{[].forEach.call(t.childNodes,(t=>{t.nodeType===Node.ELEMENT_NODE?"br"===t.nodeName.toLowerCase()?r+="\n":i(t):t.nodeType===Node.TEXT_NODE&&(r+=t.nodeValue+" ")}))};return i(t),{id:e,begin:parseInt(t.getAttribute("begin"))/1e7,end:parseInt(t.getAttribute("end"))/1e7,text:r}}));this.lines=i,e()}))}))}_render(t,e){const r=Math.ceil(this.extentHeight/30),i=t.map((t=>t.text)).join("\n").split("\n"),n=document.createElementNS("http://www.w3.org/2000/svg","text");return n.setAttributeNS(null,"text-anchor","middle"),n.setAttributeNS(null,"alignment-baseline","hanging"),n.setAttributeNS(null,"dominant-baseline","hanging"),n.setAttributeNS(null,"paint-order","stroke"),n.setAttributeNS(null,"stroke","black"),n.setAttributeNS(null,"stroke-width",1*e.secondaryTextStroke+"px"),n.setAttributeNS(null,"x",.5*this.extentWidth),n.setAttributeNS(null,"y",this.extentHeight*(e.lowerBaselinePos+.01)),n.setAttributeNS(null,"opacity",e.secondaryTextOpacity),n.style.fontSize=r*e.secondaryTextScale+"px",n.style.fontFamily="Arial, Helvetica",n.style.fill=e.secondaryTextColor,n.style.stroke="black",i.forEach(((t,e)=>{const r=document.createElementNS("http://www.w3.org/2000/svg","tspan");r.setAttributeNS(null,"x",.5*this.extentWidth),e>0&&r.setAttributeNS(null,"dy",n.style.fontSize),r.textContent=t,n.appendChild(r)})),[n]}}class g extends c{constructor(...t){super(...t),this.zip=void 0}_extract(t){return new Promise(((r,i)=>{t.then((t=>t.blob())).then((t=>(new e).loadAsync(t))).then((t=>{t.file("manifest_ttml2.xml").async("string").then((e=>{const i=(new DOMParser).parseFromString(e,"text/xml"),n=(t,e)=>{const r=t.getAttributeNames().find((t=>t.split(":").pop().toLowerCase()===e));return t.getAttribute(r)},s=n(i.querySelector("tt"),"extent");[this.extentWidth,this.extentHeight]=s.split(" ").map((t=>parseInt(t)));const a=t=>{const[e,r,i]=/(\d+):(\d+):(\d+(?:\.\d+)?)/.exec(t).slice(1).map(parseFloat);return 3600*e+60*r+i},o=[].map.call(i.querySelectorAll("tt > body > div"),((t,e)=>{t.getAttributeNames().find((t=>"extent"===t.split(":").pop().toLowerCase()));const[r,i]=n(t,"extent").split(" ").map((t=>parseInt(t))),[s,o]=n(t,"origin").split(" ").map((t=>parseInt(t)));return{id:e,width:r,height:i,top:o,left:s,imageName:t.querySelector("image").getAttribute("src"),begin:a(t.getAttribute("begin")),end:a(t.getAttribute("end"))}}));this.lines=o,this.zip=t,r()}))}))}))}_render(t,e){const r=e.secondaryImageScale,i=.5*this.extentHeight,n=this.extentHeight*e.upperBaselinePos,s=this.extentHeight*e.lowerBaselinePos;return t.map((t=>{const a=document.createElementNS("http://www.w3.org/2000/svg","image");return this.zip.file(t.imageName).async("blob").then((o=>{const{left:l,top:u,width:h,height:c}=t,[f,p]=[h*r,c*r],m=l+.5*(h-f),g=u<=i?n+d:s,_=URL.createObjectURL(o);a.setAttributeNS("http://www.w3.org/1999/xlink","href",_),a.setAttributeNS(null,"width",f),a.setAttributeNS(null,"height",p),a.setAttributeNS(null,"x",m),a.setAttributeNS(null,"y",g),a.setAttributeNS(null,"opacity",e.secondaryImageOpacity),a.addEventListener("load",(()=>{URL.revokeObjectURL(_)}))})),a}))}}class _{static build(t){const e=Object.values(t.ttDownloadables).some((t=>t.isImage)),r="closedcaptions"===t.rawTrackType,i=t.languageDescription+(r?" [CC]":""),n=t.language;return t.hydrated?e?this._buildImageBased(t,i,n,r):this._buildTextBased(t,i,n,r):new p(i,n)}static isNoneTrack(t){if(t.isNoneTrack)return!0;try{if("1"===t.new_track_id.split(";")[4])return!0}catch(t){}return void 0!==t.rank&&t.rank<0}static _buildImageBased(t,e,r,i){const n=Math.max(...Object.values(t.ttDownloadables).map((t=>t.height?t.height:-1))),s=Object.values(t.ttDownloadables).find((t=>t.height===n));let a;return a=s.downloadUrls?Object.values(s.downloadUrls):s.urls.map((t=>t.url)),new g(e,r,a,i)}static _buildTextBased(e,r,i,n){const s="dfxp-ls-sdh",a=e.ttDownloadables[s];if(!a)return t.debug(`Cannot find "${s}" for ${r}`),null;let o;return o=a.downloadUrls?Object.values(a.downloadUrls):a.urls.map((t=>t.url)),new m(r,i,o,n)}}const b="nflxmultisubs-subtitle-list",y="selector-audio-subtitle";class v{constructor(t){this.style=this.extractStyle(t),this.elem=document.createElement("div"),this.elem.classList.add(this.style.maindiv,"structural","track-list-subtitles"),this.elem.classList.add(b)}extractStyle(t){let e={maindiv:null,subdiv:null,h3:null,ul:null,li:null,selected:null};const r=t.querySelector(`div[data-uia=${y}]`);try{e.maindiv=r.firstChild.className}catch{}try{e.subdiv=r.querySelector("li div div").className}catch{}try{e.h3=r.querySelector("h3").className}catch{}try{e.ul=r.querySelector("ul").className}catch{}try{e.li=r.querySelector("li").className}catch{}try{e.selected=r.querySelector('li[data-uia*="selected"] svg').className.baseVal}catch{}return e}render(){const t=``,e=`\n \n \n \n `;this.elem.innerHTML=`

Secondary Subtitles

`;const r=document.createElement("ul");l.forEach(((i,n)=>{if(i instanceof p)return;let s=document.createElement("li");if(s.classList.add(this.style.li),i.active){const r="LOADING"===i.state?e:t;s.classList.add("selected"),s.innerHTML=`
${r}
${i.lang}
`}else s.innerHTML=`
${i.lang}
`,s.addEventListener("click",(()=>{activateSubtitle(n)}));r.classList.add(this.style.ul),r.appendChild(s)}));const i=document.createElement("div");i.style.overflowY="auto",i.style.overflowX="hidden",i.appendChild(r),this.elem.appendChild(i)}}const w=t=>"div"===t.nodeName.toLowerCase()&&t.querySelector(`div[data-uia=${y}]`);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{w(t)&&(t.getElementsByClassName(b).length||(s||(s=new v(t),s.render()),t.style.left="auto",t.style.right="10px",t.querySelector(`div[data-uia=${y}]`).appendChild(s.elem)))})),t.removedNodes.forEach((t=>{w(t)}))}))})).observe(document.body,{attributes:!0,subtree:!0,childList:!0,characterData:!0}),activateSubtitle=t=>{const e=l[t];e&&(l.forEach((t=>t.deactivate())),e.activate().then((()=>{s&&s.render()})),h.secondaryLanguageLastUsed=e.bcp47,h.secondaryLanguageLastUsedIsCaption=e.isCaption,a&&a.postMessage({settings:h})),s&&s.render()};class k{constructor(){}transform(t,e,r){const i=r?"image":"image:not(.nflxmultisubs-scaled)",n=t.querySelectorAll(i);if(n.length>0){const e=t.getAttributeNS(null,"viewBox"),[r,i]=e.split(" ").slice(-2).map((t=>parseInt(t))),s=h,a=.5*i,o=i*s.upperBaselinePos,l=i*s.lowerBaselinePos,u=s.primaryImageScale,c=s.primaryImageOpacity,f=s.primaryTextColor;[].forEach.call(n,(t=>{t.classList.add("nflxmultisubs-scaled");const e=parseInt(t.getAttributeNS(null,"data-orig-x")||t.getAttributeNS(null,"x")),r=parseInt(t.getAttributeNS(null,"data-orig-y")||t.getAttributeNS(null,"y")),i=parseInt(t.getAttributeNS(null,"data-orig-width")||t.getAttributeNS(null,"width")),n=parseInt(t.getAttributeNS(null,"data-orig-height")||t.getAttributeNS(null,"height"));[["x",e],["y",r],["width",i],["height",n]].forEach((e=>{const r=`data-orig-${e[0]}`,i=e[1];t.getAttributeNS(null,r)||t.setAttributeNS(null,r,i)}));const[s,h]=[i*u,n*u],p=e+.5*(i-s);let m;r<=a?o-h<=0?(m=o-h/2,d=h/2):(m=o-h,d=0):(m=l-h,d=0),m=m<=0?10:m,t.setAttributeNS(null,"width",s),t.setAttributeNS(null,"height",h),t.setAttributeNS(null,"x",p),t.setAttributeNS(null,"y",m),t.setAttributeNS(null,"opacity",c),t.setAttributeNS(null,"color",f)}))}}}class x{constructor(){this.lastScaledPrimaryTextContent=void 0}transform(t,e,r){let i=t.parentNode;if(!i.classList.contains("nflxmultisubs-primary-wrapper")){const e=document.createElement("div");e.classList.add("nflxmultisubs-primary-wrapper"),e.style="position:absolute; width:100%; height:100%; top:0; left:0;";const r=document.createElement("style");e.appendChild(r),i.insertBefore(e,t),e.appendChild(t),i=e}const n=t.querySelectorAll(".player-timedtext-text-container"),s=n.item(0);if(!s)return;const a=s.textContent;if(this.lastScaledPrimaryTextContent===a&&!r)return;this.lastScaledPrimaryTextContent=a;const o=i.querySelector("style");if(!o)return;const l=Array.from(s.querySelectorAll("span"));if(!l)return;const u=parseInt(l.find((t=>t.style.fontSize)).style.fontSize);if(!u)return;const d=h,c=d.primaryTextOpacity,f=d.primaryTextColor,p=`.player-timedtext-text-container span {\n font-size: ${u*d.primaryTextScale}px !important;\n opacity: ${c};\n color: ${f} !important;\n }`;o.textContent=p;const m=t.getBoundingClientRect(),[g,_]=[m.width,m.height],b=_*d.lowerBaselinePos,{left:y,top:v,width:w,height:k}=s.getBoundingClientRect(),x=.5*g-.5*w;let S=b-k;S+=e?-100:0,1==n.length&&(o.textContent+=p+"\n"+`\n .player-timedtext-text-container {\n top: ${S}px !important;\n left: ${x}px !important;\n }`)}}class S{constructor(t){this.isRunning=!1,this.isRenderDirty=void 0,this.videoElem=t,this.subtitleWrapperElem=void 0,this.subSvg=void 0,this.primaryImageTransformer=new k,this.primaryTextTransformer=new x}setRenderDirty(){this.isRenderDirty=!0}start(){this.isRunning=!0,window.requestAnimationFrame(this.loop.bind(this)),a&&a.postMessage({startPlayback:1})}stop(){this.isRunning=!1,this._clearSecondarySubtitles(),a&&a.postMessage({stopPlayback:1})}loop(){try{this._loop(),this.isRunning&&window.requestAnimationFrame(this.loop.bind(this))}catch(e){t.error("Fatal: ",e)}}_loop(){const t=document.querySelector("#appMountPoint video");if(!t&&!/netflix\..*\/watch/i.test(window.location.href))return this.stop(),void(window.__NflxMultiSubs.lastMovieId=void 0);if(t&&this.videoElem.src!==t.src)return this.stop(),void window.__NflxMultiSubs.rendererLoopDestroy();const e=this._getControlsActive();this._appendSubtitleWrapper()&&(this._adjustPrimarySubtitles(e,!!this.isRenderDirty),this._renderSecondarySubtitles(),this.subtitleWrapperElem.style.top=e?"-100px":"0",this.isRenderDirty=!1)}_connect(){if(!a)try{const e=window.__nflxMultiSubsExtId;a=browser.runtime.connect(e),t.log(`Linked: ${e}`),a.onMessage.addListener((t=>{t.settings&&(h=Object.assign({},t.settings),o&&o.setRenderDirty())}))}catch(e){t.warn("Error: cannot talk to background,",e)}}_disconnect(){a&&a.disconnect()&&(a=null)}_getControlsActive(){let t=document.querySelector('.controls, div[data-uia="controls-standard"], .watch-video--bottom-controls-container'),e=!1;if(!t){if(t=document.querySelector(".PlayerControlsNeo__layout"),!t)return!1;e=!0}return t.style.zIndex||(t.style.zIndex=3),e?!t.classList.contains("PlayerControlsNeo__layout--inactive"):null!==t}_appendSubtitleWrapper(){if(!this.subtitleWrapperElem||!this.subtitleWrapperElem.parentNode){const t=document.querySelector('div[data-uia="video-canvas"]');if(!t)return!1;this.subtitleWrapperElem=(t=>{const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.classList.add("nflxmultisubs-subtitle-svg"),e.style="position:absolute; width:100%; top:0; bottom:0; left:0; right:0;",e.setAttributeNS(null,"width","100%"),e.setAttributeNS(null,"height","100%");const r=document.createElement("div");r.classList.add("nflxmultisubs-subtitle-padding"),r.style=`display:block; content:' '; width:100%; padding-top:${100*u}%;`;const i=document.createElement("div");i.classList.add("nflxmultisubs-subtitle-container"),i.style="position:relative; width:100%; max-height:100%;",i.appendChild(e),i.appendChild(r);const n=document.createElement("div");return n.classList.add("nflxmultisubs-subtitle-wrapper"),n.style="position:absolute; top:0; left:0; width:100%; height:100%; z-index:2; display:flex; align-items:center;",n.appendChild(i),n})(),t.appendChild(this.subtitleWrapperElem)}return!0}_adjustPrimarySubtitles(t,e){const r=this.lastControlsActive!==t,i=document.querySelector(".image-based-subtitles svg");i&&this.primaryImageTransformer.transform(i,t,e||r);const n=document.querySelector(".player-timedtext");n&&this.primaryTextTransformer.transform(n,t,e||r),this.lastControlsActive=t}_clearSecondarySubtitles(){this.subSvg&&this.subSvg.parentNode&&[].forEach.call(this.subSvg.querySelectorAll("*"),(t=>t.parentNode.removeChild(t)))}_renderSecondarySubtitles(){this.subSvg&&this.subSvg.parentNode||(this.subSvg=this.subtitleWrapperElem.querySelector("svg"));const t=this.videoElem.currentTime,e=l.find((t=>t.active));if(!e)return;if(e instanceof m){const t=this.videoElem.getBoundingClientRect();e.setExtent(t.width,t.height)}const r=e.render(t,h,!!this.isRenderDirty);if(r){const[t,i]=e.getExtent();t&&i&&this.subSvg.setAttribute("viewBox",`0 0 ${t} ${i}`),this._clearSecondarySubtitles(),r.forEach((t=>this.subSvg.appendChild(t)))}}}window.addEventListener("resize",(e=>{o&&o.setRenderDirty(),t.log("Resize:",`${window.innerWidth}x${window.innerHeight} (${e.timeStamp})`)}));class E{enumManifest(){}getManifest(t){}saveManifest(t){}}class C extends E{constructor(...t){super(...t),this.manifests={}}enumManifest(){return this.manifests}getManifest(t){return this.manifests[t]}saveManifest(t){this.manifests[t.movieId]=t}}const A=()=>{if(!/netflix\.com\/watch/i.test(window.location.href))return null;try{const t=/^\/watch\/(\d+)/.exec(window.location.pathname)[1];return parseInt(t)}catch(e){t.error(e)}return null},z=new class{constructor(){this.version="2.3.5",this.lastMovieId=void 0,this.playerUrl=void 0,this.playerVersion=void 0,this.busyWaitTimeout=1e5,this.manifestManager=new C,t.log(`Version: ${this.version}`)}busyWaitVideoElement(){return new Promise(((t,e)=>{let r=0;const i=setInterval((()=>{const e=document.querySelector("#appMountPoint video");e&&(clearInterval(i),t(e)),200*r===this.busyWaitTimeout&&clearInterval(i),r+=1}),200)}))}activateManifest(e){const r=this.manifestManager.getManifest(e);if(!r)return void t.log(`Cannot find manifest: ${e}`);const i=A();i&&(i==r.movieId?this.busyWaitVideoElement().then((i=>{try{A();let n=r.movieId===e;if(!n){const e=i.parentNode.id;t.log(`Note: movieIdInPlayerNode=${e}`),n=e.includes(r.movieId.toString())}if(!n)return void t.log(`Ignored: manifest ${r.movieId} not playing`);if(r.movieId===this.lastMovieId)return((t,e)=>{const r=t.find((t=>t.new_track_id==e)),i=_.build(r),n=l.findIndex((t=>t.lang==i.lang));l[n]instanceof p&&null!==i&&(l[n]=i,s&&s.render())})(r.timedtexttracks,r.recommendedMedia.timedTextTrackId),void t.log(`Manifest ${r.movieId} updated`);switch(t.log(`Activating manifest ${r.movieId} (last=${this.lastMovieId})`),this.lastMovieId=r.movieId,l=(t=>{const e=new f;return e.activate(),t.filter((t=>!_.isNoneTrack(t))).map((t=>_.build(t))).filter((t=>null!==t)).concat(e)})(r.timedtexttracks),t.log("Language mode: ",h.secondaryLanguageMode),String(h.secondaryLanguageMode)){case"disabled":t.log("Subs disabled.");break;default:case"audio":try{const e=r.audio_tracks.find((t=>1==t.isNative)),i=e?e.language:r.audio_tracks[0].language;t.log(`Default audio track language: ${i}`);const n=l.findIndex((t=>t.bcp47==i));n>=0?(t.log(`Subtitle #${n} auto-enabled to match audio`),activateSubtitle(n)):t.log(i+" subs not available.")}catch(e){t.error("Default audio track not found, ",e)}break;case"last":if(h.secondaryLanguageLastUsed){t.log("Activating last sub language",h.secondaryLanguageLastUsed);try{let e=l.findIndex((t=>t.bcp47==h.secondaryLanguageLastUsed&&t.isCaption==h.secondaryLanguageLastUsedIsCaption));-1==e&&(e=l.findIndex((t=>t.bcp47==h.secondaryLanguageLastUsed))),e>=0?(t.log(`Subtitle #${e} enabled`),activateSubtitle(e)):t.log(h.secondaryLanguageLastUsed+" subs not available.")}catch(e){t.error("Error activating last sub language, ",e)}}else t.log("Last used language is empty, subs disabled.")}try{let{maxWidth:t,maxHeight:e}=r.video_tracks[0];u=e/t}catch(e){t.error("Video ratio not available, ",e)}}catch(e){t.error("Fatal: ",e)}o&&(o.stop(),o=null,t.log("Terminated: old renderer loop")),o||(o=new S(i),o.start(),t.log("Started: renderer loop"));const n=!!document.querySelector("[class*=PlayerControlsNeo]");t.log(`hasNeoStyleControls: ${n}`)})).catch((e=>{t.error("Fatal: ",e)})):t.log(`Different manifest, movieIdInUrl=${i}, manifest.movieId=${r.movieId}`))}updateManifest(e){try{t.log(`Intecerpted manifest: ${e.movieId}`)}catch(e){t.warn("Error:",e)}this.manifestManager.saveManifest(e),this.activateManifest(e.movieId)}rendererLoopDestroy(){const e=A();e&&(t.log(`rendererLoop destroyed, trying to activate: ${e}`),this.lastMovieId=void 0,this.activateManifest(e))}};window.__NflxMultiSubs=z,(new n).activate(),window.addEventListener("keydown",(t=>{if("v"===t.key.toLowerCase()){const t=document.querySelector(".nflxmultisubs-primary-wrapper"),e=document.querySelector(".nflxmultisubs-subtitle-wrapper");if(!t||!e)return;const r="visible"===window.getComputedStyle(t).visibility||"visible"===window.getComputedStyle(e).visibility;t.style.visibility=e.style.visibility=r?"hidden":"visible"}}),!0)})()})(); \ No newline at end of file diff --git a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/nflxmultisubs.min.js.LICENSE.txt b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/nflxmultisubs.min.js.LICENSE.txt index 995b8bc..e0f937b 100644 --- a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/nflxmultisubs.min.js.LICENSE.txt +++ b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/nflxmultisubs.min.js.LICENSE.txt @@ -1,11 +1,11 @@ /*! -JSZip v3.7.1 - A JavaScript class for generating and reading zip files +JSZip v3.10.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley -Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown. +Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : -https://github.com/nodeca/pako/blob/master/LICENSE +https://github.com/nodeca/pako/blob/main/LICENSE */ diff --git a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/settings.css b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/settings.css index 6883329..6d996ef 100644 --- a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/settings.css +++ b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/settings.css @@ -10,6 +10,7 @@ html, body { padding: 0; outline: 0; user-select: none; + overflow: hidden; } .wrapper { @@ -140,28 +141,40 @@ footer { .font-size { position: relative; - height: 30px; - width: 30px; + height: 25px; + width: 25px; border: 2px solid hsl(0, 0%, 70%); color: hsl(0, 0%, 30%); - border-radius: 21px; - font-weight: bold; + background-color: hsl(0, 0%, 98%); + border-radius: 25px; + font-size: 25px; + font-weight: normal; align-items: stretch; display: inline-flex; flex-direction: column; justify-content: center; text-align: center; } +.font-size-indicator { + height: 35px; + width: 35px; + border: 1px solid hsl(0, 0%, 70%); + background-color: hsl(0, 0%, 100%); + border-radius: 10px; +} .font-size + .font-size { - margin-left: 10px; + margin-left: 7px; } -.font-size:hover, -.font-size.active { +.action:hover{ border-color: hsl(0, 70%, 50%); color: hsl(0, 70%, 50%); cursor: pointer; } +.action:active { + border-color: hsl(0, 84%, 80%); + color: hsl(0, 91%, 86%); +} .settings-secondary-lang div span { visibility: hidden; @@ -242,8 +255,24 @@ footer { border-color: #5e5e5e transparent transparent transparent; } -.font-size-xs { font-size: 9px; } -.font-size-s { font-size: 11px; } -.font-size-m { font-size: 13px; } -.font-size-l { font-size: 15px; } -.font-size-xl { font-size: 17px; } +#primary-color-ff .picker_wrapper { + width: 230px; + left: -100px; + margin-top: 5px; +} + +#secondary-color-ff .picker_wrapper { + width: 230px; + left: -100px; + margin-bottom: 60px; +} + +#primary-color-ff .picker_arrow, +#secondary-color-ff .picker_arrow { + visibility: hidden; +} + +#primary-color-ff .picker_wrapper.popup, +#secondary-color-ff .picker_wrapper.popup { + box-shadow: 0 0 10px 1px rgb(0 0 0 / 80%); +} diff --git a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/settings.html b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/settings.html index ebfee8d..831e4dc 100644 --- a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/settings.html +++ b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/settings.html @@ -39,15 +39,13 @@

Layout

Primary Subtitles

Size

-
-
-
-
-
+
+
A
+

Text color

-
+
Currently only for text subtitles. Image-subs will be white.
@@ -58,15 +56,13 @@

Primary Subtitles

Secondary Subtitles

Size

-
A
-
A
-
A
-
A
-
A
+
+
A
+

Text color

-
+
Currently only for text subtitles. Image-subs will be white.
diff --git a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/settings.min.js b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/settings.min.js index a52a7e9..23f8b70 100644 --- a/safari_web_extension/MultiSubs/Shared (Extension)/Resources/settings.min.js +++ b/safari_web_extension/MultiSubs/Shared (Extension)/Resources/settings.min.js @@ -1 +1 @@ -(()=>{let e={};const t=chrome.runtime.connect({name:"settings"});t.onMessage.addListener((t=>{e=t.settings||e,r()}));const a=[{upperBaselinePos:.2,lowerBaselinePos:.8},{upperBaselinePos:.15,lowerBaselinePos:.85},{upperBaselinePos:.1,lowerBaselinePos:.9}],n=[{primaryImageScale:.55,primaryTextScale:.75},{primaryImageScale:.65,primaryTextScale:.85},{primaryImageScale:.75,primaryTextScale:.95},{primaryImageScale:.85,primaryTextScale:1.05},{primaryImageScale:.95,primaryTextScale:1.1}],c=[{secondaryImageScale:.35,secondaryTextScale:.85},{secondaryImageScale:.42,secondaryTextScale:.92},{secondaryImageScale:.5,secondaryTextScale:1},{secondaryImageScale:.6,secondaryTextScale:1.1},{secondaryImageScale:.8,secondaryTextScale:1.3}],s=[{secondaryLanguageMode:"disabled"},{secondaryLanguageMode:"audio"},{secondaryLanguageMode:"last"}];function o(){t.postMessage({settings:e})}function r(){if("complete"!==document.readyState)return;let t;[].forEach.call(document.querySelectorAll(".active"),(e=>{e.classList.remove("active")}));const o=a.findIndex((t=>t.lowerBaselinePos===e.lowerBaselinePos));-1!==o&&(t=document.querySelector(`.settings-layout > div[data-id="${o}"]`),t&&t.classList.add("active"));const r=n.findIndex((t=>t.primaryImageScale===e.primaryImageScale));-1!==r&&(t=document.querySelector(`.settings-primary-font-size div.font-size[data-id="${r}"]`),t&&t.classList.add("active")),document.getElementById("primary-color").value=e.primaryTextColor||"#ffffff";const d=c.findIndex((t=>t.secondaryImageScale===e.secondaryImageScale));-1!==d&&(t=document.querySelector(`.settings-secondary-font-size div.font-size[data-id="${d}"]`),t&&t.classList.add("active")),document.getElementById("secondary-color").value=e.secondaryTextColor||"#ffffff";const i=s.findIndex((t=>t.secondaryLanguageMode===e.secondaryLanguageMode));-1!==i&&(t=document.querySelector(`.settings-secondary-lang > div[data-id="${i}"]`),t&&t.classList.add("active"),e.secondaryLanguageLastUsed&&(document.getElementById("langcode").innerHTML=e.secondaryLanguageLastUsed.split("-")[0]))}window.addEventListener("load",(d=>{!function(){let e=document.querySelector("#version");e&&(e.textContent="2.3.3")}(),r();const i=document.querySelectorAll(".settings-layout > div");[].forEach.call(i,(t=>{const n=parseInt(t.getAttribute("data-id"));t.addEventListener("click",(t=>function(t){t<0||t>=a.length||(e=Object.assign(e,a[t]),o(),r())}(n)),!1)}));const l=document.querySelectorAll(".settings-primary-font-size div.font-size");[].forEach.call(l,(t=>{const a=parseInt(t.getAttribute("data-id"));t.addEventListener("click",(t=>function(t){t<0||t>=n.length||(e=Object.assign(e,n[t]),o(),r())}(a)),!1)}));const g=document.querySelectorAll(".settings-secondary-font-size div.font-size");[].forEach.call(g,(t=>{const a=parseInt(t.getAttribute("data-id"));t.addEventListener("click",(t=>function(t){t<0||t>=c.length||(e=Object.assign(e,c[t]),o(),r())}(a)),!1)})),document.getElementById("primary-color").onchange=t=>{var a;a=t.target.value,e=Object.assign(e,{primaryTextColor:a}),o(),r()},document.getElementById("secondary-color").onchange=t=>{var a;a=t.target.value,e=Object.assign(e,{secondaryTextColor:a}),o(),r()};const y=document.querySelectorAll(".settings-secondary-lang > div");[].forEach.call(y,(t=>{const a=parseInt(t.getAttribute("data-id"));t.addEventListener("click",(t=>function(t){t<0||t>=s.length||(e=Object.assign(e,s[t]),o(),r())}(a)),!1)})),document.getElementById("btnReset").addEventListener("click",(e=>{t.postMessage({settings:null})}),!1)}))})(); \ No newline at end of file +(()=>{let e={};const t=browser.runtime.connect({name:"settings"});t.onMessage.addListener((t=>{e=t.settings||e,o()}));const n=[{upperBaselinePos:.2,lowerBaselinePos:.8},{upperBaselinePos:.15,lowerBaselinePos:.85},{upperBaselinePos:.1,lowerBaselinePos:.9}],a=[{secondaryLanguageMode:"disabled"},{secondaryLanguageMode:"audio"},{secondaryLanguageMode:"last"}];function c(){t.postMessage({settings:e})}function o(){if("complete"!==document.readyState)return;let t;[].forEach.call(document.querySelectorAll(".active"),(e=>{e.classList.remove("active")}));const c=n.findIndex((t=>t.lowerBaselinePos===e.lowerBaselinePos));-1!==c&&(t=document.querySelector(`.settings-layout > div[data-id="${c}"]`),t&&t.classList.add("active")),document.getElementById("primary-font-indicator").style.scale=.8*e.primaryTextScale,document.getElementById("primary-color").value=e.primaryTextColor||"#ffffff",document.getElementById("secondary-font-indicator").style.scale=.8*e.secondaryTextScale,document.getElementById("secondary-color").value=e.secondaryTextColor||"#ffffff";const o=a.findIndex((t=>t.secondaryLanguageMode===e.secondaryLanguageMode));-1!==o&&(t=document.querySelector(`.settings-secondary-lang > div[data-id="${o}"]`),t&&t.classList.add("active"),e.secondaryLanguageLastUsed&&(document.getElementById("langcode").innerHTML=e.secondaryLanguageLastUsed.split("-")[0]))}function s(t){if("+"===t)e.primaryTextScale=Math.min(2.5,e.primaryTextScale+.1);else{if("-"!==t)return;e.primaryTextScale=Math.max(.3,e.primaryTextScale-.1)}e.primaryImageScale=.6*e.primaryTextScale,c(),o()}function r(t){if("+"===t)e.secondaryTextScale=Math.min(2.5,e.secondaryTextScale+.1);else{if("-"!==t)return;e.secondaryTextScale=Math.max(.3,e.secondaryTextScale-.1)}e.secondaryImageScale=.6*e.secondaryTextScale,c(),o()}window.addEventListener("load",(d=>{!function(){let e=document.querySelector("#version");e&&(e.textContent="2.3.5")}(),o();const l=document.querySelectorAll(".settings-layout > div");[].forEach.call(l,(t=>{const a=parseInt(t.getAttribute("data-id"));t.addEventListener("click",(t=>function(t){t<0||t>=n.length||(e=Object.assign(e,n[t]),c(),o())}(a)),!1)})),document.getElementById("primary-plus").addEventListener("click",(()=>s("+"))),document.getElementById("primary-minus").addEventListener("click",(()=>s("-"))),document.getElementById("secondary-plus").addEventListener("click",(()=>r("+"))),document.getElementById("secondary-minus").addEventListener("click",(()=>r("-"))),document.getElementById("primary-color").onchange=t=>{var n;n=t.target.value,e=Object.assign(e,{primaryTextColor:n}),c(),o()},document.getElementById("secondary-color").onchange=t=>{var n;n=t.target.value,e=Object.assign(e,{secondaryTextColor:n}),c(),o()};const i=document.querySelectorAll(".settings-secondary-lang > div");[].forEach.call(i,(t=>{const n=parseInt(t.getAttribute("data-id"));t.addEventListener("click",(t=>function(t){t<0||t>=a.length||(e=Object.assign(e,a[t]),c(),o())}(n)),!1)})),document.getElementById("btnReset").addEventListener("click",(e=>{t.postMessage({settings:null})}),!1)}))})(); \ No newline at end of file diff --git a/safari_web_extension/Step.md b/safari_web_extension/Step.md index 641c3fe..78b6354 100644 --- a/safari_web_extension/Step.md +++ b/safari_web_extension/Step.md @@ -8,6 +8,12 @@ npm install npm run build ``` +Patch the settings code to work with Safari: + +``` +LC_ALL=C sed -i '.bak' 's/chrome\.runtime/browser.runtime/g' src/*.js && rm src/*.bak +``` + If the xcode project has not been generated before, use [converter](https://developer.apple.com/documentation/safariservices/safari_web_extensions/converting_a_web_extension_for_safari) to convert chrome extension to safari extension ``` diff --git a/src/background.js b/src/background.js index 3cc640d..e6c1573 100644 --- a/src/background.js +++ b/src/background.js @@ -155,15 +155,15 @@ function handleInternalConnection(port) { // handle connections from target website and our pop-up if (BROWSER === 'chrome') { - chrome.runtime.onConnectExternal.addListener( + browser.runtime.onConnectExternal.addListener( port => handleExternalConnection(port)); - chrome.runtime.onConnect.addListener( + browser.runtime.onConnect.addListener( port => handleInternalConnection(port)); } else { // Firefox: either from website (injected agent) or pop-up are all "internal" - chrome.runtime.onConnect.addListener(port => { + browser.runtime.onConnect.addListener(port => { if (port.sender && port.sender.tab) { handleExternalConnection(port); } diff --git a/src/content.js b/src/content.js index 24511a8..b404f3f 100644 --- a/src/content.js +++ b/src/content.js @@ -5,7 +5,7 @@ window.addEventListener('load', () => { let scriptElem = document.createElement('script'); scriptElem.setAttribute('type', 'text/javascript'); scriptElem.textContent = `(() => { - window.__nflxMultiSubsExtId = ${JSON.stringify(chrome.runtime.id)}; + window.__nflxMultiSubsExtId = ${JSON.stringify(browser.runtime.id)}; })();`; document.body.appendChild(scriptElem); @@ -13,7 +13,7 @@ window.addEventListener('load', () => { scriptsToInject.forEach(scriptName => { const scriptElem = document.createElement('script'); scriptElem.setAttribute('type', 'text/javascript'); - scriptElem.setAttribute('src', chrome.runtime.getURL(scriptName)); + scriptElem.setAttribute('src', browser.runtime.getURL(scriptName)); document.head.appendChild(scriptElem); console.log(`Injected: ${scriptName}`); }); diff --git a/src/manifest.json b/src/manifest.json index b7bc3de..a19b048 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,5 +1,5 @@ { - "name": "NflxMultiSubs 2021 (Netflix Multi. Subtitles)", + "name": "NflxMultiSubs", "manifest_version": 2, "author": "Dan Chen, Gert Mertes", @@ -16,7 +16,8 @@ }, "browser_action": { - "default_icon": "icon-gray.png" + "default_icon": "icon-gray.png", + "default_popup": "settings.html" }, "icons": { diff --git a/src/nflxmultisubs.js b/src/nflxmultisubs.js index b6e1935..59fab52 100644 --- a/src/nflxmultisubs.js +++ b/src/nflxmultisubs.js @@ -68,7 +68,7 @@ let gSecondaryOffset = 0; // used to move secondary subs if primary subs overflo if (gMsgPort) return; try { const extensionId = window.__nflxMultiSubsExtId; - gMsgPort = chrome.runtime.connect(extensionId); + gMsgPort = browser.runtime.connect(extensionId); console.log(`Linked: ${extensionId}`); gMsgPort.onMessage.addListener(msg => { @@ -175,7 +175,7 @@ class SubtitleBase { console.debug('Selecting fastest server, candidates: ', this.urls.map(u => u.substr(0, 24))); - return Promise.race( + return Promise.any( this.urls.map(url => fetch(new Request(url), {method: 'HEAD'})) ).then(r => { const url = r.url; @@ -205,6 +205,18 @@ class DummySubtitle extends SubtitleBase { } } +// subtitle with no download urls +class DehydratedSubtitle extends SubtitleBase { + constructor(...args) { + super(...args); + } + + activate() { + this.active = true; + return Promise.resolve(); + } +} + class TextSubtitle extends SubtitleBase { constructor(...args) { super(...args); @@ -419,6 +431,9 @@ class SubtitleFactory { const lang = track.languageDescription + (isCaption ? ' [CC]' : ''); const bcp47 = track.language; + if (!track.hydrated) { + return new DehydratedSubtitle(lang, bcp47); + } if (isImageBased) { return this._buildImageBased(track, lang, bcp47, isCaption); } @@ -499,6 +514,17 @@ const buildSubtitleList = textTracks => { return subs.concat(dummy); }; +// textTracks: manifest.textTracks +const updateSubtitleList = (textTracks, textTrackId) => { + const track = textTracks.find(t => t.new_track_id == textTrackId), + sub = SubtitleFactory.build(track), + index = gSubtitles.findIndex(s => s.lang == sub.lang); + if (gSubtitles[index] instanceof DehydratedSubtitle && sub !== null) { + gSubtitles[index] = sub; + gSubtitleMenu && gSubtitleMenu.render(); + } +}; + //////////////////////////////////////////////////////////////////////////////// const SUBTITLE_LIST_CLASSNAME = 'nflxmultisubs-subtitle-list'; @@ -541,6 +567,7 @@ class SubtitleMenu { const listElem = document.createElement('ul'); gSubtitles.forEach((sub, id) => { + if (sub instanceof DehydratedSubtitle) return; let item = document.createElement('li'); item.classList.add(this.style.li); if (sub.active) { @@ -824,7 +851,7 @@ class PrimaryTextTransformer { // FIXME: dirty transform & magic offets // we out run the official player, so the primary text-based subtitles // does not move automatically when the navs are active - newTop += controlsActive ? -120 : 0; + newTop += controlsActive ? -100 : 0; if (containers.length == 1){ style.textContent += @@ -960,7 +987,7 @@ class RendererLoop { if (gMsgPort) return; try { const extensionId = window.__nflxMultiSubsExtId; - gMsgPort = chrome.runtime.connect(extensionId); + gMsgPort = browser.runtime.connect(extensionId); console.log(`Linked: ${extensionId}`); gMsgPort.onMessage.addListener(msg => { @@ -1004,7 +1031,7 @@ class RendererLoop { _getControlsActive() { // FIXME: better solution to handle different versions of Netflix web player UI // "Neo Style" refers to the newer version as in 2018/07 - let controlsElem = document.querySelector('.controls'), + let controlsElem = document.querySelector('.controls, div[data-uia="controls-standard"], .watch-video--bottom-controls-container'), neoStyle = false; if (!controlsElem) { controlsElem = document.querySelector('.PlayerControlsNeo__layout'); @@ -1023,7 +1050,7 @@ class RendererLoop { 'PlayerControlsNeo__layout--inactive' ); } - return controlsElem.classList.contains('active'); + return controlsElem !== null; } // @returns {boolean} Successed? @@ -1042,17 +1069,20 @@ class RendererLoop { // NOTE: we cannot put `primaryImageSubSvg` into instance state, // because there are multiple instance of the SVG and they're switched // when the langauge of primary subtitles is switched. + const force = this.lastControlsActive !== active; const primaryImageSubSvg = document.querySelector( '.image-based-subtitles svg' ); if (primaryImageSubSvg) { - this.primaryImageTransformer.transform(primaryImageSubSvg, active, dirty); + this.primaryImageTransformer.transform(primaryImageSubSvg, active, dirty || force); } const primaryTextSubDiv = document.querySelector('.player-timedtext'); if (primaryTextSubDiv) { - this.primaryTextTransformer.transform(primaryTextSubDiv, active, dirty); + this.primaryTextTransformer.transform(primaryTextSubDiv, active, dirty || force); } + + this.lastControlsActive = active; } _clearSecondarySubtitles() { @@ -1251,7 +1281,8 @@ class NflxMultiSubsManager { const movieChanged = manifest.movieId !== this.lastMovieId; if (!movieChanged) { - //console.log(`Ignored: manifest ${manifest.movieId} already loaded`); + updateSubtitleList(manifest.timedtexttracks, manifest.recommendedMedia.timedTextTrackId); + console.log(`Manifest ${manifest.movieId} updated`); return; } @@ -1382,9 +1413,9 @@ window.__NflxMultiSubs = nflxMultiSubsManager; // interface between us and the const playbackRateController = new PlaybackRateController(); playbackRateController.activate(); -window.addEventListener('keyup', (event) => { +window.addEventListener('keydown', (event) => { // toggle subtitles visibility with 'v' - if (event.code === 'KeyV') { + if (event.key.toLowerCase() === 'v') { const primary = document.querySelector('.nflxmultisubs-primary-wrapper'); const secondary = document.querySelector('.nflxmultisubs-subtitle-wrapper'); @@ -1396,4 +1427,4 @@ window.addEventListener('keyup', (event) => { primary.style.visibility = secondary.style.visibility = (visible) ? 'hidden' : 'visible'; } -}, true); \ No newline at end of file +}, true); diff --git a/src/playback-rate-controller.js b/src/playback-rate-controller.js index bbf8fa0..b188df4 100644 --- a/src/playback-rate-controller.js +++ b/src/playback-rate-controller.js @@ -8,7 +8,7 @@ class PlaybackRateController { activate() { if (this.keyUpHandler) return; - this.keyUpHandler = window.addEventListener('keyup', + this.keyUpHandler = window.addEventListener('keydown', this._keyUpHandler.bind(this)); } @@ -16,14 +16,13 @@ class PlaybackRateController { deactivate() { if (!this.keyUpHandler) return; - window.removeEventListener('keyup', this.keyUpHandler); + window.removeEventListener('keydown', this.keyUpHandler); this.keyUpHandler = null; } _keyUpHandler(evt) { - if (evt.ctrlKey || evt.altKey || evt.shiftKey || evt.metaKey) return; - if ((evt.keyCode !== 219 /* [ */) && (evt.keyCode !== 221 /* ] */)) return; + if (!['BracketLeft', 'BracketRight'].includes(evt.code) && !['[', ']'].includes(evt.key) ) return; const playerContainer = document.querySelector('.watch-video'); if (!playerContainer) return; @@ -32,8 +31,8 @@ class PlaybackRateController { if (!video) return; let playbackRate = video.playbackRate; - if (evt.keyCode === 219) playbackRate -= 0.1; // key [ pressed - else if (evt.keyCode == 221) playbackRate += 0.1; // ] pressed + if (evt.code === 'BracketLeft' || evt.key === '[') playbackRate -= 0.1; + else if (evt.code === 'BracketRight'|| evt.key === ']') playbackRate += 0.1; playbackRate = Math.max(Math.min(playbackRate, 3.0), 0.1); video.playbackRate = playbackRate; diff --git a/src/settings.css b/src/settings.css index 6883329..6d996ef 100644 --- a/src/settings.css +++ b/src/settings.css @@ -10,6 +10,7 @@ html, body { padding: 0; outline: 0; user-select: none; + overflow: hidden; } .wrapper { @@ -140,28 +141,40 @@ footer { .font-size { position: relative; - height: 30px; - width: 30px; + height: 25px; + width: 25px; border: 2px solid hsl(0, 0%, 70%); color: hsl(0, 0%, 30%); - border-radius: 21px; - font-weight: bold; + background-color: hsl(0, 0%, 98%); + border-radius: 25px; + font-size: 25px; + font-weight: normal; align-items: stretch; display: inline-flex; flex-direction: column; justify-content: center; text-align: center; } +.font-size-indicator { + height: 35px; + width: 35px; + border: 1px solid hsl(0, 0%, 70%); + background-color: hsl(0, 0%, 100%); + border-radius: 10px; +} .font-size + .font-size { - margin-left: 10px; + margin-left: 7px; } -.font-size:hover, -.font-size.active { +.action:hover{ border-color: hsl(0, 70%, 50%); color: hsl(0, 70%, 50%); cursor: pointer; } +.action:active { + border-color: hsl(0, 84%, 80%); + color: hsl(0, 91%, 86%); +} .settings-secondary-lang div span { visibility: hidden; @@ -242,8 +255,24 @@ footer { border-color: #5e5e5e transparent transparent transparent; } -.font-size-xs { font-size: 9px; } -.font-size-s { font-size: 11px; } -.font-size-m { font-size: 13px; } -.font-size-l { font-size: 15px; } -.font-size-xl { font-size: 17px; } +#primary-color-ff .picker_wrapper { + width: 230px; + left: -100px; + margin-top: 5px; +} + +#secondary-color-ff .picker_wrapper { + width: 230px; + left: -100px; + margin-bottom: 60px; +} + +#primary-color-ff .picker_arrow, +#secondary-color-ff .picker_arrow { + visibility: hidden; +} + +#primary-color-ff .picker_wrapper.popup, +#secondary-color-ff .picker_wrapper.popup { + box-shadow: 0 0 10px 1px rgb(0 0 0 / 80%); +} diff --git a/src/settings.html b/src/settings.html index ebfee8d..831e4dc 100644 --- a/src/settings.html +++ b/src/settings.html @@ -39,15 +39,13 @@

Layout

Primary Subtitles

Size

-
-
-
-
-
+
+
A
+

Text color

-
+
Currently only for text subtitles. Image-subs will be white.
@@ -58,15 +56,13 @@

Primary Subtitles

Secondary Subtitles

Size

-
A
-
A
-
A
-
A
-
A
+
+
A
+

Text color

-
+
Currently only for text subtitles. Image-subs will be white.
diff --git a/src/settings.js b/src/settings.js index c325471..7641275 100644 --- a/src/settings.js +++ b/src/settings.js @@ -1,13 +1,38 @@ let settings = {}; +let primaryPicker, secondaryPicker; -const port = chrome.runtime.connect({ name: 'settings' }); +if (BROWSER === 'firefox') { + const Picker = require('vanilla-picker'); + + primaryPicker = new Picker({ + popup: 'bottom', + color: '#ffffff', + alpha: false, + editor: false + }); + + secondaryPicker = new Picker({ + popup: 'top', + color: '#ffffff', + alpha: false, + editor: false + }); +} + +const port = browser.runtime.connect({ name: 'settings' }); port.onMessage.addListener((msg) => { settings = msg.settings || settings; renderActiveSettings(); + + primaryPicker?.setColor(settings.primaryTextColor || "#ffffff", true); + secondaryPicker?.setColor(settings.secondaryTextColor || "#ffffff", true); }); // ----------------------------------------------------------------------------- +const minimumFontScale = 0.3; +const maximumFontScale = 2.5; + const layoutPresets = [ { // compact upperBaselinePos: 0.20, @@ -23,52 +48,6 @@ const layoutPresets = [ }, ]; -const primarySizePresets = [ - { // x-small - primaryImageScale: 0.55, - primaryTextScale: 0.75, - }, - { // small - primaryImageScale: 0.65, - primaryTextScale: 0.85, - }, - { // medium (default) - primaryImageScale: 0.75, - primaryTextScale: 0.95, - }, - { // large - primaryImageScale: 0.85, - primaryTextScale: 1.05, - }, - { // x-large - primaryImageScale: 0.95, - primaryTextScale: 1.10, - }, -]; - -const secondarySizePresets = [ - { // x-small - secondaryImageScale: 0.35, - secondaryTextScale: 0.85, - }, - { // small - secondaryImageScale: 0.42, - secondaryTextScale: 0.92, - }, - { // medium (default) - secondaryImageScale: 0.50, - secondaryTextScale: 1.00, - }, - { // large - secondaryImageScale: 0.60, - secondaryTextScale: 1.10, - }, - { // x-large - secondaryImageScale: 0.80, - secondaryTextScale: 1.30, - }, -]; - const secondaryLanguagePresets = [ { secondaryLanguageMode: 'disabled', @@ -107,21 +86,13 @@ function renderActiveSettings() { elem && elem.classList.add('active'); } // primary font size - const primaryFontSizeId = primarySizePresets.findIndex(k => (k.primaryImageScale === settings.primaryImageScale)); - if (primaryFontSizeId !== -1) { - elem = document.querySelector(`.settings-primary-font-size div.font-size[data-id="${primaryFontSizeId}"]`); - elem && elem.classList.add('active'); - } + document.getElementById('primary-font-indicator').style.scale = settings.primaryTextScale * 0.8; // primary font color document.getElementById('primary-color').value = settings.primaryTextColor || "#ffffff"; // secondary font size - const secondaryFontSizeId = secondarySizePresets.findIndex(k => (k.secondaryImageScale === settings.secondaryImageScale)); - if (secondaryFontSizeId !== -1) { - elem = document.querySelector(`.settings-secondary-font-size div.font-size[data-id="${secondaryFontSizeId}"]`); - elem && elem.classList.add('active'); - } + document.getElementById('secondary-font-indicator').style.scale = settings.secondaryTextScale * 0.8; // secondary font color document.getElementById('secondary-color').value = settings.secondaryTextColor || "#ffffff"; @@ -145,18 +116,27 @@ function updateLayout(layoutId) { renderActiveSettings(); } -function updatePrimaryFontSize(fontSizeId) { - if (fontSizeId < 0 || fontSizeId >= primarySizePresets.length) return; +function updatePrimaryFontSize(action) { + if (action === "+") { + settings.primaryTextScale = Math.min(maximumFontScale, settings.primaryTextScale + 0.1); + } else if (action === "-"){ + settings.primaryTextScale = Math.max(minimumFontScale, settings.primaryTextScale - 0.1); + } else return; - settings = Object.assign(settings, primarySizePresets[fontSizeId]); + settings.primaryImageScale = 0.6 * settings.primaryTextScale; uploadSettings(); renderActiveSettings(); } -function updateSecondaryFontSize(fontSizeId) { - if (fontSizeId < 0 || fontSizeId >= secondarySizePresets.length) return; +function updateSecondaryFontSize(action) { + if (action === "+") { + settings.secondaryTextScale = Math.min(maximumFontScale, settings.secondaryTextScale + 0.1); + } else if (action === "-"){ + settings.secondaryTextScale = Math.max(minimumFontScale, settings.secondaryTextScale - 0.1); + } else return; + + settings.secondaryImageScale = 0.6 * settings.secondaryTextScale; - settings = Object.assign(settings, secondarySizePresets[fontSizeId]); uploadSettings(); renderActiveSettings(); } @@ -202,28 +182,36 @@ window.addEventListener('load', evt => { div.addEventListener('click', evt => updateLayout(layoutId), false); }); - const primarySizes = document.querySelectorAll('.settings-primary-font-size div.font-size'); - [].forEach.call(primarySizes, div => { - const fontSizeId = parseInt(div.getAttribute('data-id')); - div.addEventListener('click', evt => updatePrimaryFontSize(fontSizeId), false); - }); + document.getElementById("primary-plus").addEventListener('click', () => updatePrimaryFontSize("+")); + document.getElementById("primary-minus").addEventListener('click', () => updatePrimaryFontSize("-")); - const secondarySizes = document.querySelectorAll('.settings-secondary-font-size div.font-size'); - [].forEach.call(secondarySizes, div => { - const fontSizeId = parseInt(div.getAttribute('data-id')); - div.addEventListener('click', evt => updateSecondaryFontSize(fontSizeId), false); - }); + document.getElementById("secondary-plus").addEventListener('click', () => updateSecondaryFontSize("+")); + document.getElementById("secondary-minus").addEventListener('click', () => updateSecondaryFontSize("-")); - const primaryColorField = document.getElementById('primary-color') + const primaryColorField = document.getElementById('primary-color'); primaryColorField.onchange = evt => { - updatePrimaryColor(evt.target.value) + updatePrimaryColor(evt.target.value); } - const secondaryColorField = document.getElementById('secondary-color') + primaryPicker?.setOptions({ + parent: document.getElementById('primary-color-ff'), + onChange: color => { + updatePrimaryColor(color.hex.slice(0, 7)); + } + }); + + const secondaryColorField = document.getElementById('secondary-color'); secondaryColorField.onchange = evt => { - updateSecondaryColor(evt.target.value, false) + updateSecondaryColor(evt.target.value); } + secondaryPicker?.setOptions({ + parent: document.getElementById('secondary-color-ff'), + onChange: color => { + updateSecondaryColor(color.hex.slice(0, 7)); + } + }); + const secondaryLanguage = document.querySelectorAll('.settings-secondary-lang > div'); [].forEach.call(secondaryLanguage, div => { const languageId = parseInt(div.getAttribute('data-id'));