import{i as y,j as o,B as R,b as c,at as k,d as p,I as a}from"./mui-vendor-CkIVaoQP.js";import{r as x}from"./react-vendor-CmFgShSM.js";import{d as g}from"./Download-Br3kJHkt.js";import{d as w}from"./Close-C8iZ2Qr6.js";import{r as F,m as E}from"./index-Cr86_nOs.js";var i={},I=y;Object.defineProperty(i,"__esModule",{value:!0});var m=i.default=void 0,S=I(F()),_=o;m=i.default=(0,S.default)((0,_.jsx)("path",{d:"M15.55 5.55 11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10zM19.93 11c-.17-1.39-.72-2.73-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47zM13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03m3.89-2.42 1.42 1.41c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.48"}),"RotateRight");const A=[".jpg",".jpeg",".png",".gif",".bmp",".webp",".svg"],q=({src:e,size:n})=>{const[f,s]=x.useState(!1),[h,b]=x.useState(0),C=()=>s(!0),u=()=>s(!1),l=()=>{if(!(!e||typeof e!="string"))try{const t=document.createElement("a");t.href=e;const r=e.split("/").pop()||"document";t.download=r,t.click()}catch(t){console.error("Error downloading file:",t)}},v=()=>{b(t=>t+90)},d=()=>{if(!e||typeof e!="string")return"";try{const t=e.split("/").pop();if(!t||typeof t!="string")return"";const r=t.lastIndexOf(".");return r===-1?"":t.substring(r+1).toLowerCase()}catch(t){return console.error("Error getting file extension:",t),""}},j=()=>{if(!e||typeof e!="string")return!1;const t=d();return A.includes(`.${t}`)};if(!e||typeof e!="string")return"-";if(!j()){const t=d(),r=t?`دانلود سند ${t}`:"دانلود سند";return o.jsx(R,{size:"small",variant:"contained",startIcon:o.jsx(g,{}),onClick:l,sx:{textTransform:"none",fontSize:"0.8rem",padding:"5px 10px"},children:r})}return o.jsxs("div",{children:[o.jsx(c,{component:"img",src:e,alt:"thumbnail",sx:{width:n||"50px",height:n||"50px",cursor:"pointer",borderRadius:"10px"},onClick:C}),o.jsx(k,{open:f,onClose:u,"aria-labelledby":"modal-modal-title","aria-describedby":"modal-modal-description",sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsxs(E.div,{initial:{scale:0},animate:{scale:1},exit:{scale:0},transition:{duration:.3},style:{position:"relative"},children:[o.jsx(c,{component:"img",src:e,alt:"full-size",sx:{maxWidth:"90vw",maxHeight:"90vh",minWidth:"40vw",minHeight:"40vh",borderRadius:"10px",transform:`rotate(${h}deg)`,transition:"transform 0.3s"}}),o.jsx(p,{title:"جهت دانلود تصویر کلید کنید",placement:"right",children:o.jsx(a,{color:"primary",onClick:l,sx:{position:"absolute",top:16,right:16,backgroundColor:"rgba(255, 255, 255, 0.7)","&:hover":{backgroundColor:"rgba(255, 255, 255, 1)"},boxShadow:"0 2px 10px rgba(0, 0, 0, 0.2)",borderRadius:"50%"},children:o.jsx(g,{})})}),o.jsx(p,{title:"چرخش تصویر",placement:"right",children:o.jsx(a,{color:"default",onClick:v,sx:{position:"absolute",bottom:16,right:16,backgroundColor:"rgba(255, 255, 255, 0.7)","&:hover":{backgroundColor:"rgba(255, 255, 255, 1)"},boxShadow:"0 2px 10px rgba(0, 0, 0, 0.2)",borderRadius:"50%"},children:o.jsx(m,{})})}),o.jsx(a,{color:"secondary",onClick:u,sx:{position:"absolute",top:16,left:16,backgroundColor:"rgba(255, 255, 255, 0.7)","&:hover":{backgroundColor:"rgba(255, 255, 255, 1)"},boxShadow:"0 2px 10px rgba(0, 0, 0, 0.2)",borderRadius:"50%"},children:o.jsx(w,{})})]})})]})};export{q as S};
