var p=(d,c,o)=>new Promise((r,e)=>{var a=t=>{try{s(o.next(t))}catch(n){e(n)}},i=t=>{try{s(o.throw(t))}catch(n){e(n)}},s=t=>t.done?r(t.value):Promise.resolve(t.value).then(a,i);s((o=o.apply(d,c)).next())});import{j as m,bh as w}from"./react-vendor-xYZnmIII.js";import{B as u}from"./ui-components-CQM92IK3.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./interactive-vendor-B1OgcAgP.js";const j=({backup:d})=>{const c=o=>p(null,null,function*(){var r;try{const e=document.getElementById(`download-btn-${o}`);e&&(e.innerHTML='<span class="animate-spin mr-1">↻</span> Downloading...');const a=yield fetch(`/system/backup/${o}/download`,{method:"GET",headers:{Accept:"application/zip","X-Requested-With":"XMLHttpRequest","X-CSRF-TOKEN":((r=document.querySelector('meta[name="csrf-token"]'))==null?void 0:r.getAttribute("content"))||""}});if(!a.ok)throw new Error("Download failed");const i=a.headers.get("content-disposition"),s=i?i.split("filename=")[1].replace(/"/g,""):`backup_${o}.zip`,t=yield a.blob(),n=window.URL.createObjectURL(t),l=document.createElement("a");l.href=n,l.download=s,document.body.appendChild(l),l.click(),window.URL.revokeObjectURL(n),document.body.removeChild(l)}catch(e){alert("Failed to download backup. Please try again.")}finally{const e=document.getElementById(`download-btn-${o}`);e&&(e.innerHTML='<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"/></svg><span class="ml-1">Download</span>')}});return m.jsxs(u,{id:`download-btn-${d.id}`,variant:"ghost",onClick:()=>c(d.id),children:[m.jsx(w,{className:"h-4 w-4"}),m.jsx("span",{className:"text-sm",children:"Download"})]})};export{j as default};
