var lsKeys={token:"token"},page={token:localStorage[lsKeys.token],urlPrefix:null,urlIdentifier:null,messageElement:document.querySelector("#message"),fileinfoContainer:document.querySelector("#fileinfo"),clipboardBtn:document.querySelector("#clipboardBtn"),playerBtn:document.querySelector("#playerBtn"),downloadBtn:document.querySelector("#downloadBtn"),deleteBtn:document.querySelector("#deleteBtn"),uploadRoot:null,titleFormat:null,file:null,clipboardJS:null,updateMessageBody:function(e){page.messageElement.querySelector(".message-body").innerHTML=e,page.messageElement.classList.remove("is-hidden")},onError:function(e){console.error(e),page.updateMessageBody("\n

An error occurred!

\n

"+e.toString()+"

\n

Please check your console for more information.

\n ")},onAxiosError:function(e){var t={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,a=e.response.data&&e.response.data.description?e.response.data.description:"";page.updateMessageBody("\n

"+e.response.status+" "+t+"

\n

"+a+"

\n ")},deleteFile:function(){if(page.file){var e=document.createElement("div");e.innerHTML="

You won't be able to recover this file!

",swal({title:"Are you sure?",content:e,icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, nuke it!",closeModal:!1}}}).then((function(e){e&&axios.post("../api/upload/delete",{id:page.file.id}).then((function(e){if(e){if(!1===e.data.success)return swal("An error occurred!",e.data.description,"error");(Array.isArray(e.data.failed)?e.data.failed:[]).length?swal("An error occurred!","Unable to delete this file.","error"):swal("Deleted!","This file has been deleted.","success",{buttons:!1})}})).catch(page.onAxiosError)}))}},loadFileinfo:function(){page.urlIdentifier&&axios.get("../api/upload/get/"+page.urlIdentifier).then((function(e){if(![200,304].includes(e.status))return page.onAxiosError(e);page.file=e.data.file,page.titleFormat&&(document.title=page.titleFormat.replace(/%identifier%/g,page.file.name));for(var t="",a=Object.keys(page.file),n=0;n\n "+r+"\n "+o+"\n \n "}document.querySelector("#title").innerText=page.file.name,page.fileinfoContainer.querySelector(".table-container").innerHTML='\n
\n \n \n \n \n \n \n \n \n \n '+t+"\n \n
FieldsValues
\n
\n ";var i=page.uploadRoot+"/"+page.file.name;page.downloadBtn.setAttribute("href",i),page.clipboardBtn.dataset.clipboardText=i;var l=page.file.type.startsWith("image/"),s=page.file.type.startsWith("video/"),d=page.file.type.startsWith("audio/");if(l){var p=page.fileinfoContainer.querySelector("img");p.setAttribute("alt",page.file.name||""),p.src=page.uploadRoot+"/"+page.file.name,p.parentNode.classList.remove("is-hidden"),p.onerror=function(e){return e.currentTarget.classList.add("is-hidden")}}else(s||d)&&(page.playerBtn.setAttribute("href","../v/"+page.file.name),page.playerBtn.parentNode.parentNode.classList.remove("is-hidden"));page.fileinfoContainer.classList.remove("is-hidden"),page.messageElement.classList.add("is-hidden"),page.urlParams.has("delete")&&page.deleteBtn.click()})).catch((function(e){void 0!==e.response?page.onAxiosError(e):page.onError(e)}))}};window.addEventListener("DOMContentLoaded",(function(){window.URLSearchParams=window.URLSearchParams||function(e){var t=this;t.has=function(e){return null!=new RegExp("[?&]"+e).exec(t.searchString)}},axios.defaults.headers.common.token=page.token;var e=document.querySelector("#mainScript");if(e&&void 0!==e.dataset.uploadRoot){page.uploadRoot=e.dataset.uploadRoot,page.titleFormat=e.dataset.titleFormat;var t=window.location.protocol+"//"+window.location.host,a=window.location.pathname.match(/.*\/(.*)$/);if(!a||!a[1])return page.updateMessageBody("

Failed to parse upload identifier from URL.

");page.urlIdentifier=a[1],t+=window.location.pathname.substring(0,window.location.pathname.indexOf(a[1])),page.urlPrefix=t,page.urlParams=new URLSearchParams(window.location.search),page.clipboardJS=new ClipboardJS(".clipboard-js"),page.clipboardJS.on("success",(function(){return swal("","The link has been copied to clipboard.","success",{buttons:!1,timer:1500})})),page.clipboardJS.on("error",page.onError),page.deleteBtn.addEventListener("click",page.deleteFile),page.loadFileinfo()}})); //# sourceMappingURL=file.js.map