import{c as a,S as e,aq as l,ar as s,_ as i}from"./public.js?v=1753954525509";import{w as n,o as t,O as u}from"./page_layout.js?v=1753954525509";import{_ as r}from"./index.vue_vue_type_script_setup_true_lang.js?v=1753954525509";import{k as o,P as p,r as m,c as d,e as _,U as c,a1 as v,a2 as f,Q as h,X as k,W as y,al as b,l as S,v as g,j as w,a3 as x}from"./vue.js?v=1753954525509";import{c5 as D,cA as P,cG as L,aq as j}from"./naive.js?v=1753954525509";import"./common.js?v=1753954525509";import"./__commonjsHelpers__.js?v=1753954525509";const A={class:"w-300px"},I={class:"w-300px"},$={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:q,row:B}=F,{t:E}=p(),T=m(null),K=m([]),W=d((()=>"CloudFlareDns"===O.name)),G=d((()=>"NameSiloDns"!==O.name&&"global"===O.permission)),H=d((()=>"PorkBunDns"===O.name)),O=_({name:"",api_user:"",api_key:"",alias:"",permission:"global",status:1}),Q={api_user:{required:!0,trigger:"blur",validator:(a,e)=>!("CloudFlareDns"!==O.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")}},R=a=>{var e;"CloudFlareDns"!==a&&"limit"===O.permission&&(O.permission="global"),null==(e=T.value)||e.restoreValidation()},V=m(""),X=m(!0),z=()=>{X.value&&(O.api_user="")},J=()=>{!O.api_user&&X.value?O.api_user=V.value:O.api_user&&(X.value=!1)},M=()=>({id:q&&B?B.id:null,name:q&&B&&O.name===B.name?null:O.name,api_user:q&&B&&O.api_user===B.api_user?null:G.value?O.api_user:"",api_key:q&&B&&O.api_key===B.api_key?null:O.api_key,permission:q&&B&&O.permission===B.permission?null:"CloudFlareDns"===O.name?O.permission:"",status:q&&B&&O.status===B.status?null:O.status,alias:q&&B&&O.alias===B.alias?null:O.alias}),{loading:Y,setLoading:Z}=a();return(async()=>{try{Z(!0);const{message:a}=await s();n(a)&&a.length>0&&(O.name=a[0],K.value=a.map((a=>({label:a,value:a}))))}finally{(()=>{const{row:a,isEdit:e}=F;e&&a&&(O.name=a.name,O.api_user=a.api_user,V.value=a.api_user,O.api_key=a.api_key,O.permission=a.permission,O.status=a.status,O.alias=a.alias)})(),Z(!1)}})(),C({onConfirm:async()=>{var a;await(null==(a=T.value)?void 0:a.validate()),q&&B?await e(M()):await l(M()),N("refresh")}}),(a,e)=>{const l=D,s=P,n=L,o=j,p=r,m=t,d=i,_=u;return c(),v(_,{class:"p-20px",show:k(Y)},{default:f((()=>[h(p,{ref_key:"formRef",ref:T,model:k(O),rules:Q},{default:f((()=>[h(s,{label:a.$t("Public.Table.Status"),path:"status"},{default:f((()=>[h(l,{value:k(O).status,"onUpdate:value":e[0]||(e[0]=a=>k(O).status=a),"checked-value":1,"unchecked-value":0},null,8,["value"])])),_:1},8,["label"]),h(s,{label:a.$t("Config.Alarm.index_43"),path:"name"},{default:f((()=>[h(n,{class:"w-300px",value:k(O).name,"onUpdate:value":[e[1]||(e[1]=a=>k(O).name=a),R],options:k(K),disabled:k(q)},null,8,["value","options","disabled"])])),_:1},8,["label"]),k(G)?(c(),v(s,{key:0,label:k(H)?"Secret Key":"API User",path:"api_user"},{default:f((()=>[y("div",A,[h(o,{value:k(O).api_user,"onUpdate:value":e[2]||(e[2]=a=>k(O).api_user=a),placeholder:k(H)?"Please enter Secret Key":a.$t("SSL.Domain.index_1"),onFocus:z,onBlur:J},null,8,["value","placeholder"])])])),_:1},8,["label"])):b("",!0),h(s,{label:"API Key",path:"api_key"},{default:f((()=>[y("div",I,[h(o,{value:k(O).api_key,"onUpdate:value":e[3]||(e[3]=a=>k(O).api_key=a),placeholder:a.$t("SSL.Domain.index_2")},null,8,["value","placeholder"])])])),_:1}),h(s,{label:a.$t("Config.Panel.index_36"),path:"alias"},{default:f((()=>[y("div",$,[h(o,{value:k(O).alias,"onUpdate:value":e[4]||(e[4]=a=>k(O).alias=a),placeholder:a.$t("SSL.Domain.index_6")},null,8,["value","placeholder"])])])),_:1},8,["label"]),S(h(s,{label:"API-Limit",path:"permission"},{default:f((()=>[h(l,{value:k(O).permission,"onUpdate:value":e[5]||(e[5]=a=>k(O).permission=a),"checked-value":"limit","unchecked-value":"global"},null,8,["value"])])),_:1},512),[[g,k(W)]])])),_:1},8,["model"]),k(W)?(c(),v(d,{key:0},{default:f((()=>[y("li",null,[h(m,{target:"_blank",href:"https://www.aapanel.com/forum/d/3375-3375-set-the-clouldflare-apt-token-for-dns-editing-permissions"},{default:f((()=>[w(x(a.$t("SSL.Domain.index_3")),1)])),_:1})])])),_:1})):b("",!0),"NameCheapDns"===k(O).name?(c(),v(d,{key:1},{default:f((()=>[e[6]||(e[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,[h(m,{target:"_blank",href:"https://www.namecheap.com/support/api/intro/"},{default:f((()=>[w(x(a.$t("SSL.Domain.index_3")),1)])),_:1})])])),_:1,__:[6]})):b("",!0),"NameSiloDns"===k(O).name||"PorkBunDns"===k(O).name?(c(),v(d,{key:2},{default:f((()=>[y("li",null,[h(m,{target:"_blank",href:"https://www.aapanel.com/docs/Function/Tutorial/DNS_API_Tutorial.html"},{default:f((()=>[w(x(a.$t("SSL.Domain.index_3")),1)])),_:1})])])),_:1})):b("",!0)])),_:1},8,["show"])}}});export{C as default};
