import{qr as e}from"./ChQ2IioC.js";import{nt as t}from"./B8xAZa0G.js";function n(){let e=(typeof window<`u`?window:void 0)?.metacubexd?.control;return e?.base?{base:r(e.base),token:e.token}:{base:`${r(typeof window<`u`&&window.location?.origin?window.location.origin:``)}/api/control`}}function r(e){return e.replace(/\/$/,``)}function i(){let{base:e,token:r}=n(),i={};r&&(i.Authorization=`Bearer ${r}`);let a=t.create({prefix:e,headers:i,timeout:15e3});return{base:e,token:r,getInfo:()=>a.get(`info`).json(),getKernelStatus:()=>a.get(`kernel/status`).json(),startKernel:()=>a.post(`kernel/start`).json(),stopKernel:()=>a.post(`kernel/stop`).json(),restartKernel:()=>a.post(`kernel/restart`).json(),logsUrl:()=>r?`${e}/kernel/logs?token=${r}`:`${e}/kernel/logs`,listProfiles:()=>a.get(`profiles`).json(),createProfile:e=>a.post(`profiles`,{json:e}).json(),getProfile:e=>a.get(`profiles/${e}`).json(),updateProfile:(e,t)=>a.put(`profiles/${e}`,{json:t}).json(),deleteProfile:e=>a.delete(`profiles/${e}`).json(),duplicateProfile:(e,t)=>a.post(`profiles/${e}/duplicate`,{json:{name:t}}).json(),importProfile:(e,t)=>a.post(`profiles/import`,{json:{url:e,name:t}}).json(),activateProfile:e=>a.post(`profiles/${e}/activate`).json(),refreshProfile:e=>a.post(`profiles/${e}/refresh`).json(),validateProfile:e=>a.post(`profiles/${e}/validate`).json(),getSysProxy:()=>a.get(`sysproxy`).json(),setSysProxy:e=>a.post(`sysproxy`,{json:e}).json(),getKernelVersions:()=>a.get(`kernel/versions`).json(),switchKernel:e=>a.post(`kernel/switch`,{json:{version:e}}).json(),updateGeoAssets:()=>a.post(`geo/update`).json(),getRuntimeConfig:()=>a.get(`config/runtime`).text(),getConfigSection:e=>a.get(`config/section`,{searchParams:{key:e}}).json(),setConfigSection:e=>a.put(`config/section`,{json:e}).json(),webdavBackup:e=>a.post(`backup`,{json:e}).json(),webdavRestore:e=>a.post(`restore`,{json:e}).json(),getTun:()=>a.get(`tun`).json(),setTun:e=>a.post(`tun`,{json:e}).json(),uninstallTun:()=>a.post(`tun/uninstall`).json()}}var a=e(!1),o=e([]),s=e(null),c=e(!1),l=!1;function u(){l||(l=!0,i().getInfo().then(e=>{s.value=e,a.value=e.hasAgent===!0,o.value=Array.isArray(e.features)?e.features:[]}).catch(()=>{a.value=!1,o.value=[],s.value=null}).finally(()=>{c.value=!0}))}function d(){return u(),{hasAgent:a,features:o,info:s,ready:c,hasFeature:e=>a.value&&o.value.includes(e)}}export{i as n,d as t};