import{l as s,K as e,t as a,x as t,M as r}from"./utils-lib.js?v=20260328163632";import{r as l,c as o,v as u,a as i,g as m}from"./index28.js?v=20260328163632";import{k as n,c,r as p,o as d,J as g,V as v,_ as y,Y as b}from"./base-lib.js?v=20260328163632";import"./naive-ui.js?v=20260328163632";import"./__commonjsHelpers__.js?v=20260328163632";import"./env-lib.js?v=20260328163632";import"./index91.js?v=20260328163632";import"./index83.js?v=20260328163632";const x=n({__name:"index",emits:["close"],setup(n,{expose:x,emit:h}){const k=h,w=c((()=>!!l.value)),f=p(!1),j={labelStyle:"min-width: 100px"},_=p({formAttrs:{labelWidth:"auto"},formItems:[]}),C=p({label:s("面板名称"),attrs:j,ruleKey:"name",rules:[e({message:s("请输入面板名称"),trigger:["blur","input"]})],children:[{type:"input",key:"name",attrs:{placeholder:s("请输入面板名称"),clearable:!0,class:"!w-280px",disabled:w.value}}]}),T=p({label:s("面板Token"),attrs:j,ruleKey:"token",rules:[e({message:s("请输入面板Token"),trigger:["blur","input"]})],children:[{type:"input",key:"token",attrs:{type:"textarea",rows:3,placeholder:s("请输入面板Token"),class:"!w-280px"}}]}),H=c((()=>(_.value.formItems=[C.value,T.value],_.value))),[K,q,A]=a(H),I=async()=>{try{if(f.value)return;1==(await u({token:q.value.token})).data.data?t({loading:s("正在提交，请稍后..."),request:i(q.value),success:async s=>{r.msg({customClass:"bt-message-error-html",isHtml:!0,message:s.msg,type:s.status?"success":"error",duration:s.status?3e3:0,showClose:!s.status}),m(),k("close")}}):setTimeout((()=>{I()}),3e3)}catch(e){}};return d((()=>{})),g((()=>{f.value=!0})),x({onConfirm:async()=>{try{return await A.value.validate(),await t({loading:s("正在请求绑定主机面板，请稍后..."),request:o({token:q.value.token}),message:!0,success:async e=>{r.msg({customClass:"bt-message-error-html",isHtml:!0,message:e.msg+(e.status?"<br>"+s("请前往目标主机面板【软件商店】->【堡塔APP】确认绑定"):""),type:e.status?"success":"error",duration:e.status?3e3:0,showClose:!e.status}),e.status&&await I()}}),!1}catch(e){}}}),(s,e)=>(v(),y(b(K),{class:"p-20px pr-40px"}))}});export{x as default};
