(function(s,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("ant-design-vue"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","ant-design-vue","@vueuse/core"],t):(s=typeof globalThis<"u"?globalThis:s||self,t(s.index={},s.Vue,s.antDesignVue,s.core))})(this,function(s,t,m,S){"use strict";const g={type:{type:String,default:"button"}};function _(n){const e=t.ref(n),o=t.ref(!1);let r;function u(){r&&window.clearInterval(r)}function c(){o.value=!1,u(),r=null}function a(){t.unref(o)||r||(o.value=!0,r=setInterval(()=>{t.unref(e)===1?(c(),e.value=n):e.value-=1},1e3))}function l(){e.value=n,c()}function i(){l(),a()}return S.tryOnUnmounted(()=>{l()}),{start:a,reset:l,restart:i,clear:u,stop:c,currentCount:e,isStart:o}}const w={value:{type:[Object,Number,String,Array]},count:{type:Number,default:60},beforeStartFunc:{type:Function,default:null}},$=t.defineComponent({name:"CountButton",components:{Button:m.Button},props:w,setup(n){const e=t.ref(!1),{currentCount:o,isStart:r,start:u,reset:c}=_(n.count),a=f=>typeof f=="function",l=t.computed(()=>t.unref(r)?`${t.unref(o)}秒后重新获取`:"获取验证码");t.watchEffect(()=>{n.value===void 0&&c()});async function i(){const{beforeStartFunc:f}=n;if(f&&a(f)){e.value=!0;try{await f()&&u()}finally{e.value=!1}}else u()}return{handleStart:i,currentCount:o,loading:e,getButtonText:l,isStart:r}}}),C=(n,e)=>{const o=n.__vccOpts||n;for(const[r,u]of e)o[r]=u;return o};function B(n,e,o,r,u,c){const a=t.resolveComponent("Button");return t.openBlock(),t.createBlock(a,t.mergeProps(n.$attrs,{disabled:n.isStart,onClick:n.handleStart,loading:n.loading}),{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(n.getButtonText),1)]),_:1},16,["disabled","onClick","loading"])}const d=C($,[["render",B]]),b={value:{type:String},size:{type:String,validator:n=>["default","large","small"].includes(n)},count:{type:Number,default:60},sendCodeApi:{type:Function,default:null}},h=t.defineComponent({name:"CountDownInput",components:{CountButton:d,Input:m.Input},inheritAttrs:!1,props:b,setup(n){return{prefixCls:"countdown-input"}}}),z="";function I(n,e,o,r,u,c){const a=t.resolveComponent("CountButton"),l=t.resolveComponent("Input");return t.openBlock(),t.createBlock(l,t.mergeProps(n.$attrs,{class:n.prefixCls,size:n.size,value:n.value}),t.createSlots({addonAfter:t.withCtx(()=>[t.createVNode(a,{size:n.size,count:n.count,value:n.value,beforeStartFunc:n.sendCodeApi},null,8,["size","count","value","beforeStartFunc"])]),_:2},[t.renderList(Object.keys(n.$slots).filter(i=>i!=="addonAfter"),i=>({name:i,fn:t.withCtx(f=>[t.renderSlot(n.$slots,i,t.normalizeProps(t.guardReactiveProps(f||{})))])}))]),1040,["class","size","value"])}const y=C(h,[["render",I]]),F="",D="G",p=t.defineComponent({name:`${D}CountDown`,props:g,emits:[],components:{CountButton:d,CountDownInput:y},setup(n,e){return()=>n.type==="button"?t.createVNode(d,n,null):t.createVNode(y,n,null)}});p.install=function(n,e){n.component(e||p.name,p)};const k={title:"CountDown 倒计时",category:"数据描述",status:"100%",install(n){n.component(p.name,p)}};s.CountDown=p,s.default=k,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
