1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/gcsStorageService-CfuPNSR4.js","assets/index-CGKNpi9E.js","assets/animation-CddyXVCz.js","assets/react-vendor-CbN3pvl2.js","assets/supabase-iKSPld20.js","assets/docgen-Bp8WKBAE.js","assets/query-DPqpbKNH.js","assets/index-D2PKCkk9.css","assets/index-C7IeTs5z.js","assets/DocumentPreviewModal-CVr6_dXJ.js"])))=>i.map(i=>d[i]); 2import{aQ as $,B as o,l as W,aX as Y,aw as Z,T as J,aH as X,X as ae,af as R,_ as q,u as re,aB as le,bZ as ne,y as ie,L as oe,j as de,A as ce}from"./index-CGKNpi9E.js";import{r as d,j as e,R as xe}from"./animation-CddyXVCz.js";import{getCategoryIcon as V,getCategoryDisplayName as H,getAllCategories as me}from"./documentCategorizationService-CgIkAT40.js";import"./react-vendor-CbN3pvl2.js";import"./supabase-iKSPld20.js";import"./docgen-Bp8WKBAE.js";import"./query-DPqpbKNH.js";const he=({filesByCategory:n,onPreviewFile:p,onDeleteFile:F,getFileIcon:m,formatFileSize:w,formatDate:I})=>{const[D,E]=d.useState(new Set(Object.keys(n))),b=r=>{const c=new Set(D);c.has(r)?c.delete(r):c.add(r),E(c)},S=Object.keys(n);return S.length===0?e.jsxs("div",{className:"text-center py-12 border-2 border-dashed border-gray-200 dark:border-slate-700 rounded-2xl",children:[e.jsx($,{className:"h-16 w-16 mx-auto text-gray-300 dark:text-slate-600 mb-4"}),e.jsx("p",{className:"text-lg font-semibold text-gray-700 dark:text-slate-300 mb-2",children:"No documents yet"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Upload your first document to get started"})]}):e.jsx("div",{className:"space-y-4",children:S.map((r,c)=>{const h=n[r]||[];if(h.length===0)return null;const f=D.has(r);return e.jsxs("div",{className:"iconic-surface-soft overflow-hidden animate-slideDown",style:{animationDelay:`${c*50}ms`},children:[e.jsxs(o,{onClick:()=>b(r),variant:"ghost",size:"md",className:"w-full px-4 py-3 flex items-center justify-between hover:bg-gray-100 dark:hover:bg-slate-800/50 transition-colors h-auto border-none rounded-none",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[f?e.jsx(W,{className:"h-5 w-5 text-gray-500 dark:text-slate-400 transition-transform"}):e.jsx(Y,{className:"h-5 w-5 text-gray-500 dark:text-slate-400 transition-transform"}),e.jsx($,{className:"h-6 w-6 text-blue-500"})]}),e.jsxs("div",{className:"text-left font-normal",children:[e.jsxs("h3",{className:"font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx("span",{children:V(r)}),e.jsx("span",{children:H(r)})]}),e.jsxs("p",{className:"text-xs text-[var(--text-secondary)]/60",children:[h.length," ",h.length===1?"file":"files"]})]})]}),e.jsx("div",{className:"px-3 py-1 rounded-full bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 text-sm font-semibold",children:h.length})]}),f&&e.jsx("div",{className:"border-t border-gray-200 dark:border-slate-700",children:h.map((x,j)=>{const v=!!x.supabaseStoragePath;return e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between gap-4 hover:bg-white dark:hover:bg-slate-900/50 transition-colors border-b border-gray-100 dark:border-slate-700/50 last:border-b-0 animate-slideDown",style:{animationDelay:`${c*50+j*30}ms`},children:[e.jsxs("div",{className:`flex items-center gap-3 flex-1 min-w-0 ${v?"cursor-pointer":""}`,onClick:()=>v&&p(x),children:[e.jsx("span",{className:"text-2xl flex-shrink-0",children:m(x.mimeType)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-[var(--text-primary)] truncate hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:x.displayName,children:x.displayName}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]/60 mt-1",children:[e.jsx("span",{children:w(x.sizeBytes)}),e.jsx("span",{children:"â¢"}),e.jsx("span",{children:I(x.createTime)})]}),!v&&e.jsx("p",{className:"text-xs text-[var(--text-secondary)]/50 mt-1",children:"Preview unavailable"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[v&&e.jsx(o,{onClick:u=>{u.stopPropagation(),p(x)},variant:"ghost",size:"sm",className:"p-2 text-gray-400 hover:text-blue-500 dark:hover:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 h-auto",title:"Preview file",children:e.jsx(Z,{className:"h-4 w-4"})}),e.jsx(o,{onClick:u=>{u.stopPropagation(),F(x.name)},variant:"ghost",size:"sm",className:"p-2 text-gray-400 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 h-auto",title:"Delete file",children:e.jsx(J,{className:"h-4 w-4"})})]})]},x.name)})})]},r)})})},ue=({filesByCategory:n,getFileIcon:p,formatFileSize:F,formatDate:m})=>{const w=Object.keys(n),I=w.find(s=>{var i;return((i=n[s])==null?void 0:i.length)>0}
2)||null,[D,E]=d.useState(new Set(Object.keys(n))),[b,S]=d.useState(I),[r,c]=d.useState(null),[h,f]=d.useState(null),[x,j]=d.useState(null),[v,u]=d.useState(null),[C,U]=d.useState(!1),[g,N]=d.useState(null),T=s=>{const i=new Set(D);i.has(s)?i.delete(s):i.add(s),E(i)},k=s=>{S(s),c(null),f(null),j(null),u(null),N(null)},L=async s=>{if(c(s),f(null),j(null),u(null),N(null),!s.supabaseStoragePath){N("Preview not available for this file. Please re-upload to enable preview.");return}U(!0);try{const{getSignedUrl:i}=await q(async()=>{const{getSignedUrl:t}=await import("./gcsStorageService-CfuPNSR4.js");return{getSignedUrl:t}},__vite__mapDeps([0,1,2,3,4,5,6,7])),y=await i(s.supabaseStoragePath,3600);f(y);const M=s.mimeType==="application/vnd.openxmlformats-officedocument.wordprocessingml.document",O=s.mimeType==="text/plain";if(M){const{default:t}=await q(async()=>{const{default:te}=await import("./index-C7IeTs5z.js").then(se=>se.i);return{default:te}},__vite__mapDeps([8,3,5])),a=await fetch(y);if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);const l=await a.arrayBuffer(),ee=await t.convertToHtml({arrayBuffer:l});j(ee.value)}if(O){const t=await fetch(y);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);const a=await t.text();u(a)}}catch(i){const y=i instanceof Error?i.message:"Unknown error";N(`Failed to load preview: ${y}`)}finally{U(!1)}},z=()=>{if(h&&r){const s=document.createElement("a");s.href=h,s.download=r.displayName,document.body.appendChild(s),s.click(),document.body.removeChild(s)}},P=b?n[b]||[]:[],_=(r==null?void 0:r.mimeType)==="application/pdf",A=(r==null?void 0:r.mimeType)==="application/vnd.openxmlformats-officedocument.wordprocessingml.document",B=(r==null?void 0:r.mimeType)==="text/plain";return w.length===0?e.jsxs("div",{className:"text-center py-12 border-2 border-dashed border-gray-200 dark:border-slate-700 rounded-2xl",children:[e.jsx($,{className:"h-16 w-16 mx-auto text-gray-300 dark:text-slate-600 mb-4"}),e.jsx("p",{className:"text-lg font-semibold text-gray-700 dark:text-slate-300 mb-2",children:"No documents yet"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Upload your first document to get started"})]}):e.jsxs("div",{className:"flex gap-4 h-[600px] min-h-[400px] border border-gray-200 dark:border-slate-700 rounded-2xl overflow-hidden bg-white dark:bg-slate-900",children:[e.jsxs("div",{className:"w-64 min-w-0 flex-shrink-0 border-r border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-900/50 overflow-y-auto",children:[e.jsx("div",{className:"p-3 border-b border-gray-200 dark:border-slate-700 bg-gray-100 dark:bg-slate-800",children:e.jsx("h3",{className:"text-xs font-semibold text-gray-600 dark:text-slate-400 uppercase tracking-wide",children:"Folders"})}),e.jsx("div",{className:"p-2",children:w.map(s=>{const i=n[s]||[];if(i.length===0)return null;const y=D.has(s),M=b===s;return e.jsx("div",{className:"mb-1",children:e.jsxs(o,{onClick:()=>{T(s),k(s)},variant:"ghost",size:"md",className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors h-auto border-none justify-start 3 ${M?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 hover:bg-blue-200 dark:hover:bg-blue-900/50":"hover:bg-gray-100 dark:hover:bg-slate-800 text-gray-700 dark:text-slate-300"}`,children:[y?e.jsx(W,{className:"h-4 w-4 flex-shrink-0"}):e.jsx(Y,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"text-base",children:V(s)}),e.jsx("span",{className:"flex-1 text-left truncate font-medium",children:H(s)}),e.jsx("span",{className:"text-xs bg-gray-200 dark:bg-slate-700 px-2 py-0.5 rounded-full",children:i.length})]})},s)})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("div",{className:"p-3 border-b border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-900/50 sticky top-0",children:[e.jsx("h3",{className:"text-xs font-semibold text-gray-600 dark:text-slate-400 uppercase tracking-wide",children:b?H(b):"Select a folder"}),P.length>0&&e.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-500 mt-1",children:[P.length," ",P.length===1?"file":"files"]})]}),e.jsxs("div",{className:"p-2",children:[P.length===0&&b&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-slate-400 text-sm",children:"No files in this folder"}),!b&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-slate-400 text-sm",children:"Select a folder to view files"}),P.map(s=>{const i=(r==null?void 0:r.name)===s.name;return e.jsxs(o,{onClick:()=>L(s),variant:"ghost",size:"md",className:`w-full flex items-center gap-3 px-3 py-2 rounded-lg text-left transition-colors mb-1 h-auto border-none justify-start 4 ${i?"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 hover:bg-blue-100 dar
4k:hover:bg-blue-900/40":"hover:bg-gray-50 dark:hover:bg-slate-800/50"}`,children:[e.jsx("span",{className:"text-2xl flex-shrink-0",children:p(s.mimeType)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`font-medium truncate text-sm ${i?"text-blue-700 dark:text-blue-300":"text-gray-700 dark:text-slate-300"}`,title:s.displayName,children:s.displayName}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-500 mt-1 font-normal",children:[e.jsx("span",{children:F(s.sizeBytes)}),e.jsx("span",{children:"â¢"}),e.jsx("span",{children:m(s.createTime)})]})]})]},s.name)})]})]}),e.jsx("div",{className:`flex flex-col border-l border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-900/50 5 ${r?"flex":"hidden lg:flex"} 6 fixed inset-y-0 right-0 z-50 w-full max-w-[100vw] sm:max-w-md fixed-panel-safe 7 lg:relative lg:inset-auto lg:z-auto lg:w-[500px] lg:max-w-none lg:flex-shrink-0 lg:pb-0`,children:r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-white text-sm truncate",title:r.displayName,children:r.displayName}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:r.mimeType})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h&&e.jsxs(e.Fragment,{children:[e.jsx(o,{onClick:()=>window.open(h,"_blank","noopener,noreferrer"),variant:"ghost",size:"sm",className:"p-2 text-gray-600 hover:text-blue-600 dark:text-slate-400 dark:hover:text-blue-400 h-auto",title:"Open in new tab",children:e.jsx(X,{className:"h-4 w-4 rotate-90"})}),e.jsx(o,{onClick:z,variant:"ghost",size:"sm",className:"p-2 text-gray-600 hover:text-blue-600 dark:text-slate-400 dark:hover:text-blue-400 h-auto",title:"Download",children:e.jsx(X,{className:"h-4 w-4"})})]}),e.jsx(o,{onClick:()=>{c(null),f(null),j(null),u(null),N(null)},variant:"ghost",size:"sm",className:"p-2 text-gray-600 hover:text-red-600 dark:text-slate-400 dark:hover:text-red-400 h-auto",title:"Close preview",children:e.jsx(ae,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-600 dark:text-slate-400",children:[e.jsx("span",{children:F(r.sizeBytes)}),e.jsx("span",{children:"â¢"}),e.jsx("span",{children:m(r.createTime)})]})]}),e.jsxs("div",{className:"flex-1 overflow-hidden bg-white dark:bg-slate-950",children:[C&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-blue-600 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400",children:A?"Converting...":B?"Loading...":"Loading preview..."})]})}),g&&e.jsx("div",{className:"flex items-center justify-center h-full p-4",children:e.jsxs("div",{className:"text-center max-w-sm",children:[e.jsx(R,{className:"h-12 w-12 text-red-400 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-slate-300 mb-2 font-medium",children:"Preview Unavailable"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-slate-400 whitespace-pre-wrap",children:g})]})}),!C&&!g&&h&&_&&e.jsx("iframe",{src:h,className:"w-full h-full border-0",title:"PDF Preview",onError:()=>{N("PDF preview failed to load. Try opening in a new tab.")}}),!C&&!g&&A&&x&&e.jsx("div",{className:"h-full overflow-y-auto p-6",children:e.jsx("div",{className:"prose dark:prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:x},style:{fontSize:"13px",lineHeight:"1.6"}})}),!C&&!g&&B&&v&&e.jsx("div",{className:"h-full overflow-y-auto p-4",children:e.jsx("pre",{className:"text-xs text-gray-800 dark:text-slate-200 whitespace-pre-wrap font-mono leading-relaxed",children:v})}),!C&&!g&&h&&!_&&!A&&!B&&e.jsx("div",{className:"flex items-center justify-center h-full p-4",children:e.jsxs("div",{className:"text-center max-w-sm",children:[e.jsx(R,{className:"h-12 w-12 text-gray-300 dark:text-slate-600 mx-auto mb-3"}),e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Preview Not Supported"}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-400 mb-4",children:["This file type (",r.mimeType,") cannot be previewed."]}),e.jsx(o,{onClick:z,variant:"primary",size:"sm",leftIcon:e.jsx(X,{className:"h-4 w-4"}),children:"Download File"})]})})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center text-gray-400 dark:text-slate-600",children:[e.jsx(R,{className:"h-16 w-16 mx-auto mb-3"}),e.jsx("p",{className:"text-sm font-medium",children:"No file selected"}),e.jsx("p",{className:"text-xs mt-1",children:"Select a file to preview"})]})})})]})},pe=xe.lazy(()=>q(()=>import("./DocumentPreviewModal-CVr6_dXJ.js"),__vite__mapDeps([9,1,2,3,4,5,6,7])).then(n=>({default:n.DocumentPreviewModal}))),Q=n=>{const p=parseInt(n,10);return isNaN(p)?"Unknown size":p<1024?`${p} B`:p<1024*1024?`${(p/1024).toFixed(1)} KB`:`${(p/(1024*1024)).toFixed(1)} MB`},G=n=>{try{return new Date(n).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch{return"Unknown date"}},K=n=>n.includes("pdf")?"ð":n.includes("word")||n.includes("document")?"ð":n.includes("text")?"ð":"ð",Ne=({onBack:n})=>{const{state:p,actions:F}=re(),{corpusFiles:m,isUploadingFile:w,fileUploadError:I,isGuest:D}=p,{handleUploadCorpusFile:E,handleDeleteCorpusFile:b}=F,[S,r]=d.useState(""),[c,h]=d.useState("date"),[f,x]=d.useState("desc"),[j,v]=d.useState(null),[u,C]=d.use
7State("all"),[U,g]=d.useState(null),[N,T]=d.useState(null),[k,L]=d.useState("explorer"),z=d.useRef(null),P=t=>{var l;const a=(l=t.target.files)==null?void 0:l[0];a&&(E(a),z.current&&(z.current.value=""))},_=t=>{v(t)},A=async()=>{j&&(await b(j),v(null))},B=()=>{v(null)},s=t=>{c===t?x(f==="asc"?"desc":"asc"):(h(t),x("asc"))},i=m.filter(t=>{const a=t.displayName.toLowerCase().includes(S.toLowerCase()),l=u==="all"||t.category===u;return a&&l}).sort((t,a)=>{let l=0;return c==="name"?l=t.displayName.localeCompare(a.displayName):c==="date"?l=new Date(t.createTime).getTime()-new Date(a.createTime).getTime():c==="size"&&(l=parseInt(t.sizeBytes)-parseInt(a.sizeBytes)),f==="asc"?l:-l}),y=i.reduce((t,a)=>{const l=a.category||"other";return t[l]||(t[l]=[]),t[l].push(a),t},{}),M=m.reduce((t,a)=>{const l=a.category||"other";return t[l]=(t[l]||0)+1,t},{}),O=({field:t,label:a})=>e.jsxs(o,{onClick:()=>s(t),variant:"ghost",size:"sm",className:"inline-flex items-center gap-1 text-xs font-semibold text-gray-600 dark:text-slate-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors h-auto p-0 min-w-0 border-none",children:[a,c===t&&(f==="asc"?e.jsx(de,{className:"h-3 w-3"}):e.jsx(ce,{className:"h-3 w-3"}))]});return e.jsx("div",{className:"min-h-screen bg-gray-50 dark:bg-slate-900",children:e.jsxs("div",{className:"w-full max-w-[1850px] mx-auto px-3 sm:px-6 lg:px-10 xl:px-16 2xl:px-24 py-6 space-y-6",children:[e.jsxs("section",{className:"iconic-surface p-4 md:p-8 space-y-4",children:[e.jsx("div",{className:"flex items-center gap-3",children:n&&e.jsx(o,{onClick:n,variant:"ghost",size:"sm",className:"text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300 font-semibold",children:"â Back"})}),e.jsxs("div",{className:"flex flex-col xl:flex-row gap-6 items-start xl:items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx($,{className:"h-8 w-8 text-blue-500"}),e.jsx("p",{className:"iconic-badge",children:"Document Library"})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold rt-heading-font mb-2",children:"Career Document Library"}),e.jsx("p",{className:"text-sm md:text-base text-[var(--text-secondary)]/90 max-w-3xl leading-relaxed",children:"Upload and manage your career documents (resumes, performance reviews, project summaries). These files power AI-driven resume tailoring and career diary extraction."})]}),e.jsxs("div",{className:"iconic-surface-soft p-4 xl:w-80",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-[var(--text-secondary)]/60 font-semibold",children:"Storage Summary"}),e.jsx("p",{className:"text-3xl font-semibold text-[var(--text-primary)] mt-1",children:m.length}),e.jsxs("p",{className:"text-xs text-[var(--text-secondary)]/70",children:[m.length===1?"document":"documents"," uploaded"]})]})]})]}),!D&&e.jsxs("section",{className:"iconic-surface p-6 space-y-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-[var(--text-primary)]",children:"Upload Documents"}),(I||N)&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-500/30 text-red-700 dark:text-red-300 p-3 rounded-lg text-sm",children:I||N}),e.jsxs("div",{className:"border-2 border-dashed border-gray-300 dark:border-slate-600 rounded-2xl p-8 text-center hover:border-blue-400 dark:hover:border-blue-500 transition-colors bg-gray-50/50 dark:bg-slate-900/50",onDragOver:t=>t.preventDefault(),onDrop:t=>{var l;t.preventDefault();const a=(l=t.dataTransfer.files)==null?void 0:l[0];a&&E(a)},children:[e.jsx(R,{className:"h-12 w-12 mx-auto text-gray-400 dark:text-slate-500 mb-3"}),e.jsx("p",{className:"text-sm font-semibold text-gray-700 dark:text-slate-300 mb-1",children:"Drag and drop files here"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mb-4",children:"or click to browse (PDF, DOCX, TXT, MD)"}),e.jsx(o,{onClick:()=>{var t;return(t=z.current)==null?void 0:t.click()},disabled:w,loading:w,variant:"primary",size:"md",leftIcon:w?void 0:e.jsx(le,{className:"h-5 w-5"}),className:"rounded-full",children:"Browse Files"}),e.jsx("input",{type:"file",ref:z,onChange:P,className:"hidden",accept:".pdf,.docx,.txt,.md"})]})]}),e.jsxs("section",{className:"iconic-surface p-6 space-y-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("h2",{className:"text-xl font-semibold text-[var(--text-primary)]",children:["Your Documents (",i.length,")"]}),m.length>0&&e.jsxs("div",{className:"flex items-center gap-1 bg-gray-100 dark:bg-slate-800 rounded-lg p-1 h-9",children:[e.jsx(o,{onClick:()=>L("explorer"),variant:"ghost",size:"sm",className:`px-3 py-2 rounded-md text-xs font-semibold transition-all h-full border-none ${k==="explorer"?"bg-white dark:bg-slate-700 text-blue-600 dar
7k:text-blue-400 shadow-sm":"text-gray-600 dark:text-slate-400 hover:text-gray-900 dark:hover:text-slate-200"}`,title:"Explorer view",children:e.jsx(ne,{className:"h-4 w-4 inline"})}),e.jsx(o,{onClick:()=>L("folders"),variant:"ghost",size:"sm",className:`px-3 py-2 rounded-md text-xs font-semibold transition-all h-full border-none ${k==="folders"?"bg-white dark:bg-slate-700 text-blue-600 dark:text-blue-400 shadow-sm":"text-gray-600 dark:text-slate-400 hover:text-gray-900 dark:hover:text-slate-200"}`,title:"Folder view",children:e.jsx($,{className:"h-4 w-4 inline"})}),e.jsx(o,{onClick:()=>L("list"),variant:"ghost",size:"sm",className:`px-3 py-2 rounded-md text-xs font-semibold transition-all h-full border-none ${k==="list"?"bg-white dark:bg-slate-700 text-blue-600 dark:text-blue-400 shadow-sm":"text-gray-600 dark:text-slate-400 hover:text-gray-900 dark:hover:text-slate-200"}`,title:"List view",children:e.jsx(R,{className:"h-4 w-4 inline"})})]})]}),m.length>0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 md:w-64",children:[e.jsx(ie,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 dark:text-slate-500"}),e.jsx("input",{type:"text",value:S,onChange:t=>r(t.target.value),placeholder:"Search files...",className:"w-full pl-10 pr-3 py-2 rounded-xl border border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900 text-sm focus:ring-2 focus:ring-blue-500"})]}),k==="list"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{field:"name",label:"Name"}),e.jsx(O,{field:"date",label:"Date"}),e.jsx(O,{field:"size",label:"Size"})]})]})]}),m.length>0&&k==="list"&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(o,{onClick:()=>C("all"),variant:u==="all"?"primary":"secondary",size:"sm",className:`px-4 py-2 rounded-full text-sm font-semibold transition-all h-auto border-none 8 ${u==="all"?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-100 dark:bg-slate-800 text-gray-700 dark:text-slate-300 hover:bg-gray-200 dark:hover:bg-slate-700"}`,children:["All (",m.length,")"]}),me().map(t=>{const a=M[t]||0;return a===0?null:e.jsxs(o,{onClick:()=>C(t),variant:u===t?"primary":"secondary",size:"sm",className:`px-4 py-2 rounded-full text-sm font-semibold transition-all h-auto border-none 9 ${u===t?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-100 dark:bg-slate-800 text-gray-700 dark:text-slate-300 hover:bg-gray-200 dark:hover:bg-slate-700"}`,children:[V(t)," ",H(t)," (",a,")"]},t)})]})]}),k==="explorer"?e.jsx(ue,{filesByCategory:y,onDeleteFile:_,getFileIcon:K,formatFileSize:Q,formatDate:G}):k==="folders"?e.jsx(he,{filesByCategory:y,onPreviewFile:t=>{T(null),g(t)},onDeleteFile:_,getFileIcon:K,formatFileSize:Q,formatDate:G}):i.length===0?e.jsxs("div",{className:"text-center py-12 border-2 border-dashed border-gray-200 dark:border-slate-700 rounded-2xl",children:[e.jsx($,{className:"h-16 w-16 mx-auto text-gray-300 dark:text-slate-600 mb-4"}),e.jsx("p",{className:"text-lg font-semibold text-gray-700 dark:text-slate-300 mb-2",children:m.length===0?"No documents yet":"No matching documents"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:m.length===0?"Upload your first document to get started":"Try adjusting your search query"})]}):e.jsx("div",{className:"space-y-3",children:i.map(t=>{const a=!!t.supabaseStoragePath;return e.jsxs("div",{role:a?"button":void 0,tabIndex:a?0:-1,onClick:()=>{a?(T(null),g(t)):T("Preview unavailable for this file. Please re-upload to enable in-browser preview.")},onKeyDown:l=>{a&&(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),T(null),g(t))},className:`iconic-surface-soft p-4 flex items-center justify-between gap-4 hover:shadow-md transition-shadow ${a?"cursor-pointer focus:outline focus:outline-2 focus:outline-blue-500":"cursor-default"}`,children:[e.jsxs("div",{className:"flex items-center gap-4 flex-1 min-w-0",children:[e.jsx("span",{className:"text-3xl flex-shrink-0",children:K(t.mimeType)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-semibold text-[var(--text-primary)] truncate",title:t.displayName,children:t.displayName}),t.category&&e.jsxs("span",{className:"px-2 py-0.5 text-xs font-semibold rounded-full bg-blue-100 dar
9k:bg-blue-900/30 text-blue-700 dark:text-blue-300 flex-shrink-0",children:[V(t.category)," ",H(t.category)]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]/70 mt-1",children:[e.jsx("span",{children:Q(t.sizeBytes)}),e.jsx("span",{children:"â¢"}),e.jsx("span",{children:G(t.createTime)}),e.jsx("span",{children:"â¢"}),e.jsx("span",{className:"truncate",children:t.mimeType})]}),!a&&e.jsx("p",{className:"text-xs text-[var(--text-secondary)]/60 mt-1",children:"Preview unavailable (no storage reference)"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a&&e.jsx(o,{onClick:l=>{l.stopPropagation(),T(null),g(t)},variant:"ghost",size:"sm",className:"p-2 text-gray-400 hover:text-blue-500 dark:hover:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 h-auto",title:"Preview file",children:e.jsx(Z,{className:"h-5 w-5"})}),e.jsx(o,{onClick:l=>{l.stopPropagation(),_(t.name)},variant:"ghost",size:"sm",className:"p-2 text-gray-400 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 h-auto",title:"Delete file",children:e.jsx(J,{className:"h-5 w-5"})})]})]},t.name)})})]}),U&&e.jsx(d.Suspense,{fallback:e.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center z-50",children:e.jsx(oe,{})}),children:e.jsx(pe,{file:U,onClose:()=>g(null)})}),j&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl p-6 max-w-md w-full shadow-2xl",children:[e.jsx("h3",{className:"text-xl font-bold text-gray-900 dark:text-white mb-2",children:"Delete Document?"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400 mb-6",children:"Are you sure you want to delete this document? This action cannot be undone and the file will be removed from your document library."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(o,{onClick:A,variant:"danger",size:"lg",className:"flex-1",children:"Delete"}),e.jsx(o,{onClick:B,variant:"secondary",size:"lg",className:"flex-1",children:"Cancel"})]})]})})]})})};export{Ne as CorpusManager};
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.