import {safeUrl} from './core.mjs?v=0.12.4'; // Use XB's public subscription filters; do not invent per-format backend routes. export function subscriptionUrl(raw,client='general') { const safe=safeUrl(raw);if(!safe)throw Error('没有有效的订阅链接'); const url=new URL(safe); const flags={shadowrocket:'general',trojan:'general',meta:'meta',hiddify:'hiddify','sing-box':'sing-box',shadowsocks:'shadowsocks',general:'general'}; if(!Object.hasOwn(flags,client))throw Error('不支持的订阅格式'); url.searchParams.set('flag',flags[client]); if(client==='trojan')url.searchParams.set('types','trojan'); return url.href; } export function importUrl(raw,client,title='Fuc') { const url=subscriptionUrl(raw,client),name=encodeURIComponent(title); if(client==='shadowrocket')return 'shadowrocket://add/sub://'+btoa(url); if(client==='hiddify')return `hiddify://import/${url}#${name}`; if(client==='sing-box')return `sing-box://import-remote-profile?url=${encodeURIComponent(url)}#${name}`; if(client==='meta')return `clash://install-config?url=${encodeURIComponent(url)}&name=${name}`; throw Error('此客户端不支持一键导入'); }