import{r as p,j as e,cX as h,c3 as x,t as j}from"./vendor-rThclpOQ.js";import{B as a}from"./button-ZcsoqUQn.js";import N from"./resource-form-RXiQG8XD.js";import"./index-DquVdLUg.js";import"./utils-8KAaAB9H.js";import"./chunked-uploader-input-rUbaF7V3.js";import"./input-BeqyurrI.js";import"./index-CWNIUFqh.js";import"./input-error-Br4ngfdE.js";import"./loading-button-DKhpmf6V.js";import"./label-CtY1vfZY.js";import"./select-u0okJC03.js";import"./file-metadata-CAFSN-Sn.js";import"./inertia-SZXqLvQm.js";const R=({lesson:i,isSubmit:c,setIsSubmit:d,setOpen:o})=>{const[m,l]=p.useState(""),n=async(s,t)=>{t.preventDefault();try{const r=route("resources.download",s.id);window.open(r,"_blank")}catch{window.open(s.resource,"_blank")}};return e.jsx("div",{className:"space-y-4 py-3",children:i.resources.length>0?i.resources.map(s=>e.jsx("div",{className:"bg-muted rounded-md p-1.5",children:s.id===m?e.jsxs("div",{className:"relative",children:[e.jsx(N,{lesson:i,resource:s,isSubmit:c,setIsSubmit:d,setIsOpen:o}),e.jsx(a,{variant:"secondary",className:"absolute right-0 bottom-0",onClick:()=>l(""),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"w-full px-1",children:s.type==="link"?e.jsx("a",{target:"_blank",href:s.resource,className:"cursor-pointer text-sm hover:underline",children:s.title.slice(0,50)+(s.title.length>50?"...":"")}):e.jsx("span",{className:"cursor-pointer text-sm hover:underline",onClick:t=>n(s,t),children:s.title.slice(0,50)+(s.title.length>50?"...":"")})}),e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(a,{size:"icon",variant:"secondary",className:"h-7 w-7",onClick:()=>l(s.id),children:e.jsx(h,{className:"h-3 w-3"})}),s.type!=="link"?e.jsx(a,{asChild:!0,size:"icon",variant:"secondary",className:"h-7 w-7",children:e.jsx("a",{target:"_blank",href:s.resource,children:e.jsx(x,{className:"h-3 w-3"})})}):e.jsx(a,{size:"icon",variant:"secondary",className:"h-7 w-7",onClick:t=>n(s,t),children:e.jsx(j,{className:"h-3 w-3"})})]})]},s.id)})):e.jsx("div",{className:"bg-muted rounded-md p-1.5",children:e.jsx("div",{className:"w-full px-1 py-6 text-center",children:e.jsx("p",{className:"text-sm",children:"No resources available"})})})})};export{R as default};
