import{p as k,r as y,i as b,q as C,o as p,c as h,a as f,t as E,f as L,u as _}from"./app-211db244.js";import{i as v}from"./http-6b833e16.js";function g(){return g=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(i[a]=t[a])}return i},g.apply(this,arguments)}var B=function(){var e=!1,t=[],a=function(){if(!e){e=!0;for(var d=0,s=t.length;d<s;d++)t[d]()}},r=function(d){if(!e){t.push(d);return}d()},n={resolved:function(){return e},resolve:a,promise:{then:r}};return n},S=Object.prototype.hasOwnProperty;function A(){var i=B();return{notify:function(){i.resolve()},wait:function(){return i.promise},render:function(t,a,r){this.wait().then(function(){r(window.grecaptcha.render(t,a))})},reset:function(t){typeof t>"u"||(this.assertLoaded(),this.wait().then(function(){return window.grecaptcha.reset(t)}))},execute:function(t){typeof t>"u"||(this.assertLoaded(),this.wait().then(function(){return window.grecaptcha.execute(t)}))},checkRecaptchaLoad:function(){S.call(window,"grecaptcha")&&S.call(window.grecaptcha,"render")&&this.notify()},assertLoaded:function(){if(!i.resolved())throw new Error("ReCAPTCHA has not been loaded")}}}var u=A();typeof window<"u"&&(window.vueRecaptchaApiLoaded=u.notify);var O=k({name:"VueRecaptcha",props:{sitekey:{type:String,required:!0},theme:{type:String},badge:{type:String},type:{type:String},size:{type:String},tabindex:{type:String},loadRecaptchaScript:{type:Boolean,default:!0},recaptchaScriptId:{type:String,default:"__RECAPTCHA_SCRIPT"},recaptchaHost:{type:String,default:"www.google.com"},language:{type:String,default:""}},emits:["render","verify","expired","error"],setup:function(e,t){var a=t.slots,r=t.emit,n=y(null),c=y(null),d=function(l){r("verify",l)},s=function(){r("expired")},x=function(){r("error")};return b(function(){if(u.checkRecaptchaLoad(),e.loadRecaptchaScript&&!document.getElementById(e.recaptchaScriptId)){var o=document.createElement("script");o.id=e.recaptchaScriptId,o.src="https://"+e.recaptchaHost+"/recaptcha/api.js?onload=vueRecaptchaApiLoaded&render=explicit&hl="+e.language,o.async=!0,o.defer=!0,document.head.appendChild(o)}var l=g({},e,{callback:d,"expired-callback":s,"error-callback":x}),w=n.value,R=a.default?w.children[0]:w;u.render(R,l,function(m){c.value=m,r("render",m)})}),{root:n,widgetId:c,reset:function(){u.reset(c.value)},execute:function(){u.execute(c.value)}}},render:function(){var e=this.$slots.default,t;return typeof e=="function"?t=e():t=e,C("div",{ref:"root"},t)}});const P=f("h3",null,"流量补给",-1),V={key:0},j={key:1},H=f("p",null,"完成验证码以签到",-1),$={name:"Sign",setup(i){const e=window.Base.ReCaptcha,t=y({last_sign_at:null,traffic:0});v.get("user").then(r=>{t.value.traffic=r.data.traffic});function a(r){v.post("traffic",{recaptcha:r}).then(n=>{t.value=n.data;let c=`获得了 ${n.data.traffic} GB 流量！`;n.data.traffic===0&&(c="没有获得流量～"),alert(c)}).finally(()=>{v.get("user").then(n=>{t.value.traffic=n.data.traffic}).finally(()=>{})})}return(r,n)=>(p(),h("div",null,[P,f("div",null,[f("p",null,"当前流量: "+E(t.value.traffic)+"GB",1),t.value.is_signed?(p(),h("div",V,"今日已签到")):(p(),h("div",j,[H,L(_(O),{sitekey:_(e),loadRecaptchaScript:"",recaptchaHost:"www.recaptcha.net",onVerify:a},null,8,["sitekey"])]))])]))}};export{$ as default};
