import{j as e,e as j,D as n,c1 as f,T as N,bm as z,c3 as S}from"./vendor-BKmmeuxg.js";import{D as v}from"./data-sort-modal-B2Yf_crJ.js";import{D as b}from"./delete-modal-D1GJlb1P.js";import{B as a}from"./button-BpNwv2aE.js";import{C as o}from"./card-D9_SJYq6.js";import{S as y}from"./separator-_3LZ_wAA.js";import{u as P}from"./use-auth-NG-DQJrC.js";import{D as I}from"./layout-DkwBWm5d.js";import _ from"./category-child-form-BPIGnRYu.js";import w from"./category-form-DlZP90zs.js";import"./utils-DxSsnXxD.js";import"./dialog-B2gN9MvT.js";import"./scroll-area-C8HGru-R.js";import"./index-WW_1X1qx.js";import"./sidebar-BYcYxQeZ.js";import"./sheet-DSvHVmaW.js";import"./tooltip-BsX7Z6vz.js";import"./main-_V386djS.js";import"./index-D9-QKOod.js";import"./appearance-D2z3xcjR.js";import"./dropdown-menu-DO-po5c1.js";import"./app-BytVvUs_.js";/* empty css */import"./language-BFZ7KItL.js";import"./notification-CYMPYbAP.js";import"./popover-B4kBsMuI.js";import"./app-logo-CmnEIwal.js";import"./accordion-CNBvFN43.js";import"./route-B4ZMN77y.js";import"./avatar-j28afJTV.js";import"./use-lang-YfV87_zl.js";import"./icon-picker-iXyBXP6r.js";import"./debounce-CWHP_ANh.js";import"./label-HmIcv5Yx.js";import"./input-error-LaPr_4wd.js";import"./loading-button-BnTVAMJ7.js";import"./input-DM0goJrn.js";import"./select-CD9o3HN1.js";import"./textarea-CyndvowL.js";import"./inertia-SZXqLvQm.js";const A=c=>{const{isAdmin:p}=P(),{categories:l,lastPosition:x,lastChildPosition:h,translate:C}=c,{button:d,frontend:u,dashboard:t}=C,m=l.find(s=>s.slug==="default"),D=l.filter(s=>s.slug!=="default");return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx(w,{title:t.add_category,handler:e.jsx(a,{children:t.add_category}),lastPosition:x}),e.jsx(v,{title:t.sort_categories,data:l,handler:e.jsx(a,{variant:"ghost",className:"bg-muted hover:bg-muted-foreground/6",children:d.sort_categories}),onOrderChange:(s,i)=>{j.post(route("categories.sort"),{sortedData:s},{preserveScroll:!0,onSuccess:()=>i&&i(!1)})},renderContent:s=>e.jsx(o,{className:"w-full px-4 py-3",children:e.jsx("p",{children:s.title})})})]}),l.length>0?e.jsxs("div",{className:"mt-6 grid grid-cols-1 gap-6 border-t border-gray-300 py-6 md:grid-cols-2 lg:grid-cols-4",children:[m&&e.jsxs(o,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n,{size:20,name:m.icon}),e.jsx("h2",{children:m.title})]}),e.jsx(y,{className:"my-4"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:t.protected_category}),e.jsx("p",{className:"text-muted-foreground text-sm",children:t.default_category_description})]})]},m.id),D.map(s=>{var i;return e.jsxs(o,{className:"p-6",children:[e.jsxs("div",{className:"relative text-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n,{size:20,name:s.icon}),e.jsx("h2",{children:s.title})]}),e.jsxs("div",{className:"absolute -top-1 flex w-full items-center justify-end space-x-1",children:[e.jsx(w,{title:t.update_category,category:s,lastPosition:x,handler:e.jsx(a,{size:"icon",variant:"ghost",className:"bg-muted hover:bg-muted-foreground/10 h-8 w-8 rounded-full p-0",children:e.jsx(f,{className:"text-sm"})})}),p&&e.jsx(b,{message:u.delete_warning,routePath:route("categories.destroy",s.id),actionComponent:e.jsx(a,{size:"icon",variant:"ghost",className:"bg-destructive/8 hover:bg-destructive/6 h-8 w-8 rounded-full p-0",children:e.jsx(N,{className:"text-destructive text-sm"})})})]})]}),e.jsx(y,{className:"my-4"}),e.jsxs("div",{className:"space-y-3",children:[(i=s.category_children)==null?void 0:i.map(r=>e.jsxs("div",{className:"border-border relative rounded-md border px-2 py-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n,{size:16,name:r.icon}),e.jsx("p",{children:r.title})]}),e.jsxs("div",{className:"absolute top-0 right-0.5 flex w-full items-center justify-end gap-1",children:[e.jsx(_,{categoryChild:r,categoryId:Number(s.id),title:t.update_category,handler:e.jsx(a,{size:"icon",variant:"ghost",className:"h-8 w-8 p-0",children:e.jsx(f,{className:"text-sm"})}),lastChildPosition:h}),p&&e.jsx("div",{children:e.jsx(b,{message:u.delete_warning,routePath:route("category-child.destroy",r.id),actionComponent:e.jsx(a,{size:"icon",variant:"ghost",className:"hover:bg-destructive/6 h-8 w-8",children:e.jsx(N,{className:"text-destructive text-sm"})})})})]})]},r.id)),e.jsxs("div",{className:"flex items-center justify-baseline gap-3",children:[e.jsx(_,{categoryId:Number(s.id),title:t.add_new_category,handler:e.jsxs(a,{size:"sm",variant:"ghost",className:"bg-muted hover:!bg-muted-foreground/10 w-full",children:[e.jsx(z,{className:"text-sm"}),e.jsx("span",{children:d.create})]}),lastChildPosition:h}),e.jsx(v,{title:d.sort_categories,data:s.category_children||[],handler:e.jsxs(a,{size:"sm",variant:"ghost",className:"bg-muted hover:!bg-muted-foreground/10 w-full",children:[e.jsx(S,{className:"text-sm"}),e.jsx("span",{children:d.sort})]}),onOrderChange:(r,g)=>{j.post(route("category-child.sort"),{sortedData:r},{preserveScroll:!0,onSuccess:()=>g&&g(!1)})},renderContent:r=>e.jsx(o,{className:"w-full px-4 py-3",children:e.jsx("p",{children:r.title})})})]})]})]},s.id)})]}):e.jsx(o,{className:"mt-6 border-t border-gray-300 p-6",children:e.jsx("h2",{className:"text-center",children:t.no_results})})]})};A.layout=c=>e.jsx(I,{children:c});export{A as default};