import{defineComponent as _,cloneVNode as j,createVNode as u}from"vue";import{flattenChildren as v,getPropsSlot as C}from"../_util/props-util/index.mjs";import N from"../_util/vue-types/index.mjs";import E from"../_util/warning.mjs";import I from"../config-provider/hooks/useConfigInject.mjs";import"../menu/index.mjs";import O from"./BreadcrumbItem.mjs";import S from"./style/index.mjs";import x from"../menu/src/Menu.mjs";const M=()=>({prefixCls:String,routes:{type:Array},params:N.any,separator:N.any,itemRender:{type:Function}});function T(r,n){if(!r.breadcrumbName)return null;const m=Object.keys(n).join("|");return r.breadcrumbName.replace(new RegExp(`:(${m})`,"g"),(p,f)=>n[f]||p)}function A(r){const{route:n,params:m,routes:l,paths:p}=r,f=l.indexOf(n)===l.length-1,h=T(n,m);return f?u("span",null,[h]):u("a",{href:`#/${p.join("/")}`},[h])}const q=_({compatConfig:{MODE:3},name:"ABreadcrumb",inheritAttrs:!1,props:M(),slots:Object,setup(r,{slots:n,attrs:m}){const{prefixCls:l,direction:p}=I("breadcrumb",r),[f,h]=S(l),g=(e,t)=>(e=(e||"").replace(/^\//,""),Object.keys(t).forEach(a=>{e=e.replace(`:${a}`,t[a])}),e),P=(e,t,a)=>{const o=[...e],s=g(t||"",a);return s&&o.push(s),o},B=({routes:e=[],params:t={},separator:a,itemRender:o=A})=>{const s=[];return e.map(c=>{const d=g(c.path,t);d&&s.push(d);const i=[...s];let b=null;c.children&&c.children.length&&(b=u(x,{items:c.children.map(y=>({key:y.path||y.breadcrumbName,label:o({route:y,params:t,routes:e,paths:P(i,y.path,t)})}))},null));const R={separator:a};return b&&(R.overlay=b),u(O,{...R,key:d||c.breadcrumbName},{default:()=>[o({route:c,params:t,routes:e,paths:i})]})})};return()=>{let e;const{routes:t,params:a={}}=r,o=v(C(n,r)),s=C(n,r,"separator")??"/",c=r.itemRender||n.itemRender||A;t&&t.length>0?e=B({routes:t,params:a,separator:s,itemRender:c}):o.length&&(e=o.map((i,b)=>(E(typeof i.type=="object"&&(i.type.__ANT_BREADCRUMB_ITEM||i.type.__ANT_BREADCRUMB_SEPARATOR)),j(i,{separator:s,key:b}))));const d={[l.value]:!0,[`${l.value}-rtl`]:p.value==="rtl",[`${m.class}`]:!!m.class,[h.value]:!0};return f(u("nav",{...m,class:d},[u("ol",null,[e])]))}}});export{M as breadcrumbProps,q as default};
