import{u as d,j as s,L as m,e as c}from"./vendor-rThclpOQ.js";import{C as f}from"./checkout-item-D3TnO8UJ.js";import{B as i}from"./button-ZcsoqUQn.js";import"./index-DquVdLUg.js";import"./utils-8KAaAB9H.js";const y=({watchHistory:r})=>{const{props:e}=d(),{translate:o}=e,{frontend:l}=o;return s.jsx(i,{size:"lg",className:"w-full",asChild:!0,children:s.jsx(m,{href:route("course.player",{type:r.current_watching_type,watch_history:r.id,lesson_id:r.current_watching_id}),children:l.play_course})})},x=()=>{const{auth:r,course:e,approvalStatus:o,translate:l}=d().props,{frontend:t}=l;return o.approve_able?s.jsx(s.Fragment,{children:r.user.role==="instructor"?e.instructor_id===r.user.instructor_id?s.jsx(i,{size:"lg",className:"w-full",onClick:()=>c.post(route("player.init.watch-history"),{course_id:e.id}),children:t.play_course}):s.jsx(h,{}):s.jsx(i,{size:"lg",className:"w-full",onClick:()=>c.post(route("player.init.watch-history"),{course_id:e.id}),children:t.play_course})}):s.jsx(i,{disabled:!0,size:"lg",className:"w-full",children:t.course_player})},h=()=>{const{auth:r,course:e,translate:o,wishlists:l}=d().props,{frontend:t}=o,a=n=>{var p;c.post(route("enrollments.store"),{user_id:(p=r.user)==null?void 0:p.id,course_id:n.id,enrollment_type:"free"})},u=l.find(n=>n.course_id===e.id),_=()=>{var n;u?c.delete(route("course-wishlists.destroy",{id:u.id})):c.post(route("course-wishlists.store",{user_id:(n=r.user)==null?void 0:n.id,course_id:e.id}))};return s.jsxs(s.Fragment,{children:[s.jsx(i,{className:"w-full px-1 sm:px-3",variant:"outline",size:"lg",onClick:_,children:u?t.remove_from_wishlist:t.add_to_wishlist}),e.pricing_type==="free"?s.jsx(i,{size:"lg",className:"w-full",onClick:()=>a(e),children:t.enroll_now}):s.jsx(f,{item:"course",item_id:e.id,children:s.jsx(i,{size:"lg",className:"w-full",children:t.buy_now})})]})},C=()=>{const{auth:r,enrollment:e,watchHistory:o}=d().props,l=!!e,t=!!o,a=r.user&&["admin","instructor"].includes(r.user.role);return t&&(a||l)?s.jsx(y,{watchHistory:o}):a?s.jsx(x,{}):s.jsx(h,{})};export{C as default};
