@chenpu17/cc-gw 0.5.0 → 0.5.1

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.
Files changed (21) hide show
  1. package/package.json +1 -1
  2. package/src/server/dist/index.js +101 -78
  3. package/src/web/dist/assets/{About-DK242vw9.js → About-R4GuiAOC.js} +2 -2
  4. package/src/web/dist/assets/{ApiKeys-BGROxK6-.js → ApiKeys-CNNwIRTy.js} +1 -1
  5. package/src/web/dist/assets/{Button-Bnnxe9ep.js → Button-CgdNhVeu.js} +1 -1
  6. package/src/web/dist/assets/{Dashboard-B7zokimB.js → Dashboard-U1EC6qmF.js} +1 -1
  7. package/src/web/dist/assets/{FormField-BzT4FGj8.js → FormField-DJjnoGU0.js} +1 -1
  8. package/src/web/dist/assets/{Help-CJooSMdJ.js → Help-COAfsR6K.js} +1 -1
  9. package/src/web/dist/assets/{Input-B-P-J4xQ.js → Input-CkTJl-fF.js} +1 -1
  10. package/src/web/dist/assets/{Login-B9RgxiYX.js → Login-BbRStE3M.js} +1 -1
  11. package/src/web/dist/assets/{Logs-CsJCTftU.js → Logs-C-7diPqf.js} +1 -1
  12. package/src/web/dist/assets/{ModelManagement-dDhNa_5z.js → ModelManagement-BWX0w6Wu.js} +1 -1
  13. package/src/web/dist/assets/{PageSection-Dzvd3cKD.js → PageSection-BT-depe5.js} +1 -1
  14. package/src/web/dist/assets/{Settings-BcMQ79b0.js → Settings-CLM0Srx1.js} +1 -1
  15. package/src/web/dist/assets/{StatusBadge-CAkVtC--.js → StatusBadge-CgBAXD_S.js} +1 -1
  16. package/src/web/dist/assets/{copy-D6cuJHzh.js → copy-OD9YQ85H.js} +1 -1
  17. package/src/web/dist/assets/{index-agm-2asf.js → index-3UByifOG.js} +2 -2
  18. package/src/web/dist/assets/{index-Cm-hZvRJ.js → index-DVBy-Kka.js} +1 -1
  19. package/src/web/dist/assets/{info-CfAuBePJ.js → info-DAG4KwRm.js} +1 -1
  20. package/src/web/dist/assets/{useApiQuery-ns68sM2H.js → useApiQuery-7KXAW9hB.js} +1 -1
  21. package/src/web/dist/index.html +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chenpu17/cc-gw",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -12253,8 +12253,8 @@ async function registerMessagesRoute(app) {
12253
12253
  if (providerType === "anthropic") {
12254
12254
  let inputTokens2 = json.usage?.input_tokens ?? 0;
12255
12255
  let outputTokens2 = json.usage?.output_tokens ?? 0;
12256
- const cached2 = resolveCachedTokens(json.usage);
12257
- const cachedTokens2 = cached2.read + cached2.creation;
12256
+ const cached3 = resolveCachedTokens(json.usage);
12257
+ const cachedTokens3 = cached3.read + cached3.creation;
12258
12258
  if (!inputTokens2) {
12259
12259
  inputTokens2 = target.tokenEstimate || estimateTokens(normalized, target.modelId);
12260
12260
  }
@@ -12265,13 +12265,15 @@ async function registerMessagesRoute(app) {
12265
12265
  logUsage("non_stream.anthropic", {
12266
12266
  input: inputTokens2,
12267
12267
  output: outputTokens2,
12268
- cached: cachedTokens2
12268
+ cached: cachedTokens3
12269
12269
  });
12270
12270
  const latencyMs2 = Date.now() - requestStart;
12271
12271
  await updateLogTokens(logId, {
12272
12272
  inputTokens: inputTokens2,
12273
12273
  outputTokens: outputTokens2,
12274
- cachedTokens: cachedTokens2,
12274
+ cachedTokens: cachedTokens3,
12275
+ cacheReadTokens: cached3.read,
12276
+ cacheCreationTokens: cached3.creation,
12275
12277
  ttftMs: latencyMs2,
12276
12278
  tpotMs: computeTpot(latencyMs2, outputTokens2, { streaming: false })
12277
12279
  });
@@ -12280,9 +12282,9 @@ async function registerMessagesRoute(app) {
12280
12282
  requests: 1,
12281
12283
  inputTokens: inputTokens2,
12282
12284
  outputTokens: outputTokens2,
12283
- cachedTokens: cachedTokens2,
12284
- cacheReadTokens: cached2.read,
12285
- cacheCreationTokens: cached2.creation,
12285
+ cachedTokens: cachedTokens3,
12286
+ cacheReadTokens: cached3.read,
12287
+ cacheCreationTokens: cached3.creation,
12286
12288
  latencyMs: latencyMs2
12287
12289
  });
12288
12290
  if (storeResponsePayloads) {
@@ -12303,8 +12305,8 @@ async function registerMessagesRoute(app) {
12303
12305
  const claudeResponse = buildClaudeResponse(json, target.modelId);
12304
12306
  let inputTokens = json.usage?.prompt_tokens ?? 0;
12305
12307
  let outputTokens = json.usage?.completion_tokens ?? 0;
12306
- const cached = resolveCachedTokens(json.usage);
12307
- const cachedTokens = cached.read + cached.creation;
12308
+ const cached2 = resolveCachedTokens(json.usage);
12309
+ const cachedTokens2 = cached2.read + cached2.creation;
12308
12310
  if (!inputTokens) {
12309
12311
  inputTokens = target.tokenEstimate || estimateTokens(normalized, target.modelId);
12310
12312
  }
@@ -12315,13 +12317,15 @@ async function registerMessagesRoute(app) {
12315
12317
  logUsage("non_stream.openai", {
12316
12318
  input: inputTokens,
12317
12319
  output: outputTokens,
12318
- cached: cachedTokens
12320
+ cached: cachedTokens2
12319
12321
  });
12320
12322
  const latencyMs = Date.now() - requestStart;
12321
12323
  await updateLogTokens(logId, {
12322
12324
  inputTokens,
12323
12325
  outputTokens,
12324
- cachedTokens,
12326
+ cachedTokens: cachedTokens2,
12327
+ cacheReadTokens: cached2.read,
12328
+ cacheCreationTokens: cached2.creation,
12325
12329
  ttftMs: latencyMs,
12326
12330
  tpotMs: computeTpot(latencyMs, outputTokens, { streaming: false })
12327
12331
  });
@@ -12330,9 +12334,9 @@ async function registerMessagesRoute(app) {
12330
12334
  requests: 1,
12331
12335
  inputTokens,
12332
12336
  outputTokens,
12333
- cachedTokens,
12334
- cacheReadTokens: cached.read,
12335
- cacheCreationTokens: cached.creation,
12337
+ cachedTokens: cachedTokens2,
12338
+ cacheReadTokens: cached2.read,
12339
+ cacheCreationTokens: cached2.creation,
12336
12340
  latencyMs
12337
12341
  });
12338
12342
  if (storeResponsePayloads) {
@@ -12369,6 +12373,8 @@ async function registerMessagesRoute(app) {
12369
12373
  let usagePrompt2 = 0;
12370
12374
  let usageCompletion2 = 0;
12371
12375
  let usageCached2 = null;
12376
+ let usageCacheRead2 = 0;
12377
+ let usageCacheCreation2 = 0;
12372
12378
  let accumulatedContent2 = "";
12373
12379
  let firstTokenAt2 = null;
12374
12380
  let lastUsagePayload = null;
@@ -12504,6 +12510,8 @@ async function registerMessagesRoute(app) {
12504
12510
  usagePrompt2 = payload2.usage.input_tokens ?? usagePrompt2;
12505
12511
  usageCompletion2 = payload2.usage.output_tokens ?? usageCompletion2;
12506
12512
  const maybeCached = resolveCachedTokens(payload2.usage);
12513
+ usageCacheRead2 = maybeCached.read;
12514
+ usageCacheCreation2 = maybeCached.creation;
12507
12515
  usageCached2 = maybeCached.read + maybeCached.creation;
12508
12516
  lastUsagePayload = payload2.usage;
12509
12517
  }
@@ -12531,6 +12539,8 @@ async function registerMessagesRoute(app) {
12531
12539
  usagePrompt2 = payload2.usage.input_tokens ?? usagePrompt2;
12532
12540
  usageCompletion2 = payload2.usage.output_tokens ?? usageCompletion2;
12533
12541
  const maybeCached = resolveCachedTokens(payload2.usage);
12542
+ usageCacheRead2 = maybeCached.read;
12543
+ usageCacheCreation2 = maybeCached.creation;
12534
12544
  usageCached2 = maybeCached.read + maybeCached.creation;
12535
12545
  lastUsagePayload = payload2.usage;
12536
12546
  }
@@ -12583,9 +12593,11 @@ async function registerMessagesRoute(app) {
12583
12593
  }
12584
12594
  const totalLatencyMs = Date.now() - requestStart;
12585
12595
  const ttftMs = firstTokenAt2 ? firstTokenAt2 - requestStart : null;
12586
- const cached = resolveCachedTokens(lastUsagePayload);
12587
12596
  if (usageCached2 === null) {
12588
- usageCached2 = cached.read + cached.creation;
12597
+ const cached2 = resolveCachedTokens(lastUsagePayload);
12598
+ usageCacheRead2 = cached2.read;
12599
+ usageCacheCreation2 = cached2.creation;
12600
+ usageCached2 = cached2.read + cached2.creation;
12589
12601
  }
12590
12602
  logUsage("stream.anthropic.final", {
12591
12603
  input: usagePrompt2,
@@ -12596,8 +12608,8 @@ async function registerMessagesRoute(app) {
12596
12608
  inputTokens: usagePrompt2,
12597
12609
  outputTokens: usageCompletion2,
12598
12610
  cachedTokens: usageCached2,
12599
- cacheReadTokens: cached.read,
12600
- cacheCreationTokens: cached.creation,
12611
+ cacheReadTokens: usageCacheRead2,
12612
+ cacheCreationTokens: usageCacheCreation2,
12601
12613
  ttftMs,
12602
12614
  tpotMs: computeTpot(totalLatencyMs, usageCompletion2, {
12603
12615
  streaming: true,
@@ -12610,8 +12622,8 @@ async function registerMessagesRoute(app) {
12610
12622
  inputTokens: usagePrompt2,
12611
12623
  outputTokens: usageCompletion2,
12612
12624
  cachedTokens: usageCached2,
12613
- cacheReadTokens: cached.read,
12614
- cacheCreationTokens: cached.creation,
12625
+ cacheReadTokens: usageCacheRead2,
12626
+ cacheCreationTokens: usageCacheCreation2,
12615
12627
  latencyMs: totalLatencyMs
12616
12628
  });
12617
12629
  if (storeResponsePayloads) {
@@ -12688,6 +12700,8 @@ async function registerMessagesRoute(app) {
12688
12700
  let usagePrompt = 0;
12689
12701
  let usageCompletion = 0;
12690
12702
  let usageCached = null;
12703
+ let usageCacheRead = 0;
12704
+ let usageCacheCreation = 0;
12691
12705
  let accumulatedContent = "";
12692
12706
  let completed = false;
12693
12707
  let firstTokenAt = null;
@@ -12828,9 +12842,10 @@ data: ${JSON.stringify(data)}
12828
12842
  if (usagePayload) {
12829
12843
  usagePrompt = usagePayload.prompt_tokens ?? usagePrompt;
12830
12844
  usageCompletion = usagePayload.completion_tokens ?? usageCompletion;
12831
- if (typeof usagePayload.cached_tokens === "number") {
12832
- usageCached = usagePayload.cached_tokens;
12833
- }
12845
+ const maybeCached = resolveCachedTokens(usagePayload);
12846
+ usageCacheRead = maybeCached.read;
12847
+ usageCacheCreation = maybeCached.creation;
12848
+ usageCached = maybeCached.read + maybeCached.creation;
12834
12849
  }
12835
12850
  if (choice.delta?.tool_calls) {
12836
12851
  request.log.debug({ event: "debug.tool_call_delta", delta: choice.delta?.tool_calls }, "tool call delta received");
@@ -12937,8 +12952,8 @@ data: ${JSON.stringify(data)}
12937
12952
  inputTokens: fallbackPrompt,
12938
12953
  outputTokens: fallbackCompletion,
12939
12954
  cachedTokens: usageCached,
12940
- cacheReadTokens: 0,
12941
- cacheCreationTokens: 0,
12955
+ cacheReadTokens: usageCacheRead,
12956
+ cacheCreationTokens: usageCacheCreation,
12942
12957
  ttftMs,
12943
12958
  tpotMs: computeTpot(totalLatencyMs, fallbackCompletion, {
12944
12959
  streaming: true,
@@ -12951,8 +12966,8 @@ data: ${JSON.stringify(data)}
12951
12966
  inputTokens: fallbackPrompt,
12952
12967
  outputTokens: fallbackCompletion,
12953
12968
  cachedTokens: usageCached ?? 0,
12954
- cacheReadTokens: 0,
12955
- cacheCreationTokens: 0,
12969
+ cacheReadTokens: usageCacheRead,
12970
+ cacheCreationTokens: usageCacheCreation,
12956
12971
  latencyMs: totalLatencyMs
12957
12972
  });
12958
12973
  if (storeResponsePayloads) {
@@ -13896,20 +13911,20 @@ async function registerOpenAiRoutes(app) {
13896
13911
  if (!Number.isFinite(inputTokens3) || inputTokens3 <= 0) {
13897
13912
  inputTokens3 = target.tokenEstimate ?? estimateTokens(normalized, target.modelId);
13898
13913
  }
13899
- const cached2 = resolveCachedTokens2(usagePayload2);
13900
- const cachedTokens2 = cached2.read + cached2.creation;
13914
+ const cached3 = resolveCachedTokens2(usagePayload2);
13915
+ const cachedTokens3 = cached3.read + cached3.creation;
13901
13916
  const latencyMs3 = Date.now() - requestStart;
13902
13917
  const openAIResponse = buildOpenAIResponseFromClaude(parsed, target.modelId, converted, {
13903
13918
  inputTokens: inputTokens3,
13904
13919
  outputTokens: outputTokens3,
13905
- cachedTokens: cachedTokens2
13920
+ cachedTokens: cachedTokens3
13906
13921
  });
13907
13922
  await updateLogTokens(logId, {
13908
13923
  inputTokens: inputTokens3,
13909
13924
  outputTokens: outputTokens3,
13910
- cachedTokens: usageCached,
13911
- cacheReadTokens: cached2.read,
13912
- cacheCreationTokens: cached2.creation,
13925
+ cachedTokens: cachedTokens3,
13926
+ cacheReadTokens: cached3.read,
13927
+ cacheCreationTokens: cached3.creation,
13913
13928
  ttftMs: latencyMs3,
13914
13929
  tpotMs: computeTpot2(latencyMs3, outputTokens3, { streaming: false })
13915
13930
  });
@@ -13918,9 +13933,9 @@ async function registerOpenAiRoutes(app) {
13918
13933
  requests: 1,
13919
13934
  inputTokens: inputTokens3,
13920
13935
  outputTokens: outputTokens3,
13921
- cachedTokens: usageCached,
13922
- cacheReadTokens: usageCacheRead,
13923
- cacheCreationTokens: usageCacheCreation,
13936
+ cachedTokens: cachedTokens3,
13937
+ cacheReadTokens: cached3.read,
13938
+ cacheCreationTokens: cached3.creation,
13924
13939
  latencyMs: latencyMs3
13925
13940
  });
13926
13941
  if (storeResponsePayloads) {
@@ -13955,15 +13970,15 @@ async function registerOpenAiRoutes(app) {
13955
13970
  return 0;
13956
13971
  })();
13957
13972
  const outputTokens2 = baseOutputTokens + reasoningTokens2;
13958
- const cached = resolveCachedTokens2(usagePayload);
13959
- const cachedTokens = cached.read + cached.creation;
13973
+ const cached2 = resolveCachedTokens2(usagePayload);
13974
+ const cachedTokens2 = cached2.read + cached2.creation;
13960
13975
  const latencyMs2 = Date.now() - requestStart;
13961
13976
  await updateLogTokens(logId, {
13962
13977
  inputTokens: inputTokens2,
13963
13978
  outputTokens: outputTokens2,
13964
- cachedTokens: usageCached,
13965
- cacheReadTokens: cached.read,
13966
- cacheCreationTokens: cached.creation,
13979
+ cachedTokens: cachedTokens2,
13980
+ cacheReadTokens: cached2.read,
13981
+ cacheCreationTokens: cached2.creation,
13967
13982
  ttftMs: usagePayload?.first_token_latency_ms ?? latencyMs2,
13968
13983
  tpotMs: usagePayload?.tokens_per_second ? computeTpot2(latencyMs2, outputTokens2, { streaming: false, reasoningTokens: reasoningTokens2 }) : null
13969
13984
  });
@@ -13972,6 +13987,9 @@ async function registerOpenAiRoutes(app) {
13972
13987
  requests: 1,
13973
13988
  inputTokens: inputTokens2,
13974
13989
  outputTokens: outputTokens2,
13990
+ cachedTokens: cachedTokens2,
13991
+ cacheReadTokens: cached2.read,
13992
+ cacheCreationTokens: cached2.creation,
13975
13993
  latencyMs: latencyMs2
13976
13994
  });
13977
13995
  await finalize(200, null);
@@ -14783,15 +14801,15 @@ async function registerOpenAiRoutes(app) {
14783
14801
  inputTokens: inputTokens3,
14784
14802
  outputTokens: outputTokens3
14785
14803
  });
14786
- const cached2 = resolveCachedTokens2(usagePayload2);
14787
- const cachedTokens2 = cached2.read + cached2.creation;
14804
+ const cached3 = resolveCachedTokens2(usagePayload2);
14805
+ const cachedTokens3 = cached3.read + cached3.creation;
14788
14806
  const latencyMs3 = Date.now() - requestStart;
14789
14807
  await updateLogTokens(logId, {
14790
14808
  inputTokens: inputTokens3,
14791
14809
  outputTokens: outputTokens3,
14792
14810
  cachedTokens: usageCached,
14793
- cacheReadTokens: cached2.read,
14794
- cacheCreationTokens: cached2.creation,
14811
+ cacheReadTokens: cached3.read,
14812
+ cacheCreationTokens: cached3.creation,
14795
14813
  ttftMs: latencyMs3,
14796
14814
  tpotMs: computeTpot2(latencyMs3, outputTokens3, { streaming: false })
14797
14815
  });
@@ -14832,15 +14850,15 @@ async function registerOpenAiRoutes(app) {
14832
14850
  })(),
14833
14851
  target.modelId
14834
14852
  );
14835
- const cached = resolveCachedTokens2(usagePayload);
14836
- const cachedTokens = cached.read + cached.creation;
14853
+ const cached2 = resolveCachedTokens2(usagePayload);
14854
+ const cachedTokens2 = cached2.read + cached2.creation;
14837
14855
  const latencyMs2 = Date.now() - requestStart;
14838
14856
  await updateLogTokens(logId, {
14839
14857
  inputTokens: inputTokens2,
14840
14858
  outputTokens: outputTokens2,
14841
14859
  cachedTokens: usageCached,
14842
- cacheReadTokens: cached.read,
14843
- cacheCreationTokens: cached.creation,
14860
+ cacheReadTokens: cached2.read,
14861
+ cacheCreationTokens: cached2.creation,
14844
14862
  ttftMs: usagePayload?.first_token_latency_ms ?? latencyMs2,
14845
14863
  tpotMs: usagePayload?.tokens_per_second ? computeTpot2(latencyMs2, outputTokens2, { streaming: false }) : null
14846
14864
  });
@@ -14849,6 +14867,9 @@ async function registerOpenAiRoutes(app) {
14849
14867
  requests: 1,
14850
14868
  inputTokens: inputTokens2,
14851
14869
  outputTokens: outputTokens2,
14870
+ cachedTokens: cachedTokens2,
14871
+ cacheReadTokens: cached2.read,
14872
+ cacheCreationTokens: cached2.creation,
14852
14873
  latencyMs: latencyMs2
14853
14874
  });
14854
14875
  await finalize(200, null);
@@ -15597,7 +15618,7 @@ async function queryLogs(options = {}) {
15597
15618
  const items = await getAll(
15598
15619
  `SELECT id, timestamp, session_id, endpoint, provider, model, client_model,
15599
15620
  stream, latency_ms, status_code, input_tokens, output_tokens,
15600
- cached_tokens, ttft_ms, tpot_ms, error, api_key_id, api_key_name, api_key_value
15621
+ cached_tokens, cache_read_tokens, cache_creation_tokens, ttft_ms, tpot_ms, error, api_key_id, api_key_name, api_key_value
15601
15622
  FROM request_logs
15602
15623
  ${whereClause}
15603
15624
  ORDER BY timestamp DESC
@@ -15613,7 +15634,7 @@ async function getLogDetail(id) {
15613
15634
  const record = await getOne(
15614
15635
  `SELECT id, timestamp, session_id, endpoint, provider, model, client_model,
15615
15636
  stream, latency_ms, status_code, input_tokens, output_tokens,
15616
- cached_tokens, ttft_ms, tpot_ms, error, api_key_id, api_key_name, api_key_value
15637
+ cached_tokens, cache_read_tokens, cache_creation_tokens, ttft_ms, tpot_ms, error, api_key_id, api_key_name, api_key_value
15617
15638
  FROM request_logs
15618
15639
  WHERE id = ?`,
15619
15640
  [id]
@@ -15663,6 +15684,8 @@ async function exportLogs(options = {}) {
15663
15684
  l.input_tokens,
15664
15685
  l.output_tokens,
15665
15686
  l.cached_tokens,
15687
+ l.cache_read_tokens,
15688
+ l.cache_creation_tokens,
15666
15689
  l.ttft_ms,
15667
15690
  l.tpot_ms,
15668
15691
  l.error,
@@ -17575,15 +17598,15 @@ async function handleAnthropicProtocol(request, reply, endpoint, endpointId, app
17575
17598
  const json = await new Response(upstream.body).json();
17576
17599
  const inputTokens = json.usage?.input_tokens ?? estimateTokens(normalized, target.modelId);
17577
17600
  const outputTokens = json.usage?.output_tokens ?? 0;
17578
- const cached = resolveCachedTokens3(json.usage);
17579
- const cachedTokens = cached.read + cached.creation;
17601
+ const cached2 = resolveCachedTokens3(json.usage);
17602
+ const cachedTokens2 = cached2.read + cached2.creation;
17580
17603
  const latencyMs = Date.now() - requestStart;
17581
17604
  await updateLogTokens(logId, {
17582
17605
  inputTokens,
17583
17606
  outputTokens,
17584
- cachedTokens: usageCached,
17585
- cacheReadTokens: cached.read,
17586
- cacheCreationTokens: cached.creation,
17607
+ cachedTokens: cachedTokens2,
17608
+ cacheReadTokens: cached2.read,
17609
+ cacheCreationTokens: cached2.creation,
17587
17610
  ttftMs: latencyMs,
17588
17611
  tpotMs: computeTpot3(latencyMs, outputTokens, { streaming: false })
17589
17612
  });
@@ -17592,9 +17615,9 @@ async function handleAnthropicProtocol(request, reply, endpoint, endpointId, app
17592
17615
  requests: 1,
17593
17616
  inputTokens,
17594
17617
  outputTokens,
17595
- cachedTokens: usageCached,
17596
- cacheReadTokens: usageCacheRead,
17597
- cacheCreationTokens: usageCacheCreation,
17618
+ cachedTokens: cachedTokens2,
17619
+ cacheReadTokens: cached2.read,
17620
+ cacheCreationTokens: cached2.creation,
17598
17621
  latencyMs
17599
17622
  });
17600
17623
  if (storeResponsePayloads) {
@@ -17652,10 +17675,10 @@ async function handleAnthropicProtocol(request, reply, endpoint, endpointId, app
17652
17675
  if (parsed?.usage) {
17653
17676
  usagePrompt = parsed.usage.input_tokens ?? usagePrompt;
17654
17677
  usageCompletion = parsed.usage.output_tokens ?? usageCompletion;
17655
- const cached = resolveCachedTokens3(parsed.usage);
17656
- usageCacheRead = cached.read;
17657
- usageCacheCreation = cached.creation;
17658
- usageCached = cached.read + cached.creation;
17678
+ const cached2 = resolveCachedTokens3(parsed.usage);
17679
+ usageCacheRead = cached2.read;
17680
+ usageCacheCreation = cached2.creation;
17681
+ usageCached = cached2.read + cached2.creation;
17659
17682
  }
17660
17683
  if (!firstTokenAt && (parsed?.type === "content_block_delta" || parsed?.delta?.text)) {
17661
17684
  firstTokenAt = Date.now();
@@ -17875,15 +17898,15 @@ async function handleOpenAIChatProtocol(request, reply, endpoint, endpointId, ap
17875
17898
  const usagePayload = json?.usage ?? null;
17876
17899
  const inputTokens2 = usagePayload?.prompt_tokens ?? usagePayload?.input_tokens ?? target.tokenEstimate ?? estimateTokens(normalized, target.modelId);
17877
17900
  const outputTokens2 = usagePayload?.completion_tokens ?? usagePayload?.output_tokens ?? estimateTextTokens(json?.choices?.[0]?.message?.content ?? "", target.modelId);
17878
- const cached = resolveCachedTokens3(usagePayload);
17879
- const cachedTokens = cached.read + cached.creation;
17901
+ const cached2 = resolveCachedTokens3(usagePayload);
17902
+ const cachedTokens2 = cached2.read + cached2.creation;
17880
17903
  const latencyMs2 = Date.now() - requestStart;
17881
17904
  await updateLogTokens(logId, {
17882
17905
  inputTokens: inputTokens2,
17883
17906
  outputTokens: outputTokens2,
17884
- cachedTokens: usageCached,
17885
- cacheReadTokens: cached.read,
17886
- cacheCreationTokens: cached.creation,
17907
+ cachedTokens: cachedTokens2,
17908
+ cacheReadTokens: cached2.read,
17909
+ cacheCreationTokens: cached2.creation,
17887
17910
  ttftMs: latencyMs2,
17888
17911
  tpotMs: computeTpot3(latencyMs2, outputTokens2, { streaming: false })
17889
17912
  });
@@ -17892,9 +17915,9 @@ async function handleOpenAIChatProtocol(request, reply, endpoint, endpointId, ap
17892
17915
  requests: 1,
17893
17916
  inputTokens: inputTokens2,
17894
17917
  outputTokens: outputTokens2,
17895
- cachedTokens: usageCached,
17896
- cacheReadTokens: usageCacheRead,
17897
- cacheCreationTokens: usageCacheCreation,
17918
+ cachedTokens: cachedTokens2,
17919
+ cacheReadTokens: cached2.read,
17920
+ cacheCreationTokens: cached2.creation,
17898
17921
  latencyMs: latencyMs2
17899
17922
  });
17900
17923
  if (storeResponsePayloads) {
@@ -18167,15 +18190,15 @@ async function handleOpenAIResponsesProtocol(request, reply, endpoint, endpointI
18167
18190
  const inputTokens2 = usagePayload?.prompt_tokens ?? usagePayload?.input_tokens ?? target.tokenEstimate ?? estimateTokens(normalized, target.modelId);
18168
18191
  const content = json?.response?.body?.content ?? json?.choices?.[0]?.message?.content ?? "";
18169
18192
  const outputTokens2 = usagePayload?.completion_tokens ?? usagePayload?.output_tokens ?? estimateTextTokens(content, target.modelId);
18170
- const cached = resolveCachedTokens3(usagePayload);
18171
- const cachedTokens = cached.read + cached.creation;
18193
+ const cached2 = resolveCachedTokens3(usagePayload);
18194
+ const cachedTokens2 = cached2.read + cached2.creation;
18172
18195
  const latencyMs2 = Date.now() - requestStart;
18173
18196
  await updateLogTokens(logId, {
18174
18197
  inputTokens: inputTokens2,
18175
18198
  outputTokens: outputTokens2,
18176
18199
  cachedTokens: usageCached,
18177
- cacheReadTokens: cached.read,
18178
- cacheCreationTokens: cached.creation,
18200
+ cacheReadTokens: cached2.read,
18201
+ cacheCreationTokens: cached2.creation,
18179
18202
  ttftMs: latencyMs2,
18180
18203
  tpotMs: computeTpot3(latencyMs2, outputTokens2, { streaming: false })
18181
18204
  });
@@ -18184,9 +18207,9 @@ async function handleOpenAIResponsesProtocol(request, reply, endpoint, endpointI
18184
18207
  requests: 1,
18185
18208
  inputTokens: inputTokens2,
18186
18209
  outputTokens: outputTokens2,
18187
- cachedTokens: usageCached,
18188
- cacheReadTokens: usageCacheRead,
18189
- cacheCreationTokens: usageCacheCreation,
18210
+ cachedTokens: cachedTokens2,
18211
+ cacheReadTokens: cached2.read,
18212
+ cacheCreationTokens: cached2.creation,
18190
18213
  latencyMs: latencyMs2
18191
18214
  });
18192
18215
  if (storeResponsePayloads) {
@@ -1,4 +1,4 @@
1
- import{c as p,u as v,a as k,r,j as e,d as o,U as j,m as i}from"./index-agm-2asf.js";import{u as N}from"./useApiQuery-ns68sM2H.js";import{P as w,a as d}from"./PageSection-Dzvd3cKD.js";import"./Input-B-P-J4xQ.js";import{B as b}from"./Button-Bnnxe9ep.js";import{I as y}from"./info-CfAuBePJ.js";/**
1
+ import{c as p,u as v,a as k,r,j as e,d as o,U as j,m as i}from"./index-3UByifOG.js";import{u as N}from"./useApiQuery-7KXAW9hB.js";import{P as w,a as d}from"./PageSection-BT-depe5.js";import"./Input-CkTJl-fF.js";import{B as b}from"./Button-CgdNhVeu.js";import{I as y}from"./info-DAG4KwRm.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -8,4 +8,4 @@ import{c as p,u as v,a as k,r,j as e,d as o,U as j,m as i}from"./index-agm-2asf.
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const E=p("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]),I="0.5.0",_={version:I},L={VITE_BUILD_TIME:"2025-10-31T04:22:15.501Z",VITE_NODE_VERSION:"v22.14.0"};function m({items:t}){return t.length===0?null:e.jsx("dl",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-2",children:t.map(s=>e.jsxs("div",{className:"rounded-2xl border border-slate-200/50 bg-white p-4 shadow-sm shadow-slate-200/30 transition-all duration-200 hover:-translate-y-0.5 hover:border-slate-200/70 hover:shadow-md hover:shadow-slate-200/40 dark:border-slate-700/50 dark:bg-slate-900/80 dark:shadow-lg dark:shadow-slate-900/30 dark:hover:border-slate-600/70",children:[e.jsx("dt",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-slate-500 dark:text-slate-400",children:s.label}),e.jsx("dd",{className:"mt-2 text-base font-semibold text-slate-900 dark:text-slate-100",children:s.value}),s.hint?e.jsx("p",{className:o(i,"mt-2 text-xs leading-relaxed"),children:s.hint}):null]},s.label))})}function P(){const{t}=v(),{pushToast:s}=k(),a=N(["status","gateway"],{url:"/api/status",method:"GET"},{staleTime:6e4});r.useEffect(()=>{a.isError&&a.error&&s({title:t("about.toast.statusError.title"),description:a.error.message,variant:"error"})},[a.isError,a.error,s,t]);const n=_.version,l=r.useMemo(()=>{const u=L,f=u.VITE_BUILD_TIME,g=u.VITE_NODE_VERSION;return{buildTime:f,nodeVersion:g}},[]),h=r.useMemo(()=>[{label:t("about.app.labels.name"),value:e.jsx("span",{className:"font-mono text-sm font-semibold text-slate-900 dark:text-slate-100",children:"cc-gw"})},{label:t("about.app.labels.version"),value:e.jsxs("span",{className:"font-mono text-sm font-semibold text-blue-700 dark:text-blue-200",children:["v",n]})},{label:t("about.app.labels.buildTime"),value:l.buildTime,hint:t("about.app.hint.buildTime")},{label:t("about.app.labels.node"),value:e.jsx("span",{className:"font-mono text-sm text-slate-800 dark:text-slate-200",children:l.nodeVersion})}],[n,l.buildTime,l.nodeVersion,t]),c=r.useMemo(()=>a.data?[{label:t("about.status.labels.host"),value:a.data.host??"127.0.0.1"},{label:t("about.status.labels.port"),value:a.data.port.toLocaleString()},{label:t("about.status.labels.providers"),value:a.data.providers.toLocaleString()},{label:t("about.status.labels.active"),value:(a.data.activeRequests??0).toLocaleString(),hint:t("about.status.hint.active")}]:[],[a.data,t]),x=()=>{s({title:t("about.toast.updatesPlanned"),variant:"info"})};return e.jsxs("div",{className:"space-y-8",children:[e.jsx(w,{icon:e.jsx(y,{className:"h-6 w-6","aria-hidden":"true"}),title:t("about.title"),description:t("about.description"),badge:`v${n}`,actions:e.jsx(b,{variant:"primary",icon:e.jsx(E,{className:"h-4 w-4","aria-hidden":"true"}),onClick:x,children:t("about.support.actions.checkUpdates")})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(d,{title:t("about.app.title"),description:t("about.app.subtitle"),className:"h-full",contentClassName:"gap-4",children:e.jsx(m,{items:h})}),e.jsx(d,{title:t("about.status.title"),description:t("about.status.subtitle"),className:"h-full",contentClassName:"gap-4",actions:e.jsx(b,{variant:"subtle",size:"sm",icon:e.jsx(T,{className:"h-4 w-4","aria-hidden":"true"}),onClick:()=>a.refetch(),loading:a.isFetching,children:a.isFetching?t("common.actions.refreshing"):t("common.actions.refresh")}),children:a.isLoading?e.jsxs("div",{className:"flex h-36 flex-col items-center justify-center gap-3 text-center",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-[3px] border-blue-500/30 border-t-blue-600 dark:border-blue-400/20 dark:border-t-blue-300"}),e.jsx("p",{className:o(i,"text-sm"),children:t("about.status.loading")})]}):c.length>0?e.jsx(m,{items:c}):e.jsxs("div",{className:"flex h-36 flex-col items-center justify-center gap-2 rounded-2xl border border-dashed border-slate-200/60 bg-white p-6 text-center shadow-inner dark:border-slate-700/60 dark:bg-slate-900/60",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 dark:text-slate-200",children:t("about.status.empty")}),e.jsx("p",{className:o(i,"text-xs"),children:t("common.actions.refresh")})]})})]}),e.jsx(d,{title:t("about.support.title"),description:e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-semibold text-blue-600 dark:text-blue-300",children:t("about.support.subtitle")}),e.jsx("span",{children:t("about.support.description")})]}),className:"relative overflow-hidden",contentClassName:"gap-6",children:e.jsxs("div",{className:"flex flex-col gap-4 rounded-3xl border border-slate-200/50 bg-white p-6 shadow-lg shadow-slate-200/30 backdrop-blur-md dark:border-slate-700/50 dark:bg-slate-900/80 dark:shadow-slate-900/40",children:[e.jsxs("div",{className:"flex flex-wrap items-start gap-4",children:[e.jsx("div",{className:"grid h-12 w-12 place-items-center rounded-2xl bg-gradient-to-br from-blue-500/20 to-indigo-500/20 text-blue-600 shadow-inner dark:text-blue-200",children:e.jsx(j,{className:"h-6 w-6","aria-hidden":"true"})}),e.jsx("p",{className:o(i,"text-sm leading-6"),children:t("about.support.tip")})]}),e.jsx("code",{className:"inline-flex items-center gap-2 self-start rounded-full border border-blue-200/50 bg-blue-50/80 px-4 py-2 text-xs font-semibold tracking-wide text-blue-700 shadow-sm dark:border-blue-500/30 dark:bg-blue-900/30 dark:text-blue-200",children:"~/.cc-gw/config.json"})]})})]})}export{P as default};
11
+ */const E=p("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]),I="0.5.1",_={version:I},L={VITE_BUILD_TIME:"2025-10-31T08:47:42.611Z",VITE_NODE_VERSION:"v22.14.0"};function m({items:t}){return t.length===0?null:e.jsx("dl",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-2",children:t.map(s=>e.jsxs("div",{className:"rounded-2xl border border-slate-200/50 bg-white p-4 shadow-sm shadow-slate-200/30 transition-all duration-200 hover:-translate-y-0.5 hover:border-slate-200/70 hover:shadow-md hover:shadow-slate-200/40 dark:border-slate-700/50 dark:bg-slate-900/80 dark:shadow-lg dark:shadow-slate-900/30 dark:hover:border-slate-600/70",children:[e.jsx("dt",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-slate-500 dark:text-slate-400",children:s.label}),e.jsx("dd",{className:"mt-2 text-base font-semibold text-slate-900 dark:text-slate-100",children:s.value}),s.hint?e.jsx("p",{className:o(i,"mt-2 text-xs leading-relaxed"),children:s.hint}):null]},s.label))})}function P(){const{t}=v(),{pushToast:s}=k(),a=N(["status","gateway"],{url:"/api/status",method:"GET"},{staleTime:6e4});r.useEffect(()=>{a.isError&&a.error&&s({title:t("about.toast.statusError.title"),description:a.error.message,variant:"error"})},[a.isError,a.error,s,t]);const n=_.version,l=r.useMemo(()=>{const u=L,f=u.VITE_BUILD_TIME,g=u.VITE_NODE_VERSION;return{buildTime:f,nodeVersion:g}},[]),h=r.useMemo(()=>[{label:t("about.app.labels.name"),value:e.jsx("span",{className:"font-mono text-sm font-semibold text-slate-900 dark:text-slate-100",children:"cc-gw"})},{label:t("about.app.labels.version"),value:e.jsxs("span",{className:"font-mono text-sm font-semibold text-blue-700 dark:text-blue-200",children:["v",n]})},{label:t("about.app.labels.buildTime"),value:l.buildTime,hint:t("about.app.hint.buildTime")},{label:t("about.app.labels.node"),value:e.jsx("span",{className:"font-mono text-sm text-slate-800 dark:text-slate-200",children:l.nodeVersion})}],[n,l.buildTime,l.nodeVersion,t]),c=r.useMemo(()=>a.data?[{label:t("about.status.labels.host"),value:a.data.host??"127.0.0.1"},{label:t("about.status.labels.port"),value:a.data.port.toLocaleString()},{label:t("about.status.labels.providers"),value:a.data.providers.toLocaleString()},{label:t("about.status.labels.active"),value:(a.data.activeRequests??0).toLocaleString(),hint:t("about.status.hint.active")}]:[],[a.data,t]),x=()=>{s({title:t("about.toast.updatesPlanned"),variant:"info"})};return e.jsxs("div",{className:"space-y-8",children:[e.jsx(w,{icon:e.jsx(y,{className:"h-6 w-6","aria-hidden":"true"}),title:t("about.title"),description:t("about.description"),badge:`v${n}`,actions:e.jsx(b,{variant:"primary",icon:e.jsx(E,{className:"h-4 w-4","aria-hidden":"true"}),onClick:x,children:t("about.support.actions.checkUpdates")})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(d,{title:t("about.app.title"),description:t("about.app.subtitle"),className:"h-full",contentClassName:"gap-4",children:e.jsx(m,{items:h})}),e.jsx(d,{title:t("about.status.title"),description:t("about.status.subtitle"),className:"h-full",contentClassName:"gap-4",actions:e.jsx(b,{variant:"subtle",size:"sm",icon:e.jsx(T,{className:"h-4 w-4","aria-hidden":"true"}),onClick:()=>a.refetch(),loading:a.isFetching,children:a.isFetching?t("common.actions.refreshing"):t("common.actions.refresh")}),children:a.isLoading?e.jsxs("div",{className:"flex h-36 flex-col items-center justify-center gap-3 text-center",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-[3px] border-blue-500/30 border-t-blue-600 dark:border-blue-400/20 dark:border-t-blue-300"}),e.jsx("p",{className:o(i,"text-sm"),children:t("about.status.loading")})]}):c.length>0?e.jsx(m,{items:c}):e.jsxs("div",{className:"flex h-36 flex-col items-center justify-center gap-2 rounded-2xl border border-dashed border-slate-200/60 bg-white p-6 text-center shadow-inner dark:border-slate-700/60 dark:bg-slate-900/60",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 dark:text-slate-200",children:t("about.status.empty")}),e.jsx("p",{className:o(i,"text-xs"),children:t("common.actions.refresh")})]})})]}),e.jsx(d,{title:t("about.support.title"),description:e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-semibold text-blue-600 dark:text-blue-300",children:t("about.support.subtitle")}),e.jsx("span",{children:t("about.support.description")})]}),className:"relative overflow-hidden",contentClassName:"gap-6",children:e.jsxs("div",{className:"flex flex-col gap-4 rounded-3xl border border-slate-200/50 bg-white p-6 shadow-lg shadow-slate-200/30 backdrop-blur-md dark:border-slate-700/50 dark:bg-slate-900/80 dark:shadow-slate-900/40",children:[e.jsxs("div",{className:"flex flex-wrap items-start gap-4",children:[e.jsx("div",{className:"grid h-12 w-12 place-items-center rounded-2xl bg-gradient-to-br from-blue-500/20 to-indigo-500/20 text-blue-600 shadow-inner dark:text-blue-200",children:e.jsx(j,{className:"h-6 w-6","aria-hidden":"true"})}),e.jsx("p",{className:o(i,"text-sm leading-6"),children:t("about.support.tip")})]}),e.jsx("code",{className:"inline-flex items-center gap-2 self-start rounded-full border border-blue-200/50 bg-blue-50/80 px-4 py-2 text-xs font-semibold tracking-wide text-blue-700 shadow-sm dark:border-blue-500/30 dark:bg-blue-900/30 dark:text-blue-200",children:"~/.cc-gw/config.json"})]})})]})}export{P as default};
@@ -1,4 +1,4 @@
1
- import{c as T,u as W,a as J,r as d,j as e,L as X,N as Y,d as t,b as K,m as r,H as m,E as Z,k as ee,l as ae,f as se,h as te}from"./index-agm-2asf.js";import{E as le}from"./index-Cm-hZvRJ.js";import{u as w}from"./useApiQuery-ns68sM2H.js";import{P as ie,a as q}from"./PageSection-Dzvd3cKD.js";import{F as I}from"./FormField-BzT4FGj8.js";import{I as re}from"./Input-B-P-J4xQ.js";import{B as C}from"./Button-Bnnxe9ep.js";import{S as ne}from"./StatusBadge-CAkVtC--.js";import{C as ce}from"./copy-D6cuJHzh.js";/**
1
+ import{c as T,u as W,a as J,r as d,j as e,L as X,N as Y,d as t,b as K,m as r,H as m,E as Z,k as ee,l as ae,f as se,h as te}from"./index-3UByifOG.js";import{E as le}from"./index-DVBy-Kka.js";import{u as w}from"./useApiQuery-7KXAW9hB.js";import{P as ie,a as q}from"./PageSection-BT-depe5.js";import{F as I}from"./FormField-DJjnoGU0.js";import{I as re}from"./Input-CkTJl-fF.js";import{B as C}from"./Button-CgdNhVeu.js";import{S as ne}from"./StatusBadge-CgBAXD_S.js";import{C as ce}from"./copy-OD9YQ85H.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{j as s,d as c,J as i,E as p,k as b}from"./index-agm-2asf.js";function h({variant:n="subtle",size:o="md",children:a,loading:t,icon:e,className:l,disabled:r,...u}){const m={subtle:b,primary:p,danger:i}[n],x={sm:"h-8 px-3 text-xs",md:"h-10 px-4 text-sm",lg:"h-12 px-6 text-base"}[o];return s.jsx("button",{className:c(m,x,t&&"cursor-wait opacity-70",r&&"cursor-not-allowed opacity-50",l),disabled:r||t,...u,children:t?s.jsx("div",{className:"inline-block animate-spin rounded-full h-4 w-4 border-b-2 border-current"}):e?s.jsxs(s.Fragment,{children:[e,a]}):a})}export{h as B};
1
+ import{j as s,d as c,J as i,E as p,k as b}from"./index-3UByifOG.js";function h({variant:n="subtle",size:o="md",children:a,loading:t,icon:e,className:l,disabled:r,...u}){const m={subtle:b,primary:p,danger:i}[n],x={sm:"h-8 px-3 text-xs",md:"h-10 px-4 text-sm",lg:"h-12 px-6 text-base"}[o];return s.jsx("button",{className:c(m,x,t&&"cursor-wait opacity-70",r&&"cursor-not-allowed opacity-50",l),disabled:r||t,...u,children:t?s.jsx("div",{className:"inline-block animate-spin rounded-full h-4 w-4 border-b-2 border-current"}):e?s.jsxs(s.Fragment,{children:[e,a]}):a})}export{h as B};
@@ -1,4 +1,4 @@
1
- import{c as O,u as q,a as te,r as h,b as se,t as ae,j as e,L as re,B,d as o,m as g,g as z,e as $,f as G,h as oe,l as _,s as le,i as M,k as ie,n as P}from"./index-agm-2asf.js";import{E as ne}from"./index-Cm-hZvRJ.js";import{P as de,a as H}from"./PageSection-Dzvd3cKD.js";import{S as ce}from"./Input-B-P-J4xQ.js";import{S as me}from"./StatusBadge-CAkVtC--.js";import{u as C}from"./useApiQuery-ns68sM2H.js";/**
1
+ import{c as O,u as q,a as te,r as h,b as se,t as ae,j as e,L as re,B,d as o,m as g,g as z,e as $,f as G,h as oe,l as _,s as le,i as M,k as ie,n as P}from"./index-3UByifOG.js";import{E as ne}from"./index-DVBy-Kka.js";import{P as de,a as H}from"./PageSection-BT-depe5.js";import{S as ce}from"./Input-CkTJl-fF.js";import{S as me}from"./StatusBadge-CgBAXD_S.js";import{u as C}from"./useApiQuery-7KXAW9hB.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{j as s,d,P as m,Q as x}from"./index-agm-2asf.js";function i({label:a,children:l,className:t,required:r,error:e}){return s.jsxs("div",{className:d(x,t),children:[s.jsxs("label",{className:m,children:[a,r&&s.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),l,e&&s.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:e})]})}export{i as F};
1
+ import{j as s,d,P as m,Q as x}from"./index-3UByifOG.js";function i({label:a,children:l,className:t,required:r,error:e}){return s.jsxs("div",{className:d(x,t),children:[s.jsxs("label",{className:m,children:[a,r&&s.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),l,e&&s.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:e})]})}export{i as F};
@@ -1,4 +1,4 @@
1
- import{c as u,u as p,r as b,j as e,d as x,m}from"./index-agm-2asf.js";import{P as g,a as o}from"./PageSection-Dzvd3cKD.js";import{I as j}from"./info-CfAuBePJ.js";/**
1
+ import{c as u,u as p,r as b,j as e,d as x,m}from"./index-3UByifOG.js";import{P as g,a as o}from"./PageSection-BT-depe5.js";import{I as j}from"./info-DAG4KwRm.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as d,j as e,d as n,M as c,K as i}from"./index-agm-2asf.js";const f=d.forwardRef(({options:t,placeholder:s,className:r,...l},u)=>e.jsxs("select",{ref:u,className:n(c,r),...l,children:[s&&e.jsx("option",{value:"",disabled:!0,children:s}),t.map(a=>e.jsx("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]})),j=d.forwardRef(({variant:t="default",className:s,...r},l)=>e.jsx("input",{ref:l,className:n(i,s),...r}));export{j as I,f as S};
1
+ import{r as d,j as e,d as n,M as c,K as i}from"./index-3UByifOG.js";const f=d.forwardRef(({options:t,placeholder:s,className:r,...l},u)=>e.jsxs("select",{ref:u,className:n(c,r),...l,children:[s&&e.jsx("option",{value:"",disabled:!0,children:s}),t.map(a=>e.jsx("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]})),j=d.forwardRef(({variant:t="default",className:s,...r},l)=>e.jsx("input",{ref:l,className:n(i,s),...r}));export{j as I,f as S};
@@ -1 +1 @@
1
- import{u as y,a8 as E,a9 as C,aa as S,r as l,j as e,d,L as _,m as j,K as v,E as L}from"./index-agm-2asf.js";function P(){const{t:a}=y(),o=E(),m=C(),{authEnabled:n,isAuthenticated:x,loading:i,login:k,error:b}=S(),[r,h]=l.useState({username:"",password:""}),[f,u]=l.useState(null),[p,g]=l.useState(!1),c=l.useMemo(()=>{var t;const s=m.state;return((t=s==null?void 0:s.from)==null?void 0:t.pathname)??"/"},[m.state]);l.useEffect(()=>{if(!n&&!i){o(c,{replace:!0});return}n&&x&&!i&&o(c,{replace:!0})},[n,x,i,o,c]);const N=async s=>{if(s.preventDefault(),u(null),!r.username.trim()||!r.password){u(a("login.validation.required"));return}g(!0);try{await k(r.username.trim(),r.password),o(c,{replace:!0})}catch(t){u(t instanceof Error?t.message:a("login.validation.failed"))}finally{g(!1)}},w=s=>e.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-gradient-to-br from-slate-100 via-white to-slate-200 px-4 dark:from-slate-950/95 dark:via-slate-950 dark:to-slate-900",children:[e.jsxs("div",{className:"pointer-events-none absolute inset-0",children:[e.jsx("div",{className:"absolute left-10 top-20 h-48 w-48 rounded-full bg-slate-200/40 blur-3xl dark:bg-slate-700/30"}),e.jsx("div",{className:"absolute right-16 bottom-32 h-56 w-56 rounded-full bg-slate-300/35 blur-3xl dark:bg-slate-800/30"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_top,_rgba(15,23,42,0.08),_transparent_55%)]"})]}),e.jsx("div",{className:"relative z-10 w-full max-w-lg",children:s})]});return i?w(e.jsx("div",{className:"flex min-h-[320px] items-center justify-center rounded-3xl border border-blue-200/60 bg-white/90 shadow-2xl shadow-blue-200/50 backdrop-blur-xl dark:border-slate-800/50 dark:bg-slate-900/80 dark:shadow-slate-900/60",children:e.jsx(_,{})})):n?w(e.jsxs("main",{className:"rounded-3xl border border-slate-200/70 bg-white/95 px-8 pb-10 pt-9 shadow-2xl shadow-slate-200/40 backdrop-blur-xl dark:border-slate-800/60 dark:bg-slate-900/85 dark:shadow-slate-900/60",children:[e.jsxs("header",{className:"mb-8 flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-gradient-to-br from-slate-900 via-slate-800 to-slate-700 text-xl font-bold text-white shadow-lg shadow-slate-400/30 dark:from-blue-500 dark:via-blue-600 dark:to-indigo-600 dark:shadow-blue-900/40",children:"GW"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-2xl font-semibold text-slate-900 dark:text-slate-50",children:a("login.title")}),e.jsx("p",{className:d(j,"text-sm leading-relaxed max-w-[360px]"),children:a("login.description")})]})]}),e.jsxs("form",{className:"space-y-5",onSubmit:N,children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:a("login.fields.username")}),e.jsx("input",{value:r.username,autoComplete:"username",autoFocus:!0,onChange:s=>h(t=>({...t,username:s.target.value})),placeholder:a("login.fields.usernamePlaceholder"),className:d(v,"h-11 font-medium")})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:a("login.fields.password")}),e.jsx("input",{type:"password",value:r.password,autoComplete:"current-password",onChange:s=>h(t=>({...t,password:s.target.value})),placeholder:a("login.fields.passwordPlaceholder"),className:d(v,"h-11")})]}),f||b?e.jsx("div",{className:"rounded-2xl border border-red-200/70 bg-red-50/80 px-4 py-3 text-sm font-medium text-red-600 shadow-sm shadow-red-200/40 dark:border-red-500/40 dark:bg-red-500/15 dark:text-red-100",children:f||b}):null,e.jsx("button",{type:"submit",className:d(L,"w-full justify-center rounded-full py-3 text-sm font-semibold"),disabled:p,children:a(p?"common.actions.loading":"login.actions.submit")})]}),e.jsx("footer",{className:"mt-7 text-center text-xs",children:e.jsx("p",{className:d(j,"leading-relaxed"),children:a("login.hint")})})]})):null}export{P as default};
1
+ import{u as y,a8 as E,a9 as C,aa as S,r as l,j as e,d,L as _,m as j,K as v,E as L}from"./index-3UByifOG.js";function P(){const{t:a}=y(),o=E(),m=C(),{authEnabled:n,isAuthenticated:x,loading:i,login:k,error:b}=S(),[r,h]=l.useState({username:"",password:""}),[f,u]=l.useState(null),[p,g]=l.useState(!1),c=l.useMemo(()=>{var t;const s=m.state;return((t=s==null?void 0:s.from)==null?void 0:t.pathname)??"/"},[m.state]);l.useEffect(()=>{if(!n&&!i){o(c,{replace:!0});return}n&&x&&!i&&o(c,{replace:!0})},[n,x,i,o,c]);const N=async s=>{if(s.preventDefault(),u(null),!r.username.trim()||!r.password){u(a("login.validation.required"));return}g(!0);try{await k(r.username.trim(),r.password),o(c,{replace:!0})}catch(t){u(t instanceof Error?t.message:a("login.validation.failed"))}finally{g(!1)}},w=s=>e.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-gradient-to-br from-slate-100 via-white to-slate-200 px-4 dark:from-slate-950/95 dark:via-slate-950 dark:to-slate-900",children:[e.jsxs("div",{className:"pointer-events-none absolute inset-0",children:[e.jsx("div",{className:"absolute left-10 top-20 h-48 w-48 rounded-full bg-slate-200/40 blur-3xl dark:bg-slate-700/30"}),e.jsx("div",{className:"absolute right-16 bottom-32 h-56 w-56 rounded-full bg-slate-300/35 blur-3xl dark:bg-slate-800/30"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_top,_rgba(15,23,42,0.08),_transparent_55%)]"})]}),e.jsx("div",{className:"relative z-10 w-full max-w-lg",children:s})]});return i?w(e.jsx("div",{className:"flex min-h-[320px] items-center justify-center rounded-3xl border border-blue-200/60 bg-white/90 shadow-2xl shadow-blue-200/50 backdrop-blur-xl dark:border-slate-800/50 dark:bg-slate-900/80 dark:shadow-slate-900/60",children:e.jsx(_,{})})):n?w(e.jsxs("main",{className:"rounded-3xl border border-slate-200/70 bg-white/95 px-8 pb-10 pt-9 shadow-2xl shadow-slate-200/40 backdrop-blur-xl dark:border-slate-800/60 dark:bg-slate-900/85 dark:shadow-slate-900/60",children:[e.jsxs("header",{className:"mb-8 flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-gradient-to-br from-slate-900 via-slate-800 to-slate-700 text-xl font-bold text-white shadow-lg shadow-slate-400/30 dark:from-blue-500 dark:via-blue-600 dark:to-indigo-600 dark:shadow-blue-900/40",children:"GW"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-2xl font-semibold text-slate-900 dark:text-slate-50",children:a("login.title")}),e.jsx("p",{className:d(j,"text-sm leading-relaxed max-w-[360px]"),children:a("login.description")})]})]}),e.jsxs("form",{className:"space-y-5",onSubmit:N,children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:a("login.fields.username")}),e.jsx("input",{value:r.username,autoComplete:"username",autoFocus:!0,onChange:s=>h(t=>({...t,username:s.target.value})),placeholder:a("login.fields.usernamePlaceholder"),className:d(v,"h-11 font-medium")})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:a("login.fields.password")}),e.jsx("input",{type:"password",value:r.password,autoComplete:"current-password",onChange:s=>h(t=>({...t,password:s.target.value})),placeholder:a("login.fields.passwordPlaceholder"),className:d(v,"h-11")})]}),f||b?e.jsx("div",{className:"rounded-2xl border border-red-200/70 bg-red-50/80 px-4 py-3 text-sm font-medium text-red-600 shadow-sm shadow-red-200/40 dark:border-red-500/40 dark:bg-red-500/15 dark:text-red-100",children:f||b}):null,e.jsx("button",{type:"submit",className:d(L,"w-full justify-center rounded-full py-3 text-sm font-semibold"),disabled:p,children:a(p?"common.actions.loading":"login.actions.submit")})]}),e.jsx("footer",{className:"mt-7 text-center text-xs",children:e.jsx("p",{className:d(j,"leading-relaxed"),children:a("login.hint")})})]})):null}export{P as default};