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