import{r as x,aU as E,j as e}from"./react-vendor-xYZnmIII.js";import{I as F}from"./icon-picker-e9MMAA5U.js";import{I as o}from"./input-error-_LAmvivg.js";import{L as q}from"./loading-button-D7aXR3K4.js";import{J as j,K as A,M as g,e as f,N as v,O as b,L as n,I as h,at as H,au as U,av as V,aw as w,ax as S,T as J,Q as K,U as M,B as P}from"./ui-components-CQM92IK3.js";import{u as Q}from"./use-lang-Dg6I_Fym.js";import{o as C}from"./inertia-FIn3q7f1.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./debounce-CWHP_ANh.js";import"./icon-picker-tooltip-CR2ZyXZ1.js";import"./interactive-vendor-B1OgcAgP.js";const te=({title:I,category:s,lastPosition:N,handler:D})=>{const[_,c]=x.useState(!1),[O,d]=x.useState(!1),{dashboard:L,input:t,button:p}=Q(),{data:l,setData:i,post:u,errors:r,processing:T,reset:k}=E({title:s?s.title:"",icon:s?s.icon:"",sort:s?s.sort:N+1,status:s?s.status:1,description:s?s.description:"",thumbnail:null}),B=a=>{a.preventDefault(),s?u(route("categories.update",s.id),{onSuccess:()=>c(!1)}):u(route("categories.store"),{onSuccess:()=>{k(),c(!1)}})};return e.jsxs(j,{open:_,onOpenChange:c,children:[e.jsx(A,{children:D}),e.jsx(g,{className:"p-0",children:e.jsxs(f,{className:"max-h-[90vh] p-6",children:[e.jsx(v,{className:"mb-6",children:e.jsx(b,{children:I})}),e.jsxs("form",{onSubmit:B,className:"space-y-4 p-0.5",children:[e.jsxs("div",{children:[e.jsx(n,{children:t.title}),e.jsx(h,{required:!0,type:"text",name:"title",value:l.title,placeholder:t.title_placeholder,onChange:a=>C(a,i)}),e.jsx(o,{message:r.title})]}),e.jsxs("div",{children:[e.jsx(n,{children:t.category_icon}),e.jsx(h,{required:!0,readOnly:!0,type:"text",name:"icon",value:l.icon,placeholder:t.icon_placeholder,onClick:()=>d(!0)}),e.jsx(o,{message:r.icon}),e.jsx(j,{open:O,onOpenChange:d,children:e.jsx(g,{className:"p-0",children:e.jsxs(f,{className:"max-h-[90vh] p-6",children:[e.jsx(v,{className:"mb-6",children:e.jsx(b,{children:L.icon_picker})}),e.jsx(F,{onSelect:a=>{i("icon",a),d(!1)}})]})})})]}),e.jsxs("div",{children:[e.jsx(n,{children:t.category_status}),e.jsxs(H,{value:l.status.toString(),onValueChange:a=>i("status",Number(a)),children:[e.jsx(U,{children:e.jsx(V,{placeholder:t.status_placeholder})}),e.jsxs(w,{children:[e.jsx(S,{value:"1",children:"Active"}),e.jsx(S,{value:"0",children:"Inactive"})]})]})]}),e.jsxs("div",{children:[e.jsx(n,{children:t.description}),e.jsx(J,{name:"description",value:l.description,placeholder:t.description_placeholder,onChange:a=>C(a,i)}),e.jsx(o,{message:r.description})]}),e.jsxs("div",{children:[e.jsx(n,{children:t.thumbnail}),e.jsx(h,{type:"file",name:"thumbnail",accept:"image/*",onChange:a=>{var m;return i("thumbnail",(m=a.target.files)==null?void 0:m[0])}}),e.jsx(o,{message:r.thumbnail})]}),e.jsxs(K,{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(M,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:p.close})}),e.jsx(q,{loading:T,children:p.save_changes})]})]})]})})]})};export{te as default};
