varlsKeys={},page={urlPrefix:null,urlIdentifier:null,urlInput:document.querySelector("#identifier"),reloadBtn:document.querySelector("#reloadBtn"),downloadBtn:document.querySelector("#downloadBtn"),uploadRoot:null,titleFormat:null,videoContainer:document.querySelector("#playerContainer"),player:null};window.HELP_IMPROVE_VIDEOJS=!1,page.onError=function(e){console.error(e);varr=document.createElement("div");returnr.innerHTML="\n <p><code>"+e.toString()+"</code></p>\n <p>Please check your console for more information.</p>\n ",swal({title:"An error occurred!",icon:"error",content:r})},page.onAxiosError=function(e){varr={520:"Unknown Error",521:"Web Server Is Down",522:"Connection Timed Out",523:"Origin Is Unreachable",524:"A Timeout Occurred",525:"SSL Handshake Failed",526:"Invalid SSL Certificate",527:"Railgun Error",530:"Origin DNS Error"}[e.response.status]||e.response.statusText,t=e.response.data&&e.response.data.description?e.response.data.description:"";returnswal(e.response.status+" "+r,t,"error")},page.toggleReloadBtn=function(e){e?(page.reloadBtn.classList.remove("is-loading"),page.reloadBtn.removeAttribute("disabled")):(page.reloadBtn.classList.add("is-loading"),page.reloadBtn.setAttribute("disabled","disabled"))},page.reloadVideo=function(){if(page.urlInput.value){page.toggleReloadBtn(!1);vare=page.uploadRoot+"/"+page.urlInput.value;axios.head(e).then((function(r){if(![200,304].includes(r.status))returnpage.toggleReloadBtn(!0),page.onAxiosError(r);vart=r.headers["content-type"]||"",o=t.startsWith("video/"),a=t.startsWith("audio/");if(!o&&!a)returnpage.toggleReloadBtn(!0),swal("An error occurred!","The requested upload does not appear to be a media file.","error");page.urlIdentifier=page.urlInput.value,page.player&&(page.player.dispose(),page.videoContainer.innerHTML="");varn=document.createElement("video-js");n.id="video-js",n.className="video-js vjs-default-skin vjs-fluid vjs-big-play-centered",n.setAttribute("controls",!0),n.setAttribute("preload","auto"),page.videoContainer.appendChild(n);vari={language:"en",playbackRates:[.25,.5,.75,1,1.25,1.5,1.75,2],responsive:!0};a&&(i.plugins={wavesurfer:{backend:"MediaElement"}}),page.player=videojs("video-js",i,(function(){varr="Using video.js "+videojs.VERSION;a&&(r+="with videojs-wavesurfer "+videojs.getPluginVersion("wavesurfer")+" and wavesurfer.js "+WaveSurfer.VERSION),videojs.log(r),page.player.src({src:e,type:t})})),page.player.seekButtons({forward:10,back:10}),page.titleFormat&&(document.title=page.titleFormat.replace(/%identifier%/g,page.urlIdentifier)),page.downloadBtn&&page.downloadBtn.setAttribute("href",e),window.history.pushState(null,null,page.urlPrefix+page.urlIdentifier),page.toggleReloadBtn(!0)})).catch((function(e){page.toggleReloadBtn(!0),void0!==e.response?page.onAxiosError(e):page.onError(e)}))}},window.addEventListener("DOMContentLoaded",(function(){vare=document.querySelector("#mainScript");if(e&&void0!==e.dataset.uploadRoot){page.uploadRoot=e.dataset.uploadRoot,page.titleFormat=e.dataset.titleFormat;varr=window.location.protocol+"//"+window.location.host,t=window.location.pathname.match(/.*\/(.*)$/);if(!t||!t[1])returnswal("An error occurred!","Failed to parse upload identifier from URL.","error");if(page.urlIdentifier=t[1],r+=window.location.pathname.substring(0,window.location.pathname.indexOf(t[1])),page.urlPrefix=r,page.urlInput){page.urlInput.value=page.urlIdentifier;varo=document.querySelector("#inputForm");o.addEventListener("submit",(function(e){e.preventDefault()})),page.videoContainer&&(page.reloadBtn=document.querySelector("#reloadBtn"),page.reloadBtn&&page.reloadBtn.addEventListener("click",(function(e){o.checkValidity()&&page.reloadVideo()})),page.reloadVideo())}}}));