import{d as a,_ as e}from"./public.js?v=1763625242172";import{d7 as l,g_ as s,g$ as i,x as n,o as t,T as u}from"./page_layout.js?v=1763625242172";import{_ as r}from"./index.vue_vue_type_script_setup_true_lang.js?v=1763625242172";import{k as o,P as p,r as m,c as d,e as _,R as c,a2 as v,a3 as h,X as f,V as k,U as y,an as b,l as g,v as S,j as w,a4 as x}from"./vue.js?v=1763625242172";import{dj as D,dP as P,dV as L,au as j}from"./naive.js?v=1763625242172";import"./common.js?v=1763625242172";import"./__commonjsHelpers__.js?v=1763625242172";const I={class:"w-300px"},$={class:"w-300px"},A={class:"w-300px"},C=o({__name:"form",props:{row:{},isEdit:{type:Boolean}},emits:["refresh"],setup(o,{expose:C,emit:U}){const F=o,N=U,{isEdit:T,row:B}=F,{t:E}=p(),q=m(null),K=m([]),V=d((()=>"CloudFlareDns"===H.name)),R=d((()=>"NameSiloDns"!==H.name&&"global"===H.permission)),W=d((()=>"PorkBunDns"===H.name)),H=_({name:"",api_user:"",api_key:"",alias:"",permission:"global",status:1}),X={api_user:{required:!0,trigger:"blur",validator:(a,e)=>!("CloudFlareDns"!==H.name&&!e)||new Error(E("SSL.Domain.index_1"))},api_key:{required:!0,trigger:"blur",message:E("SSL.Domain.index_2")},alias:{required:!0,trigger:"blur",message:E("SSL.Domain.index_6")}},z=a=>{var e;"CloudFlareDns"!==a&&"limit"===H.permission&&(H.permission="global"),null==(e=q.value)||e.restoreValidation()},G=m(""),J=m(!0),M=()=>{J.value&&(H.api_user="")},O=()=>{!H.api_user&&J.value?H.api_user=G.value:H.api_user&&(J.value=!1)},Q=()=>({id:T&&B?B.id:null,name:T&&B&&H.name===B.name?null:H.name,api_user:T&&B&&H.api_user===B.api_user?null:R.value?H.api_user:"",api_key:T&&B&&H.api_key===B.api_key?null:H.api_key,permission:T&&B&&H.permission===B.permission?null:"CloudFlareDns"===H.name?H.permission:"",status:T&&B&&H.status===B.status?null:H.status,alias:T&&B&&H.alias===B.alias?null:H.alias}),{loading:Y,setLoading:Z}=a();return(async()=>{try{Z(!0);const{message:a}=await i();n(a)&&a.length>0&&(H.name=a[0],K.value=a.map((a=>({label:a,value:a}))))}finally{(()=>{const{row:a,isEdit:e}=F;e&&a&&(H.name=a.name,H.api_user=a.api_user,G.value=a.api_user,H.api_key=a.api_key,H.permission=a.permission,H.status=a.status,H.alias=a.alias)})(),Z(!1)}})(),C({onConfirm:async()=>{var a;await(null==(a=q.value)?void 0:a.validate()),T&&B?await l(Q()):await s(Q()),N("refresh")}}),(a,l)=>{const s=D,i=P,n=L,o=j,p=r,m=t,d=e,_=u;return c(),v(_,{class:"p-20px",show:k(Y)},{default:h((()=>[f(p,{ref_key:"formRef",ref:q,model:k(H),rules:X},{default:h((()=>[f(i,{label:a.$t("Public.Table.Status"),path:"status"},{default:h((()=>[f(s,{value:k(H).status,"onUpdate:value":l[0]||(l[0]=a=>k(H).status=a),"checked-value":1,"unchecked-value":0},null,8,["value"])])),_:1},8,["label"]),f(i,{label:a.$t("Config.Alarm.index_43"),path:"name"},{default:h((()=>[f(n,{class:"w-300px",value:k(H).name,"onUpdate:value":[l[1]||(l[1]=a=>k(H).name=a),z],options:k(K),disabled:k(T)},null,8,["value","options","disabled"])])),_:1},8,["label"]),k(R)?(c(),v(i,{key:0,label:k(W)?"Secret Key":"API User",path:"api_user"},{default:h((()=>[y("div",I,[f(o,{value:k(H).api_user,"onUpdate:value":l[2]||(l[2]=a=>k(H).api_user=a),placeholder:k(W)?"Please enter Secret Key":a.$t("SSL.Domain.index_1"),onFocus:M,onBlur:O},null,8,["value","placeholder"])])])),_:1},8,["label"])):b("",!0),f(i,{label:"API Key",path:"api_key"},{default:h((()=>[y("div",$,[f(o,{value:k(H).api_key,"onUpdate:value":l[3]||(l[3]=a=>k(H).api_key=a),placeholder:a.$t("SSL.Domain.index_2")},null,8,["value","placeholder"])])])),_:1}),f(i,{label:a.$t("Config.Panel.index_36"),path:"alias"},{default:h((()=>[y("div",A,[f(o,{value:k(H).alias,"onUpdate:value":l[4]||(l[4]=a=>k(H).alias=a),placeholder:a.$t("SSL.Domain.index_6")},null,8,["value","placeholder"])])])),_:1},8,["label"]),g(f(i,{label:"API-Limit",path:"permission"},{default:h((()=>[f(s,{value:k(H).permission,"onUpdate:value":l[5]||(l[5]=a=>k(H).permission=a),"checked-value":"limit","unchecked-value":"global"},null,8,["value"])])),_:1},512),[[S,k(V)]])])),_:1},8,["model"]),k(V)?(c(),v(d,{key:0},{default:h((()=>[y("li",null,[f(m,{target:"_blank",href:"https://www.aapanel.com/docs/Function/Tutorial/DNS_API_Tutorial.html"},{default:h((()=>[w(x(a.$t("SSL.Domain.index_3")),1)])),_:1})])])),_:1})):b("",!0),"NameCheapDns"===k(H).name?(c(),v(d,{key:1},{default:h((()=>[l[6]||(l[6]=y("li",null," Namecheap API needs added in Whitelisted IPs (only IPv4): Profile > Tools menu > Namecheap API Access > Whitelisted IPs, please check: ",-1)),y("li",null,[f(m,{target:"_blank",href:"https://www.namecheap.com/support/api/intro/"},{default:h((()=>[w(x(a.$t("SSL.Domain.index_3")),1)])),_:1})])])),_:1,__:[6]})):b("",!0),"NameSiloDns"===k(H).name||"PorkBunDns"===k(H).name?(c(),v(d,{key:2},{default:h((()=>[y("li",null,[f(m,{target:"_blank",href:"https://www.aapanel.com/docs/Function/Tutorial/DNS_API_Tutorial.html"},{default:h((()=>[w(x(a.$t("SSL.Domain.index_3")),1)])),_:1})])])),_:1})):b("",!0)])),_:1},8,["show"])}}});export{C as default};
