var M=Object.defineProperty,w=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var u=(r,t,a)=>t in r?M(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a,j=(r,t)=>{for(var a in t||(t={}))F.call(t,a)&&u(r,a,t[a]);if(h)for(var a of h(t))P.call(t,a)&&u(r,a,t[a]);return r},g=(r,t)=>w(r,z(t));import{aT as R,aU as U,r as k,j as e}from"./react-vendor-xYZnmIII.js";import{C as v}from"./combobox-BOClc6J1.js";import{I as c}from"./input-error-_LAmvivg.js";import{L as q}from"./loading-button-D7aXR3K4.js";import{a as A,L as d,I as G,T as J,at as f,au as _,av as S,aw as C,ax as b}from"./ui-components-CQM92IK3.js";import{o as y}from"./inertia-FIn3q7f1.js";import{j as K}from"./richtor-BECSBxkh.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./interactive-vendor-B1OgcAgP.js";const re=()=>{const{props:r}=R(),{auth:t,system:a,tab:E,categories:m,exam:i,instructors:x}=r,{data:n,setData:o,post:I,errors:l,processing:N}=U({tab:E,title:i.title||"",short_description:i.short_description||"",description:i.description||"",status:i.status||"draft",level:i.level||"",instructor_id:i.instructor_id||"",exam_category_id:i.exam_category_id||""}),D=s=>{s.preventDefault(),I(route("exams.update",{exam:i.id}))},L=k.useMemo(()=>m.map(s=>({label:s.title,value:s.id.toString()})),[m]),T=x==null?void 0:x.map(s=>({label:s.user.name,value:s.id.toString()})),V=["beginner","intermediate","advanced"],H=["draft","published","archived"],p=m.find(s=>s.id===n.exam_category_id);return e.jsx(A,{className:"container p-4 sm:p-6",children:e.jsxs("form",{onSubmit:D,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(d,{children:"Exam Title *"}),e.jsx(G,{name:"title",value:n.title,onChange:s=>y(s,o),placeholder:"Enter exam title"}),e.jsx(c,{message:l.title})]}),e.jsxs("div",{children:[e.jsx(d,{children:"Short Description"}),e.jsx(J,{rows:5,name:"short_description",value:n.short_description,onChange:s=>y(s,o),placeholder:"Brief description for exam cards"}),e.jsx(c,{message:l.short_description})]}),e.jsxs("div",{children:[e.jsx(d,{children:"Description"}),e.jsx(K,{ssr:!0,output:"html",placeholder:{paragraph:"Enter detailed exam description...",imageCaption:"Enter detailed exam description..."},contentMinHeight:256,contentMaxHeight:640,initialContent:n.description,onContentChange:s=>o(B=>g(j({},B),{description:s}))}),e.jsx(c,{message:l.description})]}),t.user.role==="admin"&&a.sub_type==="collaborative"&&e.jsxs("div",{children:[e.jsx(d,{children:"Exam Instructor *"}),e.jsx(v,{defaultValue:n.instructor_id.toString(),data:T||[],placeholder:"Select instructor",onSelect:s=>o("instructor_id",s.value)}),e.jsx(c,{message:l.instructor_id})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(d,{children:"Category *"}),e.jsx(v,{data:L,placeholder:"Select category",defaultValue:(p==null?void 0:p.id.toString())||"",onSelect:s=>{o("exam_category_id",s.value)}}),e.jsx(c,{message:l.exam_category_id})]}),e.jsxs("div",{children:[e.jsx(d,{children:"Difficulty Level *"}),e.jsxs(f,{value:n.level,onValueChange:s=>o("level",s),children:[e.jsx(_,{children:e.jsx(S,{placeholder:"Select level"})}),e.jsx(C,{children:V.map(s=>e.jsx(b,{value:s,className:"capitalize",children:s},s))})]}),e.jsx(c,{message:l.level})]}),e.jsxs("div",{children:[e.jsx(d,{children:"Status *"}),e.jsxs(f,{value:n.status,onValueChange:s=>o("status",s),children:[e.jsx(_,{children:e.jsx(S,{placeholder:"Select status"})}),e.jsx(C,{children:H.map(s=>e.jsx(b,{value:s,className:"capitalize",children:s},s))})]}),e.jsx(c,{message:l.status})]})]}),e.jsx("div",{className:"mt-8",children:e.jsx(q,{loading:N,children:"Save Changes"})})]})})};export{re as default};
