mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 10:56:15 -08:00
8 lines
30 KiB
JavaScript
8 lines
30 KiB
JavaScript
|
|
/*!
|
|
* artplayer-plugin-jassub.js v1.0.0
|
|
* Github: https://github.com/zhw2590582/ArtPlayer
|
|
* (c) 2017-2026 Harvey Zhao
|
|
* Released under the MIT License.
|
|
*/
|
|
!function(e,t,r,n,i){var a="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},s="function"==typeof a[n]&&a[n],o=s.i||{},c=s.cache||{},l="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,r){if(!c[t]){if(!e[t]){if(i[t])return i[t];var o="function"==typeof a[n]&&a[n];if(!r&&o)return o(t,!0);if(s)return s(t,!0);if(l&&"string"==typeof t)return l(t);var d=Error("Cannot find module '"+t+"'");throw d.code="MODULE_NOT_FOUND",d}h.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},h.cache={};var f=c[t]=new u.Module(t);e[t][0].call(f.exports,h,f,f.exports,a)}return c[t].exports;function h(e){var t=h.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var r={__esModule:!0};return t.forEach(function(e){var t=e[0],n=e[1],i=e[2]||e[0],a=u(n);"*"===t?Object.keys(a).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:function(){return a[e]}})}):"*"===i?Object.defineProperty(r,t,{enumerable:!0,value:a}):Object.defineProperty(r,t,{enumerable:!0,get:function(){return"default"===i?a.__esModule?a.default:a:a[i]}})}),r}return u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.require=l,this.exports={}},u.modules=e,u.cache=c,u.parent=s,u.distDir=void 0,u.publicUrl=void 0,u.devServer=void 0,u.i=o,u.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(u,"root",{get:function(){return a[n]}}),a[n]=u;for(var d=0;d<t.length;d++)u(t[d]);if(r){var f=u(r);"object"==typeof exports&&"u">typeof module?module.exports=f:"function"==typeof define&&define.amd&&define(function(){return f})}}({k1Tni:[function(e,t,r,n){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"default",function(){return c});var a=e("@swc/helpers/cjs/_object_spread.cjs"),s=e("./jassub.es.js"),o=i.interopDefault(s);function c(e){return function(t){var r=new(0,o.default)((0,a._)({video:t.video},e));return r._canvasParent.style.zIndex=20,t.on("destroy",function(){r.destroy()}),{name:"artplayerPluginJassub",instance:r}}}"u">typeof window&&(window.artplayerPluginJassub=c)},{"@swc/helpers/cjs/_object_spread.cjs":"kyoEj","./jassub.es.js":"5H1mY","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],kyoEj:[function(e,t,r,n){"use strict";var i=e("9f9b8a24218ee51e");r._=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){i._(e,t,r[t])})}return e}},{"9f9b8a24218ee51e":"ltU3W"}],ltU3W:[function(e,t,r,n){"use strict";r._=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}},{}],"5H1mY":[function(e,t,r,n){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"default",function(){return b});var a=e("@swc/helpers/cjs/_async_to_generator.cjs"),s=e("@swc/helpers/cjs/_call_super.cjs"),o=e("@swc/helpers/cjs/_class_call_check.cjs"),c=e("@swc/helpers/cjs/_create_class.cjs"),l=e("@swc/helpers/cjs/_define_property.cjs"),u=e("@swc/helpers/cjs/_inherits.cjs"),d=e("@swc/helpers/cjs/_object_spread.cjs"),f=e("@swc/helpers/cjs/_sliced_to_array.cjs"),h=e("@swc/helpers/cjs/_to_consumable_array.cjs"),_=e("@swc/helpers/cjs/_type_of.cjs"),v=e("@swc/helpers/cjs/_wrap_native_super.cjs"),p=e("@swc/helpers/cjs/_ts_generator.cjs");("u"<typeof HTMLVideoElement?"undefined":(0,_._)(HTMLVideoElement))<"u"&&!("requestVideoFrameCallback"in HTMLVideoElement.prototype)&&"getVideoPlaybackQuality"in HTMLVideoElement.prototype&&(HTMLVideoElement.prototype._rvfcpolyfillmap={},HTMLVideoElement.prototype.requestVideoFrameCallback=function(e){var t=this,r=performance.now(),n=this.getVideoPlaybackQuality(),i=this.mozPresentedFrames||this.mozPaintedFrames||n.totalVideoFrames-n.droppedVideoFrames,a=function(s,o){var c=t.getVideoPlaybackQuality(),l=t.mozPresentedFrames||t.mozPaintedFrames||c.totalVideoFrames-c.droppedVideoFrames;if(l>i){var u=t.mozFrameDelay||c.totalFrameDelay-n.totalFrameDelay||0,d=o-s;e(o,{presentationTime:o+1e3*u,expectedDisplayTime:o+d,width:t.videoWidth,height:t.videoHeight,mediaTime:Math.max(0,t.currentTime||0)+d/1e3,presentedFrames:l,processingDuration:u}),delete t._rvfcpolyfillmap[r]}else t._rvfcpolyfillmap[r]=requestAnimationFrame(function(e){return a(o,e)})};return this._rvfcpolyfillmap[r]=requestAnimationFrame(function(e){return a(r,e)}),r},HTMLVideoElement.prototype.cancelVideoFrameCallback=function(e){cancelAnimationFrame(this._rvfcpolyfillmap[e]),delete this._rvfcpolyfillmap[e]});var m={bt709:"BT709",bt470bg:"BT601",smpte170m:"BT601"},y={BT601:{BT709:"1.0863 -0.0723 -0.014 0 0 0.0965 0.8451 0.0584 0 0 -0.0141 -0.0277 1.0418"},BT709:{BT601:"0.9137 0.0784 0.0079 0 0 -0.1049 1.1722 -0.0671 0 0 0.0096 0.0322 0.9582"},FCC:{BT709:"1.0873 -0.0736 -0.0137 0 0 0.0974 0.8494 0.0531 0 0 -0.0127 -0.0251 1.0378",BT601:"1.001 -0.0008 -0.0002 0 0 0.0009 1.005 -0.006 0 0 0.0013 0.0027 0.996"},SMPTE240M:{BT709:"0.9993 0.0006 0.0001 0 0 -0.0004 0.9812 0.0192 0 0 -0.0034 -0.0114 1.0148",BT601:"0.913 0.0774 0.0096 0 0 -0.1051 1.1508 -0.0456 0 0 0.0063 0.0207 0.973"}},b=function(e){"use strict";function t(e){if((0,o._)(this,t),r=(0,s._)(this,t),!globalThis.Worker)throw r.destroy("Worker not supported");if(!e)throw r.destroy("No options provided");r._loaded=new Promise(function(e){r._init=e});var r,n,i,a=t._test();if(r._onDemandRender="requestVideoFrameCallback"in HTMLVideoElement.prototype&&(null==(n=e.onDemandRender)||n),r._offscreenRender="transferControlToOffscreen"in HTMLCanvasElement.prototype&&!e.canvas&&(null==(i=e.offscreenRender)||i),r.timeOffset=e.timeOffset||0,r._video=e.video,r._videoHeight=0,r._videoWidth=0,r._videoColorSpace=null,r._canvas=e.canvas,r._video&&!r._canvas)r._canvasParent=document.createElement("div"),r._canvasParent.className="JASSUB",r._canvasParent.style.position="relative",r._canvas=r._createCanvas(),r._video.insertAdjacentElement("afterend",r._canvasParent);else if(!r._canvas)throw r.destroy("Don't know where to render: you should give video or canvas in options.");if(r._bufferCanvas=document.createElement("canvas"),r._bufferCtx=r._bufferCanvas.getContext("2d"),!r._bufferCtx)throw r.destroy("Canvas rendering not supported");return r._canvasctrl=r._offscreenRender?r._canvas.transferControlToOffscreen():r._canvas,r._ctx=!r._offscreenRender&&r._canvasctrl.getContext("2d"),r._lastRenderTime=0,r.debug=!!e.debug,r.prescaleFactor=e.prescaleFactor||1,r.prescaleHeightLimit=e.prescaleHeightLimit||1080,r.maxRenderHeight=e.maxRenderHeight||0,r._boundResize=r.resize.bind(r),r._boundTimeUpdate=r._timeupdate.bind(r),r._boundSetRate=r.setRate.bind(r),r._boundUpdateColorSpace=r._updateColorSpace.bind(r),r._video&&r.setVideo(e.video),r._onDemandRender&&(r.busy=!1,r._lastDemandTime=null),r._worker=new Worker(e.workerUrl||"jassub-worker.js"),r._worker.onmessage=function(e){return r._onmessage(e)},r._worker.onerror=function(e){return r._error(e)},a.then(function(){var n,i,a,s;r._worker.postMessage({target:"init",wasmUrl:t._supportsSIMD&&e.modernWasmUrl?e.modernWasmUrl:null!=(n=e.wasmUrl)?n:"jassub-worker.wasm",legacyWasmUrl:null!=(i=e.legacyWasmUrl)?i:"jassub-worker.wasm.js",asyncRender:("u"<typeof createImageBitmap?"undefined":(0,_._)(createImageBitmap))<"u"&&(null==(a=e.asyncRender)||a),onDemandRender:r._onDemandRender,width:r._canvasctrl.width||0,height:r._canvasctrl.height||0,blendMode:e.blendMode||"js",subUrl:e.subUrl,subContent:e.subContent||null,fonts:e.fonts||[],availableFonts:e.availableFonts||{"liberation sans":"./default.woff2"},fallbackFont:e.fallbackFont||"liberation sans",debug:r.debug,targetFps:e.targetFps||24,dropAllAnimations:e.dropAllAnimations,dropAllBlur:e.dropAllBlur,libassMemoryLimit:e.libassMemoryLimit||0,libassGlyphLimit:e.libassGlyphLimit||0,useLocalFonts:("u"<typeof queryLocalFonts?"undefined":(0,_._)(queryLocalFonts))<"u"&&(null==(s=e.useLocalFonts)||s),hasBitmapBug:t._hasBitmapBug}),!0===r._offscreenRender&&r.sendMessage("offscreenCanvas",null,[r._canvasctrl])}),r}return(0,u._)(t,e),(0,c._)(t,[{key:"_createCanvas",value:function(){return this._canvas=document.createElement("canvas"),this._canvas.style.display="block",this._canvas.style.position="absolute",this._canvas.style.pointerEvents="none",this._canvasParent.appendChild(this._canvas),this._canvas}},{key:"resize",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null==(e=this._video)?void 0:e.paused;if((!t||!r)&&this._video){var s=this._getVideoPosition(),o=null;if(this._videoWidth){var c=this._video.videoWidth/this._videoWidth,l=this._video.videoHeight/this._videoHeight;o=this._computeCanvasSize((s.width||0)/c,(s.height||0)/l)}else o=this._computeCanvasSize(s.width||0,s.height||0);t=o.width,r=o.height,this._canvasParent&&(n=s.y-(this._canvasParent.getBoundingClientRect().top-this._video.getBoundingClientRect().top),i=s.x),this._canvas.style.width=s.width+"px",this._canvas.style.height=s.height+"px"}this._canvas.style.top=n+"px",this._canvas.style.left=i+"px",a&&!1===this.busy?this.busy=!0:a=!1,this.sendMessage("canvas",{width:t,height:r,videoWidth:this._videoWidth||this._video.videoWidth,videoHeight:this._videoHeight||this._video.videoHeight,force:a})}},{key:"_getVideoPosition",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._video.videoWidth,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._video.videoHeight,r=e/t,n=this._video,i=n.offsetWidth,a=n.offsetHeight;e=i,t=a,i/a>r?e=Math.floor(a*r):t=Math.floor(i/r);var s=(i-e)/2,o=(a-t)/2;return{width:e,height:t,x:s,y:o}}},{key:"_computeCanvasSize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.prescaleFactor<=0?1:this.prescaleFactor,n=self.devicePixelRatio||1;if(t<=0||e<=0)e=0,t=0;else{var i=r<1?-1:1,a=t*n;i*a*r<=i*this.prescaleHeightLimit?a*=r:i*a<i*this.prescaleHeightLimit&&(a=this.prescaleHeightLimit),this.maxRenderHeight>0&&a>this.maxRenderHeight&&(a=this.maxRenderHeight),e*=a/t,t=a}return{width:e,height:t}}},{key:"_timeupdate",value:function(e){var t={seeking:!0,waiting:!0,playing:!1}[e.type];null!=t&&(this._playstate=t),this.setCurrentTime(this._video.paused||this._playstate,this._video.currentTime+this.timeOffset)}},{key:"setVideo",value:function(e){var t=this;e instanceof HTMLVideoElement?(this._removeListeners(),this._video=e,this._onDemandRender?this._video.requestVideoFrameCallback(this._handleRVFC.bind(this)):(this._playstate=e.paused,e.addEventListener("timeupdate",this._boundTimeUpdate,!1),e.addEventListener("progress",this._boundTimeUpdate,!1),e.addEventListener("waiting",this._boundTimeUpdate,!1),e.addEventListener("seeking",this._boundTimeUpdate,!1),e.addEventListener("playing",this._boundTimeUpdate,!1),e.addEventListener("ratechange",this._boundSetRate,!1),e.addEventListener("resize",this._boundResize,!1)),"VideoFrame"in window&&(e.addEventListener("loadedmetadata",this._boundUpdateColorSpace,!1),e.readyState>2&&this._updateColorSpace()),e.videoWidth>0&&this.resize(),("u"<typeof ResizeObserver?"undefined":(0,_._)(ResizeObserver))<"u"&&(this._ro||(this._ro=new ResizeObserver(function(){return t.resize()})),this._ro.observe(e))):this._error("Video element invalid!")}},{key:"runBenchmark",value:function(){this.sendMessage("runBenchmark")}},{key:"setTrackByUrl",value:function(e){this.sendMessage("setTrackByUrl",{url:e}),this._reAttachOffscreen(),this._ctx&&(this._ctx.filter="none")}},{key:"setTrack",value:function(e){this.sendMessage("setTrack",{content:e}),this._reAttachOffscreen(),this._ctx&&(this._ctx.filter="none")}},{key:"freeTrack",value:function(){this.sendMessage("freeTrack")}},{key:"setIsPaused",value:function(e){this.sendMessage("video",{isPaused:e})}},{key:"setRate",value:function(e){this.sendMessage("video",{rate:e})}},{key:"setCurrentTime",value:function(e,t,r){this.sendMessage("video",{isPaused:e,currentTime:t,rate:r,colorSpace:this._videoColorSpace})}},{key:"createEvent",value:function(e){this.sendMessage("createEvent",{event:e})}},{key:"setEvent",value:function(e,t){this.sendMessage("setEvent",{event:e,index:t})}},{key:"removeEvent",value:function(e){this.sendMessage("removeEvent",{index:e})}},{key:"getEvents",value:function(e){this._fetchFromWorker({target:"getEvents"},function(t,r){e(t,r.events)})}},{key:"styleOverride",value:function(e){this.sendMessage("styleOverride",{style:e})}},{key:"disableStyleOverride",value:function(){this.sendMessage("disableStyleOverride")}},{key:"createStyle",value:function(e){this.sendMessage("createStyle",{style:e})}},{key:"setStyle",value:function(e,t){this.sendMessage("setStyle",{style:e,index:t})}},{key:"removeStyle",value:function(e){this.sendMessage("removeStyle",{index:e})}},{key:"getStyles",value:function(e){this._fetchFromWorker({target:"getStyles"},function(t,r){e(t,r.styles)})}},{key:"addFont",value:function(e){this.sendMessage("addFont",{font:e})}},{key:"setDefaultFont",value:function(e){this.sendMessage("defaultFont",{font:e})}},{key:"_sendLocalFont",value:function(e){var t=this;try{queryLocalFonts().then(function(r){var n=null==r?void 0:r.find(function(t){return t.fullName.toLowerCase()===e});n&&n.blob().then(function(e){e.arrayBuffer().then(function(e){t.addFont(new Uint8Array(e))})})})}catch(e){console.warn("Local fonts API:",e)}}},{key:"_getLocalFont",value:function(e){var t,r,n=this,i=e.font;try{(null==(r=navigator)||null==(t=r.permissions)?void 0:t.query)?navigator.permissions.query({name:"local-fonts"}).then(function(e){"granted"===e.state&&n._sendLocalFont(i)}):this._sendLocalFont(i)}catch(e){console.warn("Local fonts API:",e)}}},{key:"_unbusy",value:function(){this._lastDemandTime?this._demandRender(this._lastDemandTime):this.busy=!1}},{key:"_handleRVFC",value:function(e,t){var r=t.mediaTime,n=t.width,i=t.height;if(this._destroyed)return null;this.busy?this._lastDemandTime={mediaTime:r,width:n,height:i}:(this.busy=!0,this._demandRender({mediaTime:r,width:n,height:i})),this._video.requestVideoFrameCallback(this._handleRVFC.bind(this))}},{key:"_demandRender",value:function(e){var t=e.mediaTime,r=e.width,n=e.height;this._lastDemandTime=null,(r!==this._videoWidth||n!==this._videoHeight)&&(this._videoWidth=r,this._videoHeight=n,this.resize()),this.sendMessage("demand",{time:t+this.timeOffset})}},{key:"_detachOffscreen",value:function(){if(!this._offscreenRender||this._ctx)return null;this._canvas.remove(),this._createCanvas(),this._canvasctrl=this._canvas,this._ctx=this._canvasctrl.getContext("2d"),this.sendMessage("detachOffscreen"),this.busy=!1,this.resize(0,0,0,0,!0)}},{key:"_reAttachOffscreen",value:function(){if(!this._offscreenRender||!this._ctx)return null;this._canvas.remove(),this._createCanvas(),this._canvasctrl=this._canvas.transferControlToOffscreen(),this._ctx=!1,this.sendMessage("offscreenCanvas",null,[this._canvasctrl]),this.resize(0,0,0,0,!0)}},{key:"_updateColorSpace",value:function(){var e=this;this._video.requestVideoFrameCallback(function(){try{var t=new VideoFrame(e._video);e._videoColorSpace=m[t.colorSpace.matrix],t.close(),e.sendMessage("getColorSpace")}catch(e){console.warn(e)}})}},{key:"_verifyColorSpace",value:function(e){var t=e.subtitleColorSpace,r=e.videoColorSpace,n=void 0===r?this._videoColorSpace:r;t&&n&&t!==n&&(this._detachOffscreen(),this._ctx.filter="url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='f'><feColorMatrix type='matrix' values='".concat(y[t][n]," 0 0 0 0 0 1 0'/></filter></svg>#f\")"))}},{key:"_render",value:function(e){var t=e.images,r=e.asyncRender,n=e.times,i=e.width,a=e.height,s=e.colorSpace;this._unbusy(),this.debug&&(n.IPCTime=Date.now()-n.JSRenderTime),(this._canvasctrl.width!==i||this._canvasctrl.height!==a)&&(this._canvasctrl.width=i,this._canvasctrl.height=a,this._verifyColorSpace({subtitleColorSpace:s})),this._ctx.clearRect(0,0,this._canvasctrl.width,this._canvasctrl.height);var o=!0,c=!1,l=void 0;try{for(var u,d=t[Symbol.iterator]();!(o=(u=d.next()).done);o=!0){var f=u.value;f.image&&(r?(this._ctx.drawImage(f.image,f.x,f.y),f.image.close()):(this._bufferCanvas.width=f.w,this._bufferCanvas.height=f.h,this._bufferCtx.putImageData(new ImageData(this._fixAlpha(new Uint8ClampedArray(f.image)),f.w,f.h),0,0),this._ctx.drawImage(this._bufferCanvas,f.x,f.y)))}}catch(e){c=!0,l=e}finally{try{o||null==d.return||d.return()}finally{if(c)throw l}}if(this.debug){n.JSRenderTime=Date.now()-n.JSRenderTime-n.IPCTime;var h=0,_=n.bitmaps||t.length;for(var v in delete n.bitmaps,n)h+=n[v];console.log("Bitmaps: "+_+" Total: "+(0|h)+"ms",n)}}},{key:"_fixAlpha",value:function(e){if(t._hasAlphaBug)for(var r=3;r<e.length;r+=4)e[r]=e[r]>1?e[r]:1;return e}},{key:"_ready",value:function(){this._init(),this.dispatchEvent(new CustomEvent("ready"))}},{key:"sendMessage",value:function(e,t){return(0,a._)(function(e){var t,r,n=arguments;return(0,p._)(this,function(i){switch(i.label){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:{},r=n.length>2?n[2]:void 0,[4,this._loaded];case 1:return i.sent(),r?this._worker.postMessage((0,d._)({target:e,transferable:r},t),(0,h._)(r)):this._worker.postMessage((0,d._)({target:e},t)),[2]}})}).apply(this,arguments)}},{key:"_fetchFromWorker",value:function(e,t){var r=this;try{var n=e.target,i=setTimeout(function(){s(Error("Error: Timeout while try to fetch "+n))},5e3),a=function(e){var o=e.data;o.target===n&&(t(null,o),r._worker.removeEventListener("message",a),r._worker.removeEventListener("error",s),clearTimeout(i))},s=function(e){t(e),r._worker.removeEventListener("message",a),r._worker.removeEventListener("error",s),clearTimeout(i)};this._worker.addEventListener("message",a),this._worker.addEventListener("error",s),this._worker.postMessage(e)}catch(e){this._error(e)}}},{key:"_console",value:function(e){var t=e.content,r=e.command;console[r].apply(console,JSON.parse(t))}},{key:"_onmessage",value:function(e){var t=e.data;this["_"+t.target]&&this["_"+t.target](t)}},{key:"_error",value:function(e){var t=e instanceof Error?e:e instanceof ErrorEvent?e.error:Error(e),r=e instanceof Event?new ErrorEvent(e.type,e):new ErrorEvent("error",{error:t});return this.dispatchEvent(r),console.error(t),t}},{key:"_removeListeners",value:function(){this._video&&(this._ro&&this._ro.unobserve(this._video),this._ctx&&(this._ctx.filter="none"),this._video.removeEventListener("timeupdate",this._boundTimeUpdate),this._video.removeEventListener("progress",this._boundTimeUpdate),this._video.removeEventListener("waiting",this._boundTimeUpdate),this._video.removeEventListener("seeking",this._boundTimeUpdate),this._video.removeEventListener("playing",this._boundTimeUpdate),this._video.removeEventListener("ratechange",this._boundSetRate),this._video.removeEventListener("resize",this._boundResize),this._video.removeEventListener("loadedmetadata",this._boundUpdateColorSpace))}},{key:"destroy",value:function(e){var t,r;return e&&(e=this._error(e)),this._video&&this._canvasParent&&(null==(t=this._video.parentNode)||t.removeChild(this._canvasParent)),this._destroyed=!0,this._removeListeners(),this.sendMessage("destroy"),null==(r=this._worker)||r.terminate(),e}}],[{key:"_testSIMD",value:function(){if(null===t._supportsSIMD)try{t._supportsSIMD=WebAssembly.validate(Uint8Array.of(0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11))}catch(e){t._supportsSIMD=!1}}},{key:"_testImageBugs",value:function(){return(0,a._)(function(){var e,r,n,i,a,s,o,c,l,u,d,h,v,m,y,b,g;return(0,p._)(this,function(p){switch(p.label){case 0:if(null!==t._hasBitmapBug)return[2];if(!(r=(e=document.createElement("canvas")).getContext("2d",{willReadFrequently:!0})))throw Error("Canvas rendering not supported");if("function"==typeof ImageData.prototype.constructor)try{new ImageData(new Uint8ClampedArray([0,0,0,0]),1,1)}catch(e){console.log("Detected that ImageData is not constructable despite browser saying so"),self.ImageData=function(e,t,n){var i=r.createImageData(t,n);return e&&i.data.set(e),i}}if(!(i=(n=document.createElement("canvas")).getContext("2d",{willReadFrequently:!0})))throw Error("Canvas rendering not supported");if(e.width=n.width=1,e.height=n.height=1,r.clearRect(0,0,1,1),i.clearRect(0,0,1,1),a=i.getImageData(0,0,1,1).data,r.putImageData(new ImageData(new Uint8ClampedArray([0,255,0,0]),1,1),0,0),i.drawImage(e,0,0),s=i.getImageData(0,0,1,1).data,t._hasAlphaBug=a[1]!==s[1],t._hasAlphaBug&&console.log("Detected a browser having issue with transparent pixels, applying workaround"),!(("u"<typeof createImageBitmap?"undefined":(0,_._)(createImageBitmap))<"u"))return[3,2];return o=new Uint8ClampedArray([255,0,255,0,255]).subarray(1,5),c=i.drawImage,[4,createImageBitmap(new ImageData(o,1))];case 1:c.apply(i,[p.sent(),0,0]),l=i.getImageData(0,0,1,1).data,t._hasBitmapBug=!1,u=!0,d=!1,h=void 0;try{for(v=l.entries()[Symbol.iterator]();!(u=(m=v.next()).done);u=!0)if(b=(y=(0,f._)(m.value,2))[0],g=y[1],Math.abs(o[b]-g)>15){t._hasBitmapBug=!0,console.log("Detected a browser having issue with partial bitmaps, applying workaround");break}}catch(e){d=!0,h=e}finally{try{u||null==v.return||v.return()}finally{if(d)throw h}}return[3,3];case 2:t._hasBitmapBug=!1,p.label=3;case 3:return e.remove(),n.remove(),[2]}})})()}},{key:"_test",value:function(){return(0,a._)(function(){return(0,p._)(this,function(e){switch(e.label){case 0:return t._testSIMD(),[4,t._testImageBugs()];case 1:return e.sent(),[2]}})})()}}]),t}((0,v._)(EventTarget));(0,l._)(b,"_supportsSIMD",null),(0,l._)(b,"_hasAlphaBug",null),(0,l._)(b,"_hasBitmapBug",null)},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_call_super.cjs":"clpdF","@swc/helpers/cjs/_class_call_check.cjs":"4Uf9M","@swc/helpers/cjs/_create_class.cjs":"igUuK","@swc/helpers/cjs/_define_property.cjs":"ltU3W","@swc/helpers/cjs/_inherits.cjs":"jtSwf","@swc/helpers/cjs/_object_spread.cjs":"kyoEj","@swc/helpers/cjs/_sliced_to_array.cjs":"gIQTH","@swc/helpers/cjs/_to_consumable_array.cjs":"i81N6","@swc/helpers/cjs/_type_of.cjs":"iXhRw","@swc/helpers/cjs/_wrap_native_super.cjs":"j8pRR","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,t,r,n){"use strict";function i(e,t,r,n,i,a,s){try{var o=e[a](s),c=o.value}catch(e){r(e);return}o.done?t(c):Promise.resolve(c).then(n,i)}r._=function(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var s=e.apply(t,r);function o(e){i(s,n,a,o,c,"next",e)}function c(e){i(s,n,a,o,c,"throw",e)}o(void 0)})}}},{}],clpdF:[function(e,t,r,n){"use strict";var i=e("feddc910f69a01a6"),a=e("b644f6b72647b399"),s=e("ba991daace2b8ed9");r._=function(e,t,r){return t=i._(t),s._(e,a._()?Reflect.construct(t,r||[],i._(e).constructor):t.apply(e,r))}},{feddc910f69a01a6:"NOGHw",b644f6b72647b399:"83nDe",ba991daace2b8ed9:"hd12h"}],NOGHw:[function(e,t,r,n){"use strict";function i(e){return r._=i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}r._=i},{}],"83nDe":[function(e,t,r,n){"use strict";function i(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(r._=i=function(){return!!e})()}r._=i},{}],hd12h:[function(e,t,r,n){"use strict";var i=e("f7151fe13994d2aa"),a=e("f18e81760bb14899");r._=function(e,t){return t&&("object"===a._(t)||"function"==typeof t)?t:i._(e)}},{f7151fe13994d2aa:"1tlYe",f18e81760bb14899:"iXhRw"}],"1tlYe":[function(e,t,r,n){"use strict";r._=function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},{}],iXhRw:[function(e,t,r,n){"use strict";r._=function(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}},{}],"4Uf9M":[function(e,t,r,n){"use strict";r._=function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}},{}],igUuK:[function(e,t,r,n){"use strict";function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}r._=function(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),e}},{}],jtSwf:[function(e,t,r,n){"use strict";var i=e("b9db138b859a042c");r._=function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i._(e,t)}},{b9db138b859a042c:"7ubVA"}],"7ubVA":[function(e,t,r,n){"use strict";function i(e,t){return r._=i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}r._=i},{}],gIQTH:[function(e,t,r,n){"use strict";var i=e("d7c30a5ae0c1ab2"),a=e("3aacfce52f67defd"),s=e("f0dae09a1a08b16a"),o=e("83f3648e614d0830");r._=function(e,t){return i._(e)||a._(e,t)||o._(e,t)||s._()}},{d7c30a5ae0c1ab2:"3QSPl","3aacfce52f67defd":"5SSeo",f0dae09a1a08b16a:"heYSj","83f3648e614d0830":"fh7mx"}],"3QSPl":[function(e,t,r,n){"use strict";r._=function(e){if(Array.isArray(e))return e}},{}],"5SSeo":[function(e,t,r,n){"use strict";r._=function(e,t){var r,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a=[],s=!0,o=!1;try{for(i=i.call(e);!(s=(r=i.next()).done)&&(a.push(r.value),!t||a.length!==t);s=!0);}catch(e){o=!0,n=e}finally{try{s||null==i.return||i.return()}finally{if(o)throw n}}return a}}},{}],heYSj:[function(e,t,r,n){"use strict";r._=function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},{}],fh7mx:[function(e,t,r,n){"use strict";var i=e("3ee51b7dc02d0c44");r._=function(e,t){if(e){if("string"==typeof e)return i._(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i._(e,t)}}},{"3ee51b7dc02d0c44":"1WOAB"}],"1WOAB":[function(e,t,r,n){"use strict";r._=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}},{}],i81N6:[function(e,t,r,n){"use strict";var i=e("d402183024004bc7"),a=e("3209e2b12672cd18"),s=e("fc58adb8f1bff142"),o=e("5e213dc122a10171");r._=function(e){return i._(e)||a._(e)||o._(e)||s._()}},{d402183024004bc7:"hfQG0","3209e2b12672cd18":"fQrlQ",fc58adb8f1bff142:"fWabh","5e213dc122a10171":"fh7mx"}],hfQG0:[function(e,t,r,n){"use strict";var i=e("5bd5b10bf87fc8e");r._=function(e){if(Array.isArray(e))return i._(e)}},{"5bd5b10bf87fc8e":"1WOAB"}],fQrlQ:[function(e,t,r,n){"use strict";r._=function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}},{}],fWabh:[function(e,t,r,n){"use strict";r._=function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},{}],j8pRR:[function(e,t,r,n){"use strict";var i=e("c8857d56f4968279"),a=e("2ed7bdf1701f2d07"),s=e("5c5ad8846076b9cd"),o=e("2db6fa09e8a5be4c");function c(e){var t="function"==typeof Map?new Map:void 0;return r._=c=function(e){if(null===e||!s._(e))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return i._(e,arguments,a._(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),o._(r,e)},c(e)}r._=c},{c8857d56f4968279:"bC52X","2ed7bdf1701f2d07":"NOGHw","5c5ad8846076b9cd":"1mpbk","2db6fa09e8a5be4c":"7ubVA"}],bC52X:[function(e,t,r,n){"use strict";var i=e("62fc231ae2e75266"),a=e("3f98bf9d4f706151");function s(e,t,n){return i._()?r._=s=Reflect.construct:r._=s=function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&a._(i,r.prototype),i},s.apply(null,arguments)}r._=s},{"62fc231ae2e75266":"83nDe","3f98bf9d4f706151":"7ubVA"}],"1mpbk":[function(e,t,r,n){"use strict";r._=function(e){return -1!==Function.toString.call(e).indexOf("[native code]")}},{}],eltGh:[function(e,t,r,n){"use strict";r._=function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),o=Object.defineProperty;return o(s,"next",{value:c(0)}),o(s,"throw",{value:c(1)}),o(s,"return",{value:c(2)}),"function"==typeof Symbol&&o(s,Symbol.iterator,{value:function(){return this}}),s;function c(o){return function(c){var l=[o,c];if(r)throw TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&l[0]?n.return:l[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,l[1])).done)return i;switch(n=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,n=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){a.label=l[1];break}if(6===l[0]&&a.label<i[1]){a.label=i[1],i=l;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(l);break}i[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],n=0}finally{r=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}},{}],qpMMf:[function(e,t,r,n){r.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},r.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.exportAll=function(e,t){return Object.keys(e).forEach(function(r){"default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[r]}})}),t},r.export=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:r})}},{}]},["k1Tni"],"k1Tni","parcelRequire4dc0",{}); |