1import{j as e,m as x}from"./vendor-motion-BFXLFQTv.js";import{a as c}from"./vendor-react-CYT9s6D6.js";import{u as me,t as b,F as pe}from"./index-BBq5NlpR.js";import{D as ue}from"./DataSourceBadge-Cekmnqo-.js";import{u as he}from"./useDocumentTitle-YRwygSBj.js";import{j as y,a0 as ge,V as A,av as be,aT as J,X as se,aa as fe,aU as je,v as K,T as Q,aV as ve,a6 as $,u as Ne,r as ye,F as we,aD as Ce,a9 as Se}from"./vendor-icons-D9YvevLc.js";import"./vendor-charts-EGSdVzq-.js";const j={imported:{color:"#34d399",bg:"rgba(52,211,153,0.1)",label:"Imported"},processing:{color:"#a92f09",bg:"rgba(169,47,9,0.1)",label:"Processing"},failed:{color:"#ef4444",bg:"rgba(239,68,68,0.1)",label:"Failed"},validating:{color:"#f59e0b",bg:"rgba(245,158,11,0.1)",label:"Validating"}},k={"AWS Cost & Usage Report":"#FF9900","Azure API Sync":"#0078D4","GCP Billing Export":"#4285F4","Azure Cost Management Export":"#0078D4","Custom CSV":"#a92f09","AWS CUR Incremental":"#FF9900"},X=[{id:"up-001",name:"aws-cur-incremental-feb-2026.csv",size:"42 MB",rows:21400,date:"2/13/2026",status:"imported",type:"AWS CUR Incremental",columns:34,importedAt:"Feb 13, 2026 09:14 AM"},{id:"up-002",name:"azure-cost-management-api-sync",size:"â",rows:34100,date:"2/12/2026",status:"imported",type:"Azure API Sync",columns:28,importedAt:"Feb 12, 2026 02:30 PM"},{id:"up-003",name:"gcp-billing-export-bigquery-2025.csv",size:"127 MB",rows:64200,date:"1/30/2026",status:"imported",type:"GCP Billing Export",columns:31,importedAt:"Jan 30, 2026 11:45 AM"},{id:"up-004",name:"azure-enterprise-cost-export-2025.csv",size:"196 MB",rows:98400,date:"1/15/2026",status:"imported",type:"Azure Cost Management Export",columns:26,importedAt:"Jan 15, 2026 03:22 PM"},{id:"up-005",name:"aws-cur-consolidated-2025-q4.csv",size:"312 MB",rows:156800,date:"1/05/2026",status:"imported",type:"AWS Cost & Usage Report",columns:34,importedAt:"Jan 5, 2026 08:55 AM"},{id:"up-006",name:"custom-team-allocation-dec.csv",size:"8 MB",rows:4200,date:"12/20/2025",status:"imported",type:"Custom CSV",columns:12,importedAt:"Dec 20, 2025 10:15 AM"},{id:"up-007",name:"gcp-billing-monthly-dec-2025.csv",size:"89 MB",rows:42100,date:"12/15/2025",status:"imported",type:"GCP Billing Export",columns:31,importedAt:"Dec 15, 2025 04:30 PM"},{id:"up-008",name:"aws-cur-nov-2025.csv",size:"287 MB",rows:143500,date:"12/02/2025",status:"imported",type:"AWS Cost & Usage Report",columns:34,importedAt:"Dec 2, 2025 09:40 AM"}],Z=[{source:"lineItem/UsageStartDate",target:"Date",mapped:!0,confidence:98},{source:"lineItem/ProductCode",target:"Service",mapped:!0,confidence:95},{source:"lineItem/ResourceId",target:"Resource ID",mapped:!0,confidence:99},{source:"lineItem/UnblendedCost",target:"Cost",mapped:!0,confidence:97},{source:"product/region",target:"Region",mapped:!0,confidence:96},{source:"resourceTags/user:team",target:"Tags",mapped:!0,confidence:88},{source:"lineItem/UsageAccountId",target:"Account",mapped:!0,confidence:94},{source:"custom_field_1",target:"(unmapped)",mapped:!1,confidence:0}],Y=[{date:"2026-02-01",service:"EC2",resource_id:"i-0a1b2c3d4e5f",cost:"$2,840.00",region:"us-east-1",account:"123456789012",tags:"team:platform"},{date:"2026-02-01",service:"RDS",resource_id:"rds-prod-primary",cost:"$5,840.00",region:"us-east-1",account:"123456789012",tags:"team:data"},{date:"2026-02-01",service:"S3",resource_id:"s3-data-lake-01",cost:"$1,210.00",region:"us-east-1",account:"234567890123",tags:"team:ml"},{date:"2026-02-01",service:"Lambda",resource_id:"api-handler-prod",cost:"$320.00",region:"us-west-2",account:"123456789012",tags:"team:backend"},{date:"2026-02-01",service:"EKS",resource_id:"eks-prod-cluster",cost:"$8,420.00",region:"us-east-1",account:"345678901234",tags:"team:platform"}],Ae=["Resource ID","Service","Cost","Date","Region","Tags","Account","Provider","Usage Type","Description"];function ee(l){const i=l.toLowerCase();return i.includes("cur")&&i.includes("aws")?"AWS Cost & Usage Report":i.includes("aws")?"AWS CUR Incremental":i.includes("azure")&&i.includes("api")?"Azure API Sync":i.includes("azure")?"Azure Cost Management Export":i.includes("gcp")||i.includes("bigquery")?"GCP Billing Export":"Custom CSV"}function ke({file:l,onClose:i,onDelete:n,onReprocess:m}){return e.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",onClick:i,children:[e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),e.jsxs(x.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:25,stiffness:250},className:"relative w-full max-w-md bg-[#faf9f5] border-l border-[rgba(26,25,22,0.15)] h-full overflow-y-auto",onClick:u=>u.stopPropagation(),children:[e.jsx("div",{className:"sticky top-0 z-10 bg-[#faf9f5] border-b border-[rgba(26,25,22,0.15)] p-5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center",style:{backgroundColor:`${k[l.type]}15`},children:e.jsx(y,{className:"w-5 h-5",style:{color:k[l.type]}})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[#1a1916] text-sm truncate max-w-[250px]",style:{fontWeight:600},children:l.name}),e.jsx("span",{className:"text-[11px] text-[#55534c]",children:l.type})]})]}),e.jsx("button",{onClick:i,className:"text-[#55534c] hover:text-[#1a1916] transition-colors",children:e.jsx(se,{className:"w-5 h-5"})})]})}),e.jsxs("div",{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:j[l.status].color}}),e.jsx("span",{className:"text-xs",style:{color:j[l.status].color,fontWeight:500},children:j[l.status].label})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-[rgba(26,25,22,0.05)] border border-[rgba(26,25,22,0.10)] rounded-lg p-3",children:[e.jsx("div",{className:"text-[11px] text-[#55534c] mb-1",children:"File Size"}),e.jsx("div",{className:"text-sm text-[#1a1916]",style:{fontWeight:600},children:l.size})]}),e.jsxs("div",{className:"bg-[rgba(26,25,22,0.05)] border border-[rgba(26,25,22,0.10)] rounded-lg p-3",children:[e.jsx("div",{className:"text-[11px] text-[#55534c] mb-1",children:"Total Rows"}),e.jsx("div",{className:"text-sm text-[#1a1916]",style:{fontWeight:600}
1,children:l.rows.toLocaleString()})]}),e.jsxs("div",{className:"bg-[rgba(26,25,22,0.05)] border border-[rgba(26,25,22,0.10)] rounded-lg p-3",children:[e.jsx("div",{className:"text-[11px] text-[#55534c] mb-1",children:"Columns"}),e.jsx("div",{className:"text-sm text-[#1a1916]",style:{fontWeight:600},children:l.columns||"â"})]}),e.jsxs("div",{className:"bg-[rgba(26,25,22,0.05)] border border-[rgba(26,25,22,0.10)] rounded-lg p-3",children:[e.jsx("div",{className:"text-[11px] text-[#55534c] mb-1",children:"Upload Date"}),e.jsx("div",{className:"text-sm text-[#1a1916]",style:{fontWeight:600},children:l.date})]})]}),l.importedAt&&e.jsxs("div",{className:"bg-[rgba(26,25,22,0.05)] border border-[rgba(26,25,22,0.10)] rounded-lg p-3",children:[e.jsx("div",{className:"text-[11px] text-[#55534c] mb-1",children:"Imported At"}),e.jsx("div",{className:"text-xs text-[#1a1916]",children:l.importedAt})]}),e.jsxs("div",{className:"bg-[rgba(26,25,22,0.05)] border border-[rgba(26,25,22,0.10)] rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(we,{className:"w-4 h-4 text-[#a92f09]"}),e.jsx("span",{className:"text-sm text-[#1a1916]",style:{fontWeight:600},children:"Format Details"})]}),e.jsxs("div",{className:"space-y-2 text-xs text-[#55534c]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Detected Format"}),e.jsx("span",{className:"text-[#1a1916]",style:{fontWeight:500},children:l.type})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Encoding"}),e.jsx("span",{className:"text-[#1a1916]",style:{fontWeight:500},children:"UTF-8"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Delimiter"}),e.jsx("span",{className:"text-[#1a1916]",style:{fontWeight:500},children:"Comma (,)"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Date Format"}),e.jsx("span",{className:"text-[#1a1916]",style:{fontWeight:500},children:"ISO 8601"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{onClick:()=>m(l.id),className:"w-full flex items-center gap-2 px-4 py-2.5 rounded-lg text-xs text-[#55534c] hover:text-[#1a1916] hover:bg-[rgba(26,25,22,0.08)] border border-[rgba(26,25,22,0.15)] transition-colors",children:[e.jsx(Ce,{className:"w-3.5 h-3.5"}),"Reprocess File"]}),e.jsxs("button",{className:"w-full flex items-center gap-2 px-4 py-2.5 rounded-lg text-xs text-[#55534c] hover:text-[#1a1916] hover:bg-[rgba(26,25,22,0.08)] border border-[rgba(26,25,22,0.15)] transition-colors",children:[e.jsx(Se,{className:"w-3.5 h-3.5"}),"Download Original"]}),e.jsxs("button",{onClick:()=>{n(l.id),i()},className:"w-full flex items-center gap-2 px-4 py-2.5 rounded-lg text-xs text-[#ef4444] hover:text-[#ef4444] hover:bg-[rgba(239,68,68,0.05)] border border-[rgba(239,68,68,0.15)] transition-colors",children:[e.jsx($,{className:"w-3.5 h-3.5"}),"Delete File"]})]})]})]})]})}function $e(){he("Data Upload");const{isDemoMode:l}=me(),i=l?"demo":"api",[n,m]=c.useState(l?X:[]),[u,v]=c.useState("idle"),[W,D]=c.useState(!1),[I,M]=c.useState(0),[d,T]=c.useState(null),[w,P]=c.useState(null),[r,B]=c.useState(null),[F,L]=c.useState(Z),[f,te]=c.useState(""),[E,V]=c.useState(null),[h,_]=c.useState("all"),U=c.useRef(null),G=c.useMemo(()=>n.filter(s=>{const t=s.name.toLowerCase().includes(f.toLowerCase())||s.type.toLowerCase().includes(f.toLowerCase()),a=h==="all"||s.type===h;return t&&a}),[n,f,h]),O=c.useMemo(()=>{const s=new Set(n.map(t=>t.type));return Array.from(s)},[n]),R=n.reduce((s,t)=>s+t.rows,0);n.length;const C=c.useCallback(s=>{P(s),T({name:s.name,size:s.size}),v("uploading"),M(0);const t=setInterval(()=>{M(a=>{if(a>=100){clearInterval(t);const o=Math.floor(Math.random()*5e4)+5e3,p=Math.floor(Math.random()*20)+10,N=Math.floor(Math.random()*5);return B({rows:o,columns:p,errors:N}),L(Z),v("mapping"),100}return a+Math.floor(Math.random()*8)+3})},120)},[]),ae=c.useCallback(s=>{s.preventDefault(),D(!1);const t=s.dataTransfer.files[0];t&&C(t)},[C]),re=c.useCallback(s=>{var a;const t=(a=s.target.files)==null?void 0:a[0];t&&C(t),s.target&&(s.target.value="")},[C]),le=c.useCallback((s,t)=>{L(a=>a.map((o,p)=>p===s?{...o,target:t,mapped:t!=="",confidence:t?100:0}:o))},[]),ce=c.useCallback(()=>{v("validating"),setTimeout(()=>{if(v("done"),d&&r){const s=ee(d.name),t={id:`up-${Date.now()}`,name:d.name,size:`${Math.round(d.size/(1024*1024))} MB`,rows:r.rows,date:new Date().toLocaleDateString("en-US",{month:"numeric",day:"numeric",year:"numeric"}),status:"imported",type:s,columns:r.columns,errors:r.errors,importedAt:new Date().toLocaleStr
1ing("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})};m(a=>[t,...a]),b.success("File processed successfully",{description:`${r.rows.toLocaleString()} rows imported${r.errors?` with ${r.errors} warnings`:""}.`}),!l&&w&&w.text().then(a=>{const o=a.split(` 2`).filter(g=>g.trim());if(o.length<2)return;const p=o[0].split(",").map(g=>g.trim().replace(/^"|"$/g,"")),N=o.slice(1).map(g=>{const de=g.split(",").map(z=>z.trim().replace(/^"|"$/g,"")),H={};return p.forEach((z,xe)=>{H[z]=de[xe]||""}),H});pe.upload(N,w.name,s).catch(g=>{console.error("[CSV Upload] Backend error:",g)})}).catch(a=>console.error("[CSV Upload] Parse error:",a))}},2500)},[d,r,l,w]),S=c.useCallback(()=>{v("idle"),T(null),P(null),B(null),M(0)},[]),q=c.useCallback(s=>{const t=n.find(a=>a.id===s);t&&(m(a=>a.filter(o=>o.id!==s)),b.success(`${t.name} deleted`,{description:"File has been removed from uploads.",action:{label:"Undo",onClick:()=>{m(a=>{const o=X.findIndex(N=>N.id===s),p=[...a];return p.splice(Math.min(o,p.length),0,t),p}),b.success("File restored")}}}))},[n]),ne=c.useCallback(()=>{const s=[...n];m([]),b.success(`${s.length} files deleted`,{description:"All uploads have been cleared.",action:{label:"Undo",onClick:()=>{m(s),b.success("All files restored")}}})},[n]),ie=c.useCallback(s=>{m(t=>t.map(a=>a.id===s?{...a,status:"processing"}:a)),b.info("Reprocessing file...",{description:"This may take a moment."}),setTimeout(()=>{m(t=>t.map(a=>a.id===s?{...a,status:"imported"}:a)),b.success("File reprocessed successfully")},3e3)},[]),oe=[{label:"Total Files",value:n.length.toString(),color:"#a92f09",icon:e.jsx(y,{className:"w-4 h-4"})},{label:"Total Rows",value:R>=1e6?`${(R/1e6).toFixed(1)}M`:`${(R/1e3).toFixed(0)}K`,color:"#a92f09",icon:e.jsx(ge,{className:"w-4 h-4"})},{label:"Imported",value:n.filter(s=>s.status==="imported").length.toString(),color:"#34d399",icon:e.jsx(A,{className:"w-4 h-4"})},{label:"Formats",value:O.length.toString(),color:"#f59e0b",icon:e.jsx(be,{className:"w-4 h-4"})}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-[#55534c]",children:"Upload cloud cost data files for analysis. Auto-detects Azure, AWS, and GCP columns. Handles quoted fields, BOM, and all date formats."}),e.jsx(ue,{source:i})]}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:oe.map((s,t)=>e.jsxs(x.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:t*.05},className:"bg-[#faf9f5] rounded-md p-4 border border-[rgba(26,25,22,0.15)]",style:{borderTop:`2px solid ${s.color}`},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-[11px] text-[#55534c] uppercase tracking-wide",style:{fontWeight:600},children:s.label}),e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{backgroundColor:`${s.color}15`,color:s.color},children:s.icon})]}),e.jsx("div",{className:"text-xl text-[#1a1916]",style:{fontWeight:700},children:s.value})]},s.label))}),u==="idle"&&e.jsx(x.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},children:e.jsxs("div",{onDragOver:s=>{s.preventDefault(),D(!0)},onDragLeave:()=>D(!1),onDrop:ae,className:`border-2 border-dashed rounded-lg p-10 text-center transition-all cursor-pointer bg-[#faf9f5] ${W?"border-[#a92f09] bg-[#a92f09]/5 scale-[1.01]":"border-[rgba(26,25,22,0.08)] hover:border-[rgba(26,25,22,0.13)]"}`,onClick:()=>{var s;return(s=U.current)==null?void 0:s.click()},children:[e.jsx("div",{className:`w-16 h-16 rounded-lg mx-auto mb-4 flex items-center justify-center transition-colors ${W?"bg-[#a92f09]/20":"bg-gradient-to-br from-[#a92f09]/20 to-[#1a1916]/20"}`,children:e.jsx(J,{className:`w-8 h-8 ${W?"text-[#a92f09]":"text-[#55534c]"}`})}),e.jsx("h3",{className:"text-[#1a1916] text-lg mb-2",style:{fontWeight:600},children:"Upload cloud cost data"}),e.jsx("p",{className:"text-sm text-[#55534c] mb-5",children:"Drag and drop your CSV, or click to browse. Supports AWS CUR, Azure Billing, and GCP exports."}),e.jsxs("button",{onClick:s=>{var t;s.stopPropagation(),(t=U.current)==null||t.click()},className:"inline-flex items-center gap-2 px-6 py-2.5 bg-[#1a1916] text-[#faf9f5] rounded-lg text-sm",style:{fontWeight:500},children:[e.jsx(J,{className:"w-4 h-4"}),"Browse Files"]}),e.jsx("input",{ref:U,type:"file",accept:".csv,.xlsx,.tsv",className:"hidden",onChange:re}),e.jsx("p",{className:"text-[11px] text-[#8b8880] mt-4",children:"Auto-detects Azure, AWS, and GCP columns. Handles quoted fields, BOM, and all date formats."})]})}),u==="uploading"&&d&&e.jsx(x.div,{initial:{opacity:0,y:16}
2,animate:{opacity:1,y:0},className:"bg-[#faf9f5] border border-[rgba(26,25,22,0.15)] rounded-md p-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-md bg-[#a92f09]/10 flex items-center justify-center shrink-0",children:e.jsx(y,{className:"w-6 h-6 text-[#a92f09]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"text-sm text-[#1a1916]",style:{fontWeight:500},children:d.name}),e.jsxs("span",{className:"text-xs text-[#55534c]",children:[Math.min(I,100),"%"]})]}),e.jsx("div",{className:"w-full h-2 bg-[rgba(26,25,22,0.10)] rounded-full overflow-hidden",children:e.jsx(x.div,{initial:{width:0},animate:{width:`${Math.min(I,100)}%`},className:"h-full bg-[#1a1916] rounded-full"})}),e.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[e.jsx("div",{className:"text-xs text-[#55534c]",children:"Uploading & parsing..."}),e.jsx("button",{onClick:S,className:"text-[11px] text-[#55534c] hover:text-[#1a1916]",children:"Cancel"})]})]})]})}),u==="mapping"&&d&&r&&e.jsx(x.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},className:"space-y-5",children:e.jsxs("div",{className:"bg-[#faf9f5] border border-[rgba(26,25,22,0.15)] rounded-md overflow-hidden",children:[e.jsx("div",{className:"p-5 border-b border-[rgba(26,25,22,0.15)]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-[#34d399]/10 flex items-center justify-center",children:e.jsx(A,{className:"w-5 h-5 text-[#34d399]"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[#1a1916]",style:{fontWeight:600},children:"File parsed successfully"}),e.jsxs("div",{className:"text-xs text-[#55534c]",children:[d.name," â ",r.rows.toLocaleString()," rows, ",r.columns," columns"]})]})]}),e.jsx("button",{onClick:S,className:"text-[#55534c] hover:text-[#1a1916]",children:e.jsx(se,{className:"w-4 h-4"})})]})}),e.jsxs("div",{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-[rgba(26,25,22,0.05)] border border-[rgba(26,25,22,0.10)] rounded-lg p-3",children:[e.jsx("div",{className:"text-[11px] text-[#55534c]",children:"Total Rows"}),e.jsx("div",{className:"text-lg text-[#1a1916]",style:{fontWeight:700},children:r.rows.toLocaleString()})]}),e.jsxs("div",{className:"bg-[rgba(26,25,22,0.05)] border border-[rgba(26,25,22,0.10)] rounded-lg p-3",children:[e.jsx("div",{className:"text-[11px] text-[#55534c]",children:"Valid Rows"}),e.jsx("div",{className:"text-lg text-[#34d399]",style:{fontWeight:700},children:(r.rows-r.errors).toLocaleString()})]}),e.jsxs("div",{className:"bg-[rgba(26,25,22,0.05)] border border-[rgba(26,25,22,0.10)] rounded-lg p-3",children:[e.jsx("div",{className:"text-[11px] text-[#55534c]",children:"Warnings"}),e.jsx("div",{className:"text-lg text-[#f59e0b]",style:{fontWeight:700},children:r.errors})]})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-[rgba(169,47,9,0.05)] border border-[rgba(169,47,9,0.15)]",children:[e.jsx(fe,{className:"w-4 h-4 text-[#a92f09] shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-[#a92f09]",style:{fontWeight:500},children:"Auto-detected: "}),e.jsx("span",{className:"text-xs text-[#1a1916]",style:{fontWeight:500},children:ee(d.name)})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(je,{className:"w-4 h-4 text-[#a92f09]"}),e.jsx("h4",{className:"text-[#1a1916] text-sm",style:{fontWeight:600},children:"Column Mapping"}),e.jsxs("span",{className:"text-[11px] text-[#8b8880]",children:[F.filter(s=>s.mapped).length,"/",F.length," mapped"]})]}),e.jsx("div",{className:"space-y-2",children:F.map((s,t)=>e.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${s.mapped?"border-[rgba(26,25,22,0.10)] bg-[rgba(26,25,22,0.05)]":"border-[#f59e0b]/20 bg-[#f59e0b]/5"}`,children:[e.jsx("span",{className:"text-xs text-[#1a1916] font-mono w-48 truncate",style:{fontWeight:500},children:s.source}),e.jsx(K,{className:"w-3 h-3 text-[#55534c] shrink-0"}),e.jsxs("select",{className:`flex-1 bg-transparent text-xs rounded-lg px-2 py-1 border focus:outline-none ${s.mapped?"border-[rgba(26,25,22,0.15)] text-[#1a1916]":"border-[#f59e0b]/30 text-[#f59e0b]"}
2`,value:s.target,onChange:a=>le(t,a.target.value),children:[e.jsx("option",{value:"",className:"bg-[#faf9f5]",children:"â Select field â"}),Ae.map(a=>e.jsx("option",{value:a,className:"bg-[#faf9f5]",children:a},a))]}),s.mapped?e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(A,{className:"w-4 h-4 text-[#34d399]"}),e.jsxs("span",{className:"text-[11px] text-[#34d399]",children:[s.confidence,"%"]})]}):e.jsx(Q,{className:"w-4 h-4 text-[#f59e0b] shrink-0"})]},t))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ve,{className:"w-4 h-4 text-[#a92f09]"}),e.jsx("h4",{className:"text-[#1a1916] text-sm",style:{fontWeight:600},children:"Data Preview"}),e.jsx("span",{className:"text-[11px] text-[#55534c]",children:"(first 5 rows)"})]}),e.jsx("div",{className:"overflow-x-auto rounded-lg border border-[rgba(26,25,22,0.15)]",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b border-[rgba(26,25,22,0.15)]",children:Object.keys(Y[0]).map(s=>e.jsx("th",{className:"text-left px-3 py-2 text-[11px] text-[#55534c] uppercase font-mono whitespace-nowrap",style:{fontWeight:600},children:s},s))})}),e.jsx("tbody",{children:Y.map((s,t)=>e.jsx("tr",{className:"border-b border-[rgba(26,25,22,0.10)] hover:bg-[rgba(26,25,22,0.05)]",children:Object.values(s).map((a,o)=>e.jsx("td",{className:"px-3 py-2 text-xs text-[#55534c] whitespace-nowrap",children:a},o))},t))})]})})]}),r.errors>0&&e.jsxs("div",{className:"bg-[#f59e0b]/5 border border-[#f59e0b]/20 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Q,{className:"w-4 h-4 text-[#f59e0b]"}),e.jsxs("span",{className:"text-xs text-[#f59e0b]",style:{fontWeight:600},children:[r.errors," row",r.errors!==1?"s":""," with warnings"]})]}),e.jsxs("div",{className:"space-y-1 text-[11px] text-[#55534c]",children:[e.jsx("div",{children:"Row 847: Missing cost value (will be set to $0.00)"}),e.jsx("div",{children:"Row 1,102: Invalid date format in usage_date"}),r.errors>2&&e.jsx("div",{children:"Row 1,203: Duplicate resource_id detected"}),r.errors>3&&e.jsx("div",{children:"Row 2,481: Unexpected currency format"}),r.errors>4&&e.jsx("div",{children:'Row 3,922: Region not recognized â mapped to "unknown"'})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:S,className:"px-4 py-2 text-xs text-[#55534c] hover:text-[#1a1916] border border-[rgba(26,25,22,0.08)] rounded-lg transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:ce,className:"flex items-center gap-1.5 px-5 py-2 bg-[#1a1916] text-[#faf9f5] text-xs rounded-lg",style:{fontWeight:500},children:["Confirm & Import",e.jsx(K,{className:"w-4 h-4"})]})]})]})]})}),u==="validating"&&e.jsxs(x.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},className:"bg-[#faf9f5] border border-[rgba(26,25,22,0.15)] rounded-md p-10 text-center",children:[e.jsx("div",{className:"w-14 h-14 border-2 border-[#a92f09] border-t-transparent rounded-full animate-spin mx-auto mb-4"}),e.jsx("h3",{className:"text-[#1a1916] text-sm mb-1",style:{fontWeight:600},children:"Processing & validating data..."}),e.jsx("p",{className:"text-xs text-[#55534c]",children:"Mapping columns, deduplicating rows, and normalizing cost values."})]}),u==="done"&&d&&r&&e.jsxs(x.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},className:"bg-[#faf9f5] border border-[#34d399]/20 rounded-md p-10 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-lg bg-[#34d399]/10 flex items-center justify-center mx-auto mb-4",children:e.jsx(A,{className:"w-8 h-8 text-[#34d399]"})}),e.jsx("h3",{className:"text-[#1a1916] text-lg mb-1",style:{fontWeight:700},children:"Import Complete!"}),e.jsxs("p",{className:"text-sm text-[#55534c] mb-6",children:[(r.rows-r.errors).toLocaleString()," rows imported.",r.errors>0&&` ${r.errors} rows had warnings.`]}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx("button",{onClick:S,className:"px-4 py-2 text-xs text-[#55534c] hover:text-[#1a1916] border border-[rgba(26,25,22,0.08)] rounded-lg transition-colors",children:"Upload Another"}),e.jsx("button",{className:"px-4 py-2 bg-[#1a1916] text-[#faf9f5] text-xs rounded-lg",style:{fontWeight:500},children:"View in Analytics"})]})]}),e.jsxs(x.div,{initial:{opacity:0,y:16}
2,animate:{opacity:1,y:0},transition:{delay:.1},className:"bg-[#faf9f5] border border-[rgba(26,25,22,0.15)] rounded-md overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-5 border-b border-[rgba(26,25,22,0.15)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-[#1a1916] text-sm",style:{fontWeight:600},children:"Recent Uploads"}),e.jsxs("span",{className:"text-[11px] text-[#8b8880]",children:[n.length," files"]})]}),e.jsx("div",{className:"flex items-center gap-2",children:n.length>0&&e.jsxs("button",{onClick:ne,className:"flex items-center gap-1 text-xs text-[#ef4444] hover:text-[#ef4444]/80 transition-colors",children:[e.jsx($,{className:"w-3 h-3"}),"Delete All"]})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-3 px-5 py-3 border-b border-[rgba(26,25,22,0.10)]",children:[e.jsxs("div",{className:"relative flex-1 w-full sm:max-w-xs",children:[e.jsx(Ne,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-[#55534c]"}),e.jsx("input",{value:f,onChange:s=>te(s.target.value),placeholder:"Search files...",className:"w-full bg-[rgba(26,25,22,0.08)] border border-[rgba(26,25,22,0.15)] rounded-lg pl-8 pr-3 py-1.5 text-xs text-[#1a1916] placeholder:text-[#8b8880] focus:outline-none focus:border-[#a92f09]/50"})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto",children:[e.jsx("button",{onClick:()=>_("all"),className:`px-2.5 py-1 rounded-md text-[11px] whitespace-nowrap transition-all ${h==="all"?"bg-[#a92f09]/20 text-[#a92f09] border border-[#a92f09]/30":"text-[#55534c] border border-[rgba(26,25,22,0.15)] hover:text-[#1a1916]"}`,style:{fontWeight:500},children:"All"}),O.map(s=>e.jsx("button",{onClick:()=>_(s),className:`px-2.5 py-1 rounded-md text-[11px] whitespace-nowrap transition-all ${h===s?"bg-[#a92f09]/20 text-[#a92f09] border border-[#a92f09]/30":"text-[#55534c] border border-[rgba(26,25,22,0.15)] hover:text-[#1a1916]"}`,style:{fontWeight:500},children:s},s))]})]}),G.length>0?e.jsx("div",{className:"divide-y divide-[rgba(26,25,22,0.10)]",children:G.map((s,t)=>e.jsxs(x.div,{initial:{opacity:0}
2,animate:{opacity:1},transition:{delay:t*.02},className:"flex items-center justify-between px-5 py-3.5 hover:bg-[rgba(26,25,22,0.05)] cursor-pointer group transition-colors",onClick:()=>V(s),children:[e.jsxs("div",{className:"flex items-center gap-3.5 flex-1 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${k[s.type]}12`},children:e.jsx(y,{className:"w-4 h-4",style:{color:k[s.type]}})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-[#1a1916] truncate",style:{fontWeight:500},children:s.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[e.jsx("span",{className:"text-[11px] text-[#8b8880]",children:s.size}),s.rows>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[11px] text-[#8b8880]",children:"·"}),e.jsxs("span",{className:"text-[11px] text-[#8b8880]",children:[s.rows.toLocaleString()," rows"]})]}),e.jsx("span",{className:"text-[11px] text-[#8b8880]",children:"·"}),e.jsx("span",{className:"text-[11px] text-[#8b8880]",children:s.date})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx("span",{className:"text-[11px] text-[#55534c] hidden sm:block px-2 py-0.5 rounded-md bg-[rgba(26,25,22,0.08)] border border-[rgba(26,25,22,0.10)]",children:s.type}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:j[s.status].color}}),e.jsx("span",{className:"text-xs",style:{color:j[s.status].color,fontWeight:500},children:j[s.status].label})]}),e.jsx("button",{onClick:a=>{a.stopPropagation(),q(s.id)},className:"opacity-0 group-hover:opacity-100 text-[#55534c] hover:text-[#ef4444] transition-all p-1",children:e.jsx($,{className:"w-3.5 h-3.5"})}),e.jsx(ye,{className:"w-4 h-4 text-[#8b8880] opacity-0 group-hover:opacity-100 transition-opacity"})]})]},s.id))}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(y,{className:"w-8 h-8 text-[#8b8880] mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-[#55534c]",style:{fontWeight:500},children:f||h!=="all"?"No files match your filters":"No uploads yet"}),e.jsx("p",{className:"text-[11px] text-[#8b8880] mt-1",children:f||h!=="all"?"Try a different search or filter":"Upload a CSV file to get started"})]})]}),E&&e.jsx(ke,{file:E,onClose:()=>V(null),onDelete:q,onReprocess:ie})]})}export{$e as CsvUploadPage};
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.