import{r as e,j as s}from"./vendor-react-Dp9pL_Wn.js";import{d as i,S as t,c as n}from"./vendor-ant-cds-DvTmcYA1.js";import{M as a}from"./vendor-intl-BDR1NhN_.js";import{D as l,c as o,d as c}from"./c0632795f-DFHAnV4h.js";import{a5 as d}from"./c4b350ac1-KLFM4jkb.js";const r=e.memo(({file:r,isLoading:m,hideFileName:x,hideCopyButton:p,hideDescriptionHeading:f,leadingActions:h})=>{const{copyToClipboard:j,didCopy:g}=i(),[v,u]=e.useState("normal"),w=r?.path||"",y=w.split("/").pop()||"",{fileMimeType:b,fileSyntax:N,displayFileType:C,showViewToggle:M,isTextContent:T}=d(w),F=e.useCallback(async()=>{"string"==typeof r?.content&&await j(r.content)},[j,r?.content]);if(m)return s.jsxs("div",{"aria-busy":"true",className:n("flex flex-col flex-1 min-h-0 gap-3",x&&"p-5 font-base"),children:[s.jsx(t,{width:"45%",height:"1.25em",className:"mb-1"}),s.jsx(t,{width:"100%"}),s.jsx(t,{width:"95%"}),s.jsx(t,{width:"100%"}),s.jsx(t,{width:"60%"})]});if(!r)return null;if(r.contentsOmitted){const e=void 0!==r.size?(r.size/1048576).toFixed(1):void 0;return s.jsxs("div",{className:"flex flex-1 flex-col min-h-0",children:[!x&&s.jsx("div",{className:"flex items-center justify-between pb-2",children:s.jsx("span",{className:"font-base text-text-500",children:y})}),x&&h&&s.jsx("div",{className:"flex items-center gap-sm px-4 pt-3 min-w-0",children:h}),s.jsx("div",{className:"flex flex-1 items-center justify-center text-text-400",children:e?s.jsx(a,{defaultMessage:"{sizeMb} MB \u2014 too large to preview",id:"CcdMgiliKQ",values:{sizeMb:e}}):s.jsx(a,{defaultMessage:"File is too large to preview",id:"nVfvltfEIc"})})]})}const S=T&&(M||!p)&&(p?M&&s.jsx(o,{viewing:v,onViewingChange:u}):s.jsx(c,{viewing:v,onViewingChange:u,onCopy:F,didCopy:g,showToggle:M,inline:!0}));return s.jsxs("div",{className:"relative flex flex-1 flex-col min-h-0",children:[!x&&s.jsxs("div",{className:"flex items-center justify-between pb-2",children:[s.jsx("span",{className:"font-base text-text-500",children:y}),S]}),x&&h&&s.jsxs("div",{className:"flex items-center justify-between gap-sm px-4 pt-3",children:[s.jsx("div",{className:"flex items-center gap-sm min-w-0",children:h}),S&&s.jsx("div",{className:"shrink-0",children:S})]}),x&&!h&&S&&s.jsx("div",{className:"absolute top-3 right-3 z-[1] rounded-md bg-surface-1",children:S}),s.jsx("div",{className:n("flex-1 min-h-0",x&&("code"===C?"font-base":"p-5")),children:s.jsx(l,{content:r.content,displayFileType:C,language:N,viewing:v,fileName:y,mimeType:b,noAutoScroll:!0,compact:!0,proseInset:x,scrollFade:!0,typography:x?"inherit":void 0,hideDescriptionHeading:f})})]})});r.displayName="SkillFilePreview";export{r as S};
