window.addEventListener(`message`,e=>{let t=document.getElementById(`asset`),n=document.getElementById(`exit`),r=document.getElementById(`confirm`),i=document.getElementById(`progress`),a=e.ports[0];a.onmessage=e=>{if(typeof e.data==`object`&&`isFocused`in e.data){Array.from(document.getElementsByTagName(`button`)).forEach(t=>{e.data.isFocused?t.classList.remove(`blurred`):t.classList.add(`blurred`)});return}};function o(){if(t.files!==null&&t.files.length>0){i.innerText=`Uploading file...`;let e=new XMLHttpRequest,n=new FormData;e.open(`POST`,`../uploadAsset`,!0),e.onloadend=()=>{e.status===200?a.postMessage(null):i.innerText=e.statusText.length>0?`Upload failed: ${e.statusText}`:`Upload failed`},n.append(`file`,t.files[0]),e.send(n)}else a.postMessage(null)}n.addEventListener(`click`,()=>{a.postMessage(null)}),r.addEventListener(`click`,o),window.addEventListener(`keydown`,e=>{e.code===`Enter`&&o()})});