import{d as e,n as a,r as l,E as t,I as u,e as n,D as s,A as p,$ as r,y as d,B as v,F as i,k as o}from"./main-D8Z-8iPZ.js";import{u as y}from"./useStore-CEiyUWBM.js";import{S as m}from"./index-4SW2EnHr.js";import{u as f}from"./index-yiIyVSv0.js";import{N as c}from"./text-BWsiCV4g.js";const _=e({name:"DnsProviderSelect",props:{type:{type:String,default:""},path:{type:String,default:""},value:{type:String,default:""},valueType:{type:String,default:"value"},isAddMode:{type:Boolean,default:!0}},emits:["update:value"],setup(e,{emit:_}){const{handleError:b}=f(),g=a(),{fetchDnsProvider:x,dnsProvider:h}=y(),S=l({label:"",value:"",type:""}),j=l([]),A=()=>{window.open("/auth-api-manage","_blank")},w=({option:a})=>n("div",{style:{display:"flex",alignItems:"center"}},[a.label?n(i,null,[n(m,{iconName:`resources-${a.type}`,size:"2rem"},null),n("div",{style:{marginLeft:".8rem",padding:"4px 0"}},[n(c,null,{default:()=>[a.label]})])]):n("span",{style:{fontSize:"1.4rem",color:"#9CA3AF"}},["dns"===e.type?r("t_3_1745490735059"):r("t_19_1745735766810")])]),k=e=>n("div",{style:{display:"flex",alignItems:"center"}},[n(m,{iconName:`resources-${e.type}`,size:"2rem"},null),n("div",{style:{marginLeft:".8rem",padding:"4px 0"}},[n(c,null,{default:()=>[e.label]})])]),C=()=>{var e,a,l;const t=h.value.find((e=>e.value===S.value.value));t&&(S.value={label:t.label,value:t.value,type:t.type}),h.value.length>0&&""===S.value.value&&(S.value={label:(null==(e=h.value[0])?void 0:e.label)||"",value:(null==(a=h.value[0])?void 0:a.value)||"",type:(null==(l=h.value[0])?void 0:l.type)||""}),_("update:value",S.value)},D=e=>{S.value.value=e,C()};return t((()=>h.value),(a=>{j.value=a.map((a=>({label:a.label,value:"value"===e.valueType?a.value:a.type,type:"value"===e.valueType?a.type:a.value})))||[],C()})),t((()=>e.value),(()=>D(e.value)),{immediate:!0}),u((()=>{x(e.type)})),()=>{let a;return n(s,{cols:24},{default:()=>[n(p,{span:e.isAddMode?13:24,label:"dns"===e.type?r("t_3_1745735765112"):r("t_0_1745744902975"),path:e.path},{default:()=>[n(d,{class:"flex-1 w-full",options:j.value,renderLabel:k,renderTag:w,filterable:!0,placeholder:"dns"===e.type?r("t_3_1745490735059"):r("t_1_1745744905566"),value:S.value.value,"onUpdate:value":e=>S.value.value=e,onUpdateValue:D},{empty:()=>n("span",{class:"text-[1.4rem]"},["dns"===e.type?r("t_3_1745490735059"):r("t_1_1745744905566")])})]}),e.isAddMode&&n(p,{span:11},{default:()=>{return[n(v,{class:"mx-[8px]",onClick:A},{default:()=>["dns"===e.type?r("t_1_1746004861166"):r("t_0_1745748292337")]}),n(v,{onClick:()=>(async(a="")=>{try{await x(a),h.value.length||g.warning("dns"===e.type?r("t_0_1746673515941"):r("t_2_1745748298902"))}catch(l){b(l)}})(e.type)},(l=a=r("t_0_1746497662220"),"function"==typeof l||"[object Object]"===Object.prototype.toString.call(l)&&!o(l)?a:{default:()=>[a]}))];var l}})]})}}});export{_ as D};
