ldrouter 1.18.1 → 1.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/server/config/index.js +10 -1
- package/dist/server/routes/admin/api-keys.js +1 -2
- package/dist/server/routes/admin/backup.js +21 -6
- package/dist/server/routes/admin/models.js +7 -7
- package/dist/server/routes/admin/providers.js +15 -14
- package/dist/server/routes/admin/setup.js +4 -1
- package/dist/web/assets/{index-C868AUvW.js → index-DYrnLQwk.js} +2 -2
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@ All notable changes to this project are documented here. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/) and the project adheres to
|
|
5
5
|
[Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [1.18.2] - 2026-10-02
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Restore now adopts the backup's master key, including across restarts.
|
|
12
|
+
- Admin deletion now permanently removes API keys, models, and providers with dependent routing configuration cleaned up first.
|
|
13
|
+
- `/setup` always exposes the master-key input and reports runtime key availability.
|
|
14
|
+
|
|
7
15
|
## [1.17.9] - 2026-09-22
|
|
8
16
|
|
|
9
17
|
### Fixed
|
|
@@ -49,12 +49,21 @@ export function loadConfig(env = process.env, argv = process.argv) {
|
|
|
49
49
|
(parsed.NODE_ENV === 'test' ? path.resolve('../.tmp/test-data') : path.resolve(os.homedir(), '.latedev-router'));
|
|
50
50
|
const isContainer = Boolean(env.LATEDEV_DATA_DIR?.startsWith('/data') || process.env.CONTAINER === '1');
|
|
51
51
|
const dbFile = parsed.LATEDEV_DB_URL ?? path.join(dataDir, 'data.sqlite');
|
|
52
|
+
const restoredMasterKeyPath = path.join(dataDir, 'master.key.restore');
|
|
53
|
+
let restoredMasterKey = null;
|
|
54
|
+
try {
|
|
55
|
+
if (fs.existsSync(restoredMasterKeyPath))
|
|
56
|
+
restoredMasterKey = fs.readFileSync(restoredMasterKeyPath, 'utf8').trim() || null;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
/* ignore unreadable override — use the configured key */
|
|
60
|
+
}
|
|
52
61
|
cached = {
|
|
53
62
|
host: cliArgs.host ?? parsed.LATEDEV_HOST,
|
|
54
63
|
port: cliArgs.port ?? parsed.LATEDEV_PORT,
|
|
55
64
|
dataDir,
|
|
56
65
|
dbFile,
|
|
57
|
-
masterKey: parsed.LATEDEV_MASTER_KEY ?? readMasterKeyFile(dataDir),
|
|
66
|
+
masterKey: restoredMasterKey ?? parsed.LATEDEV_MASTER_KEY ?? readMasterKeyFile(dataDir),
|
|
58
67
|
trustProxyHops: parsed.LATEDEV_TRUST_PROXY,
|
|
59
68
|
logLevel: parsed.LOG_LEVEL ?? parsed.LATEDEV_LOG_LEVEL,
|
|
60
69
|
env: parsed.NODE_ENV,
|
|
@@ -215,8 +215,7 @@ export async function registerApiKeyRoutes(app) {
|
|
|
215
215
|
const k = db.select().from(schema.apiKeys).where(eq(schema.apiKeys.id, id)).get();
|
|
216
216
|
if (!k)
|
|
217
217
|
throw new GatewayError('invalid_request_error', 'API key not found', { status: 404 });
|
|
218
|
-
|
|
219
|
-
db.update(schema.apiKeys).set({ enabled: false, updatedAt: new Date().toISOString(), name: `${k.name} (deleted ${new Date().toISOString().slice(0, 10)})` }).where(eq(schema.apiKeys.id, id)).run();
|
|
218
|
+
db.delete(schema.apiKeys).where(eq(schema.apiKeys.id, id)).run();
|
|
220
219
|
recordAudit({ action: 'api_key.delete', success: true, targetType: 'api_key', targetId: id, targetName: k.name, ip: req.ip });
|
|
221
220
|
return { ok: true };
|
|
222
221
|
});
|
|
@@ -156,6 +156,10 @@ export async function registerBackupRoutes(app) {
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
const liveDb = cfg.dbFile;
|
|
159
|
+
const previousMasterKey = cfg.masterKey;
|
|
160
|
+
const restoreKeyPath = path.join(cfg.dataDir, 'master.key.restore');
|
|
161
|
+
const previousRestoreKey = fs.existsSync(restoreKeyPath) ? fs.readFileSync(restoreKeyPath) : null;
|
|
162
|
+
const restoredKey = restoredMasterKey?.toString('base64');
|
|
159
163
|
// Snapshot current DB before restore (kept for manual rollback).
|
|
160
164
|
const snapshot = path.join(cfg.dataDir, `pre-restore-${Date.now()}.sqlite`);
|
|
161
165
|
const Database = (await import('better-sqlite3')).default;
|
|
@@ -186,6 +190,13 @@ export async function registerBackupRoutes(app) {
|
|
|
186
190
|
recordAudit({ action: 'db.restore', success: false, ip: req.ip, metadata: { reason: 'rename_failed', err: String(e) } });
|
|
187
191
|
throw new GatewayError('gateway_error', 'Restore atomic replace failed', { status: 500 });
|
|
188
192
|
}
|
|
193
|
+
// The backup key is authoritative. Apply it before reopening the restored
|
|
194
|
+
// database so every post-restore read uses the key that encrypted it.
|
|
195
|
+
if (restoredKey) {
|
|
196
|
+
fs.writeFileSync(restoreKeyPath, restoredKey, { mode: 0o600, encoding: 'utf8' });
|
|
197
|
+
setConfigMasterKey(restoredKey);
|
|
198
|
+
resetMasterKeyCache();
|
|
199
|
+
}
|
|
189
200
|
// Hot-reload the database in-process: reopen the replaced file, validate
|
|
190
201
|
// it, and keep serving. No gateway restart needed.
|
|
191
202
|
try {
|
|
@@ -207,6 +218,16 @@ export async function registerBackupRoutes(app) {
|
|
|
207
218
|
}
|
|
208
219
|
fs.copyFileSync(snapshot, liveDb);
|
|
209
220
|
openDb(liveDb);
|
|
221
|
+
try {
|
|
222
|
+
if (previousRestoreKey)
|
|
223
|
+
fs.writeFileSync(restoreKeyPath, previousRestoreKey, { mode: 0o600 });
|
|
224
|
+
else
|
|
225
|
+
fs.unlinkSync(restoreKeyPath);
|
|
226
|
+
}
|
|
227
|
+
catch { /* no prior override */ }
|
|
228
|
+
if (previousMasterKey)
|
|
229
|
+
setConfigMasterKey(previousMasterKey);
|
|
230
|
+
resetMasterKeyCache();
|
|
210
231
|
}
|
|
211
232
|
catch (rollbackErr) {
|
|
212
233
|
const err = e.message;
|
|
@@ -217,12 +238,6 @@ export async function registerBackupRoutes(app) {
|
|
|
217
238
|
recordAudit({ action: 'db.restore', success: false, ip: req.ip, metadata: { reason: 'validation_failed', err: e.message } });
|
|
218
239
|
throw new GatewayError('gateway_error', `Restore failed: ${e.message}`, { status: 500 });
|
|
219
240
|
}
|
|
220
|
-
if (restoredMasterKey) {
|
|
221
|
-
const restoredKey = restoredMasterKey.toString('base64');
|
|
222
|
-
fs.writeFileSync(path.join(cfg.dataDir, 'master.key'), restoredKey, { mode: 0o600, encoding: 'utf8' });
|
|
223
|
-
setConfigMasterKey(restoredKey);
|
|
224
|
-
resetMasterKeyCache();
|
|
225
|
-
}
|
|
226
241
|
// The swap invalidates the previous admin session (its row lived in the
|
|
227
242
|
// old database). Re-create the current session in the restored database so
|
|
228
243
|
// the admin stays logged in across the hot restore.
|
|
@@ -219,13 +219,13 @@ export async function registerModelRoutes(app) {
|
|
|
219
219
|
const m = db.select().from(schema.models).where(eq(schema.models.id, id)).get();
|
|
220
220
|
if (!m)
|
|
221
221
|
throw new GatewayError('invalid_request_error', 'Model not found', { status: 404 });
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
222
|
+
db.transaction((tx) => {
|
|
223
|
+
tx.delete(schema.comboMembers).where(eq(schema.comboMembers.modelId, id)).run();
|
|
224
|
+
tx.delete(schema.modelAliases).where(sql `target_kind = 'model' AND target_id = ${id}`).run();
|
|
225
|
+
tx.delete(schema.apiKeyModelPermissions).where(sql `target_kind = 'model' AND target_id = ${id}`).run();
|
|
226
|
+
tx.delete(schema.responseCache).where(sql `target_kind = 'model' AND target_id = ${id}`).run();
|
|
227
|
+
tx.delete(schema.models).where(eq(schema.models.id, id)).run();
|
|
228
|
+
});
|
|
229
229
|
recordAudit({ action: 'model.delete', success: true, targetType: 'model', targetId: id, targetName: m.publicModelId, ip: req.ip });
|
|
230
230
|
return { ok: true };
|
|
231
231
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { sql, eq } from 'drizzle-orm';
|
|
2
|
+
import { sql, eq, inArray } from 'drizzle-orm';
|
|
3
3
|
import { getDb, schema } from '../../db/index.js';
|
|
4
4
|
import { requireAdminAuth } from '../../auth/middleware.js';
|
|
5
5
|
import { recordAudit } from '../../db/repositories/audit.js';
|
|
@@ -156,19 +156,20 @@ export async function registerProviderRoutes(app) {
|
|
|
156
156
|
const p = db.select().from(schema.providers).where(eq(schema.providers.id, id)).get();
|
|
157
157
|
if (!p)
|
|
158
158
|
throw new GatewayError('invalid_request_error', 'Provider not found', { status: 404 });
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
159
|
+
const models = db.select({ id: schema.models.id }).from(schema.models).where(eq(schema.models.providerId, id)).all();
|
|
160
|
+
const modelIds = models.map((model) => model.id);
|
|
161
|
+
db.transaction((tx) => {
|
|
162
|
+
tx.delete(schema.codexAccounts).where(eq(schema.codexAccounts.providerId, id)).run();
|
|
163
|
+
tx.delete(schema.qoderAccounts).where(eq(schema.qoderAccounts.providerId, id)).run();
|
|
164
|
+
if (modelIds.length > 0) {
|
|
165
|
+
tx.delete(schema.comboMembers).where(inArray(schema.comboMembers.modelId, modelIds)).run();
|
|
166
|
+
tx.delete(schema.modelAliases).where(sql `target_kind = 'model' AND target_id IN (${sql.join(modelIds.map((modelId) => sql `${modelId}`), sql `, `)})`).run();
|
|
167
|
+
tx.delete(schema.apiKeyModelPermissions).where(sql `target_kind = 'model' AND target_id IN (${sql.join(modelIds.map((modelId) => sql `${modelId}`), sql `, `)})`).run();
|
|
168
|
+
tx.delete(schema.responseCache).where(sql `target_kind = 'model' AND target_id IN (${sql.join(modelIds.map((modelId) => sql `${modelId}`), sql `, `)})`).run();
|
|
169
|
+
tx.delete(schema.models).where(inArray(schema.models.id, modelIds)).run();
|
|
170
|
+
}
|
|
171
|
+
tx.delete(schema.providers).where(eq(schema.providers.id, id)).run();
|
|
172
|
+
});
|
|
172
173
|
recordAudit({ action: 'provider.delete', success: true, targetType: 'provider', targetId: id, targetName: p.name, ip: req.ip });
|
|
173
174
|
return { ok: true };
|
|
174
175
|
});
|
|
@@ -20,7 +20,10 @@ export async function registerSetupRoutes(app) {
|
|
|
20
20
|
const s = getSettings();
|
|
21
21
|
return {
|
|
22
22
|
setupComplete: s.setupComplete,
|
|
23
|
-
|
|
23
|
+
// The database flag can survive removal of the key file or env var. The
|
|
24
|
+
// setup form needs the runtime truth so it never hides the only recovery
|
|
25
|
+
// input when encryption is not actually available.
|
|
26
|
+
masterKeyConfigured: isMasterKeyConfigured(),
|
|
24
27
|
};
|
|
25
28
|
});
|
|
26
29
|
app.post('/api/admin/setup', async (req, _reply) => {
|
|
@@ -338,10 +338,10 @@ Please change the parent <Route path="${N}"> to <Route path="${N==="/"?"*":`${N}
|
|
|
338
338
|
.block-interactivity-`.concat(n,` {pointer-events: none;}
|
|
339
339
|
.allow-interactivity-`).concat(n,` {pointer-events: all;}
|
|
340
340
|
`)},aA=0,Ms=[];function rA(n){var a=m.useRef([]),l=m.useRef([0,0]),s=m.useRef(),c=m.useState(aA++)[0],u=m.useState(J1)[0],f=m.useRef(n);m.useEffect(function(){f.current=n},[n]),m.useEffect(function(){if(n.inert){document.body.classList.add("block-interactivity-".concat(c));var j=EM([n.lockRef.current],(n.shards||[]).map(Sb),!0).filter(Boolean);return j.forEach(function(C){return C.classList.add("allow-interactivity-".concat(c))}),function(){document.body.classList.remove("block-interactivity-".concat(c)),j.forEach(function(C){return C.classList.remove("allow-interactivity-".concat(c))})}}},[n.inert,n.lockRef.current,n.shards]);var p=m.useCallback(function(j,C){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!f.current.allowPinchZoom;var N=Bc(j),M=l.current,T="deltaX"in j?j.deltaX:M[0]-N[0],D="deltaY"in j?j.deltaY:M[1]-N[1],O,A=j.target,U=Math.abs(T)>Math.abs(D)?"h":"v";if("touches"in j&&U==="h"&&A.type==="range")return!1;var k=window.getSelection(),$=k&&k.anchorNode,X=$?$===A||$.contains(A):!1;if(X)return!1;var te=bb(U,A);if(!te)return!0;if(te?O=U:(O=U==="v"?"h":"v",te=bb(U,A)),!te)return!1;if(!s.current&&"changedTouches"in j&&(T||D)&&(s.current=O),!O)return!0;var G=s.current||O;return eA(G,C,j,G==="h"?T:D)},[]),g=m.useCallback(function(j){var C=j;if(!(!Ms.length||Ms[Ms.length-1]!==u)){var N="deltaY"in C?wb(C):Bc(C),M=a.current.filter(function(O){return O.name===C.type&&(O.target===C.target||C.target===O.shadowParent)&&tA(O.delta,N)})[0];if(M&&M.should){C.cancelable&&C.preventDefault();return}if(!M){var T=(f.current.shards||[]).map(Sb).filter(Boolean).filter(function(O){return O.contains(C.target)}),D=T.length>0?p(C,T[0]):!f.current.noIsolation;D&&C.cancelable&&C.preventDefault()}}},[]),v=m.useCallback(function(j,C,N,M){var T={name:j,delta:C,target:N,should:M,shadowParent:lA(N)};a.current.push(T),setTimeout(function(){a.current=a.current.filter(function(D){return D!==T})},1)},[]),x=m.useCallback(function(j){l.current=Bc(j),s.current=void 0},[]),y=m.useCallback(function(j){v(j.type,wb(j),j.target,p(j,n.lockRef.current))},[]),b=m.useCallback(function(j){v(j.type,Bc(j),j.target,p(j,n.lockRef.current))},[]);m.useEffect(function(){return Ms.push(u),n.setCallbacks({onScrollCapture:y,onWheelCapture:y,onTouchMoveCapture:b}),document.addEventListener("wheel",g,Ts),document.addEventListener("touchmove",g,Ts),document.addEventListener("touchstart",x,Ts),function(){Ms=Ms.filter(function(j){return j!==u}),document.removeEventListener("wheel",g,Ts),document.removeEventListener("touchmove",g,Ts),document.removeEventListener("touchstart",x,Ts)}},[]);var w=n.removeScrollBar,E=n.inert;return m.createElement(m.Fragment,null,E?m.createElement(u,{styles:nA(c)}):null,w?m.createElement(KM,{noRelative:n.noRelative,gapMode:n.gapMode}):null)}function lA(n){for(var a=null;n!==null;)n instanceof ShadowRoot&&(a=n.host,n=n.host),n=n.parentNode;return a}const sA=kM(Z1,rA);var Bu=m.forwardRef(function(n,a){return m.createElement(Uu,ka({},n,{ref:a,sideCar:sA}))});Bu.classNames=Uu.classNames;var oA=Object.defineProperty,pt=(n,a)=>oA(n,"name",{value:a,configurable:!0}),iA=["Enter"," "],cA=["ArrowDown","PageUp","Home"],nw=["ArrowUp","PageDown","End"],uA=[...cA,...nw],Hu="Menu",[rm,dA,fA]=Ru(Hu),[Ul,aw]=kn(Hu,[fA,Ks,Lu]),tp=Ks(),rw=Lu(),[hA,hi]=Ul(Hu),[mA,np]=Ul(Hu),pA=pt(n=>{const{__scopeMenu:a,open:l=!1,children:s,dir:c,onOpenChange:u,modal:f=!0}=n,p=tp(a),[g,v]=m.useState(null),x=m.useRef(!1),y=ia(u),b=di(c);return m.useEffect(()=>{const w=pt(()=>{x.current=!0,document.addEventListener("pointerdown",E,{capture:!0,once:!0}),document.addEventListener("pointermove",E,{capture:!0,once:!0})},"handleKeyDown"),E=pt(()=>x.current=!1,"handlePointer");return document.addEventListener("keydown",w,{capture:!0}),()=>{document.removeEventListener("keydown",w,{capture:!0}),document.removeEventListener("pointerdown",E,{capture:!0}),document.removeEventListener("pointermove",E,{capture:!0})}},[]),m.useEffect(()=>{if(!l)return;const w=pt(()=>y(!1),"handleBlur");return window.addEventListener("blur",w),()=>window.removeEventListener("blur",w)},[l,y]),o.jsx(O1,{...p,children:o.jsx(hA,{scope:a,open:l,onOpenChange:y,content:g,onContentChange:v,children:o.jsx(mA,{scope:a,onClose:m.useCallback(()=>y(!1),[y]),isUsingKeyboardRef:x,dir:b,modal:f,children:s})})})},"Menu"),gA=m.forwardRef(pt(function(a,l){const{__scopeMenu:s,...c}=a,u=tp(s);return o.jsx(_1,{...u,...c,ref:l})},"MenuAnchor")),lw="MenuPortal",[vA,xA]=Ul(lw,{forceMount:void 0}),yA=pt(n=>{const{__scopeMenu:a,forceMount:l,children:s,container:c}=n,u=hi(lw,a);return o.jsx(vA,{scope:a,forceMount:l,children:o.jsx(Cr,{present:l||u.open,children:o.jsx(Zm,{asChild:!0,container:c,children:s})})})},"MenuPortal"),ll="MenuContent",[bA,sw]=Ul(ll),wA=m.forwardRef(pt(function(a,l){const s=xA(ll,a.__scopeMenu),{forceMount:c=s.forceMount,...u}=a,f=hi(ll,a.__scopeMenu),p=np(ll,a.__scopeMenu);return o.jsx(rm.Provider,{scope:a.__scopeMenu,children:o.jsx(Cr,{present:c||f.open,children:o.jsx(rm.Slot,{scope:a.__scopeMenu,children:p.modal?o.jsx(SA,{...u,ref:l}):o.jsx(jA,{...u,ref:l})})})})},"MenuContent")),SA=m.forwardRef(pt(function(a,l){const s=hi(ll,a.__scopeMenu),c=m.useRef(null),u=Xe(l,c);return m.useEffect(()=>{const f=c.current;if(f)return ep(f)},[]),o.jsx(ow,{...a,ref:u,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:Ne(a.onFocusOutside,f=>f.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentModal")),jA=m.forwardRef(pt(function(a,l){const s=hi(ll,a.__scopeMenu);return o.jsx(ow,{...a,ref:l,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentNonModal")),CA=Ha("MenuContent.ScrollLock"),ow=m.forwardRef(pt(function(a,l){const{__scopeMenu:s,loop:c=!1,trapFocus:u,onOpenAutoFocus:f,onCloseAutoFocus:p,disableOutsidePointerEvents:g,onEntryFocus:v,onEscapeKeyDown:x,onPointerDownOutside:y,onFocusOutside:b,onInteractOutside:w,onDismiss:E,disableOutsideScroll:j,...C}=a,N=hi(ll,s),M=np(ll,s),T=tp(s),D=rw(s),O=dA(s),[A,U]=m.useState(null),k=m.useRef(null),$=Xe(l,k,N.onContentChange),X=m.useRef(0),te=m.useRef(""),G=m.useRef(0),ie=m.useRef(null),ce=m.useRef("right"),se=m.useRef(0),_=j?Bu:m.Fragment,H=j?{as:CA,allowPinchZoom:!0}:void 0,Q=pt(ee=>{var oe,de;const z=te.current+ee,I=O().filter(fe=>!fe.disabled),F=document.activeElement,re=(oe=I.find(fe=>fe.ref.current===F))==null?void 0:oe.textValue,he=I.map(fe=>fe.textValue),ge=fw(he,z,re),q=(de=I.find(fe=>fe.textValue===ge))==null?void 0:de.ref.current;pt((function fe(Te){te.current=Te,window.clearTimeout(X.current),Te!==""&&(X.current=window.setTimeout(()=>fe(""),1e3))}),"updateSearch")(z),q&&setTimeout(()=>q.focus())},"handleTypeaheadSearch");m.useEffect(()=>()=>window.clearTimeout(X.current),[]),fi();const J=m.useCallback(ee=>{var I,F;return ce.current===((I=ie.current)==null?void 0:I.side)&&mw(ee,(F=ie.current)==null?void 0:F.area)},[]);return o.jsx(bA,{scope:s,searchRef:te,onItemEnter:m.useCallback(ee=>{J(ee)&&ee.preventDefault()},[J]),onItemLeave:m.useCallback(ee=>{var z;J(ee)||((z=k.current)==null||z.focus(),U(null))},[J]),onTriggerLeave:m.useCallback(ee=>{J(ee)&&ee.preventDefault()},[J]),pointerGraceTimerRef:G,onPointerGraceIntentChange:m.useCallback(ee=>{ie.current=ee},[]),children:o.jsx(_,{...H,children:o.jsx(qm,{asChild:!0,trapped:u,onMountAutoFocus:Ne(f,ee=>{var z;ee.preventDefault(),(z=k.current)==null||z.focus({preventScroll:!0})}),onUnmountAutoFocus:p,children:o.jsx(Nu,{asChild:!0,disableOutsidePointerEvents:g,onEscapeKeyDown:x,onPointerDownOutside:y,onFocusOutside:b,onInteractOutside:w,onDismiss:E,children:o.jsx(G1,{asChild:!0,...D,dir:M.dir,orientation:"vertical",loop:c,currentTabStopId:A,onCurrentTabStopIdChange:U,onEntryFocus:Ne(v,ee=>{M.isUsingKeyboardRef.current||ee.preventDefault()}),preventScrollOnEntryFocus:!0,children:o.jsx(Qm,{role:"menu","aria-orientation":"vertical","data-state":iw(N.open),"data-radix-menu-content":"",dir:M.dir,...T,...C,ref:$,style:{outline:"none",...C.style},onKeyDown:Ne(C.onKeyDown,ee=>{const I=ee.target.closest("[data-radix-menu-content]")===ee.currentTarget,F=ee.ctrlKey||ee.altKey||ee.metaKey,re=ee.key.length===1;I&&(ee.key==="Tab"&&ee.preventDefault(),!F&&re&&Q(ee.key));const he=k.current;if(ee.target!==he||!uA.includes(ee.key))return;ee.preventDefault();const q=O().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);nw.includes(ee.key)&&q.reverse(),uw(q)}),onBlur:Ne(a.onBlur,ee=>{ee.currentTarget.contains(ee.target)||(window.clearTimeout(X.current),te.current="")}),onPointerMove:Ne(a.onPointerMove,cu(ee=>{const z=ee.target,I=se.current!==ee.clientX;if(ee.currentTarget.contains(z)&&I){const F=ee.clientX>se.current?"right":"left";ce.current=F,se.current=ee.clientX}}))})})})})})})},"MenuContentImpl")),EA=m.forwardRef(pt(function(a,l){const{__scopeMenu:s,...c}=a;return o.jsx(Ve.div,{...c,ref:l})},"MenuLabel")),lm="MenuItem",jb="menu.itemSelect",RA=m.forwardRef(pt(function(a,l){const{disabled:s=!1,onSelect:c,...u}=a,f=m.useRef(null),p=np(lm,a.__scopeMenu),g=sw(lm,a.__scopeMenu),v=Xe(l,f),x=m.useRef(!1),y=pt(()=>{const b=f.current;if(!s&&b){const w=new CustomEvent(jb,{bubbles:!0,cancelable:!0});b.addEventListener(jb,E=>c==null?void 0:c(E),{once:!0}),Bm(b,w),w.defaultPrevented?x.current=!1:p.onClose()}},"handleSelect");return o.jsx(NA,{...u,ref:v,disabled:s,onClick:Ne(a.onClick,y),onPointerDown:b=>{var w;(w=a.onPointerDown)==null||w.call(a,b),x.current=!0},onPointerUp:Ne(a.onPointerUp,b=>{var w;x.current||(w=b.currentTarget)==null||w.click()}),onKeyDown:Ne(a.onKeyDown,b=>{s||b.target!==b.currentTarget||g.searchRef.current!==""&&b.key===" "||iA.includes(b.key)&&(b.currentTarget.click(),b.preventDefault())})})},"MenuItem")),NA=m.forwardRef(pt(function(a,l){const{__scopeMenu:s,disabled:c=!1,textValue:u,...f}=a,p=sw(lm,s),g=rw(s),v=m.useRef(null),x=Xe(l,v),[y,b]=m.useState(!1),[w,E]=m.useState("");return m.useEffect(()=>{const j=v.current;j&&E((j.textContent??"").trim())},[f.children]),o.jsx(rm.ItemSlot,{scope:s,disabled:c,textValue:u??w,children:o.jsx(K1,{asChild:!0,...g,focusable:!c,children:o.jsx(Ve.div,{role:"menuitem","data-highlighted":y?"":void 0,"aria-disabled":c||void 0,"data-disabled":c?"":void 0,...f,ref:x,onPointerMove:Ne(a.onPointerMove,cu(j=>{c?p.onItemLeave(j):(p.onItemEnter(j),j.defaultPrevented||j.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ne(a.onPointerLeave,cu(j=>p.onItemLeave(j))),onFocus:Ne(a.onFocus,()=>b(!0)),onBlur:Ne(a.onBlur,()=>b(!1))})})})},"MenuItemImpl")),TA="MenuRadioGroup",[B4,H4]=Ul(TA,{value:void 0,onValueChange:pt(()=>{},"onValueChange")}),MA="MenuItemIndicator",[I4,P4]=Ul(MA,{checked:!1}),AA=m.forwardRef(pt(function(a,l){const{__scopeMenu:s,...c}=a;return o.jsx(Ve.div,{role:"separator","aria-orientation":"horizontal",...c,ref:l})},"MenuSeparator")),DA="MenuSub",[q4,V4]=Ul(DA);function iw(n){return n?"open":"closed"}pt(iw,"getOpenState");function cw(n){return n==="indeterminate"}pt(cw,"isIndeterminate");function OA(n){return cw(n)?"indeterminate":n?"checked":"unchecked"}pt(OA,"getCheckedState");function uw(n){const a=document.activeElement;for(const l of n)if(l===a||(l.focus(),document.activeElement!==a))return}pt(uw,"focusFirst");function dw(n,a){return n.map((l,s)=>n[(a+s)%n.length])}pt(dw,"wrapArray");function fw(n,a,l){const c=a.length>1&&Array.from(a).every(v=>v===a[0])?a[0]:a,u=l?n.indexOf(l):-1;let f=dw(n,Math.max(u,0));c.length===1&&(f=f.filter(v=>v!==l));const g=f.find(v=>v.toLowerCase().startsWith(c.toLowerCase()));return g!==l?g:void 0}pt(fw,"getNextMatch");function hw(n,a){const{x:l,y:s}=n;let c=!1;for(let u=0,f=a.length-1;u<a.length;f=u++){const p=a[u],g=a[f],v=p.x,x=p.y,y=g.x,b=g.y;x>s!=b>s&&l<(y-v)*(s-x)/(b-x)+v&&(c=!c)}return c}pt(hw,"isPointInPolygon");function mw(n,a){if(!a)return!1;const l={x:n.clientX,y:n.clientY};return hw(l,a)}pt(mw,"isPointerInGraceArea");function cu(n){return a=>a.pointerType==="mouse"?n(a):void 0}pt(cu,"whenMouse");var _A=pA,kA=gA,zA=yA,LA=wA,UA=EA,BA=RA,HA=AA,IA=Object.defineProperty,Bl=(n,a)=>IA(n,"name",{value:a,configurable:!0}),ap="DropdownMenu",[PA,$4]=kn(ap,[aw]),Hl=aw(),[qA,pw]=PA(ap),VA=Bl(n=>{const{__scopeDropdownMenu:a,children:l,dir:s,open:c,defaultOpen:u,onOpenChange:f,modal:p=!0}=n,g=Hl(a),v=m.useRef(null),[x,y]=yr({prop:c,defaultProp:u??!1,onChange:f,caller:ap});return o.jsx(qA,{scope:a,triggerId:La(),triggerRef:v,contentId:La(),open:x,onOpenChange:y,onOpenToggle:m.useCallback(()=>y(b=>!b),[y]),modal:p,children:o.jsx(_A,{...g,open:x,onOpenChange:y,dir:s,modal:p,children:l})})},"DropdownMenu"),$A="DropdownMenuTrigger",YA=m.forwardRef(Bl(function(a,l){const{__scopeDropdownMenu:s,disabled:c=!1,...u}=a,f=pw($A,s),p=Hl(s),g=Xe(l,f.triggerRef);return o.jsx(kA,{asChild:!0,...p,children:o.jsx(Ve.button,{type:"button",id:f.triggerId,"aria-haspopup":"menu","aria-expanded":f.open,"aria-controls":f.open?f.contentId:void 0,"data-state":f.open?"open":"closed","data-disabled":c?"":void 0,disabled:c,...u,ref:g,onPointerDown:Ne(a.onPointerDown,v=>{!c&&v.button===0&&v.ctrlKey===!1&&(f.onOpenToggle(),f.open||v.preventDefault())}),onKeyDown:Ne(a.onKeyDown,v=>{c||(["Enter"," "].includes(v.key)&&f.onOpenToggle(),v.key==="ArrowDown"&&f.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(v.key)&&v.preventDefault())})})})},"DropdownMenuTrigger")),GA=Bl(n=>{const{__scopeDropdownMenu:a,...l}=n,s=Hl(a);return o.jsx(zA,{...s,...l})},"DropdownMenuPortal"),KA="DropdownMenuContent",XA=m.forwardRef(Bl(function(a,l){const{__scopeDropdownMenu:s,...c}=a,u=pw(KA,s),f=Hl(s),p=m.useRef(!1);return o.jsx(LA,{id:u.contentId,"aria-labelledby":u.triggerId,...f,...c,ref:l,onCloseAutoFocus:Ne(a.onCloseAutoFocus,g=>{var v;p.current||(v=u.triggerRef.current)==null||v.focus(),p.current=!1,g.preventDefault()}),onInteractOutside:Ne(a.onInteractOutside,g=>{const v=g.detail.originalEvent,x=v.button===0&&v.ctrlKey===!0,y=v.button===2||x;(!u.modal||y)&&(p.current=!0)}),style:{...a.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),FA=m.forwardRef(Bl(function(a,l){const{__scopeDropdownMenu:s,...c}=a,u=Hl(s);return o.jsx(UA,{...u,...c,ref:l})},"DropdownMenuLabel")),QA=m.forwardRef(Bl(function(a,l){const{__scopeDropdownMenu:s,...c}=a,u=Hl(s);return o.jsx(BA,{...u,...c,ref:l})},"DropdownMenuItem")),ZA=m.forwardRef(Bl(function(a,l){const{__scopeDropdownMenu:s,...c}=a,u=Hl(s);return o.jsx(HA,{...u,...c,ref:l})},"DropdownMenuSeparator")),JA=VA,WA=YA,eD=GA,gw=XA,vw=FA,xw=QA,yw=ZA;const tD=JA,nD=WA,bw=m.forwardRef(({className:n,sideOffset:a=4,...l},s)=>o.jsx(eD,{children:o.jsx(gw,{ref:s,sideOffset:a,className:Ee("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",n),...l})}));bw.displayName=gw.displayName;const ww=m.forwardRef(({className:n,inset:a,...l},s)=>o.jsx(xw,{ref:s,className:Ee("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",n),...l}));ww.displayName=xw.displayName;const aD=m.forwardRef(({className:n,...a},l)=>o.jsx(vw,{ref:l,className:Ee("px-2 py-1.5 text-sm font-semibold",n),...a}));aD.displayName=vw.displayName;const rD=m.forwardRef(({className:n,...a},l)=>o.jsx(yw,{ref:l,className:Ee("-mx-1 my-1 h-px bg-muted",n),...a}));rD.displayName=yw.displayName;function lD(){const{theme:n,setTheme:a}=mN(),{user:l,logout:s}=_m(),[c,u]=m.useState(!1),[f,p]=m.useState(null),g=oi(),v=n==="light"?yR:n==="dark"?fR:dR;return m.useEffect(()=>{Se.get("/api/admin/update/check?force=1").then(x=>p(x)).catch(()=>{})},[]),o.jsxs("header",{className:"flex h-14 items-center justify-between border-b bg-background px-4",children:[o.jsx("div",{className:"text-sm text-muted-foreground",children:"Admin"}),o.jsxs("div",{className:"flex items-center gap-2",children:[(f==null?void 0:f.hasUpdate)&&o.jsxs(me,{variant:"ghost",size:"sm",title:`New version available: v${f.latestVersion} — go to Settings → System to update`,onClick:()=>g("/settings?tab=system"),children:[o.jsx(WE,{className:"mr-1 h-4 w-4 text-blue-500"}),"Update v",f.latestVersion]}),o.jsx(me,{variant:"ghost",size:"icon",onClick:()=>a(n==="dark"?"light":"dark"),children:o.jsx(v,{className:"h-4 w-4"})}),o.jsxs(tD,{open:c,onOpenChange:u,children:[o.jsx(nD,{asChild:!0,children:o.jsx(me,{variant:"ghost",children:(l==null?void 0:l.username)??"admin"})}),o.jsx(bw,{align:"end",children:o.jsxs(ww,{onClick:()=>void s(),children:[o.jsx(uR,{className:"mr-2 h-4 w-4"})," Sign out"]})})]})]})]})}const Ae=m.forwardRef(({className:n,type:a,...l},s)=>o.jsx("input",{type:a,className:Ee("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",n),ref:s,...l}));Ae.displayName="Input";var sD=Object.defineProperty,oD=(n,a)=>sD(n,"name",{value:a,configurable:!0}),iD=m.forwardRef(oD(function(a,l){return o.jsx(Ve.label,{...a,ref:l,onMouseDown:s=>{var u;s.target.closest("button, input, select, textarea")||((u=a.onMouseDown)==null||u.call(a,s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}})},"Label")),Sw=iD;const we=m.forwardRef(({className:n,...a},l)=>o.jsx(Sw,{ref:l,className:Ee("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",n),...a}));we.displayName=Sw.displayName;const nt=m.forwardRef(({className:n,...a},l)=>o.jsx("div",{ref:l,className:Ee("rounded-lg border bg-card text-card-foreground shadow-sm",n),...a}));nt.displayName="Card";const at=m.forwardRef(({className:n,...a},l)=>o.jsx("div",{ref:l,className:Ee("flex flex-col space-y-1.5 p-6",n),...a}));at.displayName="CardHeader";const rt=m.forwardRef(({className:n,...a},l)=>o.jsx("h3",{ref:l,className:Ee("text-lg font-semibold leading-none tracking-tight",n),...a}));rt.displayName="CardTitle";const gn=m.forwardRef(({className:n,...a},l)=>o.jsx("p",{ref:l,className:Ee("text-sm text-muted-foreground",n),...a}));gn.displayName="CardDescription";const lt=m.forwardRef(({className:n,...a},l)=>o.jsx("div",{ref:l,className:Ee("p-6 pt-0",n),...a}));lt.displayName="CardContent";const jw=m.forwardRef(({className:n,...a},l)=>o.jsx("div",{ref:l,className:Ee("flex items-center p-6 pt-0",n),...a}));jw.displayName="CardFooter";var cD=n=>{switch(n){case"success":return fD;case"info":return mD;case"warning":return hD;case"error":return pD;default:return null}},uD=Array(12).fill(0),dD=({visible:n,className:a})=>ue.createElement("div",{className:["sonner-loading-wrapper",a].filter(Boolean).join(" "),"data-visible":n},ue.createElement("div",{className:"sonner-spinner"},uD.map((l,s)=>ue.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),fD=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),hD=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),mD=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),pD=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),gD=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ue.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ue.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),vD=()=>{let[n,a]=ue.useState(document.hidden);return ue.useEffect(()=>{let l=()=>{a(document.hidden)};return document.addEventListener("visibilitychange",l),()=>window.removeEventListener("visibilitychange",l)},[]),n},sm=1,xD=class{constructor(){this.subscribe=n=>(this.subscribers.push(n),()=>{let a=this.subscribers.indexOf(n);this.subscribers.splice(a,1)}),this.publish=n=>{this.subscribers.forEach(a=>a(n))},this.addToast=n=>{this.publish(n),this.toasts=[...this.toasts,n]},this.create=n=>{var a;let{message:l,...s}=n,c=typeof(n==null?void 0:n.id)=="number"||((a=n.id)==null?void 0:a.length)>0?n.id:sm++,u=this.toasts.find(p=>p.id===c),f=n.dismissible===void 0?!0:n.dismissible;return this.dismissedToasts.has(c)&&this.dismissedToasts.delete(c),u?this.toasts=this.toasts.map(p=>p.id===c?(this.publish({...p,...n,id:c,title:l}),{...p,...n,id:c,dismissible:f,title:l}):p):this.addToast({title:l,...s,dismissible:f,id:c}),c},this.dismiss=n=>(this.dismissedToasts.add(n),n||this.toasts.forEach(a=>{this.subscribers.forEach(l=>l({id:a.id,dismiss:!0}))}),this.subscribers.forEach(a=>a({id:n,dismiss:!0})),n),this.message=(n,a)=>this.create({...a,message:n}),this.error=(n,a)=>this.create({...a,message:n,type:"error"}),this.success=(n,a)=>this.create({...a,type:"success",message:n}),this.info=(n,a)=>this.create({...a,type:"info",message:n}),this.warning=(n,a)=>this.create({...a,type:"warning",message:n}),this.loading=(n,a)=>this.create({...a,type:"loading",message:n}),this.promise=(n,a)=>{if(!a)return;let l;a.loading!==void 0&&(l=this.create({...a,promise:n,type:"loading",message:a.loading,description:typeof a.description!="function"?a.description:void 0}));let s=n instanceof Promise?n:n(),c=l!==void 0,u,f=s.then(async g=>{if(u=["resolve",g],ue.isValidElement(g))c=!1,this.create({id:l,type:"default",message:g});else if(bD(g)&&!g.ok){c=!1;let v=typeof a.error=="function"?await a.error(`HTTP error! status: ${g.status}`):a.error,x=typeof a.description=="function"?await a.description(`HTTP error! status: ${g.status}`):a.description;this.create({id:l,type:"error",message:v,description:x})}else if(a.success!==void 0){c=!1;let v=typeof a.success=="function"?await a.success(g):a.success,x=typeof a.description=="function"?await a.description(g):a.description;this.create({id:l,type:"success",message:v,description:x})}}).catch(async g=>{if(u=["reject",g],a.error!==void 0){c=!1;let v=typeof a.error=="function"?await a.error(g):a.error,x=typeof a.description=="function"?await a.description(g):a.description;this.create({id:l,type:"error",message:v,description:x})}}).finally(()=>{var g;c&&(this.dismiss(l),l=void 0),(g=a.finally)==null||g.call(a)}),p=()=>new Promise((g,v)=>f.then(()=>u[0]==="reject"?v(u[1]):g(u[1])).catch(v));return typeof l!="string"&&typeof l!="number"?{unwrap:p}:Object.assign(l,{unwrap:p})},this.custom=(n,a)=>{let l=(a==null?void 0:a.id)||sm++;return this.create({jsx:n(l),id:l,...a}),l},this.getActiveToasts=()=>this.toasts.filter(n=>!this.dismissedToasts.has(n.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Tn=new xD,yD=(n,a)=>{let l=(a==null?void 0:a.id)||sm++;return Tn.addToast({title:n,...a,id:l}),l},bD=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",wD=yD,SD=()=>Tn.toasts,jD=()=>Tn.getActiveToasts(),ve=Object.assign(wD,{success:Tn.success,info:Tn.info,warning:Tn.warning,error:Tn.error,custom:Tn.custom,message:Tn.message,promise:Tn.promise,dismiss:Tn.dismiss,loading:Tn.loading},{getHistory:SD,getToasts:jD});function CD(n,{insertAt:a}={}){if(typeof document>"u")return;let l=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",a==="top"&&l.firstChild?l.insertBefore(s,l.firstChild):l.appendChild(s),s.styleSheet?s.styleSheet.cssText=n:s.appendChild(document.createTextNode(n))}CD(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
341
|
-
`);function Hc(n){return n.label!==void 0}var ED=3,RD="32px",ND="16px",Cb=4e3,TD=356,MD=14,AD=20,DD=200;function xa(...n){return n.filter(Boolean).join(" ")}function OD(n){let[a,l]=n.split("-"),s=[];return a&&s.push(a),l&&s.push(l),s}var _D=n=>{var a,l,s,c,u,f,p,g,v,x,y;let{invert:b,toast:w,unstyled:E,interacting:j,setHeights:C,visibleToasts:N,heights:M,index:T,toasts:D,expanded:O,removeToast:A,defaultRichColors:U,closeButton:k,style:$,cancelButtonStyle:X,actionButtonStyle:te,className:G="",descriptionClassName:ie="",duration:ce,position:se,gap:_,loadingIcon:H,expandByDefault:Q,classNames:J,icons:ee,closeButtonAriaLabel:z="Close toast",pauseWhenPageIsHidden:I}=n,[F,re]=ue.useState(null),[he,ge]=ue.useState(null),[q,oe]=ue.useState(!1),[de,fe]=ue.useState(!1),[Te,je]=ue.useState(!1),[De,Fe]=ue.useState(!1),[et,le]=ue.useState(!1),[Le,Ie]=ue.useState(0),[kt,St]=ue.useState(0),Ft=ue.useRef(w.duration||ce||Cb),on=ue.useRef(null),Qt=ue.useRef(null),jt=T===0,fn=T+1<=N,Mt=w.type,At=w.dismissible!==!1,cn=w.className||"",fa=w.descriptionClassName||"",Ta=ue.useMemo(()=>M.findIndex(Ce=>Ce.toastId===w.id)||0,[M,w.id]),Gn=ue.useMemo(()=>{var Ce;return(Ce=w.closeButton)!=null?Ce:k},[w.closeButton,k]),dl=ue.useMemo(()=>w.duration||ce||Cb,[w.duration,ce]),ha=ue.useRef(0),Dt=ue.useRef(0),hn=ue.useRef(0),Tt=ue.useRef(null),[Js,Pl]=se.split("-"),ql=ue.useMemo(()=>M.reduce((Ce,ke,Ue)=>Ue>=Ta?Ce:Ce+ke.height,0),[M,Ta]),Ya=vD(),Nr=w.invert||b,vt=Mt==="loading";Dt.current=ue.useMemo(()=>Ta*_+ql,[Ta,ql]),ue.useEffect(()=>{Ft.current=dl},[dl]),ue.useEffect(()=>{oe(!0)},[]),ue.useEffect(()=>{let Ce=Qt.current;if(Ce){let ke=Ce.getBoundingClientRect().height;return St(ke),C(Ue=>[{toastId:w.id,height:ke,position:w.position},...Ue]),()=>C(Ue=>Ue.filter(gt=>gt.toastId!==w.id))}},[C,w.id]),ue.useLayoutEffect(()=>{if(!q)return;let Ce=Qt.current,ke=Ce.style.height;Ce.style.height="auto";let Ue=Ce.getBoundingClientRect().height;Ce.style.height=ke,St(Ue),C(gt=>gt.find(Ct=>Ct.toastId===w.id)?gt.map(Ct=>Ct.toastId===w.id?{...Ct,height:Ue}:Ct):[{toastId:w.id,height:Ue,position:w.position},...gt])},[q,w.title,w.description,C,w.id]);let st=ue.useCallback(()=>{fe(!0),Ie(Dt.current),C(Ce=>Ce.filter(ke=>ke.toastId!==w.id)),setTimeout(()=>{A(w)},DD)},[w,A,C,Dt]);ue.useEffect(()=>{if(w.promise&&Mt==="loading"||w.duration===1/0||w.type==="loading")return;let Ce;return O||j||I&&Ya?(()=>{if(hn.current<ha.current){let ke=new Date().getTime()-ha.current;Ft.current=Ft.current-ke}hn.current=new Date().getTime()})():Ft.current!==1/0&&(ha.current=new Date().getTime(),Ce=setTimeout(()=>{var ke;(ke=w.onAutoClose)==null||ke.call(w,w),st()},Ft.current)),()=>clearTimeout(Ce)},[O,j,w,Mt,I,Ya,st]),ue.useEffect(()=>{w.delete&&st()},[st,w.delete]);function Bt(){var Ce,ke,Ue;return ee!=null&&ee.loading?ue.createElement("div",{className:xa(J==null?void 0:J.loader,(Ce=w==null?void 0:w.classNames)==null?void 0:Ce.loader,"sonner-loader"),"data-visible":Mt==="loading"},ee.loading):H?ue.createElement("div",{className:xa(J==null?void 0:J.loader,(ke=w==null?void 0:w.classNames)==null?void 0:ke.loader,"sonner-loader"),"data-visible":Mt==="loading"},H):ue.createElement(dD,{className:xa(J==null?void 0:J.loader,(Ue=w==null?void 0:w.classNames)==null?void 0:Ue.loader),visible:Mt==="loading"})}return ue.createElement("li",{tabIndex:0,ref:Qt,className:xa(G,cn,J==null?void 0:J.toast,(a=w==null?void 0:w.classNames)==null?void 0:a.toast,J==null?void 0:J.default,J==null?void 0:J[Mt],(l=w==null?void 0:w.classNames)==null?void 0:l[Mt]),"data-sonner-toast":"","data-rich-colors":(s=w.richColors)!=null?s:U,"data-styled":!(w.jsx||w.unstyled||E),"data-mounted":q,"data-promise":!!w.promise,"data-swiped":et,"data-removed":de,"data-visible":fn,"data-y-position":Js,"data-x-position":Pl,"data-index":T,"data-front":jt,"data-swiping":Te,"data-dismissible":At,"data-type":Mt,"data-invert":Nr,"data-swipe-out":De,"data-swipe-direction":he,"data-expanded":!!(O||Q&&q),style:{"--index":T,"--toasts-before":T,"--z-index":D.length-T,"--offset":`${de?Le:Dt.current}px`,"--initial-height":Q?"auto":`${kt}px`,...$,...w.style},onDragEnd:()=>{je(!1),re(null),Tt.current=null},onPointerDown:Ce=>{vt||!At||(on.current=new Date,Ie(Dt.current),Ce.target.setPointerCapture(Ce.pointerId),Ce.target.tagName!=="BUTTON"&&(je(!0),Tt.current={x:Ce.clientX,y:Ce.clientY}))},onPointerUp:()=>{var Ce,ke,Ue,gt;if(De||!At)return;Tt.current=null;let Ct=Number(((Ce=Qt.current)==null?void 0:Ce.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ct=Number(((ke=Qt.current)==null?void 0:ke.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),$t=new Date().getTime()-((Ue=on.current)==null?void 0:Ue.getTime()),xt=F==="x"?Ct:ct,zt=Math.abs(xt)/$t;if(Math.abs(xt)>=AD||zt>.11){Ie(Dt.current),(gt=w.onDismiss)==null||gt.call(w,w),ge(F==="x"?Ct>0?"right":"left":ct>0?"down":"up"),st(),Fe(!0),le(!1);return}je(!1),re(null)},onPointerMove:Ce=>{var ke,Ue,gt,Ct;if(!Tt.current||!At||((ke=window.getSelection())==null?void 0:ke.toString().length)>0)return;let ct=Ce.clientY-Tt.current.y,$t=Ce.clientX-Tt.current.x,xt=(Ue=n.swipeDirections)!=null?Ue:OD(se);!F&&(Math.abs($t)>1||Math.abs(ct)>1)&&re(Math.abs($t)>Math.abs(ct)?"x":"y");let zt={x:0,y:0};F==="y"?(xt.includes("top")||xt.includes("bottom"))&&(xt.includes("top")&&ct<0||xt.includes("bottom")&&ct>0)&&(zt.y=ct):F==="x"&&(xt.includes("left")||xt.includes("right"))&&(xt.includes("left")&&$t<0||xt.includes("right")&&$t>0)&&(zt.x=$t),(Math.abs(zt.x)>0||Math.abs(zt.y)>0)&&le(!0),(gt=Qt.current)==null||gt.style.setProperty("--swipe-amount-x",`${zt.x}px`),(Ct=Qt.current)==null||Ct.style.setProperty("--swipe-amount-y",`${zt.y}px`)}},Gn&&!w.jsx?ue.createElement("button",{"aria-label":z,"data-disabled":vt,"data-close-button":!0,onClick:vt||!At?()=>{}:()=>{var Ce;st(),(Ce=w.onDismiss)==null||Ce.call(w,w)},className:xa(J==null?void 0:J.closeButton,(c=w==null?void 0:w.classNames)==null?void 0:c.closeButton)},(u=ee==null?void 0:ee.close)!=null?u:gD):null,w.jsx||m.isValidElement(w.title)?w.jsx?w.jsx:typeof w.title=="function"?w.title():w.title:ue.createElement(ue.Fragment,null,Mt||w.icon||w.promise?ue.createElement("div",{"data-icon":"",className:xa(J==null?void 0:J.icon,(f=w==null?void 0:w.classNames)==null?void 0:f.icon)},w.promise||w.type==="loading"&&!w.icon?w.icon||Bt():null,w.type!=="loading"?w.icon||(ee==null?void 0:ee[Mt])||cD(Mt):null):null,ue.createElement("div",{"data-content":"",className:xa(J==null?void 0:J.content,(p=w==null?void 0:w.classNames)==null?void 0:p.content)},ue.createElement("div",{"data-title":"",className:xa(J==null?void 0:J.title,(g=w==null?void 0:w.classNames)==null?void 0:g.title)},typeof w.title=="function"?w.title():w.title),w.description?ue.createElement("div",{"data-description":"",className:xa(ie,fa,J==null?void 0:J.description,(v=w==null?void 0:w.classNames)==null?void 0:v.description)},typeof w.description=="function"?w.description():w.description):null),m.isValidElement(w.cancel)?w.cancel:w.cancel&&Hc(w.cancel)?ue.createElement("button",{"data-button":!0,"data-cancel":!0,style:w.cancelButtonStyle||X,onClick:Ce=>{var ke,Ue;Hc(w.cancel)&&At&&((Ue=(ke=w.cancel).onClick)==null||Ue.call(ke,Ce),st())},className:xa(J==null?void 0:J.cancelButton,(x=w==null?void 0:w.classNames)==null?void 0:x.cancelButton)},w.cancel.label):null,m.isValidElement(w.action)?w.action:w.action&&Hc(w.action)?ue.createElement("button",{"data-button":!0,"data-action":!0,style:w.actionButtonStyle||te,onClick:Ce=>{var ke,Ue;Hc(w.action)&&((Ue=(ke=w.action).onClick)==null||Ue.call(ke,Ce),!Ce.defaultPrevented&&st())},className:xa(J==null?void 0:J.actionButton,(y=w==null?void 0:w.classNames)==null?void 0:y.actionButton)},w.action.label):null))};function Eb(){if(typeof window>"u"||typeof document>"u")return"ltr";let n=document.documentElement.getAttribute("dir");return n==="auto"||!n?window.getComputedStyle(document.documentElement).direction:n}function kD(n,a){let l={};return[n,a].forEach((s,c)=>{let u=c===1,f=u?"--mobile-offset":"--offset",p=u?ND:RD;function g(v){["top","right","bottom","left"].forEach(x=>{l[`${f}-${x}`]=typeof v=="number"?`${v}px`:v})}typeof s=="number"||typeof s=="string"?g(s):typeof s=="object"?["top","right","bottom","left"].forEach(v=>{s[v]===void 0?l[`${f}-${v}`]=p:l[`${f}-${v}`]=typeof s[v]=="number"?`${s[v]}px`:s[v]}):g(p)}),l}var zD=m.forwardRef(function(n,a){let{invert:l,position:s="bottom-right",hotkey:c=["altKey","KeyT"],expand:u,closeButton:f,className:p,offset:g,mobileOffset:v,theme:x="light",richColors:y,duration:b,style:w,visibleToasts:E=ED,toastOptions:j,dir:C=Eb(),gap:N=MD,loadingIcon:M,icons:T,containerAriaLabel:D="Notifications",pauseWhenPageIsHidden:O}=n,[A,U]=ue.useState([]),k=ue.useMemo(()=>Array.from(new Set([s].concat(A.filter(I=>I.position).map(I=>I.position)))),[A,s]),[$,X]=ue.useState([]),[te,G]=ue.useState(!1),[ie,ce]=ue.useState(!1),[se,_]=ue.useState(x!=="system"?x:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),H=ue.useRef(null),Q=c.join("+").replace(/Key/g,"").replace(/Digit/g,""),J=ue.useRef(null),ee=ue.useRef(!1),z=ue.useCallback(I=>{U(F=>{var re;return(re=F.find(he=>he.id===I.id))!=null&&re.delete||Tn.dismiss(I.id),F.filter(({id:he})=>he!==I.id)})},[]);return ue.useEffect(()=>Tn.subscribe(I=>{if(I.dismiss){U(F=>F.map(re=>re.id===I.id?{...re,delete:!0}:re));return}setTimeout(()=>{$E.flushSync(()=>{U(F=>{let re=F.findIndex(he=>he.id===I.id);return re!==-1?[...F.slice(0,re),{...F[re],...I},...F.slice(re+1)]:[I,...F]})})})}),[]),ue.useEffect(()=>{if(x!=="system"){_(x);return}if(x==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?_("dark"):_("light")),typeof window>"u")return;let I=window.matchMedia("(prefers-color-scheme: dark)");try{I.addEventListener("change",({matches:F})=>{_(F?"dark":"light")})}catch{I.addListener(({matches:re})=>{try{_(re?"dark":"light")}catch(he){console.error(he)}})}},[x]),ue.useEffect(()=>{A.length<=1&&G(!1)},[A]),ue.useEffect(()=>{let I=F=>{var re,he;c.every(ge=>F[ge]||F.code===ge)&&(G(!0),(re=H.current)==null||re.focus()),F.code==="Escape"&&(document.activeElement===H.current||(he=H.current)!=null&&he.contains(document.activeElement))&&G(!1)};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[c]),ue.useEffect(()=>{if(H.current)return()=>{J.current&&(J.current.focus({preventScroll:!0}),J.current=null,ee.current=!1)}},[H.current]),ue.createElement("section",{ref:a,"aria-label":`${D} ${Q}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},k.map((I,F)=>{var re;let[he,ge]=I.split("-");return A.length?ue.createElement("ol",{key:I,dir:C==="auto"?Eb():C,tabIndex:-1,ref:H,className:p,"data-sonner-toaster":!0,"data-theme":se,"data-y-position":he,"data-lifted":te&&A.length>1&&!u,"data-x-position":ge,style:{"--front-toast-height":`${((re=$[0])==null?void 0:re.height)||0}px`,"--width":`${TD}px`,"--gap":`${N}px`,...w,...kD(g,v)},onBlur:q=>{ee.current&&!q.currentTarget.contains(q.relatedTarget)&&(ee.current=!1,J.current&&(J.current.focus({preventScroll:!0}),J.current=null))},onFocus:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||ee.current||(ee.current=!0,J.current=q.relatedTarget)},onMouseEnter:()=>G(!0),onMouseMove:()=>G(!0),onMouseLeave:()=>{ie||G(!1)},onDragEnd:()=>G(!1),onPointerDown:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||ce(!0)},onPointerUp:()=>ce(!1)},A.filter(q=>!q.position&&F===0||q.position===I).map((q,oe)=>{var de,fe;return ue.createElement(_D,{key:q.id,icons:T,index:oe,toast:q,defaultRichColors:y,duration:(de=j==null?void 0:j.duration)!=null?de:b,className:j==null?void 0:j.className,descriptionClassName:j==null?void 0:j.descriptionClassName,invert:l,visibleToasts:E,closeButton:(fe=j==null?void 0:j.closeButton)!=null?fe:f,interacting:ie,position:I,style:j==null?void 0:j.style,unstyled:j==null?void 0:j.unstyled,classNames:j==null?void 0:j.classNames,cancelButtonStyle:j==null?void 0:j.cancelButtonStyle,actionButtonStyle:j==null?void 0:j.actionButtonStyle,removeToast:z,toasts:A.filter(Te=>Te.position==q.position),heights:$.filter(Te=>Te.position==q.position),setHeights:X,expandByDefault:u,gap:N,loadingIcon:M,expanded:te,pauseWhenPageIsHidden:O,swipeDirections:n.swipeDirections})})):null}))});function LD(){const{login:n}=_m(),[a,l]=m.useState("admin"),[s,c]=m.useState(""),[u,f]=m.useState(""),[p,g]=m.useState(""),[v,x]=m.useState(!1),[y,b]=m.useState(!1),w=oi(),E=_n();return o.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:o.jsxs(nt,{className:"w-full max-w-sm",children:[o.jsxs(at,{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("img",{src:"/logo.png",alt:"LateDev Router",className:"h-8 w-8 object-contain"}),o.jsx(rt,{children:"Sign in"})]}),o.jsx(gn,{children:"Enter your admin credentials."})]}),o.jsxs(lt,{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(we,{children:"Username"}),o.jsx(Ae,{value:a,onChange:j=>l(j.target.value),autoFocus:!0})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(we,{children:"Password"}),o.jsx(Ae,{type:"password",value:s,onChange:j=>c(j.target.value)})]}),v&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(we,{children:"2FA code (or recovery code)"}),o.jsx(Ae,{value:u,onChange:j=>f(j.target.value),placeholder:"123456",maxLength:6})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(we,{children:"Recovery code (alternative)"}),o.jsx(Ae,{value:p,onChange:j=>g(j.target.value),placeholder:"ABCD12-EF3456"})]})]})]}),o.jsx("div",{className:"px-6 pb-6",children:o.jsx(me,{className:"w-full",disabled:y,onClick:async()=>{var j,C;b(!0);try{if((await n(a,s,u||void 0,p||void 0)).totpRequired){x(!0);return}const M=((C=(j=E.state)==null?void 0:j.from)==null?void 0:C.pathname)??"/";w(M,{replace:!0})}catch(N){ve.error(N.message)}finally{b(!1)}},children:"Sign in"})})]})})}function UD(){const[n,a]=m.useState("admin"),[l,s]=m.useState(""),[c,u]=m.useState(""),[f,p]=m.useState(!1),[g,v]=m.useState(!0),[x,y]=m.useState(null),[b,w]=m.useState(""),[E,j]=m.useState(!1);m.useEffect(()=>{Se.get("/api/admin/setup/status").then(M=>v(!M.masterKeyConfigured)).catch(()=>v(!0))},[]);const C=!g||c.trim().length>=32,N=!f&&l.length>=12&&C;return o.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:o.jsxs(nt,{className:"w-full max-w-md",children:[o.jsxs(at,{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("img",{src:"/logo.png",alt:"LateDev Router",className:"h-8 w-8 object-contain rounded"}),o.jsx(rt,{children:"Welcome to LateDev Router"})]}),o.jsx(gn,{children:"Set up the administrator account to get started."})]}),o.jsxs(lt,{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(we,{children:"Username"}),o.jsx(Ae,{value:n,onChange:M=>a(M.target.value)})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(we,{children:"Password (12+ chars)"}),o.jsx(Ae,{type:"password",value:l,onChange:M=>s(M.target.value)})]}),g&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(we,{children:"Master encryption key (required, 32+ chars)"}),o.jsx(Ae,{type:"password",value:c,onChange:M=>u(M.target.value),placeholder:"Paste or generate a 32+ character key"}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Provider API keys are encrypted with this key (AES-256-GCM). Store it somewhere safe — if it is lost, stored provider credentials cannot be recovered. Generate one with:"," ",o.jsx("code",{className:"break-all",children:`node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"`})]})]})]}),o.jsxs(jw,{className:"flex-col items-stretch gap-4",children:[o.jsx(me,{disabled:!N,onClick:async()=>{p(!0);try{await Se.post("/api/admin/setup",{username:n,password:l,setupMasterKey:g?c.trim():void 0}),ve.success("Admin account created"),window.location.assign("/login")}catch(M){ve.error(M.message)}finally{p(!1)}},children:"Create admin"}),o.jsxs("div",{className:"border-t pt-4 space-y-2",children:[o.jsx(we,{children:"Import existing database"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Use this to restore the administrator account, password, TOTP settings, providers, models, and master key from a backup without setting up again. Enter the same 6-digit backup passphrase used when the file was created."}),o.jsx(Ae,{type:"file",accept:".json,application/json",onChange:M=>{var T;return y(((T=M.target.files)==null?void 0:T[0])??null)}}),o.jsx(Ae,{inputMode:"numeric",maxLength:6,value:b,onChange:M=>w(M.target.value.replace(/\D/g,"")),placeholder:"Backup passphrase (6 digits)"}),o.jsx(me,{variant:"outline",disabled:!x||b.length!==6||E,onClick:async()=>{var M,T;if(x){j(!0);try{const D=JSON.parse(await x.text()),O=await fetch("/api/admin/backup/restore",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({backup:D,passphrase:b})});if(!O.ok)throw new Error(((T=(M=await O.json())==null?void 0:M.error)==null?void 0:T.message)??"Import failed");ve.success("Database imported"),window.location.assign("/login")}catch(D){ve.error(D.message)}finally{j(!1)}}},children:"Import database"})]})]})]})})}function $a({title:n,description:a,actions:l,className:s}){return o.jsxs("div",{className:Ee("mb-6 flex items-start justify-between gap-4",s),children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:n}),a&&o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a})]}),l&&o.jsx("div",{className:"flex items-center gap-2",children:l})]})}const BD=K0("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground",success:"border-transparent bg-emerald-600 text-white",warning:"border-transparent bg-amber-500 text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Qe({className:n,variant:a,...l}){return o.jsx("div",{className:Ee(BD({variant:a}),n),...l})}const Oh=n=>n==="ready"||n==="healthy"?"success":n==="disabled"?"secondary":"destructive";function HD(){const[n,a]=m.useState(null);return m.useEffect(()=>{Se.get("/api/admin/dashboard").then(a).catch(()=>a(null))},[]),n?o.jsxs("div",{children:[o.jsx($a,{title:"Dashboard",description:"Operational summary for today",actions:o.jsxs("div",{className:"flex gap-2",children:[o.jsx(me,{asChild:!0,variant:"outline",size:"sm",children:o.jsxs(ra,{to:"/providers",children:[o.jsx(Su,{className:"mr-1 h-4 w-4"})," Provider"]})}),o.jsx(me,{asChild:!0,variant:"outline",size:"sm",children:o.jsxs(ra,{to:"/combos",children:[o.jsx(T0,{className:"mr-1 h-4 w-4"})," Combo"]})}),o.jsx(me,{asChild:!0,variant:"outline",size:"sm",children:o.jsxs(ra,{to:"/api-keys",children:[o.jsx(N0,{className:"mr-1 h-4 w-4"})," API Key"]})})]})}),o.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[o.jsxs(nt,{children:[o.jsx(at,{className:"pb-1",children:o.jsx(rt,{className:"text-sm text-muted-foreground",children:"Requests today"})}),o.jsx(lt,{className:"text-2xl font-semibold",children:Kt(n.today.total)})]}),o.jsxs(nt,{children:[o.jsx(at,{className:"pb-1",children:o.jsx(rt,{className:"text-sm text-muted-foreground",children:"Success rate"})}),o.jsx(lt,{className:"text-2xl font-semibold",children:n.today.total?Eu(n.today.success/n.today.total):"—"})]}),o.jsxs(nt,{children:[o.jsx(at,{className:"pb-1",children:o.jsx(rt,{className:"text-sm text-muted-foreground",children:"Failed"})}),o.jsx(lt,{className:"text-2xl font-semibold",children:Kt(n.today.failed)})]}),o.jsxs(nt,{children:[o.jsx(at,{className:"pb-1",children:o.jsx(rt,{className:"text-sm text-muted-foreground",children:"Tokens today"})}),o.jsx(lt,{className:"text-2xl font-semibold",children:Kt(n.today.totalTokens)})]})]}),o.jsxs("div",{className:"mt-6 grid gap-4 lg:grid-cols-2",children:[o.jsxs(nt,{children:[o.jsxs(at,{children:[o.jsx(rt,{className:"text-base",children:"Provider health"}),o.jsxs(gn,{children:[n.providers.length," configured"]})]}),o.jsxs(lt,{className:"space-y-2",children:[n.providers.length===0&&o.jsxs("p",{className:"text-sm text-muted-foreground",children:["No providers yet. ",o.jsx(ra,{to:"/providers",className:"text-primary",children:"Add one"}),"."]}),n.providers.map(l=>o.jsxs("div",{className:"flex items-center justify-between rounded border p-2 text-sm",children:[o.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[o.jsx(M0,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),o.jsx(ra,{className:"truncate font-medium text-primary hover:underline",to:`/providers?providerId=${encodeURIComponent(l.id)}`,children:l.name}),o.jsx("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:l.slug}),o.jsx(Qe,{variant:"outline",className:"ml-2",children:l.type})]}),o.jsx(Qe,{variant:Oh(l.health),children:l.health})]},l.id))]})]}),o.jsxs(nt,{children:[o.jsxs(at,{children:[o.jsx(rt,{className:"text-base",children:"Recent failures"}),o.jsx(gn,{children:"Today"})]}),o.jsxs(lt,{className:"space-y-1 text-sm",children:[n.recentFailures.length===0&&o.jsx("p",{className:"text-muted-foreground",children:"No failures today."}),n.recentFailures.map(l=>{var s;return o.jsxs("div",{className:"flex items-center justify-between border-b py-1 last:border-0",children:[o.jsxs("div",{children:[o.jsx("span",{className:"font-mono text-xs",children:l.requestedModel}),o.jsxs("div",{className:"text-xs text-muted-foreground",children:[l.errorType??`HTTP ${l.httpStatus}`," — ",(s=l.errorMessage)==null?void 0:s.slice(0,60)]})]}),o.jsx("span",{className:"text-xs text-muted-foreground",children:Lm(l.createdAt)})]},l.id)})]})]})]}),o.jsxs(nt,{className:"mt-6",children:[o.jsxs(at,{children:[o.jsxs(rt,{className:"flex items-center gap-2 text-base",children:[o.jsx(km,{className:"h-4 w-4"})," Health center"]}),o.jsx(gn,{children:"Passive status from recent traffic; no active provider polling."})]}),o.jsxs(lt,{className:"grid gap-4 lg:grid-cols-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"mb-2 text-sm font-medium",children:"Combos"}),o.jsx("div",{className:"space-y-2",children:n.combos.length===0?o.jsx("p",{className:"text-sm text-muted-foreground",children:"No combos configured."}):n.combos.map(l=>o.jsxs("div",{className:"flex items-center justify-between rounded border p-2 text-sm",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx(ra,{className:"font-mono text-xs text-primary hover:underline",to:"/combos",children:l.publicModelId}),o.jsxs("div",{className:"text-xs text-muted-foreground",children:[l.readyMembers,"/",l.memberCount," members ready",l.reasons.length>0?` · ${l.reasons.join(", ")}`:""]})]}),o.jsx(Qe,{variant:Oh(l.state),children:l.state})]},l.id))})]}),o.jsxs("div",{children:[o.jsx("div",{className:"mb-2 text-sm font-medium",children:"Models"}),o.jsx("div",{className:"max-h-64 space-y-2 overflow-auto",children:n.models.length===0?o.jsx("p",{className:"text-sm text-muted-foreground",children:"No models imported."}):n.models.map(l=>o.jsxs("div",{className:"flex items-center justify-between rounded border p-2 text-sm",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx(ra,{className:"font-mono text-xs text-primary hover:underline",to:`/models?providerId=${encodeURIComponent(l.providerId)}`,children:l.publicModelId}),o.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[l.providerName??"Unknown provider",l.lastFailureReason?` · last: ${l.lastFailureReason}`:""]})]}),o.jsx(Qe,{variant:Oh(l.state),children:l.state})]},l.id))})]})]})]})]}):o.jsx("div",{className:"text-muted-foreground",children:"Loading…"})}const ca=m.forwardRef(({className:n,...a},l)=>o.jsx("div",{className:"relative w-full overflow-auto",children:o.jsx("table",{ref:l,className:Ee("w-full caption-bottom text-sm",n),...a})}));ca.displayName="Table";const ua=m.forwardRef(({className:n,...a},l)=>o.jsx("thead",{ref:l,className:Ee("[&_tr]:border-b",n),...a}));ua.displayName="TableHeader";const da=m.forwardRef(({className:n,...a},l)=>o.jsx("tbody",{ref:l,className:Ee("[&_tr:last-child]:border-0",n),...a}));da.displayName="TableBody";const We=m.forwardRef(({className:n,...a},l)=>o.jsx("tr",{ref:l,className:Ee("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",n),...a}));We.displayName="TableRow";const ye=m.forwardRef(({className:n,...a},l)=>o.jsx("th",{ref:l,className:Ee("h-10 px-2 text-left align-middle font-medium text-muted-foreground",n),...a}));ye.displayName="TableHead";const pe=m.forwardRef(({className:n,...a},l)=>o.jsx("td",{ref:l,className:Ee("p-2 align-middle",n),...a}));pe.displayName="TableCell";var ID=Object.defineProperty,Yn=(n,a)=>ID(n,"name",{value:a,configurable:!0}),rp="Dialog",[Cw,Ew]=kn(rp),[PD,Na]=Cw(rp),Rw=Yn(n=>{const{__scopeDialog:a,children:l,open:s,defaultOpen:c,onOpenChange:u,modal:f=!0}=n,p=m.useRef(null),g=m.useRef(null),[v,x]=yr({prop:s,defaultProp:c??!1,onChange:u,caller:rp}),[y,b]=m.useState(0),[w,E]=m.useState(0);return o.jsx(PD,{scope:a,triggerRef:p,contentRef:g,contentId:La(),titleId:La(),descriptionId:La(),titlePresent:y>0,descriptionPresent:w>0,setTitleCount:b,setDescriptionCount:E,open:v,onOpenChange:x,onOpenToggle:m.useCallback(()=>x(j=>!j),[x]),modal:f,children:l})},"Dialog"),qD="DialogTrigger",Nw=m.forwardRef(Yn(function(a,l){const{__scopeDialog:s,...c}=a,u=Na(qD,s),f=Xe(l,u.triggerRef);return o.jsx(Ve.button,{type:"button","aria-haspopup":"dialog","aria-expanded":u.open,"aria-controls":u.open?u.contentId:void 0,"data-state":Iu(u.open),...c,ref:f,onClick:Ne(a.onClick,u.onOpenToggle)})},"DialogTrigger")),Tw="DialogPortal",[VD,Mw]=Cw(Tw,{forceMount:void 0}),Aw=Yn(n=>{const{__scopeDialog:a,forceMount:l,children:s,container:c}=n,u=Na(Tw,a);return o.jsx(VD,{scope:a,forceMount:l,children:m.Children.map(s,f=>o.jsx(Cr,{present:l||u.open,children:o.jsx(Zm,{asChild:!0,container:c,children:f})}))})},"DialogPortal"),om="DialogOverlay",lp=m.forwardRef(Yn(function(a,l){const s=Mw(om,a.__scopeDialog),{forceMount:c=s.forceMount,...u}=a,f=Na(om,a.__scopeDialog);return f.modal?o.jsx(Cr,{present:c||f.open,children:o.jsx(YD,{...u,ref:l})}):null},"DialogOverlay")),$D=Ha("DialogOverlay.RemoveScroll"),YD=m.forwardRef(Yn(function(a,l){const{__scopeDialog:s,...c}=a,u=Na(om,s),f=o1(),p=Xe(l,f);return o.jsx(Bu,{as:$D,allowPinchZoom:!0,shards:[u.contentRef],children:o.jsx(Ve.div,{"data-state":Iu(u.open),...c,ref:p,style:{pointerEvents:"auto",...c.style}})})},"DialogOverlayImpl")),ei="DialogContent",sp=m.forwardRef(Yn(function(a,l){const s=Mw(ei,a.__scopeDialog),{forceMount:c=s.forceMount,...u}=a,f=Na(ei,a.__scopeDialog);return o.jsx(Cr,{present:c||f.open,children:f.modal?o.jsx(GD,{...u,ref:l}):o.jsx(KD,{...u,ref:l})})},"DialogContent")),GD=m.forwardRef(Yn(function(a,l){const s=Na(ei,a.__scopeDialog),c=m.useRef(null),u=Xe(l,s.contentRef,c);return m.useEffect(()=>{const f=c.current;if(f)return ep(f)},[]),o.jsx(Dw,{...a,ref:u,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:Ne(a.onCloseAutoFocus,f=>{var p;f.preventDefault(),(p=s.triggerRef.current)==null||p.focus()}),onPointerDownOutside:Ne(a.onPointerDownOutside,f=>{const p=f.detail.originalEvent,g=p.button===0&&p.ctrlKey===!0;(p.button===2||g)&&f.preventDefault()}),onFocusOutside:Ne(a.onFocusOutside,f=>f.preventDefault())})},"DialogContentModal")),KD=m.forwardRef(Yn(function(a,l){const s=Na(ei,a.__scopeDialog),c=m.useRef(!1),u=m.useRef(!1);return o.jsx(Dw,{...a,ref:l,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:f=>{var p,g;(p=a.onCloseAutoFocus)==null||p.call(a,f),f.defaultPrevented||(c.current||(g=s.triggerRef.current)==null||g.focus(),f.preventDefault()),c.current=!1,u.current=!1},onInteractOutside:f=>{var v,x;(v=a.onInteractOutside)==null||v.call(a,f),f.defaultPrevented||(c.current=!0,f.detail.originalEvent.type==="pointerdown"&&(u.current=!0));const p=f.target;((x=s.triggerRef.current)==null?void 0:x.contains(p))&&f.preventDefault(),f.detail.originalEvent.type==="focusin"&&u.current&&f.preventDefault()}})},"DialogContentNonModal")),Dw=m.forwardRef(Yn(function(a,l){const{__scopeDialog:s,trapFocus:c,onOpenAutoFocus:u,onCloseAutoFocus:f,...p}=a,g=Na(ei,s);return fi(),o.jsx(o.Fragment,{children:o.jsx(qm,{asChild:!0,loop:!0,trapped:c,onMountAutoFocus:u,onUnmountAutoFocus:f,children:o.jsx(Nu,{role:"dialog",id:g.contentId,"aria-describedby":g.descriptionPresent?g.descriptionId:void 0,"aria-labelledby":g.titlePresent?g.titleId:void 0,"data-state":Iu(g.open),...p,ref:l,deferPointerDownOutside:!0,onDismiss:()=>g.onOpenChange(!1)})})})},"DialogContentImpl")),XD="DialogTitle",op=m.forwardRef(Yn(function(a,l){const{__scopeDialog:s,...c}=a,u=Na(XD,s),{setTitleCount:f}=u;return Xt(()=>(f(p=>p+1),()=>f(p=>p-1)),[f]),o.jsx(Ve.h2,{id:u.titleId,...c,ref:l})},"DialogTitle")),FD="DialogDescription",ip=m.forwardRef(Yn(function(a,l){const{__scopeDialog:s,...c}=a,u=Na(FD,s),{setDescriptionCount:f}=u;return Xt(()=>(f(p=>p+1),()=>f(p=>p-1)),[f]),o.jsx(Ve.p,{id:u.descriptionId,...c,ref:l})},"DialogDescription")),QD="DialogClose",cp=m.forwardRef(Yn(function(a,l){const{__scopeDialog:s,...c}=a,u=Na(QD,s);return o.jsx(Ve.button,{type:"button",...c,ref:l,onClick:Ne(a.onClick,()=>u.onOpenChange(!1))})},"DialogClose"));function Iu(n){return n?"open":"closed"}Yn(Iu,"getState");const Mn=Rw,mi=Nw,ZD=Aw,Ow=m.forwardRef(({className:n,...a},l)=>o.jsx(lp,{ref:l,className:Ee("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...a}));Ow.displayName=lp.displayName;const vn=m.forwardRef(({className:n,children:a,...l},s)=>o.jsxs(ZD,{children:[o.jsx(Ow,{}),o.jsxs(sp,{ref:s,className:Ee("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 sm:rounded-lg",n),...l,children:[a,o.jsxs(cp,{className:"absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100",children:[o.jsx(Cu,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));vn.displayName=sp.displayName;const xn=({className:n,...a})=>o.jsx("div",{className:Ee("flex flex-col space-y-1.5 text-center sm:text-left",n),...a});xn.displayName="DialogHeader";const An=({className:n,...a})=>o.jsx("div",{className:Ee("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...a});An.displayName="DialogFooter";const yn=m.forwardRef(({className:n,...a},l)=>o.jsx(op,{ref:l,className:Ee("text-lg font-semibold leading-none tracking-tight",n),...a}));yn.displayName=op.displayName;const uu=m.forwardRef(({className:n,...a},l)=>o.jsx(ip,{ref:l,className:Ee("text-sm text-muted-foreground",n),...a}));uu.displayName=ip.displayName;var JD=Object.defineProperty,Er=(n,a)=>JD(n,"name",{value:a,configurable:!0}),WD="AlertDialog",[eO,Y4]=kn(WD,[Ew]),Rr=Ew(),tO=Er(n=>{const{__scopeAlertDialog:a,...l}=n,s=Rr(a);return o.jsx(Rw,{...s,...l,modal:!0})},"AlertDialog"),nO=m.forwardRef(Er(function(a,l){const{__scopeAlertDialog:s,...c}=a,u=Rr(s);return o.jsx(Nw,{...u,...c,ref:l})},"AlertDialogTrigger")),aO=Er(n=>{const{__scopeAlertDialog:a,...l}=n,s=Rr(a);return o.jsx(Aw,{...s,...l})},"AlertDialogPortal"),rO=m.forwardRef(Er(function(a,l){const{__scopeAlertDialog:s,...c}=a,u=Rr(s);return o.jsx(lp,{...u,...c,ref:l})},"AlertDialogOverlay")),lO="AlertDialogContent",[sO,oO]=eO(lO),iO=m.forwardRef(Er(function(a,l){const{__scopeAlertDialog:s,children:c,...u}=a,f=Rr(s),p=m.useRef(null),g=Xe(l,p),v=m.useRef(null);return o.jsx(sO,{scope:s,cancelRef:v,children:o.jsx(sp,{role:"alertdialog",...f,...u,ref:g,onOpenAutoFocus:Ne(u.onOpenAutoFocus,x=>{var y;x.preventDefault(),(y=v.current)==null||y.focus({preventScroll:!0})}),onPointerDownOutside:x=>x.preventDefault(),onInteractOutside:x=>x.preventDefault(),children:c})})},"AlertDialogContent")),cO=m.forwardRef(Er(function(a,l){const{__scopeAlertDialog:s,...c}=a,u=Rr(s);return o.jsx(op,{...u,...c,ref:l})},"AlertDialogTitle")),uO=m.forwardRef(Er(function(a,l){const{__scopeAlertDialog:s,...c}=a,u=Rr(s);return o.jsx(ip,{...u,...c,ref:l})},"AlertDialogDescription")),dO=m.forwardRef(Er(function(a,l){const{__scopeAlertDialog:s,...c}=a,u=Rr(s);return o.jsx(cp,{...u,...c,ref:l})},"AlertDialogAction")),fO="AlertDialogCancel",hO=m.forwardRef(Er(function(a,l){const{__scopeAlertDialog:s,...c}=a,{cancelRef:u}=oO(fO,s),f=Rr(s),p=Xe(l,u);return o.jsx(cp,{...f,...c,ref:p})},"AlertDialogCancel")),mO=tO,pO=nO,gO=aO,_w=rO,kw=iO,zw=dO,Lw=hO,Uw=cO,Bw=uO;const up=mO,vO=pO,xO=gO,Hw=m.forwardRef(({className:n,...a},l)=>o.jsx(_w,{ref:l,className:Ee("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...a}));Hw.displayName=_w.displayName;const Pu=m.forwardRef(({className:n,...a},l)=>o.jsxs(xO,{children:[o.jsx(Hw,{}),o.jsx(kw,{ref:l,className:Ee("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg sm:max-w-[425px]",n),...a})]}));Pu.displayName=kw.displayName;const dp=({className:n,...a})=>o.jsx("div",{className:Ee("flex flex-col space-y-2 text-center sm:text-left",n),...a}),fp=({className:n,...a})=>o.jsx("div",{className:Ee("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...a}),qu=m.forwardRef(({className:n,...a},l)=>o.jsx(Uw,{ref:l,className:Ee("text-lg font-semibold",n),...a}));qu.displayName=Uw.displayName;const Vu=m.forwardRef(({className:n,...a},l)=>o.jsx(Bw,{ref:l,className:Ee("text-sm text-muted-foreground",n),...a}));Vu.displayName=Bw.displayName;const $u=m.forwardRef(({className:n,...a},l)=>o.jsx(zw,{ref:l,className:Ee("inline-flex h-9 items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90",n),...a}));$u.displayName=zw.displayName;const Yu=m.forwardRef(({className:n,...a},l)=>o.jsx(Lw,{ref:l,className:Ee("inline-flex h-9 items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium hover:bg-accent",n),...a}));Yu.displayName=Lw.displayName;var yO=Object.defineProperty,bO=(n,a)=>yO(n,"name",{value:a,configurable:!0});function im(n,[a,l]){return Math.min(l,Math.max(a,n))}bO(im,"clamp");var wO=Object.defineProperty,SO=(n,a)=>wO(n,"name",{value:a,configurable:!0});function Iw(n){const a=m.useRef({value:n,previous:n});return m.useMemo(()=>(a.current.value!==n&&(a.current.previous=a.current.value,a.current.value=n),a.current.previous),[n])}SO(Iw,"usePrevious");var jO=Object.defineProperty,CO=(n,a)=>jO(n,"name",{value:a,configurable:!0}),Pw=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),EO=m.forwardRef(CO(function(a,l){return o.jsx(Ve.span,{...a,ref:l,style:{...Pw,...a.style}})},"VisuallyHidden")),RO=EO,NO=Object.defineProperty,ht=(n,a)=>NO(n,"name",{value:a,configurable:!0}),TO=[" ","Enter","ArrowUp","ArrowDown"],MO=[" ","Enter"],Bs="Select",[Gu,hp,AO]=Ru(Bs),[Il,G4]=kn(Bs,[AO,Ks]),mp=Ks(),[DO,ul]=Il(Bs),[OO,_O]=Il(Bs);function qw(n){const{__scopeSelect:a,children:l,open:s,defaultOpen:c,onOpenChange:u,value:f,defaultValue:p,onValueChange:g,dir:v,name:x,autoComplete:y,disabled:b,required:w,form:E,internal_do_not_use_render:j}=n,C=mp(a),[N,M]=m.useState(null),[T,D]=m.useState(null),[O,A]=m.useState(!1),U=di(v),[k,$]=yr({prop:s,defaultProp:c??!1,onChange:u,caller:Bs}),[X,te]=yr({prop:f,defaultProp:p,onChange:g,caller:Bs}),G=m.useRef(null),ie=m.useRef(X);m.useEffect(()=>{const I=E?N==null?void 0:N.ownerDocument.getElementById(E):N==null?void 0:N.form;if(I instanceof HTMLFormElement){const F=ht(()=>te(ie.current),"reset");return I.addEventListener("reset",F),()=>I.removeEventListener("reset",F)}},[E,N,te]);const ce=N?!!E||!!N.closest("form"):!0,[se,_]=m.useState(new Set),H=La(),Q=Array.from(se).map(I=>I.props.value).join(";"),J=m.useCallback(I=>{_(F=>new Set(F).add(I))},[]),ee=m.useCallback(I=>{_(F=>{const re=new Set(F);return re.delete(I),re})},[]),z={required:w,trigger:N,onTriggerChange:M,valueNode:T,onValueNodeChange:D,valueNodeHasChildren:O,onValueNodeHasChildrenChange:A,contentId:H,value:X,onValueChange:te,open:k,onOpenChange:$,dir:U,triggerPointerDownPosRef:G,disabled:b,name:x,autoComplete:y,form:E,nativeOptions:se,nativeSelectKey:Q,isFormControl:ce};return o.jsx(O1,{...C,children:o.jsx(DO,{scope:a,...z,children:o.jsx(Gu.Provider,{scope:a,children:o.jsx(OO,{scope:a,onNativeOptionAdd:J,onNativeOptionRemove:ee,children:Xw(j)?j(z):l})})})})}ht(qw,"SelectProvider");var kO=ht(n=>{const{__scopeSelect:a,children:l,...s}=n;return o.jsx(qw,{__scopeSelect:a,...s,internal_do_not_use_render:({isFormControl:c})=>o.jsxs(o.Fragment,{children:[l,c?o.jsx(n_,{__scopeSelect:a}):null]})})},"Select"),zO="SelectTrigger",Vw=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,disabled:c=!1,...u}=a,f=mp(s),p=ul(zO,s),g=p.disabled||c,v=Xe(l,p.onTriggerChange),x=hp(s),y=m.useRef("touch"),[b,w,E]=pp(C=>{const N=x().filter(D=>!D.disabled),M=N.find(D=>D.value===p.value),T=gp(N,C,M);T!==void 0&&p.onValueChange(T.value)}),j=ht(C=>{g||(p.onOpenChange(!0),E()),C&&(p.triggerPointerDownPosRef.current={x:Math.round(C.pageX),y:Math.round(C.pageY)})},"handleOpen");return o.jsx(_1,{asChild:!0,...f,children:o.jsx(Ve.button,{type:"button",role:"combobox","aria-controls":p.open?p.contentId:void 0,"aria-expanded":p.open,"aria-required":p.required,"aria-autocomplete":"none",dir:p.dir,"data-state":p.open?"open":"closed",disabled:g,"data-disabled":g?"":void 0,"data-placeholder":pi(p.value)?"":void 0,...u,ref:v,onClick:Ne(u.onClick,C=>{C.currentTarget.focus(),y.current!=="mouse"&&j(C)}),onPointerDown:Ne(u.onPointerDown,C=>{y.current=C.pointerType;const N=C.target;N.hasPointerCapture(C.pointerId)&&N.releasePointerCapture(C.pointerId),C.button===0&&C.ctrlKey===!1&&C.pointerType==="mouse"&&(j(C),C.preventDefault())}),onKeyDown:Ne(u.onKeyDown,C=>{const N=b.current!=="";!(C.ctrlKey||C.altKey||C.metaKey)&&C.key.length===1&&w(C.key),!(N&&C.key===" ")&&TO.includes(C.key)&&(j(),C.preventDefault())})})})},"SelectTrigger")),LO="SelectValue",UO=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,className:c,style:u,children:f,placeholder:p="",...g}=a,v=ul(LO,s),{onValueNodeHasChildrenChange:x}=v,y=f!==void 0,b=Xe(l,v.onValueNodeChange);Xt(()=>{x(y)},[x,y]);const w=pi(v.value);return o.jsx(Ve.span,{...g,asChild:w?!1:g.asChild,ref:b,style:{pointerEvents:"none"},children:o.jsx(m.Fragment,{children:w?p:f},w?"placeholder":"value")})},"SelectValue")),BO=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,children:c,...u}=a;return o.jsx(Ve.span,{"aria-hidden":!0,...u,ref:l,children:c||"▼"})},"SelectIcon")),HO="SelectPortal",[IO,PO]=Il(HO,{forceMount:void 0}),qO=ht(n=>{const{__scopeSelect:a,forceMount:l,...s}=n;return o.jsx(IO,{scope:n.__scopeSelect,forceMount:l,children:o.jsx(Zm,{asChild:!0,...s})})},"SelectPortal"),zl="SelectContent",$w=m.forwardRef(ht(function(a,l){const s=PO(zl,a.__scopeSelect),{forceMount:c=s.forceMount,...u}=a,f=ul(zl,a.__scopeSelect),[p,g]=m.useState();return Xt(()=>{g(new DocumentFragment)},[]),o.jsx(Cr,{present:c||f.open,children:({present:v})=>v?o.jsx(YO,{...u,ref:l}):o.jsx(VO,{...u,fragment:p})})},"SelectContent")),VO=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,children:c,fragment:u}=a;return u?ba.createPortal(o.jsx(Yw,{scope:s,children:o.jsx(Gu.Slot,{scope:s,children:o.jsx("div",{ref:l,children:c})})}),u):null},"SelectContentFragment")),ya=10,[Yw,Ku]=Il(zl),$O=Ha("SelectContent.RemoveScroll"),YO=m.forwardRef(ht(function(a,l){const{__scopeSelect:s}=a,{position:c="item-aligned",onCloseAutoFocus:u,onEscapeKeyDown:f,onPointerDownOutside:p,side:g,sideOffset:v,align:x,alignOffset:y,arrowPadding:b,collisionBoundary:w,collisionPadding:E,sticky:j,hideWhenDetached:C,avoidCollisions:N,...M}=a,T=ul(zl,s),[D,O]=m.useState(null),[A,U]=m.useState(null),k=Xe(l,O),[$,X]=m.useState(null),[te,G]=m.useState(null),ie=hp(s),[ce,se]=m.useState(!1),_=m.useRef(!1);m.useEffect(()=>{if(D)return ep(D)},[D]),fi();const H=m.useCallback(oe=>{const[de,...fe]=ie().map(De=>De.ref.current),[Te]=fe.slice(-1),je=document.activeElement;for(const De of oe)if(De===je||(De==null||De.scrollIntoView({block:"nearest"}),De===de&&A&&(A.scrollTop=0),De===Te&&A&&(A.scrollTop=A.scrollHeight),De==null||De.focus(),document.activeElement!==je))return},[ie,A]),Q=m.useCallback(()=>H([$,D]),[H,$,D]);m.useEffect(()=>{ce&&Q()},[ce,Q]);const{onOpenChange:J,triggerPointerDownPosRef:ee}=T;m.useEffect(()=>{if(D){let oe={x:0,y:0};const de=ht(Te=>{var je,De;oe={x:Math.abs(Math.round(Te.pageX)-(((je=ee.current)==null?void 0:je.x)??0)),y:Math.abs(Math.round(Te.pageY)-(((De=ee.current)==null?void 0:De.y)??0))}},"handlePointerMove"),fe=ht(Te=>{oe.x<=10&&oe.y<=10?Te.preventDefault():Te.composedPath().includes(D)||J(!1),document.removeEventListener("pointermove",de),ee.current=null},"handlePointerUp");return ee.current!==null&&(document.addEventListener("pointermove",de),document.addEventListener("pointerup",fe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",de),document.removeEventListener("pointerup",fe,{capture:!0})}}},[D,J,ee]),m.useEffect(()=>{const oe=ht(()=>J(!1),"close");return window.addEventListener("blur",oe),window.addEventListener("resize",oe),()=>{window.removeEventListener("blur",oe),window.removeEventListener("resize",oe)}},[J]);const[z,I]=pp(oe=>{const de=ie().filter(je=>!je.disabled),fe=de.find(je=>je.ref.current===document.activeElement),Te=gp(de,oe,fe);Te&&setTimeout(()=>{var je;return(je=Te.ref.current)==null?void 0:je.focus()})}),F=m.useCallback((oe,de,fe)=>{const Te=!_.current&&!fe;(T.value!==void 0&&T.value===de||Te)&&(X(oe),Te&&(_.current=!0))},[T.value]),re=m.useCallback(()=>D==null?void 0:D.focus(),[D]),he=m.useCallback((oe,de,fe)=>{const Te=!_.current&&!fe;(T.value!==void 0&&T.value===de||Te)&&G(oe)},[T.value]),ge=c==="popper"?Rb:GO,q=ge===Rb?{side:g,sideOffset:v,align:x,alignOffset:y,arrowPadding:b,collisionBoundary:w,collisionPadding:E,sticky:j,hideWhenDetached:C,avoidCollisions:N}:{};return o.jsx(Yw,{scope:s,content:D,viewport:A,onViewportChange:U,itemRefCallback:F,selectedItem:$,onItemLeave:re,itemTextRefCallback:he,focusSelectedItem:Q,selectedItemText:te,position:c,isPositioned:ce,searchRef:z,children:o.jsx(Bu,{as:$O,allowPinchZoom:!0,children:o.jsx(qm,{asChild:!0,trapped:T.open,onMountAutoFocus:oe=>{oe.preventDefault()},onUnmountAutoFocus:Ne(u,oe=>{var de;(de=T.trigger)==null||de.focus({preventScroll:!0}),oe.preventDefault()}),children:o.jsx(Nu,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:oe=>oe.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:o.jsx(ge,{role:"listbox",id:T.contentId,"data-state":T.open?"open":"closed",dir:T.dir,onContextMenu:oe=>oe.preventDefault(),...M,...q,onPlaced:()=>se(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...M.style},onKeyDown:Ne(M.onKeyDown,oe=>{const de=oe.ctrlKey||oe.altKey||oe.metaKey;if(oe.key==="Tab"&&oe.preventDefault(),!de&&oe.key.length===1&&I(oe.key),["ArrowUp","ArrowDown","Home","End"].includes(oe.key)){let Te=ie().filter(je=>!je.disabled).map(je=>je.ref.current);if(["ArrowUp","End"].includes(oe.key)&&(Te=Te.slice().reverse()),["ArrowUp","ArrowDown"].includes(oe.key)){const je=oe.target,De=Te.indexOf(je);Te=Te.slice(De+1)}setTimeout(()=>H(Te)),oe.preventDefault()}})})})})})})},"SelectContentImpl")),GO=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,onPlaced:c,...u}=a,f=ul(zl,s),p=Ku(zl,s),[g,v]=m.useState(null),[x,y]=m.useState(null),b=Xe(l,y),w=hp(s),E=m.useRef(!1),j=m.useRef(!0),{viewport:C,selectedItem:N,selectedItemText:M,focusSelectedItem:T}=p,D=m.useCallback(()=>{if(f.trigger&&f.valueNode&&g&&x&&C&&N&&M){const k=f.trigger.getBoundingClientRect(),$=x.getBoundingClientRect(),X=f.valueNode.getBoundingClientRect(),te=M.getBoundingClientRect();if(f.dir!=="rtl"){const je=te.left-$.left,De=X.left-je,Fe=k.left-De,et=k.width+Fe,le=Math.max(et,$.width),Le=window.innerWidth-ya,Ie=im(De,[ya,Math.max(ya,Le-le)]);g.style.minWidth=et+"px",g.style.left=Ie+"px"}else{const je=$.right-te.right,De=window.innerWidth-X.right-je,Fe=window.innerWidth-k.right-De,et=k.width+Fe,le=Math.max(et,$.width),Le=window.innerWidth-ya,Ie=im(De,[ya,Math.max(ya,Le-le)]);g.style.minWidth=et+"px",g.style.right=Ie+"px"}const G=w(),ie=window.innerHeight-ya*2,ce=C.scrollHeight,se=window.getComputedStyle(x),_=parseInt(se.borderTopWidth,10),H=parseInt(se.paddingTop,10),Q=parseInt(se.borderBottomWidth,10),J=parseInt(se.paddingBottom,10),ee=_+H+ce+J+Q,z=Math.min(N.offsetHeight*5,ee),I=window.getComputedStyle(C),F=parseInt(I.paddingTop,10),re=parseInt(I.paddingBottom,10),he=k.top+k.height/2-ya,ge=ie-he,q=N.offsetHeight/2,oe=N.offsetTop+q,de=_+H+oe,fe=ee-de;if(de<=he){const je=G.length>0&&N===G[G.length-1].ref.current;g.style.bottom="0px";const De=x.clientHeight-C.offsetTop-C.offsetHeight,Fe=Math.max(ge,q+(je?re:0)+De+Q),et=de+Fe;g.style.height=et+"px"}else{const je=G.length>0&&N===G[0].ref.current;g.style.top="0px";const Fe=Math.max(he,_+C.offsetTop+(je?F:0)+q)+fe;g.style.height=Fe+"px",C.scrollTop=de-he+C.offsetTop}g.style.margin=`${ya}px 0`,g.style.minHeight=z+"px",g.style.maxHeight=ie+"px",c==null||c(),requestAnimationFrame(()=>E.current=!0)}},[w,f.trigger,f.valueNode,g,x,C,N,M,f.dir,c]);Xt(()=>D(),[D]);const[O,A]=m.useState();Xt(()=>{x&&A(window.getComputedStyle(x).zIndex)},[x]);const U=m.useCallback(k=>{k&&j.current===!0&&(D(),T==null||T(),j.current=!1)},[D,T]);return o.jsx(KO,{scope:s,contentWrapper:g,shouldExpandOnScrollRef:E,onScrollButtonChange:U,children:o.jsx("div",{ref:v,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:O},children:o.jsx(Ve.div,{...u,ref:b,style:{boxSizing:"border-box",maxHeight:"100%",...u.style}})})})},"SelectItemAlignedPosition")),Rb=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,align:c="start",collisionPadding:u=ya,...f}=a,p=mp(s);return o.jsx(Qm,{...p,...f,ref:l,align:c,collisionPadding:u,style:{boxSizing:"border-box",...f.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[KO,XO]=Il(zl,{}),Nb="SelectViewport",FO=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,nonce:c,...u}=a,f=Ku(Nb,s),p=XO(Nb,s),g=Xe(l,f.onViewportChange),v=m.useRef(0);return o.jsxs(o.Fragment,{children:[o.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:c}),o.jsx(Gu.Slot,{scope:s,children:o.jsx(Ve.div,{"data-radix-select-viewport":"",role:"presentation",...u,ref:g,style:{position:"relative",flex:1,overflow:"hidden auto",...u.style},onScroll:Ne(u.onScroll,x=>{const y=x.currentTarget,{contentWrapper:b,shouldExpandOnScrollRef:w}=p;if(w!=null&&w.current&&b){const E=Math.abs(v.current-y.scrollTop);if(E>0){const j=window.innerHeight-ya*2,C=parseFloat(b.style.minHeight),N=parseFloat(b.style.height),M=Math.max(C,N);if(M<j){const T=M+E,D=Math.min(j,T),O=T-D;b.style.height=D+"px",b.style.bottom==="0px"&&(y.scrollTop=O>0?O:0,b.style.justifyContent="flex-end")}}}v.current=y.scrollTop})})})]})},"SelectViewport")),QO="SelectGroup",[K4,X4]=Il(QO),cm="SelectItem",[ZO,Gw]=Il(cm),Kw=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,value:c,disabled:u=!1,textValue:f,...p}=a,g=ul(cm,s),v=Ku(cm,s),x=g.value===c,[y,b]=m.useState(f??""),[w,E]=m.useState(!1),j=ia(D=>{var O;return(O=v.itemRefCallback)==null?void 0:O.call(v,D,c,u)}),C=Xe(l,j),N=La(),M=m.useRef("touch"),T=ht(()=>{u||(g.onValueChange(c),g.onOpenChange(!1))},"handleSelect");return o.jsx(ZO,{scope:s,value:c,disabled:u,textId:N,isSelected:x,onItemTextChange:m.useCallback(D=>{b(O=>O||((D==null?void 0:D.textContent)??"").trim())},[]),children:o.jsx(Gu.ItemSlot,{scope:s,value:c,disabled:u,textValue:y,children:o.jsx(Ve.div,{role:"option","aria-labelledby":N,"data-highlighted":w?"":void 0,"aria-selected":x&&w,"data-state":x?"checked":"unchecked","aria-disabled":u||void 0,"data-disabled":u?"":void 0,tabIndex:u?void 0:-1,...p,ref:C,onFocus:Ne(p.onFocus,()=>E(!0)),onBlur:Ne(p.onBlur,()=>E(!1)),onClick:Ne(p.onClick,()=>{M.current!=="mouse"&&T()}),onPointerUp:Ne(p.onPointerUp,()=>{M.current==="mouse"&&T()}),onPointerDown:Ne(p.onPointerDown,D=>{M.current=D.pointerType}),onPointerMove:Ne(p.onPointerMove,D=>{var O;M.current=D.pointerType,u?(O=v.onItemLeave)==null||O.call(v):M.current==="mouse"&&D.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ne(p.onPointerLeave,D=>{var O;D.currentTarget===document.activeElement&&((O=v.onItemLeave)==null||O.call(v))}),onKeyDown:Ne(p.onKeyDown,D=>{var A;u||D.target!==D.currentTarget||((A=v.searchRef)==null?void 0:A.current)!==""&&D.key===" "||(MO.includes(D.key)&&T(),D.key===" "&&D.preventDefault())})})})})},"SelectItem")),Ic="SelectItemText",JO=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,className:c,style:u,...f}=a,p=ul(Ic,s),g=Ku(Ic,s),v=Gw(Ic,s),x=_O(Ic,s),[y,b]=m.useState(null),w=ia(T=>{var D;return(D=g.itemTextRefCallback)==null?void 0:D.call(g,T,v.value,v.disabled)}),E=Xe(l,b,v.onItemTextChange,w),j=y==null?void 0:y.textContent,C=m.useMemo(()=>o.jsx("option",{value:v.value,disabled:v.disabled,children:j},v.value),[v.disabled,v.value,j]),{onNativeOptionAdd:N,onNativeOptionRemove:M}=x;return Xt(()=>(N(C),()=>M(C)),[N,M,C]),o.jsxs(o.Fragment,{children:[o.jsx(Ve.span,{id:v.textId,...f,ref:E}),v.isSelected&&p.valueNode&&!p.valueNodeHasChildren&&!pi(p.value)?ba.createPortal(f.children,p.valueNode):null]})},"SelectItemText")),WO="SelectItemIndicator",e_=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,...c}=a;return Gw(WO,s).isSelected?o.jsx(Ve.span,{"aria-hidden":!0,...c,ref:l}):null},"SelectItemIndicator")),t_="SelectBubbleInput",n_=m.forwardRef(ht(function({__scopeSelect:a,...l},s){const c=ul(t_,a),{value:u,onValueChange:f,required:p,disabled:g,name:v,autoComplete:x,form:y}=c,{nativeOptions:b,nativeSelectKey:w}=c,E=m.useRef(null),j=Xe(s,E),C=u??"",N=Iw(C),M=Array.from(b).some(T=>(T.props.value??"")==="");return m.useEffect(()=>{const T=E.current;if(!T)return;const D=window.HTMLSelectElement.prototype,A=Object.getOwnPropertyDescriptor(D,"value").set;if(N!==C&&A){const U=new Event("change",{bubbles:!0});A.call(T,C),T.dispatchEvent(U)}},[N,C]),o.jsxs(Ve.select,{"aria-hidden":!0,required:p,tabIndex:-1,name:v,autoComplete:x,disabled:g,form:y,onChange:T=>f(T.target.value),...l,style:{...Pw,...l.style},ref:j,defaultValue:C,children:[pi(u)&&!M?o.jsx("option",{value:""}):null,Array.from(b)]},w)},"SelectBubbleInput"));function Xw(n){return typeof n=="function"}ht(Xw,"isFunction");function pi(n){return n===""||n===void 0}ht(pi,"shouldShowPlaceholder");function pp(n){const a=ia(n),l=m.useRef(""),s=m.useRef(0),c=m.useCallback(f=>{const p=l.current+f;a(p),ht((function g(v){l.current=v,window.clearTimeout(s.current),v!==""&&(s.current=window.setTimeout(()=>g(""),1e3))}),"updateSearch")(p)},[a]),u=m.useCallback(()=>{l.current="",window.clearTimeout(s.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(s.current),[]),[l,c,u]}ht(pp,"useTypeaheadSearch");function gp(n,a,l){const c=a.length>1&&Array.from(a).every(v=>v===a[0])?a[0]:a,u=l?n.indexOf(l):-1;let f=Fw(n,Math.max(u,0));c.length===1&&(f=f.filter(v=>v!==l));const g=f.find(v=>v.textValue.toLowerCase().startsWith(c.toLowerCase()));return g!==l?g:void 0}ht(gp,"findNextItem");function Fw(n,a){return n.map((l,s)=>n[(a+s)%n.length])}ht(Fw,"wrapArray");const Ua=kO,Ba=UO,Sa=m.forwardRef(({className:n,children:a,...l},s)=>o.jsxs(Vw,{ref:s,className:Ee("flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",n),...l,children:[a,o.jsx(BO,{asChild:!0,children:o.jsx(JE,{className:"h-4 w-4 opacity-50"})})]}));Sa.displayName=Vw.displayName;const ja=m.forwardRef(({className:n,children:a,position:l="popper",...s},c)=>o.jsx(qO,{children:o.jsx($w,{ref:c,className:Ee("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",n),position:l,...s,children:o.jsx(FO,{className:Ee("p-1",l==="popper"&&"w-full min-w-[var(--radix-select-trigger-width)]"),children:a})})}));ja.displayName=$w.displayName;const Rt=m.forwardRef(({className:n,children:a,...l},s)=>o.jsxs(Kw,{ref:s,className:Ee("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),...l,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(e_,{children:o.jsx(C0,{className:"h-4 w-4"})})}),o.jsx(JO,{children:a})]}));Rt.displayName=Kw.displayName;var a_=Object.defineProperty,il=(n,a)=>a_(n,"name",{value:a,configurable:!0}),vp="Switch",[r_,F4]=kn(vp),[l_,xp]=r_(vp);function Qw(n){const{__scopeSwitch:a,checked:l,children:s,defaultChecked:c,disabled:u,form:f,name:p,onCheckedChange:g,required:v,value:x="on",internal_do_not_use_render:y}=n,[b,w]=yr({prop:l,defaultProp:c??!1,onChange:g,caller:vp}),[E,j]=m.useState(null),[C,N]=m.useState(null),M=m.useRef(!1),[T,D]=m.useReducer(U=>U+1,0),O=E?!!f||!!E.closest("form"):!0,A={checked:b,setChecked:w,disabled:u,control:E,setControl:j,name:p,form:f,value:x,hasConsumerStoppedPropagationRef:M,userInteractionCount:T,onUserInteraction:D,required:v,defaultChecked:c,isFormControl:O,bubbleInput:C,setBubbleInput:N};return o.jsx(l_,{scope:a,...A,children:Jw(y)?y(A):s})}il(Qw,"SwitchProvider");var s_="SwitchTrigger",o_=m.forwardRef(il(function({__scopeSwitch:a,onClick:l,...s},c){const{control:u,form:f,value:p,disabled:g,checked:v,required:x,setControl:y,setChecked:b,hasConsumerStoppedPropagationRef:w,onUserInteraction:E,isFormControl:j,bubbleInput:C}=xp(s_,a),N=Xe(c,y),M=m.useRef(v);return m.useEffect(()=>{const T=f?u==null?void 0:u.ownerDocument.getElementById(f):u==null?void 0:u.form;if(T instanceof HTMLFormElement){const D=il(()=>b(M.current),"reset");return T.addEventListener("reset",D),()=>T.removeEventListener("reset",D)}},[u,f,b]),o.jsx(Ve.button,{type:"button",role:"switch","aria-checked":v,"aria-required":x,"data-state":yp(v),"data-disabled":g?"":void 0,disabled:g,value:p,...s,ref:N,onClick:Ne(l,T=>{E(),b(D=>!D),C&&j&&(w.current=T.isPropagationStopped(),w.current||T.stopPropagation())})})},"SwitchTrigger")),Zw=m.forwardRef(il(function(a,l){const{__scopeSwitch:s,name:c,checked:u,defaultChecked:f,required:p,disabled:g,value:v,onCheckedChange:x,form:y,...b}=a;return o.jsx(Qw,{__scopeSwitch:s,checked:u,defaultChecked:f,disabled:g,required:p,onCheckedChange:x,name:c,form:y,value:v,internal_do_not_use_render:({isFormControl:w})=>o.jsxs(o.Fragment,{children:[o.jsx(o_,{...b,ref:l,__scopeSwitch:s}),w&&o.jsx(d_,{__scopeSwitch:s})]})})},"Switch")),i_="SwitchThumb",c_=m.forwardRef(il(function(a,l){const{__scopeSwitch:s,...c}=a,u=xp(i_,s);return o.jsx(Ve.span,{"data-state":yp(u.checked),"data-disabled":u.disabled?"":void 0,...c,ref:l})},"SwitchThumb")),u_="SwitchBubbleInput",d_=m.forwardRef(il(function({__scopeSwitch:a,onClick:l,...s},c){const{control:u,hasConsumerStoppedPropagationRef:f,userInteractionCount:p,checked:g,defaultChecked:v,required:x,disabled:y,name:b,value:w,form:E,bubbleInput:j,setBubbleInput:C}=xp(u_,a),N=Xe(c,C),M=_u(u),T=m.useRef(!1),D=m.useRef(g),O=m.useRef(p);m.useEffect(()=>{const U=j;if(!U)return;const k=window.HTMLInputElement.prototype,X=Object.getOwnPropertyDescriptor(k,"checked").set,te=p!==O.current;O.current=p;const G=D.current!==g;D.current=g;const ie=!(te&&f.current);if(G&&X){T.current=!te;const ce=new Event("click",{bubbles:ie});X.call(U,g),U.dispatchEvent(ce),T.current=!1}},[j,g,f,p]);const A=m.useRef(g);return o.jsx(Ve.input,{type:"checkbox","aria-hidden":!0,defaultChecked:v??A.current,required:x,disabled:y,name:b,value:w,form:E,...s,tabIndex:-1,ref:N,onClick:Ne(l,U=>{T.current&&U.stopPropagation()}),style:{...s.style,...M,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function Jw(n){return typeof n=="function"}il(Jw,"isFunction");function yp(n){return n?"checked":"unchecked"}il(yp,"getState");const Ca=m.forwardRef(({className:n,...a},l)=>o.jsx(Zw,{className:Ee("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",n),...a,ref:l,children:o.jsx(c_,{className:Ee("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Ca.displayName=Zw.displayName;const Al={name:"",slug:"",type:"openai",baseUrl:"https://api.openai.com",apiKey:"",customHeaders:"",enabled:!0},f_={openai:"https://api.openai.com",anthropic:"https://api.anthropic.com"};function h_(){const[n,a]=m.useState([]),[l,s]=m.useState(!1),[c,u]=m.useState(Al),[f,p]=m.useState(!1),[g,v]=m.useState(null),[x,y]=m.useState(null),[b,w]=m.useState(Al),[E,j]=m.useState(null),[C,N]=m.useState(!1),M=async()=>{try{const k=await Se.get("/api/admin/providers");a(k.providers)}catch(k){ve.error(k.message||"Unable to load providers")}};m.useEffect(()=>{M()},[]);const T=async()=>{p(!0);try{let k;if(c.customHeaders.trim())try{k=JSON.parse(c.customHeaders)}catch{throw new Error("Custom headers must be valid JSON object")}await Se.post("/api/admin/providers",{name:c.name,slug:c.slug||void 0,type:c.type,baseUrl:c.baseUrl,apiKey:c.apiKey,customHeaders:k,enabled:c.enabled}),ve.success("Provider created"),s(!1),u(Al),M()}catch(k){ve.error(k.message)}finally{p(!1)}},D=async k=>{v(k);try{const $=await Se.post(`/api/admin/providers/${k}/test`);ve.success($.ok?`Connection OK: ${$.detail}`:`Failed: ${$.detail}`),M()}catch($){ve.error($.message)}finally{v(null)}},O=k=>{y(k.id),w({...Al,name:k.name,slug:k.slug||"",type:k.type,baseUrl:k.baseUrl,apiKey:"",customHeaders:"",enabled:k.enabled})},A=async()=>{if(x){p(!0);try{let k;if(b.customHeaders.trim())try{k=JSON.parse(b.customHeaders)}catch{throw new Error("Custom headers must be valid JSON object")}await Se.patch("/api/admin/providers",{id:x,name:b.name,slug:b.slug||void 0,type:b.type,baseUrl:b.baseUrl,apiKey:b.apiKey||void 0,customHeaders:k,enabled:b.enabled}),ve.success("Provider updated"),y(null),w(Al),M()}catch(k){ve.error(k.message)}finally{p(!1)}}},U=async k=>{N(!0);try{await Se.del(`/api/admin/providers/${k}`),ve.success("Provider removed"),M()}catch($){ve.error($.message)}finally{N(!1),j(null)}};return o.jsxs("div",{children:[o.jsx($a,{title:"Providers",description:"Upstream LLM providers and their credentials",actions:o.jsx("div",{className:"flex gap-2",children:o.jsxs(Mn,{open:l,onOpenChange:s,children:[o.jsx(mi,{asChild:!0,children:o.jsx(me,{children:"Add compatible provider"})}),o.jsxs(vn,{children:[o.jsxs(xn,{children:[o.jsx(yn,{children:"New provider"}),o.jsx(uu,{children:"API-key or compatible endpoint."})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx(we,{htmlFor:"provider-name",children:"Name"}),o.jsx(Ae,{id:"provider-name",value:c.name,onChange:k=>u({...c,name:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{htmlFor:"provider-slug",children:"Slug (optional)"}),o.jsx(Ae,{id:"provider-slug",value:c.slug,onChange:k=>u({...c,slug:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{children:"Type"}),o.jsxs(Ua,{value:c.type,onValueChange:k=>u($=>({...$,type:k,baseUrl:f_[k]})),children:[o.jsx(Sa,{children:o.jsx(Ba,{})}),o.jsxs(ja,{children:[o.jsx(Rt,{value:"openai",children:"OpenAI-compatible"}),o.jsx(Rt,{value:"anthropic",children:"Anthropic-compatible"})]})]})]}),o.jsxs("div",{children:[o.jsx(we,{htmlFor:"provider-base-url",children:"Base URL"}),o.jsx(Ae,{id:"provider-base-url",value:c.baseUrl,onChange:k=>u({...c,baseUrl:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{htmlFor:"provider-api-key",children:"API key"}),o.jsx(Ae,{id:"provider-api-key",type:"password",value:c.apiKey,onChange:k=>u({...c,apiKey:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{htmlFor:"provider-headers",children:"Custom headers (JSON)"}),o.jsx(Ae,{id:"provider-headers",value:c.customHeaders,onChange:k=>u({...c,customHeaders:k.target.value}),placeholder:'{"X-Org":"acme"}'})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ca,{checked:c.enabled,onCheckedChange:k=>u({...c,enabled:k})}),o.jsx(we,{children:"Enabled"})]})]}),o.jsxs(An,{children:[o.jsx(me,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),o.jsx(me,{disabled:f||!c.name||!c.apiKey,onClick:T,children:f?"Creating…":"Create"})]})]})]})})}),o.jsxs(nt,{children:[o.jsxs(at,{children:[o.jsx(rt,{className:"text-base",children:"All providers"}),o.jsxs(gn,{children:[n.length," total"]})]}),o.jsx(lt,{children:o.jsxs(ca,{children:[o.jsx(ua,{children:o.jsxs(We,{children:[o.jsx(ye,{children:"Name"}),o.jsx(ye,{children:"Type"}),o.jsx(ye,{children:"Base URL"}),o.jsx(ye,{children:"Models"}),o.jsx(ye,{children:"Health"}),o.jsx(ye,{children:"Enabled"}),o.jsx(ye,{className:"text-right",children:"Actions"})]})}),o.jsxs(da,{children:[n.length===0&&o.jsx(We,{children:o.jsx(pe,{colSpan:7,className:"text-center text-muted-foreground",children:"No providers yet."})}),n.map(k=>o.jsxs(We,{children:[o.jsxs(pe,{className:"font-medium",children:[k.name," ",o.jsx("span",{className:"text-xs text-muted-foreground",children:k.slug})]}),o.jsx(pe,{children:o.jsx(Qe,{variant:"outline",children:k.type})}),o.jsx(pe,{className:"text-xs text-muted-foreground",children:k.baseUrl}),o.jsx(pe,{children:k.modelCount}),o.jsx(pe,{children:o.jsx(Qe,{variant:k.health==="healthy"?"success":k.health==="down"?"destructive":"secondary",children:k.health})}),o.jsx(pe,{children:k.enabled?"Yes":"No"}),o.jsx(pe,{className:"text-right",children:o.jsxs("div",{className:"flex justify-end gap-1",children:[o.jsx(me,{size:"sm",variant:"outline",disabled:g===k.id,onClick:()=>D(k.id),children:o.jsx(A0,{className:"h-3 w-3"})}),o.jsx(me,{size:"sm",variant:"outline",onClick:()=>O(k),children:"✎"}),o.jsx(me,{size:"sm",variant:"outline",onClick:()=>j(k.id),children:o.jsx(ju,{className:"h-3 w-3"})})]})})]},k.id))]})]})})]}),o.jsx(Mn,{open:!!x,onOpenChange:k=>{k||(y(null),w(Al))},children:o.jsxs(vn,{children:[o.jsx(xn,{children:o.jsx(yn,{children:"Edit provider"})}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx(we,{children:"Name"}),o.jsx(Ae,{value:b.name,onChange:k=>w({...b,name:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{children:"Slug (optional)"}),o.jsx(Ae,{value:b.slug,onChange:k=>w({...b,slug:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{children:"Type"}),o.jsxs(Ua,{value:b.type,onValueChange:k=>w({...b,type:k}),children:[o.jsx(Sa,{children:o.jsx(Ba,{})}),o.jsxs(ja,{children:[o.jsx(Rt,{value:"openai",children:"OpenAI-compatible"}),o.jsx(Rt,{value:"anthropic",children:"Anthropic-compatible"})]})]})]}),o.jsxs("div",{children:[o.jsx(we,{children:"Base URL"}),o.jsx(Ae,{value:b.baseUrl,onChange:k=>w({...b,baseUrl:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{children:"API key (leave empty to keep current)"}),o.jsx(Ae,{type:"password",value:b.apiKey,onChange:k=>w({...b,apiKey:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{children:"Custom headers (JSON)"}),o.jsx(Ae,{value:b.customHeaders,onChange:k=>w({...b,customHeaders:k.target.value}),placeholder:'{"X-Org":"acme"}'})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ca,{checked:b.enabled,onCheckedChange:k=>w({...b,enabled:k})}),o.jsx(we,{children:"Enabled"})]})]}),o.jsxs(An,{children:[o.jsx(me,{variant:"outline",onClick:()=>{y(null),w(Al)},children:"Cancel"}),o.jsx(me,{disabled:f||!b.name,onClick:A,children:"Save changes"})]})]})}),o.jsx(up,{open:!!E,onOpenChange:k=>{k||j(null)},children:o.jsxs(Pu,{children:[o.jsxs(dp,{children:[o.jsx(qu,{children:"Delete provider?"}),o.jsx(Vu,{children:"This will soft-disable the provider if models depend on it."})]}),o.jsxs(fp,{children:[o.jsx(Yu,{children:"Cancel"}),o.jsx($u,{disabled:C,onClick:k=>{E&&(k.preventDefault(),U(E))},children:C?"Deleting…":"Delete"})]})]})})]})}var m_=Object.defineProperty,Sr=(n,a)=>m_(n,"name",{value:a,configurable:!0}),bp="Checkbox",[p_,Q4]=kn(bp),[g_,wp]=p_(bp);function Ww(n){const{__scopeCheckbox:a,checked:l,children:s,defaultChecked:c,disabled:u,form:f,name:p,onCheckedChange:g,required:v,value:x="on",internal_do_not_use_render:y}=n,[b,w]=yr({prop:l,defaultProp:c??!1,onChange:g,caller:bp}),[E,j]=m.useState(null),[C,N]=m.useState(null),M=m.useRef(!1),[T,D]=m.useReducer(U=>U+1,0),O=E?!!f||!!E.closest("form"):!0,A={checked:b,disabled:u,setChecked:w,control:E,setControl:j,name:p,form:f,value:x,hasConsumerStoppedPropagationRef:M,userInteractionCount:T,onUserInteraction:D,required:v,defaultChecked:vr(c)?!1:c,isFormControl:O,bubbleInput:C,setBubbleInput:N};return o.jsx(g_,{scope:a,...A,children:tS(y)?y(A):s})}Sr(Ww,"CheckboxProvider");var v_="CheckboxTrigger",x_=m.forwardRef(Sr(function({__scopeCheckbox:a,onKeyDown:l,onClick:s,...c},u){const{control:f,value:p,disabled:g,checked:v,required:x,setControl:y,setChecked:b,hasConsumerStoppedPropagationRef:w,onUserInteraction:E,isFormControl:j,bubbleInput:C}=wp(v_,a),N=Xe(u,y),M=m.useRef(v);return m.useEffect(()=>{const T=f==null?void 0:f.form;if(T){const D=Sr(()=>b(M.current),"reset");return T.addEventListener("reset",D),()=>T.removeEventListener("reset",D)}},[f,b]),o.jsx(Ve.button,{type:"button",role:"checkbox","aria-checked":vr(v)?"mixed":v,"aria-required":x,"data-state":Sp(v),"data-disabled":g?"":void 0,disabled:g,value:p,...c,ref:N,onKeyDown:Ne(l,T=>{T.key==="Enter"&&T.preventDefault()}),onClick:Ne(s,T=>{E(),b(D=>vr(D)?!0:!D),C&&j&&(w.current=T.isPropagationStopped(),w.current||T.stopPropagation())})})},"CheckboxTrigger")),eS=m.forwardRef(Sr(function(a,l){const{__scopeCheckbox:s,name:c,checked:u,defaultChecked:f,required:p,disabled:g,value:v,onCheckedChange:x,form:y,...b}=a;return o.jsx(Ww,{__scopeCheckbox:s,checked:u,defaultChecked:f,disabled:g,required:p,onCheckedChange:x,name:c,form:y,value:v,internal_do_not_use_render:({isFormControl:w})=>o.jsxs(o.Fragment,{children:[o.jsx(x_,{...b,ref:l,__scopeCheckbox:s}),w&&o.jsx(S_,{__scopeCheckbox:s})]})})},"Checkbox")),y_="CheckboxIndicator",b_=m.forwardRef(Sr(function(a,l){const{__scopeCheckbox:s,forceMount:c,...u}=a,f=wp(y_,s);return o.jsx(Cr,{present:c||vr(f.checked)||f.checked===!0,children:o.jsx(Ve.span,{"data-state":Sp(f.checked),"data-disabled":f.disabled?"":void 0,...u,ref:l,style:{pointerEvents:"none",...a.style}})})},"CheckboxIndicator")),w_="CheckboxBubbleInput",S_=m.forwardRef(Sr(function({__scopeCheckbox:a,onClick:l,...s},c){const{control:u,hasConsumerStoppedPropagationRef:f,userInteractionCount:p,checked:g,defaultChecked:v,required:x,disabled:y,name:b,value:w,form:E,bubbleInput:j,setBubbleInput:C}=wp(w_,a),N=Xe(c,C),M=_u(u),T=m.useRef(!1),D=m.useRef(g),O=m.useRef(p);m.useEffect(()=>{const U=j;if(!U)return;const k=window.HTMLInputElement.prototype,X=Object.getOwnPropertyDescriptor(k,"checked").set,te=p!==O.current;O.current=p;const G=D.current!==g;D.current=g;const ie=!(te&&f.current);if(G&&X){T.current=!te;const ce=new Event("click",{bubbles:ie});U.indeterminate=vr(g),X.call(U,vr(g)?!1:g),U.dispatchEvent(ce),T.current=!1}},[j,g,f,p]);const A=m.useRef(vr(g)?!1:g);return o.jsx(Ve.input,{type:"checkbox","aria-hidden":!0,defaultChecked:v??A.current,required:x,disabled:y,name:b,value:w,form:E,...s,tabIndex:-1,ref:N,onClick:Ne(l,U=>{T.current&&U.stopPropagation()}),style:{...s.style,...M,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function tS(n){return typeof n=="function"}Sr(tS,"isFunction");function vr(n){return n==="indeterminate"}Sr(vr,"isIndeterminate");function Sp(n){return vr(n)?"indeterminate":n?"checked":"unchecked"}Sr(Sp,"getState");const jp=m.forwardRef(({className:n,...a},l)=>o.jsx(eS,{ref:l,className:Ee("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",n),...a,children:o.jsx(b_,{className:Ee("flex items-center justify-center text-current"),children:o.jsx(C0,{className:"h-3.5 w-3.5"})})}));jp.displayName=eS.displayName;const um=["image_input","audio_input","tools","structured_output","reasoning","chat","streaming"],j_=["unknown","yes","no"];function C_(n,a){return n[a]===!0?"yes":n[a]===!1?"no":"unknown"}function E_(n){const a={};for(const l of um)a[l]=n[l]==="yes"?!0:n[l]==="no"?!1:null;return a}function R_(){const[n,a]=m.useState([]),[l,s]=m.useState([]),[c,u]=m.useState("all"),[f,p]=m.useState(!1),[g,v]=m.useState(""),[x,y]=m.useState([]),[b,w]=m.useState(new Set),[E,j]=m.useState(!1),[C,N]=m.useState(""),[M,T]=m.useState(""),[D,O]=m.useState(null),[A,U]=m.useState(!1),[k,$]=m.useState(null),[X,te]=m.useState(null),[G,ie]=m.useState(null),[ce,se]=m.useState({}),[_,H]=m.useState(!1),Q=q=>{const oe={};for(const de of um)oe[de]=C_(q.capabilities,de);se(oe),ie(q)},J=async()=>{if(G){H(!0);try{await Se.patch("/api/admin/models",{id:G.id,capabilities:E_(ce)}),ve.success("Capabilities updated"),ie(null),ee()}catch(q){ve.error(q.message)}finally{H(!1)}}},ee=async()=>{const[q,oe]=await Promise.all([Se.get("/api/admin/models"),Se.get("/api/admin/providers")]);a(q.models),s(oe.providers)};m.useEffect(()=>{ee()},[]);const z=n.filter(q=>!(c!=="all"&&q.providerId!==c||C&&!q.publicModelId.toLowerCase().includes(C.toLowerCase()))),I=x.filter(q=>{if(!M)return!0;const oe=M.toLowerCase();return q.upstreamId.toLowerCase().includes(oe)||q.displayName.toLowerCase().includes(oe)}),F=async()=>{if(g){j(!0);try{const q=await Se.post(`/api/admin/providers/${g}/discover`);y(q.models),w(new Set)}catch(q){ve.error(q.message)}finally{j(!1)}}},re=async()=>{if(b.size!==0)try{const q=await Se.post("/api/admin/models/import",{providerId:g,modelIds:Array.from(b)});ve.success(`Imported ${q.imported} of ${q.requested}`),p(!1),y([]),w(new Set),ee()}catch(q){ve.error(q.message)}},he=async()=>{if(X)try{await Se.del(`/api/admin/models/${X.id}`),ve.success("Model deleted"),te(null),ee()}catch(q){ve.error(q.message)}},ge=async q=>{var de,fe,Te;O(q),U(!0);const oe=Date.now();$({phase:"streaming",startedAt:oe,text:"",progress:{}});try{const je=await ru(`/api/admin/models/${q}/test-stream`,{method:"POST",headers:{"content-type":"application/json"},body:"{}"});if(!je.ok){const Ie=await je.text().catch(()=>"");$({phase:"error",model:q,error:`HTTP ${je.status}: ${Ie}`});return}const De=(de=je.body)==null?void 0:de.getReader();if(!De){$({phase:"error",model:q,error:"No response body"});return}const Fe=new TextDecoder;let et="",le="",Le=!1;for(;!Le;){const{value:Ie,done:kt}=await De.read();Le=kt,Ie&&(et+=Fe.decode(Ie,{stream:!0}));let St;for(;(St=et.indexOf(`
|
|
341
|
+
`);function Hc(n){return n.label!==void 0}var ED=3,RD="32px",ND="16px",Cb=4e3,TD=356,MD=14,AD=20,DD=200;function xa(...n){return n.filter(Boolean).join(" ")}function OD(n){let[a,l]=n.split("-"),s=[];return a&&s.push(a),l&&s.push(l),s}var _D=n=>{var a,l,s,c,u,f,p,g,v,x,y;let{invert:b,toast:w,unstyled:E,interacting:j,setHeights:C,visibleToasts:N,heights:M,index:T,toasts:D,expanded:O,removeToast:A,defaultRichColors:U,closeButton:k,style:$,cancelButtonStyle:X,actionButtonStyle:te,className:G="",descriptionClassName:ie="",duration:ce,position:se,gap:_,loadingIcon:H,expandByDefault:Q,classNames:J,icons:ee,closeButtonAriaLabel:z="Close toast",pauseWhenPageIsHidden:I}=n,[F,re]=ue.useState(null),[he,ge]=ue.useState(null),[q,oe]=ue.useState(!1),[de,fe]=ue.useState(!1),[Te,je]=ue.useState(!1),[De,Fe]=ue.useState(!1),[et,le]=ue.useState(!1),[Le,Ie]=ue.useState(0),[kt,St]=ue.useState(0),Ft=ue.useRef(w.duration||ce||Cb),on=ue.useRef(null),Qt=ue.useRef(null),jt=T===0,fn=T+1<=N,Mt=w.type,At=w.dismissible!==!1,cn=w.className||"",fa=w.descriptionClassName||"",Ta=ue.useMemo(()=>M.findIndex(Ce=>Ce.toastId===w.id)||0,[M,w.id]),Gn=ue.useMemo(()=>{var Ce;return(Ce=w.closeButton)!=null?Ce:k},[w.closeButton,k]),dl=ue.useMemo(()=>w.duration||ce||Cb,[w.duration,ce]),ha=ue.useRef(0),Dt=ue.useRef(0),hn=ue.useRef(0),Tt=ue.useRef(null),[Js,Pl]=se.split("-"),ql=ue.useMemo(()=>M.reduce((Ce,ke,Ue)=>Ue>=Ta?Ce:Ce+ke.height,0),[M,Ta]),Ya=vD(),Nr=w.invert||b,vt=Mt==="loading";Dt.current=ue.useMemo(()=>Ta*_+ql,[Ta,ql]),ue.useEffect(()=>{Ft.current=dl},[dl]),ue.useEffect(()=>{oe(!0)},[]),ue.useEffect(()=>{let Ce=Qt.current;if(Ce){let ke=Ce.getBoundingClientRect().height;return St(ke),C(Ue=>[{toastId:w.id,height:ke,position:w.position},...Ue]),()=>C(Ue=>Ue.filter(gt=>gt.toastId!==w.id))}},[C,w.id]),ue.useLayoutEffect(()=>{if(!q)return;let Ce=Qt.current,ke=Ce.style.height;Ce.style.height="auto";let Ue=Ce.getBoundingClientRect().height;Ce.style.height=ke,St(Ue),C(gt=>gt.find(Ct=>Ct.toastId===w.id)?gt.map(Ct=>Ct.toastId===w.id?{...Ct,height:Ue}:Ct):[{toastId:w.id,height:Ue,position:w.position},...gt])},[q,w.title,w.description,C,w.id]);let st=ue.useCallback(()=>{fe(!0),Ie(Dt.current),C(Ce=>Ce.filter(ke=>ke.toastId!==w.id)),setTimeout(()=>{A(w)},DD)},[w,A,C,Dt]);ue.useEffect(()=>{if(w.promise&&Mt==="loading"||w.duration===1/0||w.type==="loading")return;let Ce;return O||j||I&&Ya?(()=>{if(hn.current<ha.current){let ke=new Date().getTime()-ha.current;Ft.current=Ft.current-ke}hn.current=new Date().getTime()})():Ft.current!==1/0&&(ha.current=new Date().getTime(),Ce=setTimeout(()=>{var ke;(ke=w.onAutoClose)==null||ke.call(w,w),st()},Ft.current)),()=>clearTimeout(Ce)},[O,j,w,Mt,I,Ya,st]),ue.useEffect(()=>{w.delete&&st()},[st,w.delete]);function Bt(){var Ce,ke,Ue;return ee!=null&&ee.loading?ue.createElement("div",{className:xa(J==null?void 0:J.loader,(Ce=w==null?void 0:w.classNames)==null?void 0:Ce.loader,"sonner-loader"),"data-visible":Mt==="loading"},ee.loading):H?ue.createElement("div",{className:xa(J==null?void 0:J.loader,(ke=w==null?void 0:w.classNames)==null?void 0:ke.loader,"sonner-loader"),"data-visible":Mt==="loading"},H):ue.createElement(dD,{className:xa(J==null?void 0:J.loader,(Ue=w==null?void 0:w.classNames)==null?void 0:Ue.loader),visible:Mt==="loading"})}return ue.createElement("li",{tabIndex:0,ref:Qt,className:xa(G,cn,J==null?void 0:J.toast,(a=w==null?void 0:w.classNames)==null?void 0:a.toast,J==null?void 0:J.default,J==null?void 0:J[Mt],(l=w==null?void 0:w.classNames)==null?void 0:l[Mt]),"data-sonner-toast":"","data-rich-colors":(s=w.richColors)!=null?s:U,"data-styled":!(w.jsx||w.unstyled||E),"data-mounted":q,"data-promise":!!w.promise,"data-swiped":et,"data-removed":de,"data-visible":fn,"data-y-position":Js,"data-x-position":Pl,"data-index":T,"data-front":jt,"data-swiping":Te,"data-dismissible":At,"data-type":Mt,"data-invert":Nr,"data-swipe-out":De,"data-swipe-direction":he,"data-expanded":!!(O||Q&&q),style:{"--index":T,"--toasts-before":T,"--z-index":D.length-T,"--offset":`${de?Le:Dt.current}px`,"--initial-height":Q?"auto":`${kt}px`,...$,...w.style},onDragEnd:()=>{je(!1),re(null),Tt.current=null},onPointerDown:Ce=>{vt||!At||(on.current=new Date,Ie(Dt.current),Ce.target.setPointerCapture(Ce.pointerId),Ce.target.tagName!=="BUTTON"&&(je(!0),Tt.current={x:Ce.clientX,y:Ce.clientY}))},onPointerUp:()=>{var Ce,ke,Ue,gt;if(De||!At)return;Tt.current=null;let Ct=Number(((Ce=Qt.current)==null?void 0:Ce.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ct=Number(((ke=Qt.current)==null?void 0:ke.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),$t=new Date().getTime()-((Ue=on.current)==null?void 0:Ue.getTime()),xt=F==="x"?Ct:ct,zt=Math.abs(xt)/$t;if(Math.abs(xt)>=AD||zt>.11){Ie(Dt.current),(gt=w.onDismiss)==null||gt.call(w,w),ge(F==="x"?Ct>0?"right":"left":ct>0?"down":"up"),st(),Fe(!0),le(!1);return}je(!1),re(null)},onPointerMove:Ce=>{var ke,Ue,gt,Ct;if(!Tt.current||!At||((ke=window.getSelection())==null?void 0:ke.toString().length)>0)return;let ct=Ce.clientY-Tt.current.y,$t=Ce.clientX-Tt.current.x,xt=(Ue=n.swipeDirections)!=null?Ue:OD(se);!F&&(Math.abs($t)>1||Math.abs(ct)>1)&&re(Math.abs($t)>Math.abs(ct)?"x":"y");let zt={x:0,y:0};F==="y"?(xt.includes("top")||xt.includes("bottom"))&&(xt.includes("top")&&ct<0||xt.includes("bottom")&&ct>0)&&(zt.y=ct):F==="x"&&(xt.includes("left")||xt.includes("right"))&&(xt.includes("left")&&$t<0||xt.includes("right")&&$t>0)&&(zt.x=$t),(Math.abs(zt.x)>0||Math.abs(zt.y)>0)&&le(!0),(gt=Qt.current)==null||gt.style.setProperty("--swipe-amount-x",`${zt.x}px`),(Ct=Qt.current)==null||Ct.style.setProperty("--swipe-amount-y",`${zt.y}px`)}},Gn&&!w.jsx?ue.createElement("button",{"aria-label":z,"data-disabled":vt,"data-close-button":!0,onClick:vt||!At?()=>{}:()=>{var Ce;st(),(Ce=w.onDismiss)==null||Ce.call(w,w)},className:xa(J==null?void 0:J.closeButton,(c=w==null?void 0:w.classNames)==null?void 0:c.closeButton)},(u=ee==null?void 0:ee.close)!=null?u:gD):null,w.jsx||m.isValidElement(w.title)?w.jsx?w.jsx:typeof w.title=="function"?w.title():w.title:ue.createElement(ue.Fragment,null,Mt||w.icon||w.promise?ue.createElement("div",{"data-icon":"",className:xa(J==null?void 0:J.icon,(f=w==null?void 0:w.classNames)==null?void 0:f.icon)},w.promise||w.type==="loading"&&!w.icon?w.icon||Bt():null,w.type!=="loading"?w.icon||(ee==null?void 0:ee[Mt])||cD(Mt):null):null,ue.createElement("div",{"data-content":"",className:xa(J==null?void 0:J.content,(p=w==null?void 0:w.classNames)==null?void 0:p.content)},ue.createElement("div",{"data-title":"",className:xa(J==null?void 0:J.title,(g=w==null?void 0:w.classNames)==null?void 0:g.title)},typeof w.title=="function"?w.title():w.title),w.description?ue.createElement("div",{"data-description":"",className:xa(ie,fa,J==null?void 0:J.description,(v=w==null?void 0:w.classNames)==null?void 0:v.description)},typeof w.description=="function"?w.description():w.description):null),m.isValidElement(w.cancel)?w.cancel:w.cancel&&Hc(w.cancel)?ue.createElement("button",{"data-button":!0,"data-cancel":!0,style:w.cancelButtonStyle||X,onClick:Ce=>{var ke,Ue;Hc(w.cancel)&&At&&((Ue=(ke=w.cancel).onClick)==null||Ue.call(ke,Ce),st())},className:xa(J==null?void 0:J.cancelButton,(x=w==null?void 0:w.classNames)==null?void 0:x.cancelButton)},w.cancel.label):null,m.isValidElement(w.action)?w.action:w.action&&Hc(w.action)?ue.createElement("button",{"data-button":!0,"data-action":!0,style:w.actionButtonStyle||te,onClick:Ce=>{var ke,Ue;Hc(w.action)&&((Ue=(ke=w.action).onClick)==null||Ue.call(ke,Ce),!Ce.defaultPrevented&&st())},className:xa(J==null?void 0:J.actionButton,(y=w==null?void 0:w.classNames)==null?void 0:y.actionButton)},w.action.label):null))};function Eb(){if(typeof window>"u"||typeof document>"u")return"ltr";let n=document.documentElement.getAttribute("dir");return n==="auto"||!n?window.getComputedStyle(document.documentElement).direction:n}function kD(n,a){let l={};return[n,a].forEach((s,c)=>{let u=c===1,f=u?"--mobile-offset":"--offset",p=u?ND:RD;function g(v){["top","right","bottom","left"].forEach(x=>{l[`${f}-${x}`]=typeof v=="number"?`${v}px`:v})}typeof s=="number"||typeof s=="string"?g(s):typeof s=="object"?["top","right","bottom","left"].forEach(v=>{s[v]===void 0?l[`${f}-${v}`]=p:l[`${f}-${v}`]=typeof s[v]=="number"?`${s[v]}px`:s[v]}):g(p)}),l}var zD=m.forwardRef(function(n,a){let{invert:l,position:s="bottom-right",hotkey:c=["altKey","KeyT"],expand:u,closeButton:f,className:p,offset:g,mobileOffset:v,theme:x="light",richColors:y,duration:b,style:w,visibleToasts:E=ED,toastOptions:j,dir:C=Eb(),gap:N=MD,loadingIcon:M,icons:T,containerAriaLabel:D="Notifications",pauseWhenPageIsHidden:O}=n,[A,U]=ue.useState([]),k=ue.useMemo(()=>Array.from(new Set([s].concat(A.filter(I=>I.position).map(I=>I.position)))),[A,s]),[$,X]=ue.useState([]),[te,G]=ue.useState(!1),[ie,ce]=ue.useState(!1),[se,_]=ue.useState(x!=="system"?x:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),H=ue.useRef(null),Q=c.join("+").replace(/Key/g,"").replace(/Digit/g,""),J=ue.useRef(null),ee=ue.useRef(!1),z=ue.useCallback(I=>{U(F=>{var re;return(re=F.find(he=>he.id===I.id))!=null&&re.delete||Tn.dismiss(I.id),F.filter(({id:he})=>he!==I.id)})},[]);return ue.useEffect(()=>Tn.subscribe(I=>{if(I.dismiss){U(F=>F.map(re=>re.id===I.id?{...re,delete:!0}:re));return}setTimeout(()=>{$E.flushSync(()=>{U(F=>{let re=F.findIndex(he=>he.id===I.id);return re!==-1?[...F.slice(0,re),{...F[re],...I},...F.slice(re+1)]:[I,...F]})})})}),[]),ue.useEffect(()=>{if(x!=="system"){_(x);return}if(x==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?_("dark"):_("light")),typeof window>"u")return;let I=window.matchMedia("(prefers-color-scheme: dark)");try{I.addEventListener("change",({matches:F})=>{_(F?"dark":"light")})}catch{I.addListener(({matches:re})=>{try{_(re?"dark":"light")}catch(he){console.error(he)}})}},[x]),ue.useEffect(()=>{A.length<=1&&G(!1)},[A]),ue.useEffect(()=>{let I=F=>{var re,he;c.every(ge=>F[ge]||F.code===ge)&&(G(!0),(re=H.current)==null||re.focus()),F.code==="Escape"&&(document.activeElement===H.current||(he=H.current)!=null&&he.contains(document.activeElement))&&G(!1)};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[c]),ue.useEffect(()=>{if(H.current)return()=>{J.current&&(J.current.focus({preventScroll:!0}),J.current=null,ee.current=!1)}},[H.current]),ue.createElement("section",{ref:a,"aria-label":`${D} ${Q}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},k.map((I,F)=>{var re;let[he,ge]=I.split("-");return A.length?ue.createElement("ol",{key:I,dir:C==="auto"?Eb():C,tabIndex:-1,ref:H,className:p,"data-sonner-toaster":!0,"data-theme":se,"data-y-position":he,"data-lifted":te&&A.length>1&&!u,"data-x-position":ge,style:{"--front-toast-height":`${((re=$[0])==null?void 0:re.height)||0}px`,"--width":`${TD}px`,"--gap":`${N}px`,...w,...kD(g,v)},onBlur:q=>{ee.current&&!q.currentTarget.contains(q.relatedTarget)&&(ee.current=!1,J.current&&(J.current.focus({preventScroll:!0}),J.current=null))},onFocus:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||ee.current||(ee.current=!0,J.current=q.relatedTarget)},onMouseEnter:()=>G(!0),onMouseMove:()=>G(!0),onMouseLeave:()=>{ie||G(!1)},onDragEnd:()=>G(!1),onPointerDown:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||ce(!0)},onPointerUp:()=>ce(!1)},A.filter(q=>!q.position&&F===0||q.position===I).map((q,oe)=>{var de,fe;return ue.createElement(_D,{key:q.id,icons:T,index:oe,toast:q,defaultRichColors:y,duration:(de=j==null?void 0:j.duration)!=null?de:b,className:j==null?void 0:j.className,descriptionClassName:j==null?void 0:j.descriptionClassName,invert:l,visibleToasts:E,closeButton:(fe=j==null?void 0:j.closeButton)!=null?fe:f,interacting:ie,position:I,style:j==null?void 0:j.style,unstyled:j==null?void 0:j.unstyled,classNames:j==null?void 0:j.classNames,cancelButtonStyle:j==null?void 0:j.cancelButtonStyle,actionButtonStyle:j==null?void 0:j.actionButtonStyle,removeToast:z,toasts:A.filter(Te=>Te.position==q.position),heights:$.filter(Te=>Te.position==q.position),setHeights:X,expandByDefault:u,gap:N,loadingIcon:M,expanded:te,pauseWhenPageIsHidden:O,swipeDirections:n.swipeDirections})})):null}))});function LD(){const{login:n}=_m(),[a,l]=m.useState("admin"),[s,c]=m.useState(""),[u,f]=m.useState(""),[p,g]=m.useState(""),[v,x]=m.useState(!1),[y,b]=m.useState(!1),w=oi(),E=_n();return o.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:o.jsxs(nt,{className:"w-full max-w-sm",children:[o.jsxs(at,{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("img",{src:"/logo.png",alt:"LateDev Router",className:"h-8 w-8 object-contain"}),o.jsx(rt,{children:"Sign in"})]}),o.jsx(gn,{children:"Enter your admin credentials."})]}),o.jsxs(lt,{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(we,{children:"Username"}),o.jsx(Ae,{value:a,onChange:j=>l(j.target.value),autoFocus:!0})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(we,{children:"Password"}),o.jsx(Ae,{type:"password",value:s,onChange:j=>c(j.target.value)})]}),v&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(we,{children:"2FA code (or recovery code)"}),o.jsx(Ae,{value:u,onChange:j=>f(j.target.value),placeholder:"123456",maxLength:6})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(we,{children:"Recovery code (alternative)"}),o.jsx(Ae,{value:p,onChange:j=>g(j.target.value),placeholder:"ABCD12-EF3456"})]})]})]}),o.jsx("div",{className:"px-6 pb-6",children:o.jsx(me,{className:"w-full",disabled:y,onClick:async()=>{var j,C;b(!0);try{if((await n(a,s,u||void 0,p||void 0)).totpRequired){x(!0);return}const M=((C=(j=E.state)==null?void 0:j.from)==null?void 0:C.pathname)??"/";w(M,{replace:!0})}catch(N){ve.error(N.message)}finally{b(!1)}},children:"Sign in"})})]})})}function UD(){const[n,a]=m.useState("admin"),[l,s]=m.useState(""),[c,u]=m.useState(""),[f,p]=m.useState(!1),[g,v]=m.useState(!0),[x,y]=m.useState(null),[b,w]=m.useState(""),[E,j]=m.useState(!1);m.useEffect(()=>{Se.get("/api/admin/setup/status").then(M=>v(!M.masterKeyConfigured)).catch(()=>v(!0))},[]);const C=!g||c.trim().length>=32,N=!f&&l.length>=12&&C;return o.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:o.jsxs(nt,{className:"w-full max-w-md",children:[o.jsxs(at,{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("img",{src:"/logo.png",alt:"LateDev Router",className:"h-8 w-8 object-contain rounded"}),o.jsx(rt,{children:"Welcome to LateDev Router"})]}),o.jsx(gn,{children:"Set up the administrator account to get started."})]}),o.jsxs(lt,{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(we,{children:"Username"}),o.jsx(Ae,{value:n,onChange:M=>a(M.target.value)})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(we,{children:"Password (12+ chars)"}),o.jsx(Ae,{type:"password",value:l,onChange:M=>s(M.target.value)})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs(we,{children:["Master encryption key ",g?"(required, 32+ chars)":"(already configured)"]}),o.jsx(Ae,{type:"password",value:c,onChange:M=>u(M.target.value),placeholder:"Paste or generate a 32+ character key"}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Provider API keys are encrypted with this key (AES-256-GCM). Store it somewhere safe — if it is lost, stored provider credentials cannot be recovered. Generate one with:"," ",o.jsx("code",{className:"break-all",children:`node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"`})]})]})]}),o.jsxs(jw,{className:"flex-col items-stretch gap-4",children:[o.jsx(me,{disabled:!N,onClick:async()=>{p(!0);try{await Se.post("/api/admin/setup",{username:n,password:l,setupMasterKey:c.trim()||void 0}),ve.success("Admin account created"),window.location.assign("/login")}catch(M){ve.error(M.message)}finally{p(!1)}},children:"Create admin"}),o.jsxs("div",{className:"border-t pt-4 space-y-2",children:[o.jsx(we,{children:"Import existing database"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Use this to restore the administrator account, password, TOTP settings, providers, models, and master key from a backup without setting up again. Enter the same 6-digit backup passphrase used when the file was created."}),o.jsx(Ae,{type:"file",accept:".json,application/json",onChange:M=>{var T;return y(((T=M.target.files)==null?void 0:T[0])??null)}}),o.jsx(Ae,{inputMode:"numeric",maxLength:6,value:b,onChange:M=>w(M.target.value.replace(/\D/g,"")),placeholder:"Backup passphrase (6 digits)"}),o.jsx(me,{variant:"outline",disabled:!x||b.length!==6||E,onClick:async()=>{var M,T;if(x){j(!0);try{const D=JSON.parse(await x.text()),O=await fetch("/api/admin/backup/restore",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({backup:D,passphrase:b})});if(!O.ok)throw new Error(((T=(M=await O.json())==null?void 0:M.error)==null?void 0:T.message)??"Import failed");ve.success("Database imported"),window.location.assign("/login")}catch(D){ve.error(D.message)}finally{j(!1)}}},children:"Import database"})]})]})]})})}function $a({title:n,description:a,actions:l,className:s}){return o.jsxs("div",{className:Ee("mb-6 flex items-start justify-between gap-4",s),children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:n}),a&&o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a})]}),l&&o.jsx("div",{className:"flex items-center gap-2",children:l})]})}const BD=K0("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground",success:"border-transparent bg-emerald-600 text-white",warning:"border-transparent bg-amber-500 text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Qe({className:n,variant:a,...l}){return o.jsx("div",{className:Ee(BD({variant:a}),n),...l})}const Oh=n=>n==="ready"||n==="healthy"?"success":n==="disabled"?"secondary":"destructive";function HD(){const[n,a]=m.useState(null);return m.useEffect(()=>{Se.get("/api/admin/dashboard").then(a).catch(()=>a(null))},[]),n?o.jsxs("div",{children:[o.jsx($a,{title:"Dashboard",description:"Operational summary for today",actions:o.jsxs("div",{className:"flex gap-2",children:[o.jsx(me,{asChild:!0,variant:"outline",size:"sm",children:o.jsxs(ra,{to:"/providers",children:[o.jsx(Su,{className:"mr-1 h-4 w-4"})," Provider"]})}),o.jsx(me,{asChild:!0,variant:"outline",size:"sm",children:o.jsxs(ra,{to:"/combos",children:[o.jsx(T0,{className:"mr-1 h-4 w-4"})," Combo"]})}),o.jsx(me,{asChild:!0,variant:"outline",size:"sm",children:o.jsxs(ra,{to:"/api-keys",children:[o.jsx(N0,{className:"mr-1 h-4 w-4"})," API Key"]})})]})}),o.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[o.jsxs(nt,{children:[o.jsx(at,{className:"pb-1",children:o.jsx(rt,{className:"text-sm text-muted-foreground",children:"Requests today"})}),o.jsx(lt,{className:"text-2xl font-semibold",children:Kt(n.today.total)})]}),o.jsxs(nt,{children:[o.jsx(at,{className:"pb-1",children:o.jsx(rt,{className:"text-sm text-muted-foreground",children:"Success rate"})}),o.jsx(lt,{className:"text-2xl font-semibold",children:n.today.total?Eu(n.today.success/n.today.total):"—"})]}),o.jsxs(nt,{children:[o.jsx(at,{className:"pb-1",children:o.jsx(rt,{className:"text-sm text-muted-foreground",children:"Failed"})}),o.jsx(lt,{className:"text-2xl font-semibold",children:Kt(n.today.failed)})]}),o.jsxs(nt,{children:[o.jsx(at,{className:"pb-1",children:o.jsx(rt,{className:"text-sm text-muted-foreground",children:"Tokens today"})}),o.jsx(lt,{className:"text-2xl font-semibold",children:Kt(n.today.totalTokens)})]})]}),o.jsxs("div",{className:"mt-6 grid gap-4 lg:grid-cols-2",children:[o.jsxs(nt,{children:[o.jsxs(at,{children:[o.jsx(rt,{className:"text-base",children:"Provider health"}),o.jsxs(gn,{children:[n.providers.length," configured"]})]}),o.jsxs(lt,{className:"space-y-2",children:[n.providers.length===0&&o.jsxs("p",{className:"text-sm text-muted-foreground",children:["No providers yet. ",o.jsx(ra,{to:"/providers",className:"text-primary",children:"Add one"}),"."]}),n.providers.map(l=>o.jsxs("div",{className:"flex items-center justify-between rounded border p-2 text-sm",children:[o.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[o.jsx(M0,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),o.jsx(ra,{className:"truncate font-medium text-primary hover:underline",to:`/providers?providerId=${encodeURIComponent(l.id)}`,children:l.name}),o.jsx("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:l.slug}),o.jsx(Qe,{variant:"outline",className:"ml-2",children:l.type})]}),o.jsx(Qe,{variant:Oh(l.health),children:l.health})]},l.id))]})]}),o.jsxs(nt,{children:[o.jsxs(at,{children:[o.jsx(rt,{className:"text-base",children:"Recent failures"}),o.jsx(gn,{children:"Today"})]}),o.jsxs(lt,{className:"space-y-1 text-sm",children:[n.recentFailures.length===0&&o.jsx("p",{className:"text-muted-foreground",children:"No failures today."}),n.recentFailures.map(l=>{var s;return o.jsxs("div",{className:"flex items-center justify-between border-b py-1 last:border-0",children:[o.jsxs("div",{children:[o.jsx("span",{className:"font-mono text-xs",children:l.requestedModel}),o.jsxs("div",{className:"text-xs text-muted-foreground",children:[l.errorType??`HTTP ${l.httpStatus}`," — ",(s=l.errorMessage)==null?void 0:s.slice(0,60)]})]}),o.jsx("span",{className:"text-xs text-muted-foreground",children:Lm(l.createdAt)})]},l.id)})]})]})]}),o.jsxs(nt,{className:"mt-6",children:[o.jsxs(at,{children:[o.jsxs(rt,{className:"flex items-center gap-2 text-base",children:[o.jsx(km,{className:"h-4 w-4"})," Health center"]}),o.jsx(gn,{children:"Passive status from recent traffic; no active provider polling."})]}),o.jsxs(lt,{className:"grid gap-4 lg:grid-cols-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"mb-2 text-sm font-medium",children:"Combos"}),o.jsx("div",{className:"space-y-2",children:n.combos.length===0?o.jsx("p",{className:"text-sm text-muted-foreground",children:"No combos configured."}):n.combos.map(l=>o.jsxs("div",{className:"flex items-center justify-between rounded border p-2 text-sm",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx(ra,{className:"font-mono text-xs text-primary hover:underline",to:"/combos",children:l.publicModelId}),o.jsxs("div",{className:"text-xs text-muted-foreground",children:[l.readyMembers,"/",l.memberCount," members ready",l.reasons.length>0?` · ${l.reasons.join(", ")}`:""]})]}),o.jsx(Qe,{variant:Oh(l.state),children:l.state})]},l.id))})]}),o.jsxs("div",{children:[o.jsx("div",{className:"mb-2 text-sm font-medium",children:"Models"}),o.jsx("div",{className:"max-h-64 space-y-2 overflow-auto",children:n.models.length===0?o.jsx("p",{className:"text-sm text-muted-foreground",children:"No models imported."}):n.models.map(l=>o.jsxs("div",{className:"flex items-center justify-between rounded border p-2 text-sm",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx(ra,{className:"font-mono text-xs text-primary hover:underline",to:`/models?providerId=${encodeURIComponent(l.providerId)}`,children:l.publicModelId}),o.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[l.providerName??"Unknown provider",l.lastFailureReason?` · last: ${l.lastFailureReason}`:""]})]}),o.jsx(Qe,{variant:Oh(l.state),children:l.state})]},l.id))})]})]})]})]}):o.jsx("div",{className:"text-muted-foreground",children:"Loading…"})}const ca=m.forwardRef(({className:n,...a},l)=>o.jsx("div",{className:"relative w-full overflow-auto",children:o.jsx("table",{ref:l,className:Ee("w-full caption-bottom text-sm",n),...a})}));ca.displayName="Table";const ua=m.forwardRef(({className:n,...a},l)=>o.jsx("thead",{ref:l,className:Ee("[&_tr]:border-b",n),...a}));ua.displayName="TableHeader";const da=m.forwardRef(({className:n,...a},l)=>o.jsx("tbody",{ref:l,className:Ee("[&_tr:last-child]:border-0",n),...a}));da.displayName="TableBody";const We=m.forwardRef(({className:n,...a},l)=>o.jsx("tr",{ref:l,className:Ee("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",n),...a}));We.displayName="TableRow";const ye=m.forwardRef(({className:n,...a},l)=>o.jsx("th",{ref:l,className:Ee("h-10 px-2 text-left align-middle font-medium text-muted-foreground",n),...a}));ye.displayName="TableHead";const pe=m.forwardRef(({className:n,...a},l)=>o.jsx("td",{ref:l,className:Ee("p-2 align-middle",n),...a}));pe.displayName="TableCell";var ID=Object.defineProperty,Yn=(n,a)=>ID(n,"name",{value:a,configurable:!0}),rp="Dialog",[Cw,Ew]=kn(rp),[PD,Na]=Cw(rp),Rw=Yn(n=>{const{__scopeDialog:a,children:l,open:s,defaultOpen:c,onOpenChange:u,modal:f=!0}=n,p=m.useRef(null),g=m.useRef(null),[v,x]=yr({prop:s,defaultProp:c??!1,onChange:u,caller:rp}),[y,b]=m.useState(0),[w,E]=m.useState(0);return o.jsx(PD,{scope:a,triggerRef:p,contentRef:g,contentId:La(),titleId:La(),descriptionId:La(),titlePresent:y>0,descriptionPresent:w>0,setTitleCount:b,setDescriptionCount:E,open:v,onOpenChange:x,onOpenToggle:m.useCallback(()=>x(j=>!j),[x]),modal:f,children:l})},"Dialog"),qD="DialogTrigger",Nw=m.forwardRef(Yn(function(a,l){const{__scopeDialog:s,...c}=a,u=Na(qD,s),f=Xe(l,u.triggerRef);return o.jsx(Ve.button,{type:"button","aria-haspopup":"dialog","aria-expanded":u.open,"aria-controls":u.open?u.contentId:void 0,"data-state":Iu(u.open),...c,ref:f,onClick:Ne(a.onClick,u.onOpenToggle)})},"DialogTrigger")),Tw="DialogPortal",[VD,Mw]=Cw(Tw,{forceMount:void 0}),Aw=Yn(n=>{const{__scopeDialog:a,forceMount:l,children:s,container:c}=n,u=Na(Tw,a);return o.jsx(VD,{scope:a,forceMount:l,children:m.Children.map(s,f=>o.jsx(Cr,{present:l||u.open,children:o.jsx(Zm,{asChild:!0,container:c,children:f})}))})},"DialogPortal"),om="DialogOverlay",lp=m.forwardRef(Yn(function(a,l){const s=Mw(om,a.__scopeDialog),{forceMount:c=s.forceMount,...u}=a,f=Na(om,a.__scopeDialog);return f.modal?o.jsx(Cr,{present:c||f.open,children:o.jsx(YD,{...u,ref:l})}):null},"DialogOverlay")),$D=Ha("DialogOverlay.RemoveScroll"),YD=m.forwardRef(Yn(function(a,l){const{__scopeDialog:s,...c}=a,u=Na(om,s),f=o1(),p=Xe(l,f);return o.jsx(Bu,{as:$D,allowPinchZoom:!0,shards:[u.contentRef],children:o.jsx(Ve.div,{"data-state":Iu(u.open),...c,ref:p,style:{pointerEvents:"auto",...c.style}})})},"DialogOverlayImpl")),ei="DialogContent",sp=m.forwardRef(Yn(function(a,l){const s=Mw(ei,a.__scopeDialog),{forceMount:c=s.forceMount,...u}=a,f=Na(ei,a.__scopeDialog);return o.jsx(Cr,{present:c||f.open,children:f.modal?o.jsx(GD,{...u,ref:l}):o.jsx(KD,{...u,ref:l})})},"DialogContent")),GD=m.forwardRef(Yn(function(a,l){const s=Na(ei,a.__scopeDialog),c=m.useRef(null),u=Xe(l,s.contentRef,c);return m.useEffect(()=>{const f=c.current;if(f)return ep(f)},[]),o.jsx(Dw,{...a,ref:u,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:Ne(a.onCloseAutoFocus,f=>{var p;f.preventDefault(),(p=s.triggerRef.current)==null||p.focus()}),onPointerDownOutside:Ne(a.onPointerDownOutside,f=>{const p=f.detail.originalEvent,g=p.button===0&&p.ctrlKey===!0;(p.button===2||g)&&f.preventDefault()}),onFocusOutside:Ne(a.onFocusOutside,f=>f.preventDefault())})},"DialogContentModal")),KD=m.forwardRef(Yn(function(a,l){const s=Na(ei,a.__scopeDialog),c=m.useRef(!1),u=m.useRef(!1);return o.jsx(Dw,{...a,ref:l,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:f=>{var p,g;(p=a.onCloseAutoFocus)==null||p.call(a,f),f.defaultPrevented||(c.current||(g=s.triggerRef.current)==null||g.focus(),f.preventDefault()),c.current=!1,u.current=!1},onInteractOutside:f=>{var v,x;(v=a.onInteractOutside)==null||v.call(a,f),f.defaultPrevented||(c.current=!0,f.detail.originalEvent.type==="pointerdown"&&(u.current=!0));const p=f.target;((x=s.triggerRef.current)==null?void 0:x.contains(p))&&f.preventDefault(),f.detail.originalEvent.type==="focusin"&&u.current&&f.preventDefault()}})},"DialogContentNonModal")),Dw=m.forwardRef(Yn(function(a,l){const{__scopeDialog:s,trapFocus:c,onOpenAutoFocus:u,onCloseAutoFocus:f,...p}=a,g=Na(ei,s);return fi(),o.jsx(o.Fragment,{children:o.jsx(qm,{asChild:!0,loop:!0,trapped:c,onMountAutoFocus:u,onUnmountAutoFocus:f,children:o.jsx(Nu,{role:"dialog",id:g.contentId,"aria-describedby":g.descriptionPresent?g.descriptionId:void 0,"aria-labelledby":g.titlePresent?g.titleId:void 0,"data-state":Iu(g.open),...p,ref:l,deferPointerDownOutside:!0,onDismiss:()=>g.onOpenChange(!1)})})})},"DialogContentImpl")),XD="DialogTitle",op=m.forwardRef(Yn(function(a,l){const{__scopeDialog:s,...c}=a,u=Na(XD,s),{setTitleCount:f}=u;return Xt(()=>(f(p=>p+1),()=>f(p=>p-1)),[f]),o.jsx(Ve.h2,{id:u.titleId,...c,ref:l})},"DialogTitle")),FD="DialogDescription",ip=m.forwardRef(Yn(function(a,l){const{__scopeDialog:s,...c}=a,u=Na(FD,s),{setDescriptionCount:f}=u;return Xt(()=>(f(p=>p+1),()=>f(p=>p-1)),[f]),o.jsx(Ve.p,{id:u.descriptionId,...c,ref:l})},"DialogDescription")),QD="DialogClose",cp=m.forwardRef(Yn(function(a,l){const{__scopeDialog:s,...c}=a,u=Na(QD,s);return o.jsx(Ve.button,{type:"button",...c,ref:l,onClick:Ne(a.onClick,()=>u.onOpenChange(!1))})},"DialogClose"));function Iu(n){return n?"open":"closed"}Yn(Iu,"getState");const Mn=Rw,mi=Nw,ZD=Aw,Ow=m.forwardRef(({className:n,...a},l)=>o.jsx(lp,{ref:l,className:Ee("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...a}));Ow.displayName=lp.displayName;const vn=m.forwardRef(({className:n,children:a,...l},s)=>o.jsxs(ZD,{children:[o.jsx(Ow,{}),o.jsxs(sp,{ref:s,className:Ee("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 sm:rounded-lg",n),...l,children:[a,o.jsxs(cp,{className:"absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100",children:[o.jsx(Cu,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));vn.displayName=sp.displayName;const xn=({className:n,...a})=>o.jsx("div",{className:Ee("flex flex-col space-y-1.5 text-center sm:text-left",n),...a});xn.displayName="DialogHeader";const An=({className:n,...a})=>o.jsx("div",{className:Ee("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...a});An.displayName="DialogFooter";const yn=m.forwardRef(({className:n,...a},l)=>o.jsx(op,{ref:l,className:Ee("text-lg font-semibold leading-none tracking-tight",n),...a}));yn.displayName=op.displayName;const uu=m.forwardRef(({className:n,...a},l)=>o.jsx(ip,{ref:l,className:Ee("text-sm text-muted-foreground",n),...a}));uu.displayName=ip.displayName;var JD=Object.defineProperty,Er=(n,a)=>JD(n,"name",{value:a,configurable:!0}),WD="AlertDialog",[eO,Y4]=kn(WD,[Ew]),Rr=Ew(),tO=Er(n=>{const{__scopeAlertDialog:a,...l}=n,s=Rr(a);return o.jsx(Rw,{...s,...l,modal:!0})},"AlertDialog"),nO=m.forwardRef(Er(function(a,l){const{__scopeAlertDialog:s,...c}=a,u=Rr(s);return o.jsx(Nw,{...u,...c,ref:l})},"AlertDialogTrigger")),aO=Er(n=>{const{__scopeAlertDialog:a,...l}=n,s=Rr(a);return o.jsx(Aw,{...s,...l})},"AlertDialogPortal"),rO=m.forwardRef(Er(function(a,l){const{__scopeAlertDialog:s,...c}=a,u=Rr(s);return o.jsx(lp,{...u,...c,ref:l})},"AlertDialogOverlay")),lO="AlertDialogContent",[sO,oO]=eO(lO),iO=m.forwardRef(Er(function(a,l){const{__scopeAlertDialog:s,children:c,...u}=a,f=Rr(s),p=m.useRef(null),g=Xe(l,p),v=m.useRef(null);return o.jsx(sO,{scope:s,cancelRef:v,children:o.jsx(sp,{role:"alertdialog",...f,...u,ref:g,onOpenAutoFocus:Ne(u.onOpenAutoFocus,x=>{var y;x.preventDefault(),(y=v.current)==null||y.focus({preventScroll:!0})}),onPointerDownOutside:x=>x.preventDefault(),onInteractOutside:x=>x.preventDefault(),children:c})})},"AlertDialogContent")),cO=m.forwardRef(Er(function(a,l){const{__scopeAlertDialog:s,...c}=a,u=Rr(s);return o.jsx(op,{...u,...c,ref:l})},"AlertDialogTitle")),uO=m.forwardRef(Er(function(a,l){const{__scopeAlertDialog:s,...c}=a,u=Rr(s);return o.jsx(ip,{...u,...c,ref:l})},"AlertDialogDescription")),dO=m.forwardRef(Er(function(a,l){const{__scopeAlertDialog:s,...c}=a,u=Rr(s);return o.jsx(cp,{...u,...c,ref:l})},"AlertDialogAction")),fO="AlertDialogCancel",hO=m.forwardRef(Er(function(a,l){const{__scopeAlertDialog:s,...c}=a,{cancelRef:u}=oO(fO,s),f=Rr(s),p=Xe(l,u);return o.jsx(cp,{...f,...c,ref:p})},"AlertDialogCancel")),mO=tO,pO=nO,gO=aO,_w=rO,kw=iO,zw=dO,Lw=hO,Uw=cO,Bw=uO;const up=mO,vO=pO,xO=gO,Hw=m.forwardRef(({className:n,...a},l)=>o.jsx(_w,{ref:l,className:Ee("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...a}));Hw.displayName=_w.displayName;const Pu=m.forwardRef(({className:n,...a},l)=>o.jsxs(xO,{children:[o.jsx(Hw,{}),o.jsx(kw,{ref:l,className:Ee("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg sm:max-w-[425px]",n),...a})]}));Pu.displayName=kw.displayName;const dp=({className:n,...a})=>o.jsx("div",{className:Ee("flex flex-col space-y-2 text-center sm:text-left",n),...a}),fp=({className:n,...a})=>o.jsx("div",{className:Ee("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...a}),qu=m.forwardRef(({className:n,...a},l)=>o.jsx(Uw,{ref:l,className:Ee("text-lg font-semibold",n),...a}));qu.displayName=Uw.displayName;const Vu=m.forwardRef(({className:n,...a},l)=>o.jsx(Bw,{ref:l,className:Ee("text-sm text-muted-foreground",n),...a}));Vu.displayName=Bw.displayName;const $u=m.forwardRef(({className:n,...a},l)=>o.jsx(zw,{ref:l,className:Ee("inline-flex h-9 items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90",n),...a}));$u.displayName=zw.displayName;const Yu=m.forwardRef(({className:n,...a},l)=>o.jsx(Lw,{ref:l,className:Ee("inline-flex h-9 items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium hover:bg-accent",n),...a}));Yu.displayName=Lw.displayName;var yO=Object.defineProperty,bO=(n,a)=>yO(n,"name",{value:a,configurable:!0});function im(n,[a,l]){return Math.min(l,Math.max(a,n))}bO(im,"clamp");var wO=Object.defineProperty,SO=(n,a)=>wO(n,"name",{value:a,configurable:!0});function Iw(n){const a=m.useRef({value:n,previous:n});return m.useMemo(()=>(a.current.value!==n&&(a.current.previous=a.current.value,a.current.value=n),a.current.previous),[n])}SO(Iw,"usePrevious");var jO=Object.defineProperty,CO=(n,a)=>jO(n,"name",{value:a,configurable:!0}),Pw=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),EO=m.forwardRef(CO(function(a,l){return o.jsx(Ve.span,{...a,ref:l,style:{...Pw,...a.style}})},"VisuallyHidden")),RO=EO,NO=Object.defineProperty,ht=(n,a)=>NO(n,"name",{value:a,configurable:!0}),TO=[" ","Enter","ArrowUp","ArrowDown"],MO=[" ","Enter"],Bs="Select",[Gu,hp,AO]=Ru(Bs),[Il,G4]=kn(Bs,[AO,Ks]),mp=Ks(),[DO,ul]=Il(Bs),[OO,_O]=Il(Bs);function qw(n){const{__scopeSelect:a,children:l,open:s,defaultOpen:c,onOpenChange:u,value:f,defaultValue:p,onValueChange:g,dir:v,name:x,autoComplete:y,disabled:b,required:w,form:E,internal_do_not_use_render:j}=n,C=mp(a),[N,M]=m.useState(null),[T,D]=m.useState(null),[O,A]=m.useState(!1),U=di(v),[k,$]=yr({prop:s,defaultProp:c??!1,onChange:u,caller:Bs}),[X,te]=yr({prop:f,defaultProp:p,onChange:g,caller:Bs}),G=m.useRef(null),ie=m.useRef(X);m.useEffect(()=>{const I=E?N==null?void 0:N.ownerDocument.getElementById(E):N==null?void 0:N.form;if(I instanceof HTMLFormElement){const F=ht(()=>te(ie.current),"reset");return I.addEventListener("reset",F),()=>I.removeEventListener("reset",F)}},[E,N,te]);const ce=N?!!E||!!N.closest("form"):!0,[se,_]=m.useState(new Set),H=La(),Q=Array.from(se).map(I=>I.props.value).join(";"),J=m.useCallback(I=>{_(F=>new Set(F).add(I))},[]),ee=m.useCallback(I=>{_(F=>{const re=new Set(F);return re.delete(I),re})},[]),z={required:w,trigger:N,onTriggerChange:M,valueNode:T,onValueNodeChange:D,valueNodeHasChildren:O,onValueNodeHasChildrenChange:A,contentId:H,value:X,onValueChange:te,open:k,onOpenChange:$,dir:U,triggerPointerDownPosRef:G,disabled:b,name:x,autoComplete:y,form:E,nativeOptions:se,nativeSelectKey:Q,isFormControl:ce};return o.jsx(O1,{...C,children:o.jsx(DO,{scope:a,...z,children:o.jsx(Gu.Provider,{scope:a,children:o.jsx(OO,{scope:a,onNativeOptionAdd:J,onNativeOptionRemove:ee,children:Xw(j)?j(z):l})})})})}ht(qw,"SelectProvider");var kO=ht(n=>{const{__scopeSelect:a,children:l,...s}=n;return o.jsx(qw,{__scopeSelect:a,...s,internal_do_not_use_render:({isFormControl:c})=>o.jsxs(o.Fragment,{children:[l,c?o.jsx(n_,{__scopeSelect:a}):null]})})},"Select"),zO="SelectTrigger",Vw=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,disabled:c=!1,...u}=a,f=mp(s),p=ul(zO,s),g=p.disabled||c,v=Xe(l,p.onTriggerChange),x=hp(s),y=m.useRef("touch"),[b,w,E]=pp(C=>{const N=x().filter(D=>!D.disabled),M=N.find(D=>D.value===p.value),T=gp(N,C,M);T!==void 0&&p.onValueChange(T.value)}),j=ht(C=>{g||(p.onOpenChange(!0),E()),C&&(p.triggerPointerDownPosRef.current={x:Math.round(C.pageX),y:Math.round(C.pageY)})},"handleOpen");return o.jsx(_1,{asChild:!0,...f,children:o.jsx(Ve.button,{type:"button",role:"combobox","aria-controls":p.open?p.contentId:void 0,"aria-expanded":p.open,"aria-required":p.required,"aria-autocomplete":"none",dir:p.dir,"data-state":p.open?"open":"closed",disabled:g,"data-disabled":g?"":void 0,"data-placeholder":pi(p.value)?"":void 0,...u,ref:v,onClick:Ne(u.onClick,C=>{C.currentTarget.focus(),y.current!=="mouse"&&j(C)}),onPointerDown:Ne(u.onPointerDown,C=>{y.current=C.pointerType;const N=C.target;N.hasPointerCapture(C.pointerId)&&N.releasePointerCapture(C.pointerId),C.button===0&&C.ctrlKey===!1&&C.pointerType==="mouse"&&(j(C),C.preventDefault())}),onKeyDown:Ne(u.onKeyDown,C=>{const N=b.current!=="";!(C.ctrlKey||C.altKey||C.metaKey)&&C.key.length===1&&w(C.key),!(N&&C.key===" ")&&TO.includes(C.key)&&(j(),C.preventDefault())})})})},"SelectTrigger")),LO="SelectValue",UO=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,className:c,style:u,children:f,placeholder:p="",...g}=a,v=ul(LO,s),{onValueNodeHasChildrenChange:x}=v,y=f!==void 0,b=Xe(l,v.onValueNodeChange);Xt(()=>{x(y)},[x,y]);const w=pi(v.value);return o.jsx(Ve.span,{...g,asChild:w?!1:g.asChild,ref:b,style:{pointerEvents:"none"},children:o.jsx(m.Fragment,{children:w?p:f},w?"placeholder":"value")})},"SelectValue")),BO=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,children:c,...u}=a;return o.jsx(Ve.span,{"aria-hidden":!0,...u,ref:l,children:c||"▼"})},"SelectIcon")),HO="SelectPortal",[IO,PO]=Il(HO,{forceMount:void 0}),qO=ht(n=>{const{__scopeSelect:a,forceMount:l,...s}=n;return o.jsx(IO,{scope:n.__scopeSelect,forceMount:l,children:o.jsx(Zm,{asChild:!0,...s})})},"SelectPortal"),zl="SelectContent",$w=m.forwardRef(ht(function(a,l){const s=PO(zl,a.__scopeSelect),{forceMount:c=s.forceMount,...u}=a,f=ul(zl,a.__scopeSelect),[p,g]=m.useState();return Xt(()=>{g(new DocumentFragment)},[]),o.jsx(Cr,{present:c||f.open,children:({present:v})=>v?o.jsx(YO,{...u,ref:l}):o.jsx(VO,{...u,fragment:p})})},"SelectContent")),VO=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,children:c,fragment:u}=a;return u?ba.createPortal(o.jsx(Yw,{scope:s,children:o.jsx(Gu.Slot,{scope:s,children:o.jsx("div",{ref:l,children:c})})}),u):null},"SelectContentFragment")),ya=10,[Yw,Ku]=Il(zl),$O=Ha("SelectContent.RemoveScroll"),YO=m.forwardRef(ht(function(a,l){const{__scopeSelect:s}=a,{position:c="item-aligned",onCloseAutoFocus:u,onEscapeKeyDown:f,onPointerDownOutside:p,side:g,sideOffset:v,align:x,alignOffset:y,arrowPadding:b,collisionBoundary:w,collisionPadding:E,sticky:j,hideWhenDetached:C,avoidCollisions:N,...M}=a,T=ul(zl,s),[D,O]=m.useState(null),[A,U]=m.useState(null),k=Xe(l,O),[$,X]=m.useState(null),[te,G]=m.useState(null),ie=hp(s),[ce,se]=m.useState(!1),_=m.useRef(!1);m.useEffect(()=>{if(D)return ep(D)},[D]),fi();const H=m.useCallback(oe=>{const[de,...fe]=ie().map(De=>De.ref.current),[Te]=fe.slice(-1),je=document.activeElement;for(const De of oe)if(De===je||(De==null||De.scrollIntoView({block:"nearest"}),De===de&&A&&(A.scrollTop=0),De===Te&&A&&(A.scrollTop=A.scrollHeight),De==null||De.focus(),document.activeElement!==je))return},[ie,A]),Q=m.useCallback(()=>H([$,D]),[H,$,D]);m.useEffect(()=>{ce&&Q()},[ce,Q]);const{onOpenChange:J,triggerPointerDownPosRef:ee}=T;m.useEffect(()=>{if(D){let oe={x:0,y:0};const de=ht(Te=>{var je,De;oe={x:Math.abs(Math.round(Te.pageX)-(((je=ee.current)==null?void 0:je.x)??0)),y:Math.abs(Math.round(Te.pageY)-(((De=ee.current)==null?void 0:De.y)??0))}},"handlePointerMove"),fe=ht(Te=>{oe.x<=10&&oe.y<=10?Te.preventDefault():Te.composedPath().includes(D)||J(!1),document.removeEventListener("pointermove",de),ee.current=null},"handlePointerUp");return ee.current!==null&&(document.addEventListener("pointermove",de),document.addEventListener("pointerup",fe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",de),document.removeEventListener("pointerup",fe,{capture:!0})}}},[D,J,ee]),m.useEffect(()=>{const oe=ht(()=>J(!1),"close");return window.addEventListener("blur",oe),window.addEventListener("resize",oe),()=>{window.removeEventListener("blur",oe),window.removeEventListener("resize",oe)}},[J]);const[z,I]=pp(oe=>{const de=ie().filter(je=>!je.disabled),fe=de.find(je=>je.ref.current===document.activeElement),Te=gp(de,oe,fe);Te&&setTimeout(()=>{var je;return(je=Te.ref.current)==null?void 0:je.focus()})}),F=m.useCallback((oe,de,fe)=>{const Te=!_.current&&!fe;(T.value!==void 0&&T.value===de||Te)&&(X(oe),Te&&(_.current=!0))},[T.value]),re=m.useCallback(()=>D==null?void 0:D.focus(),[D]),he=m.useCallback((oe,de,fe)=>{const Te=!_.current&&!fe;(T.value!==void 0&&T.value===de||Te)&&G(oe)},[T.value]),ge=c==="popper"?Rb:GO,q=ge===Rb?{side:g,sideOffset:v,align:x,alignOffset:y,arrowPadding:b,collisionBoundary:w,collisionPadding:E,sticky:j,hideWhenDetached:C,avoidCollisions:N}:{};return o.jsx(Yw,{scope:s,content:D,viewport:A,onViewportChange:U,itemRefCallback:F,selectedItem:$,onItemLeave:re,itemTextRefCallback:he,focusSelectedItem:Q,selectedItemText:te,position:c,isPositioned:ce,searchRef:z,children:o.jsx(Bu,{as:$O,allowPinchZoom:!0,children:o.jsx(qm,{asChild:!0,trapped:T.open,onMountAutoFocus:oe=>{oe.preventDefault()},onUnmountAutoFocus:Ne(u,oe=>{var de;(de=T.trigger)==null||de.focus({preventScroll:!0}),oe.preventDefault()}),children:o.jsx(Nu,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:oe=>oe.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:o.jsx(ge,{role:"listbox",id:T.contentId,"data-state":T.open?"open":"closed",dir:T.dir,onContextMenu:oe=>oe.preventDefault(),...M,...q,onPlaced:()=>se(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...M.style},onKeyDown:Ne(M.onKeyDown,oe=>{const de=oe.ctrlKey||oe.altKey||oe.metaKey;if(oe.key==="Tab"&&oe.preventDefault(),!de&&oe.key.length===1&&I(oe.key),["ArrowUp","ArrowDown","Home","End"].includes(oe.key)){let Te=ie().filter(je=>!je.disabled).map(je=>je.ref.current);if(["ArrowUp","End"].includes(oe.key)&&(Te=Te.slice().reverse()),["ArrowUp","ArrowDown"].includes(oe.key)){const je=oe.target,De=Te.indexOf(je);Te=Te.slice(De+1)}setTimeout(()=>H(Te)),oe.preventDefault()}})})})})})})},"SelectContentImpl")),GO=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,onPlaced:c,...u}=a,f=ul(zl,s),p=Ku(zl,s),[g,v]=m.useState(null),[x,y]=m.useState(null),b=Xe(l,y),w=hp(s),E=m.useRef(!1),j=m.useRef(!0),{viewport:C,selectedItem:N,selectedItemText:M,focusSelectedItem:T}=p,D=m.useCallback(()=>{if(f.trigger&&f.valueNode&&g&&x&&C&&N&&M){const k=f.trigger.getBoundingClientRect(),$=x.getBoundingClientRect(),X=f.valueNode.getBoundingClientRect(),te=M.getBoundingClientRect();if(f.dir!=="rtl"){const je=te.left-$.left,De=X.left-je,Fe=k.left-De,et=k.width+Fe,le=Math.max(et,$.width),Le=window.innerWidth-ya,Ie=im(De,[ya,Math.max(ya,Le-le)]);g.style.minWidth=et+"px",g.style.left=Ie+"px"}else{const je=$.right-te.right,De=window.innerWidth-X.right-je,Fe=window.innerWidth-k.right-De,et=k.width+Fe,le=Math.max(et,$.width),Le=window.innerWidth-ya,Ie=im(De,[ya,Math.max(ya,Le-le)]);g.style.minWidth=et+"px",g.style.right=Ie+"px"}const G=w(),ie=window.innerHeight-ya*2,ce=C.scrollHeight,se=window.getComputedStyle(x),_=parseInt(se.borderTopWidth,10),H=parseInt(se.paddingTop,10),Q=parseInt(se.borderBottomWidth,10),J=parseInt(se.paddingBottom,10),ee=_+H+ce+J+Q,z=Math.min(N.offsetHeight*5,ee),I=window.getComputedStyle(C),F=parseInt(I.paddingTop,10),re=parseInt(I.paddingBottom,10),he=k.top+k.height/2-ya,ge=ie-he,q=N.offsetHeight/2,oe=N.offsetTop+q,de=_+H+oe,fe=ee-de;if(de<=he){const je=G.length>0&&N===G[G.length-1].ref.current;g.style.bottom="0px";const De=x.clientHeight-C.offsetTop-C.offsetHeight,Fe=Math.max(ge,q+(je?re:0)+De+Q),et=de+Fe;g.style.height=et+"px"}else{const je=G.length>0&&N===G[0].ref.current;g.style.top="0px";const Fe=Math.max(he,_+C.offsetTop+(je?F:0)+q)+fe;g.style.height=Fe+"px",C.scrollTop=de-he+C.offsetTop}g.style.margin=`${ya}px 0`,g.style.minHeight=z+"px",g.style.maxHeight=ie+"px",c==null||c(),requestAnimationFrame(()=>E.current=!0)}},[w,f.trigger,f.valueNode,g,x,C,N,M,f.dir,c]);Xt(()=>D(),[D]);const[O,A]=m.useState();Xt(()=>{x&&A(window.getComputedStyle(x).zIndex)},[x]);const U=m.useCallback(k=>{k&&j.current===!0&&(D(),T==null||T(),j.current=!1)},[D,T]);return o.jsx(KO,{scope:s,contentWrapper:g,shouldExpandOnScrollRef:E,onScrollButtonChange:U,children:o.jsx("div",{ref:v,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:O},children:o.jsx(Ve.div,{...u,ref:b,style:{boxSizing:"border-box",maxHeight:"100%",...u.style}})})})},"SelectItemAlignedPosition")),Rb=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,align:c="start",collisionPadding:u=ya,...f}=a,p=mp(s);return o.jsx(Qm,{...p,...f,ref:l,align:c,collisionPadding:u,style:{boxSizing:"border-box",...f.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[KO,XO]=Il(zl,{}),Nb="SelectViewport",FO=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,nonce:c,...u}=a,f=Ku(Nb,s),p=XO(Nb,s),g=Xe(l,f.onViewportChange),v=m.useRef(0);return o.jsxs(o.Fragment,{children:[o.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:c}),o.jsx(Gu.Slot,{scope:s,children:o.jsx(Ve.div,{"data-radix-select-viewport":"",role:"presentation",...u,ref:g,style:{position:"relative",flex:1,overflow:"hidden auto",...u.style},onScroll:Ne(u.onScroll,x=>{const y=x.currentTarget,{contentWrapper:b,shouldExpandOnScrollRef:w}=p;if(w!=null&&w.current&&b){const E=Math.abs(v.current-y.scrollTop);if(E>0){const j=window.innerHeight-ya*2,C=parseFloat(b.style.minHeight),N=parseFloat(b.style.height),M=Math.max(C,N);if(M<j){const T=M+E,D=Math.min(j,T),O=T-D;b.style.height=D+"px",b.style.bottom==="0px"&&(y.scrollTop=O>0?O:0,b.style.justifyContent="flex-end")}}}v.current=y.scrollTop})})})]})},"SelectViewport")),QO="SelectGroup",[K4,X4]=Il(QO),cm="SelectItem",[ZO,Gw]=Il(cm),Kw=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,value:c,disabled:u=!1,textValue:f,...p}=a,g=ul(cm,s),v=Ku(cm,s),x=g.value===c,[y,b]=m.useState(f??""),[w,E]=m.useState(!1),j=ia(D=>{var O;return(O=v.itemRefCallback)==null?void 0:O.call(v,D,c,u)}),C=Xe(l,j),N=La(),M=m.useRef("touch"),T=ht(()=>{u||(g.onValueChange(c),g.onOpenChange(!1))},"handleSelect");return o.jsx(ZO,{scope:s,value:c,disabled:u,textId:N,isSelected:x,onItemTextChange:m.useCallback(D=>{b(O=>O||((D==null?void 0:D.textContent)??"").trim())},[]),children:o.jsx(Gu.ItemSlot,{scope:s,value:c,disabled:u,textValue:y,children:o.jsx(Ve.div,{role:"option","aria-labelledby":N,"data-highlighted":w?"":void 0,"aria-selected":x&&w,"data-state":x?"checked":"unchecked","aria-disabled":u||void 0,"data-disabled":u?"":void 0,tabIndex:u?void 0:-1,...p,ref:C,onFocus:Ne(p.onFocus,()=>E(!0)),onBlur:Ne(p.onBlur,()=>E(!1)),onClick:Ne(p.onClick,()=>{M.current!=="mouse"&&T()}),onPointerUp:Ne(p.onPointerUp,()=>{M.current==="mouse"&&T()}),onPointerDown:Ne(p.onPointerDown,D=>{M.current=D.pointerType}),onPointerMove:Ne(p.onPointerMove,D=>{var O;M.current=D.pointerType,u?(O=v.onItemLeave)==null||O.call(v):M.current==="mouse"&&D.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ne(p.onPointerLeave,D=>{var O;D.currentTarget===document.activeElement&&((O=v.onItemLeave)==null||O.call(v))}),onKeyDown:Ne(p.onKeyDown,D=>{var A;u||D.target!==D.currentTarget||((A=v.searchRef)==null?void 0:A.current)!==""&&D.key===" "||(MO.includes(D.key)&&T(),D.key===" "&&D.preventDefault())})})})})},"SelectItem")),Ic="SelectItemText",JO=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,className:c,style:u,...f}=a,p=ul(Ic,s),g=Ku(Ic,s),v=Gw(Ic,s),x=_O(Ic,s),[y,b]=m.useState(null),w=ia(T=>{var D;return(D=g.itemTextRefCallback)==null?void 0:D.call(g,T,v.value,v.disabled)}),E=Xe(l,b,v.onItemTextChange,w),j=y==null?void 0:y.textContent,C=m.useMemo(()=>o.jsx("option",{value:v.value,disabled:v.disabled,children:j},v.value),[v.disabled,v.value,j]),{onNativeOptionAdd:N,onNativeOptionRemove:M}=x;return Xt(()=>(N(C),()=>M(C)),[N,M,C]),o.jsxs(o.Fragment,{children:[o.jsx(Ve.span,{id:v.textId,...f,ref:E}),v.isSelected&&p.valueNode&&!p.valueNodeHasChildren&&!pi(p.value)?ba.createPortal(f.children,p.valueNode):null]})},"SelectItemText")),WO="SelectItemIndicator",e_=m.forwardRef(ht(function(a,l){const{__scopeSelect:s,...c}=a;return Gw(WO,s).isSelected?o.jsx(Ve.span,{"aria-hidden":!0,...c,ref:l}):null},"SelectItemIndicator")),t_="SelectBubbleInput",n_=m.forwardRef(ht(function({__scopeSelect:a,...l},s){const c=ul(t_,a),{value:u,onValueChange:f,required:p,disabled:g,name:v,autoComplete:x,form:y}=c,{nativeOptions:b,nativeSelectKey:w}=c,E=m.useRef(null),j=Xe(s,E),C=u??"",N=Iw(C),M=Array.from(b).some(T=>(T.props.value??"")==="");return m.useEffect(()=>{const T=E.current;if(!T)return;const D=window.HTMLSelectElement.prototype,A=Object.getOwnPropertyDescriptor(D,"value").set;if(N!==C&&A){const U=new Event("change",{bubbles:!0});A.call(T,C),T.dispatchEvent(U)}},[N,C]),o.jsxs(Ve.select,{"aria-hidden":!0,required:p,tabIndex:-1,name:v,autoComplete:x,disabled:g,form:y,onChange:T=>f(T.target.value),...l,style:{...Pw,...l.style},ref:j,defaultValue:C,children:[pi(u)&&!M?o.jsx("option",{value:""}):null,Array.from(b)]},w)},"SelectBubbleInput"));function Xw(n){return typeof n=="function"}ht(Xw,"isFunction");function pi(n){return n===""||n===void 0}ht(pi,"shouldShowPlaceholder");function pp(n){const a=ia(n),l=m.useRef(""),s=m.useRef(0),c=m.useCallback(f=>{const p=l.current+f;a(p),ht((function g(v){l.current=v,window.clearTimeout(s.current),v!==""&&(s.current=window.setTimeout(()=>g(""),1e3))}),"updateSearch")(p)},[a]),u=m.useCallback(()=>{l.current="",window.clearTimeout(s.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(s.current),[]),[l,c,u]}ht(pp,"useTypeaheadSearch");function gp(n,a,l){const c=a.length>1&&Array.from(a).every(v=>v===a[0])?a[0]:a,u=l?n.indexOf(l):-1;let f=Fw(n,Math.max(u,0));c.length===1&&(f=f.filter(v=>v!==l));const g=f.find(v=>v.textValue.toLowerCase().startsWith(c.toLowerCase()));return g!==l?g:void 0}ht(gp,"findNextItem");function Fw(n,a){return n.map((l,s)=>n[(a+s)%n.length])}ht(Fw,"wrapArray");const Ua=kO,Ba=UO,Sa=m.forwardRef(({className:n,children:a,...l},s)=>o.jsxs(Vw,{ref:s,className:Ee("flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",n),...l,children:[a,o.jsx(BO,{asChild:!0,children:o.jsx(JE,{className:"h-4 w-4 opacity-50"})})]}));Sa.displayName=Vw.displayName;const ja=m.forwardRef(({className:n,children:a,position:l="popper",...s},c)=>o.jsx(qO,{children:o.jsx($w,{ref:c,className:Ee("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",n),position:l,...s,children:o.jsx(FO,{className:Ee("p-1",l==="popper"&&"w-full min-w-[var(--radix-select-trigger-width)]"),children:a})})}));ja.displayName=$w.displayName;const Rt=m.forwardRef(({className:n,children:a,...l},s)=>o.jsxs(Kw,{ref:s,className:Ee("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),...l,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(e_,{children:o.jsx(C0,{className:"h-4 w-4"})})}),o.jsx(JO,{children:a})]}));Rt.displayName=Kw.displayName;var a_=Object.defineProperty,il=(n,a)=>a_(n,"name",{value:a,configurable:!0}),vp="Switch",[r_,F4]=kn(vp),[l_,xp]=r_(vp);function Qw(n){const{__scopeSwitch:a,checked:l,children:s,defaultChecked:c,disabled:u,form:f,name:p,onCheckedChange:g,required:v,value:x="on",internal_do_not_use_render:y}=n,[b,w]=yr({prop:l,defaultProp:c??!1,onChange:g,caller:vp}),[E,j]=m.useState(null),[C,N]=m.useState(null),M=m.useRef(!1),[T,D]=m.useReducer(U=>U+1,0),O=E?!!f||!!E.closest("form"):!0,A={checked:b,setChecked:w,disabled:u,control:E,setControl:j,name:p,form:f,value:x,hasConsumerStoppedPropagationRef:M,userInteractionCount:T,onUserInteraction:D,required:v,defaultChecked:c,isFormControl:O,bubbleInput:C,setBubbleInput:N};return o.jsx(l_,{scope:a,...A,children:Jw(y)?y(A):s})}il(Qw,"SwitchProvider");var s_="SwitchTrigger",o_=m.forwardRef(il(function({__scopeSwitch:a,onClick:l,...s},c){const{control:u,form:f,value:p,disabled:g,checked:v,required:x,setControl:y,setChecked:b,hasConsumerStoppedPropagationRef:w,onUserInteraction:E,isFormControl:j,bubbleInput:C}=xp(s_,a),N=Xe(c,y),M=m.useRef(v);return m.useEffect(()=>{const T=f?u==null?void 0:u.ownerDocument.getElementById(f):u==null?void 0:u.form;if(T instanceof HTMLFormElement){const D=il(()=>b(M.current),"reset");return T.addEventListener("reset",D),()=>T.removeEventListener("reset",D)}},[u,f,b]),o.jsx(Ve.button,{type:"button",role:"switch","aria-checked":v,"aria-required":x,"data-state":yp(v),"data-disabled":g?"":void 0,disabled:g,value:p,...s,ref:N,onClick:Ne(l,T=>{E(),b(D=>!D),C&&j&&(w.current=T.isPropagationStopped(),w.current||T.stopPropagation())})})},"SwitchTrigger")),Zw=m.forwardRef(il(function(a,l){const{__scopeSwitch:s,name:c,checked:u,defaultChecked:f,required:p,disabled:g,value:v,onCheckedChange:x,form:y,...b}=a;return o.jsx(Qw,{__scopeSwitch:s,checked:u,defaultChecked:f,disabled:g,required:p,onCheckedChange:x,name:c,form:y,value:v,internal_do_not_use_render:({isFormControl:w})=>o.jsxs(o.Fragment,{children:[o.jsx(o_,{...b,ref:l,__scopeSwitch:s}),w&&o.jsx(d_,{__scopeSwitch:s})]})})},"Switch")),i_="SwitchThumb",c_=m.forwardRef(il(function(a,l){const{__scopeSwitch:s,...c}=a,u=xp(i_,s);return o.jsx(Ve.span,{"data-state":yp(u.checked),"data-disabled":u.disabled?"":void 0,...c,ref:l})},"SwitchThumb")),u_="SwitchBubbleInput",d_=m.forwardRef(il(function({__scopeSwitch:a,onClick:l,...s},c){const{control:u,hasConsumerStoppedPropagationRef:f,userInteractionCount:p,checked:g,defaultChecked:v,required:x,disabled:y,name:b,value:w,form:E,bubbleInput:j,setBubbleInput:C}=xp(u_,a),N=Xe(c,C),M=_u(u),T=m.useRef(!1),D=m.useRef(g),O=m.useRef(p);m.useEffect(()=>{const U=j;if(!U)return;const k=window.HTMLInputElement.prototype,X=Object.getOwnPropertyDescriptor(k,"checked").set,te=p!==O.current;O.current=p;const G=D.current!==g;D.current=g;const ie=!(te&&f.current);if(G&&X){T.current=!te;const ce=new Event("click",{bubbles:ie});X.call(U,g),U.dispatchEvent(ce),T.current=!1}},[j,g,f,p]);const A=m.useRef(g);return o.jsx(Ve.input,{type:"checkbox","aria-hidden":!0,defaultChecked:v??A.current,required:x,disabled:y,name:b,value:w,form:E,...s,tabIndex:-1,ref:N,onClick:Ne(l,U=>{T.current&&U.stopPropagation()}),style:{...s.style,...M,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function Jw(n){return typeof n=="function"}il(Jw,"isFunction");function yp(n){return n?"checked":"unchecked"}il(yp,"getState");const Ca=m.forwardRef(({className:n,...a},l)=>o.jsx(Zw,{className:Ee("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",n),...a,ref:l,children:o.jsx(c_,{className:Ee("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Ca.displayName=Zw.displayName;const Al={name:"",slug:"",type:"openai",baseUrl:"https://api.openai.com",apiKey:"",customHeaders:"",enabled:!0},f_={openai:"https://api.openai.com",anthropic:"https://api.anthropic.com"};function h_(){const[n,a]=m.useState([]),[l,s]=m.useState(!1),[c,u]=m.useState(Al),[f,p]=m.useState(!1),[g,v]=m.useState(null),[x,y]=m.useState(null),[b,w]=m.useState(Al),[E,j]=m.useState(null),[C,N]=m.useState(!1),M=async()=>{try{const k=await Se.get("/api/admin/providers");a(k.providers)}catch(k){ve.error(k.message||"Unable to load providers")}};m.useEffect(()=>{M()},[]);const T=async()=>{p(!0);try{let k;if(c.customHeaders.trim())try{k=JSON.parse(c.customHeaders)}catch{throw new Error("Custom headers must be valid JSON object")}await Se.post("/api/admin/providers",{name:c.name,slug:c.slug||void 0,type:c.type,baseUrl:c.baseUrl,apiKey:c.apiKey,customHeaders:k,enabled:c.enabled}),ve.success("Provider created"),s(!1),u(Al),M()}catch(k){ve.error(k.message)}finally{p(!1)}},D=async k=>{v(k);try{const $=await Se.post(`/api/admin/providers/${k}/test`);ve.success($.ok?`Connection OK: ${$.detail}`:`Failed: ${$.detail}`),M()}catch($){ve.error($.message)}finally{v(null)}},O=k=>{y(k.id),w({...Al,name:k.name,slug:k.slug||"",type:k.type,baseUrl:k.baseUrl,apiKey:"",customHeaders:"",enabled:k.enabled})},A=async()=>{if(x){p(!0);try{let k;if(b.customHeaders.trim())try{k=JSON.parse(b.customHeaders)}catch{throw new Error("Custom headers must be valid JSON object")}await Se.patch("/api/admin/providers",{id:x,name:b.name,slug:b.slug||void 0,type:b.type,baseUrl:b.baseUrl,apiKey:b.apiKey||void 0,customHeaders:k,enabled:b.enabled}),ve.success("Provider updated"),y(null),w(Al),M()}catch(k){ve.error(k.message)}finally{p(!1)}}},U=async k=>{N(!0);try{await Se.del(`/api/admin/providers/${k}`),ve.success("Provider removed"),M()}catch($){ve.error($.message)}finally{N(!1),j(null)}};return o.jsxs("div",{children:[o.jsx($a,{title:"Providers",description:"Upstream LLM providers and their credentials",actions:o.jsx("div",{className:"flex gap-2",children:o.jsxs(Mn,{open:l,onOpenChange:s,children:[o.jsx(mi,{asChild:!0,children:o.jsx(me,{children:"Add compatible provider"})}),o.jsxs(vn,{children:[o.jsxs(xn,{children:[o.jsx(yn,{children:"New provider"}),o.jsx(uu,{children:"API-key or compatible endpoint."})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx(we,{htmlFor:"provider-name",children:"Name"}),o.jsx(Ae,{id:"provider-name",value:c.name,onChange:k=>u({...c,name:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{htmlFor:"provider-slug",children:"Slug (optional)"}),o.jsx(Ae,{id:"provider-slug",value:c.slug,onChange:k=>u({...c,slug:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{children:"Type"}),o.jsxs(Ua,{value:c.type,onValueChange:k=>u($=>({...$,type:k,baseUrl:f_[k]})),children:[o.jsx(Sa,{children:o.jsx(Ba,{})}),o.jsxs(ja,{children:[o.jsx(Rt,{value:"openai",children:"OpenAI-compatible"}),o.jsx(Rt,{value:"anthropic",children:"Anthropic-compatible"})]})]})]}),o.jsxs("div",{children:[o.jsx(we,{htmlFor:"provider-base-url",children:"Base URL"}),o.jsx(Ae,{id:"provider-base-url",value:c.baseUrl,onChange:k=>u({...c,baseUrl:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{htmlFor:"provider-api-key",children:"API key"}),o.jsx(Ae,{id:"provider-api-key",type:"password",value:c.apiKey,onChange:k=>u({...c,apiKey:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{htmlFor:"provider-headers",children:"Custom headers (JSON)"}),o.jsx(Ae,{id:"provider-headers",value:c.customHeaders,onChange:k=>u({...c,customHeaders:k.target.value}),placeholder:'{"X-Org":"acme"}'})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ca,{checked:c.enabled,onCheckedChange:k=>u({...c,enabled:k})}),o.jsx(we,{children:"Enabled"})]})]}),o.jsxs(An,{children:[o.jsx(me,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),o.jsx(me,{disabled:f||!c.name||!c.apiKey,onClick:T,children:f?"Creating…":"Create"})]})]})]})})}),o.jsxs(nt,{children:[o.jsxs(at,{children:[o.jsx(rt,{className:"text-base",children:"All providers"}),o.jsxs(gn,{children:[n.length," total"]})]}),o.jsx(lt,{children:o.jsxs(ca,{children:[o.jsx(ua,{children:o.jsxs(We,{children:[o.jsx(ye,{children:"Name"}),o.jsx(ye,{children:"Type"}),o.jsx(ye,{children:"Base URL"}),o.jsx(ye,{children:"Models"}),o.jsx(ye,{children:"Health"}),o.jsx(ye,{children:"Enabled"}),o.jsx(ye,{className:"text-right",children:"Actions"})]})}),o.jsxs(da,{children:[n.length===0&&o.jsx(We,{children:o.jsx(pe,{colSpan:7,className:"text-center text-muted-foreground",children:"No providers yet."})}),n.map(k=>o.jsxs(We,{children:[o.jsxs(pe,{className:"font-medium",children:[k.name," ",o.jsx("span",{className:"text-xs text-muted-foreground",children:k.slug})]}),o.jsx(pe,{children:o.jsx(Qe,{variant:"outline",children:k.type})}),o.jsx(pe,{className:"text-xs text-muted-foreground",children:k.baseUrl}),o.jsx(pe,{children:k.modelCount}),o.jsx(pe,{children:o.jsx(Qe,{variant:k.health==="healthy"?"success":k.health==="down"?"destructive":"secondary",children:k.health})}),o.jsx(pe,{children:k.enabled?"Yes":"No"}),o.jsx(pe,{className:"text-right",children:o.jsxs("div",{className:"flex justify-end gap-1",children:[o.jsx(me,{size:"sm",variant:"outline",disabled:g===k.id,onClick:()=>D(k.id),children:o.jsx(A0,{className:"h-3 w-3"})}),o.jsx(me,{size:"sm",variant:"outline",onClick:()=>O(k),children:"✎"}),o.jsx(me,{size:"sm",variant:"outline",onClick:()=>j(k.id),children:o.jsx(ju,{className:"h-3 w-3"})})]})})]},k.id))]})]})})]}),o.jsx(Mn,{open:!!x,onOpenChange:k=>{k||(y(null),w(Al))},children:o.jsxs(vn,{children:[o.jsx(xn,{children:o.jsx(yn,{children:"Edit provider"})}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx(we,{children:"Name"}),o.jsx(Ae,{value:b.name,onChange:k=>w({...b,name:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{children:"Slug (optional)"}),o.jsx(Ae,{value:b.slug,onChange:k=>w({...b,slug:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{children:"Type"}),o.jsxs(Ua,{value:b.type,onValueChange:k=>w({...b,type:k}),children:[o.jsx(Sa,{children:o.jsx(Ba,{})}),o.jsxs(ja,{children:[o.jsx(Rt,{value:"openai",children:"OpenAI-compatible"}),o.jsx(Rt,{value:"anthropic",children:"Anthropic-compatible"})]})]})]}),o.jsxs("div",{children:[o.jsx(we,{children:"Base URL"}),o.jsx(Ae,{value:b.baseUrl,onChange:k=>w({...b,baseUrl:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{children:"API key (leave empty to keep current)"}),o.jsx(Ae,{type:"password",value:b.apiKey,onChange:k=>w({...b,apiKey:k.target.value})})]}),o.jsxs("div",{children:[o.jsx(we,{children:"Custom headers (JSON)"}),o.jsx(Ae,{value:b.customHeaders,onChange:k=>w({...b,customHeaders:k.target.value}),placeholder:'{"X-Org":"acme"}'})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ca,{checked:b.enabled,onCheckedChange:k=>w({...b,enabled:k})}),o.jsx(we,{children:"Enabled"})]})]}),o.jsxs(An,{children:[o.jsx(me,{variant:"outline",onClick:()=>{y(null),w(Al)},children:"Cancel"}),o.jsx(me,{disabled:f||!b.name,onClick:A,children:"Save changes"})]})]})}),o.jsx(up,{open:!!E,onOpenChange:k=>{k||j(null)},children:o.jsxs(Pu,{children:[o.jsxs(dp,{children:[o.jsx(qu,{children:"Delete provider?"}),o.jsx(Vu,{children:"This permanently removes the provider, its models, and dependent routing configuration."})]}),o.jsxs(fp,{children:[o.jsx(Yu,{children:"Cancel"}),o.jsx($u,{disabled:C,onClick:k=>{E&&(k.preventDefault(),U(E))},children:C?"Deleting…":"Delete"})]})]})})]})}var m_=Object.defineProperty,Sr=(n,a)=>m_(n,"name",{value:a,configurable:!0}),bp="Checkbox",[p_,Q4]=kn(bp),[g_,wp]=p_(bp);function Ww(n){const{__scopeCheckbox:a,checked:l,children:s,defaultChecked:c,disabled:u,form:f,name:p,onCheckedChange:g,required:v,value:x="on",internal_do_not_use_render:y}=n,[b,w]=yr({prop:l,defaultProp:c??!1,onChange:g,caller:bp}),[E,j]=m.useState(null),[C,N]=m.useState(null),M=m.useRef(!1),[T,D]=m.useReducer(U=>U+1,0),O=E?!!f||!!E.closest("form"):!0,A={checked:b,disabled:u,setChecked:w,control:E,setControl:j,name:p,form:f,value:x,hasConsumerStoppedPropagationRef:M,userInteractionCount:T,onUserInteraction:D,required:v,defaultChecked:vr(c)?!1:c,isFormControl:O,bubbleInput:C,setBubbleInput:N};return o.jsx(g_,{scope:a,...A,children:tS(y)?y(A):s})}Sr(Ww,"CheckboxProvider");var v_="CheckboxTrigger",x_=m.forwardRef(Sr(function({__scopeCheckbox:a,onKeyDown:l,onClick:s,...c},u){const{control:f,value:p,disabled:g,checked:v,required:x,setControl:y,setChecked:b,hasConsumerStoppedPropagationRef:w,onUserInteraction:E,isFormControl:j,bubbleInput:C}=wp(v_,a),N=Xe(u,y),M=m.useRef(v);return m.useEffect(()=>{const T=f==null?void 0:f.form;if(T){const D=Sr(()=>b(M.current),"reset");return T.addEventListener("reset",D),()=>T.removeEventListener("reset",D)}},[f,b]),o.jsx(Ve.button,{type:"button",role:"checkbox","aria-checked":vr(v)?"mixed":v,"aria-required":x,"data-state":Sp(v),"data-disabled":g?"":void 0,disabled:g,value:p,...c,ref:N,onKeyDown:Ne(l,T=>{T.key==="Enter"&&T.preventDefault()}),onClick:Ne(s,T=>{E(),b(D=>vr(D)?!0:!D),C&&j&&(w.current=T.isPropagationStopped(),w.current||T.stopPropagation())})})},"CheckboxTrigger")),eS=m.forwardRef(Sr(function(a,l){const{__scopeCheckbox:s,name:c,checked:u,defaultChecked:f,required:p,disabled:g,value:v,onCheckedChange:x,form:y,...b}=a;return o.jsx(Ww,{__scopeCheckbox:s,checked:u,defaultChecked:f,disabled:g,required:p,onCheckedChange:x,name:c,form:y,value:v,internal_do_not_use_render:({isFormControl:w})=>o.jsxs(o.Fragment,{children:[o.jsx(x_,{...b,ref:l,__scopeCheckbox:s}),w&&o.jsx(S_,{__scopeCheckbox:s})]})})},"Checkbox")),y_="CheckboxIndicator",b_=m.forwardRef(Sr(function(a,l){const{__scopeCheckbox:s,forceMount:c,...u}=a,f=wp(y_,s);return o.jsx(Cr,{present:c||vr(f.checked)||f.checked===!0,children:o.jsx(Ve.span,{"data-state":Sp(f.checked),"data-disabled":f.disabled?"":void 0,...u,ref:l,style:{pointerEvents:"none",...a.style}})})},"CheckboxIndicator")),w_="CheckboxBubbleInput",S_=m.forwardRef(Sr(function({__scopeCheckbox:a,onClick:l,...s},c){const{control:u,hasConsumerStoppedPropagationRef:f,userInteractionCount:p,checked:g,defaultChecked:v,required:x,disabled:y,name:b,value:w,form:E,bubbleInput:j,setBubbleInput:C}=wp(w_,a),N=Xe(c,C),M=_u(u),T=m.useRef(!1),D=m.useRef(g),O=m.useRef(p);m.useEffect(()=>{const U=j;if(!U)return;const k=window.HTMLInputElement.prototype,X=Object.getOwnPropertyDescriptor(k,"checked").set,te=p!==O.current;O.current=p;const G=D.current!==g;D.current=g;const ie=!(te&&f.current);if(G&&X){T.current=!te;const ce=new Event("click",{bubbles:ie});U.indeterminate=vr(g),X.call(U,vr(g)?!1:g),U.dispatchEvent(ce),T.current=!1}},[j,g,f,p]);const A=m.useRef(vr(g)?!1:g);return o.jsx(Ve.input,{type:"checkbox","aria-hidden":!0,defaultChecked:v??A.current,required:x,disabled:y,name:b,value:w,form:E,...s,tabIndex:-1,ref:N,onClick:Ne(l,U=>{T.current&&U.stopPropagation()}),style:{...s.style,...M,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function tS(n){return typeof n=="function"}Sr(tS,"isFunction");function vr(n){return n==="indeterminate"}Sr(vr,"isIndeterminate");function Sp(n){return vr(n)?"indeterminate":n?"checked":"unchecked"}Sr(Sp,"getState");const jp=m.forwardRef(({className:n,...a},l)=>o.jsx(eS,{ref:l,className:Ee("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",n),...a,children:o.jsx(b_,{className:Ee("flex items-center justify-center text-current"),children:o.jsx(C0,{className:"h-3.5 w-3.5"})})}));jp.displayName=eS.displayName;const um=["image_input","audio_input","tools","structured_output","reasoning","chat","streaming"],j_=["unknown","yes","no"];function C_(n,a){return n[a]===!0?"yes":n[a]===!1?"no":"unknown"}function E_(n){const a={};for(const l of um)a[l]=n[l]==="yes"?!0:n[l]==="no"?!1:null;return a}function R_(){const[n,a]=m.useState([]),[l,s]=m.useState([]),[c,u]=m.useState("all"),[f,p]=m.useState(!1),[g,v]=m.useState(""),[x,y]=m.useState([]),[b,w]=m.useState(new Set),[E,j]=m.useState(!1),[C,N]=m.useState(""),[M,T]=m.useState(""),[D,O]=m.useState(null),[A,U]=m.useState(!1),[k,$]=m.useState(null),[X,te]=m.useState(null),[G,ie]=m.useState(null),[ce,se]=m.useState({}),[_,H]=m.useState(!1),Q=q=>{const oe={};for(const de of um)oe[de]=C_(q.capabilities,de);se(oe),ie(q)},J=async()=>{if(G){H(!0);try{await Se.patch("/api/admin/models",{id:G.id,capabilities:E_(ce)}),ve.success("Capabilities updated"),ie(null),ee()}catch(q){ve.error(q.message)}finally{H(!1)}}},ee=async()=>{const[q,oe]=await Promise.all([Se.get("/api/admin/models"),Se.get("/api/admin/providers")]);a(q.models),s(oe.providers)};m.useEffect(()=>{ee()},[]);const z=n.filter(q=>!(c!=="all"&&q.providerId!==c||C&&!q.publicModelId.toLowerCase().includes(C.toLowerCase()))),I=x.filter(q=>{if(!M)return!0;const oe=M.toLowerCase();return q.upstreamId.toLowerCase().includes(oe)||q.displayName.toLowerCase().includes(oe)}),F=async()=>{if(g){j(!0);try{const q=await Se.post(`/api/admin/providers/${g}/discover`);y(q.models),w(new Set)}catch(q){ve.error(q.message)}finally{j(!1)}}},re=async()=>{if(b.size!==0)try{const q=await Se.post("/api/admin/models/import",{providerId:g,modelIds:Array.from(b)});ve.success(`Imported ${q.imported} of ${q.requested}`),p(!1),y([]),w(new Set),ee()}catch(q){ve.error(q.message)}},he=async()=>{if(X)try{await Se.del(`/api/admin/models/${X.id}`),ve.success("Model deleted"),te(null),ee()}catch(q){ve.error(q.message)}},ge=async q=>{var de,fe,Te;O(q),U(!0);const oe=Date.now();$({phase:"streaming",startedAt:oe,text:"",progress:{}});try{const je=await ru(`/api/admin/models/${q}/test-stream`,{method:"POST",headers:{"content-type":"application/json"},body:"{}"});if(!je.ok){const Ie=await je.text().catch(()=>"");$({phase:"error",model:q,error:`HTTP ${je.status}: ${Ie}`});return}const De=(de=je.body)==null?void 0:de.getReader();if(!De){$({phase:"error",model:q,error:"No response body"});return}const Fe=new TextDecoder;let et="",le="",Le=!1;for(;!Le;){const{value:Ie,done:kt}=await De.read();Le=kt,Ie&&(et+=Fe.decode(Ie,{stream:!0}));let St;for(;(St=et.indexOf(`
|
|
342
342
|
|
|
343
343
|
`))>=0;){const Ft=et.slice(0,St);et=et.slice(St+2);const on=Ft.split(`
|
|
344
|
-
`);let Qt="",jt="";for(const fn of on)fn.startsWith("event: ")?Qt=fn.slice(7):fn.startsWith("data: ")&&(jt=fn.slice(6));if(jt){if(Qt===""||Qt==="message")try{const Mt=(fe=JSON.parse(jt).choices)==null?void 0:fe[0];(Te=Mt==null?void 0:Mt.delta)!=null&&Te.content&&(le+=Mt.delta.content),$(At=>{if(!At||At.phase!=="streaming")return At;const cn=Date.now()-oe,fa=At.progress.ttftMs??cn;return{...At,text:le,progress:{ttftMs:fa,elapsedMs:cn}}})}catch{}if(Qt==="test_meta")try{const fn=JSON.parse(jt);$({phase:"done",model:q,result:fn,text:le})}catch{}if(Qt==="test_error")try{const fn=JSON.parse(jt);$({phase:"error",model:q,error:fn.message})}catch{}}}}$(Ie=>!Ie||Ie.phase==="streaming"?{phase:"error",model:q,error:"Stream ended unexpectedly"}:Ie)}catch(je){$({phase:"error",model:q,error:je.message})}finally{O(null)}};return o.jsxs("div",{children:[o.jsx($a,{title:"Models",description:"Physical models imported from providers",actions:o.jsxs(Mn,{open:f,onOpenChange:p,children:[o.jsx(mi,{asChild:!0,children:o.jsxs(me,{variant:"outline",children:[o.jsx(E0,{className:"mr-1 h-4 w-4"})," Fetch models"]})}),o.jsxs(vn,{className:"max-w-2xl",children:[o.jsx(xn,{children:o.jsx(yn,{children:"Discover models"})}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-end gap-2",children:[o.jsx("div",{className:"flex-1",children:o.jsxs(Ua,{value:g,onValueChange:v,children:[o.jsx(Sa,{children:o.jsx(Ba,{placeholder:"Choose provider"})}),o.jsx(ja,{children:l.map(q=>o.jsx(Rt,{value:q.id,children:q.name},q.id))})]})}),o.jsx(me,{onClick:F,disabled:!g||E,children:E?"Fetching…":"Fetch"})]}),x.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("div",{className:"flex items-center gap-2 flex-1",children:o.jsxs("div",{className:"relative flex-1",children:[o.jsx(D0,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(Ae,{className:"pl-8",placeholder:"Search models…",value:M,onChange:q=>T(q.target.value)}),M&&o.jsx("button",{className:"absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",onClick:()=>T(""),children:o.jsx(Cu,{className:"h-4 w-4"})})]})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:"text-sm text-muted-foreground",children:[I.length," / ",x.length," · ",b.size," selected"]}),o.jsx(me,{variant:"outline",size:"sm",onClick:()=>w(new Set(I.filter(q=>!q.alreadyImported).map(q=>q.upstreamId))),children:"Select All (new)"}),o.jsx(me,{variant:"outline",size:"sm",onClick:()=>w(new Set),children:"Clear"})]})]}),o.jsx("div",{className:"max-h-80 space-y-1 overflow-auto rounded border p-2",children:I.length===0&&x.length>0?o.jsx("div",{className:"text-center text-sm text-muted-foreground py-4",children:"No models match your search."}):I.map(q=>o.jsxs("label",{className:"flex items-center gap-2 rounded p-1 text-sm hover:bg-accent",children:[o.jsx(jp,{checked:b.has(q.upstreamId),onCheckedChange:oe=>{const de=new Set(b);oe?de.add(q.upstreamId):de.delete(q.upstreamId),w(de)}}),o.jsx("span",{className:"font-mono text-xs",children:q.upstreamId}),q.alreadyImported&&o.jsx(Qe,{variant:"secondary",children:"imported"})]},q.upstreamId))})]})]}),o.jsxs(An,{children:[o.jsx(me,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),o.jsxs(me,{disabled:b.size===0,onClick:re,children:["Import ",b.size||""]})]})]})]})}),o.jsxs(nt,{children:[o.jsxs(at,{children:[o.jsx(rt,{className:"text-base",children:"All models"}),o.jsxs(gn,{children:[n.length," total"]})]}),o.jsxs(lt,{children:[o.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[o.jsxs(Ua,{value:c,onValueChange:u,children:[o.jsx(Sa,{className:"w-56",children:o.jsx(Ba,{})}),o.jsxs(ja,{children:[o.jsx(Rt,{value:"all",children:"All providers"}),l.map(q=>o.jsx(Rt,{value:q.id,children:q.name},q.id))]})]}),o.jsx(Ae,{className:"max-w-xs",placeholder:"Search public ID",value:C,onChange:q=>N(q.target.value)})]}),o.jsxs(ca,{children:[o.jsx(ua,{children:o.jsxs(We,{children:[o.jsx(ye,{children:"Public ID"}),o.jsx(ye,{children:"Provider"}),o.jsx(ye,{children:"Upstream ID"}),o.jsx(ye,{children:"Capabilities"}),o.jsx(ye,{children:"Available"}),o.jsx(ye,{children:"Enabled"}),o.jsx(ye,{})]})}),o.jsxs(da,{children:[z.length===0&&o.jsx(We,{children:o.jsx(pe,{colSpan:7,className:"text-center text-muted-foreground",children:"No models"})}),z.map(q=>o.jsxs(We,{children:[o.jsx(pe,{className:"font-mono text-xs",children:q.publicModelId}),o.jsx(pe,{children:q.providerSlug}),o.jsx(pe,{className:"text-xs text-muted-foreground",children:q.upstreamModelId}),o.jsx(pe,{className:"space-x-1",children:Object.entries(q.capabilities).filter(([,oe])=>oe===!0).slice(0,4).map(([oe])=>o.jsx(Qe,{variant:"outline",className:"mr-1",children:oe},oe))}),o.jsx(pe,{children:q.upstreamAvailable?o.jsx(Qe,{variant:"success",children:"up"}):o.jsx(Qe,{variant:"destructive",children:"down"})}),o.jsx(pe,{children:q.enabled?"Yes":"No"}),o.jsx(pe,{className:"text-right",children:o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[o.jsxs(me,{size:"sm",variant:"outline",onClick:()=>Q(q),disabled:D!==null,children:[o.jsx(vR,{className:"h-3.5 w-3.5"})," Capabilities"]}),o.jsxs(me,{size:"sm",variant:"outline",onClick:()=>void ge(q.id),disabled:D!==null,children:[D===q.id?o.jsx(_s,{className:"h-3.5 w-3.5 animate-spin"}):o.jsx(iR,{className:"h-3.5 w-3.5"})," Test"]}),o.jsxs(me,{size:"sm",variant:"destructive",onClick:()=>te(q),disabled:D!==null,children:[o.jsx(ju,{className:"h-3.5 w-3.5"})," Xoá"]})]})})]},q.id))]})]})]})]}),o.jsx(Mn,{open:!!X,onOpenChange:q=>{q||te(null)},children:o.jsxs(vn,{className:"max-w-md",children:[o.jsx(xn,{children:o.jsx(yn,{children:"Xoá model"})}),o.jsxs("div",{className:"space-y-2 text-sm",children:[o.jsxs("p",{children:["Bạn có chắc muốn xoá model ",o.jsx("span",{className:"font-mono",children:X==null?void 0:X.publicModelId}),"?"]}),o.jsx("p",{className:"text-muted-foreground",children:"Model đang được dùng trong combo sẽ bị soft-disable (vô hiệu hoá) thay vì xoá hẳn, để giữ lịch sử và tham chiếu combo."})]}),o.jsxs(An,{children:[o.jsx(me,{variant:"outline",onClick:()=>te(null),children:"Huỷ"}),o.jsx(me,{variant:"destructive",onClick:he,children:"Xoá"})]})]})}),o.jsx(Mn,{open:G!==null,onOpenChange:q=>{q||ie(null)},children:o.jsxs(vn,{className:"max-w-lg",children:[o.jsx(xn,{children:o.jsxs(yn,{children:["Capabilities — ",G==null?void 0:G.publicModelId]})}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("p",{className:"text-xs text-muted-foreground",children:[o.jsx("strong",{children:"Unknown"})," means the router has no verified answer and will attempt the request."," ",o.jsx("strong",{children:"No"})," blocks requests needing that capability (HTTP 400/502 before any upstream call)."]}),um.map(q=>{var de;const oe=(de=G==null?void 0:G.discoveredCapabilities)==null?void 0:de[q];return o.jsxs("div",{className:"flex items-center justify-between gap-3 rounded px-1 py-1 text-sm hover:bg-accent",children:[o.jsxs("span",{className:"flex items-baseline gap-2",children:[o.jsx("code",{className:"text-xs",children:q}),o.jsx("span",{className:"text-xs text-muted-foreground",children:oe===void 0?"discovered: unknown":`discovered: ${String(oe)}`})]}),o.jsx("div",{className:"flex gap-1",children:j_.map(fe=>o.jsx(me,{size:"sm",variant:ce[q]===fe?"default":"outline",onClick:()=>se(Te=>({...Te,[q]:fe})),children:fe==="unknown"?"Unknown":fe==="yes"?"Yes":"No"},fe))})]},q)})]}),o.jsxs(An,{children:[o.jsx(me,{variant:"outline",onClick:()=>ie(null),children:"Huỷ"}),o.jsx(me,{onClick:J,disabled:_,children:_?"Saving…":"Lưu"})]})]})}),o.jsx(Mn,{open:A,onOpenChange:U,children:o.jsxs(vn,{className:"max-w-2xl",children:[o.jsx(xn,{children:o.jsx(yn,{children:"Kết quả test model"})}),k&&k.phase==="streaming"&&o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[o.jsx(_s,{className:"h-4 w-4 animate-spin"})," Đang stream…",o.jsxs("span",{className:"font-mono text-xs text-muted-foreground/60",children:["TTFT ",k.progress.ttftMs!=null?`${k.progress.ttftMs} ms`:"…"]}),o.jsxs("span",{className:"font-mono text-xs text-muted-foreground/60",children:["· ",k.progress.elapsedMs!=null?`${k.progress.elapsedMs} ms`:"…"]})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Phản hồi (streaming)"}),o.jsxs("div",{className:"max-h-60 overflow-auto whitespace-pre-wrap rounded border bg-muted p-3 font-mono text-xs",children:[k.text||o.jsx("span",{className:"text-muted-foreground/60 animate-pulse",children:"waiting for first token…"}),k.phase==="streaming"&&o.jsx("span",{className:"ml-0.5 inline-block h-3.5 w-1.5 animate-pulse bg-primary/70"})]})]})]}),k&&k.phase==="done"&&o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsx(Qe,{variant:k.result.success?"success":"destructive",children:k.result.success?"Thành công":"Thất bại"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-xs text-muted-foreground",children:"Thời gian phản hồi"}),o.jsxs("div",{className:"font-mono",children:[k.result.latencyMs," ms"]})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-xs text-muted-foreground",children:"TTFT"}),o.jsx("div",{className:"font-mono",children:k.result.ttftMs!=null?`${k.result.ttftMs} ms`:"—"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-xs text-muted-foreground",children:"Tokens (in / out)"}),o.jsxs("div",{className:"font-mono",children:[k.result.usage.input," / ",k.result.usage.output]})]})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Phản hồi của model"}),o.jsx("div",{className:"max-h-60 overflow-auto whitespace-pre-wrap rounded border bg-muted p-3 font-mono text-xs",children:k.text||k.result.text||"(trống)"})]}),k.result.attempts.length>0&&o.jsxs("div",{children:[o.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Attempts"}),o.jsx("div",{className:"space-y-1",children:k.result.attempts.map((q,oe)=>o.jsxs("div",{className:"flex items-center gap-2 rounded border p-2 text-xs",children:[o.jsx(Qe,{variant:q.success?"success":"destructive",children:q.success?"OK":"FAIL"}),o.jsxs("span",{className:"font-mono",children:[q.providerName," / ",q.modelId]}),o.jsxs("span",{className:"text-muted-foreground",children:[q.latencyMs," ms"]}),q.failureReason&&o.jsx("span",{className:"text-destructive",children:q.failureReason})]},oe))})]})]}),k&&k.phase==="error"&&o.jsxs("div",{className:"space-y-2 text-sm",children:[o.jsx(Qe,{variant:"destructive",children:"Thất bại"}),o.jsx("p",{className:"text-destructive",children:k.error})]}),o.jsx(An,{children:o.jsx(me,{variant:"outline",onClick:()=>U(!1),children:"Đóng"})})]})})]})}function N_(){for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return m.useMemo(()=>s=>{a.forEach(c=>c(s))},a)}const Xu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Xs(n){const a=Object.prototype.toString.call(n);return a==="[object Window]"||a==="[object global]"}function Cp(n){return"nodeType"in n}function zn(n){var a,l;return n?Xs(n)?n:Cp(n)&&(a=(l=n.ownerDocument)==null?void 0:l.defaultView)!=null?a:window:window}function Ep(n){const{Document:a}=zn(n);return n instanceof a}function gi(n){return Xs(n)?!1:n instanceof zn(n).HTMLElement}function nS(n){return n instanceof zn(n).SVGElement}function Fs(n){return n?Xs(n)?n.document:Cp(n)?Ep(n)?n:gi(n)||nS(n)?n.ownerDocument:document:document:document}const qa=Xu?m.useLayoutEffect:m.useEffect;function Rp(n){const a=m.useRef(n);return qa(()=>{a.current=n}),m.useCallback(function(){for(var l=arguments.length,s=new Array(l),c=0;c<l;c++)s[c]=arguments[c];return a.current==null?void 0:a.current(...s)},[])}function T_(){const n=m.useRef(null),a=m.useCallback((s,c)=>{n.current=setInterval(s,c)},[]),l=m.useCallback(()=>{n.current!==null&&(clearInterval(n.current),n.current=null)},[]);return[a,l]}function ti(n,a){a===void 0&&(a=[n]);const l=m.useRef(n);return qa(()=>{l.current!==n&&(l.current=n)},a),l}function vi(n,a){const l=m.useRef();return m.useMemo(()=>{const s=n(l.current);return l.current=s,s},[...a])}function du(n){const a=Rp(n),l=m.useRef(null),s=m.useCallback(c=>{c!==l.current&&(a==null||a(c,l.current)),l.current=c},[]);return[l,s]}function dm(n){const a=m.useRef();return m.useEffect(()=>{a.current=n},[n]),a.current}let _h={};function xi(n,a){return m.useMemo(()=>{if(a)return a;const l=_h[n]==null?0:_h[n]+1;return _h[n]=l,n+"-"+l},[n,a])}function aS(n){return function(a){for(var l=arguments.length,s=new Array(l>1?l-1:0),c=1;c<l;c++)s[c-1]=arguments[c];return s.reduce((u,f)=>{const p=Object.entries(f);for(const[g,v]of p){const x=u[g];x!=null&&(u[g]=x+n*v)}return u},{...a})}}const Us=aS(1),ni=aS(-1);function M_(n){return"clientX"in n&&"clientY"in n}function Np(n){if(!n)return!1;const{KeyboardEvent:a}=zn(n.target);return a&&n instanceof a}function A_(n){if(!n)return!1;const{TouchEvent:a}=zn(n.target);return a&&n instanceof a}function fm(n){if(A_(n)){if(n.touches&&n.touches.length){const{clientX:a,clientY:l}=n.touches[0];return{x:a,y:l}}else if(n.changedTouches&&n.changedTouches.length){const{clientX:a,clientY:l}=n.changedTouches[0];return{x:a,y:l}}}return M_(n)?{x:n.clientX,y:n.clientY}:null}const fu=Object.freeze({Translate:{toString(n){if(!n)return;const{x:a,y:l}=n;return"translate3d("+(a?Math.round(a):0)+"px, "+(l?Math.round(l):0)+"px, 0)"}},Scale:{toString(n){if(!n)return;const{scaleX:a,scaleY:l}=n;return"scaleX("+a+") scaleY("+l+")"}},Transform:{toString(n){if(n)return[fu.Translate.toString(n),fu.Scale.toString(n)].join(" ")}},Transition:{toString(n){let{property:a,duration:l,easing:s}=n;return a+" "+l+"ms "+s}}}),Tb="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function D_(n){return n.matches(Tb)?n:n.querySelector(Tb)}const O_={display:"none"};function __(n){let{id:a,value:l}=n;return ue.createElement("div",{id:a,style:O_},l)}function k_(n){let{id:a,announcement:l,ariaLiveType:s="assertive"}=n;const c={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ue.createElement("div",{id:a,style:c,role:"status","aria-live":s,"aria-atomic":!0},l)}function z_(){const[n,a]=m.useState("");return{announce:m.useCallback(s=>{s!=null&&a(s)},[]),announcement:n}}const rS=m.createContext(null);function L_(n){const a=m.useContext(rS);m.useEffect(()=>{if(!a)throw new Error("useDndMonitor must be used within a children of <DndContext>");return a(n)},[n,a])}function U_(){const[n]=m.useState(()=>new Set),a=m.useCallback(s=>(n.add(s),()=>n.delete(s)),[n]);return[m.useCallback(s=>{let{type:c,event:u}=s;n.forEach(f=>{var p;return(p=f[c])==null?void 0:p.call(f,u)})},[n]),a]}const B_={draggable:`
|
|
344
|
+
`);let Qt="",jt="";for(const fn of on)fn.startsWith("event: ")?Qt=fn.slice(7):fn.startsWith("data: ")&&(jt=fn.slice(6));if(jt){if(Qt===""||Qt==="message")try{const Mt=(fe=JSON.parse(jt).choices)==null?void 0:fe[0];(Te=Mt==null?void 0:Mt.delta)!=null&&Te.content&&(le+=Mt.delta.content),$(At=>{if(!At||At.phase!=="streaming")return At;const cn=Date.now()-oe,fa=At.progress.ttftMs??cn;return{...At,text:le,progress:{ttftMs:fa,elapsedMs:cn}}})}catch{}if(Qt==="test_meta")try{const fn=JSON.parse(jt);$({phase:"done",model:q,result:fn,text:le})}catch{}if(Qt==="test_error")try{const fn=JSON.parse(jt);$({phase:"error",model:q,error:fn.message})}catch{}}}}$(Ie=>!Ie||Ie.phase==="streaming"?{phase:"error",model:q,error:"Stream ended unexpectedly"}:Ie)}catch(je){$({phase:"error",model:q,error:je.message})}finally{O(null)}};return o.jsxs("div",{children:[o.jsx($a,{title:"Models",description:"Physical models imported from providers",actions:o.jsxs(Mn,{open:f,onOpenChange:p,children:[o.jsx(mi,{asChild:!0,children:o.jsxs(me,{variant:"outline",children:[o.jsx(E0,{className:"mr-1 h-4 w-4"})," Fetch models"]})}),o.jsxs(vn,{className:"max-w-2xl",children:[o.jsx(xn,{children:o.jsx(yn,{children:"Discover models"})}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-end gap-2",children:[o.jsx("div",{className:"flex-1",children:o.jsxs(Ua,{value:g,onValueChange:v,children:[o.jsx(Sa,{children:o.jsx(Ba,{placeholder:"Choose provider"})}),o.jsx(ja,{children:l.map(q=>o.jsx(Rt,{value:q.id,children:q.name},q.id))})]})}),o.jsx(me,{onClick:F,disabled:!g||E,children:E?"Fetching…":"Fetch"})]}),x.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("div",{className:"flex items-center gap-2 flex-1",children:o.jsxs("div",{className:"relative flex-1",children:[o.jsx(D0,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(Ae,{className:"pl-8",placeholder:"Search models…",value:M,onChange:q=>T(q.target.value)}),M&&o.jsx("button",{className:"absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",onClick:()=>T(""),children:o.jsx(Cu,{className:"h-4 w-4"})})]})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:"text-sm text-muted-foreground",children:[I.length," / ",x.length," · ",b.size," selected"]}),o.jsx(me,{variant:"outline",size:"sm",onClick:()=>w(new Set(I.filter(q=>!q.alreadyImported).map(q=>q.upstreamId))),children:"Select All (new)"}),o.jsx(me,{variant:"outline",size:"sm",onClick:()=>w(new Set),children:"Clear"})]})]}),o.jsx("div",{className:"max-h-80 space-y-1 overflow-auto rounded border p-2",children:I.length===0&&x.length>0?o.jsx("div",{className:"text-center text-sm text-muted-foreground py-4",children:"No models match your search."}):I.map(q=>o.jsxs("label",{className:"flex items-center gap-2 rounded p-1 text-sm hover:bg-accent",children:[o.jsx(jp,{checked:b.has(q.upstreamId),onCheckedChange:oe=>{const de=new Set(b);oe?de.add(q.upstreamId):de.delete(q.upstreamId),w(de)}}),o.jsx("span",{className:"font-mono text-xs",children:q.upstreamId}),q.alreadyImported&&o.jsx(Qe,{variant:"secondary",children:"imported"})]},q.upstreamId))})]})]}),o.jsxs(An,{children:[o.jsx(me,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),o.jsxs(me,{disabled:b.size===0,onClick:re,children:["Import ",b.size||""]})]})]})]})}),o.jsxs(nt,{children:[o.jsxs(at,{children:[o.jsx(rt,{className:"text-base",children:"All models"}),o.jsxs(gn,{children:[n.length," total"]})]}),o.jsxs(lt,{children:[o.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[o.jsxs(Ua,{value:c,onValueChange:u,children:[o.jsx(Sa,{className:"w-56",children:o.jsx(Ba,{})}),o.jsxs(ja,{children:[o.jsx(Rt,{value:"all",children:"All providers"}),l.map(q=>o.jsx(Rt,{value:q.id,children:q.name},q.id))]})]}),o.jsx(Ae,{className:"max-w-xs",placeholder:"Search public ID",value:C,onChange:q=>N(q.target.value)})]}),o.jsxs(ca,{children:[o.jsx(ua,{children:o.jsxs(We,{children:[o.jsx(ye,{children:"Public ID"}),o.jsx(ye,{children:"Provider"}),o.jsx(ye,{children:"Upstream ID"}),o.jsx(ye,{children:"Capabilities"}),o.jsx(ye,{children:"Available"}),o.jsx(ye,{children:"Enabled"}),o.jsx(ye,{})]})}),o.jsxs(da,{children:[z.length===0&&o.jsx(We,{children:o.jsx(pe,{colSpan:7,className:"text-center text-muted-foreground",children:"No models"})}),z.map(q=>o.jsxs(We,{children:[o.jsx(pe,{className:"font-mono text-xs",children:q.publicModelId}),o.jsx(pe,{children:q.providerSlug}),o.jsx(pe,{className:"text-xs text-muted-foreground",children:q.upstreamModelId}),o.jsx(pe,{className:"space-x-1",children:Object.entries(q.capabilities).filter(([,oe])=>oe===!0).slice(0,4).map(([oe])=>o.jsx(Qe,{variant:"outline",className:"mr-1",children:oe},oe))}),o.jsx(pe,{children:q.upstreamAvailable?o.jsx(Qe,{variant:"success",children:"up"}):o.jsx(Qe,{variant:"destructive",children:"down"})}),o.jsx(pe,{children:q.enabled?"Yes":"No"}),o.jsx(pe,{className:"text-right",children:o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[o.jsxs(me,{size:"sm",variant:"outline",onClick:()=>Q(q),disabled:D!==null,children:[o.jsx(vR,{className:"h-3.5 w-3.5"})," Capabilities"]}),o.jsxs(me,{size:"sm",variant:"outline",onClick:()=>void ge(q.id),disabled:D!==null,children:[D===q.id?o.jsx(_s,{className:"h-3.5 w-3.5 animate-spin"}):o.jsx(iR,{className:"h-3.5 w-3.5"})," Test"]}),o.jsxs(me,{size:"sm",variant:"destructive",onClick:()=>te(q),disabled:D!==null,children:[o.jsx(ju,{className:"h-3.5 w-3.5"})," Xoá"]})]})})]},q.id))]})]})]})]}),o.jsx(Mn,{open:!!X,onOpenChange:q=>{q||te(null)},children:o.jsxs(vn,{className:"max-w-md",children:[o.jsx(xn,{children:o.jsx(yn,{children:"Xoá model"})}),o.jsxs("div",{className:"space-y-2 text-sm",children:[o.jsxs("p",{children:["Bạn có chắc muốn xoá model ",o.jsx("span",{className:"font-mono",children:X==null?void 0:X.publicModelId}),"?"]}),o.jsx("p",{className:"text-muted-foreground",children:"Model sẽ bị xoá khỏi combo, alias, permission và cache trước khi xoá hẳn."})]}),o.jsxs(An,{children:[o.jsx(me,{variant:"outline",onClick:()=>te(null),children:"Huỷ"}),o.jsx(me,{variant:"destructive",onClick:he,children:"Xoá"})]})]})}),o.jsx(Mn,{open:G!==null,onOpenChange:q=>{q||ie(null)},children:o.jsxs(vn,{className:"max-w-lg",children:[o.jsx(xn,{children:o.jsxs(yn,{children:["Capabilities — ",G==null?void 0:G.publicModelId]})}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("p",{className:"text-xs text-muted-foreground",children:[o.jsx("strong",{children:"Unknown"})," means the router has no verified answer and will attempt the request."," ",o.jsx("strong",{children:"No"})," blocks requests needing that capability (HTTP 400/502 before any upstream call)."]}),um.map(q=>{var de;const oe=(de=G==null?void 0:G.discoveredCapabilities)==null?void 0:de[q];return o.jsxs("div",{className:"flex items-center justify-between gap-3 rounded px-1 py-1 text-sm hover:bg-accent",children:[o.jsxs("span",{className:"flex items-baseline gap-2",children:[o.jsx("code",{className:"text-xs",children:q}),o.jsx("span",{className:"text-xs text-muted-foreground",children:oe===void 0?"discovered: unknown":`discovered: ${String(oe)}`})]}),o.jsx("div",{className:"flex gap-1",children:j_.map(fe=>o.jsx(me,{size:"sm",variant:ce[q]===fe?"default":"outline",onClick:()=>se(Te=>({...Te,[q]:fe})),children:fe==="unknown"?"Unknown":fe==="yes"?"Yes":"No"},fe))})]},q)})]}),o.jsxs(An,{children:[o.jsx(me,{variant:"outline",onClick:()=>ie(null),children:"Huỷ"}),o.jsx(me,{onClick:J,disabled:_,children:_?"Saving…":"Lưu"})]})]})}),o.jsx(Mn,{open:A,onOpenChange:U,children:o.jsxs(vn,{className:"max-w-2xl",children:[o.jsx(xn,{children:o.jsx(yn,{children:"Kết quả test model"})}),k&&k.phase==="streaming"&&o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[o.jsx(_s,{className:"h-4 w-4 animate-spin"})," Đang stream…",o.jsxs("span",{className:"font-mono text-xs text-muted-foreground/60",children:["TTFT ",k.progress.ttftMs!=null?`${k.progress.ttftMs} ms`:"…"]}),o.jsxs("span",{className:"font-mono text-xs text-muted-foreground/60",children:["· ",k.progress.elapsedMs!=null?`${k.progress.elapsedMs} ms`:"…"]})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Phản hồi (streaming)"}),o.jsxs("div",{className:"max-h-60 overflow-auto whitespace-pre-wrap rounded border bg-muted p-3 font-mono text-xs",children:[k.text||o.jsx("span",{className:"text-muted-foreground/60 animate-pulse",children:"waiting for first token…"}),k.phase==="streaming"&&o.jsx("span",{className:"ml-0.5 inline-block h-3.5 w-1.5 animate-pulse bg-primary/70"})]})]})]}),k&&k.phase==="done"&&o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsx(Qe,{variant:k.result.success?"success":"destructive",children:k.result.success?"Thành công":"Thất bại"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-xs text-muted-foreground",children:"Thời gian phản hồi"}),o.jsxs("div",{className:"font-mono",children:[k.result.latencyMs," ms"]})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-xs text-muted-foreground",children:"TTFT"}),o.jsx("div",{className:"font-mono",children:k.result.ttftMs!=null?`${k.result.ttftMs} ms`:"—"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-xs text-muted-foreground",children:"Tokens (in / out)"}),o.jsxs("div",{className:"font-mono",children:[k.result.usage.input," / ",k.result.usage.output]})]})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Phản hồi của model"}),o.jsx("div",{className:"max-h-60 overflow-auto whitespace-pre-wrap rounded border bg-muted p-3 font-mono text-xs",children:k.text||k.result.text||"(trống)"})]}),k.result.attempts.length>0&&o.jsxs("div",{children:[o.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Attempts"}),o.jsx("div",{className:"space-y-1",children:k.result.attempts.map((q,oe)=>o.jsxs("div",{className:"flex items-center gap-2 rounded border p-2 text-xs",children:[o.jsx(Qe,{variant:q.success?"success":"destructive",children:q.success?"OK":"FAIL"}),o.jsxs("span",{className:"font-mono",children:[q.providerName," / ",q.modelId]}),o.jsxs("span",{className:"text-muted-foreground",children:[q.latencyMs," ms"]}),q.failureReason&&o.jsx("span",{className:"text-destructive",children:q.failureReason})]},oe))})]})]}),k&&k.phase==="error"&&o.jsxs("div",{className:"space-y-2 text-sm",children:[o.jsx(Qe,{variant:"destructive",children:"Thất bại"}),o.jsx("p",{className:"text-destructive",children:k.error})]}),o.jsx(An,{children:o.jsx(me,{variant:"outline",onClick:()=>U(!1),children:"Đóng"})})]})})]})}function N_(){for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return m.useMemo(()=>s=>{a.forEach(c=>c(s))},a)}const Xu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Xs(n){const a=Object.prototype.toString.call(n);return a==="[object Window]"||a==="[object global]"}function Cp(n){return"nodeType"in n}function zn(n){var a,l;return n?Xs(n)?n:Cp(n)&&(a=(l=n.ownerDocument)==null?void 0:l.defaultView)!=null?a:window:window}function Ep(n){const{Document:a}=zn(n);return n instanceof a}function gi(n){return Xs(n)?!1:n instanceof zn(n).HTMLElement}function nS(n){return n instanceof zn(n).SVGElement}function Fs(n){return n?Xs(n)?n.document:Cp(n)?Ep(n)?n:gi(n)||nS(n)?n.ownerDocument:document:document:document}const qa=Xu?m.useLayoutEffect:m.useEffect;function Rp(n){const a=m.useRef(n);return qa(()=>{a.current=n}),m.useCallback(function(){for(var l=arguments.length,s=new Array(l),c=0;c<l;c++)s[c]=arguments[c];return a.current==null?void 0:a.current(...s)},[])}function T_(){const n=m.useRef(null),a=m.useCallback((s,c)=>{n.current=setInterval(s,c)},[]),l=m.useCallback(()=>{n.current!==null&&(clearInterval(n.current),n.current=null)},[]);return[a,l]}function ti(n,a){a===void 0&&(a=[n]);const l=m.useRef(n);return qa(()=>{l.current!==n&&(l.current=n)},a),l}function vi(n,a){const l=m.useRef();return m.useMemo(()=>{const s=n(l.current);return l.current=s,s},[...a])}function du(n){const a=Rp(n),l=m.useRef(null),s=m.useCallback(c=>{c!==l.current&&(a==null||a(c,l.current)),l.current=c},[]);return[l,s]}function dm(n){const a=m.useRef();return m.useEffect(()=>{a.current=n},[n]),a.current}let _h={};function xi(n,a){return m.useMemo(()=>{if(a)return a;const l=_h[n]==null?0:_h[n]+1;return _h[n]=l,n+"-"+l},[n,a])}function aS(n){return function(a){for(var l=arguments.length,s=new Array(l>1?l-1:0),c=1;c<l;c++)s[c-1]=arguments[c];return s.reduce((u,f)=>{const p=Object.entries(f);for(const[g,v]of p){const x=u[g];x!=null&&(u[g]=x+n*v)}return u},{...a})}}const Us=aS(1),ni=aS(-1);function M_(n){return"clientX"in n&&"clientY"in n}function Np(n){if(!n)return!1;const{KeyboardEvent:a}=zn(n.target);return a&&n instanceof a}function A_(n){if(!n)return!1;const{TouchEvent:a}=zn(n.target);return a&&n instanceof a}function fm(n){if(A_(n)){if(n.touches&&n.touches.length){const{clientX:a,clientY:l}=n.touches[0];return{x:a,y:l}}else if(n.changedTouches&&n.changedTouches.length){const{clientX:a,clientY:l}=n.changedTouches[0];return{x:a,y:l}}}return M_(n)?{x:n.clientX,y:n.clientY}:null}const fu=Object.freeze({Translate:{toString(n){if(!n)return;const{x:a,y:l}=n;return"translate3d("+(a?Math.round(a):0)+"px, "+(l?Math.round(l):0)+"px, 0)"}},Scale:{toString(n){if(!n)return;const{scaleX:a,scaleY:l}=n;return"scaleX("+a+") scaleY("+l+")"}},Transform:{toString(n){if(n)return[fu.Translate.toString(n),fu.Scale.toString(n)].join(" ")}},Transition:{toString(n){let{property:a,duration:l,easing:s}=n;return a+" "+l+"ms "+s}}}),Tb="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function D_(n){return n.matches(Tb)?n:n.querySelector(Tb)}const O_={display:"none"};function __(n){let{id:a,value:l}=n;return ue.createElement("div",{id:a,style:O_},l)}function k_(n){let{id:a,announcement:l,ariaLiveType:s="assertive"}=n;const c={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ue.createElement("div",{id:a,style:c,role:"status","aria-live":s,"aria-atomic":!0},l)}function z_(){const[n,a]=m.useState("");return{announce:m.useCallback(s=>{s!=null&&a(s)},[]),announcement:n}}const rS=m.createContext(null);function L_(n){const a=m.useContext(rS);m.useEffect(()=>{if(!a)throw new Error("useDndMonitor must be used within a children of <DndContext>");return a(n)},[n,a])}function U_(){const[n]=m.useState(()=>new Set),a=m.useCallback(s=>(n.add(s),()=>n.delete(s)),[n]);return[m.useCallback(s=>{let{type:c,event:u}=s;n.forEach(f=>{var p;return(p=f[c])==null?void 0:p.call(f,u)})},[n]),a]}const B_={draggable:`
|
|
345
345
|
To pick up a draggable item, press the space bar.
|
|
346
346
|
While dragging, use the arrow keys to move the item.
|
|
347
347
|
Press space again to drop the item in its new position, or press escape to cancel.
|
package/dist/web/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<meta name="color-scheme" content="light dark" />
|
|
8
8
|
<title>LateDev Router</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-DYrnLQwk.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/index-n9bGQMSj.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|