var MediasitePlayCover=function(){function makeAppendable(n){mixInProps(n,rt)}function mixInProps(n,t){for(prop in t)t.hasOwnProperty(prop)&&(n.hasOwnProperty(prop)||(n[prop]=t[prop]))}function Thumbnail(){function init(){n=document.createElement("div"),n.className=tt}var t=this,n;makeAppendable(this),Object.defineProperty(this,"rootElement",{get:function(){return n}}),Object.defineProperty(this,"imageUrl",{set:function(t){n.style.backgroundImage=t?"url("+t+")":"none"}}),init()}function WaitingWidget(n){function init(){f=makeParagraph(t.waitingForLive,lt),u=makeParagraph(t.timeUnknown,ct),r.rootElement=makeDiv(i),r.rootElement.appendChild(f),r.rootElement.appendChild(u),scheduleUpdate(500)}function updateTime(){var t=getSecondsUntilAirDate(),n=timeTextFromSeconds(t),i=s&&n&&n.length>0;u.innerText=n,u.style.display=i?"block":"none",r.rootElement.className=getOuterCssClass(t)}function getSecondsUntilAirDate(){return(e-getNowUnixTime())/1e3}function getOuterCssClass(n){return n<=60?at:n<=3600?vt:yt}function scheduleUpdate(n){function scheduleNext(){o=setTimeout(callback,n)}function callback(){updateTime(),scheduleNext()}cancelScheduledUpdate(),scheduleNext()}function cancelScheduledUpdate(){clearTimeout(o)}function getNowUnixTime(){return+new Date}function timeTextFromSeconds(n){return typeof n!="number"?t.timeUnknown:n<-60?"":n<0?formatTimeText(0):n<86400?formatTimeText(n):""}function formatTimeText(n){var e,u,f,r,i;return f=Math.floor(n%60),u=Math.floor(n/60)%60,hr=Math.floor(n/3600),r=hr>0?t.timeFormat_hhmmss||"":t.timeFormat_mmss||"",i=r.replace("%%hh%%",hr+""),i=i.replace("%%mm%%",zeroPad(u+"",2)),i=i.replace("%%ss%%",zeroPad(f+"",2))}function zeroPad(n,t){while(n.length0;ct.innerHTML=t?n:"",oi=t,updateOuterCssClasses()}}),this.goLoading=function(){setModeCssClass("mode-loading")},this.goOnDemand=function(){setModeCssClass("mode-ondemand")},this.goLive=function(){setModeCssClass("mode-live")},this.goLiveEnded=function(){setModeCssClass("mode-ended")},this.goWaiting=function(){setModeCssClass("mode-waiting")},this.goUnavailable=function(){setModeCssClass("mode-unavailable")},this.destroy=function(){clearInterval(wi),t.removeFromDom()},init()}function PlayCover(n){function init(){f=new PlayCoverView(n),f.clickAction=doClickAction,f.goLoading()}function chainResolveThumbnails(n,t,i){i=i||function(){};var r=n&&u[n]||newThumbnailInfo();if(!r.url){t?chainResolveThumbnails(t,null,i):i(null);return}if(r.didResolve){i(r.resolvedUrl);return}resolveThumbnailUrl(r,function(r){var f=t&&u[t];r=r||{},u[n]=r,r.didResolve?i(r.resolvedUrl):f?chainResolveThumbnails(t,null,i):i(null)})}function resolveThumbnailUrl(n,t){if(n.triedResolve){t(n);return}var i=newThumbnailInfo(n.url);imageUrlToDataUrl(n.url,function(n){i.triedResolve=!0,n.loadingError?(i.didResolve=!1,i.resolvedUrl=""):(i.didResolve=!0,i.resolvedUrl=n.dataUrl||url),t(i)})}function doClickAction(){e&&typeof i.clickAction=="function"&&i.clickAction()}function onPropertySet(){updateView()}function onSetAirDate(){clearTimeout(s);var r=+new Date,u=i.airDateUnixTime-r,f=Math.max(0,u);setTimeout(updateView,f)}function updateViewMode(){e&&setCoverModeForPlayState(f,getEffectivePresentationState())}function updateView(n){n=n||function(){},setViewPropertyIfDifferent("backgroundImageUrl",i.options.backgroundImageUrl),e?getThumbnailUrlForView(function(t){setViewPropertyIfDifferent("thumbnailUrl",t),setViewPropertyIfDifferent("shouldShowTitle",i.options.shouldShowTitle),setViewPropertyIfDifferent("shouldShowPlayButton",i.options.shouldShowPlayButton),setViewPropertyIfDifferent("shouldShowLiveCountdown",i.options.shouldShowLiveCountdown),setViewPropertyIfDifferent("backgroundImageUrl",i.options.backgroundImageUrl),setViewPropertyIfDifferent("titleText",i.title),setViewPropertyIfDifferent("airDateUnixTime",i.airDateUnixTime),setViewPropertyIfDifferent("customMessageHtml",i.customMessageHtml),updateViewMode(),n(!0)}):n(!1)}function getThumbnailUrlForView(n){isUnavailable(getEffectivePresentationState())?chainResolveThumbnails("defaultThumbnailUrl",null,n):chainResolveThumbnails("thumbnailUrl","defaultThumbnailUrl",n)}function setViewPropertyIfDifferent(n,t){var i=o.hasOwnProperty(n),r=o[n];i&&r===t||(o[n]=t,f[n]=t)}function getEffectivePresentationState(){return i.options.shouldDelayLiveUntilAirDate&&isCurrentlyLive(i.presentationStatus)&&!haveReachedAirDate(i.airDateUnixTime)?t.ScheduledForLive:i.presentationStatus}function haveReachedAirDate(n){var t=500,i=+new Date;return n=n||0,i>=n-t}function setCoverModeForPlayState(n,t){isCurrentlyLive(t)?n.goLive():isWaitingToBeginLive(t)?n.goWaiting():isLiveEnded(t)?n.goLiveEnded():isOnDemand(t)?n.goOnDemand():n.goUnavailable()}function isOnDemand(n){return n===t.OnDemand}function isCurrentlyLive(n){return n===t.Live||n===t.LivePaused}function isWaitingToBeginLive(n){return n===t.ScheduledForLive||n===t.OpenForLive}function isLiveEnded(n){return n===t.LiveEnded}function isUnavailable(n){return n===t.NotAvailable}function prop(n,t,i,f){u[t]=f,r(n,t,{get:function(){return u[t]},set:function(n){u[t]=n,i(t,n)}})}function newThumbnailInfo(n){return{url:n||null,triedResolve:!1,didResolve:!1,resolvedUrl:null}}function setThumbnailUrlByName(n,t){var i=u[n];i&&i.url===t||(u[n]=newThumbnailInfo(t))}function getThumbnailUrlByName(n){var t=u[n];return t&&t.url}function defThumbnailProp(n,t){u[t]=newThumbnailInfo(),r(n,t,{set:function(n){setThumbnailUrlByName(t,n),updateView()},get:function(){return getThumbnailUrlByName(t)}})}var i=this,h,f,e=!1,u={},o={},c,l=15e3,s;makeAppendable(this),r(this,"rootElement",{get:function(){return f.rootElement}}),prop(i,"title",onPropertySet),prop(i,"airDateUnixTime",onSetAirDate),prop(i,"presentationStatus",onPropertySet),prop(i,"customMessageHtml",onPropertySet),defThumbnailProp(i,"thumbnailUrl"),defThumbnailProp(i,"defaultThumbnailUrl"),r(i,"options",{value:{},writable:!1}),prop(i.options,"backgroundImageUrl",onPropertySet),prop(i.options,"shouldShowTitle",onPropertySet,!0),prop(i.options,"shouldShowPlayButton",onPropertySet,!0),prop(i.options,"shouldShowLiveCountdown",onPropertySet,!0),prop(i.options,"shouldDelayLiveUntilAirDate",onPropertySet,!1),this.clickAction=function(){},this.ready=function(n){e=!0,updateView(function(){setTimeout(n,0)})},this.destroy=function(){f.destroy()},init()}function PresentationStatusWatcher(n,i){function init(){startStatusCheckPolling(),maybeStopStatusCheckPolling()}function intervalTick(){now()>=r&&callForStatus()}function calcCallDelay(){var i=n&&n.presentationStatus||"",r=n&&n.airDateUnixTime||0,u=Math.abs(now()-r)<3e5;return i==t.OpenForLive||i==t.ScheduledForLive&&u?h:i==t.ScheduledForLive?s:i==t.Live||i==t.LivePaused?o:c}function callForStatus(){r=now()+calcCallDelay()+e,i(receiveStatus)}function receiveStatus(t){n.presentationStatus=t.status,r=now()+calcCallDelay(),maybeStopStatusCheckPolling()}function startStatusCheckPolling(){u=setInterval(intervalTick,f)}function stopStatusCheckPolling(){clearInterval(u)}function maybeStopStatusCheckPolling(){var i=n&&n.presentationStatus;(i===t.OnDemand||i===t.NotAvailable)&&stopStatusCheckPolling()}function now(){return+new Date}var f=1e3,l=3e5,e=1e4,o=15e3,s=1e4,h=5e3,c=3e4,a=this,u,r=0;this.destroy=function(){stopStatusCheckPolling()},init()}function handleClick(n){n&&n.target&&n.target.tagName==="A"||typeof this.clickAction=="function"&&this.clickAction()}function makePlayButtonGraphic(){var i,n,t,r="http://www.w3.org/2000/svg";return i=document.createElementNS(r,"svg"),i.setAttribute("viewBox","0 0 100 100"),n=document.createElementNS(r,"circle"),n.setAttribute("class",ot),n.setAttribute("cx","50"),n.setAttribute("cy","50"),n.setAttribute("r","50"),n.setAttribute("fill","#000"),n.setAttribute("opacity","0.5"),i.appendChild(n),t=document.createElementNS(r,"path"),t.setAttribute("class",et),t.setAttribute("d","M 30,20 85,50 30,80"),t.setAttribute("fill","#fff"),t.setAttribute("opacity","0.9"),i.appendChild(t),i}function makeLiveDot(){var t,n,i="http://www.w3.org/2000/svg";return t=document.createElementNS(i,"svg"),t.setAttribute("viewBox","0 0 100 100"),n=document.createElementNS(i,"circle"),n.setAttribute("cx","50"),n.setAttribute("cy","50"),n.setAttribute("r","50"),n.setAttribute("fill","#ee0000"),n.setAttribute("opacity","1.0"),t.appendChild(n),t}function makeButton(n,t){var i=document.createElement("button");return i.className=t,i.appendChild(n),i}function makeTitleRegion(n,t){var i=document.createElement("div");return i.className=st,i.appendChild(n),i.style.diplay=t?"block":"none",i}function makeDiv(n){return makeTag("div","",n)}function makeParagraph(n,t){return makeTag("p",n,t)}function makeSpan(n,t){return makeTag("span",n,t)}function makeTag(n,t,i){var r=document.createElement(n);return r.className=i,r.innerText=t,r}function imageUrlToDataUrl(n,t){var r=document.createElement("img"),i={loadingError:!1,dataUrl:""};r.addEventListener("load",function(){var u;try{i.dataUrl=imgToDataUrl(r)}catch(f){i.dataUrl=""}t(i)}),r.addEventListener("error",function(){i.loadingError=!0,t(i)}),r.src=n}function imgToDataUrl(n){var t=document.createElement("canvas"),i=t.getContext("2d");return t.width=n.width,t.height=n.height,i.drawImage(n,0,0),t.toDataURL()}function findMatchingSizeClassNames(n,t){var i,r,u=[];n=n||0,t=t||{};for(i in t)t.hasOwnProperty(i)&&(r=t[i],n>=r.min&&n<=r.max&&u.push(i));return u}function getSizeClass(n,t){var i=findMatchingSizeClassNames(n,t);return i.join(" ")}function getWidthSizeClass(n){return getSizeClass(n,b)}function getHeightSizeClass(n){return getSizeClass(n,k)}function createPlayCover(n){return new PlayCover(n)}function createPresentationStatusWatcher(n,t){return new PresentationStatusWatcher(n,t)}var e=500,t={NotAvailable:"NotAvailable",ScheduledForLive:"ScheduledForLive",OpenForLive:"OpenForLive",Live:"Live",LivePaused:"LivePaused",LiveEnded:"LiveEnded",OnDemand:"OnDemand"},tt="mediasite-thumbnail",i="mediasite-waiting-widget message-widget",yt=i,vt=i+" last-hour",at=i+" last-minute",lt="waiting-text",ct="waiting-time",u="mediasite-playcover",ht="customized",st="title-region",f="play-button",ot="play-circle",et="play-arrow",ft="overlay-sheet shade-overlay",ut="overlay-sheet loading-overlay",wt="overlay-sheet playable-overlay",it="overlay-sheet custom-overlay",nt="overlay-sheet live-overlay",pt="overlay-sheet waiting-overlay",g="overlay-sheet ended-overlay",d="overlay-sheet unavailable-overlay",o="live-indicator",s="live-text",h="loading-text message-widget",c="ended-text message-widget",l="unavailable-text message-widget",a="custom-content-wrapper",v="custom-message-wrapper",y="custom-message",p="no-title",w="no-playbutton",b={"width-tiny":{min:0,max:349},"width-small":{min:350,max:499},"width-medium":{min:500,max:749},"width-big":{min:750,max:1099},"width-bigger":{min:1100,max:1499},"width-huge":{min:1500,max:Infinity}},k={"height-tiny":{min:0,max:196},"height-small":{min:197,max:280},"height-medium":{min:281,max:421},"height-big":{min:422,max:618},"height-bigger":{min:619,max:843},"height-huge":{min:844,max:Infinity}},rt={rootElement:null,appendToDom:function(n){n&&n.appendChild&&this.rootElement&&this.rootElement.nodeType===1&&n.appendChild(this.rootElement)},removeFromDom:function(){this.rootElement&&this.rootElement.parentElement&&this.rootElement.parentElement.removeChild&&this.rootElement.parentElement.removeChild(this.rootElement)}},r=Object.defineProperty;return{PRESENTATION_STATUS:t,create:createPlayCover,createStatusWatcher:createPresentationStatusWatcher,PlayCover:PlayCover,PresentationStatusWatcher:PresentationStatusWatcher,PlayCoverView:PlayCoverView,Thumbnail:Thumbnail,WaitingWidget:WaitingWidget,imageUrlToDataUrl:imageUrlToDataUrl}}()