dsh-model-allowance 1.1.1 → 1.2.0
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/README.md +9 -3
- package/README.zh.md +7 -3
- package/client.js +277 -118
- package/index.js +69 -0
- package/lib/providers/promotions.js +169 -0
- package/lib/providers/qwen_promotions.js +223 -0
- package/lib/providers/qwen_token_plan.js +3 -0
- package/lib/providers/shared.js +14 -0
- package/lib/providers/zai.js +25 -0
- package/lib/providers.js +4 -0
- package/lib/remote.js +14 -0
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -42,14 +42,14 @@ __export(index_exports, {
|
|
|
42
42
|
inject: () => inject
|
|
43
43
|
});
|
|
44
44
|
module.exports = __toCommonJS(index_exports);
|
|
45
|
-
var
|
|
45
|
+
var import_react10 = require("react");
|
|
46
46
|
|
|
47
47
|
// src/client/badge.js
|
|
48
48
|
var React6 = __toESM(require("react"), 1);
|
|
49
|
-
var
|
|
49
|
+
var import_react8 = require("react");
|
|
50
50
|
|
|
51
51
|
// src/client/components/balance-panel.js
|
|
52
|
-
var
|
|
52
|
+
var import_react7 = require("react");
|
|
53
53
|
|
|
54
54
|
// src/client/format.js
|
|
55
55
|
var CURRENCY_SYMBOLS = {
|
|
@@ -616,6 +616,9 @@ function statusLabel(state, t) {
|
|
|
616
616
|
return key === void 0 ? t("status.unknown") : t(key);
|
|
617
617
|
}
|
|
618
618
|
|
|
619
|
+
// src/client/promotions.js
|
|
620
|
+
var import_react3 = require("react");
|
|
621
|
+
|
|
619
622
|
// src/client/schedule.js
|
|
620
623
|
var import_react2 = require("react");
|
|
621
624
|
function formatCountdown(ms) {
|
|
@@ -810,6 +813,57 @@ function scheduleView(schedule, now, t) {
|
|
|
810
813
|
);
|
|
811
814
|
}
|
|
812
815
|
|
|
816
|
+
// src/client/promotions.js
|
|
817
|
+
var pad22 = (value) => String(value).padStart(2, "0");
|
|
818
|
+
function wallMinutes2(time) {
|
|
819
|
+
const [hour, minute] = time.split(":").map(Number);
|
|
820
|
+
return hour * 60 + minute;
|
|
821
|
+
}
|
|
822
|
+
function promotionActive(promotion, now) {
|
|
823
|
+
if (promotion.timezone === void 0) return true;
|
|
824
|
+
const parts = zoneParts(now, promotion.timezone);
|
|
825
|
+
if (promotion.from !== void 0 && promotion.to !== void 0) {
|
|
826
|
+
const date = `${String(parts.year)}-${pad22(parts.month)}-${pad22(parts.day)}`;
|
|
827
|
+
if (date < promotion.from || date > promotion.to) return false;
|
|
828
|
+
}
|
|
829
|
+
if (promotion.daily !== void 0) {
|
|
830
|
+
const minutes = parts.hour * 60 + parts.minute;
|
|
831
|
+
const from = wallMinutes2(promotion.daily.from);
|
|
832
|
+
const to = wallMinutes2(promotion.daily.to);
|
|
833
|
+
const inside = from <= to ? minutes >= from && minutes < to : minutes >= from || minutes < to;
|
|
834
|
+
if (!inside) return false;
|
|
835
|
+
}
|
|
836
|
+
return true;
|
|
837
|
+
}
|
|
838
|
+
function promotionChip(promotion) {
|
|
839
|
+
const language = activeLanguage();
|
|
840
|
+
return promotion.chip?.[language] ?? promotion.chip?.en ?? promotion.chip?.zh;
|
|
841
|
+
}
|
|
842
|
+
function promotionForModel(promotions, modelId) {
|
|
843
|
+
if (!Array.isArray(promotions) || typeof modelId !== "string" || modelId === "") return void 0;
|
|
844
|
+
const wanted = modelId.toLowerCase();
|
|
845
|
+
return promotions.find(
|
|
846
|
+
(promotion) => promotion.models.some((model) => model.toLowerCase() === wanted)
|
|
847
|
+
);
|
|
848
|
+
}
|
|
849
|
+
function promotionNote(promotion) {
|
|
850
|
+
const language = activeLanguage();
|
|
851
|
+
return promotion.note?.[language] ?? promotion.note?.en ?? promotion.note?.zh;
|
|
852
|
+
}
|
|
853
|
+
function promoTipView(promotion, position) {
|
|
854
|
+
const note = promotionNote(promotion);
|
|
855
|
+
if (note === void 0) return null;
|
|
856
|
+
return (0, import_react3.createElement)(
|
|
857
|
+
"div",
|
|
858
|
+
{
|
|
859
|
+
className: "dsh-model-allowance-promo-tip",
|
|
860
|
+
role: "tooltip",
|
|
861
|
+
style: { bottom: `${String(position.bottom)}px`, right: `${String(position.right)}px` }
|
|
862
|
+
},
|
|
863
|
+
note
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
|
|
813
867
|
// src/client/windows.js
|
|
814
868
|
function windowTitle(window, t) {
|
|
815
869
|
const label = window.label?.[activeLanguage()] ?? window.label?.en ?? window.label?.zh;
|
|
@@ -868,7 +922,7 @@ function barTone(percent) {
|
|
|
868
922
|
}
|
|
869
923
|
|
|
870
924
|
// src/client/components/effort-flyout.js
|
|
871
|
-
var
|
|
925
|
+
var import_react4 = require("react");
|
|
872
926
|
|
|
873
927
|
// src/client/models.js
|
|
874
928
|
function providerGroup(catalog, provider) {
|
|
@@ -921,7 +975,7 @@ function EffortFlyout({
|
|
|
921
975
|
keepEffortFlyout,
|
|
922
976
|
scheduleEffortFlyoutClose
|
|
923
977
|
}) {
|
|
924
|
-
return (0,
|
|
978
|
+
return (0, import_react4.createElement)(
|
|
925
979
|
"div",
|
|
926
980
|
{
|
|
927
981
|
className: "dsh-model-allowance-effort-menu",
|
|
@@ -935,7 +989,7 @@ function EffortFlyout({
|
|
|
935
989
|
},
|
|
936
990
|
...effortChoices(hoverModel.model).map((effort) => {
|
|
937
991
|
const isCurrentEffort = hoverModel.model.id === currentModel && effort.id === selectedEffort;
|
|
938
|
-
return (0,
|
|
992
|
+
return (0, import_react4.createElement)(
|
|
939
993
|
"button",
|
|
940
994
|
{
|
|
941
995
|
type: "button",
|
|
@@ -950,19 +1004,19 @@ function EffortFlyout({
|
|
|
950
1004
|
void switchToModel(hoverModel.model, effort.id);
|
|
951
1005
|
}
|
|
952
1006
|
},
|
|
953
|
-
(0,
|
|
1007
|
+
(0, import_react4.createElement)(
|
|
954
1008
|
"span",
|
|
955
1009
|
{ className: "dsh-model-allowance-model-name" },
|
|
956
1010
|
effort.providerDefault ? t("model.effortDefault") : effort.name
|
|
957
1011
|
),
|
|
958
|
-
effort.isDefault && !isCurrentEffort ? (0,
|
|
1012
|
+
effort.isDefault && !isCurrentEffort ? (0, import_react4.createElement)("span", { className: "dsh-model-allowance-model-note" }, t("model.effortDefault")) : null
|
|
959
1013
|
);
|
|
960
1014
|
})
|
|
961
1015
|
);
|
|
962
1016
|
}
|
|
963
1017
|
|
|
964
1018
|
// src/client/components/model-menu.js
|
|
965
|
-
var
|
|
1019
|
+
var import_react5 = require("react");
|
|
966
1020
|
function ModelMenu({
|
|
967
1021
|
t,
|
|
968
1022
|
models,
|
|
@@ -973,18 +1027,21 @@ function ModelMenu({
|
|
|
973
1027
|
switchToModel,
|
|
974
1028
|
modelWrapRef,
|
|
975
1029
|
showEffortFlyout,
|
|
976
|
-
scheduleEffortFlyoutClose
|
|
1030
|
+
scheduleEffortFlyoutClose,
|
|
1031
|
+
promotions,
|
|
1032
|
+
showPromoTip,
|
|
1033
|
+
hidePromoTip
|
|
977
1034
|
}) {
|
|
978
|
-
return (0,
|
|
1035
|
+
return (0, import_react5.createElement)(
|
|
979
1036
|
"div",
|
|
980
1037
|
{
|
|
981
1038
|
className: "dsh-model-allowance-model-menu",
|
|
982
1039
|
role: "menu",
|
|
983
1040
|
"aria-label": t("model.title")
|
|
984
1041
|
},
|
|
985
|
-
state === "loading" ? (0,
|
|
986
|
-
state === "empty" ? (0,
|
|
987
|
-
state === "error" ? (0,
|
|
1042
|
+
state === "loading" ? (0, import_react5.createElement)("div", { className: "dsh-model-allowance-model-message" }, t("model.loading")) : null,
|
|
1043
|
+
state === "empty" ? (0, import_react5.createElement)("div", { className: "dsh-model-allowance-model-message" }, t("model.empty")) : null,
|
|
1044
|
+
state === "error" ? (0, import_react5.createElement)(
|
|
988
1045
|
"div",
|
|
989
1046
|
{
|
|
990
1047
|
className: "dsh-model-allowance-model-message",
|
|
@@ -996,7 +1053,9 @@ function ModelMenu({
|
|
|
996
1053
|
const isCurrent = model.id === currentModel;
|
|
997
1054
|
const efforts = effortChoices(model);
|
|
998
1055
|
const defaultEffortId = efforts?.find((effort) => effort.isDefault)?.id;
|
|
999
|
-
|
|
1056
|
+
const promotion = promotionForModel(promotions, model.id);
|
|
1057
|
+
const chip = promotion === void 0 ? void 0 : promotionChip(promotion);
|
|
1058
|
+
return (0, import_react5.createElement)(
|
|
1000
1059
|
"button",
|
|
1001
1060
|
{
|
|
1002
1061
|
type: "button",
|
|
@@ -1013,6 +1072,7 @@ function ModelMenu({
|
|
|
1013
1072
|
},
|
|
1014
1073
|
...efforts === null ? {} : {
|
|
1015
1074
|
onMouseEnter: (event) => {
|
|
1075
|
+
if (event.target?.closest?.(".dsh-model-allowance-promo-chip")) return;
|
|
1016
1076
|
const wrap = modelWrapRef.current;
|
|
1017
1077
|
if (!wrap) return;
|
|
1018
1078
|
const top = event.currentTarget.getBoundingClientRect().top - wrap.getBoundingClientRect().top;
|
|
@@ -1023,12 +1083,30 @@ function ModelMenu({
|
|
|
1023
1083
|
}
|
|
1024
1084
|
}
|
|
1025
1085
|
},
|
|
1026
|
-
(0,
|
|
1027
|
-
(0,
|
|
1086
|
+
(0, import_react5.createElement)("span", { className: "dsh-model-allowance-model-name" }, model.name ?? model.id),
|
|
1087
|
+
promotion === void 0 || chip === void 0 || chip === "" ? null : (0, import_react5.createElement)(
|
|
1088
|
+
"span",
|
|
1089
|
+
{
|
|
1090
|
+
className: "dsh-model-allowance-promo-chip",
|
|
1091
|
+
// A bare span is role=generic, which ARIA forbids naming;
|
|
1092
|
+
// img lets the announcement reach assistive tech.
|
|
1093
|
+
role: "img",
|
|
1094
|
+
"aria-label": promotionNote(promotion),
|
|
1095
|
+
onMouseEnter: (event) => {
|
|
1096
|
+
scheduleEffortFlyoutClose(model.id);
|
|
1097
|
+
showPromoTip?.(model, event);
|
|
1098
|
+
},
|
|
1099
|
+
onMouseLeave: () => {
|
|
1100
|
+
hidePromoTip?.();
|
|
1101
|
+
}
|
|
1102
|
+
},
|
|
1103
|
+
chip
|
|
1104
|
+
),
|
|
1105
|
+
(0, import_react5.createElement)(
|
|
1028
1106
|
"span",
|
|
1029
1107
|
{ className: "dsh-model-allowance-model-side" },
|
|
1030
|
-
switchingModel === model.id ? (0,
|
|
1031
|
-
efforts === null ? null : (0,
|
|
1108
|
+
switchingModel === model.id ? (0, import_react5.createElement)("span", { className: "dsh-model-allowance-model-note" }, t("model.switching")) : isCurrent ? (0, import_react5.createElement)("span", { className: "dsh-model-allowance-model-note" }, t("model.current")) : null,
|
|
1109
|
+
efforts === null ? null : (0, import_react5.createElement)(
|
|
1032
1110
|
"span",
|
|
1033
1111
|
{
|
|
1034
1112
|
className: "dsh-model-allowance-model-arrow",
|
|
@@ -1040,7 +1118,7 @@ function ModelMenu({
|
|
|
1040
1118
|
);
|
|
1041
1119
|
}),
|
|
1042
1120
|
// A failed switch keeps the list open and says why.
|
|
1043
|
-
modelError && state !== "error" ? (0,
|
|
1121
|
+
modelError && state !== "error" ? (0, import_react5.createElement)(
|
|
1044
1122
|
"div",
|
|
1045
1123
|
{
|
|
1046
1124
|
className: "dsh-model-allowance-model-message",
|
|
@@ -1053,7 +1131,7 @@ function ModelMenu({
|
|
|
1053
1131
|
|
|
1054
1132
|
// src/client/components/provider-strip.js
|
|
1055
1133
|
var React2 = __toESM(require("react"), 1);
|
|
1056
|
-
var
|
|
1134
|
+
var import_react6 = require("react");
|
|
1057
1135
|
|
|
1058
1136
|
// src/client/hooks/use-provider-directory.js
|
|
1059
1137
|
var React = __toESM(require("react"), 1);
|
|
@@ -1211,7 +1289,7 @@ function ProviderStrip({
|
|
|
1211
1289
|
const mark = markFor(entry.route);
|
|
1212
1290
|
const name = nameOf(entry.route);
|
|
1213
1291
|
const active = entryCovers(entry, activeProvider);
|
|
1214
|
-
return (0,
|
|
1292
|
+
return (0, import_react6.createElement)(
|
|
1215
1293
|
"button",
|
|
1216
1294
|
{
|
|
1217
1295
|
type: "button",
|
|
@@ -1240,10 +1318,10 @@ function ProviderStrip({
|
|
|
1240
1318
|
event.preventDefault();
|
|
1241
1319
|
tabs[next]?.focus();
|
|
1242
1320
|
};
|
|
1243
|
-
return (0,
|
|
1321
|
+
return (0, import_react6.createElement)(
|
|
1244
1322
|
"div",
|
|
1245
1323
|
{ className: "dsh-model-allowance-switcher-wrap" },
|
|
1246
|
-
(0,
|
|
1324
|
+
(0, import_react6.createElement)(
|
|
1247
1325
|
"div",
|
|
1248
1326
|
{
|
|
1249
1327
|
ref: stripRef,
|
|
@@ -1253,7 +1331,7 @@ function ProviderStrip({
|
|
|
1253
1331
|
onKeyDown: onTabKeyDown
|
|
1254
1332
|
},
|
|
1255
1333
|
...shown.map(markButton),
|
|
1256
|
-
overflow.length > 0 ? (0,
|
|
1334
|
+
overflow.length > 0 ? (0, import_react6.createElement)(
|
|
1257
1335
|
"button",
|
|
1258
1336
|
{
|
|
1259
1337
|
type: "button",
|
|
@@ -1267,11 +1345,11 @@ function ProviderStrip({
|
|
|
1267
1345
|
"\u22EF"
|
|
1268
1346
|
) : null
|
|
1269
1347
|
),
|
|
1270
|
-
menuOpen && overflow.length > 0 ? (0,
|
|
1348
|
+
menuOpen && overflow.length > 0 ? (0, import_react6.createElement)(
|
|
1271
1349
|
"div",
|
|
1272
1350
|
{ className: "dsh-model-allowance-menu", role: "menu" },
|
|
1273
1351
|
...overflow.map(
|
|
1274
|
-
(entry) => (0,
|
|
1352
|
+
(entry) => (0, import_react6.createElement)(
|
|
1275
1353
|
"button",
|
|
1276
1354
|
{
|
|
1277
1355
|
type: "button",
|
|
@@ -1283,7 +1361,7 @@ function ProviderStrip({
|
|
|
1283
1361
|
setMenuOpen(false);
|
|
1284
1362
|
}
|
|
1285
1363
|
},
|
|
1286
|
-
(0,
|
|
1364
|
+
(0, import_react6.createElement)(
|
|
1287
1365
|
"span",
|
|
1288
1366
|
{
|
|
1289
1367
|
className: "dsh-model-allowance-menu-mark",
|
|
@@ -1291,7 +1369,7 @@ function ProviderStrip({
|
|
|
1291
1369
|
},
|
|
1292
1370
|
providerIcon(entry.route, 11, markFor(entry.route))
|
|
1293
1371
|
),
|
|
1294
|
-
(0,
|
|
1372
|
+
(0, import_react6.createElement)("span", null, nameOf(entry.route))
|
|
1295
1373
|
)
|
|
1296
1374
|
)
|
|
1297
1375
|
) : null
|
|
@@ -1306,6 +1384,7 @@ function BalancePanel({
|
|
|
1306
1384
|
activeProvider,
|
|
1307
1385
|
available,
|
|
1308
1386
|
schedule,
|
|
1387
|
+
promotions,
|
|
1309
1388
|
currentStatus,
|
|
1310
1389
|
serviceState,
|
|
1311
1390
|
refresh,
|
|
@@ -1324,7 +1403,9 @@ function BalancePanel({
|
|
|
1324
1403
|
setStripWidth,
|
|
1325
1404
|
stripRef
|
|
1326
1405
|
}) {
|
|
1327
|
-
|
|
1406
|
+
const activePromotions = promotions?.provider === activeProvider ? (promotions.promotions ?? []).filter((promotion) => promotionActive(promotion, now)) : [];
|
|
1407
|
+
const tipPromotion = catalog.promoTip == null ? void 0 : promotionForModel(activePromotions, catalog.promoTip.model.id);
|
|
1408
|
+
return (0, import_react7.createElement)(
|
|
1328
1409
|
"div",
|
|
1329
1410
|
{
|
|
1330
1411
|
className: "dsh-model-allowance-panel",
|
|
@@ -1334,7 +1415,7 @@ function BalancePanel({
|
|
|
1334
1415
|
},
|
|
1335
1416
|
// With more than one readable provider the card opens a switcher;
|
|
1336
1417
|
// with one there is nothing to switch, so it just names it.
|
|
1337
|
-
available.length > 1 ? (0,
|
|
1418
|
+
available.length > 1 ? (0, import_react7.createElement)(ProviderStrip, {
|
|
1338
1419
|
t,
|
|
1339
1420
|
available,
|
|
1340
1421
|
activeProvider,
|
|
@@ -1346,24 +1427,24 @@ function BalancePanel({
|
|
|
1346
1427
|
stripWidth,
|
|
1347
1428
|
setStripWidth,
|
|
1348
1429
|
stripRef
|
|
1349
|
-
}) : (0,
|
|
1430
|
+
}) : (0, import_react7.createElement)(
|
|
1350
1431
|
"div",
|
|
1351
1432
|
{ className: "dsh-model-allowance-row" },
|
|
1352
|
-
(0,
|
|
1353
|
-
(0,
|
|
1433
|
+
(0, import_react7.createElement)("span", null, t("detail.provider")),
|
|
1434
|
+
(0, import_react7.createElement)("span", null, nameOf(activeProvider))
|
|
1354
1435
|
),
|
|
1355
|
-
view?.kind === "amount" && typeof view.amount === "number" ? (0,
|
|
1436
|
+
view?.kind === "amount" && typeof view.amount === "number" ? (0, import_react7.createElement)(
|
|
1356
1437
|
"div",
|
|
1357
1438
|
{ className: "dsh-model-allowance-row" },
|
|
1358
|
-
(0,
|
|
1359
|
-
(0,
|
|
1439
|
+
(0, import_react7.createElement)("span", null, t("detail.amount")),
|
|
1440
|
+
(0, import_react7.createElement)("span", null, formatAmount(view.amount, view.currency))
|
|
1360
1441
|
) : null,
|
|
1361
1442
|
...Array.isArray(view?.windows) && view.windows.length > 0 ? view.windows.map((window, index) => {
|
|
1362
1443
|
const consumed = windowUsedPercent(window);
|
|
1363
1444
|
const percent = consumed === void 0 ? void 0 : Math.max(0, Math.round(consumed));
|
|
1364
1445
|
const filled = consumed === void 0 ? 0 : Math.min(100, Math.max(0, consumed));
|
|
1365
1446
|
const usage = windowUsage(window, t);
|
|
1366
|
-
return (0,
|
|
1447
|
+
return (0, import_react7.createElement)(
|
|
1367
1448
|
"div",
|
|
1368
1449
|
{
|
|
1369
1450
|
className: "dsh-model-allowance-window",
|
|
@@ -1374,20 +1455,20 @@ function BalancePanel({
|
|
|
1374
1455
|
// *between* windows are drawn.
|
|
1375
1456
|
"data-first": index === 0 ? "true" : void 0
|
|
1376
1457
|
},
|
|
1377
|
-
(0,
|
|
1458
|
+
(0, import_react7.createElement)(
|
|
1378
1459
|
"div",
|
|
1379
1460
|
{ className: "dsh-model-allowance-window-head" },
|
|
1380
|
-
(0,
|
|
1461
|
+
(0, import_react7.createElement)("span", { className: "dsh-model-allowance-window-title" }, windowTitle(window, t)),
|
|
1381
1462
|
// Countable units sit beside the title; a plan that
|
|
1382
1463
|
// reports only a percentage has none to show.
|
|
1383
|
-
usage === void 0 ? null : (0,
|
|
1464
|
+
usage === void 0 ? null : (0, import_react7.createElement)("span", { className: "dsh-model-allowance-usage" }, usage)
|
|
1384
1465
|
),
|
|
1385
|
-
percent === void 0 ? null : (0,
|
|
1466
|
+
percent === void 0 ? null : (0, import_react7.createElement)(
|
|
1386
1467
|
"div",
|
|
1387
1468
|
{ className: "dsh-model-allowance-percent" },
|
|
1388
1469
|
t("window.usedPercent", { percent })
|
|
1389
1470
|
),
|
|
1390
|
-
percent === void 0 ? null : (0,
|
|
1471
|
+
percent === void 0 ? null : (0, import_react7.createElement)(
|
|
1391
1472
|
"div",
|
|
1392
1473
|
{
|
|
1393
1474
|
className: "dsh-model-allowance-bar",
|
|
@@ -1397,7 +1478,7 @@ function BalancePanel({
|
|
|
1397
1478
|
"aria-valuemax": 100,
|
|
1398
1479
|
"aria-valuetext": t("window.usedPercent", { percent })
|
|
1399
1480
|
},
|
|
1400
|
-
(0,
|
|
1481
|
+
(0, import_react7.createElement)("div", {
|
|
1401
1482
|
className: "dsh-model-allowance-bar-fill",
|
|
1402
1483
|
"data-tone": barTone(percent),
|
|
1403
1484
|
style: { width: `${String(filled)}%` }
|
|
@@ -1406,59 +1487,59 @@ function BalancePanel({
|
|
|
1406
1487
|
// A window with zero usage has not started its rolling timer
|
|
1407
1488
|
// yet, so the countdown would be misleading. Hide it until
|
|
1408
1489
|
// consumption begins.
|
|
1409
|
-
typeof window.resetAt === "number" && (typeof window.remainingPercent !== "number" || window.remainingPercent < 100) ? (0,
|
|
1490
|
+
typeof window.resetAt === "number" && (typeof window.remainingPercent !== "number" || window.remainingPercent < 100) ? (0, import_react7.createElement)(
|
|
1410
1491
|
"div",
|
|
1411
1492
|
{ className: "dsh-model-allowance-foot" },
|
|
1412
|
-
(0,
|
|
1493
|
+
(0, import_react7.createElement)(
|
|
1413
1494
|
"span",
|
|
1414
1495
|
null,
|
|
1415
1496
|
t("window.resetIn", {
|
|
1416
1497
|
duration: formatCountdown(window.resetAt - now)
|
|
1417
1498
|
})
|
|
1418
1499
|
),
|
|
1419
|
-
(0,
|
|
1500
|
+
(0, import_react7.createElement)("span", null, formatResetAt(window.resetAt))
|
|
1420
1501
|
) : null
|
|
1421
1502
|
);
|
|
1422
1503
|
}) : [],
|
|
1423
1504
|
// A single scalar reading has no windows to break down.
|
|
1424
|
-
!Array.isArray(view?.windows) && typeof view?.remainingMs === "number" ? (0,
|
|
1505
|
+
!Array.isArray(view?.windows) && typeof view?.remainingMs === "number" ? (0, import_react7.createElement)(
|
|
1425
1506
|
"div",
|
|
1426
1507
|
{ className: "dsh-model-allowance-row" },
|
|
1427
|
-
(0,
|
|
1428
|
-
(0,
|
|
1508
|
+
(0, import_react7.createElement)("span", null, t("detail.remaining")),
|
|
1509
|
+
(0, import_react7.createElement)("span", null, formatDuration(view.remainingMs, t))
|
|
1429
1510
|
) : null,
|
|
1430
|
-
!Array.isArray(view?.windows) && typeof view?.remaining === "number" ? (0,
|
|
1511
|
+
!Array.isArray(view?.windows) && typeof view?.remaining === "number" ? (0, import_react7.createElement)(
|
|
1431
1512
|
"div",
|
|
1432
1513
|
{ className: "dsh-model-allowance-row" },
|
|
1433
|
-
(0,
|
|
1434
|
-
(0,
|
|
1514
|
+
(0, import_react7.createElement)("span", null, t("detail.remaining")),
|
|
1515
|
+
(0, import_react7.createElement)("span", null, String(view.remaining))
|
|
1435
1516
|
) : null,
|
|
1436
|
-
!Array.isArray(view?.windows) && typeof view?.total === "number" ? (0,
|
|
1517
|
+
!Array.isArray(view?.windows) && typeof view?.total === "number" ? (0, import_react7.createElement)(
|
|
1437
1518
|
"div",
|
|
1438
1519
|
{ className: "dsh-model-allowance-row" },
|
|
1439
|
-
(0,
|
|
1440
|
-
(0,
|
|
1520
|
+
(0, import_react7.createElement)("span", null, t("detail.total")),
|
|
1521
|
+
(0, import_react7.createElement)("span", null, String(view.total))
|
|
1441
1522
|
) : null,
|
|
1442
|
-
view?.status === "failed" ? (0,
|
|
1523
|
+
view?.status === "failed" ? (0, import_react7.createElement)(
|
|
1443
1524
|
"div",
|
|
1444
1525
|
{ className: "dsh-model-allowance-error" },
|
|
1445
1526
|
t("detail.error"),
|
|
1446
1527
|
// The Host reports why a reading failed; showing it is what
|
|
1447
1528
|
// turns "it does not work" into something actionable.
|
|
1448
|
-
view.error ? (0,
|
|
1529
|
+
view.error ? (0, import_react7.createElement)("div", { className: "dsh-model-allowance-reason" }, view.error) : null
|
|
1449
1530
|
) : null,
|
|
1450
|
-
view?.status === "unsupported" ? (0,
|
|
1531
|
+
view?.status === "unsupported" ? (0, import_react7.createElement)(
|
|
1451
1532
|
"div",
|
|
1452
1533
|
{ className: "dsh-model-allowance-reason" },
|
|
1453
1534
|
t("badge.unsupportedWithName", { name: nameOf(activeProvider) })
|
|
1454
1535
|
) : null,
|
|
1455
|
-
view?.status === "unconfigured" ? (0,
|
|
1536
|
+
view?.status === "unconfigured" ? (0, import_react7.createElement)(
|
|
1456
1537
|
"div",
|
|
1457
1538
|
{ className: "dsh-model-allowance-reason" },
|
|
1458
1539
|
t("badge.setupHint"),
|
|
1459
1540
|
// The reading carries the provider's setup guide; it is the walk
|
|
1460
1541
|
// from "no credential" to a stored pair, so it is one click away.
|
|
1461
|
-
view.setupUrl ? (0,
|
|
1542
|
+
view.setupUrl ? (0, import_react7.createElement)(
|
|
1462
1543
|
"a",
|
|
1463
1544
|
{
|
|
1464
1545
|
className: "dsh-model-allowance-setup-link",
|
|
@@ -1472,16 +1553,16 @@ function BalancePanel({
|
|
|
1472
1553
|
// A vendor that prices by the wall clock gets its phase and
|
|
1473
1554
|
// countdown here, above the footer.
|
|
1474
1555
|
schedule && schedule.provider === activeProvider ? scheduleView(schedule, now, t) : null,
|
|
1475
|
-
(0,
|
|
1556
|
+
(0, import_react7.createElement)(
|
|
1476
1557
|
"div",
|
|
1477
1558
|
{ className: "dsh-model-allowance-actions" },
|
|
1478
1559
|
// The platform status sits at the left edge of the footer, on
|
|
1479
1560
|
// the same line as the reading time: the card gains no extra
|
|
1480
1561
|
// row, and the state and the source page stay together.
|
|
1481
|
-
(0,
|
|
1562
|
+
(0, import_react7.createElement)(
|
|
1482
1563
|
"span",
|
|
1483
1564
|
{ className: "dsh-model-allowance-status-wrap" },
|
|
1484
|
-
(0,
|
|
1565
|
+
(0, import_react7.createElement)(
|
|
1485
1566
|
currentStatus?.url ? "a" : "span",
|
|
1486
1567
|
{
|
|
1487
1568
|
className: "dsh-model-allowance-status",
|
|
@@ -1492,17 +1573,17 @@ function BalancePanel({
|
|
|
1492
1573
|
rel: "noreferrer noopener"
|
|
1493
1574
|
} : {}
|
|
1494
1575
|
},
|
|
1495
|
-
(0,
|
|
1576
|
+
(0, import_react7.createElement)("span", {
|
|
1496
1577
|
className: "dsh-model-allowance-status-dot",
|
|
1497
1578
|
"aria-hidden": true
|
|
1498
1579
|
}),
|
|
1499
|
-
(0,
|
|
1580
|
+
(0, import_react7.createElement)(
|
|
1500
1581
|
"span",
|
|
1501
1582
|
{ className: "dsh-model-allowance-status-label" },
|
|
1502
1583
|
statusLabel(serviceState, t)
|
|
1503
1584
|
),
|
|
1504
1585
|
...currentStatus?.url ? [
|
|
1505
|
-
(0,
|
|
1586
|
+
(0, import_react7.createElement)(
|
|
1506
1587
|
"span",
|
|
1507
1588
|
{
|
|
1508
1589
|
className: "dsh-model-allowance-status-arrow",
|
|
@@ -1515,7 +1596,7 @@ function BalancePanel({
|
|
|
1515
1596
|
// The reason is a warning mark rather than another line:
|
|
1516
1597
|
// the footer stays one row, and the detail is one hover
|
|
1517
1598
|
// — or one keyboard focus — away.
|
|
1518
|
-
currentStatus?.summary ? (0,
|
|
1599
|
+
currentStatus?.summary ? (0, import_react7.createElement)(
|
|
1519
1600
|
"span",
|
|
1520
1601
|
{
|
|
1521
1602
|
className: "dsh-model-allowance-status-help",
|
|
@@ -1523,26 +1604,26 @@ function BalancePanel({
|
|
|
1523
1604
|
role: "note",
|
|
1524
1605
|
"aria-label": currentStatus.summary
|
|
1525
1606
|
},
|
|
1526
|
-
(0,
|
|
1607
|
+
(0, import_react7.createElement)(
|
|
1527
1608
|
"span",
|
|
1528
1609
|
{
|
|
1529
1610
|
"aria-hidden": true
|
|
1530
1611
|
},
|
|
1531
1612
|
"!"
|
|
1532
1613
|
),
|
|
1533
|
-
(0,
|
|
1614
|
+
(0, import_react7.createElement)(
|
|
1534
1615
|
"span",
|
|
1535
1616
|
{ className: "dsh-model-allowance-status-tip", role: "tooltip" },
|
|
1536
1617
|
currentStatus.summary
|
|
1537
1618
|
)
|
|
1538
1619
|
) : null
|
|
1539
1620
|
),
|
|
1540
|
-
view?.updatedAt ? (0,
|
|
1621
|
+
view?.updatedAt ? (0, import_react7.createElement)(
|
|
1541
1622
|
"span",
|
|
1542
1623
|
{ className: "dsh-model-allowance-updated" },
|
|
1543
1624
|
t("detail.updatedAt", { time: formatClock(view.updatedAt) })
|
|
1544
1625
|
) : null,
|
|
1545
|
-
(0,
|
|
1626
|
+
(0, import_react7.createElement)(
|
|
1546
1627
|
"button",
|
|
1547
1628
|
{
|
|
1548
1629
|
type: "button",
|
|
@@ -1554,7 +1635,7 @@ function BalancePanel({
|
|
|
1554
1635
|
},
|
|
1555
1636
|
refreshGlyph(16)
|
|
1556
1637
|
),
|
|
1557
|
-
view?.consoleUrl ? (0,
|
|
1638
|
+
view?.consoleUrl ? (0, import_react7.createElement)(
|
|
1558
1639
|
"a",
|
|
1559
1640
|
{
|
|
1560
1641
|
className: "dsh-model-allowance-icon-button",
|
|
@@ -1569,10 +1650,10 @@ function BalancePanel({
|
|
|
1569
1650
|
// The switch to another model of this provider. It sits to the
|
|
1570
1651
|
// right of the console link, which is the last thing the footer
|
|
1571
1652
|
// offered before, so the two never trade places.
|
|
1572
|
-
canSwitch ? (0,
|
|
1653
|
+
canSwitch ? (0, import_react7.createElement)(
|
|
1573
1654
|
"span",
|
|
1574
1655
|
{ ref: catalog.modelWrapRef, className: "dsh-model-allowance-model-wrap" },
|
|
1575
|
-
(0,
|
|
1656
|
+
(0, import_react7.createElement)(
|
|
1576
1657
|
"button",
|
|
1577
1658
|
{
|
|
1578
1659
|
type: "button",
|
|
@@ -1590,7 +1671,7 @@ function BalancePanel({
|
|
|
1590
1671
|
},
|
|
1591
1672
|
modelGlyph(16)
|
|
1592
1673
|
),
|
|
1593
|
-
catalog.modelMenuOpen ? (0,
|
|
1674
|
+
catalog.modelMenuOpen ? (0, import_react7.createElement)(ModelMenu, {
|
|
1594
1675
|
t,
|
|
1595
1676
|
models: catalog.shownModelList,
|
|
1596
1677
|
state: catalog.shownModelListState,
|
|
@@ -1600,12 +1681,15 @@ function BalancePanel({
|
|
|
1600
1681
|
switchToModel: catalog.switchToModel,
|
|
1601
1682
|
modelWrapRef: catalog.modelWrapRef,
|
|
1602
1683
|
showEffortFlyout: catalog.showEffortFlyout,
|
|
1603
|
-
scheduleEffortFlyoutClose: catalog.scheduleEffortFlyoutClose
|
|
1684
|
+
scheduleEffortFlyoutClose: catalog.scheduleEffortFlyoutClose,
|
|
1685
|
+
promotions: activePromotions,
|
|
1686
|
+
showPromoTip: catalog.showPromoTip,
|
|
1687
|
+
hidePromoTip: catalog.hidePromoTip
|
|
1604
1688
|
}) : null,
|
|
1605
1689
|
// The effort flyout is a sibling of the list, not a
|
|
1606
1690
|
// child: the list scrolls, and a nested panel would be
|
|
1607
1691
|
// clipped by it.
|
|
1608
|
-
catalog.modelMenuOpen && catalog.hoverModel !== null && catalog.shownModelList.includes(catalog.hoverModel.model) ? (0,
|
|
1692
|
+
catalog.modelMenuOpen && catalog.hoverModel !== null && catalog.shownModelList.includes(catalog.hoverModel.model) ? (0, import_react7.createElement)(EffortFlyout, {
|
|
1609
1693
|
t,
|
|
1610
1694
|
hoverModel: catalog.hoverModel,
|
|
1611
1695
|
currentModel: catalog.currentModel,
|
|
@@ -1614,7 +1698,11 @@ function BalancePanel({
|
|
|
1614
1698
|
switchToModel: catalog.switchToModel,
|
|
1615
1699
|
keepEffortFlyout: catalog.keepEffortFlyout,
|
|
1616
1700
|
scheduleEffortFlyoutClose: catalog.scheduleEffortFlyoutClose
|
|
1617
|
-
}) : null
|
|
1701
|
+
}) : null,
|
|
1702
|
+
// The badge's tip is a sibling of the list for the same reason
|
|
1703
|
+
// the flyout is: the list scrolls, and a nested hint would be
|
|
1704
|
+
// clipped by it.
|
|
1705
|
+
catalog.modelMenuOpen && catalog.promoTip != null && tipPromotion !== void 0 && catalog.shownModelList.some((model) => model.id === catalog.promoTip.model.id) ? promoTipView(tipPromotion, catalog.promoTip) : null
|
|
1618
1706
|
) : null
|
|
1619
1707
|
)
|
|
1620
1708
|
);
|
|
@@ -1782,6 +1870,7 @@ function useModelCatalog({ ctx, t, sessionId, activeProvider, entryOf, selection
|
|
|
1782
1870
|
const [modelMenuOpen, setModelMenuOpen] = React5.useState(false);
|
|
1783
1871
|
const [hoverModel, setHoverModel] = React5.useState(null);
|
|
1784
1872
|
const hoverModelTimer = React5.useRef(null);
|
|
1873
|
+
const [promoTip, setPromoTip] = React5.useState(null);
|
|
1785
1874
|
const [switchingModel, setSwitchingModel] = React5.useState(null);
|
|
1786
1875
|
const modelWrapRef = React5.useRef(null);
|
|
1787
1876
|
const catalogRef = React5.useRef({ value: null, at: 0 });
|
|
@@ -1896,10 +1985,25 @@ function useModelCatalog({ ctx, t, sessionId, activeProvider, entryOf, selection
|
|
|
1896
1985
|
const keepEffortFlyout = React5.useCallback(() => {
|
|
1897
1986
|
clearTimeout(hoverModelTimer.current);
|
|
1898
1987
|
}, []);
|
|
1988
|
+
const showPromoTip = React5.useCallback((model, event) => {
|
|
1989
|
+
const wrap = modelWrapRef.current;
|
|
1990
|
+
if (!wrap) return;
|
|
1991
|
+
const chip = event.currentTarget.getBoundingClientRect();
|
|
1992
|
+
const wrapRect = wrap.getBoundingClientRect();
|
|
1993
|
+
setPromoTip({
|
|
1994
|
+
model,
|
|
1995
|
+
bottom: wrapRect.bottom - chip.top + 6,
|
|
1996
|
+
right: wrapRect.right - chip.right
|
|
1997
|
+
});
|
|
1998
|
+
}, []);
|
|
1999
|
+
const hidePromoTip = React5.useCallback(() => {
|
|
2000
|
+
setPromoTip(null);
|
|
2001
|
+
}, []);
|
|
1899
2002
|
const toggleModelMenu = React5.useCallback(() => {
|
|
1900
2003
|
setModelError(null);
|
|
1901
2004
|
clearTimeout(hoverModelTimer.current);
|
|
1902
2005
|
setHoverModel(null);
|
|
2006
|
+
setPromoTip(null);
|
|
1903
2007
|
setModelMenuOpen((value) => !value);
|
|
1904
2008
|
}, []);
|
|
1905
2009
|
const modelProvider = catalogProvider ?? activeProvider;
|
|
@@ -1920,6 +2024,9 @@ function useModelCatalog({ ctx, t, sessionId, activeProvider, entryOf, selection
|
|
|
1920
2024
|
showEffortFlyout,
|
|
1921
2025
|
scheduleEffortFlyoutClose,
|
|
1922
2026
|
keepEffortFlyout,
|
|
2027
|
+
promoTip,
|
|
2028
|
+
showPromoTip,
|
|
2029
|
+
hidePromoTip,
|
|
1923
2030
|
toggleModelMenu,
|
|
1924
2031
|
switchToModel
|
|
1925
2032
|
};
|
|
@@ -2054,8 +2161,12 @@ var STYLES = [
|
|
|
2054
2161
|
// through the model names. A solid layer keeps the list readable wherever
|
|
2055
2162
|
// it opens.
|
|
2056
2163
|
".dsh-model-allowance-model-wrap{position:relative;display:inline-flex}",
|
|
2164
|
+
// The list sizes itself to its content: a model name is always shown in
|
|
2165
|
+
// full, and the menu widens to fit it rather than truncating. Only the
|
|
2166
|
+
// viewport caps the width; a long list still scrolls vertically.
|
|
2057
2167
|
".dsh-model-allowance-model-menu{position:absolute;bottom:calc(100% + 4px);right:0;z-index:30;",
|
|
2058
|
-
"min-width:180px;max-width:
|
|
2168
|
+
"width:max-content;min-width:180px;max-width:calc(100vw - 24px);",
|
|
2169
|
+
"max-height:240px;overflow-y:auto;padding:4px;border:0;",
|
|
2059
2170
|
"border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-2);",
|
|
2060
2171
|
"box-shadow:var(--dsw-elevation-prominent)}",
|
|
2061
2172
|
".dsh-model-allowance-model-item{display:flex;align-items:center;justify-content:space-between;",
|
|
@@ -2066,7 +2177,7 @@ var STYLES = [
|
|
|
2066
2177
|
// would give the chip a second meaning it does not have.
|
|
2067
2178
|
'.dsh-model-allowance-model-item[data-current="true"]{color:var(--dsw-alias-label-secondary)}',
|
|
2068
2179
|
".dsh-model-allowance-model-item[disabled]{opacity:.6;cursor:default}",
|
|
2069
|
-
".dsh-model-allowance-model-name{
|
|
2180
|
+
".dsh-model-allowance-model-name{white-space:nowrap}",
|
|
2070
2181
|
// The trailing side of a model row carries its state label and, for a
|
|
2071
2182
|
// model with reasoning efforts, the arrow that says a flyout waits to
|
|
2072
2183
|
// the right.
|
|
@@ -2092,6 +2203,25 @@ var STYLES = [
|
|
|
2092
2203
|
// The trailing label names the state of one model: the one in use, or the
|
|
2093
2204
|
// one being switched to.
|
|
2094
2205
|
".dsh-model-allowance-model-note{flex:none;color:var(--dsw-alias-label-tertiary);font-size:11px}",
|
|
2206
|
+
// A running promotion marks its model with a small multiplier badge beside
|
|
2207
|
+
// the name — the card's only statement of the event. The business hue says
|
|
2208
|
+
// "offer" without borrowing the success green the allowance bars speak;
|
|
2209
|
+
// the badge paints its own colour, so the dimmed current row still shows it.
|
|
2210
|
+
".dsh-model-allowance-promo-chip{display:inline-flex;align-items:center;flex:none;",
|
|
2211
|
+
"padding:0 5px;border-radius:999px;height:16px;font-size:10px;font-weight:600;line-height:1;",
|
|
2212
|
+
"color:var(--dsw-alias-state-business-primary);",
|
|
2213
|
+
"background:color-mix(in srgb, var(--dsw-alias-state-business-primary) 12%, transparent)}",
|
|
2214
|
+
// The auto margin belongs to the menu row: it keeps name and badge together
|
|
2215
|
+
// at the left while the state label stays at the right edge.
|
|
2216
|
+
".dsh-model-allowance-model-item .dsh-model-allowance-promo-chip{margin-right:auto}",
|
|
2217
|
+
// The badge's hover tip reads the vendor's one-line announcement on the
|
|
2218
|
+
// card's shared tooltip surface. A sibling of the scrolling menu, so
|
|
2219
|
+
// nothing clips it; pointer-events:none keeps it a pure hint.
|
|
2220
|
+
".dsh-model-allowance-promo-tip{position:absolute;z-index:32;width:max-content;",
|
|
2221
|
+
"max-width:240px;padding:6px 8px;border:0;border-radius:var(--dsw-radius-sm);",
|
|
2222
|
+
"background:var(--dsw-alias-tooltip-bg);box-shadow:var(--dsw-elevation-prominent);",
|
|
2223
|
+
"font-size:11px;line-height:1.5;color:var(--dsw-static-neutral-bluish-00);",
|
|
2224
|
+
"pointer-events:none;white-space:normal;text-align:left}",
|
|
2095
2225
|
// A message covers the whole list: it loads, it is empty, or the switch
|
|
2096
2226
|
// failed and says why.
|
|
2097
2227
|
".dsh-model-allowance-model-message{padding:4px 6px;color:var(--dsw-alias-label-secondary);",
|
|
@@ -2291,6 +2421,7 @@ function BalanceBadge(props) {
|
|
|
2291
2421
|
}, [open]);
|
|
2292
2422
|
const [stripWidth, setStripWidth] = React6.useState(0);
|
|
2293
2423
|
const stripRef = React6.useRef(null);
|
|
2424
|
+
const [promotions, setPromotions] = React6.useState(null);
|
|
2294
2425
|
const { available, defaultProvider, entryOf, nameOf } = useProviderDirectory(selected);
|
|
2295
2426
|
const provider = selected ?? defaultProvider;
|
|
2296
2427
|
const activeProvider = picked ?? provider;
|
|
@@ -2324,17 +2455,18 @@ function BalanceBadge(props) {
|
|
|
2324
2455
|
React6.useEffect(() => {
|
|
2325
2456
|
if (!activeProvider) return void 0;
|
|
2326
2457
|
let cancelled = false;
|
|
2327
|
-
|
|
2458
|
+
const readDeclaration = async (method, apply2, label2) => {
|
|
2328
2459
|
try {
|
|
2329
2460
|
const api = await getBalanceApi();
|
|
2330
|
-
if (!api || typeof api
|
|
2331
|
-
const result = await api
|
|
2332
|
-
if (cancelled
|
|
2333
|
-
setSchedule(result.value);
|
|
2461
|
+
if (!api || typeof api[method] !== "function") return;
|
|
2462
|
+
const result = await api[method](activeProvider);
|
|
2463
|
+
if (!cancelled && result.ok) apply2(result.value);
|
|
2334
2464
|
} catch (error) {
|
|
2335
|
-
console.error(
|
|
2465
|
+
console.error(`[model-allowance] reading the ${label2} failed`, { error });
|
|
2336
2466
|
}
|
|
2337
|
-
}
|
|
2467
|
+
};
|
|
2468
|
+
void readDeclaration("schedule", setSchedule, "pricing schedule");
|
|
2469
|
+
void readDeclaration("promotions", setPromotions, "usage promotions");
|
|
2338
2470
|
return () => {
|
|
2339
2471
|
cancelled = true;
|
|
2340
2472
|
};
|
|
@@ -2418,7 +2550,7 @@ function BalanceBadge(props) {
|
|
|
2418
2550
|
if (!provider) return null;
|
|
2419
2551
|
const currentStatus = providerStatus?.provider === activeProvider ? providerStatus : null;
|
|
2420
2552
|
const serviceState = statusDisplayState(currentStatus);
|
|
2421
|
-
return (0,
|
|
2553
|
+
return (0, import_react8.createElement)(
|
|
2422
2554
|
"div",
|
|
2423
2555
|
{
|
|
2424
2556
|
ref: rootRef,
|
|
@@ -2428,8 +2560,8 @@ function BalanceBadge(props) {
|
|
|
2428
2560
|
},
|
|
2429
2561
|
// Component-local styles: React removes them with the component, and
|
|
2430
2562
|
// every colour comes from a theme token so light and dark both follow.
|
|
2431
|
-
(0,
|
|
2432
|
-
(0,
|
|
2563
|
+
(0, import_react8.createElement)("style", { key: "styles" }, STYLES_JOINED),
|
|
2564
|
+
(0, import_react8.createElement)(
|
|
2433
2565
|
"button",
|
|
2434
2566
|
{
|
|
2435
2567
|
type: "button",
|
|
@@ -2439,12 +2571,12 @@ function BalanceBadge(props) {
|
|
|
2439
2571
|
"aria-controls": open ? "dsh-model-allowance-panel" : void 0,
|
|
2440
2572
|
onClick: () => setOpen((value) => !value)
|
|
2441
2573
|
},
|
|
2442
|
-
(0,
|
|
2443
|
-
(0,
|
|
2574
|
+
(0, import_react8.createElement)("span", { className: "dsh-model-allowance-dot", "aria-hidden": true }),
|
|
2575
|
+
(0, import_react8.createElement)("span", { className: "dsh-model-allowance-label" }, label),
|
|
2444
2576
|
// How far the number moved since the last reading, for a few seconds
|
|
2445
2577
|
// after it lands. The arrow follows the number shown beside it: down
|
|
2446
2578
|
// means the balance fell.
|
|
2447
|
-
showingDifference ? (0,
|
|
2579
|
+
showingDifference ? (0, import_react8.createElement)(
|
|
2448
2580
|
"span",
|
|
2449
2581
|
{
|
|
2450
2582
|
className: "dsh-model-allowance-delta",
|
|
@@ -2454,13 +2586,14 @@ function BalanceBadge(props) {
|
|
|
2454
2586
|
`${view.consumption.delta < 0 ? "\u2193" : "\u2191"}${formatDelta(view.consumption)}`
|
|
2455
2587
|
) : null
|
|
2456
2588
|
),
|
|
2457
|
-
open ? (0,
|
|
2589
|
+
open ? (0, import_react8.createElement)(BalancePanel, {
|
|
2458
2590
|
t,
|
|
2459
2591
|
now,
|
|
2460
2592
|
view,
|
|
2461
2593
|
activeProvider,
|
|
2462
2594
|
available,
|
|
2463
2595
|
schedule,
|
|
2596
|
+
promotions,
|
|
2464
2597
|
currentStatus,
|
|
2465
2598
|
serviceState,
|
|
2466
2599
|
refresh,
|
|
@@ -2547,6 +2680,21 @@ function createBalanceContribution() {
|
|
|
2547
2680
|
holidays: z.array(z.string()).optional(),
|
|
2548
2681
|
note: z.object({ zh: z.string().optional(), en: z.string().optional() }).optional()
|
|
2549
2682
|
}).nullable();
|
|
2683
|
+
const promotionSchema = z.object({
|
|
2684
|
+
models: z.array(z.string()),
|
|
2685
|
+
chip: z.object({ zh: z.string().optional(), en: z.string().optional() }),
|
|
2686
|
+
note: z.object({ zh: z.string().optional(), en: z.string().optional() }),
|
|
2687
|
+
// A static declaration carries a date window; a live catalog read may
|
|
2688
|
+
// carry a daily one (a night offer badges only at night), or none at all.
|
|
2689
|
+
timezone: z.string().optional(),
|
|
2690
|
+
from: z.string().optional(),
|
|
2691
|
+
to: z.string().optional(),
|
|
2692
|
+
daily: z.object({ from: z.string(), to: z.string() }).optional()
|
|
2693
|
+
});
|
|
2694
|
+
const promotionsSchema = z.object({
|
|
2695
|
+
provider: z.string(),
|
|
2696
|
+
promotions: z.array(promotionSchema)
|
|
2697
|
+
}).nullable();
|
|
2550
2698
|
const strict = (schema, description, typeSymbol) => ({
|
|
2551
2699
|
mode: "strict",
|
|
2552
2700
|
typeSymbol,
|
|
@@ -2686,6 +2834,17 @@ function createBalanceContribution() {
|
|
|
2686
2834
|
invocation: { kind: "direct" },
|
|
2687
2835
|
parameters: [providerParameter],
|
|
2688
2836
|
result: strict(scheduleSchema, "The schedule, or null.", "dsh-model-allowance#schedule")
|
|
2837
|
+
},
|
|
2838
|
+
"balance/promotions": {
|
|
2839
|
+
service: "balanceController",
|
|
2840
|
+
description: "The model-scoped usage promotions for one provider, when it declares any.",
|
|
2841
|
+
invocation: { kind: "direct" },
|
|
2842
|
+
parameters: [providerParameter],
|
|
2843
|
+
result: strict(
|
|
2844
|
+
promotionsSchema,
|
|
2845
|
+
"The promotions, or null.",
|
|
2846
|
+
"dsh-model-allowance#promotions"
|
|
2847
|
+
)
|
|
2689
2848
|
}
|
|
2690
2849
|
}
|
|
2691
2850
|
};
|
|
@@ -2693,7 +2852,7 @@ function createBalanceContribution() {
|
|
|
2693
2852
|
|
|
2694
2853
|
// src/client/credentials-page.js
|
|
2695
2854
|
var React7 = __toESM(require("react"), 1);
|
|
2696
|
-
var
|
|
2855
|
+
var import_react9 = require("react");
|
|
2697
2856
|
|
|
2698
2857
|
// src/client/credential-groups.js
|
|
2699
2858
|
var CREDENTIAL_GROUPS = Object.freeze([
|
|
@@ -2887,10 +3046,10 @@ function CredentialsSection({ ctx, t }) {
|
|
|
2887
3046
|
};
|
|
2888
3047
|
const renderField = (field, editMode) => {
|
|
2889
3048
|
const info = infos?.[field.ref];
|
|
2890
|
-
return (0,
|
|
3049
|
+
return (0, import_react9.createElement)(
|
|
2891
3050
|
"div",
|
|
2892
3051
|
{ key: field.ref, className: "dsh-allowance-cfg-field" },
|
|
2893
|
-
(0,
|
|
3052
|
+
(0, import_react9.createElement)(
|
|
2894
3053
|
editMode ? "label" : "div",
|
|
2895
3054
|
{
|
|
2896
3055
|
className: "dsh-allowance-cfg-field-label",
|
|
@@ -2898,7 +3057,7 @@ function CredentialsSection({ ctx, t }) {
|
|
|
2898
3057
|
},
|
|
2899
3058
|
pick(field.label)
|
|
2900
3059
|
),
|
|
2901
|
-
editMode ? (0,
|
|
3060
|
+
editMode ? (0, import_react9.createElement)("input", {
|
|
2902
3061
|
id: `dsh-allowance-cfg-${field.ref}`,
|
|
2903
3062
|
className: "dsh-allowance-cfg-input",
|
|
2904
3063
|
type: "password",
|
|
@@ -2910,7 +3069,7 @@ function CredentialsSection({ ctx, t }) {
|
|
|
2910
3069
|
}) : (
|
|
2911
3070
|
// A stored record reads as text, not as a box that mimics the
|
|
2912
3071
|
// entry form: the two states must be told apart at a glance.
|
|
2913
|
-
(0,
|
|
3072
|
+
(0, import_react9.createElement)(
|
|
2914
3073
|
"span",
|
|
2915
3074
|
{ className: "dsh-allowance-cfg-text" },
|
|
2916
3075
|
typeof info?.masked === "string" && info.masked !== "" ? info.masked : "********"
|
|
@@ -2921,18 +3080,18 @@ function CredentialsSection({ ctx, t }) {
|
|
|
2921
3080
|
const renderGroup = (group) => {
|
|
2922
3081
|
const allStored = group.fields.every((field) => infos?.[field.ref]?.configured === true);
|
|
2923
3082
|
const editMode = !allStored || editing[group.id] === true;
|
|
2924
|
-
return (0,
|
|
3083
|
+
return (0, import_react9.createElement)(
|
|
2925
3084
|
"section",
|
|
2926
3085
|
{ key: group.id, className: "dsh-allowance-cfg-card" },
|
|
2927
|
-
(0,
|
|
3086
|
+
(0, import_react9.createElement)(
|
|
2928
3087
|
"div",
|
|
2929
3088
|
{ className: "dsh-allowance-cfg-card-head" },
|
|
2930
|
-
(0,
|
|
3089
|
+
(0, import_react9.createElement)("h3", { className: "dsh-allowance-cfg-card-title" }, pick(group.name)),
|
|
2931
3090
|
// The stored state names itself, so the card reads as configured or
|
|
2932
3091
|
// as a form to fill without reading any field.
|
|
2933
|
-
allStored ? (0,
|
|
3092
|
+
allStored ? (0, import_react9.createElement)("span", { className: "dsh-allowance-cfg-status" }, t("settings.configured")) : null
|
|
2934
3093
|
),
|
|
2935
|
-
group.docUrl ? (0,
|
|
3094
|
+
group.docUrl ? (0, import_react9.createElement)(
|
|
2936
3095
|
"a",
|
|
2937
3096
|
{
|
|
2938
3097
|
className: "dsh-allowance-cfg-link",
|
|
@@ -2943,10 +3102,10 @@ function CredentialsSection({ ctx, t }) {
|
|
|
2943
3102
|
`${group.docLabel ? pick(group.docLabel) : t("settings.doc")} \u2197`
|
|
2944
3103
|
) : null,
|
|
2945
3104
|
group.fields.map((field) => renderField(field, editMode)),
|
|
2946
|
-
(0,
|
|
3105
|
+
(0, import_react9.createElement)(
|
|
2947
3106
|
"div",
|
|
2948
3107
|
{ className: "dsh-allowance-cfg-actions" },
|
|
2949
|
-
editMode ? (0,
|
|
3108
|
+
editMode ? (0, import_react9.createElement)(
|
|
2950
3109
|
"button",
|
|
2951
3110
|
{
|
|
2952
3111
|
type: "button",
|
|
@@ -2957,7 +3116,7 @@ function CredentialsSection({ ctx, t }) {
|
|
|
2957
3116
|
},
|
|
2958
3117
|
busy ? t("settings.testing") : t("settings.save")
|
|
2959
3118
|
) : [
|
|
2960
|
-
(0,
|
|
3119
|
+
(0, import_react9.createElement)(
|
|
2961
3120
|
"button",
|
|
2962
3121
|
{
|
|
2963
3122
|
type: "button",
|
|
@@ -2969,7 +3128,7 @@ function CredentialsSection({ ctx, t }) {
|
|
|
2969
3128
|
},
|
|
2970
3129
|
t("settings.edit")
|
|
2971
3130
|
),
|
|
2972
|
-
(0,
|
|
3131
|
+
(0, import_react9.createElement)(
|
|
2973
3132
|
"button",
|
|
2974
3133
|
{
|
|
2975
3134
|
type: "button",
|
|
@@ -2982,7 +3141,7 @@ function CredentialsSection({ ctx, t }) {
|
|
|
2982
3141
|
t("settings.delete")
|
|
2983
3142
|
)
|
|
2984
3143
|
],
|
|
2985
|
-
allStored && editMode ? (0,
|
|
3144
|
+
allStored && editMode ? (0, import_react9.createElement)(
|
|
2986
3145
|
"button",
|
|
2987
3146
|
{
|
|
2988
3147
|
type: "button",
|
|
@@ -2996,17 +3155,17 @@ function CredentialsSection({ ctx, t }) {
|
|
|
2996
3155
|
)
|
|
2997
3156
|
);
|
|
2998
3157
|
};
|
|
2999
|
-
return (0,
|
|
3158
|
+
return (0, import_react9.createElement)(
|
|
3000
3159
|
React7.Fragment,
|
|
3001
3160
|
null,
|
|
3002
3161
|
// Component-local styles: React removes them with the component.
|
|
3003
|
-
(0,
|
|
3004
|
-
(0,
|
|
3162
|
+
(0, import_react9.createElement)("style", { key: "styles" }, STYLES2),
|
|
3163
|
+
(0, import_react9.createElement)(
|
|
3005
3164
|
"div",
|
|
3006
3165
|
{ className: "dsh-allowance-cfg" },
|
|
3007
|
-
(0,
|
|
3008
|
-
credentials === void 0 ? (0,
|
|
3009
|
-
notice === void 0 ? null : (0,
|
|
3166
|
+
(0, import_react9.createElement)("h2", { className: "dsh-allowance-cfg-title" }, t("settings.title")),
|
|
3167
|
+
credentials === void 0 ? (0, import_react9.createElement)("p", { className: "dsh-allowance-cfg-error" }, t("settings.unavailable")) : infos === void 0 ? (0, import_react9.createElement)("p", { className: "dsh-allowance-cfg-hint" }, t("settings.loading")) : CREDENTIAL_GROUPS.map((group) => renderGroup(group)),
|
|
3168
|
+
notice === void 0 ? null : (0, import_react9.createElement)(
|
|
3010
3169
|
"p",
|
|
3011
3170
|
{
|
|
3012
3171
|
key: "notice",
|
|
@@ -3083,7 +3242,7 @@ function apply(ctx) {
|
|
|
3083
3242
|
id: "model-allowance",
|
|
3084
3243
|
order: 10
|
|
3085
3244
|
},
|
|
3086
|
-
(props) => (0,
|
|
3245
|
+
(props) => (0, import_react10.createElement)(BalanceBadge, { ...props, ctx, t })
|
|
3087
3246
|
)
|
|
3088
3247
|
);
|
|
3089
3248
|
const SECTION = "settings.section";
|
|
@@ -3096,7 +3255,7 @@ function apply(ctx) {
|
|
|
3096
3255
|
order: 30,
|
|
3097
3256
|
label: () => t("settings.nav")
|
|
3098
3257
|
},
|
|
3099
|
-
(props) => (0,
|
|
3258
|
+
(props) => (0, import_react10.createElement)(CredentialsSection, { ...props, ctx, t })
|
|
3100
3259
|
)
|
|
3101
3260
|
);
|
|
3102
3261
|
}
|