import{g as m,D as j,E as M,B as p,G as O,d as N,H as U,z as y,q as A,bU as $,aD as B,s as L,L as R,k as F,T as P,be as V,ab as X}from"./app-Bei_nIK3.js";import{i as _,o as q}from"./useFlexGapSupport-I9-A4OAO.js";import{S as G}from"./index-BE0aTWss.js";const z=t=>{const{value:n,formatter:e,precision:a,decimalSeparator:s,groupSeparator:u="",prefixCls:r}=t;let c;if(typeof e=="function")c=e({value:n});else{const i=String(n),f=i.match(/^(-?)(\d*)(\.(\d+))?$/);if(!f)c=i;else{const d=f[1];let o=f[2]||"0",l=f[4]||"";o=o.replace(/\B(?=(\d{3})+(?!\d))/g,u),typeof a=="number"&&(l=l.padEnd(a,"0").slice(0,a>0?a:0)),l&&(l=`${s}${l}`),c=[m("span",{key:"int",class:`${r}-content-value-int`},[d,o]),l&&m("span",{key:"decimal",class:`${r}-content-value-decimal`},[l])]}}return m("span",{class:`${r}-content-value`},[c])};z.displayName="StatisticNumber";const Y=t=>{const{componentCls:n,marginXXS:e,padding:a,colorTextDescription:s,statisticTitleFontSize:u,colorTextHeading:r,statisticContentFontSize:c,statisticFontFamily:i}=t;return{[`${n}`]:p(p({},O(t)),{[`${n}-title`]:{marginBottom:e,color:s,fontSize:u},[`${n}-skeleton`]:{paddingTop:a},[`${n}-content`]:{color:r,fontSize:c,fontFamily:i,[`${n}-content-value`]:{display:"inline-block",direction:"ltr"},[`${n}-content-prefix, ${n}-content-suffix`]:{display:"inline-block"},[`${n}-content-prefix`]:{marginInlineEnd:e},[`${n}-content-suffix`]:{marginInlineStart:e}}})}},J=j("Statistic",t=>{const{fontSizeHeading3:n,fontSize:e,fontFamily:a}=t,s=M(t,{statisticTitleFontSize:e,statisticContentFontSize:n,statisticFontFamily:a});return[Y(s)]}),E=()=>({prefixCls:String,decimalSeparator:String,groupSeparator:String,format:String,value:R([Number,String,Object]),valueStyle:{type:Object,default:void 0},valueRender:L(),formatter:B(),precision:Number,prefix:$(),suffix:$(),title:$(),loading:A()}),v=N({compatConfig:{MODE:3},name:"AStatistic",inheritAttrs:!1,props:_(E(),{decimalSeparator:".",groupSeparator:",",loading:!1}),slots:Object,setup(t,n){let{slots:e,attrs:a}=n;const{prefixCls:s,direction:u}=U("statistic",t),[r,c]=J(s);return()=>{var i,f,d,o,l,g,S;const{value:H=0,valueStyle:k,valueRender:w}=t,x=s.value,b=(i=t.title)!==null&&i!==void 0?i:(f=e.title)===null||f===void 0?void 0:f.call(e),h=(d=t.prefix)!==null&&d!==void 0?d:(o=e.prefix)===null||o===void 0?void 0:o.call(e),D=(l=t.suffix)!==null&&l!==void 0?l:(g=e.suffix)===null||g===void 0?void 0:g.call(e),I=(S=t.formatter)!==null&&S!==void 0?S:e.formatter;let C=m(z,y({"data-for-update":Date.now()},p(p({},t),{prefixCls:x,value:H,formatter:I})),null);return w&&(C=w(C)),r(m("div",y(y({},a),{},{class:[x,{[`${x}-rtl`]:u.value==="rtl"},a.class,c.value]}),[b&&m("div",{class:`${x}-title`},[b]),m(G,{paragraph:!1,loading:t.loading},{default:()=>[m("div",{style:k,class:`${x}-content`},[h&&m("span",{class:`${x}-content-prefix`},[h]),C,D&&m("span",{class:`${x}-content-suffix`},[D])])]})]))}}}),K=[["Y",1e3*60*60*24*365],["M",1e3*60*60*24*30],["D",1e3*60*60*24],["H",1e3*60*60],["m",1e3*60],["s",1e3],["S",1]];function Q(t,n){let e=t;const a=/\[[^\]]*]/g,s=(n.match(a)||[]).map(i=>i.slice(1,-1)),u=n.replace(a,"[]"),r=K.reduce((i,f)=>{let[d,o]=f;if(i.includes(d)){const l=Math.floor(e/o);return e-=l*o,i.replace(new RegExp(`${d}+`,"g"),g=>{const S=g.length;return l.toString().padStart(S,"0")})}return i},u);let c=0;return r.replace(a,()=>{const i=s[c];return c+=1,i})}function W(t,n){const{format:e=""}=n,a=new Date(t).getTime(),s=Date.now(),u=Math.max(a-s,0);return Q(u,e)}const Z=1e3/30;function T(t){return new Date(t).getTime()}const tt=()=>p(p({},E()),{value:R([Number,String,Object]),format:String,onFinish:Function,onChange:Function}),et=N({compatConfig:{MODE:3},name:"AStatisticCountdown",props:_(tt(),{format:"HH:mm:ss"}),setup(t,n){let{emit:e,slots:a}=n;const s=F(),u=F(),r=()=>{const{value:o}=t;T(o)>=Date.now()?c():i()},c=()=>{if(s.value)return;const o=T(t.value);s.value=setInterval(()=>{u.value.$forceUpdate(),o>Date.now()&&e("change",o-Date.now()),r()},Z)},i=()=>{const{value:o}=t;s.value&&(clearInterval(s.value),s.value=void 0,T(o)<Date.now()&&e("finish"))},f=o=>{let{value:l,config:g}=o;const{format:S}=t;return W(l,p(p({},g),{format:S}))},d=o=>o;return P(()=>{r()}),V(()=>{r()}),X(()=>{i()}),()=>{const o=t.value;return m(v,y({ref:u},p(p({},q(t,["onFinish","onChange"])),{value:o,valueRender:d,formatter:f})),a)}}});v.Countdown=et;v.install=function(t){return t.component(v.name,v),t.component(v.Countdown.name,v.Countdown),t};v.Countdown;export{v as S};
