"use strict";exports.id=3593,exports.ids=[3593],exports.modules={53593:(a,b,c)=>{c.d(b,{createSqlJsAdapter:()=>k});var d=c(73024),e=c.n(d),f=c(46293),g=c.n(f),h=c(63775);let i=null;async function j(){return i||(i=await g()())}async function k(a){let b=await j(),c=e().existsSync(a)?e().readFileSync(a):null,d=new b.Database(c);d.exec(h.oG);let f=!1,g=null;function i(){let b=d.export();e().writeFileSync(a,Buffer.from(b)),f=!1}function k(){f=!0,g&&clearTimeout(g),g=setTimeout(()=>{if(g=null,f)try{i()}catch(a){console.error("[sqljs] save failed:",a)}},100)}function l(a){if(!(!a||Array.isArray(a)&&0===a.length))return a}let m=()=>{if(f)try{i()}catch{}};return process.on("beforeExit",m),process.on("SIGINT",m),process.on("SIGTERM",m),{driver:"sql.js",run:function(a,b=[]){let c=d.prepare(a);try{c.bind(l(b)),c.step();let a=d.getRowsModified(),e=d.exec("SELECT last_insert_rowid() as id")[0]?.values?.[0]?.[0]??null;return k(),{changes:a,lastInsertRowid:e}}finally{c.free()}},get:function(a,b=[]){let c=d.prepare(a);try{if(c.bind(l(b)),c.step())return c.getAsObject();return}finally{c.free()}},all:function(a,b=[]){let c=d.prepare(a);try{c.bind(l(b));let a=[];for(;c.step();)a.push(c.getAsObject());return a}finally{c.free()}},exec:function(a){d.exec(a),k()},transaction:function(a){let b=`sp_${Math.random().toString(36).slice(2)}`;d.exec(`SAVEPOINT ${b}`);try{let c=a();return d.exec(`RELEASE ${b}`),k(),c}catch(a){try{d.exec(`ROLLBACK TO ${b}`),d.exec(`RELEASE ${b}`)}catch{}throw a}},close:function(){g&&clearTimeout(g),f&&i(),d.close()},raw:d}}},63775:(a,b,c)=>{c.d(b,{CG:()=>e,oG:()=>d,zE:()=>f});let d=`
PRAGMA journal_mode = WAL;
PRAGMA synchronous = NORMAL;
PRAGMA temp_store = MEMORY;
PRAGMA mmap_size = 30000000;
PRAGMA cache_size = -64000;
PRAGMA foreign_keys = ON;
PRAGMA busy_timeout = 5000;
`,e={_meta:{columns:{key:"TEXT PRIMARY KEY",value:"TEXT NOT NULL"}},settings:{columns:{id:"INTEGER PRIMARY KEY CHECK (id = 1)",data:"TEXT NOT NULL"}},providerConnections:{columns:{id:"TEXT PRIMARY KEY",provider:"TEXT NOT NULL",authType:"TEXT NOT NULL",name:"TEXT",email:"TEXT",priority:"INTEGER",isActive:"INTEGER DEFAULT 1",data:"TEXT NOT NULL",createdAt:"TEXT NOT NULL",updatedAt:"TEXT NOT NULL"},indexes:["CREATE INDEX IF NOT EXISTS idx_pc_provider ON providerConnections(provider)","CREATE INDEX IF NOT EXISTS idx_pc_provider_active ON providerConnections(provider, isActive)","CREATE INDEX IF NOT EXISTS idx_pc_priority ON providerConnections(provider, priority)"]},providerNodes:{columns:{id:"TEXT PRIMARY KEY",type:"TEXT",name:"TEXT",data:"TEXT NOT NULL",createdAt:"TEXT NOT NULL",updatedAt:"TEXT NOT NULL"},indexes:["CREATE INDEX IF NOT EXISTS idx_pn_type ON providerNodes(type)"]},proxyPools:{columns:{id:"TEXT PRIMARY KEY",isActive:"INTEGER DEFAULT 1",testStatus:"TEXT",data:"TEXT NOT NULL",createdAt:"TEXT NOT NULL",updatedAt:"TEXT NOT NULL"},indexes:["CREATE INDEX IF NOT EXISTS idx_pp_active ON proxyPools(isActive)","CREATE INDEX IF NOT EXISTS idx_pp_status ON proxyPools(testStatus)"]},apiKeys:{columns:{id:"TEXT PRIMARY KEY",key:"TEXT UNIQUE NOT NULL",name:"TEXT",machineId:"TEXT",isActive:"INTEGER DEFAULT 1",allowedModels:"TEXT DEFAULT '[]'",createdAt:"TEXT NOT NULL"},indexes:["CREATE INDEX IF NOT EXISTS idx_ak_key ON apiKeys(key)"]},combos:{columns:{id:"TEXT PRIMARY KEY",name:"TEXT UNIQUE NOT NULL",kind:"TEXT",models:"TEXT NOT NULL",createdAt:"TEXT NOT NULL",updatedAt:"TEXT NOT NULL"},indexes:["CREATE INDEX IF NOT EXISTS idx_combo_name ON combos(name)"]},kv:{columns:{scope:"TEXT NOT NULL",key:"TEXT NOT NULL",value:"TEXT NOT NULL"},primaryKey:"PRIMARY KEY (scope, key)",indexes:["CREATE INDEX IF NOT EXISTS idx_kv_scope ON kv(scope)"]},usageHistory:{columns:{id:"INTEGER PRIMARY KEY AUTOINCREMENT",timestamp:"TEXT NOT NULL",provider:"TEXT",model:"TEXT",connectionId:"TEXT",apiKey:"TEXT",endpoint:"TEXT",promptTokens:"INTEGER DEFAULT 0",completionTokens:"INTEGER DEFAULT 0",cost:"REAL DEFAULT 0",status:"TEXT",tokens:"TEXT",meta:"TEXT"},indexes:["CREATE INDEX IF NOT EXISTS idx_uh_ts ON usageHistory(timestamp DESC)","CREATE INDEX IF NOT EXISTS idx_uh_provider ON usageHistory(provider)","CREATE INDEX IF NOT EXISTS idx_uh_model ON usageHistory(model)","CREATE INDEX IF NOT EXISTS idx_uh_conn ON usageHistory(connectionId)"]},usageDaily:{columns:{dateKey:"TEXT PRIMARY KEY",data:"TEXT NOT NULL"}},requestDetails:{columns:{id:"TEXT PRIMARY KEY",timestamp:"TEXT NOT NULL",provider:"TEXT",model:"TEXT",connectionId:"TEXT",status:"TEXT",data:"TEXT NOT NULL"},indexes:["CREATE INDEX IF NOT EXISTS idx_rd_ts ON requestDetails(timestamp DESC)","CREATE INDEX IF NOT EXISTS idx_rd_provider ON requestDetails(provider)","CREATE INDEX IF NOT EXISTS idx_rd_model ON requestDetails(model)","CREATE INDEX IF NOT EXISTS idx_rd_conn ON requestDetails(connectionId)"]}};function f(a,b){let c=Object.entries(b.columns).map(([a,b])=>`${a} ${b}`);return b.primaryKey&&c.push(b.primaryKey),`CREATE TABLE IF NOT EXISTS ${a} (${c.join(", ")})`}}};