import{j as e}from"./vendor-query-BSpUEUJE.js";import{r}from"./vendor-react-CWq2BoMo.js";import{C as m,d,a as N,b,c as v}from"./card-Dd3vXi0j.js";import{B as x,R as g,H as w}from"./index-DVdSf46I.js";import{P as C}from"./progress-DbdJg_K5.js";import{F as S}from"./file-down-CoG2-WQC.js";import{ac as F}from"./Index-CsHtvMhJ.js";import{H as R}from"./hard-drive-C3hNEnQL.js";import"./vendor-pdf-OPq5ZiHo.js";import"./vendor-ui-extra-CW6ezZiQ.js";import"./vendor-ui-core-BWFXPlYg.js";import"./vendor-charts-bmwX1u6y.js";import"./currencyConfig-Ch2cK6at.js";import"./alert-cV8dsncc.js";import"./vendor-barcode-DhT-N8Id.js";function q(){const[s,p]=r.useState(null),[n,o]=r.useState(!0),i=async()=>{o(!0);try{const t=await w();p(t)}catch(t){console.error("Failed to load storage info:",t)}o(!1)};r.useEffect(()=>{i()},[]);const j=()=>{var l;const f="\uFEFF"+[["التقرير","تقرير استخدام التخزين"],["التاريخ",new Date().toLocaleString("ar-SA")],[""],["التخزين"],["المستخدم",(s==null?void 0:s.formattedUsed)||"غير معروف"],["المتاح",(s==null?void 0:s.formattedAvailable)||"غير معروف"],["النسبة",`${((l=s==null?void 0:s.percentUsed)==null?void 0:l.toFixed(1))||0}%`]].map(u=>u.join(",")).join(`
`),h=new Blob([f],{type:"text/csv;charset=utf-8;"}),c=URL.createObjectURL(h),a=document.createElement("a");a.href=c,a.download=`storage-report-${new Date().toISOString().split("T")[0]}.csv`,a.click(),URL.revokeObjectURL(c)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"تقرير استخدام التخزين"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(x,{variant:"outline",size:"sm",onClick:i,disabled:n,children:[e.jsx(g,{className:`h-4 w-4 ml-1 ${n?"animate-spin":""}`}),"تحديث"]}),e.jsxs(x,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(S,{className:"h-4 w-4 ml-1"}),"تصدير"]})]})]}),e.jsx(m,{children:e.jsx(d,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(F,{className:"h-8 w-8 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-lg",children:"نظام Online-First"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"جميع الفواتير تُحفظ مباشرة على السيرفر"})]})]})})}),s&&e.jsxs(m,{children:[e.jsxs(N,{className:"pb-2",children:[e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"مساحة التخزين المحلية"]}),e.jsx(v,{children:"تستخدم للتخزين المؤقت فقط (ملفات CSS، صور، إلخ)"})]}),e.jsxs(d,{children:[e.jsx(C,{value:s.percentUsed,className:"h-3 mb-3"}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:["مستخدم: ",e.jsx("span",{className:"font-medium text-foreground",children:s.formattedUsed})]}),e.jsxs("span",{className:"text-muted-foreground",children:["متاح: ",e.jsx("span",{className:"font-medium text-foreground",children:s.formattedAvailable})]})]}),e.jsxs("div",{className:"mt-2 text-center",children:[e.jsxs("span",{className:"text-2xl font-bold",children:[s.percentUsed.toFixed(1),"%"]}),e.jsx("span",{className:"text-sm text-muted-foreground mr-1",children:"مستخدم"})]})]})]})]})}export{q as OfflineSyncReport};
