import{tuple as e}from"../_util/type.mjs";import t from"../_util/classNames.mjs";import n from"../_util/props-util/initDefaultProps.mjs";import r from"../config-provider/hooks/useConfigInject.mjs";import i from"../_util/vue-types/index.mjs";import a from"../_util/isNumeric.mjs";import{SiderCollapsedKey as o,SiderHookProviderKey as s}from"./injectionKey.mjs";import{createVNode as c,defineComponent as l,inject as u,onBeforeUnmount as d,onMounted as f,provide as p,shallowRef as m,watch as h}from"vue";import{BarsOutlined as g,LeftOutlined as _,RightOutlined as v}from"@antsoo-lib/icons";var y={xs:`479.98px`,sm:`575.98px`,md:`767.98px`,lg:`991.98px`,xl:`1199.98px`,xxl:`1599.98px`,xxxl:`1999.98px`},b=()=>({prefixCls:String,collapsible:{type:Boolean,default:void 0},collapsed:{type:Boolean,default:void 0},defaultCollapsed:{type:Boolean,default:void 0},reverseArrow:{type:Boolean,default:void 0},zeroWidthTriggerStyle:{type:Object,default:void 0},trigger:i.any,width:i.oneOfType([i.number,i.string]),collapsedWidth:i.oneOfType([i.number,i.string]),breakpoint:i.oneOf(e(`xs`,`sm`,`md`,`lg`,`xl`,`xxl`,`xxxl`)),theme:i.oneOf(e(`light`,`dark`)).def(`dark`),onBreakpoint:Function,onCollapse:Function}),x=(()=>{let e=0;return(t=``)=>(e+=1,`${t}${e}`)})(),S=l({compatConfig:{MODE:3},name:`ALayoutSider`,inheritAttrs:!1,props:n(b(),{collapsible:!1,defaultCollapsed:!1,reverseArrow:!1,width:200,collapsedWidth:80}),emits:[`breakpoint`,`update:collapsed`,`collapse`],setup(e,{emit:n,attrs:i,slots:l}){let{prefixCls:b}=r(`layout-sider`,e),S=u(s,void 0),C=m(!!(e.collapsed===void 0?e.defaultCollapsed:e.collapsed)),w=m(!1);h(()=>e.collapsed,()=>{C.value=!!e.collapsed}),p(o,C);let T=(t,r)=>{e.collapsed===void 0&&(C.value=t),n(`update:collapsed`,t),n(`collapse`,t,r)},E=m(e=>{w.value=e.matches,n(`breakpoint`,e.matches),C.value!==e.matches&&T(e.matches,`responsive`)}),D;function O(e){return E.value(e)}let k=x(`ant-sider-`);S&&S.addSider(k),f(()=>{h(()=>e.breakpoint,()=>{try{D?.removeEventListener(`change`,O)}catch{D?.removeListener(O)}if(typeof window<`u`){let{matchMedia:t}=window;if(t&&e.breakpoint&&e.breakpoint in y){D=t(`(max-width: ${y[e.breakpoint]})`);try{D.addEventListener(`change`,O)}catch{D.addListener(O)}O(D)}}},{immediate:!0})}),d(()=>{try{D?.removeEventListener(`change`,O)}catch{D?.removeListener(O)}S&&S.removeSider(k)});let A=()=>{T(!C.value,`clickTrigger`)};return()=>{let n=b.value,{collapsedWidth:r,width:o,reverseArrow:s,zeroWidthTriggerStyle:u,trigger:d=l.trigger?.(),collapsible:f,theme:p}=e,m=C.value?r:o,h=a(m)?`${m}px`:String(m),y=Number.parseFloat(String(r||0))===0?c(`span`,{onClick:A,class:t(`${n}-zero-width-trigger`,`${n}-zero-width-trigger-${s?`right`:`left`}`),style:u},[d||c(g,null,null)]):null,x={expanded:c(s?v:_,null,null),collapsed:c(s?_:v,null,null)}[C.value?`collapsed`:`expanded`],S=d===null?null:y||c(`div`,{class:`${n}-trigger`,onClick:A,style:{width:h}},[d||x]),T=[i.style,{flex:`0 0 ${h}`,maxWidth:h,minWidth:h,width:h}],E=t(n,`${n}-${p}`,{[`${n}-collapsed`]:!!C.value,[`${n}-has-trigger`]:f&&d!==null&&!y,[`${n}-below`]:!!w.value,[`${n}-zero-width`]:Number.parseFloat(h)===0},i.class);return c(`aside`,{...i,class:E,style:T},[c(`div`,{class:`${n}-children`},[l.default?.()]),f||w.value&&y?S:null])}}});export{S as default,b as siderProps};