Files
ArtPlayer/docs/compiled/artplayer-plugin-vast.legacy.js
T
Harvey Zhao 699bf09577 feat: update changelog with Parcel to Vite refactor
feat: add danmuku plugin documentation and i18n setup guide

- Created a new documentation file for the danmuku plugin with code examples.
- Added a comprehensive guide for language settings (i18n) including default languages, importing languages, adding new languages, and modifying existing languages.
- Included code snippets for initializing the Artplayer with different language settings.

Add internationalization support for multiple languages in Artplayer

- Introduced Arabic (ar), Czech (cs), Spanish (es), Persian (fa), French (fr), Indonesian (id), Polish (pl), Russian (ru), Turkish (tr), Vietnamese (vi), and Traditional Chinese (zh-tw) translations.
- Created corresponding JavaScript and ES module files for each language containing translated strings for player controls and settings.
- Added a new documentation file for language settings in the project.

feat: add initial implementation of start option page with interactive code execution buttons

feat: add danmuku plugin documentation and i18n setup guide

- Created a new documentation file for the danmuku plugin, providing code examples for usage.
- Added a comprehensive guide for language settings, including default languages, importing languages, adding new languages, and modifying existing languages.
- Included code snippets for initializing the Artplayer with different language settings and importing language files.

refactor: update danmuku worker implementation and remove unused i18n files

- Changed the way the Danmuku class creates a Web Worker by using a worker loader instead of creating a blob.
- Removed Arabic, Czech, Spanish, Persian, French, Indonesian, Polish, Russian, Turkish, Vietnamese, and Traditional Chinese i18n files as they are no longer needed.
- Updated the Vite build configuration to disable banners for inline workers and added a plugin to remove worker banners from generated code.

feat: add danmuku plugin and i18n setup documentation

- Created a new documentation file for the danmuku plugin, providing code examples for usage.
- Added a new documentation file for language settings (i18n), detailing how to set default languages, import languages, and add new languages.
- Included code snippets for initializing the Artplayer with different language settings and examples for modifying existing languages.

feat: add danmuku plugin and i18n setup documentation

- Created a new documentation file for the danmuku plugin with code examples.
- Added a new documentation file for language settings (i18n) including import instructions and examples for setting default and custom languages.
- Updated the i18n documentation to include details on adding and modifying languages.

feat: add danmuku plugin and i18n setup documentation

- Created a new JavaScript file for the danmuku plugin documentation with multiple code execution buttons.
- Added a new JavaScript file for i18n (internationalization) setup documentation, including instructions for language settings, importing languages, and modifying language options.
- Included examples for setting default languages and adding new languages in the i18n documentation.

Refactor code structure for improved readability and maintainability
2026-03-07 15:21:34 +08:00

8 lines
23 KiB
JavaScript

/*!
* artplayer-plugin-vast.js v1.1.1
* Github: https://github.com/zhw2590582/ArtPlayer
* (c) 2017-2026 Harvey Zhao
* Released under the MIT License.
*/
!function(t,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e():"function"==typeof define&&define.amd?(t.ArtplayerPluginVast=e(),define(function(){return t.ArtplayerPluginVast})):(t="undefined"!==typeof globalThis?globalThis:t||self).ArtplayerPluginVast=e()}(this,function(){"use strict";var t=null,e=function(){t=null};function i(t,e,i){return e&&function(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}(t.prototype,e),t}function n(){return n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},n.apply(this,arguments)}function s(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(t,e,i){return(a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct:function(t,e,i){var n=[null];n.push.apply(n,e);var s=new(Function.bind.apply(t,n));return i&&o(s,i.prototype),s}).apply(null,arguments)}function d(t){var e="function"==typeof Map?new Map:void 0;return d=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return a(t,arguments,r(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),o(i,t)},d(t)}function h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var l=0;function c(t){return"__private_"+l+++"_"+t}function f(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}var v={};v.CustomEvent="function"==typeof CustomEvent?CustomEvent:function(t){return e[t]=new e("").constructor[t],e;function e(t,e){e||(e={});var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,!!e.bubbles,!!e.cancelable,e.detail),i}}("prototype");var p,y,E,A=v.CustomEvent,m=c("mediaElement"),b=c("currentTime"),g=c("enabled"),O=function(){function t(t){Object.defineProperty(this,m,{writable:!0,value:void 0}),Object.defineProperty(this,b,{writable:!0,value:void 0}),Object.defineProperty(this,g,{writable:!0,value:void 0}),this.seeking=void 0,f(this,m)[m]=t,f(this,b)[b]=0,f(this,g)[g]=!1,this.seeking=!1,this.t=this.t.bind(this),this.i=this.i.bind(this),this.h=this.h.bind(this),this.enable()}var e=t.prototype;return e.i=function(){this.seeking=!0},e.h=function(){this.seeking=!1},e.t=function(){var t,e;this.seeking||null!=(t=f(this,m)[m])&&t.paused||(f(this,b)[b]=null==(e=f(this,m)[m])?void 0:e.currentTime)},e.enable=function(){var t,e,i;f(this,g)[g]||(null==(t=f(this,m)[m])||t.addEventListener("seeking",this.i),null==(e=f(this,m)[m])||e.addEventListener("seeked",this.h),null==(i=f(this,m)[m])||i.addEventListener("timeupdate",this.t),f(this,g)[g]=!0)},e.disable=function(){var t,e,i;f(this,g)[g]&&(null==(t=f(this,m)[m])||t.removeEventListener("seeking",this.i),null==(e=f(this,m)[m])||e.removeEventListener("seeked",this.h),null==(i=f(this,m)[m])||i.removeEventListener("timeupdate",this.t),f(this,g)[g]=!1)},e.play=function(){var t=this;return new Promise(function(e){var i;e(null==(i=f(t,m)[m])?void 0:i.play())})},e.pause=function(){var t;null==(t=f(this,m)[m])||t.pause()},e.reset=function(){f(this,b)[b]=0,f(this,g)[g]=!1,this.seeking=!1,this.enable()},e.destroy=function(){f(this,b)[b]=0,f(this,g)[g]=!1,this.seeking=!1,this.disable(),f(this,m)[m]=void 0},i(t,[{key:"enabled",get:function(){return f(this,g)[g]}},{key:"currentTime",get:function(){return f(this,b)[b]}},{key:"duration",get:function(){var t;return null==(t=f(this,m)[m])?void 0:t.duration}},{key:"muted",get:function(){var t;return null==(t=f(this,m)[m])?void 0:t.muted}},{key:"volume",get:function(){var t;return null==(t=f(this,m)[m])?void 0:t.volume}}]),t}(),w=function(){function t(){this.delegate=document.createDocumentFragment()}var e=t.prototype;return e.addEventListener=function(){this.delegate.addEventListener.apply(this.delegate,[].slice.call(arguments))},e.dispatchEvent=function(){return this.delegate.dispatchEvent.apply(this.delegate,[].slice.call(arguments))},e.removeEventListener=function(){return this.delegate.removeEventListener.apply(this.delegate,[].slice.call(arguments))},t}(),P=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"];(E=p||(p={})).MEDIA_START="MediaStart",E.MEDIA_IMPRESSION="MediaImpression",E.MEDIA_STOP="MediaStop",E.MEDIA_CUE_POINTS_CHANGE="MediaCuePointsChange",E.MEDIA_RESUMED="MediaResumed",function(t){t.AD_ERROR="AdError",t.AD_BUFFERING="AdBuffering",t.LOADED="AdLoaded",t.IMPRESSION="AdImpression",t.STARTED="AdStarted",t.FIRST_QUARTILE="AdFirstQuartile",t.MIDPOINT="AdMidpoint",t.THIRD_QUARTILE="AdThirdQuartile",t.AD_PROGRESS="AdProgress",t.COMPLETE="AdComplete",t.CLICK="AdClick",t.PAUSED="AdPaused",t.RESUMED="AdResumed",t.SKIPPED="AdSkipped",t.SKIPPABLE_STATE_CHANGED="AdSkippableStateChanged",t.VOLUME_CHANGED="AdVolumeChanged",t.VOLUME_MUTED="AdMuted",t.AD_METADATA="AdMetadata",t.AD_BREAK_READY="AdBreakReady",t.CONTENT_PAUSE_REQUESTED="AdContentPauseRequested",t.CONTENT_RESUME_REQUESTED="AdContentResumeRequested",t.ALL_ADS_COMPLETED="AdAllAdsCompleted",t.DURATION_CHANGE="AdDurationChange",t.INTERACTION="AdInteraction",t.LINEAR_CHANGED="AdLinearChanged",t.LOG="AdLog",t.USER_CLOSE="AdUserClose",t.AD_CAN_PLAY="AdCanPlay",t.EXPANDED_CHANGED="AdExpandedChanged",t.VIEWABLE_IMPRESSION="AdViewableImpression"}(y||(y={}));var R=n({},y,p),T=function(){this.disableCustomPlaybackForIOS10Plus=!1,this.autoResize=!0,this.clickTrackingElement=void 0},S=function(t){function e(){var e;return(e=t.call.apply(t,[this].concat([].slice.call(arguments)))||this).errorCode=void 0,e.innerError=void 0,e.type=void 0,e.vastErrorCode=void 0,e}return s(e,t),e}(d(Error));S.ERROR_CODE_ADS_MANAGER_LOADED_TIMEOUT=9e3,S.ERROR_CODE_REQUEST_ADS_TIMEOUT=9001;var D=c("mediaElement"),_=c("adElement"),C=c("customPlayhead"),k=c("adsRenderingSettings"),I=c("ima"),L=c("adDisplayContainer"),M=c("adsManager"),j=c("width"),N=c("height"),U=c("adsLoader"),B=c("playerOptions"),z=c("resizeObserver"),x=c("currentAd"),V=c("loadedAd"),G=c("mediaStartTriggered"),F=c("mediaImpressionTriggered"),H=c("mediaInActivation"),W=c("customPlaybackTimeAdjustedOnEnded"),q=c("cuePoints"),Q=c("adCurrentTime"),K=c("adDuration"),$=c("startAdCallback"),Y=c("adsManagerLoadedTimeout"),X=c("requestAdsTimeout"),Z=c("wasExternallyPaused"),J=c("lastNonZeroAdVolume"),tt=c("activatePromise"),et=function(t){function e(e,i,n,s,r){var o;void 0===s&&(s=new e.AdsRenderingSettings),void 0===r&&(r=new T),o=t.call(this)||this,Object.defineProperty(h(o),D,{writable:!0,value:void 0}),Object.defineProperty(h(o),_,{writable:!0,value:void 0}),Object.defineProperty(h(o),C,{writable:!0,value:void 0}),Object.defineProperty(h(o),k,{writable:!0,value:void 0}),Object.defineProperty(h(o),I,{writable:!0,value:void 0}),Object.defineProperty(h(o),L,{writable:!0,value:void 0}),Object.defineProperty(h(o),M,{writable:!0,value:void 0}),Object.defineProperty(h(o),j,{writable:!0,value:void 0}),Object.defineProperty(h(o),N,{writable:!0,value:void 0}),Object.defineProperty(h(o),U,{writable:!0,value:void 0}),Object.defineProperty(h(o),B,{writable:!0,value:void 0}),Object.defineProperty(h(o),z,{writable:!0,value:void 0}),Object.defineProperty(h(o),x,{writable:!0,value:void 0}),Object.defineProperty(h(o),V,{writable:!0,value:void 0}),Object.defineProperty(h(o),G,{writable:!0,value:!1}),Object.defineProperty(h(o),F,{writable:!0,value:!1}),Object.defineProperty(h(o),H,{writable:!0,value:!1}),Object.defineProperty(h(o),W,{writable:!0,value:!1}),Object.defineProperty(h(o),q,{writable:!0,value:[]}),Object.defineProperty(h(o),Q,{writable:!0,value:void 0}),Object.defineProperty(h(o),K,{writable:!0,value:void 0}),Object.defineProperty(h(o),$,{writable:!0,value:void 0}),Object.defineProperty(h(o),Y,{writable:!0,value:void 0}),Object.defineProperty(h(o),X,{writable:!0,value:void 0}),Object.defineProperty(h(o),Z,{writable:!0,value:!1}),Object.defineProperty(h(o),J,{writable:!0,value:1}),Object.defineProperty(h(o),tt,{writable:!0,value:Promise.resolve()}),f(h(o),D)[D]=i,f(h(o),_)[_]=n,f(h(o),I)[I]=e,f(h(o),B)[B]=r,f(h(o),k)[k]=s,f(h(o),k)[k].restoreCustomPlaybackStateOnAdBreakComplete=!0,r.disableCustomPlaybackForIOS10Plus&&!f(h(o),D)[D].hasAttribute("playsinline")&&f(h(o),D)[D].setAttribute("playsinline",""),f(h(o),I)[I].settings.setDisableCustomPlaybackForIOS10Plus(r.disableCustomPlaybackForIOS10Plus),f(h(o),C)[C]=new O(f(h(o),D)[D]),o.o=o.o.bind(h(o)),P.forEach(function(t){f(h(o),D)[D].addEventListener(t,o.o)}),o.u=o.u.bind(h(o)),o.l=o.l.bind(h(o));var a=f(h(o),D)[D],d=a.offsetHeight,u=a.offsetWidth;return f(h(o),j)[j]=u,f(h(o),N)[N]=d,r.autoResize&&window.ResizeObserver&&(f(h(o),z)[z]=new window.ResizeObserver(function(t){return o.v(t)}),f(h(o),z)[z].observe(f(h(o),D)[D])),o}s(e,t);var n=e.prototype;return n.activate=function(){var t=this;if(!f(this,G)[G]&&!f(this,H)[H]&&(f(this,H)[H]=!0,f(this,D)[D].paused)){var e=function(){return f(t,D)[D].pause(),new Promise(function(e){setTimeout(function(){f(t,H)[H]=!1,e()},1)})};f(this,tt)[tt]=new Promise(function(e){return e(f(t,D)[D].play())}).then(e).catch(e)}},n.playAds=function(t){this.m(t)},n.loadAds=function(t,e){this.m(t,!1,e)},n.p=function(){var t=this;return f(this,tt)[tt].then(function(){return new Promise(function(e){return e(f(t,D)[D].play())})})},n.m=function(t,e,i){var n=this;void 0===e&&(e=!0),this.reset(),this.O(),f(this,I)[I].settings.setAutoPlayAdBreaks(e),f(this,D)[D].ended&&(f(this,C)[C].reset(),f(this,D)[D].currentTime=0),f(this,$)[$]=i,t.linearAdSlotWidth=f(this,j)[j],t.linearAdSlotHeight=f(this,N)[N],t.nonLinearAdSlotWidth=f(this,j)[j],t.nonLinearAdSlotHeight=f(this,N)[N],null==t.contentDuration&&(t.contentDuration=-3),f(this,Y)[Y]=window.setTimeout(function(){var t=new S("No adsManagerLoadedEvent within 5000ms.");t.errorCode=S.ERROR_CODE_ADS_MANAGER_LOADED_TIMEOUT,n.j(t)},5e3),f(this,X)[X]=window.setTimeout(function(){var t=new S("No response for ads-request within 10000ms.");t.errorCode=S.ERROR_CODE_REQUEST_ADS_TIMEOUT,n.j(t)},1e4),f(this,U)[U].requestAds(t)},n.O=function(){f(this,L)[L]=new(f(this,I)[I].AdDisplayContainer)(f(this,_)[_],f(this,B)[B].disableCustomPlaybackForIOS10Plus?void 0:f(this,D)[D],f(this,B)[B].clickTrackingElement),f(this,U)[U]=new(f(this,I)[I].AdsLoader)(f(this,L)[L]),f(this,U)[U].addEventListener(f(this,I)[I].AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.u,!1),f(this,U)[U].addEventListener(f(this,I)[I].AdErrorEvent.Type.AD_ERROR,this.l,!1)},n.skipAd=function(){f(this,M)[M]&&f(this,M)[M].skip()},n.discardAdBreak=function(){f(this,M)[M]&&f(this,M)[M].discardAdBreak()},n.play=function(){var t=this;f(this,Z)[Z]=!1,!f(this,C)[C].enabled&&f(this,M)[M]?f(this,M)[M].resume():f(this,Y)[Y]||this.p().then(function(){}).catch(function(){t.dispatchEvent(new A("pause"))})},n.pause=function(){f(this,Z)[Z]=!0,!f(this,C)[C].enabled&&f(this,M)[M]?f(this,M)[M].pause():f(this,D)[D].pause()},n.g=function(t){f(this,q)[q]=[].concat(t),this.dispatchEvent(new A(R.MEDIA_CUE_POINTS_CHANGE,{detail:{cuePoints:[].concat(f(this,q)[q])}}))},n.A=function(t){var e=this.cuePoints.indexOf(t);e>-1&&(f(this,q)[q].splice(e,1),this.g(f(this,q)[q]))},n.resizeAd=function(t,e){f(this,j)[j]=t,f(this,N)[N]=e,f(this,M)[M]&&f(this,M)[M].resize(t,e,this.k()),f(this,_)[_].style.width=t+"px",f(this,_)[_].style.height=e+"px"},n.reset=function(t){void 0===t&&(t=!1),t&&(f(this,F)[F]=!1,f(this,G)[G]=!1,f(this,W)[W]=!1),this.C(),f(this,q)[q]=[],f(this,Z)[Z]=!1,f(this,$)[$]=void 0,f(this,M)[M]&&f(this,M)[M].destroy(),f(this,M)[M]=void 0,f(this,I)[I].settings.setAutoPlayAdBreaks(!0),t&&this.P(),f(this,_)[_].style.display="none"},n.P=function(){f(this,U)[U]&&(f(this,U)[U].removeEventListener(f(this,I)[I].AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.u,!1),f(this,U)[U].removeEventListener(f(this,I)[I].AdErrorEvent.Type.AD_ERROR,this.l,!1),f(this,U)[U].destroy()),f(this,L)[L]&&f(this,L)[L].destroy()},n.destroy=function(){var t,e,i,n,s=this;this.reset(!0),f(this,C)[C].destroy(),P.forEach(function(t){f(s,D)[D].removeEventListener(t,s.o)}),null==(t=f(this,U)[U])||t.removeEventListener(f(this,I)[I].AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.u,!1),null==(e=f(this,L)[L])||e.destroy(),null==(i=f(this,U)[U])||i.destroy(),f(this,F)[F]=!1,f(this,W)[W]=!1,f(this,G)[G]=!1,null==(n=f(this,z)[z])||n.disconnect()},n.isCustomPlaybackUsed=function(){return!1===f(this,I)[I].settings.getDisableCustomPlaybackForIOS10Plus()&&!f(this,_)[_].querySelector("video")},n.C=function(){window.clearTimeout(f(this,Y)[Y]),window.clearTimeout(f(this,X)[X]),f(this,Y)[Y]=void 0,f(this,X)[X]=void 0,f(this,x)[x]=void 0,f(this,Q)[Q]=void 0,f(this,K)[K]=void 0,f(this,_)[_].style.display="none",f(this,_)[_].classList.remove("nonlinear"),f(this,M)[M]&&this.R()},n.o=function(t){var e=this;if(f(this,C)[C].enabled||"volumechange"===t.type){if("timeupdate"===t.type){if(f(this,M)[M]){var i=f(this,M)[M].getCuePoints().filter(function(t){return t>=0&&t<f(e,C)[C].currentTime}).pop();this.A(i)}!f(this,F)[F]&&f(this,G)[G]&&f(this,D)[D].currentTime>=.5&&(this.dispatchEvent(new A(R.MEDIA_IMPRESSION)),f(this,F)[F]=!0)}if("play"!==t.type||f(this,G)[G]||f(this,H)[H]||(this.dispatchEvent(new A(R.MEDIA_START)),f(this,G)[G]=!0),"ended"===t.type&&(this.isCustomPlaybackUsed()&&f(this,D)[D].currentTime===f(this,D)[D].duration&&f(this,q)[q].indexOf(-1)>-1&&(f(this,D)[D].currentTime=f(this,D)[D].duration-1e-5,f(this,W)[W]=!0),f(this,U)[U].contentComplete(),f(this,M)[M]||this.T()),!window.ResizeObserver&&f(this,B)[B].autoResize&&"loadedmetadata"===t.type){var n=f(this,D)[D],s=n.offsetHeight,r=n.offsetWidth;f(this,j)[j]=r,f(this,N)[N]=s,this.R()}f(this,H)[H]&&"volumechange"!==t.type||this.dispatchEvent(new A(t.type))}},n.S=function(t){var e=this,i=f(this,I)[I].AdEvent;switch(t.type){case i.Type.LOADED:var n=t.getAd();f(this,$)[$]&&0===f(this,q)[q].length?f(this,$)[$]({ad:n,start:function(){e.M(),f(e,$)[$]=void 0},startWithoutReset:function(){e.M()}}):f(this,V)[V]=n;break;case i.Type.AD_BREAK_READY:this.C(),f(this,$)[$]?(f(this,$)[$]({ad:f(this,V)[V],adBreakTime:t.getAdData().adBreakTime,start:function(){e.M(),f(e,$)[$]=void 0},startWithoutReset:function(){e.M()}}),f(this,V)[V]=void 0):this.M();break;case i.Type.STARTED:var s=f(this,x)[x]=t.getAd();s.getAdPodInfo().getAdPosition()>1&&f(this,M)[M].setVolume(f(this,M)[M].getVolume()),f(this,_)[_].classList.remove("nonlinear"),this.R(),s.isLinear()?(f(this,C)[C].disable(),f(this,K)[K]=s.getDuration(),f(this,Q)[Q]=0):(f(this,_)[_].classList.add("nonlinear"),this.I()),f(this,_)[_].style.display="",f(this,Z)[Z]&&(f(this,Z)[Z]=!1,f(this,M)[M].pause());break;case i.Type.ALL_ADS_COMPLETED:if(f(this,W)[W])return;this.isCustomPlaybackUsed()&&Boolean(f(this,x)[x])&&-1!==f(this,x)[x].getAdPodInfo().getTimeOffset()&&this.I(),this.reset();break;case i.Type.CONTENT_PAUSE_REQUESTED:this.C(),f(this,x)[x]=t.getAd(),f(this,_)[_].style.display="",f(this,D)[D].pause(),this.R(),f(this,x)[x]&&this.A(f(this,x)[x].getAdPodInfo().getTimeOffset()),f(this,M)[M].setVolume(f(this,D)[D].muted?0:f(this,D)[D].volume),f(this,C)[C].disable(),f(this,K)[K]=f(this,x)[x].getDuration(),f(this,Q)[Q]=0;break;case i.Type.CONTENT_RESUME_REQUESTED:var r=Boolean(f(this,x)[x]);if(r){var o=f(this,M)[M].getVolume();f(this,D)[D].muted=0===o,f(this,D)[D].volume=f(this,J)[J]}f(this,W)[W]&&(f(this,D)[D].currentTime=f(this,D)[D].duration+1,f(this,W)[W]=!1),f(this,D)[D].ended?(this.reset(),this.T()):this.C(),r&&(f(this,Z)[Z]=!1,this.I());break;case i.Type.AD_METADATA:this.g(f(this,M)[M].getCuePoints()),-1===f(this,q)[q].indexOf(0)&&(f(this,$)[$]?f(this,$)[$]({start:function(){e.I(),f(e,$)[$]=void 0},startWithoutReset:function(){e.I()}}):this.I());break;case i.Type.AD_PROGRESS:var a=t.getAdData();f(this,Q)[Q]=a.currentTime,f(this,K)[K]=a.duration;break;case i.Type.LOG:var d=t.getAdData();f(this,$)[$]?f(this,$)[$]({start:function(){e.I(),f(e,$)[$]=void 0},startWithoutReset:function(){e.I()}}):d.adError&&!f(this,x)[x]&&this.I();break;case i.Type.VOLUME_CHANGED:var h=f(this,M)[M].getVolume();h>0&&(f(this,J)[J]=h)}},n.l=function(t){this.j(this.B(t))},n.u=function(t){var e=this,i=f(this,I)[I],n=i.AdEvent,s=i.AdErrorEvent.Type.AD_ERROR;window.clearTimeout(f(this,Y)[Y]);var r=f(this,M)[M]=t.getAdsManager(f(this,C)[C],f(this,k)[k]);Object.keys(n.Type).forEach(function(t){r.addEventListener(n.Type[t],function(i){if(e.S(i),R[t]){var n=["LOG","AD_PROGRESS"].indexOf(t)>-1;e.dispatchEvent(new A(R[t],{detail:{ad:i.getAd()||f(e,x)[x],adData:n?i.getAdData():{}}}))}})}),r.addEventListener(s,function(t){return e.j(e.B(t))});try{var o;r.init(f(this,j)[j],f(this,N)[N],this.k()),r.setVolume(f(this,D)[D].muted?0:f(this,D)[D].volume),null==(o=f(this,L)[L])||o.initialize(),f(this,$)[$]||this.M()}catch(a){this.j(new S(a.message))}},n.M=function(){if(f(this,G)[G]||(this.dispatchEvent(new A(R.MEDIA_START)),f(this,G)[G]=!0),f(this,M)[M])try{f(this,M)[M].start()}catch(t){this.j(new S(t.message))}else this.I()},n.T=function(){var t=this;setTimeout(function(){f(t,F)[F]=!1,f(t,G)[G]=!1,f(t,W)[W]=!1,t.dispatchEvent(new A(R.MEDIA_STOP))},1)},n.v=function(t){for(var e,i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,e){if(t){if("string"==typeof t)return u(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?u(t,e):void 0}}(t))){e&&(t=e);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t);!(e=i()).done;){var n=e.value;n.contentBoxSize&&1===n.contentBoxSize.length?(f(this,j)[j]=n.contentBoxSize[0].inlineSize,f(this,N)[N]=n.contentBoxSize[0].blockSize):n.contentBoxSize&&n.contentBoxSize.inlineSize?(f(this,j)[j]=n.contentBoxSize.inlineSize,f(this,N)[N]=n.contentBoxSize.blockSize):(f(this,j)[j]=n.contentRect.width,f(this,N)[N]=n.contentRect.height)}this.R()},n.R=function(){if(f(this,B)[B].autoResize&&f(this,M)[M]){var t=f(this,x)[x],e=this.k();t&&!t.isLinear()?t&&(t.getWidth()>f(this,j)[j]||t.getHeight()>f(this,N)[N]?this.resizeAd(f(this,j)[j],f(this,N)[N]):(f(this,M)[M].resize(t.getWidth(),t.getHeight()+20,e),f(this,_)[_].style.width=t.getWidth()+"px",f(this,_)[_].style.height=t.getHeight()+20+"px")):this.resizeAd(f(this,j)[j],f(this,N)[N])}},n.k=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||f(this,D)[D].webkitDisplayingFullscreen?f(this,I)[I].ViewMode.FULLSCREEN:f(this,I)[I].ViewMode.NORMAL},n.I=function(){var t=this;f(this,_)[_].style.display="none",f(this,D)[D].ended||(f(this,C)[C].enable(),f(this,Z)[Z]?(f(this,D)[D].pause(),this.dispatchEvent(new A("pause"))):(this.p().then(function(){}).catch(function(){t.dispatchEvent(new A("pause"))}),this.dispatchEvent(new A("play")),this.dispatchEvent(new A(R.MEDIA_RESUMED))),f(this,Z)[Z]=!1)},n.B=function(t){var e=t.getError(),i=new S(e.getMessage());return i.type=e.getType(),i.errorCode=e.getErrorCode(),i.vastErrorCode=e.getVastErrorCode&&e.getVastErrorCode(),i.innerError=e.getInnerError(),i},n.j=function(t){var e=this;this.dispatchEvent(new A(R.AD_ERROR,{detail:{error:t}})),this.C(),f(this,$)[$]?f(this,$)[$]({start:function(){e.I(),f(e,$)[$]=void 0},startWithoutReset:function(){e.I()}}):this.I()},i(e,[{key:"volume",get:function(){return!f(this,C)[C].enabled&&f(this,M)[M]?f(this,M)[M].getVolume():f(this,D)[D].volume},set:function(t){!f(this,C)[C].enabled&&f(this,M)[M]&&f(this,M)[M].setVolume(t),f(this,D)[D].volume=t}},{key:"muted",get:function(){return!f(this,C)[C].enabled&&f(this,M)[M]?0===f(this,M)[M].getVolume():f(this,D)[D].muted},set:function(t){!f(this,C)[C].enabled&&f(this,M)[M]&&f(this,M)[M].setVolume(t?0:f(this,J)[J]),f(this,D)[D].muted=t}},{key:"currentTime",get:function(){return void 0!==f(this,Q)[Q]?f(this,Q)[Q]:f(this,D)[D].currentTime},set:function(t){f(this,C)[C].enabled&&(f(this,D)[D].currentTime=t)}},{key:"duration",get:function(){return void 0!==f(this,K)[K]?f(this,K)[K]:f(this,D)[D].duration}},{key:"cuePoints",get:function(){return[].concat(f(this,q)[q])}}]),e}(w);function it(i){return n=>{return s=null,r=null,o=function*(){const{template:s,constructor:r}=n,{createElement:o,setStyles:a}=r.utils,{$video:d,$player:h}=s;yield function(){var i=window;return i.google&&i.google.ima?Promise.resolve(i.google.ima):t||((t=new Promise(function(t,e){var i=document.createElement("script");i.async=!0,i.src="https://imasdk.googleapis.com/js/sdkloader/ima3.js",i.onload=t,i.onerror=e,document.body.appendChild(i)}).then(function(){return i.google.ima})).then(e).catch(e),t)}();const u=window.google.ima,l=new u.AdsRenderingSettings;l.restoreCustomPlaybackStateOnAdBreakComplete=!0,l.enablePreloading=!0;const c=new T;let f=!1,v=null,p=null;function y(){return v||(p=function(){const t=o("div"),e=`art-vast-${Date.now()}`;return t.id=e,a(t,{position:"absolute",inset:"0",width:"100%",height:"100%",zIndex:"150",backgroundColor:"black",display:"none",pointerEvents:"auto"}),t}(),h.appendChild(p),v=new et(u,d,p,l,c),v.addEventListener("AdContentPauseRequested",()=>{f=!0,p.style.display="block"}),v.addEventListener("AdContentResumeRequested",()=>{f=!1,p.style.display="none"}),v.addEventListener("AdStarted",()=>{f=!0,p.style.display="block"}),v.addEventListener("AdError",t=>{console.error("VAST Ad Error:",t.detail),f=!1,p.style.display="none"}),v)}return"function"===typeof i&&(yield i({art:n,playUrl:function(t,e={}){if(f)return;v||y();const i=new u.AdsRequest;i.adTagUrl=t;for(const n in e)i[n]=e[n];v.playAds(i)},playRes:function(t,e={}){if(f)return;v||y();const i=new u.AdsRequest;i.adsResponse=t;for(const n in e)i[n]=e[n];v.playAds(i)},init:y,ima:u,adsRenderingSettings:l,playerOptions:c,get imaPlayer(){return v},get container(){return p}})),{name:"artplayerPluginVast",destroy:function(){(null==v?void 0:v.destroy)&&v.destroy(),(null==p?void 0:p.parentNode)&&p.parentNode.removeChild(p),p=null,v=null}}},new Promise((t,e)=>{var i=t=>{try{a(o.next(t))}catch(i){e(i)}},n=t=>{try{a(o.throw(t))}catch(i){e(i)}},a=e=>e.done?t(e.value):Promise.resolve(e.value).then(i,n);a((o=o.apply(s,r)).next())});var s,r,o}}return"undefined"!==typeof window&&(window.artplayerPluginVast=it),it});