import{Tt as e}from"./vue-vendor-DMUmTARL.js";import{Y as t,v as n,xt as r}from"./index-kSn5YXd0.js";function i(i,a,o,s={}){let c=n(),{cacheKey:l,successMessage:u=`保存成功`,afterLoad:d,ready:f}=s,p=e(null),{loading:m,refresh:h}=r(i,{cacheKey:l?`${l}:${t.zfileVersion}`:void 0,ready:f,onSuccess(e){p.value=d?d(e.data):e.data}}),{loading:g,runAsync:_}=r(async e=>a?a(e):Promise.resolve(),{manual:!0,onSuccess(){c.success(u)}});return{configData:p,configLoading:m,reloadConfig:h,saveData:async(e,t)=>{let n=t??p.value;return!n||o?.value&&!await new Promise(t=>{o.value?.validate((n,r)=>{if(n){t(!0);return}if(e===!0&&r)for(let e in r){let t=r[e].map(e=>e.message||``).join(`, `);t&&c.warning(t)}t(!1)})})?!1:(await _(n),!0)},saveLoading:g}}export{i as t};