import{defineComponent as g,ref as A,onBeforeMount as R,onBeforeUnmount as E,provide as M,toRef as x,computed as N,createVNode as s}from"vue";import{flattenChildren as B}from"../_util/props-util/index.mjs";import P,{responsiveArray as S}from"../_util/responsiveObserve.mjs";import{cloneElement as k}from"../_util/vnode.mjs";import d from"../_util/vue-types/index.mjs";import z from"../config-provider/hooks/useConfigInject.mjs";import U from"./Row.mjs";import _ from"./style/index.mjs";d.any;const F=()=>({prefixCls:String,label:d.any,labelStyle:{type:Object,default:void 0},contentStyle:{type:Object,default:void 0},span:{type:Number,default:1}}),L=g({compatConfig:{MODE:3},name:"ADescriptionsItem",props:F(),setup(e,{slots:n}){return()=>n.default?.()}}),C={xxxl:3,xxl:3,xl:3,lg:3,md:3,sm:2,xs:1};function T(e,n){if(typeof e=="number")return e;if(typeof e=="object")for(let o=0;o<S.length;o++){const t=S[o];if(n[t]&&e[t]!==void 0)return e[t]||C[t]}return 3}function h(e,n,o){let t=e;return(o===void 0||o>n)&&(t=k(e,{span:n})),t}function V(e,n){const o=B(e),t=[];let l=[],r=n;return o.forEach((i,p)=>{const c=i.props?.span,a=c||1;if(p===o.length-1){l.push(h(i,r,c)),t.push(l);return}a<r?(r-=a,l.push(i)):(l.push(h(i,r,a)),t.push(l),r=n,l=[])}),t}const q=()=>({prefixCls:String,bordered:{type:Boolean,default:void 0},size:{type:String,default:"default"},title:d.any,extra:d.any,column:{type:[Number,Object],default:()=>C},layout:String,colon:{type:Boolean,default:void 0},labelStyle:{type:Object,default:void 0},contentStyle:{type:Object,default:void 0}}),G=Symbol("descriptionsContext"),u=g({compatConfig:{MODE:3},name:"ADescriptions",inheritAttrs:!1,props:q(),slots:Object,Item:L,setup(e,{slots:n,attrs:o}){const{prefixCls:t,direction:l}=z("descriptions",e);let r;const i=A({}),[p,c]=_(t),a=P();R(()=>{r=a.value.subscribe(f=>{typeof e.column=="object"&&(i.value=f)})}),E(()=>{a.value.unsubscribe(r)}),M(G,{labelStyle:x(e,"labelStyle"),contentStyle:x(e,"contentStyle")});const O=N(()=>T(e.column,i.value));return()=>{const{size:f,bordered:b=!1,layout:j="horizontal",colon:I=!0,title:m=n.title?.(),extra:y=n.extra?.()}=e,w=n.default?.(),$=V(w,O.value);return p(s("div",{...o,class:[t.value,{[`${t.value}-${f}`]:f!=="default",[`${t.value}-bordered`]:!!b,[`${t.value}-rtl`]:l.value==="rtl"},o.class,c.value]},[(m||y)&&s("div",{class:`${t.value}-header`},[m&&s("div",{class:`${t.value}-title`},[m]),y&&s("div",{class:`${t.value}-extra`},[y])]),s("div",{class:`${t.value}-view`},[s("table",null,[s("tbody",null,[$.map((D,v)=>s(U,{key:v,index:v,colon:I,prefixCls:t.value,vertical:j==="vertical",bordered:b,row:D},null))])])])]))}}});u.install=function(e){return e.component(u.name,u),e.component(u.Item.name,u.Item),e};export{L as DescriptionsItem,u as default,G as descriptionsContext,q as descriptionsProps};
