import{d as a,_ as e}from"./public.js?v=1764233927359";import{o as l,T as s,d9 as i,g$ as n,h0 as t,x as u}from"./page_layout.js?v=1764233927359";import{_ as r}from"./index.vue_vue_type_script_setup_true_lang.js?v=1764233927359";import{k as o,P as p,r as m,c as d,e as _,a2 as c,V as v,a3 as h,W as f,an as k,U as y,l as b,S,v as g,j as w,a4 as x}from"./vue.js?v=1764233927359";import{dR as D,dj as P,dV as L,au as j}from"./naive.js?v=1764233927359";import"./common.js?v=1764233927359";import"./__commonjsHelpers__.js?v=1764233927359";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),W=d(()=>"NameSiloDns"!==H.name&&"global"===H.permission),R=d(()=>"PorkBunDns"===H.name),H=_({name:"",api_user:"",api_key:"",alias:"",permission:"global",status:1}),z={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")}},G=a=>{var e;"CloudFlareDns"!==a&&"limit"===H.permission&&(H.permission="global"),null==(e=q.value)||e.restoreValidation()},J=m(""),M=m(!0),O=()=>{M.value&&(H.api_user="")},Q=()=>{!H.api_user&&M.value?H.api_user=J.value:H.api_user&&(M.value=!1)},X=()=>({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:W.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 t();u(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,J.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 i(X()):await n(X()),N("refresh")}}),(a,i)=>{const n=P,t=D,u=L,o=j,p=r,m=l,d=e,_=s;return v(),c(_,{class:"p-20px",show:y(Y)},{default:h(()=>[f(p,{ref_key:"formRef",ref:q,model:y(H),rules:z},{default:h(()=>[f(t,{label:a.$t("Public.Table.Status"),path:"status"},{default:h(()=>[f(n,{value:y(H).status,"onUpdate:value":i[0]||(i[0]=a=>y(H).status=a),"checked-value":1,"unchecked-value":0},null,8,["value"])]),_:1},8,["label"]),f(t,{label:a.$t("Config.Alarm.index_43"),path:"name"},{default:h(()=>[f(u,{class:"w-300px",value:y(H).name,"onUpdate:value":[i[1]||(i[1]=a=>y(H).name=a),G],options:y(K),disabled:y(T)},null,8,["value","options","disabled"])]),_:1},8,["label"]),y(W)?(v(),c(t,{key:0,label:y(R)?"Secret Key":"API User",path:"api_user"},{default:h(()=>[S("div",I,[f(o,{value:y(H).api_user,"onUpdate:value":i[2]||(i[2]=a=>y(H).api_user=a),placeholder:y(R)?"Please enter Secret Key":a.$t("SSL.Domain.index_1"),onFocus:O,onBlur:Q},null,8,["value","placeholder"])])]),_:1},8,["label"])):k("",!0),f(t,{label:"API Key",path:"api_key"},{default:h(()=>[S("div",$,[f(o,{value:y(H).api_key,"onUpdate:value":i[3]||(i[3]=a=>y(H).api_key=a),placeholder:a.$t("SSL.Domain.index_2")},null,8,["value","placeholder"])])]),_:1}),f(t,{label:a.$t("Config.Panel.index_36"),path:"alias"},{default:h(()=>[S("div",A,[f(o,{value:y(H).alias,"onUpdate:value":i[4]||(i[4]=a=>y(H).alias=a),placeholder:a.$t("SSL.Domain.index_6")},null,8,["value","placeholder"])])]),_:1},8,["label"]),b(f(t,{label:"API-Limit",path:"permission"},{default:h(()=>[f(n,{value:y(H).permission,"onUpdate:value":i[5]||(i[5]=a=>y(H).permission=a),"checked-value":"limit","unchecked-value":"global"},null,8,["value"])]),_:1},512),[[g,y(V)]])]),_:1},8,["model"]),y(V)?(v(),c(d,{key:0},{default:h(()=>[S("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})):k("",!0),"NameCheapDns"===y(H).name?(v(),c(d,{key:1},{default:h(()=>[i[6]||(i[6]=S("li",null," Namecheap API needs added in Whitelisted IPs (only IPv4): Profile > Tools menu > Namecheap API Access > Whitelisted IPs, please check: ",-1)),S("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]})):k("",!0),"NameSiloDns"===y(H).name||"PorkBunDns"===y(H).name?(v(),c(d,{key:2},{default:h(()=>[S("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})):k("",!0)]),_:1},8,["show"])}}});export{C as default};
