import{r as C,b as D,j as e}from"./vendor-BKmmeuxg.js";import{I}from"./icon-picker-dialog-AqyWbPod.js";import{I as l}from"./input-error-LaPr_4wd.js";import{L as N}from"./loading-button-BnTVAMJ7.js";import{B as _}from"./button-BpNwv2aE.js";import{D as L,a as T,b as B,c as E,d as F,e as k,f as A}from"./dialog-B2gN9MvT.js";import{I as h}from"./input-DM0goJrn.js";import{L as r}from"./label-HmIcv5Yx.js";import{S as H}from"./scroll-area-C8HGru-R.js";import{S as O,a as P,b as V,c as q,d as u}from"./select-CD9o3HN1.js";import{T as y}from"./textarea-CyndvowL.js";import{u as R}from"./use-lang-YfV87_zl.js";import{o as x}from"./inertia-SZXqLvQm.js";import"./icon-picker-iXyBXP6r.js";import"./debounce-CWHP_ANh.js";import"./tooltip-BsX7Z6vz.js";import"./utils-DxSsnXxD.js";import"./index-WW_1X1qx.js";const re=({title:j,category:t,handler:g})=>{const[f,c]=C.useState(!1),{input:a,button:m}=R(),{data:o,setData:i,post:d,errors:n,processing:v,reset:b}=D({title:t?t.title:"",icon:t?t.icon:"",status:t?t.status?1:0:1,description:t?t.description:"",thumbnail:null}),S=s=>{s.preventDefault(),t?d(route("exam-categories.update",t.id),{onSuccess:()=>c(!1)}):d(route("exam-categories.store"),{onSuccess:()=>{b(),c(!1)}})};return e.jsxs(L,{open:f,onOpenChange:c,children:[e.jsx(T,{children:g}),e.jsx(B,{className:"p-0",children:e.jsxs(H,{className:"max-h-[90vh] p-6",children:[e.jsx(E,{className:"mb-6",children:e.jsx(F,{children:j})}),e.jsxs("form",{onSubmit:S,className:"space-y-4 p-0.5",children:[e.jsxs("div",{children:[e.jsx(r,{children:a.title}),e.jsx(h,{required:!0,type:"text",name:"title",value:o.title,placeholder:a.title_placeholder,onChange:s=>x(s,i)}),e.jsx(l,{message:n.title})]}),e.jsxs("div",{children:[e.jsx(r,{children:a.category_icon}),e.jsx(I,{name:"icon",value:o.icon||"",placeholder:"Pick your category icon",onSelect:s=>i("icon",s)}),e.jsx(l,{message:n.icon})]}),e.jsxs("div",{children:[e.jsx(r,{children:a.category_status}),e.jsxs(O,{value:o.status.toString(),onValueChange:s=>i("status",Number(s)),children:[e.jsx(P,{children:e.jsx(V,{placeholder:a.status_placeholder})}),e.jsxs(q,{children:[e.jsx(u,{value:"1",children:"Active"}),e.jsx(u,{value:"0",children:"Inactive"})]})]})]}),e.jsxs("div",{children:[e.jsx(r,{children:a.description}),e.jsx(y,{name:"description",value:o.description,placeholder:a.description_placeholder,onChange:s=>x(s,i)}),e.jsx(l,{message:n.description})]}),e.jsxs("div",{children:[e.jsx(r,{children:a.thumbnail}),e.jsx(h,{type:"file",name:"thumbnail",accept:"image/*",onChange:s=>{var p;return i("thumbnail",(p=s.target.files)==null?void 0:p[0])}}),e.jsx(l,{message:n.thumbnail})]}),e.jsxs(k,{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(A,{asChild:!0,children:e.jsx(_,{type:"button",variant:"outline",children:m.close})}),e.jsx(N,{loading:v,children:m.save_changes})]})]})]})})]})};export{re as default};
