1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/export-jobs.functions-BidlUpuA.js","assets/index-Byr3-ZG9.js"])))=>i.map(i=>d[i]); 2import{t as h,e as P,l as k,f as N,r as x,u as m,j as e,aJ as he,aK as fe,aL as ge,aM as je,aN as K,B as R,L as be,by as te,_ as le}from"./index-Byr3-ZG9.js";import{u as C}from"./useQuery-BBjG80V5.js";import{u as S}from"./useServerFn-B7pgqgaZ.js";import{u as ye}from"./workspace-provider-CKzCVHUV.js";import{P as ve,S as p,D as we}from"./page-header-BZJsL8cv.js";import{P as T}from"./loading-state-B_8zYixL.js";import{E as Pe}from"./empty-state-1uGAgBNe.js";import{C as f,b as v,c as w,a as g}from"./card-D-hti0MG.js";import{T as ke,a as Ne,b as j,c as b}from"./tabs-DnnvGKhX.js";import{T as Se,a as Ce,b as re,c as Te,d as Fe,e as Ke}from"./table-CsyKMT9W.js";import{D as Ee,a as Re,b as De,e as q}from"./dropdown-menu-DAjk-uLk.js";import{b as Be}from"./format-BN-xHBis.js";import{y as G,s as B,R as y,C as Y,a as E,b as z,P as _e,c as Ie,d as Le,e as Oe}from"./chart-theme-CpYmwPZ5.js";import{d as Me}from"./csv-Np-eVIM4.js";import{triggerDownload as $,isMobileBrowser as $e}from"./download-CXPzt36x.js";import{C as ae}from"./chart-column-DQhHhONi.js";import{T as ie}from"./trending-up-6OOdb5Mz.js";import{S as ce}from"./shopping-cart-tAY4Hrq4.js";import{P as de}from"./package-C9gH5z6Q.js";import{U as pe}from"./users-BkyksqG3.js";import{M as Ae}from"./message-square-DBm5fvMC.js";import{T as V}from"./truck-DWBtfibm.js";import{U as qe}from"./user-cog-B5C3hpKe.js";import{D as Q}from"./download-BXEyqv_I.js";import{F as Z}from"./file-text-D4-wdKEF.js";import{F as ee,a as se}from"./file-spreadsheet-BtKe6lPy.js";import{R as _,C as L,X as O,Y as M,T as I,B as J,q as oe,r as Ye}from"./generateCategoricalChart-C6ihGV1D.js";import{A as ze,a as He}from"./AreaChart-D88cTxtT.js";import{B as X}from"./BarChart-BNf1-8PY.js";import{C as me}from"./circle-x-DoLKTbrE.js";import{T as Ue}from"./triangle-alert-DO2lXNOD.js";import{I as We}from"./inbox-DGRnT3ZY.js";import{L as Ge}from"./loader-circle-1xwwrGn4.js";import{R as Ve}from"./refresh-cw-DOEiQdEE.js";import{C as Je}from"./circle-check-B4IvvZS4.js";import"./useBaseQuery-BzlRu7Qh.js";import"./permissions-oI9sGaZQ.js";import"./skeleton-DVgDTlom.js";import"./index-yAdIqc92.js";import"./index-DRgLYt68.js";import"./index-BdrRkcsb.js";import"./index-D-YBli6d.js";import"./index-CH519oRz.js";import"./chevron-right-81HbrJ12.js";import"./circle-CWrBtUtn.js";import"./workspace-formatting-pTwaF40f.js";import"./locations-0Wdef19u.js";function Xe(s,o){if(o.length===0){h.error("No data to export");return}const a=Array.from(o.reduce((i,c)=>(Object.keys(c).forEach(d=>i.add(d)),i),new Set)),r=i=>String(i??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),t=`<tr>${a.map(i=>`<th style="background:#f3f4f6;border:1px solid #e5e7eb;padding:6px;text-align:left;font-family:Arial">${r(i)}</th>`).join("")}</tr>`,n=o.map(i=>`<tr>${a.map(c=>`<td style="border:1px solid #e5e7eb;padding:6px;font-family:Arial">${r(i[c])}</td>`).join("")}</tr>`).join(""),l=`<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="utf-8"></head><body><table>${t}${n}</table></body></html>`;$(s,new Blob([l],{type:"application/vnd.ms-excel"}))}function ne(s,o,a){const r=l=>String(l??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),t=l=>{if(l.length===0)return'<p style="color:#888">No data</p>';const i=Array.from(l.reduce((c,d)=>(Object.keys(d).forEach(A=>c.add(A)),c),new Set));return`<table><thead><tr>${i.map(c=>`<th>${r(c)}</th>`).join("")}</tr></thead><tbody>${l.map(c=>`<tr>${i.map(d=>`<td>${r(c[d])}</td>`).join("")}</tr>`).join("")}</tbody></table>`},n=a?"<script>window.onload=()=>{setTimeout(()=>window.print(),250)}<\/script>":'<div class="hint">Tap the browser menu and choose <b>Print</b> or <b>Save as PDF</b> to download.</div>';return`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${r(s)}</title> 3<style> 4 body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Arial,sans-serif;color:#111;padding:24px;font-size:12px;margin:0} 5 h1{font-size:22px;margin:0 0 4px} 6 h2{font-size:14px;margin:20px 0 8px;border-bottom:1px solid #e5e7eb;padding-bottom:4px} 7 table{border-collapse:collapse;width:100%;margin-top:8px;font-size:11px} 8 th,td{border:1px solid #e5e7eb;padding:6px 8px;text-align:left;vertical-align:top} 9 th{background:#f9fafb;font-weight:600} 10 .meta{color:#6b7280;font-size:11px;margin-bottom:12px} 11 .hint{position:sticky;top:0;background:#fef3c7;border:1px solid #fde68a;color:#78350f;padding:8px 12px;border-radius:6px;margin-bottom:12px;font-size:12px} 12 @media print { body{padding:12px} .hint{display:none} } 13</style></head><body> 14${n} 15<h1>${r(s)}</h1> 16<div class="meta">
16Generated ${new Date().toLocaleString()}</div> 17${o.map(l=>`<h2>${r(l.title)}</h2>${t(l.rows)}`).join("")} 18</body></html>`}function Qe(s,o){try{if($e()){const n=ne(s,o,!1),l=new Blob([n],{type:"text/html;charset=utf-8"});$(`${s.replace(/\s+/g,"-")}.html`,l),h.message("Open the file and tap Share â Print â Save as PDF");return}const r=ne(s,o,!0),t=window.open("","_blank");if(!t){const n=new Blob([r],{type:"text/html;charset=utf-8"});$(`${s.replace(/\s+/g,"-")}.html`,n);return}t.document.open(),t.document.write(r),t.document.close(),h.success("Opening PDF preview")}catch(a){console.error("[export] pdf failed",a),h.error("Could not export PDF")}}function H(s,o,a){if(!a||a.length===0){h.error("No data to export");return}try{return s==="csv"?Me(`${o}.csv`,a):s==="xlsx"?Xe(`${o}.xls`,a):Qe(o,[{title:o,rows:a}])}catch(r){console.error("[export] section failed",{format:s,filename:o,err:r}),h.error("Export failed")}}const Ze=P({method:"POST"}).middleware([k]).handler(N("e4f381b03a3740a620fc880c0bba35e07571dd8e77de9cc7e7de68caa696f18b")),es=P({method:"POST"}).middleware([k]).handler(N("5624239a300ce8263a00213304626f9c2c9ceafc7563411ef2821022681001f1")),ss=P({method:"POST"}).middleware([k]).handler(N("f617ba6f438ebf9274b6e46b32f8753a43d3fda7541a96849b34914fce52c328")),ts=P({method:"POST"}).middleware([k]).handler(N("299ea95b46d03d3881c63bfddc0837c0124ffd944d01af4bfe53da81b17f19ae")),rs=P({method:"POST"}).middleware([k]).handler(N("b563a77e99d8063694bf26a6faea12f167c4ef308601d88bef9daf58f39ffe06")),as=P({method:"POST"}).middleware([k]).handler(N("1c1c484d6de0ad4440264a64061016b8134ccb72acd995752b524dafbc0fc285")),os=P({method:"POST"}).middleware([k]).handler(N("1b3585d5c9288fc998d86ef6621eedc13457d4edb7a5ec0f004f73079801fc5a"));function ns(s,o,a=new Date){const r=G(a,o);switch(s){case"today":return{fromYmd:r,toYmd:r,preset:s};case"yesterday":{const t=B(r,-1);return{fromYmd:t,toYmd:t,preset:s}}case"7d":return{fromYmd:B(r,-6),toYmd:r,preset:s};case"30d":return{fromYmd:B(r,-29),toYmd:r,preset:s};case"90d":return{fromYmd:B(r,-89),toYmd:r,preset:s};case"mtd":return{fromYmd:r.slice(0,7)+"-01",toYmd:r,preset:s};case"ytd":return{fromYmd:r.slice(0,4)+"-01-01",toYmd:r,preset:s}}}const ls=P({method:"POST"}).middleware([k]).handler(N("b00576b0a30ce7e1adf1e33a31ebc18748b33e9579d327368214126bd7fbd4c2")),is={forbidden:"You do not have access to this workspace."};function cs(s){const o=s instanceof Error?s.message:String(s??"");return is[o]??"Could not prepare this export. Please try again."}function U(){const[s,o]=x.useState("idle"),[a,r]=x.useState(null),t=x.useRef(null),n=x.useRef(!1),l=x.useCallback(async d=>{if(!n.current){n.current=!0,t.current=d,o("preparing"),r(null);try{await d(),o("success")}catch(A){r(cs(A)),o("error")}finally{n.current=!1}}},[]),i=x.useCallback(async()=>{const d=t.current;d&&await l(d)},[l]),c=x.useCallback(()=>{o("idle"),r(null)},[]);return{state:s,error:a,run:l,retry:i,reset:c}}function ds(s,o){const a=new Date;if(s==="this_month"){const n=G(a,o);return{from:n.slice(0,7)+"-01",to:n}}if(s==="last_month"){const l=G(a,o).slice(0,7)+"-01",i=B(l,-1);return{from:i.slice(0,7)+"-01",to:i}}const t=ns(s==="7d"?"7d":s==="30d"?"30d":s==="90d"?"90d":"ytd",o,a);return{from:t.fromYmd,to:t.toYmd}}function D(s){return`${(s*100).toFixed(1)}%`}function ps(){const{currentWorkspace:s}=ye(),[o,a]=x.useState("90d"),r=x.useMemo(()=>ds(o,s?.timezone??null),[o,s?.timezone]),t=s?{workspaceId:s.id,from:r.from,to:r.to}:null;return{currentWorkspace:s,preset:o,setPreset:a,input:t}}function Nt(){const{t:s}=m(),{currentWorkspace:o,preset:a,setPreset:r,input:t}=ps(),[n,l]=x.useState("sales"),i=o?.currency??"USD",c=d=>Be(d,i);return o?e.jsxs("div",{className:"space-y-6",children:[e.jsx(ve,{title:s("reportsPage.title"),description:s("reportsPage.description"),icon:e.jsx(ae,{className:"h-5 w-5"}),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(he,{value:a,onValueChange:d=>r(d),children:[e.jsx(fe,{className:"w-[150px]",children:e.jsx(ge,{})}),e.jsxs(je,{children:[e.jsx(K,{value:"7d",children:s("reportsPage.presets.7d")}),e.jsx(K,{value:"30d",children:s("reportsPage.presets.30d")}),e.jsx(K,{value:"90d",children:s("reportsPage.presets.90d")}),e.jsx(K,{value:"this_month",children:s("reportsPage.presets.this_month")}),e.jsx(K,{value:"last_month",children:s("reportsPage.presets.last_month")}),e.jsx(K,{value:"ytd",children:s("reportsPage.presets.ytd")})]})]}),t&&e.jsx(Es,{input:t,preset:a,fm:c})]})}),e.jsxs(ke,{value:n,onValueChange:d=>l(d),className:"space-y-4",children:[e.jsx("div",{className:"-mx-1 overflow-x-auto sm:mx-0 sm:overflow-visible",children:e.jsxs(Ne,{className:"inline-flex h-auto w-max min-w-full flex-nowrap whitespace-nowrap sm:flex sm:w-auto
18sm:flex-wrap",children:[e.jsxs(j,{value:"sales",children:[e.jsx(ie,{className:"h-4 w-4 mr-1.5 rtl-flip"}),s("reportsPage.tabs.sales")]}),e.jsxs(j,{value:"orders",children:[e.jsx(ce,{className:"h-4 w-4 mr-1.5 rtl-flip"}),s("reportsPage.tabs.orders")]}),e.jsxs(j,{value:"products",children:[e.jsx(de,{className:"h-4 w-4 mr-1.5 rtl-flip"}),s("reportsPage.tabs.products")]}),e.jsxs(j,{value:"customers",children:[e.jsx(pe,{className:"h-4 w-4 mr-1.5 rtl-flip"}),s("reportsPage.tabs.customers")]}),e.jsxs(j,{value:"channels",children:[e.jsx(Ae,{className:"h-4 w-4 mr-1.5 rtl-flip"}),s("reportsPage.tabs.channels")]}),e.jsxs(j,{value:"fulfillment",children:[e.jsx(V,{className:"h-4 w-4 mr-1.5 rtl-flip"}),s("reportsPage.tabs.fulfillment")]}),e.jsxs(j,{value:"team",children:[e.jsx(qe,{className:"h-4 w-4 mr-1.5 rtl-flip"}),s("reportsPage.tabs.team")]}),e.jsxs(j,{value:"export",children:[e.jsx(Q,{className:"h-4 w-4 mr-1.5 rtl-flip"}),s("reportsPage.tabs.exportCenter")]})]})}),n==="sales"&&t&&e.jsx(b,{value:"sales",className:"space-y-4",children:e.jsx(ms,{input:t,preset:a,fm:c})}),n==="orders"&&t&&e.jsx(b,{value:"orders",className:"space-y-4",children:e.jsx(us,{input:t,preset:a,fm:c})}),n==="products"&&t&&e.jsx(b,{value:"products",className:"space-y-4",children:e.jsx(xs,{input:t,preset:a,fm:c})}),n==="customers"&&t&&e.jsx(b,{value:"customers",className:"space-y-4",children:e.jsx(hs,{input:t,preset:a,fm:c})}),n==="channels"&&t&&e.jsx(b,{value:"channels",className:"space-y-4",children:e.jsx(fs,{input:t,preset:a,fm:c})}),n==="fulfillment"&&t&&e.jsx(b,{value:"fulfillment",className:"space-y-4",children:e.jsx(gs,{input:t,preset:a})}),n==="team"&&t&&e.jsx(b,{value:"team",className:"space-y-4",children:e.jsx(js,{input:t,preset:a,fm:c})}),n==="export"&&t&&e.jsx(b,{value:"export",className:"space-y-4",children:e.jsx(Ks,{input:t,preset:a,fm:c})})]})]}):e.jsx(Pe,{icon:ae,title:s("reportsPage.noWorkspaceTitle"),description:s("reportsPage.noWorkspaceDesc")})}function ms({input:s,preset:o,fm:a}){const r=S(Ze),{data:t,isLoading:n,error:l}=C({queryKey:["reports","sales",s.workspaceId,o],queryFn:async()=>await r({data:s}),staleTime:6e4});return n||!t?e.jsx(T,{}):l?e.jsx(F,{err:l}):e.jsx(bs,{d:t,fm:a})}function us({input:s,preset:o,fm:a}){const r=S(es),{data:t,isLoading:n,error:l}=C({queryKey:["reports","orders",s.workspaceId,o],queryFn:async()=>await r({data:s}),staleTime:6e4});return n||!t?e.jsx(T,{}):l?e.jsx(F,{err:l}):e.jsx(ys,{d:t,fm:a})}function xs({input:s,preset:o,fm:a}){const r=S(ss),{data:t,isLoading:n,error:l}=C({queryKey:["reports","products",s.workspaceId,o],queryFn:async()=>await r({data:s}),staleTime:6e4});return n||!t?e.jsx(T,{}):l?e.jsx(F,{err:l}):e.jsx(vs,{d:t,fm:a})}function hs({input:s,preset:o,fm:a}){const r=S(ts),{data:t,isLoading:n,error:l}=C({queryKey:["reports","customers",s.workspaceId,o],queryFn:async()=>await r({data:s}),staleTime:6e4});return n||!t?e.jsx(T,{}):l?e.jsx(F,{err:l}):e.jsx(ws,{d:t,fm:a})}function fs({input:s,preset:o,fm:a}){const r=S(rs),{data:t,isLoading:n,error:l}=C({queryKey:["reports","channels",s.workspaceId,o],queryFn:async()=>await r({data:s}),staleTime:6e4});return n||!t?e.jsx(T,{}):l?e.jsx(F,{err:l}):e.jsx(Ps,{d:t,fm:a})}function gs({input:s,preset:o}){const a=S(as),{data:r,isLoading:t,error:n}=C({queryKey:["reports","fulfillment",s.workspaceId,o],queryFn:async()=>await a({data:s}),staleTime:6e4});return t||!r?e.jsx(T,{}):n?e.jsx(F,{err:n}):e.jsx(ks,{d:r})}function js({input:s,preset:o,fm:a}){const r=S(os),{data:t,isLoading:n,error:l}=C({queryKey:["reports","team",s.workspaceId,o],queryFn:async()=>await r({data:s}),staleTime:6e4});return n||!t?e.jsx(T,{}):l?e.jsx(F,{err:l}):e.jsx(Ns,{d:t,fm:a})}function F({err:s}){const{t:o}=m();return e.jsx(f,{children:e.jsxs(g,{className:"p-6 text-sm text-destructive",children:[o("reportsPage.table.noDataInRange"),e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:s?.message??String(s)})]})})}function bs({d:s,fm:o}){const{t:a}=m(),r=t=>a(`reportsPage.cols.${t}`);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(p,{label:a("reportsPage.kpi.totalRevenue"),value:o(s.totalRevenue),icon:e.jsx(ie,{className:"h-4 w-4"})}),e.jsx(p,{label:a("reportsPage.kpi.totalOrders"),value:s.totalOrders.toLocaleStr
18ing(),icon:e.jsx(ce,{className:"h-4 w-4"})}),e.jsx(p,{label:a("reportsPage.kpi.aov"),value:o(s.aov)}),e.jsx(p,{label:a("reportsPage.kpi.categoriesSold"),value:s.revenueByCategory.length})]}),e.jsxs(f,{children:[e.jsx(v,{children:e.jsx(w,{className:"text-base",children:a("reportsPage.sections.revenueTrend")})}),e.jsx(g,{className:"h-[280px]",children:e.jsx(_,{width:"100%",height:"100%",children:e.jsxs(ze,{data:s.revenueSeries,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"rev",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:y.start,stopOpacity:.4}),e.jsx("stop",{offset:"100%",stopColor:y.end,stopOpacity:.02})]}),e.jsxs("linearGradient",{id:"revStroke",x1:"0",y1:"0",x2:"1",y2:"0",children:[e.jsx("stop",{offset:"0%",stopColor:y.start}),e.jsx("stop",{offset:"50%",stopColor:y.mid}),e.jsx("stop",{offset:"100%",stopColor:y.end})]})]}),e.jsx(L,{strokeDasharray:"3 3",stroke:Y}),e.jsx(O,{dataKey:"date",tick:E}),e.jsx(M,{tick:E}),e.jsx(I,{contentStyle:z,formatter:t=>o(t)}),e.jsx(He,{type:"monotone",dataKey:"revenue",stroke:"url(#revStroke)",strokeWidth:2.5,fill:"url(#rev)",activeDot:{r:5,fill:y.mid,stroke:"#fff",strokeWidth:2}})]})})})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs(f,{children:[e.jsx(v,{children:e.jsx(w,{className:"text-base",children:a("reportsPage.sections.revenueByWeek")})}),e.jsx(g,{className:"h-[260px]",children:e.jsx(_,{width:"100%",height:"100%",children:e.jsxs(X,{data:s.revenueByWeek,children:[e.jsx(L,{strokeDasharray:"3 3",stroke:Y}),e.jsx(O,{dataKey:"period",tick:E}),e.jsx(M,{tick:E}),e.jsx(I,{contentStyle:z,formatter:t=>o(t)}),e.jsx(J,{dataKey:"revenue",fill:y.start,radius:[6,6,0,0]})]})})})]}),e.jsxs(f,{children:[e.jsx(v,{children:e.jsx(w,{className:"text-base",children:a("reportsPage.sections.revenueByMonth")})}),e.jsx(g,{className:"h-[260px]",children:e.jsx(_,{width:"100%",height:"100%",children:e.jsxs(X,{data:s.revenueByMonth,children:[e.jsx(L,{strokeDasharray:"3 3",stroke:Y}),e.jsx(O,{dataKey:"period",tick:E}),e.jsx(M,{tick:E}),e.jsx(I,{contentStyle:z,formatter:t=>o(t)}),e.jsx(J,{dataKey:"revenue",fill:y.end,radius:[6,6,0,0]})]})})})]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(u,{title:a("reportsPage.sections.revenueByProduct"),rows:s.revenueByProduct.map(t=>({[r("product")]:t.name,[r("sku")]:t.sku??"â",[r("qtySold")]:t.qty,[r("revenue")]:o(t.revenue)})),exportName:"revenue-by-product"}),e.jsx(u,{title:a("reportsPage.sections.revenueByCategory"),rows:s.revenueByCategory.map(t=>({[r("category")]:t.category,[r("qtySold")]:t.qty,[r("revenue")]:o(t.revenue)})),exportName:"revenue-by-category"})]})]})}function ys({d:s,fm:o}){const{t:a}=m(),r=t=>a(`reportsPage.cols.${t}`);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(p,{label:a("reportsPage.kpi.aov"),value:o(s.aov)}),e.jsx(p,{label:a("reportsPage.kpi.cancellationRate"),value:D(s.cancellationRate),icon:e.jsx(me,{className:"h-4 w-4"})}),e.jsx(p,{label:a("reportsPage.kpi.returnRate"),value:D(s.returnRate)}),e.jsx(p,{label:a("reportsPage.kpi.totalOrders"),value:s.totalOrders.toLocaleString()})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs(f,{children:[e.jsx(v,{children:e.jsx(w,{className:"text-base",children:a("reportsPage.sections.ordersByStatus")})}),e.jsx(g,{className:"h-[280px]",children:e.jsx(_,{width:"100%",height:"100%",children:e.jsxs(_e,{children:[e.jsx(Ie,{data:s.ordersByStatus,dataKey:"count",nameKey:"status",cx:"50%",cy:"50%",outerRadius:90,label:!0,children:s.ordersByStatus.map((t,n)=>e.jsx(oe,{fill:Le(t.status)},n))}),e.jsx(Ye,{wrapperStyle:{fontSize:11}}),e.jsx(I,{})]})})})]}),e.jsxs(f,{children:[e.jsx(v,{children:e.jsx(w,{className:"text-base",children:a("reportsPage.sections.ordersByChannel")})}),e.jsx(g,{className:"h-[280px]",children:e.jsx(_,{width:"100%",height:"100%",children:e.jsxs(X,{data:s.ordersByChannel,children:[e.jsx(L,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e.jsx(O,{dataKey:"channel",tick:{fontSize:11}}),e.jsx(M,{tick:{fontSize:11}}),e.jsx(I,{}),e.jsx(J,{dataKey:"count",radius:[4,4,0,0],children:s.ordersByChannel.map((t,n)=>e.jsx(oe,{fill:Oe(t.channel)},n))})]})})})]})]}),e.jsx(u,{title:a("reportsPage.sections.ordersByStatusBreakdown"),rows:s.ordersByStatus.map(t=>({[r("status")]:t.status,[r("count")]:t.count,[r("revenue")]:o(t.revenue)})),exportName:"orders-by-status"})]})}function vs({d:s,fm:o}){const{t:a}=m(),r=t=>a(`reportsPage.cols.${t}`);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(p,{label:a("reportsPage.kpi.bestSellers"),value:s.bestSelling.length}),e.jsx(p,{label:a("reportsPage.kpi.slowMoving"),value:s.slowMoving.length}),e.jsx(p,{label:a("reportsPage.kpi.lowStock"),value:s.lowStock.length,icon:e.jsx(Ue,{className:"h-4 w-4 text-amber-500"})}),e.jsx(p,{label:a("reportsPage.kpi.outOfStock"),value:s.outOfStock.length,icon:e.jsx(me,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(u,{title:a("reportsPage.sections.bestSellingProducts"),rows:s.bestSelling.map(t=>({[r("product")]:t.name,[r("sku")]:t.sku??"â",[r("qty")]:t.qty,[r("revenue")]:o(t.revenue)})),exportName:"best-sellers"}),e.jsx(u,{title:a("reportsPage.sections.slowMovingProducts"),rows:s.slowMoving.map(t=>({[r("product")]:t.name,[r("sku")]:t.sku??"â",[r("onHand")]:t.on_hand,[r("sold")]:t.qty})),exportName:"slow-moving"}),e.jsx(u,{title:a("reportsPage.sections.lowStock"),rows:s.lowStock.map(t=>({[r("product")]:t.name,[r("sku")]:t.sku??"â",[r("onHand")]:t.on_hand,[r("reorderAt")]:t.reorder_point})),exportName:"low-stock"}),e.jsx(u,{title:a("reportsPage.sections.outOfStock"),rows:s.outOfStock.map(t=>({[r("product")]:t.name,[r("sku")]:t.sku??"â",[r("warehouse")]:t.warehouse??"â"})),exportName:"out-of-stock"})]})]})}function ws({d:s,fm:o}){const{t:a}=m(),r=t=>a(`reportsPage.cols.${t}`);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(p,{label:a("reportsPage.kpi.newCustomers"),value:s.newCustomers,icon:e.jsx(pe,{className:"h-4 w-4"})}),e.jsx(p,{label:a("reportsPage.kpi.returningCustomers"),value:s.returningCustomers}),e.jsx(p,{label:a("reportsPage.kpi.repeatPurchaseRate"),value:D(s.repeatPurchaseRate)}),e.jsx(p,{label:a("reportsPage.kpi.avgClv"),value:o(s.avgClv)})]}),e.jsx(u,{title:a("reportsPage.sections.topCustomers"),rows:s.topCustomers.map(t=>({[r("customer")]:t.name??"â",[r("orders")]:t.orders,[r("revenue")]:o(t.revenue)})),exportName:"top-customers"})]})}function Ps({d:s,fm:o}){const{t:a}=m(),r=l=>a(`reportsPage.cols.${l}`),t=[{name:a("reportsPage.funnel.messages"),value:s.funnel.messages},{name:a("reportsPage.funnel.interested"),value:s.funnel.interested},{name:a("reportsPage.funnel.orderCreated"),value:s.funnel.orderCreated},{name:a("reportsPage.funnel.confirmed"),value:s.funnel.confirmed},{name:a("reportsPage.funnel.delivered"),value:s.funnel.delivered}],n=Math.max(1,...t.map(l=>l.value));return e.jsxs(e.Fragment,{children:[e.jsxs(f,{children:[e.jsx(v,{children:e.jsx(w,{className:"text-base",children:a("reportsPage.sections.conversionFunnel")})}),e.jsx(g,{className:"space-y-2.5",children:t.map((l,i)=>{const c=l.value/n*100,d=i>0&&t[i-1].value?l.value/t[i-1].value*100:null;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"font-medium",children:l.name}),e.jsxs("span",{className:"tabular-nums",children:[l.value.toLocaleStr
18ing(),d!==null&&e.jsxs("span",{className:"text-muted-foreground ms-2 text-xs",children:["(",d.toFixed(1),"%)"]})]})]}),e.jsx("div",{className:"h-7 rounded-md bg-muted overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary/80 transition-all",style:{width:`${c}%`}})})]},l.name)})})]}),e.jsx(u,{title:a("reportsPage.sections.channelPerformance"),rows:s.channelPerformance.map(l=>({[r("channel")]:l.channel,[r("conversations")]:l.conversations,[r("orders")]:l.orders,[r("revenue")]:o(l.revenue),[r("aov")]:o(l.aov),[r("convRate")]:D(l.conversionRate)})),exportName:"channel-performance"})]})}function ks({d:s}){const{t:o}=m(),a=n=>o(`reportsPage.cols.${n}`),r=s.fulfillment,t=[{label:o("reportsPage.stages.pending"),value:r.pending,color:"#f59e0b",icon:We},{label:o("reportsPage.stages.processing"),value:r.processing,color:"#8b5cf6",icon:de},{label:o("reportsPage.stages.shipped"),value:r.shipped,color:"#06b6d4",icon:V},{label:o("reportsPage.stages.delivered"),value:r.delivered,color:"#10b981",icon:V}];return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:t.map(n=>e.jsxs("div",{className:"rounded-xl border bg-card p-5 shadow-xs",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:n.label}),e.jsx(n.icon,{className:"h-4 w-4",style:{color:n.color}})]}),e.jsx("div",{className:"mt-2 text-2xl font-semibold tabular-nums",children:n.value})]},n.label))}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(p,{label:o("reportsPage.kpi.deliverySuccessRate"),value:D(r.successRate),hint:o("reportsPage.kpi.deliveryHint",{delivered:r.delivered,total:s.totalOrders})}),e.jsx(p,{label:o("reportsPage.kpi.avgShippingTime"),value:r.avgShippingDays!==null?o("reportsPage.kpi.daysUnit",{n:r.avgShippingDays}):"â",hint:o("reportsPage.kpi.fromConfirmedToDelivered")})]}),e.jsx(u,{title:o("reportsPage.sections.fulfillmentSummary"),rows:[{[a("stage")]:o("reportsPage.stages.pending"),[a("orders")]:r.pending},{[a("stage")]:o("reportsPage.stages.processing"),[a("orders")]:r.processing},{[a("stage")]:o("reportsPage.stages.shipped"),[a("orders")]:r.shipped},{[a("stage")]:o("reportsPage.stages.delivered"),[a("orders")]:r.delivered},{[a("stage")]:o("reportsPage.stages.cancelled"),[a("orders")]:r.cancelled},{[a("stage")]:o("reportsPage.stages.returned"),[a("orders")]:r.returned}],exportName:"fulfillment"})]})}function Ns({d:s,fm:o}){const{t:a}=m(),r=t=>a(`reportsPage.cols.${t}`);return e.jsx(u,{title:a("reportsPage.sections.teamPerformance"),rows:s.team.map(t=>({[r("agent")]:t.name,[r("orders")]:t.orders,[r("revenue")]:o(t.revenue),[r("conversations")]:t.conversations,[r("avgResponse")]:t.avgResponseMinutes!==null?a("reportsPage.kpi.minUnit",{n:t.avgResponseMinutes}):"â",[r("convRate")]:D(t.conversionRate)})),exportName:"team-performance"})}const ue=[{sectionKey:"revenue-daily",titleKey:"reportsPage.datasets.revenueDaily"},{sectionKey:"revenue-weekly",titleKey:"reportsPage.datasets.revenueWeekly"},{sectionKey:"revenue-monthly",titleKey:"reportsPage.datasets.revenueMonthly"},{sectionKey:"revenue-by-product",titleKey:"reportsPage.datasets.revenueByProduct"},{sectionKey:"revenue-by-category",titleKey:"reportsPage.datasets.revenueByCategory"},{sectionKey:"orders-by-status",titleKey:"reportsPage.datasets.ordersByStatus"},{sectionKey:"orders-by-channel",titleKey:"reportsPage.datasets.ordersByChannel"},{sectionKey:"best-sellers",titleKey:"reportsPage.datasets.bestSellers"},{sectionKey:"slow-moving",titleKey:"reportsPage.datasets.slowMoving"},{sectionKey:"low-stock",titleKey:"reportsPage.datasets.lowStock"},{sectionKey:"out-of-stock",titleKey:"reportsPage.datasets.outOfStock"},{sectionKey:"top-customers",titleKey:"reportsPage.datasets.topCustomers"},{sectionKey:"channel-performance",titleKey:"reportsPage.datasets.channelPerformance"},{sectionKey:"team-performance",titleKey:"reportsPage.datasets.teamPerformance"},{sectionKey:"fulfillment-summary",titleKey:"reportsPage.datasets.fulfillmentSummary"}],Ss="This export is too large for instant generation. Backgroun
18d exports are being prepared and will be available in a coming update.";function Cs(s,o){const a=atob(s),r=new Uint8Array(a.length);for(let t=0;t<a.length;t++)r[t]=a.charCodeAt(t);return new Blob([r],{type:o})}async function xe(s){const{getExportJobFn:o,getExportDownloadUrlFn:a}=await le(async()=>{const{getExportJobFn:n,getExportDownloadUrlFn:l}=await import("./export-jobs.functions-BidlUpuA.js");return{getExportJobFn:n,getExportDownloadUrlFn:l}},__vite__mapDeps([0,1])),r=Date.now()+300*1e3;let t=2e3;for(;Date.now()<r;){const n=await o({data:s});if(n.status==="ready"){const l=await a({data:s}),i=document.createElement("a");i.href=l.url,i.download=l.fileName,i.rel="noopener",document.body.appendChild(i),i.click(),i.remove();return}if(n.status==="failed"||n.status==="cancelled"||n.status==="expired")throw new Error(`export_${n.status}:${n.error??""}`);await new Promise(l=>setTimeout(l,t)),t=Math.min(t+1e3,6e3)}throw new Error("export_timeout")}async function Ts(s,o){const a=await s({data:o});if(a.status==="deferred"){h.message(Ss);return}if(a.status==="enqueued"){h.message("Preparing your export â this will download shortly."),await xe({jobId:a.jobId,workspaceId:o.workspaceId});return}const r=Cs(a.base64,a.mime);$(a.fileName,r)}function W({action:s,icon:o,label:a,onClick:r}){const t=s.state==="preparing";return e.jsxs(R,{size:"sm",variant:"outline",onClick:r,disabled:t,"aria-busy":t,title:s.state==="error"?s.error??void 0:void 0,children:[t?e.jsx(Ge,{className:"h-4 w-4 mr-1.5 animate-spin"}):s.state==="error"?e.jsx(Ve,{className:"h-4 w-4 mr-1.5 rtl-flip"}):s.state==="success"?e.jsx(Je,{className:"h-4 w-4 mr-1.5 text-green-600"}):o,s.state==="error"?"Retry":a]})}function Fs({spec:s,input:o,t:a,runFn:r}){const t=U(),n=U(),l=U(),i=(c,d)=>{if(d.state==="error"){d.retry();return}d.run(()=>Ts(r,{workspaceId:o.workspaceId,from:o.from,to:o.to,format:c,sections:[s.sectionKey]}))};return e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium",children:a(s.titleKey)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.state==="error"||n.state==="error"||l.state==="error"?t.error??n.error??l.error:a("reportsPage.exportCenter.readyOnDemand",{defaultValue:"Prepared on demand â click a format below."})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{action:t,icon:e.jsx(Z,{className:"h-4 w-4 mr-1.5 rtl-flip"}),label:a("reportsPage.exportCenter.pdf"),onClick:()=>i("pdf",t)}),e.jsx(W,{action:n,icon:e.jsx(ee,{className:"h-4 w-4 mr-1.5 rtl-flip"}),label:a("reportsPage.exportCenter.excel"),onClick:()=>i("xlsx",n)}),e.jsx(W,{action:l,icon:e.jsx(se,{className:"h-4 w-4 mr-1.5 rtl-flip"}),label:a("reportsPage.exportCenter.csv"),onClick:()=>i("csv",l)})]})]})}function Ks({input:s}){const{t:o}=m(),a=S(ls);return e.jsxs(f,{children:[e.jsxs(v,{className:"flex flex-row items-center justify-between gap-2 space-y-0",children:[e.jsx(w,{className:"text-base",children:o("reportsPage.exportCenter.title")}),e.jsx(R,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs(be,{to:"/reports/exports",children:[e.jsx(Q,{className:"h-4 w-4 mr-1.5 rtl-flip"}),"Export History"]})})]}),e.jsxs(g,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:o("reportsPage.exportCenter.description")}),e.jsx("div",{className:"rounded-lg border divide-y",children:ue.map(r=>e.jsx(Fs,{spec:r,input:s,t:o,runFn:a},r.sectionKey))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o("reportsPage.exportCenter.syncLimits",{defaultValue:`Synchronous exports run for up to ${te.toLocaleString()} orders in range. Larger workspaces will use background exports (coming soon).`,max:te.toLocaleString()})})]})]})}function Es({input:s,preset:o,fm:a}){const{t:r}=m(),t=async n=>{try{const{enqueueExportJobFn:l}=await le(async()=>{const{enqueueExportJobFn:d}=await import("./export-jobs.functions-BidlUpuA.js");return{enqueueExportJobFn:d}},__vite__mapDeps([0,1])),i=ue.map(d=>d.sectionKey),c=await l({data:{workspaceId:s.workspaceId,from:s.from,to:s.to,format:n,sections:i}});h.message("Preparing your combined export â this will download shortly."),await xe({jobId:c.jobId,workspaceId:s.workspaceId})}catch(l){h.error(l instanceof Error?l.message:"Export failed")}};return e.jsxs(Ee,{children:[e.jsx(Re,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",children:[e.jsx(Q,{className:"h-4 w-4 mr-1.5 rtl-flip"}),r("reportsPage.exportMenu.export")]})}),e.jsxs(De,{align:"end",children:[e.jsxs(q,{onClick:()=>{t("pdf")},children:[e.jsx(Z,{className:"h-4 w-4 mr-2 rtl-flip"}),r("reportsPage.exportMenu.fullPdf")]}),e.jsxs(q,{onClick:()=>{t("xlsx")},children:[e.jsx(ee,{className:"h-4 w-4 mr-2 rtl-flip"}),r("reportsPage.exportMenu.combinedExcel")]}),e.jsxs(q,{onClick:()=>{t("csv")},children:[e.jsx(se,{className:"h-4 w-4 mr-2 rtl-flip"}),r("reportsPage.exportMenu.combinedCsv")]})]})]})}function u({title:s,rows:o,exportName:a}){const{t:r}=m(),t=o[0]?Object.keys(o[0]):[];return e.jsxs(f,{children:[e.jsxs(v,{className:"flex flex-row items-center justify-between space-y-0 gap-2",children:[e.jsx(w,{className:"text-base truncate",children:s}),e.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[e.jsx(R,{size:"sm",variant:"ghost",onClick:()=>H("csv",a,o),title:r("reportsPage.table.exportCsvTip"),"aria-label":r("reportsPage.table.exportCsvTip"),children:e.jsx(se,{className:"h-4 w-4"})}),e.jsx(R,{size:"sm",variant:"ghost",onClick:()=>H("xlsx",a,o),title:r("reportsPage.table.exportExcelTip"),"aria-label":r("reportsPage.table.exportExcelTip"),children:e.jsx(ee,{className:"h-4 w-4"})}),e.jsx(R,{size:"sm",variant:"ghost",onClick:()=>H("pdf",a,o),title:r("reportsPage.table.exportPdfTip"),"aria-label":r("reportsPage.table.exportPdfTip"),children:e.jsx(Z,{className:"h-4 w-4"})})]})]}),e.jsxs(g,{className:"p-0",children:[o.length===0?e.jsx("div",{className:"p-8 text-sm text-center text-muted-foreground",children:r("reportsPage.table.noDataInRange")}):e.jsx(we,{className:"border-0 rounded-none shadow-none",children:e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsx(re,{children:t.map(n=>e.jsx(Te,{children:n},n))})}),e.jsx(Fe,{children:o.slice(0,50).map((n,l)=>e.jsx(re,{children:t.map(i=>e.jsx(Ke,{className:"tabular-nums",children:String(n[i]??"â")},i))},l))})]})}),o.length>50&&e.jsx("div",{className:"px-4 py-2 text-xs text-muted-foreground border-t",children:r("reportsPage.table.showingOf",{total:o.length})})]})]})}export{Nt as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.