import{r as x,b as E,j as e}from"./vendor-rThclpOQ.js";import{I as F}from"./icon-picker-B7sCh2g1.js";import{I as o}from"./input-error-Br4ngfdE.js";import{L as q}from"./loading-button-DKhpmf6V.js";import{B as A}from"./button-ZcsoqUQn.js";import{D as j,a as H,b as f,c as g,d as v,e as V,f as P}from"./dialog-CDEDwQhm.js";import{I as m}from"./input-BeqyurrI.js";import{L as r}from"./label-CtY1vfZY.js";import{S as b}from"./scroll-area-BCwyUKIK.js";import{S as R,a as w,b as z,c as G,d as S}from"./select-u0okJC03.js";import{T as J}from"./textarea-DM_GyfeP.js";import{u as K}from"./use-lang-BK6P2WMc.js";import{o as C}from"./inertia-SZXqLvQm.js";import"./debounce-CWHP_ANh.js";import"./tooltip-WOIaUmuC.js";import"./utils-8KAaAB9H.js";import"./index-DquVdLUg.js";const oe=({title:D,category:s,lastPosition:I,handler:N})=>{const[_,c]=x.useState(!1),[L,d]=x.useState(!1),{dashboard:O,input:a,button:p}=K(),{data:n,setData:i,post:h,errors:l,processing:T,reset:k}=E({title:s?s.title:"",icon:s?s.icon:"",sort:s?s.sort:I+1,status:s?s.status:1,description:s?s.description:"",thumbnail:null}),B=t=>{t.preventDefault(),s?h(route("categories.update",s.id),{onSuccess:()=>c(!1)}):h(route("categories.store"),{onSuccess:()=>{k(),c(!1)}})};return e.jsxs(j,{open:_,onOpenChange:c,children:[e.jsx(H,{children:N}),e.jsx(f,{className:"p-0",children:e.jsxs(b,{className:"max-h-[90vh] p-6",children:[e.jsx(g,{className:"mb-6",children:e.jsx(v,{children:D})}),e.jsxs("form",{onSubmit:B,className:"space-y-4 p-0.5",children:[e.jsxs("div",{children:[e.jsx(r,{children:a.title}),e.jsx(m,{required:!0,type:"text",name:"title",value:n.title,placeholder:a.title_placeholder,onChange:t=>C(t,i)}),e.jsx(o,{message:l.title})]}),e.jsxs("div",{children:[e.jsx(r,{children:a.category_icon}),e.jsx(m,{required:!0,readOnly:!0,type:"text",name:"icon",value:n.icon,placeholder:a.icon_placeholder,onClick:()=>d(!0)}),e.jsx(o,{message:l.icon}),e.jsx(j,{open:L,onOpenChange:d,children:e.jsx(f,{className:"p-0",children:e.jsxs(b,{className:"max-h-[90vh] p-6",children:[e.jsx(g,{className:"mb-6",children:e.jsx(v,{children:O.icon_picker})}),e.jsx(F,{onSelect:t=>{i("icon",t),d(!1)}})]})})})]}),e.jsxs("div",{children:[e.jsx(r,{children:a.category_status}),e.jsxs(R,{value:n.status.toString(),onValueChange:t=>i("status",Number(t)),children:[e.jsx(w,{children:e.jsx(z,{placeholder:a.status_placeholder})}),e.jsxs(G,{children:[e.jsx(S,{value:"1",children:"Active"}),e.jsx(S,{value:"0",children:"Inactive"})]})]})]}),e.jsxs("div",{children:[e.jsx(r,{children:a.description}),e.jsx(J,{name:"description",value:n.description,placeholder:a.description_placeholder,onChange:t=>C(t,i)}),e.jsx(o,{message:l.description})]}),e.jsxs("div",{children:[e.jsx(r,{children:a.thumbnail}),e.jsx(m,{type:"file",name:"thumbnail",accept:"image/*",onChange:t=>{var u;return i("thumbnail",(u=t.target.files)==null?void 0:u[0])}}),e.jsx(o,{message:l.thumbnail})]}),e.jsxs(V,{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(P,{asChild:!0,children:e.jsx(A,{type:"button",variant:"outline",children:p.close})}),e.jsx(q,{loading:T,children:p.save_changes})]})]})]})})]})};export{oe as default};
