import{u as T,b as z,r as G,j as e}from"./vendor-BKmmeuxg.js";import{C as p}from"./combobox-Byd5-E0j.js";import{I as c}from"./input-error-LaPr_4wd.js";import{L as P}from"./loading-button-BnTVAMJ7.js";import{A as N,a as C,c as F}from"./accordion-CNBvFN43.js";import{C as w}from"./card-D9_SJYq6.js";import{C as B}from"./checkbox-BBZKtHnN.js";import{I as m}from"./input-DM0goJrn.js";import{L as i}from"./label-HmIcv5Yx.js";import{R as j,a as u}from"./radio-group-C0C2vfl-.js";import{S as $,a as q,b as J,c as K,d as O}from"./select-CD9o3HN1.js";import{T as Q}from"./textarea-CyndvowL.js";import{c as U}from"./course-durations-B0f021Xm.js";import{c as W}from"./course-languages-DcPHNS0l.js";import{D as X}from"./layout-DkwBWm5d.js";import{o as l}from"./inertia-SZXqLvQm.js";import{k as Y}from"./richtor-CRcM6Du2.js";import"./button-BpNwv2aE.js";import"./index-WW_1X1qx.js";import"./utils-DxSsnXxD.js";import"./popover-B4kBsMuI.js";import"./sidebar-BYcYxQeZ.js";import"./separator-_3LZ_wAA.js";import"./sheet-DSvHVmaW.js";import"./tooltip-BsX7Z6vz.js";import"./main-_V386djS.js";import"./index-D9-QKOod.js";import"./appearance-D2z3xcjR.js";import"./dropdown-menu-DO-po5c1.js";import"./app-BytVvUs_.js";/* empty css */import"./language-BFZ7KItL.js";import"./notification-CYMPYbAP.js";import"./scroll-area-C8HGru-R.js";import"./app-logo-CmnEIwal.js";import"./route-B4ZMN77y.js";import"./avatar-j28afJTV.js";import"./use-lang-YfV87_zl.js";const Z=n=>{const{props:S}=T(),{translate:I}=S,{input:r,button:V,common:_}=I,h=n.auth.user,{labels:L,prices:g,expiries:v,categories:f,instructors:k,system:y}=n,{data:a,setData:t,post:D,errors:o,processing:A}=z({title:"",short_description:"",description:"",status:"draft",level:"",language:"",pricing_type:"paid",price:"",discount:!1,discount_price:"",expiry_type:"lifetime",expiry_duration:"",drip_content:!1,thumbnail:null,instructor_id:h.role==="admin"&&y.sub_type==="collaborative"?"":h.instructor_id,course_category_id:"",course_category_child_id:""}),M=s=>{s.preventDefault(),D(route("courses.store"))},R=G.useMemo(()=>f.flatMap(s=>{var b;const x={label:s.title,value:s.title,id:s.id,child_id:""},H=((b=s.category_children)==null?void 0:b.map(d=>({label:`--${d.title}`,value:d.title,id:d.course_category_id,child_id:d.id})))||[];return[x,...H]}),[f]),E=k.map(s=>({label:s.user.name,value:s.id}));return e.jsx(w,{className:"container p-6",children:e.jsxs("form",{onSubmit:M,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(i,{children:[r.title," *"]}),e.jsx(m,{name:"title",value:a.title,onChange:s=>l(s,t),placeholder:r.title_placeholder}),e.jsx(c,{message:o.title})]}),e.jsxs("div",{children:[e.jsx(i,{children:r.short_description}),e.jsx(Q,{rows:5,name:"short_description",value:a.short_description,onChange:s=>l(s,t),placeholder:r.short_description_placeholder}),e.jsx(c,{message:o.short_description})]}),e.jsxs("div",{children:[e.jsx(i,{children:r.description}),e.jsx(Y,{ssr:!0,output:"html",placeholder:{paragraph:r.description_placeholder,imageCaption:r.description_placeholder},contentMinHeight:256,contentMaxHeight:640,initialContent:a.description,onContentChange:s=>t(x=>({...x,description:s}))}),e.jsx(c,{message:o.description})]})]}),e.jsxs("div",{className:"space-y-4",children:[h.role==="admin"&&y.sub_type==="collaborative"&&e.jsxs("div",{children:[e.jsxs(i,{htmlFor:"instructor_id",children:[r.course_instructor," *"]}),e.jsx(p,{defaultValue:a.instructor_id,data:E||[],placeholder:r.course_instructor,onSelect:s=>t("instructor_id",s.value)}),e.jsx(c,{message:o.instructor_id})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsxs(i,{htmlFor:"course_category_id",children:[r.category," *"]}),e.jsx(p,{data:R,placeholder:r.category_placeholder,onSelect:s=>{t("course_category_id",s.id),t("course_category_child_id",s.child_id)}}),e.jsx(c,{message:o.course_category_id})]}),e.jsxs("div",{children:[e.jsxs(i,{htmlFor:"level",children:[r.course_level," *"]}),e.jsxs($,{value:a.level,onValueChange:s=>t("level",s),children:[e.jsx(q,{children:e.jsx(J,{placeholder:r.course_level_placeholder})}),e.jsx(K,{children:L.map(s=>e.jsx(O,{value:s,children:s},s))})]}),e.jsx(c,{message:o.level})]})]}),e.jsxs("div",{children:[e.jsxs(i,{children:[r.course_language," *"]}),e.jsx(p,{data:W,placeholder:r.course_language_placeholder,onSelect:s=>t("language",s.value)}),e.jsx(c,{message:o.language})]}),e.jsxs("div",{children:[e.jsxs(i,{children:[r.pricing_type," *"]}),e.jsx(j,{defaultValue:a.pricing_type,className:"flex items-center space-x-4 pt-2 pb-1",onValueChange:s=>t("pricing_type",s),children:g.map(s=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(u,{className:"cursor-pointer",id:s,value:s}),e.jsx(i,{htmlFor:s,className:"capitalize",children:s})]},s))}),e.jsx(c,{message:o.pricing_type}),e.jsx(N,{collapsible:!0,type:"single",value:a.pricing_type,children:e.jsx(C,{value:g[1],className:"border-none",children:e.jsxs(F,{className:"space-y-4 p-0.5",children:[e.jsxs("div",{className:"pt-3",children:[e.jsxs(i,{htmlFor:"price",children:[r.price," *"]}),e.jsx(m,{type:"number",name:"price",value:a.price,onChange:s=>l(s,t),placeholder:r.course_price_placeholder}),e.jsx(c,{message:o.price})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(B,{id:"discount",name:"discount",checked:a.discount,onCheckedChange:s=>{t("discount",s)}}),e.jsx(i,{htmlFor:"discount",children:r.course_discount})]}),a.discount&&e.jsxs("div",{children:[e.jsx(m,{type:"number",name:"discount_price",value:a.discount_price,onChange:s=>l(s,t),placeholder:r.discount_price_placeholder}),e.jsx(c,{message:o.discount_price})]})]})]})})})]}),e.jsxs("div",{children:[e.jsx(i,{children:r.expiry_period_type}),e.jsx(j,{defaultValue:a.expiry_type,className:"flex items-center space-x-4 pt-2 pb-1",onValueChange:s=>t("expiry_type",s),children:v.map(s=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(u,{className:"cursor-pointer",id:s,value:s}),e.jsx(i,{htmlFor:s,className:"capitalize",children:s.replace("_"," ")})]},s))}),e.jsx(c,{message:o.expiry_type}),e.jsx(N,{collapsible:!0,type:"single",value:a.expiry_type,children:e.jsx(C,{value:v[1],className:"border-none",children:e.jsx(F,{className:"space-y-4 p-0.5",children:e.jsxs("div",{className:"pt-3",children:[e.jsx(i,{htmlFor:"expiry_duration",children:r.expiry_duration}),e.jsx(p,{defaultValue:a.expiry_duration,data:U,placeholder:r.expiry_duration_placeholder||"Select duration",onSelect:s=>t("expiry_duration",s.value)}),e.jsx(c,{message:o.expiry_duration})]})})})})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"thumbnail",children:r.thumbnail}),e.jsx(m,{type:"file",name:"thumbnail",onChange:s=>l(s,t)}),e.jsx(c,{message:o.thumbnail})]}),e.jsxs("div",{children:[e.jsxs(i,{htmlFor:"drip_content",children:[r.enable_drip_content," *"]}),e.jsxs(j,{defaultValue:a.drip_content?"on":"off",className:"flex items-center space-x-4 pt-2 pb-1",onValueChange:s=>t("drip_content",s==="on"),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(u,{className:"cursor-pointer",id:"off",value:"off"}),e.jsx(i,{htmlFor:"off",children:_.off})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(u,{className:"cursor-pointer",id:"on",value:"on"}),e.jsx(i,{htmlFor:"on",children:_.on})]})]}),e.jsx(c,{message:o.drip_content})]})]})]}),e.jsx("div",{className:"col-span-2 mt-6 text-right",children:e.jsx(P,{loading:A,children:V.create_course})})]})})};Z.layout=n=>e.jsx(X,{children:n});export{Z as default};