var T=Object.defineProperty,E=Object.defineProperties;var H=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var y=(s,a,l)=>a in s?T(s,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):s[a]=l,x=(s,a)=>{for(var l in a||(a={}))q.call(a,l)&&y(s,l,a[l]);if(D)for(var l of D(a))I.call(a,l)&&y(s,l,a[l]);return s},h=(s,a)=>E(s,H(a));import{r as M,aT as A,aU as B,j as e,aX as v}from"./react-vendor-xYZnmIII.js";import{D as C}from"./datetime-picker-By0-QSwT.js";import{I as m}from"./input-error-_LAmvivg.js";import{L as O}from"./loading-button-D7aXR3K4.js";import{J as P,K as U,M as J,e as K,N as Q,O as R,L as i,I as u,C as X,Q as z,U as G,B as V}from"./ui-components-CQM92IK3.js";import{b as S}from"./date-Burj_6Bf.js";import{o as n}from"./inertia-FIn3q7f1.js";import{j as W}from"./richtor-BECSBxkh.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./use-lang-Dg6I_Fym.js";import"./interactive-vendor-B1OgcAgP.js";const ue=({title:s,assignment:a,handler:l})=>{const[N,p]=M.useState(!1),{props:j}=A(),{translate:L}=j,{dashboard:_,input:k,button:b}=L,{data:r,setData:o,post:Y,put:Z,reset:f,errors:d,processing:F}=B({title:(a==null?void 0:a.title)||"",course_id:j.course.id,total_mark:(a==null?void 0:a.total_mark)||"",pass_mark:(a==null?void 0:a.pass_mark)||"",retake:(a==null?void 0:a.retake)||1,summary:(a==null?void 0:a.summary)||"",deadline:a!=null&&a.deadline?new Date(a.deadline):new Date,late_submission:(a==null?void 0:a.late_submission)||!1,late_total_mark:(a==null?void 0:a.late_total_mark)||0,late_deadline:a!=null&&a.late_deadline?new Date(a.late_deadline):""}),w=t=>{t.preventDefault();const c={title:r.title,course_id:r.course_id,total_mark:r.total_mark,pass_mark:r.pass_mark,retake:r.retake,summary:r.summary,deadline:r.deadline?S(r.deadline):"",late_submission:r.late_submission,late_total_mark:r.late_total_mark,late_deadline:r.late_deadline?S(r.late_deadline):""};a?v.put(route("assignment.update",a.id),c,{onSuccess:()=>{f(),p(!1)}}):v.post(route("assignment.store"),c,{onSuccess:()=>{f(),p(!1)}})};return e.jsxs(P,{open:N,onOpenChange:p,children:[e.jsx(U,{children:l}),e.jsx(J,{className:"p-0",children:e.jsxs(K,{className:"max-h-[90vh] p-6",children:[e.jsx(Q,{className:"mb-6",children:e.jsx(R,{children:s})}),e.jsxs("form",{onSubmit:w,className:"space-y-4 p-0.5",children:[e.jsxs("div",{children:[e.jsx(i,{children:k.title}),e.jsx(u,{required:!0,type:"text",name:"title",value:r.title,placeholder:"Enter assignment title",onChange:t=>n(t,o)}),e.jsx(m,{message:d.title})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Deadline"}),e.jsx(C,{date:r.deadline,setDate:t=>o("deadline",t)}),e.jsx(m,{message:d.deadline})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(i,{children:_.total_mark}),e.jsx(u,{required:!0,type:"number",name:"total_mark",value:r.total_mark,onChange:t=>n(t,o)}),e.jsx(m,{message:d.total_mark})]}),e.jsxs("div",{children:[e.jsx(i,{children:_.pass_mark}),e.jsx(u,{required:!0,type:"number",name:"pass_mark",value:r.pass_mark,onChange:t=>n(t,o)}),e.jsx(m,{message:d.pass_mark})]}),e.jsxs("div",{children:[e.jsx(i,{children:k.retake_attempts}),e.jsx(u,{min:"1",required:!0,type:"number",name:"retake",value:r.retake,placeholder:"00",onChange:t=>n(t,o)}),e.jsx(m,{message:d.retake})]})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"summary",children:"Summary"}),e.jsx(W,{ssr:!0,output:"html",placeholder:{paragraph:"Type assignment summary here...",imageCaption:"Type caption for image (optional)"},contentMinHeight:256,contentMaxHeight:640,initialContent:r.summary,onContentChange:t=>o(c=>h(x({},c),{summary:t}))}),e.jsx(m,{message:d.summary})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(X,{id:"late_submission",checked:r.late_submission,onCheckedChange:t=>o(c=>h(x({},c),{late_submission:t}))}),e.jsx(i,{htmlFor:"late_submission",className:"cursor-pointer",children:"Allow Late Submission"})]}),r.late_submission&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(i,{children:"Late Submission Mark"}),e.jsx(u,{type:"number",name:"late_total_mark",value:r.late_total_mark,placeholder:"Enter marks for late submission",onChange:t=>n(t,o)}),e.jsx(m,{message:d.late_total_mark})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Late Submission Deadline"}),e.jsx(C,{date:r.late_deadline?new Date(r.late_deadline):new Date,setDate:t=>o("late_deadline",t)}),e.jsx(m,{message:d.late_deadline})]})]}),e.jsxs(z,{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(G,{asChild:!0,children:e.jsx(V,{type:"button",variant:"outline",children:b.close})}),e.jsx(O,{loading:F,children:b.submit})]})]})]})})]})};export{ue as default};
