import{An as e,pr as t,qr as n,x as r}from"./ChQ2IioC.js";import{n as i,t as a}from"./CPMu7zly.js";function o(e){return e.split(`
`).map(e=>e.trim()).filter(e=>e.length>0)}function s(e){return e.join(`
`)}function c(){let c=i(),{hasFeature:l}=a(),{t:u}=e(),d=t(()=>l(`system-proxy`)),f=n(!1),p=n(0),m=n(``),h=n(!1),g=e=>{f.value=e.enabled,p.value=e.port,m.value=s(e.bypass)},_=async()=>{h.value=!0;try{g(await c.getSysProxy())}catch(e){r.error(u(`systemProxyLoadFailed`),{description:e instanceof Error?e.message:String(e)})}finally{h.value=!1}},v=async e=>{h.value=!0;try{return g(await c.setSysProxy({enabled:f.value,bypass:o(m.value)})),e?.silent||r.success(u(`systemProxyApplied`)),!0}catch(e){return r.error(u(`systemProxyApplyFailed`),{description:e instanceof Error?e.message:String(e)}),!1}finally{h.value=!1}};return{available:d,enabled:f,port:p,bypassText:m,loading:h,load:_,save:v,toggle:async e=>{let t=f.value;f.value=e,await v({silent:!0})||(f.value=t)}}}export{c as t};