import{a7 as d,e as g,cc as p,j as s,M as f,Q as A,R as y,T as t,a2 as v,aq as b,am as F,a3 as x,B as C,w as I,r as j,aw as N,x as L}from"./main-TIUJvpaR.js";import{u as w}from"./menu-item-form-CdXiCX5v.js";import{A as D,a as c}from"./accordion-CabB8onw.js";import{u as Q}from"./use-filter-BxwsO3gU.js";import{A as R}from"./Add-CRE_6SK0.js";import{L as S,a as T}from"./list-DlNGU0yW.js";import{u as k}from"./uc-first-pSl3nM3z.js";function V({title:o=s.jsx(t,{message:"Add menu item"})}){const{type:r}=d(),{data:a}=g(p.settings.menuEditorConfig()),i=w(),m=(a==null?void 0:a.categories)||[],n=r==="drawer"?"max-h-auto":"max-h-240 overflow-y-auto";return s.jsxs(f,{size:r==="drawer"?"md":"sm",children:[s.jsx(A,{children:o}),s.jsx(y,{children:s.jsxs(D,{variant:"outline",children:[s.jsx(c,{label:s.jsx(t,{message:"Link"}),bodyClassName:n,children:s.jsx(z,{})}),s.jsx(c,{label:s.jsx(t,{message:"Route"}),bodyClassName:n,children:s.jsx(h,{items:i})}),m.map(l=>s.jsx(c,{bodyClassName:n,label:s.jsx(t,{message:l.name}),children:s.jsx(h,{items:l.items})},l.name))]})})]})}function z(){const o=v({defaultValues:{id:b(6),type:"link",target:"_blank"}}),{close:r}=d();return s.jsxs(F,{form:o,onSubmit:a=>{r(a)},children:[s.jsx(x,{required:!0,name:"label",label:s.jsx(t,{message:"Label"}),className:"mb-20"}),s.jsx(x,{required:!0,type:"url",name:"action",placeholder:"https://",label:s.jsx(t,{message:"Url"}),className:"mb-20"}),s.jsx("div",{className:"text-right",children:s.jsx(C,{type:"submit",variant:"flat",color:"primary",size:"xs",children:s.jsx(t,{message:"Add to menu"})})})]})}function h({items:o}){const{trans:r}=I(),{close:a}=d(),[i,m]=j.useState(""),{contains:n}=Q({sensitivity:"base"}),l=o.filter(e=>n(e.action??"",i));return s.jsxs(j.Fragment,{children:[s.jsx(N,{placeholder:r(L("Search...")),value:i,size:"sm",onChange:e=>m(e.target.value),className:"mb-12"}),s.jsx(S,{children:l.map(e=>s.jsx(T,{startIcon:s.jsx(R,{size:"sm"}),onSelected:()=>{if(e.label){const u=e.label.split("/").pop();e.label=u?k(u):e.label,e.id=b(6)}e.target||(e.target="_self"),a(e)},children:e.label},e.id))})]})}export{V as A};
