import{c as s,h as e,r,o as a,k as t,l,e as o,x as i,p as d,q as u,F as c,v as m,N as _,z as n,bT as p,a7 as g,a4 as y}from"./base-lib.js?v=1761009159";import{g as b,bt as v,bu as f,bv as h}from"./useStore4.js?v=1761009159";import{I as k,o as R,e as U}from"./utils-lib.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const j={class:"p-[1.6rem]"},L=["onClick"],w=U(s({__name:"set-url",props:{compData:{default:()=>({})}},emits:["close"],setup(s,{expose:U,emit:w}){const{refs:{settingData:x},getSet:D}=b(),S=s,q=w,C=e({registry_mirrors_address:"不使用加速"}),N=r([]),O=["不使用加速",x.value.bad_registry_path],V=(s,e)=>{e(N.value)};return a((()=>{C.registry_mirrors_address=""===S.compData.url||"未设置加速URL"===S.compData.url?"不使用加速":S.compData.url;N.value=[...x.value.options,{label:"不使用加速",value:"不使用加速"}],x.value.bad_registry&&(C.registry_mirrors_address=x.value.bad_registry_path,N.value.unshift({label:"".concat(x.value.bad_registry_path,"(推荐)"),value:x.value.bad_registry_path}))})),U({onConfirm:async()=>{try{let s={registry_mirrors_address:C.registry_mirrors_address};"不使用加速"===s.registry_mirrors_address&&(s.registry_mirrors_address=""),await R({title:"设置加速URL",content:"设置后需要重启docker，请确保可以重启docker再操作！"}),await k({loading:"正在设置加速URL，请稍候...",request:h({data:JSON.stringify(s)}),message:!0,success:s=>{s.status&&(D(),q("close"))}})}catch(s){console.log(s)}}}),(s,e)=>{const r=p,a=g,b=y;return t(),l("div",j,[o(b,{ref:"urlFormRef",size:"default",model:d(C),"label-position":"right",onSubmit:e[1]||(e[1]=_((()=>{}),["prevent"]))},{default:i((()=>[o(a,{prop:"registry_mirrors_address",label:"加速URL"},{default:i((()=>[o(r,{modelValue:d(C).registry_mirrors_address,"onUpdate:modelValue":e[0]||(e[0]=s=>d(C).registry_mirrors_address=s),"fetch-suggestions":V,"popper-class":"my-urlautocomplete",placeholder:"请选择或输入加速URL"},{default:i((({item:s})=>{return[u("div",{class:c(["flex items-center justify-between px-[2rem]",s.value===d(C).registry_mirrors_address?"bg-[#f5f7fa]":""])},[u("div",{class:c(["w-[38rem] truncate",s.value===d(C).registry_mirrors_address?"bt-link":""])},m(s.label),3),(e=s.value,O.includes(e)?n("",!0):(t(),l("span",{key:0,class:"bt-danger",onClick:_((e=>(async s=>{try{await k({loading:"正在删除加速URL，请稍候...",request:v({data:JSON.stringify({registry_mirrors_address:s})}),message:!0,success:async s=>{if(s.status){const s=await f(),e=[];Object.entries(s.data.com_reg_mirrors).forEach((s=>{e.push({label:"".concat(s[0],"(").concat(s[1],")"),value:s[0]})})),N.value=e}}})}catch(e){console.log(e)}})(s.value)),["stop"])},"删除",8,L)))],2)];var e})),_:1},8,["modelValue"])])),_:1})])),_:1},8,["model"]),e[2]||(e[2]=u("ul",{class:"list-disc text-[#777] ml-[11.7rem] mt-[1.5rem]"},[u("li",null,"优先使用加速URL执行操作，请求超时将跳过使用默认加速方式"),u("li",null,"设置加速后需要手动重启docker")],-1))])}}}),[["__scopeId","data-v-3ab1632a"]]);export{w as default};
