varlsKeys={token:"token",chunkSize:"chunkSize",parallelUploads:"parallelUploads",uploadsHistoryOrder:"uploadsHistoryOrder",previewImages:"previewImages",fileLength:"fileLength",uploadAge:"uploadAge"},page={token:localStorage[lsKeys.token],private:null,enableUserAccounts:null,maxSize:null,chunkSize:null,temporaryUploadAges:null,fileIdentifierLength:null,album:null,parallelUploads:null,previewImages:null,fileLength:null,uploadAge:null,maxSizeBytes:null,urlMaxSize:null,urlMaxSizeBytes:null,tabs:[],activeTab:null,albumSelect:null,previewTemplate:null,dropzone:null,clipboardJS:null,lazyLoad:null,imageExts:[".webp",".jpg",".jpeg",".bmp",".gif",".png",".tiff",".tif",".svg"],videoExts:[".webm",".mp4",".wmv",".avi",".mov",".mkv"],albumTitleMaxLength:70,albumDescMaxLength:4e3,onInitError:function(e){console.error(e),document.querySelector("#albumDiv").classList.add("is-hidden"),document.querySelector("#tabs").classList.add("is-hidden"),document.querySelectorAll(".tab-content").forEach((function(e){returne.classList.add("is-hidden")}));vara=document.querySelector("#loginToUpload");if(a.innerText="An error occurred. Try to reload?",a.classList.remove("is-loading"),a.classList.remove("is-hidden"),a.addEventListener("click",(function(){location.reload()})),!e.response)returnpage.onUnexpectedError(e,!0);vart={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,r=e.response.data&&e.response.data.description?e.response.data.description:"Please check the console for more information.";returnswal(e.response.status+" "+t,r,"error")},onUnexpectedError:function(e,a){if(a||console.error(e),e.response)returnswal("An error occurred!","There was an error with the request, please check the console for more information.","error");vart=document.createElement("div");returnt.innerHTML="<code>"+e.toString()+"</code>",swal({title:"An error occurred!",icon:"error",content:t})},checkIfPublic:function(e){vara=!1;returnaxios.get("api/check",{onDownloadProgress:function(){a||"function"!=typeofpage.doRender||(page.doRender(),a=!0)}}).then((function(a){returnpage.private=a.data.private,page.enableUserAccounts=a.data.enableUserAccounts,page.maxSize=parseInt(a.data.maxSize),page.maxSizeBytes=1e6*page.maxSize,page.chunkSize=parseInt(a.data.chunkSize),page.temporaryUploadAges=a.data.temporaryUploadAges,page.fileIdentifierLength=a.data.fileIdentifierLength,page.preparePage(e)})).catch(page.onInitError)},preparePage:function(){if(!page.private)returnpage.prepareUpload();if(page.token)returnpage.verifyToken(page.token,!0);vare=document.querySelector("#loginToUpload");e.href="auth",e.classList.remove("is-loading"),page.enableUserAccounts?e.innerText="Anonymous upload is disabled. Log in to upload.":e.innerText="Running in private mode. Log in to upload."},verifyToken:function(e,a){returnaxios.post("api/tokens/verify",{token:e}).then((function(t){return!1===t.data.success?swal({title:"An error occurred!",text:t.data.description,icon:"error"}).then((function(){a&&(localStorage.removeItem("token"),location.reload())})):(localStorage.token=e,page.token=e,page.prepareUpload())})).catch(page.onInitError)},prepareUpload:function(){page.token&&(document.querySelector("#albumDiv").classList.remove("is-hidden"),page.albumSelect=document.querySelector("#albumSelect"),page.albumSelect.addEventListener("change",(function(){page.album=parseInt(page.albumSelect.value),"function"==typeofpage.prepareShareX&&page.prepareShareX()})),page.fetchAlbums()),page.prepareUploadConfig(),document.querySelector("#maxSize > span").innerHTML=page.getPrettyBytes(page.maxSizeBytes),document.querySelector("#loginToUpload").classList.add("is-hidden"),!page.token&&page.enableUserAccounts&&(document.querySelector("#loginLinkText").innerHTML="Create an account and keep track of your uploads"),page.prepareDropzone(),"function"==typeofpage.prepareShareX&&page.prepareShareX();