PageSourceSearch

https://careerdiary.io/assets/DocumentPreviewModal-D6Mh6NNB.js

js careerdiary.io collected 2026-10-02 01:59:19 UTC 6,991 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/gcsStorageService-CRDg_3EU.js","assets/index-DnWsV7cE.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"])))=>i.map(i=>d[i]);
2import{af as g,B as w,aH as p,X as _,_ as P}from"./index-DnWsV7cE.js";import{r as c,j as e}from"./animation-CddyXVCz.js";import"./react-vendor-CbN3pvl2.js";import"./supabase-iKSPld20.js";import"./docgen-Bp8WKBAE.js";import"./query-DPqpbKNH.js";const O=({file:t,onClose:v})=>{const[s,k]=c.useState(null),[y,D]=c.useState(null),[b,T]=c.useState(null),[m,j]=c.useState(!1),[n,l]=c.useState(null),N=t.mimeType==="application/pdf",d=t.mimeType==="application/vnd.openxmlformats-officedocument.wordprocessingml.document",x=t.mimeType==="text/plain";c.useEffect(()=>{(async()=>{if(!t.supabaseStoragePath){console.warn("[DocumentPreview] No supabaseStoragePath for file:",t.displayName),l("Preview not available for this file. Please re-upload to enable in-browser preview.");return}console.log("[DocumentPreview] Loading preview for:",{fileName:t.displayName,mimeType:t.mimeType,storagePath:t.supabaseStoragePath}),j(!0),l(null);try{const{getSignedUrl:h}=await P(async()=>{const{getSignedUrl:a}=await import("./gcsStorageService-CRDg_3EU.js");return{getSignedUrl:a}},__vite__mapDeps([0,1,2,3,4,5,6,7])),i=await h(t.supabaseStoragePath,3600);if(console.log("[DocumentPreview] Signed URL generated successfully"),k(i),d){console.log("[DocumentPreview] Converting DOCX to HTML...");try{const{default:a}=await P(async()=>{const{default:E}=await import("./index-C7IeTs5z.js").then(S=>S.i);return{default:E}},__vite__mapDeps([8,3,5])),o=await fetch(i);if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);const C=await o.arrayBuffer(),u=await a.convertToHtml({arrayBuffer:C});console.log("[DocumentPreview] DOCX conversion successful",{warnings:u.messages.length,htmlLength:u.value.length}),u.messages.length>0&&console.warn("[DocumentPreview] DOCX conversion warnings:",u.messages),D(u.value)}catch(a){console.error("[DocumentPreview] DOCX conversion failed:",a),l(`Failed to convert Word document: ${a instanceof Error?a.message:"Unknown error"}`);return}}if(x){console.log("[DocumentPreview] Fetching text content...");try{const a=await fetch(i);if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);const o=await a.text();console.log("[DocumentPreview] Text content loaded:",{length:o.length}),T(o)}catch(a){console.error("[DocumentPreview] Text fetch failed:",a),l(`Failed to load text file: ${a instanceof Error?a.message:"Unknown error"}`);return}}}catch(h){const i=h instanceof Error?h.message:"Unknown error";console.error("[DocumentPreview] Failed to load preview:",{error:h,message:i,file:t.displayName}),l(`Failed to load preview: ${i}`)}finally{j(!1)}})()},[t.supabaseStoragePath,t.displayName,t.mimeType,d,x]);const f=()=>{if(s){const r=document.createElement("a");r.href=s,r.download=t.displayName,document.body.appendChild(r),r.click(),document.body.removeChild(r)}};return e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4 animate-fadeIn backdrop-blur-sm",onClick:v,children:e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl shadow-2xl w-full max-w-5xl h-[90vh] flex flex-col animate-zoomIn",onClick:r=>r.stopPropagation(),style:{animation:"zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)"},children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-slate-700",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx(g,{className:"h-6 w-6 text-blue-500 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-white truncate",children:t.displayName}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:t.mimeType})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s&&e.jsx(w,{onClick:()=>window.open(s,"_blank","noopener,noreferrer"),variant:"ghost",size:"sm",title:"Open in new tab",className:"p-2",children:e.jsx(p,{className:"h-5 w-5 rotate-90"})}),s&&e.jsx(w,{onClick:f,variant:"ghost",size:"sm",title:"Download",className:"p-2",children:e.jsx(p,{className:"h-5 w-5"})}),e.jsx(w,{onClick:v,variant:"ghost",size:"sm",title:"Close",className:"p-2 hover:text-red-600 dark:hover:text-red-400",children:e.jsx(_,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-hidden",children:[m&&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-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-slate-400",children:d?"Convert
2ing Word document...":x?"Loading text file...":"Loading preview..."})]})}),n&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center max-w-md px-4",children:[e.jsx(g,{className:"h-16 w-16 text-red-400 dark:text-red-500 mx-auto mb-4"}),e.jsx("p",{className:"text-lg font-semibold text-gray-700 dark:text-slate-300 mb-2",children:"Preview Unavailable"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400 mb-4 whitespace-pre-wrap",children:n}),s&&e.jsx(w,{onClick:f,variant:"primary",size:"lg",leftIcon:e.jsx(p,{className:"h-5 w-5"}),children:"Download File"})]})}),!m&&!n&&s&&N&&e.jsx("iframe",{src:s,className:"w-full h-full border-0",title:"PDF Preview",onError:()=>{console.error("[DocumentPreview] PDF iframe failed to load"),l("PDF preview failed to load. Try opening in a new tab or downloading the file.")}}),!m&&!n&&d&&y&&e.jsx("div",{className:"h-full overflow-y-auto p-8 bg-white dark:bg-slate-900",children:e.jsx("div",{className:"max-w-4xl mx-auto prose dark:prose-invert prose-slate",dangerouslySetInnerHTML:{__html:y},style:{fontSize:"14px",lineHeight:"1.6"}})}),!m&&!n&&x&&b&&e.jsx("div",{className:"h-full overflow-y-auto p-6 bg-gray-50 dark:bg-slate-950",children:e.jsx("pre",{className:"text-sm text-gray-800 dark:text-slate-200 whitespace-pre-wrap font-mono leading-relaxed",children:b})}),!m&&!n&&s&&!N&&!d&&!x&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx(g,{className:"h-16 w-16 text-gray-300 dark:text-slate-600 mx-auto mb-4"}),e.jsx("p",{className:"text-lg font-semibold text-gray-700 dark:text-slate-300 mb-2",children:"Preview Not Supported"}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-4",children:["This file type (",t.mimeType,") cannot be previewed in the browser."]}),e.jsx(w,{onClick:f,variant:"primary",size:"lg",leftIcon:e.jsx(p,{className:"h-5 w-5"}),children:"Download File"})]})})]})]})})};export{O as DocumentPreviewModal};

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.