var U=Object.defineProperty,$=Object.defineProperties;var k=Object.getOwnPropertyDescriptors;var d=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var g=(e,s,o)=>s in e?U(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o,j=(e,s)=>{for(var o in s||(s={}))w.call(s,o)&&g(e,o,s[o]);if(d)for(var o of d(s))b.call(s,o)&&g(e,o,s[o]);return e},v=(e,s)=>$(e,k(s));var N=(e,s)=>{var o={};for(var r in e)w.call(e,r)&&s.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&d)for(var r of d(e))s.indexOf(r)<0&&b.call(e,r)&&(o[r]=e[r]);return o};import{aT as I,r as R,j as t,b5 as S,cw as y,bh as _}from"./react-vendor-xYZnmIII.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";const W=V=>{var x=V,{src:e,fileName:s,className:o}=x,r=N(x,["src","fileName","className"]);const{props:F}=I(),{translate:C}=F,{frontend:n}=C,u=R.useMemo(()=>{const l=a=>{var m;return((m=a.split("?")[0].split(".").pop())==null?void 0:m.toLowerCase())||""},p=a=>{const h=["pdf"],f=["doc","docx","xls","xlsx","ppt","pptx","odt","ods","odp"],m=["jpg","jpeg","png","gif","bmp","webp","svg"],E=["txt","rtf","csv"];return h.includes(a)?"pdf":f.includes(a)?"office":m.includes(a)?"image":E.includes(a)?"text":"unsupported"},c=l(e),i=p(c);return{extension:c,type:i}},[e]),D=()=>{const l="h-full max-h-[calc(100vh-60px)] min-h-[80vh] w-full";switch(u.type){case"pdf":return t.jsx("iframe",{src:e,width:"100%",height:"100%",allowFullScreen:!0,title:n.pdf_document,className:l});case"office":{const p=`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(e)}`;return t.jsxs("div",{className:"relative h-full",children:[t.jsx("iframe",{src:p,width:"100%",height:"100%",allowFullScreen:!0,title:`${u.extension.toUpperCase()} Document`,className:l,onError:()=>{const c=`https://docs.google.com/gview?url=${encodeURIComponent(e)}&embedded=true`,i=document.querySelector('iframe[src*="officeapps.live.com"]');i&&(i.src=c)}}),t.jsxs("div",{className:"absolute top-2 right-2 flex gap-2",children:[t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"bg-white/90 hover:bg-white p-2 rounded-md shadow-sm transition-colors",title:n.open_in_new_tab,children:t.jsx(y,{className:"w-4 h-4 text-gray-600"})}),t.jsx("a",{href:e,download:s,className:"bg-white/90 hover:bg-white p-2 rounded-md shadow-sm transition-colors",title:n.download_document,children:t.jsx(_,{className:"w-4 h-4 text-gray-600"})})]})]})}case"image":return t.jsx("div",{className:"flex items-center justify-center h-full bg-gray-50",children:t.jsx("img",{src:e,alt:s||n.document,className:"max-w-full max-h-full object-contain"})});case"text":return t.jsx("iframe",{src:e,width:"100%",height:"100%",title:n.text_document,className:l});default:return t.jsxs("div",{className:"flex flex-col items-center justify-center h-full bg-gray-50 text-gray-600",children:[t.jsx(S,{className:"w-16 h-16 mb-4 text-gray-400"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:n.unsupported_document_format}),t.jsx("p",{className:"text-sm text-center mb-6 max-w-md",children:n.document_format_cannot_be_previewed.replace("{extension}",u.extension)}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors",children:[t.jsx(y,{className:"w-4 h-4"}),n.open_in_new_tab_button]}),t.jsxs("a",{href:e,download:s,className:"inline-flex items-center gap-2 px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 transition-colors",children:[t.jsx(_,{className:"w-4 h-4"}),n.download]})]})]})}};return t.jsx("div",v(j({className:`h-full ${o||""}`},r),{children:D()}))};export{W as default};
