exports.id=330,exports.ids=[330],exports.modules={78335:()=>{},89718:(a,b,c)=>{"use strict";c.d(b,{Iq:()=>y,L9:()=>w,Lh:()=>z,OM:()=>s,PX:()=>x,XW:()=>B,Xx:()=>E,bI:()=>C,c:()=>v,fv:()=>u,mt:()=>D,o5:()=>t,yg:()=>A});var d=c(82996),e=c(11259),f=c(47193),g=c(76760),h=c.n(g),i=c(48161),j=c.n(i),k=c(73024),l=c.n(k);let m="u">typeof caches||"object"==typeof caches,n=function(){if(m)return"/tmp";if(process.env.DATA_DIR)return process.env.DATA_DIR;let a=process.platform,b=j().homedir(),c="arouter";return"win32"===a?h().join(process.env.APPDATA||h().join(b,"AppData","Roaming"),c):h().join(b,`.${c}`)}(),o=m?null:h().join(n,"db.json");function p(){return{providerConnections:[],providerNodes:[],proxyPools:[],modelAliases:{},mitmAlias:{},combos:[],apiKeys:[],settings:{cloudEnabled:!1,tunnelEnabled:!1,tunnelUrl:"",stickyRoundRobinLimit:3,providerStrategies:{},requireLogin:!0,observabilityEnabled:!0,observabilityMaxRecords:1e3,observabilityBatchSize:20,observabilityFlushIntervalMs:5e3,observabilityMaxJsonSize:1024,outboundProxyEnabled:!1,outboundProxyUrl:"",outboundNoProxy:""},pricing:{}}}m||l().existsSync(n)||l().mkdirSync(n,{recursive:!0});let q=null;async function r(){if(m){if(!q){let a=p();(q=new d.t({read:async()=>{},write:async()=>{}},a)).data=a}return q}if(!q){let a=new e.Pv(o);q=new d.t(a,p())}try{await q.read()}catch(a){if(a instanceof SyntaxError)console.warn("[DB] Corrupt JSON detected, resetting to defaults..."),q.data=p(),await q.write();else throw a}if(q.data){let{data:a,changed:b}=function(a){let b=p(),c=a&&"object"==typeof a?a:{},d=!1;for(let[a,e]of Object.entries(b)){if(void 0===c[a]||null===c[a]){c[a]=e,d=!0;continue}if("settings"===a&&("object"!=typeof c.settings||Array.isArray(c.settings))){c.settings={...e},d=!0;continue}if("settings"===a&&"object"==typeof c.settings&&!Array.isArray(c.settings))for(let[a,b]of Object.entries(e))void 0===c.settings[a]&&("outboundProxyEnabled"===a&&"string"==typeof c.settings.outboundProxyUrl&&c.settings.outboundProxyUrl.trim()?c.settings.outboundProxyEnabled=!0:c.settings[a]=b,d=!0);if("apiKeys"===a&&Array.isArray(c.apiKeys))for(let a of c.apiKeys)(void 0===a.isActive||null===a.isActive)&&(a.isActive=!0,d=!0)}return{data:c,changed:d}}(q.data);q.data=a,b&&await q.write()}else q.data=p(),await q.write();return q}async function s(){return(await r()).data.modelAliases||{}}async function t(a,b){let c=await r();c.data.modelAliases[a]=b,await c.write()}async function u(a){let b=await r();delete b.data.modelAliases[a],await b.write()}async function v(a){let b=(await r()).data.mitmAlias||{};return a?b[a]||{}:b}async function w(a,b){let c=await r();c.data.mitmAlias||(c.data.mitmAlias={}),c.data.mitmAlias[a]=b||{},await c.write()}async function x(){return(await r()).data.apiKeys||[]}async function y(a,b){if(!b)throw Error("machineId is required");let d=await r(),e=new Date().toISOString(),{generateApiKeyWithMachine:g}=await c.e(844).then(c.bind(c,86844)),h=g(b),i={id:(0,f.A)(),name:a,key:h.key,machineId:b,isActive:!0,createdAt:e};return d.data.apiKeys.push(i),await d.write(),i}async function z(a){let b=await r(),c=b.data.apiKeys.findIndex(b=>b.id===a);return -1!==c&&(b.data.apiKeys.splice(c,1),await b.write(),!0)}async function A(a){return(await r()).data.apiKeys.find(b=>b.id===a)||null}async function B(a,b){let c=await r(),d=c.data.apiKeys.findIndex(b=>b.id===a);return -1===d?null:(c.data.apiKeys[d]={...c.data.apiKeys[d],...b},await c.write(),c.data.apiKeys[d])}async function C(){let a=await r(),b=["displayName","email","globalPriority","defaultModel","accessToken","refreshToken","expiresAt","tokenType","scope","idToken","projectId","apiKey","testStatus","lastTested","lastError","lastErrorAt","rateLimitedUntil","expiresIn","consecutiveUseCount"],c=0;for(let d of a.data.providerConnections){for(let a of b)(null===d[a]||void 0===d[a])&&(delete d[a],c++);d.providerSpecificData&&0===Object.keys(d.providerSpecificData).length&&(delete d.providerSpecificData,c++)}return c>0&&await a.write(),c}async function D(){return(await r()).data.settings||{cloudEnabled:!1}}async function E(a){let b=await r();return b.data.settings={...b.data.settings,...a},await b.write(),b.data.settings}},96487:()=>{}};