@flowplayer/player 3.41.0 → 3.43.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/plugins/ovp.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.ovp=t())}(this,function(){"use strict";function e(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}const t=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),o=(...e)=>e.reduce((e,n)=>t(n)?(Object.keys(n).forEach(r=>{if(t(e[r])&&t(n[r]))return e[r]=o(e[r],n[r]);e[r]=n[r]}),e):e,{}),n="is-starting",r="is-source-processing",a="flowplayer:error";class Pipe{static of(e){return new Pipe(e)}static maybe(e,t,...o){return null==e?e:t.apply(e,[e,...o])}constructor(e){this.data=e}tap(e,...t){return e.apply(this,[this.data,...t]),new Pipe(this.data)}fmap(e,...t){const o=e.apply(this,[this.data,...t]);return new Pipe(o)}unwrap(){return this.data}}const i=window,s=i._flowplayerTimekeeper||(i._flowplayerTimekeeper={});function c(e){return fetch(e).then(e=>e.json())}function l(...e){let t=[].join.call(e,"/");return"/"!==t[0]&&(t="/"+t),d()+"/web/public/native/config"+t}const d=()=>"https://ljsp.lwcdn.com";function u(e){(async function(){const e=s.cachedServerOffset;if(e)return e;const t=s.pendingRequest||(s.pendingRequest=fetch("https://ljsp.lwcdn.com/web/public/countdown/time.json")),o=await t,n=parseInt(o.headers.get("age")||"0"),r=await o.json(),a=Date.now()-r.millisUtc-1e3*n;return s.cachedServerOffset=a,s.cachedServerOffset})().then(t=>Object.assign(e,{server_time_offset:t}))}function p(e,t){var n,r;t="object"==typeof t?t:{};const a={title:null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.title,description:null===(r=null==e?void 0:e.metadata)||void 0===r?void 0:r.description},i={ima:{parameters:function({media_id:e,duration:t,title:o,tags:n,category_name:r,ad_keywords:a}){return{ad_keywords:a||"",media_id:e||"",category:r||"",media_name:o||"",media_tags:n||"",media_duration:t||-1}}((null==e?void 0:e.metadata)||{})}},s=t.embed||{};return delete s.src,o(i,a,e,(delete(c=t).src,delete c.metadata,delete c.title,delete c.description,delete c.duration,delete c.poster,c),s);var c}const m=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,f=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,y=/^[A-Za-z0-9]{8}$/,v=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/[A-Za-z0-9]{8}$/;function w(e){return"object"==typeof e&&"ovp/base64"==e.type}function h(e,t){return function(e,t){return!(!m.test(e)&&!f.test(e)||(t.type="video/ovp",0))}(e,t)||function(e,t){return!(!y.test(e)&&!v.test(e)||(t&&(t.type="video/ovp"),0))}(e,t)||w(t)}function k(e){try{return function(e){return null===e?{}:JSON.parse(e)}(decodeURIComponent(atob(e).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join("")))}catch(e){return{err:e.message}}}function b(e){const t=e.split(/[^0-9]/).map(e=>parseInt(e,10));return Date.UTC(t[0],t[1]-1,t[2],t[3],t[4],t[5])}function P(e){var t;return null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.live_start_time}const g="ovp:request:start",E="ovp:request:media:complete",C="ovp:request:playlist:complete",_="ovp:live:countdown:tick",A="ovp:live:countdown:start",N="ovp:live:countdown:complete",M="ovp:media:changed",S="ovp:message:realtime",O="ovp:config:finalized";var D=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:g,OVP_MEDIA_REQUEST_COMPLETE:E,OVP_PLAYLIST_REQUEST_COMPLETE:C,LIVE_COUNTDOWN_TICK:_,LIVE_COUNTDOWN_START:A,LIVE_COUNTDOWN_COMPLETE:N,OVP_MEDIA_CHANGED:M,OVP_REALTIME_MESSAGE:S,OVP_CONFIG_FINALIZED:O});const T={Unknown:"00-00",MediaUnknown:"01-00",MediaUnavailable:"01-01",MediaUnsupportedVideoFormat:"01-02",MediaUnsupportedAudioFormat:"01-03",MediaBitrateExceeded:"01-04",MediaBufferOverread:"01-05",MediaIntegerOverflow:"01-06",MediaQuotaExceeded:"01-07",MediaInvalidCompositionDuration:"01-08",MediaInvalidCompositionSourceDuration:"01-09",MediaInvalidCompositionSourceStartTime:"01-10",MediaMalformedDepth:"01-11",PlaybackUnknown:"02-00",PlaybackVideoBufferUnderRun:"02-01",PlaybackAudioBufferUnderRun:"02-02",PlaybackVideoBufferingTimeout:"02-03",PlaybackAudioBufferingTimeout:"02-04",PlaybackManifestParseError:"02-05",PlaybackVideoDecodeError:"02-06",PlaybackAudioDecodeError:"02-07",PlaybackDroppedFramesExceeded:"02-08",PlaybackPlayheadExceedsDuration:"02-09",PlaybackUnsupportedDevice:"02-10",PlaybackManifestLoadError:"02-11",PlaybackManifestLoadTimeout:"02-12",PlaybackManifestParsingError:"02-13",PlaybackManifestIncompatibleCodecs:"02-14",PlaybackLevelEmptyError:"02-15",PlaybackLevelLoadError:"02-16",PlaybackLevelLoadTimeout:"02-17",PlaybackLevelSwitchError:"02-18",PlaybackAudioTrackLoadError:"02-19",PlaybackAudioTrackLoadTimeout:"02-20",PlaybackFragLoadError:"02-21",PlaybackFragLoadTimeout:"02-22",PlaybackFragDecryptError:"02-23",PlaybackFragParsingError:"02-24",PlaybackFragGap:"02-25",PlaybackRemuxAllocError:"02-26",PlaybackBufferAddCodecError:"02-27",PlaybackBufferIncompatibleCodecs:"02-28",PlaybackBufferAppendError:"02-29",PlaybackBufferStalledError:"02-30",PlaybackBufferFullError:"02-31",PlaybackBufferSeekOverHole:"02-32",PlaybackBufferNudgeOnStall:"02-33",PlaybackInternalException:"02-34",PlaybackInternalAborted:"02-35",PlaybackManifestLoaderFailure:"02-36",PlaybackSegmentBaseLoaderError:"02-37",PlaybackTimeSyncFailed:"02-38",PlaybackFragmentLoaderFailure:"02-39",PlaybackAppendError:"02-40",PlaybackRemoveError:"02-41",PlaybackDataUpdateFailed:"02-42",PlaybackManifestNoStreams:"02-43",PlaybackUnknownManifestType:"02-44",PlaybackDashInsufficientSegmentInfo:"02-45",PlaybackDashNoRepresentations:"02-46",PlaybackDashNoAdaptationSets:"02-47",PlaybackDashNoInitSegment:"02-48",PlaybackDashUnsupportedContainerFormat:"02-49",PlaybackDashKeySystemMismatch:"02-50",PlaybackMultipleKeyIDs:"02-51",PlaybackDashConflictingKeyIDs:"02-52",PlaybackRestrictedStreams:"02-53",PlaybackHlsMasterAndMediaTags:"02-54",PlaybackRepresentationIdConflict:"02-55",PlaybackHlsUnsupportedKeyFormats:"02-56",PlaybackManifestNoVariants:"02-57",PlaybackHlsUndeclaredVariables:"02-58",PlaybackAes128InvalidKeyLength:"02-59",PlaybackDashConflictingAes128Keys:"02-60",PlaybackDashUnsupportedAes128Encryption:"02-61",PlaybackManifestPatchMismatch:"02-62",PlaybackEmptyMediaPlaylist:"02-63",PlaybackNonContiguousCompositionTrack:"02-64",PlaybackDecoderNotFound:"02-65",PlaybackDecoderTemporarilyUnavailable:"02-66",PlaybackIncompatibleAsset:"02-67",PlaybackNoCompatibleExternalDisplay:"02-69",PlaybackOutOfMemory:"02-70",PlaybackToneMappingFailed:"02-71",PlaybackVideoCompositorFailed:"02-72",NetworkUnknown:"03-00",NetworkNoInternet:"03-01",NetworkRequestTimeout:"03-02",NetworkUnableToResolveHost:"03-03",NetworkResourceNotFound:"03-04",NetworkExpiredUrl:"03-05",NetworkUrlResolutionFailed:"03-06",NetworkDownloadErrorIdManifest:"03-07",NetworkDownloadErrorIdSidx:"03-08",NetworkDownloadErrorIdContent:"03-09",NetworkDownloadErrorIdInitialization:"03-10",NetworkDownloadErrorIdXlink:"03-11",NetworkHttpRequestFailed:"03-12",NetworkMaxRetriesExceeded:"03-13",NetworkSegmentMissing:"03-14",NetworkHttp400BadRequest:"03-400",NetworkHttp401Unauthorized:"03-401",NetworkHttp402PaymentRequired:"03-402",NetworkHttp403Forbidden:"03-403",NetworkHttp404NotFound:"03-404",NetworkHttp405MethodNotAllowed:"03-405",NetworkHttp406NotAcceptable:"03-406",NetworkHttp407ProxyAuthenticationRequired:"03-407",NetworkHttp408RequestTimeout:"03-408",NetworkHttp409Conflict:"03-409",NetworkHttp410Gone:"03-410",NetworkHttp411LengthRequired:"03-411",NetworkHttp412PreconditionFailed:"03-412",NetworkHttp413PayloadTooLarge:"03-413",NetworkHttp414URITooLong:"03-414",NetworkHttp415UnsupportedMediaType:"03-415",NetworkHttp416RangeNotSatisfiable:"03-416",NetworkHttp417ExpectationFailed:"03-417",NetworkHttp418ImATeapot:"03-418",NetworkHttp421MisdirectedRequest:"03-421",NetworkHttp422UnprocessableEntity:"03-422",NetworkHttp423Locked:"03-423",NetworkHttp424FailedDependency:"03-424",NetworkHttp425TooEarly:"03-425",NetworkHttp426UpgradeRequired:"03-426",NetworkHttp428PreconditionRequired:"03-428",NetworkHttp429TooManyRequests:"03-429",NetworkHttp431RequestHeaderFieldsTooLarge:"03-431",NetworkHttp451UnavailableForLegalReasons:"03-451",NetworkHttp500InternalServerError:"03-500",NetworkHttp501NotImplemented:"03-501",NetworkHttp502BadGateway:"03-502",NetworkHttp503ServiceUnavailable:"03-503",NetworkHttp504GatewayTimeout:"03-504",NetworkHttp505HTTPVersionNotSupported:"03-505",NetworkHttp506VariantAlsoNegotiates:"03-506",NetworkHttp507InsufficientStorage:"03-507",NetworkHttp508LoopDetected:"03-508",NetworkHttp510NotExtended:"03-510",NetworkHttp511NetworkAuthenticationRequired:"03-511",ContentProtectionUnknown:"04-00",ContentProtectionConcurrentStreamLimitExceeded:"04-01",ContentProtectionEntitlementRefused:"04-02",ContentProtectionLicenseExpired:"04-03",ContentProtectionBadLicenseRequest:"04-04",ContentProtectionLicenseServerTimeout:"04-05",ContentProtectionInsufficientHDCPSupport:"04-06",ContentProtectionGeoRestricted:"04-07",ContentProtectionParentalControlRestricted:"04-08",ContentProtectionCDNUnauthorized:"04-09",ContentProtectionInvalidAccessToken:"04-10",ContentProtectionKeySystemNoKeys:"04-11",ContentProtectionKeySystemNoAccess:"04-12",ContentProtectionKeySystemNoSession:"04-13",ContentProtectionKeySystemNoConfiguredLicense:"04-14",ContentProtectionKeySystemCertificateRequestFailed:"04-15",ContentProtectionKeySystemCertificateUpdateFailed:"04-16",ContentProtectionKeySystemSessionUpdateFailed:"04-17",ContentProtectionKeySystemStatusOutputRestricted:"04-18",ContentProtectionKeySystemStatusInternalError:"04-19",ContentProtectionKeyLoadError:"04-20",ContentProtectionKeyLoadTimeout:"04-21",ContentProtectionCapabilityMediaKeysError:"04-22",ContentProtectionManifestKeySystemUnknown:"04-23",ContentProtectionKeySystemUnavailable:"04-24",ContentProtectionCDMCreationFailed:"04-25",ContentProtectionCDMAttachFailed:"04-26",ContentProtectionCDMServerCertificateRejected:"04-27",ContentProtectionCDMSessionCreationFailed:"04-28",ContentProtectionCDMLicenseRequestFailed:"04-29",ContentProtectionCDMLicenseResponseRejected:"04-30",ContentProtectionManifestMissingDRMInfo:"04-31",ContentProtectionLicenseServerMissing:"04-32",ContentProtectionOfflineSessionRemoved:"04-33",ContentProtectionInitDataTransformationError:"04-34",ContentProtectionServerCertificateRequestFailed:"04-35",ContentProtectionInsufficientHDCPVersion:"04-36",ContentProtectionHDCPVersionCheckFailed:"04-37",AdsUnknown:"08-00",AdsVastParseError:"08-100",AdsInvalidVastSchema:"08-101",AdsVastVersionNotSupported:"08-102",AdsUnexpectedAdType:"08-200",AdsCreativeLinearityMismatch:"08-201",AdsCreativeDurationMismatch:"08-202",AdsCreativeSizeMismatch:"08-203",AdsWrapperVastError:"08-300",AdsVastResponseRedirectTimeout:"08-301",AdsWrapperLimitReached:"08-302",AdsVastResponseEmpty:"08-303",AdsLinearAdDisplayError:"08-400",AdsMediaFileNotFound:"08-401",AdsMediaFileUnavailable:"08-402",AdsUnsupportedMimeType:"08-403",AdsUnableToDisplayMediaFile:"08-405",AdsMezzanineFileMissing:"08-406",AdsMezzanineFileDownloaded:"08-407",AdsRejectedAd:"08-408",AdsInteractiveCreativeError:"08-409",AdsVerificationNodeExecutionError:"08-410",AdsNonLinearAdDisplayError:"08-500",AdsNonLinearAdSizeMismatch:"08-501",AdsNonLinearAdFetchError:"08-502",AdsNonLinearUnsupportedType:"08-503",AdsCompanionAdDisplayError:"08-600",AdsCompanionAdSizeMismatch:"08-601",AdsRequiredCompanionAdError:"08-602",AdsCompanionAdFetchError:"08-603",AdsUndefinedVastError:"08-900",AdsUnknownVpaidError:"08-901",AdsVastDocumentEmpty:"08-999"},L=Object.fromEntries(Object.entries(T).map(([e,t])=>[t,e]));const F=[1e7]+""+-1e3+-4e3+-8e3+-1e11,R="off";class FlowplayerError extends Error{static getErrorKey(e){return e in L?L[e]:L["00-00"]}constructor(e,t,o={}){super(e),this.message=e,this.flowplayerErrorCode=t,this.config=o,this.id="undefined"==typeof crypto?"":F.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)),this.isFatal=!!o.isFatal,this.errorKey=FlowplayerError.getErrorKey(this.flowplayerErrorCode)||"unknown"}toJSON(){return{message:this.message,flowplayer_error_code:this.flowplayerErrorCode,id:this.id,root_error_id:this.config.rootErrorId,resource:this.config.resource,is_fatal:this.isFatal,is_retry:!!this.config.isRetry}}}function I(e,t){const o=null==t?void 0:t.src;if(w(t))return function(e,t){const o=k(t.src||"");if(function(e){return"string"==typeof e.err}(o))return console.error(o.err);H(e,o)}(e,t);if(!o)return;e.setState(r,!0);const n=function(e){return~e.indexOf("/")?e:"/media/"+e}(o),i=l(n);fetch(i).then(async t=>t.ok?H(e,await t.json()):function(e,t,o,n){e.setState(r,!1);const i=new FlowplayerError(n.message||"error loading ovp source",function(e){const t=`03-${e}`;return t in L?t:T.NetworkUnknown}(o),{resource:t,isFatal:!0,retryOpts:{retry:R}});e.emit(a,{error:i})}(e,t.url,t.status,await t.json()))}function H(e,t){return delete t.live,e.emit(M,t),function(e){return Array.isArray(e.playlist)}(t)?function(e,t){e.emit(C,function(e,t){"number"!=typeof t.delay&&"number"!=typeof e.delay&&(t.delay=5);const n=Object.assign({},e),r=(null==e?void 0:e.playlist)||{},a=o(t,r),i=((null==a?void 0:a.playlist)||[]).map(e=>{t.ima&&Object.assign(e,{ima:t.ima});const o=p(e,n);return delete o.playlist,o});return delete a.ima,Object.assign(a,{playlist:i})}(e.opts,t))}(e,t):P(t)?function(e,t){var o,n;const r=(null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.live_start_time)||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.starttime);r&&(t.live_start_time=Pipe.of(r).fmap(b).unwrap());e.emit(A,Pipe.of(t).fmap(p,e.opts).unwrap())}(e,t):function(e,t){e.emit(E,Pipe.of(t).fmap(p,e.opts).unwrap())}(e,t)}const U={};function j(e,t,o){"object"!=typeof U[t]&&(U[t]=o);const n=e.opts,r=(null==n?void 0:n.metadata)||{};r.player_id=t,n.metadata=r,o.title&&delete o.title,o.description&&delete o.description;const a=Object.assign(n,o);e.setOpts(a),o.autoplay&&e.togglePlay(!0)}const x="recommendationsready";let V=!1;function K(e,t,o){q()||Pipe.of("recommendation").fmap(l,t,o).fmap(c).fmap(t=>t.then(t=>function(e,t){const o=t.playlist,n=e.opts;if(n.recommendations=o,!o.length)return;e.emit(x,{playlist:o.map(function(e){var t,o;return{poster:e.poster,src:e.src,title:null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.title,description:null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.description,metadata:e.metadata||{},chapters:e.chapters,thumbnails:e.thumbnails,subtitles:e.subtitles}})})}(e,t)).catch(B))}function q(){return V}function B(e){V=!0,console.error("Failed to load recommendations: %j",e)}function z(e){const t="number"==typeof e?e:parseInt(e,10);return(t>9?"":"0")+t}function W(e,t){const o=e._customElements.get(t);return o&&e.root.querySelector(o)||void 0}const G="flowplayer-live-countdown";function $(e){const t=Date.now()-(e.server_time_offset||0);return Math.floor(((e.live_start_time||0)-t)/1e3)}function Q(e,t){let o=0;function a(){const a=$(t);if(a<0||isNaN(a)||0===e.reaper||void 0===t.live_start_time)return clearInterval(o),function(e,t,o){e.emit(N);const n=W(e,G);if(n&&n.remove(),e.root.classList.remove("is-livecountdown"),o)return e.setState(r,!1);e.emit(E,t)}(e,t,void 0===t.live_start_time);var i,s,c;i=e,s=e.root,c=a,s.classList.add("is-livecountdown"),i.emit(_,{remaining_time:Z(c+1)}),i.hasState(n)||i.setState(n,!0)}u(t),a(),o=setInterval(a,250)}function Z(e){const t=function(e){"number"!=typeof e&&(e=parseInt(e,10)),e=Math.round(e);const t=Math.floor(e/86400);e-=86400*t;const o=Math.floor(e/3600);e-=3600*o;const n=Math.floor(e/60);return{days:t,hours:o,minutes:n,seconds:e-=60*n}}(e);let o="";return t.days&&(o+=t.days+":"),o+z(t.hours)+":"+z(t.minutes)+":"+z(t.seconds)}class WebsocketBridge{static of(e){return new WebsocketBridge(e)}constructor(e){this.manualDisconnect=!1,this.video=e,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}connect(e){this.client=new WebSocket("wss://player.ws.flowplayer.com?mediaId="+e),this.current_media_id=e,this.wireup()}onClose(){this.manualDisconnect?this.manualDisconnect=!1:this.current_media_id&&this.reconnect(this.current_media_id)}onMessage(e){JSON.parse(e.data).forEach(e=>{this.video.emit(S,e)})}reconnect(e){this.cleanup(),this.connect(e)}wireup(){this.client&&(this.client.addEventListener("message",this.onMessage),this.client.addEventListener("close",this.onClose))}cleanup(){this.client&&(this.client.removeEventListener("message",this.onMessage),this.client.removeEventListener("close",this.onClose),this.client=void 0)}disconnect(){this.client&&(this.manualDisconnect=!0,this.client.close())}}const J=(e,t)=>new(((e,t)=>{const o=e.get(t);if(!o)throw new Error(`no flowplayer component with the name ${t} exists`);const n=window.customElements.get(t);if(!n)throw new Error(`no default flowplayer component with the name ${t} exists`);const r=window.customElements.get(o);return"function"!=typeof r?n:r})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerLiveCountdown extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-livecountdown");const t=function(...e){const t=document.createElement("div");return 0==e.length||t.classList.add(...e),t}("fp-inner");this.append(t);const o=document.createElement("p");o.innerText=e.i18n("ovp.starting_in"),t.append(o);const n=document.createElement("p");n.classList.add("fp-countdown"),t.append(n),e.on(_,t=>{const o=t.detail.remaining_time;e.root.classList.add("is-livecountdown"),n.innerText=o})}}const X=["Expired token","No token provided in configuration","Invalid token provided","Domain not allowed"];function Y({root:e,video:t,data:o}){t&&t.destroy(),console.error(new Error(o.details||o.reason)),e.innerHTML="",e.classList.remove("flowplayer"),e.classList.add("flowplayer-fatal"),e.style.removeProperty("background-image");const n=!!(r=o.details)&&X.some(e=>r.includes(e));var r;const a=document.createElement("h2");a.textContent=n?"No Valid Token":"Playback Error";const i=document.createElement("p");i.textContent="Are you the site owner?";const s=document.createElement("a");s.classList.add("troubleshoot"),s.target="_blank",n?(s.href="https://share.hsforms.com/1HcZVhTHPSCmbyzp7DQ1oyw4wws",s.textContent="Get Trial Token (Beta)"):(s.href="https://docs.flowplayer.com/troubleshooting/player#"+o.reason,s.textContent="Troubleshoot?");const c=document.createElement("img");c.src="https://flowplayer.com/user/pages/images/logo-white.png",c.alt="Flowplayer Logo",e.append(a,i,s,c)}const ee=["*.lwcdn.com","*.flowplayer.com","*.wowza.com"];function te(){try{return window.location.hostname!==window.parent.location.hostname?function(e){const t=document.createElement("a");return t.href=e,t}(document.referrer).hostname:document.location.hostname}catch(e){return window.location.hostname}}function oe(e){const t=document.createElement("a");t.href=e;const o=t.pathname&&t.pathname.split(".");return o.length>1&&o[o.length-1]}function ne(e){switch(e){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return e}}const re=t=>{var{src:o}=t,n=e(t,["src"]);return[Object.assign({src:o,type:o?ne("video/"+oe(o)):""},n)]};function ae(e){return re({src:e})}function ie(t){var{src:o,type:n}=t,r=e(t,["src","type"]);return o&&n?[Object.assign({src:o,type:n},r)]:n&&!o?[Object.assign({type:n},r)]:re(Object.assign({src:o},r))}const se=1;var ce,le;function de(e){const t=[];e.on("health:ready",()=>{const o=e.opt("metadata.stream_target_id");o&&!t.includes(o)&&(t.push(o),function(e,{feature_name:t,behavior:o,sample_rate:n}){t&&(n||(n=se),e.emit("flowplayer:feature",{feature_name:t,behavior:o,sample_rate:n}))}(e,{feature_name:"ewv",behavior:"used"}))})}!function(e){e[e.Err=0]="Err",e[e.Ok=1]="Ok"}(ce||(ce={}));const ue=((le=class OVP{constructor(e){((e,t,o)=>{window.customElements.get(t)||window.customElements.define(t,o),e.customElements.get(t)||e.customElements.set(t,t)})(e,G,FlowplayerLiveCountdown)}onload(e,t,o,n){if("string"==typeof(null==n?void 0:n.src))return"string"!=typeof e.player_id||0===n.src.indexOf(e.player_id)||w(n)||(n.src=[e.player_id,n.src].join("/")),I(o,n)}wants(e,t,o){return h(e,t)}init(t,n,a){const i=new WebsocketBridge(a);let s=Object.assign({},t);const d=function(e){if(!s)return e;t.autoplay!==s.autoplay&&(s.autoplay=t.autoplay),delete s.src;const n=o(e,s);return a.emit(O,n),n};a.on("src",()=>{(a.currentSrc||a.root.classList.contains("is-livecountdown"))&&(s=!1)}),a.on(g,function(){a.setState("is-waiting",!0),t.recommendations&&(t.recommendations=!1)}),a.on(M,function({data:e}){var t,o;const n=null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.media_id;(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.live_start_time)&&n&&(i.disconnect(),i.connect(n))}),a.on(S,function({data:e}){var o;const n=null==e?void 0:e.event,r=null==e?void 0:e.value,i=a.opt("metadata",{live_start_time:""});switch(n){case"METADATA":{const e=Object.assign(i,r),n=Object.assign(t,{metadata:e});(null===(o=null==n?void 0:n.metadata)||void 0===o?void 0:o.live_start_time)&&(n.live_start_time=b(n.metadata.live_start_time)),a.setOpts(n);break}}}),a.on("beforeplay",function(e){const o=t;if(P(o)){if(pe(o))return;e.preventDefault()}}),a.on(E,function(e){const t=e.data;if(!t)return;var o;if(t.src&&(t.src=(o=t.src,"string"==typeof o?ae(o):Array.isArray(o)||"object"!=typeof o?o.reduce(function(e,t){return"string"==typeof t&&(t=ae(t)),"object"!=typeof t||Array.isArray(t)||(t=ie(t)),e.concat(t)},[]):ie(o)).map(e=>(e.src&&e.src.startsWith("//")&&(e.src="https:"+e.src),e))),0==a.reaper||"object"!=typeof t||$(t)>0)return;const n=d(t);a.setOpts(n),a.setAttrs(n),n.src&&a.setSrc(n.src),a.setState(r,!1)}),a.on("config",function({data:e}){var o,r;if("string"==typeof t.src&&h(t.src,{}))return;if((null==e?void 0:e.domains)&&(null==e?void 0:e.domains.length)&&!((e,t)=>{const o=e.split(".").reverse();return t.concat(ee).some(e=>{const t=e.split(".").reverse(),n="*"===t[t.length-1];return n&&t.pop(),(n||t.length===o.length)&&t.every((e,t)=>o[t]===e)})})(te(),e.domains))return Y({root:n,video:a,data:{details:`Hostname ${te()} is not allowed to load player ${null===(o=e.metadata)||void 0===o?void 0:o.player_id}.`,reason:"domain"}});if(t.src&&me(t.src))return;const i=null==e?void 0:e.brand_color;return i&&a.root.style.setProperty("--fp-brand-color","#"==i[0]?i:"#"+i),"string"==typeof t.player_id&&(null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.player_id)!==t.player_id?function(e,t){if("object"==typeof U[t])return console.debug("using Cache(%s)",t),j(e,t,U[t]);Pipe.of(t).fmap(l).fmap(c).fmap(o=>o.then(o=>j(e,t,o)).catch(console.error))}(a,t.player_id):void 0}),a.on(C,function(t){var o;const n=t.data;if(!n||0==a.reaper)return;const{playlist:i}=n,s=e(n,["playlist"]),c=d(Object.assign(s,{playlist:Object.assign({},s)}));Array.isArray(c.playlist)&&(c.playlist=s),delete c.loop,c.playlist.playlist_title||(c.playlist.playlist_title=null===(o=s.metadata)||void 0===o?void 0:o.playlist_title),a.setOpts(c),a.setAttrs(c);const l={type:"flowplayer/playlist",items:i};a.setSrc(l),a.setState(r,!1)}),a.on(A,function(e){const o=e.data;if(!o||0==a.reaper)return;const r=d(o);if(a.setOpts(r),a.setAttrs(r),$(o)<=0)return a.emit(E,o);W(a,G)||(n.appendChild(J(a,G)),Q(a,t))}),a.on("timeupdate",function(){var e,o,n;const r=t;P(r)?pe(r)||(a.togglePlay(!1),a.emit("ended")):t.recommendations&&(null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)&&(Array.isArray(t.recommendations)||a.currentTime/a.duration<.8||q()||(null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.media_id)&&(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.player_id)&&K(a,t.metadata.media_id,t.metadata.player_id))}),a.on("reap",function(){i.disconnect()}),de(a)}}).pluginName="ovp",le.events=D,le);function pe(e){var t,o;const n=null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.live_stop_time;if(!n)return!0;return!!(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.allow_after_stop_time)||b(n)>Date.now()}const me=e=>{var t;if(e&&Array.isArray(e))return"object"==typeof e[0]&&"ovp/base64"===(null===(t=e[0])||void 0===t?void 0:t.type)};return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const o=e.flowplayer;return"function"==typeof o?(o(t),t):(Array.isArray(o.extensions)||(o.extensions=[]),~o.extensions.indexOf(t)||o.extensions.push(t),t)}(window,ue)});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.ovp=t())}(this,function(){"use strict";function e(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}const t=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),o=(...e)=>e.reduce((e,n)=>t(n)?(Object.keys(n).forEach(r=>{if(t(e[r])&&t(n[r]))return e[r]=o(e[r],n[r]);e[r]=n[r]}),e):e,{}),n="is-starting",r="is-source-processing",a="flowplayer:error";class Pipe{static of(e){return new Pipe(e)}static maybe(e,t,...o){return null==e?e:t.apply(e,[e,...o])}constructor(e){this.data=e}tap(e,...t){return e.apply(this,[this.data,...t]),new Pipe(this.data)}fmap(e,...t){const o=e.apply(this,[this.data,...t]);return new Pipe(o)}unwrap(){return this.data}}const i=window,s=i._flowplayerTimekeeper||(i._flowplayerTimekeeper={});function c(e){return fetch(e).then(e=>e.json())}function l(...e){let t=[].join.call(e,"/");return"/"!==t[0]&&(t="/"+t),d()+"/web/public/native/config"+t}const d=()=>"https://ljsp.lwcdn.com";function u(e){(async function(){const e=s.cachedServerOffset;if(e)return e;const t=s.pendingRequest||(s.pendingRequest=fetch("https://ljsp.lwcdn.com/web/public/countdown/time.json")),o=await t,n=parseInt(o.headers.get("age")||"0"),r=await o.json(),a=Date.now()-r.millisUtc-1e3*n;return s.cachedServerOffset=a,s.cachedServerOffset})().then(t=>Object.assign(e,{server_time_offset:t}))}function p(e,t){var n,r;t="object"==typeof t?t:{};const a={title:null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.title,description:null===(r=null==e?void 0:e.metadata)||void 0===r?void 0:r.description},i={ima:{parameters:function({media_id:e,duration:t,title:o,tags:n,category_name:r,ad_keywords:a}){return{ad_keywords:a||"",media_id:e||"",category:r||"",media_name:o||"",media_tags:n||"",media_duration:t||-1}}((null==e?void 0:e.metadata)||{})}},s=t.embed||{};return delete s.src,o(i,a,e,(delete(c=t).src,delete c.metadata,delete c.title,delete c.description,delete c.duration,delete c.poster,c),s);var c}const m=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,f=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,y=/^[A-Za-z0-9]{8}$/,v=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/[A-Za-z0-9]{8}$/;function w(e){return"object"==typeof e&&"ovp/base64"==e.type}function h(e,t){return function(e,t){return!(!m.test(e)&&!f.test(e)||(t.type="video/ovp",0))}(e,t)||function(e,t){return!(!y.test(e)&&!v.test(e)||(t&&(t.type="video/ovp"),0))}(e,t)||w(t)}function k(e){try{return function(e){return null===e?{}:JSON.parse(e)}(decodeURIComponent(atob(e).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join("")))}catch(e){return{err:e.message}}}function b(e){const t=e.split(/[^0-9]/).map(e=>parseInt(e,10));return Date.UTC(t[0],t[1]-1,t[2],t[3],t[4],t[5])}function P(e){var t;return null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.live_start_time}const g="ovp:request:start",E="ovp:request:media:complete",C="ovp:request:playlist:complete",_="ovp:live:countdown:tick",A="ovp:live:countdown:start",N="ovp:live:countdown:complete",M="ovp:media:changed",S="ovp:message:realtime",O="ovp:config:finalized";var D=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:g,OVP_MEDIA_REQUEST_COMPLETE:E,OVP_PLAYLIST_REQUEST_COMPLETE:C,LIVE_COUNTDOWN_TICK:_,LIVE_COUNTDOWN_START:A,LIVE_COUNTDOWN_COMPLETE:N,OVP_MEDIA_CHANGED:M,OVP_REALTIME_MESSAGE:S,OVP_CONFIG_FINALIZED:O});const L={Unknown:"00-00",MediaUnknown:"01-00",MediaUnavailable:"01-01",MediaUnsupportedVideoFormat:"01-02",MediaUnsupportedAudioFormat:"01-03",MediaBitrateExceeded:"01-04",MediaBufferOverread:"01-05",MediaIntegerOverflow:"01-06",MediaQuotaExceeded:"01-07",MediaInvalidCompositionDuration:"01-08",MediaInvalidCompositionSourceDuration:"01-09",MediaInvalidCompositionSourceStartTime:"01-10",MediaMalformedDepth:"01-11",PlaybackUnknown:"02-00",PlaybackVideoBufferUnderRun:"02-01",PlaybackAudioBufferUnderRun:"02-02",PlaybackVideoBufferingTimeout:"02-03",PlaybackAudioBufferingTimeout:"02-04",PlaybackManifestParseError:"02-05",PlaybackVideoDecodeError:"02-06",PlaybackAudioDecodeError:"02-07",PlaybackDroppedFramesExceeded:"02-08",PlaybackPlayheadExceedsDuration:"02-09",PlaybackUnsupportedDevice:"02-10",PlaybackManifestLoadError:"02-11",PlaybackManifestLoadTimeout:"02-12",PlaybackManifestParsingError:"02-13",PlaybackManifestIncompatibleCodecs:"02-14",PlaybackLevelEmptyError:"02-15",PlaybackLevelLoadError:"02-16",PlaybackLevelLoadTimeout:"02-17",PlaybackLevelSwitchError:"02-18",PlaybackAudioTrackLoadError:"02-19",PlaybackAudioTrackLoadTimeout:"02-20",PlaybackFragLoadError:"02-21",PlaybackFragLoadTimeout:"02-22",PlaybackFragDecryptError:"02-23",PlaybackFragParsingError:"02-24",PlaybackFragGap:"02-25",PlaybackRemuxAllocError:"02-26",PlaybackBufferAddCodecError:"02-27",PlaybackBufferIncompatibleCodecs:"02-28",PlaybackBufferAppendError:"02-29",PlaybackBufferStalledError:"02-30",PlaybackBufferFullError:"02-31",PlaybackBufferSeekOverHole:"02-32",PlaybackBufferNudgeOnStall:"02-33",PlaybackInternalException:"02-34",PlaybackInternalAborted:"02-35",PlaybackManifestLoaderFailure:"02-36",PlaybackSegmentBaseLoaderError:"02-37",PlaybackTimeSyncFailed:"02-38",PlaybackFragmentLoaderFailure:"02-39",PlaybackAppendError:"02-40",PlaybackRemoveError:"02-41",PlaybackDataUpdateFailed:"02-42",PlaybackManifestNoStreams:"02-43",PlaybackUnknownManifestType:"02-44",PlaybackDashInsufficientSegmentInfo:"02-45",PlaybackDashNoRepresentations:"02-46",PlaybackDashNoAdaptationSets:"02-47",PlaybackDashNoInitSegment:"02-48",PlaybackDashUnsupportedContainerFormat:"02-49",PlaybackDashKeySystemMismatch:"02-50",PlaybackMultipleKeyIDs:"02-51",PlaybackDashConflictingKeyIDs:"02-52",PlaybackRestrictedStreams:"02-53",PlaybackHlsMasterAndMediaTags:"02-54",PlaybackRepresentationIdConflict:"02-55",PlaybackHlsUnsupportedKeyFormats:"02-56",PlaybackManifestNoVariants:"02-57",PlaybackHlsUndeclaredVariables:"02-58",PlaybackAes128InvalidKeyLength:"02-59",PlaybackDashConflictingAes128Keys:"02-60",PlaybackDashUnsupportedAes128Encryption:"02-61",PlaybackManifestPatchMismatch:"02-62",PlaybackEmptyMediaPlaylist:"02-63",PlaybackNonContiguousCompositionTrack:"02-64",PlaybackDecoderNotFound:"02-65",PlaybackDecoderTemporarilyUnavailable:"02-66",PlaybackIncompatibleAsset:"02-67",PlaybackNoCompatibleExternalDisplay:"02-69",PlaybackOutOfMemory:"02-70",PlaybackToneMappingFailed:"02-71",PlaybackVideoCompositorFailed:"02-72",NetworkUnknown:"03-00",NetworkNoInternet:"03-01",NetworkRequestTimeout:"03-02",NetworkUnableToResolveHost:"03-03",NetworkResourceNotFound:"03-04",NetworkExpiredUrl:"03-05",NetworkUrlResolutionFailed:"03-06",NetworkDownloadErrorIdManifest:"03-07",NetworkDownloadErrorIdSidx:"03-08",NetworkDownloadErrorIdContent:"03-09",NetworkDownloadErrorIdInitialization:"03-10",NetworkDownloadErrorIdXlink:"03-11",NetworkHttpRequestFailed:"03-12",NetworkMaxRetriesExceeded:"03-13",NetworkSegmentMissing:"03-14",NetworkHttp400BadRequest:"03-400",NetworkHttp401Unauthorized:"03-401",NetworkHttp402PaymentRequired:"03-402",NetworkHttp403Forbidden:"03-403",NetworkHttp404NotFound:"03-404",NetworkHttp405MethodNotAllowed:"03-405",NetworkHttp406NotAcceptable:"03-406",NetworkHttp407ProxyAuthenticationRequired:"03-407",NetworkHttp408RequestTimeout:"03-408",NetworkHttp409Conflict:"03-409",NetworkHttp410Gone:"03-410",NetworkHttp411LengthRequired:"03-411",NetworkHttp412PreconditionFailed:"03-412",NetworkHttp413PayloadTooLarge:"03-413",NetworkHttp414URITooLong:"03-414",NetworkHttp415UnsupportedMediaType:"03-415",NetworkHttp416RangeNotSatisfiable:"03-416",NetworkHttp417ExpectationFailed:"03-417",NetworkHttp418ImATeapot:"03-418",NetworkHttp421MisdirectedRequest:"03-421",NetworkHttp422UnprocessableEntity:"03-422",NetworkHttp423Locked:"03-423",NetworkHttp424FailedDependency:"03-424",NetworkHttp425TooEarly:"03-425",NetworkHttp426UpgradeRequired:"03-426",NetworkHttp428PreconditionRequired:"03-428",NetworkHttp429TooManyRequests:"03-429",NetworkHttp431RequestHeaderFieldsTooLarge:"03-431",NetworkHttp451UnavailableForLegalReasons:"03-451",NetworkHttp500InternalServerError:"03-500",NetworkHttp501NotImplemented:"03-501",NetworkHttp502BadGateway:"03-502",NetworkHttp503ServiceUnavailable:"03-503",NetworkHttp504GatewayTimeout:"03-504",NetworkHttp505HTTPVersionNotSupported:"03-505",NetworkHttp506VariantAlsoNegotiates:"03-506",NetworkHttp507InsufficientStorage:"03-507",NetworkHttp508LoopDetected:"03-508",NetworkHttp510NotExtended:"03-510",NetworkHttp511NetworkAuthenticationRequired:"03-511",ContentProtectionUnknown:"04-00",ContentProtectionConcurrentStreamLimitExceeded:"04-01",ContentProtectionEntitlementRefused:"04-02",ContentProtectionLicenseExpired:"04-03",ContentProtectionBadLicenseRequest:"04-04",ContentProtectionLicenseServerTimeout:"04-05",ContentProtectionInsufficientHDCPSupport:"04-06",ContentProtectionGeoRestricted:"04-07",ContentProtectionParentalControlRestricted:"04-08",ContentProtectionCDNUnauthorized:"04-09",ContentProtectionInvalidAccessToken:"04-10",ContentProtectionKeySystemNoKeys:"04-11",ContentProtectionKeySystemNoAccess:"04-12",ContentProtectionKeySystemNoSession:"04-13",ContentProtectionKeySystemNoConfiguredLicense:"04-14",ContentProtectionKeySystemCertificateRequestFailed:"04-15",ContentProtectionKeySystemCertificateUpdateFailed:"04-16",ContentProtectionKeySystemSessionUpdateFailed:"04-17",ContentProtectionKeySystemStatusOutputRestricted:"04-18",ContentProtectionKeySystemStatusInternalError:"04-19",ContentProtectionKeyLoadError:"04-20",ContentProtectionKeyLoadTimeout:"04-21",ContentProtectionCapabilityMediaKeysError:"04-22",ContentProtectionManifestKeySystemUnknown:"04-23",ContentProtectionKeySystemUnavailable:"04-24",ContentProtectionCDMCreationFailed:"04-25",ContentProtectionCDMAttachFailed:"04-26",ContentProtectionCDMServerCertificateRejected:"04-27",ContentProtectionCDMSessionCreationFailed:"04-28",ContentProtectionCDMLicenseRequestFailed:"04-29",ContentProtectionCDMLicenseResponseRejected:"04-30",ContentProtectionManifestMissingDRMInfo:"04-31",ContentProtectionLicenseServerMissing:"04-32",ContentProtectionOfflineSessionRemoved:"04-33",ContentProtectionInitDataTransformationError:"04-34",ContentProtectionServerCertificateRequestFailed:"04-35",ContentProtectionInsufficientHDCPVersion:"04-36",ContentProtectionHDCPVersionCheckFailed:"04-37",AdsUnknown:"08-00",AdsVastParseError:"08-100",AdsInvalidVastSchema:"08-101",AdsVastVersionNotSupported:"08-102",AdsUnexpectedAdType:"08-200",AdsCreativeLinearityMismatch:"08-201",AdsCreativeDurationMismatch:"08-202",AdsCreativeSizeMismatch:"08-203",AdsWrapperVastError:"08-300",AdsVastResponseRedirectTimeout:"08-301",AdsWrapperLimitReached:"08-302",AdsVastResponseEmpty:"08-303",AdsLinearAdDisplayError:"08-400",AdsMediaFileNotFound:"08-401",AdsMediaFileUnavailable:"08-402",AdsUnsupportedMimeType:"08-403",AdsUnableToDisplayMediaFile:"08-405",AdsMezzanineFileMissing:"08-406",AdsMezzanineFileDownloaded:"08-407",AdsRejectedAd:"08-408",AdsInteractiveCreativeError:"08-409",AdsVerificationNodeExecutionError:"08-410",AdsNonLinearAdDisplayError:"08-500",AdsNonLinearAdSizeMismatch:"08-501",AdsNonLinearAdFetchError:"08-502",AdsNonLinearUnsupportedType:"08-503",AdsCompanionAdDisplayError:"08-600",AdsCompanionAdSizeMismatch:"08-601",AdsRequiredCompanionAdError:"08-602",AdsCompanionAdFetchError:"08-603",AdsUndefinedVastError:"08-900",AdsUnknownVpaidError:"08-901",AdsVastDocumentEmpty:"08-999"},T=Object.fromEntries(Object.entries(L).map(([e,t])=>[t,e]));const F=[1e7]+""+-1e3+-4e3+-8e3+-1e11,R="off";class FlowplayerError extends Error{static getErrorKey(e){return e in T?T[e]:T["00-00"]}constructor(e,t,o={}){super(e),this.message=e,this.flowplayerErrorCode=t,this.config=o,this.id="undefined"==typeof crypto?"":F.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)),this.isFatal=!!o.isFatal,this.errorKey=FlowplayerError.getErrorKey(this.flowplayerErrorCode)||"unknown"}toJSON(){return{message:this.message,flowplayer_error_code:this.flowplayerErrorCode,id:this.id,root_error_id:this.config.rootErrorId,resource:this.config.resource,is_fatal:this.isFatal,is_retry:!!this.config.isRetry}}}function I(e,t){const o=null==t?void 0:t.src;if(w(t))return function(e,t){const o=k(t.src||"");if(function(e){return"string"==typeof e.err}(o))return console.error(o.err);H(e,o)}(e,t);if(!o)return;e.setState(r,!0);const n=function(e){return~e.indexOf("/")?e:"/media/"+e}(o),i=l(n);fetch(i).then(async t=>t.ok?H(e,await t.json()):function(e,t,o,n){e.setState(r,!1);const i=new FlowplayerError(n.message||"error loading ovp source",function(e){const t=`03-${e}`;return t in T?t:L.NetworkUnknown}(o),{resource:t,isFatal:!0,retryOpts:{retry:R}});e.emit(a,{error:i})}(e,t.url,t.status,await t.json()))}function H(e,t){return delete t.live,e.emit(M,t),function(e){return Array.isArray(e.playlist)}(t)?function(e,t){e.emit(C,function(e,t){"number"!=typeof t.delay&&"number"!=typeof e.delay&&(t.delay=5);const n=Object.assign({},e),r=(null==e?void 0:e.playlist)||{},a=o(t,r),i=((null==a?void 0:a.playlist)||[]).map(e=>{t.ima&&Object.assign(e,{ima:t.ima});const o=p(e,n);return delete o.playlist,o});return delete a.ima,Object.assign(a,{playlist:i})}(e.opts,t))}(e,t):P(t)?function(e,t){var o,n;const r=(null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.live_start_time)||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.starttime);r&&(t.live_start_time=Pipe.of(r).fmap(b).unwrap());e.emit(A,Pipe.of(t).fmap(p,e.opts).unwrap())}(e,t):function(e,t){e.emit(E,Pipe.of(t).fmap(p,e.opts).unwrap())}(e,t)}const U={};function j(e,t,o){"object"!=typeof U[t]&&(U[t]=o);const n=e.opts,r=(null==n?void 0:n.metadata)||{};r.player_id=t,n.metadata=r,o.title&&delete o.title,o.description&&delete o.description;const a=Object.assign(n,o);e.setOpts(a),o.autoplay&&e.togglePlay(!0)}const x="recommendationsready";let V=!1;function K(e,t,o){q()||Pipe.of("recommendation").fmap(l,t,o).fmap(c).fmap(t=>t.then(t=>function(e,t){const o=t.playlist,n=e.opts;if(n.recommendations=o,!o.length)return;e.emit(x,{playlist:o.map(function(e){var t,o;return{poster:e.poster,src:e.src,title:null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.title,description:null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.description,metadata:e.metadata||{},chapters:e.chapters,thumbnails:e.thumbnails,subtitles:e.subtitles}})})}(e,t)).catch(B))}function q(){return V}function B(e){V=!0,console.error("Failed to load recommendations: %j",e)}function z(e){const t="number"==typeof e?e:parseInt(e,10);return(t>9?"":"0")+t}function W(e,t){const o=e._customElements.get(t);return o&&e.root.querySelector(o)||void 0}const G="flowplayer-live-countdown";function $(e){const t=Date.now()-(e.server_time_offset||0);return Math.floor(((e.live_start_time||0)-t)/1e3)}function J(e,t){let o=0;function a(){const a=$(t);if(a<0||isNaN(a)||0===e.reaper||void 0===t.live_start_time)return clearInterval(o),function(e,t,o){e.emit(N);const n=W(e,G);if(n&&n.remove(),e.root.classList.remove("is-livecountdown"),o)return e.setState(r,!1);e.emit(E,t)}(e,t,void 0===t.live_start_time);var i,s,c;i=e,s=e.root,c=a,s.classList.add("is-livecountdown"),i.emit(_,{remaining_time:Q(c+1)}),i.hasState(n)||i.setState(n,!0)}u(t),a(),o=setInterval(a,250)}function Q(e){const t=function(e){"number"!=typeof e&&(e=parseInt(e,10)),e=Math.round(e);const t=Math.floor(e/86400);e-=86400*t;const o=Math.floor(e/3600);e-=3600*o;const n=Math.floor(e/60);return{days:t,hours:o,minutes:n,seconds:e-=60*n}}(e);let o="";return t.days&&(o+=t.days+":"),o+z(t.hours)+":"+z(t.minutes)+":"+z(t.seconds)}class WebsocketBridge{static of(e){return new WebsocketBridge(e)}constructor(e){this.manualDisconnect=!1,this.video=e,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}connect(e){this.client=new WebSocket("wss://player.ws.flowplayer.com?mediaId="+e),this.current_media_id=e,this.wireup()}onClose(){this.manualDisconnect?this.manualDisconnect=!1:this.current_media_id&&this.reconnect(this.current_media_id)}onMessage(e){JSON.parse(e.data).forEach(e=>{this.video.emit(S,e)})}reconnect(e){this.cleanup(),this.connect(e)}wireup(){this.client&&(this.client.addEventListener("message",this.onMessage),this.client.addEventListener("close",this.onClose))}cleanup(){this.client&&(this.client.removeEventListener("message",this.onMessage),this.client.removeEventListener("close",this.onClose),this.client=void 0)}disconnect(){this.client&&(this.manualDisconnect=!0,this.client.close())}}const Z=(e,t)=>new(((e,t)=>{const o=e.get(t);if(!o)throw new Error(`no flowplayer component with the name ${t} exists`);const n=window.customElements.get(t);if(!n)throw new Error(`no default flowplayer component with the name ${t} exists`);const r=window.customElements.get(o);return"function"!=typeof r?n:r})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerLiveCountdown extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-livecountdown");const t=function(...e){const t=document.createElement("div");return 0==e.length||t.classList.add(...e),t}("fp-inner");this.append(t);const o=document.createElement("p");o.innerText=e.i18n("ovp.starting_in"),t.append(o);const n=document.createElement("p");n.classList.add("fp-countdown"),t.append(n),e.on(_,t=>{const o=t.detail.remaining_time;e.root.classList.add("is-livecountdown"),n.innerText=o})}}const Y=["Expired token","No token provided in configuration","Invalid token provided","Domain not allowed"];function X({root:e,video:t,data:o}){t&&t.destroy(),console.error(new Error(o.details||o.reason)),e.innerHTML="",e.classList.remove("flowplayer"),e.classList.add("flowplayer-fatal"),e.style.removeProperty("background-image");const n=!!(r=o.details)&&Y.some(e=>r.includes(e));var r;const a=document.createElement("h2");a.textContent=n?"No Valid Token":"Playback Error";const i=document.createElement("p");i.textContent="Are you the site owner?";const s=document.createElement("a");s.classList.add("troubleshoot"),s.target="_blank",n?(s.href="https://form.typeform.com/to/YKJpmJSy",s.textContent="Get Trial Token (Beta)"):(s.href="https://docs.flowplayer.com/troubleshooting/player#"+o.reason,s.textContent="Troubleshoot?");const c=document.createElement("img");c.src="https://flowplayer.com/user/pages/images/logo-white.png",c.alt="Flowplayer Logo",e.append(a,i,s,c)}const ee=["*.lwcdn.com","*.flowplayer.com","*.wowza.com"];function te(){try{return window.location.hostname!==window.parent.location.hostname?function(e){const t=document.createElement("a");return t.href=e,t}(document.referrer).hostname:document.location.hostname}catch(e){return window.location.hostname}}function oe(e){const t=document.createElement("a");t.href=e;const o=t.pathname&&t.pathname.split(".");return o.length>1&&o[o.length-1]}function ne(e){switch(e){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return e}}const re=t=>{var{src:o}=t,n=e(t,["src"]);return[Object.assign({src:o,type:o?ne("video/"+oe(o)):""},n)]};function ae(e){return re({src:e})}function ie(t){var{src:o,type:n}=t,r=e(t,["src","type"]);return o&&n?[Object.assign({src:o,type:n},r)]:n&&!o?[Object.assign({type:n},r)]:re(Object.assign({src:o},r))}const se=1;var ce,le;function de(e){const t=[];e.on("health:ready",()=>{const o=e.opt("metadata.stream_target_id");o&&!t.includes(o)&&(t.push(o),function(e,{feature_name:t,behavior:o,sample_rate:n}){t&&(n||(n=se),e.emit("flowplayer:feature",{feature_name:t,behavior:o,sample_rate:n}))}(e,{feature_name:"ewv",behavior:"used"}))})}!function(e){e[e.Err=0]="Err",e[e.Ok=1]="Ok"}(ce||(ce={}));const ue=((le=class OVP{constructor(e){((e,t,o)=>{window.customElements.get(t)||window.customElements.define(t,o),e.customElements.get(t)||e.customElements.set(t,t)})(e,G,FlowplayerLiveCountdown)}onload(e,t,o,n){if("string"==typeof(null==n?void 0:n.src))return"string"!=typeof e.player_id||0===n.src.indexOf(e.player_id)||w(n)||(n.src=[e.player_id,n.src].join("/")),I(o,n)}wants(e,t,o){return h(e,t)}init(t,n,a){const i=new WebsocketBridge(a);let s=Object.assign({},t);const d=function(e){if(!s)return e;t.autoplay!==s.autoplay&&(s.autoplay=t.autoplay),delete s.src;const n=o(e,s);return a.emit(O,n),n};a.on("src",()=>{(a.currentSrc||a.root.classList.contains("is-livecountdown"))&&(s=!1)}),a.on(g,function(){a.setState("is-waiting",!0),t.recommendations&&(t.recommendations=!1)}),a.on(M,function({data:e}){var t,o;const n=null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.media_id;(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.live_start_time)&&n&&(i.disconnect(),i.connect(n))}),a.on(S,function({data:e}){var o;const n=null==e?void 0:e.event,r=null==e?void 0:e.value,i=a.opt("metadata",{live_start_time:""});switch(n){case"METADATA":{const e=Object.assign(i,r),n=Object.assign(t,{metadata:e});(null===(o=null==n?void 0:n.metadata)||void 0===o?void 0:o.live_start_time)&&(n.live_start_time=b(n.metadata.live_start_time)),a.setOpts(n);break}}}),a.on("beforeplay",function(e){const o=t;if(P(o)){if(pe(o))return;e.preventDefault()}}),a.on(E,function(e){const t=e.data;if(!t)return;var o;if(t.src&&(t.src=(o=t.src,"string"==typeof o?ae(o):Array.isArray(o)||"object"!=typeof o?o.reduce(function(e,t){return"string"==typeof t&&(t=ae(t)),"object"!=typeof t||Array.isArray(t)||(t=ie(t)),e.concat(t)},[]):ie(o)).map(e=>(e.src&&e.src.startsWith("//")&&(e.src="https:"+e.src),e))),0==a.reaper||"object"!=typeof t||$(t)>0)return;const n=d(t);a.setOpts(n),a.setAttrs(n),n.src&&a.setSrc(n.src),a.setState(r,!1)}),a.on("config",function({data:e}){var o,r;if("string"==typeof t.src&&h(t.src,{}))return;if((null==e?void 0:e.domains)&&(null==e?void 0:e.domains.length)&&!((e,t)=>{const o=e.split(".").reverse();return t.concat(ee).some(e=>{const t=e.split(".").reverse(),n="*"===t[t.length-1];return n&&t.pop(),(n||t.length===o.length)&&t.every((e,t)=>o[t]===e)})})(te(),e.domains))return X({root:n,video:a,data:{details:`Hostname ${te()} is not allowed to load player ${null===(o=e.metadata)||void 0===o?void 0:o.player_id}.`,reason:"domain"}});if(t.src&&me(t.src))return;const i=null==e?void 0:e.brand_color;return i&&a.root.style.setProperty("--fp-brand-color","#"==i[0]?i:"#"+i),"string"==typeof t.player_id&&(null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.player_id)!==t.player_id?function(e,t){if("object"==typeof U[t])return console.debug("using Cache(%s)",t),j(e,t,U[t]);Pipe.of(t).fmap(l).fmap(c).fmap(o=>o.then(o=>j(e,t,o)).catch(console.error))}(a,t.player_id):void 0}),a.on(C,function(t){var o;const n=t.data;if(!n||0==a.reaper)return;const{playlist:i}=n,s=e(n,["playlist"]),c=d(Object.assign(s,{playlist:Object.assign({},s)}));Array.isArray(c.playlist)&&(c.playlist=s),delete c.loop,c.playlist.playlist_title||(c.playlist.playlist_title=null===(o=s.metadata)||void 0===o?void 0:o.playlist_title),a.setOpts(c),a.setAttrs(c);const l={type:"flowplayer/playlist",items:i};a.setSrc(l),a.setState(r,!1)}),a.on(A,function(e){const o=e.data;if(!o||0==a.reaper)return;const r=d(o);if(a.setOpts(r),a.setAttrs(r),$(o)<=0)return a.emit(E,o);W(a,G)||(n.appendChild(Z(a,G)),J(a,t))}),a.on("timeupdate",function(){var e,o,n;const r=t;P(r)?pe(r)||(a.togglePlay(!1),a.emit("ended")):t.recommendations&&(null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)&&(Array.isArray(t.recommendations)||a.currentTime/a.duration<.8||q()||(null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.media_id)&&(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.player_id)&&K(a,t.metadata.media_id,t.metadata.player_id))}),a.on("reap",function(){i.disconnect()}),de(a)}}).pluginName="ovp",le.events=D,le);function pe(e){var t,o;const n=null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.live_stop_time;if(!n)return!0;return!!(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.allow_after_stop_time)||b(n)>Date.now()}const me=e=>{var t;if(e&&Array.isArray(e))return"object"==typeof e[0]&&"ovp/base64"===(null===(t=e[0])||void 0===t?void 0:t.type)};return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const o=e.flowplayer;return"function"==typeof o?(o(t),t):(Array.isArray(o.extensions)||(o.extensions=[]),~o.extensions.indexOf(t)||o.extensions.push(t),t)}(window,ue)});
package/plugins/rts.d.ts CHANGED
@@ -2524,27 +2524,93 @@ declare const WILL_SEEK = "will-seek";
2524
2524
  /**
2525
2525
  * @public
2526
2526
  */
2527
- export declare type WowzaWebRTCSrc = {
2527
+ export declare type WowzaWebRTCBaseSrc = {
2528
2528
  /**
2529
- * The Signaling URL or SDP URL in Wowza Streaming Engine contains your StreamLock domain. The StreamLock domain can be found as part of your SSL certificate name.
2530
- *
2531
- * If using legacy Wowza video: the SDP URL listed on the Overview tab for your WebRTC stream in Wowza Video.
2529
+ * Base URL for signaling. For WebSocket: the full WSS endpoint
2530
+ * (e.g. `wss://[host]/webrtc-session.json`). For WHEP: the HTTP base URL —
2531
+ * the adapter appends `/{applicationName}/{streamName}/whep` automatically.
2532
2532
  */
2533
2533
  sdpUrl: string;
2534
2534
  /**
2535
2535
  * The name of the application you set up in Wowza Streaming Engine for WebRTC streams.
2536
- *
2537
- * If using legacy Wowza video: The value from the Application field on the Overview tab for your WebRTC stream in Wowza Video.
2538
2536
  */
2539
2537
  applicationName: string;
2540
2538
  /**
2541
- * The stream name can be found on the Incoming Streams page for the application you created for the stream in Wowza Streaming Engine.
2542
- *
2543
- * If using legacy Wowza video: The value from the Stream Name field on the Overview tab for your WebRTC stream in Wowza Video.
2539
+ * The stream name from the Incoming Streams page for the application in Wowza Streaming Engine.
2544
2540
  */
2545
2541
  streamName: string;
2546
- token?: string;
2542
+ /**
2543
+ * Comma-separated list of STUN server URLs,
2544
+ * e.g. `"stun:stun.example.com:3478, stun:stun2.example.com:3478"`.
2545
+ */
2546
+ stunServerURL?: string;
2547
+ /**
2548
+ * Comma-separated list of TURN server URLs, e.g. `"turn:turn.example.com:3478"`.
2549
+ */
2550
+ turnServerURL?: string;
2551
+ /**
2552
+ * Username for TURN server authentication.
2553
+ */
2554
+ turnUsername?: string;
2555
+ /**
2556
+ * Password/credential for TURN server authentication.
2557
+ */
2558
+ turnPassword?: string;
2547
2559
  type: "wowza/webrtc";
2548
2560
  };
2549
2561
 
2562
+ /**
2563
+ * @public
2564
+ */
2565
+ export declare type WowzaWebRTCSrc = WowzaWebRTCWhepSrc | WowzaWebRTCWsSrc;
2566
+
2567
+ /**
2568
+ * @public
2569
+ */
2570
+ export declare type WowzaWebRTCWhepSrc = WowzaWebRTCBaseSrc & {
2571
+ /**
2572
+ * Use WHEP (WebRTC-HTTP Egress Protocol) instead of WebSocket signaling.
2573
+ * Requires WSE 4.10+ or Wowza Video with WHEP enabled.
2574
+ */
2575
+ useWhep: true;
2576
+ /**
2577
+ * Bearer token sent as `Authorization: Bearer <authToken>` on all WHEP requests.
2578
+ */
2579
+ authToken?: string;
2580
+ };
2581
+
2582
+ /**
2583
+ * @public
2584
+ */
2585
+ export declare type WowzaWebRTCWsSrc = WowzaWebRTCBaseSrc & {
2586
+ useWhep?: false;
2587
+ /**
2588
+ * Pre-computed WSE secure token. Generate this server-side — never expose the shared
2589
+ * secret in client code. Pass the resulting `{ hash, starttime, endtime }` object here
2590
+ * and the adapter will include it in the WebSocket signaling message.
2591
+ */
2592
+ secureToken?: {
2593
+ hash: string;
2594
+ starttime: string;
2595
+ endtime: string;
2596
+ };
2597
+ /**
2598
+ * Use the WSE v2 WebSocket signaling protocol (client creates the offer, trickle ICE)
2599
+ * instead of the classic protocol (server creates the offer, bundled ICE candidates).
2600
+ * Requires WSE 4.10+, and the server must actually be configured to accept it — WSE
2601
+ * decides which protocol answers a connection per VHost, via `SelectedVersion` in
2602
+ * `VHost.xml` (`legacy`, `v2`, or `dynamic`, the latter honoring this flag). Servers
2603
+ * upgraded in place from an older version may keep a `VHost.xml` without v2 enabled,
2604
+ * in which case setting this to `true` fails silently — no error, the connection just
2605
+ * hangs, since the legacy stack doesn't understand v2's message format and never replies.
2606
+ * Leave unset/`false` (classic protocol) by default; it works everywhere and fails with
2607
+ * a clear synchronous error when something is wrong. Only opt into `true` for a specific,
2608
+ * confirmed reason (e.g. the server's advertised ICE candidate isn't reachable by the
2609
+ * browser) and after confirming with the server operator that v2 is actually enabled.
2610
+ * Wowza Video (the hosted/managed service) only speaks the classic protocol — leave this
2611
+ * unset/`false` there; it does not apply.
2612
+ */
2613
+ useV2Signaling?: boolean;
2614
+ };
2615
+
2550
2616
  export { }