class UploadAdapter{constructor(e){this.loader=e}upload(){return this.loader.file.then(e=>{let r=new FormData;return r.append("image",e),fetch(config.url+"/image/upload",{method:"POST",headers:{"X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},body:r}).then(e=>e.ok?e.json():e.json().then(e=>{throw Error(e.error)})).then(e=>{if(e.uploaded)return e;throw Error("Failed to upload the image")})}).catch(e=>{throw console.error(e),e})}abort(){this.xhr&&this.xhr.abort()}response(){return{default:this.default}}destroy(){this.xhr&&(this.xhr.removeEventListener("abort",this._boundAbort),this.xhr.removeEventListener("error",this._boundError),this.xhr.removeEventListener("load",this._boundLoad),this.xhr.removeEventListener("progress",this._boundProgress),this.xhr=null)}}