@hanzo/ui 8.27.61 → 8.27.64
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/dist/auth/SignIn.cjs +2 -78
- package/dist/auth/SignIn.d.ts +1 -9
- package/dist/auth/SignIn.d.ts.map +1 -1
- package/dist/auth/SignIn.js +2 -78
- package/dist/auth/SignIn.js.map +1 -1
- package/dist/consent/Consent.cjs +8 -23
- package/dist/consent/Consent.d.ts.map +1 -1
- package/dist/consent/Consent.js +11 -26
- package/dist/consent/Consent.js.map +1 -1
- package/dist/gallery.cjs +2 -2
- package/dist/gallery.d.ts.map +1 -1
- package/dist/gallery.html +2 -2
- package/dist/gallery.js +2 -2
- package/dist/gallery.js.map +1 -1
- package/dist/marketing/Footer.cjs +1 -1
- package/dist/marketing/Footer.js +1 -1
- package/dist/models/catalog.cjs +22 -1
- package/dist/models/catalog.d.ts +9 -0
- package/dist/models/catalog.d.ts.map +1 -1
- package/dist/models/catalog.js +20 -0
- package/dist/models/catalog.js.map +1 -1
- package/dist/models/index.cjs +3 -3
- package/dist/models/index.d.ts +2 -2
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +2 -2
- package/dist/models/index.js.map +1 -1
- package/dist/models/picker.logic.cjs +3 -24
- package/dist/models/picker.logic.d.ts +1 -11
- package/dist/models/picker.logic.d.ts.map +1 -1
- package/dist/models/picker.logic.js +2 -22
- package/dist/models/picker.logic.js.map +1 -1
- package/dist/product/LimitedBanner.cjs +15 -9
- package/dist/product/LimitedBanner.d.ts +22 -2
- package/dist/product/LimitedBanner.d.ts.map +1 -1
- package/dist/product/LimitedBanner.js +14 -9
- package/dist/product/LimitedBanner.js.map +1 -1
- package/dist/product/PlanUsage.cjs +26 -13
- package/dist/product/PlanUsage.d.ts +12 -3
- package/dist/product/PlanUsage.d.ts.map +1 -1
- package/dist/product/PlanUsage.js +26 -13
- package/dist/product/PlanUsage.js.map +1 -1
- package/dist/product/UsageMeter.cjs +3 -5
- package/dist/product/UsageMeter.d.ts.map +1 -1
- package/dist/product/UsageMeter.js +3 -5
- package/dist/product/UsageMeter.js.map +1 -1
- package/dist/product/limits.cjs +43 -15
- package/dist/product/limits.d.ts +18 -5
- package/dist/product/limits.d.ts.map +1 -1
- package/dist/product/limits.js +41 -14
- package/dist/product/limits.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ModelPicker's decisions, as pure functions over plain values: which rows are
|
|
3
|
-
* drawn, which slice of them a scrolled viewport shows
|
|
4
|
-
* conversation starts on. Tested in node.
|
|
3
|
+
* drawn, and which slice of them a scrolled viewport shows. Tested in node.
|
|
5
4
|
*/
|
|
6
|
-
import { can,
|
|
7
|
-
/** The house router: what a conversation is answered by until a model is picked. */
|
|
8
|
-
export const ENSO = 'enso-auto';
|
|
5
|
+
import { can, ENSO, groupModels, matchesModel, sortModels, withResearch, } from './catalog.js';
|
|
9
6
|
/** Whether a model may be picked: everything the gateway lists, never a research preview. */
|
|
10
7
|
export const pickable = (m) => m.access !== 'research';
|
|
11
8
|
/**
|
|
@@ -54,21 +51,4 @@ export function revealTop(i, top, height, row) {
|
|
|
54
51
|
return y + row - height;
|
|
55
52
|
return null;
|
|
56
53
|
}
|
|
57
|
-
/**
|
|
58
|
-
* The model a new conversation, run or playground tab starts on: Enso for a
|
|
59
|
-
* conversation, else the first of Hanzo's own models that does what the scope
|
|
60
|
-
* asks, else the first free or Hanzo model that does. Never a premium model:
|
|
61
|
-
* a person picks one of those. '' when nothing qualifies.
|
|
62
|
-
*/
|
|
63
|
-
export function defaultModel(models, scope = 'chat') {
|
|
64
|
-
const offered = models.filter((m) => pickable(m) && m.class !== 'premium' && can(m, scope));
|
|
65
|
-
if (scope === 'chat' && offered.some((m) => m.id === ENSO))
|
|
66
|
-
return ENSO;
|
|
67
|
-
for (const f of FAMILIES) {
|
|
68
|
-
const ours = sortModels(offered.filter((m) => m.family === f.id));
|
|
69
|
-
if (ours.length)
|
|
70
|
-
return ours[0].id;
|
|
71
|
-
}
|
|
72
|
-
return sortModels(offered)[0]?.id ?? '';
|
|
73
|
-
}
|
|
74
54
|
//# sourceMappingURL=picker.logic.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picker.logic.js","sourceRoot":"","sources":["../../src/models/picker.logic.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"picker.logic.js","sourceRoot":"","sources":["../../src/models/picker.logic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,GAAG,EACH,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,YAAY,GAGb,MAAM,WAAW,CAAA;AAOlB,6FAA6F;AAC7F,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAoB,EAAW,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,UAAU,CAAA;AAElF;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACxB,MAAoC,EACpC,KAAa,EACb,KAAkB;IAElB,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;IACvG,MAAM,IAAI,GAAgB,EAAE,CAAA;IAC5B,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAA;IAChG,KAAK,MAAM,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,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AI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;IACtE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC,EAAE,CAAA;AAChF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,CAAS,EAAE,GAAW,EAAE,MAAc,EAAE,GAAW;IAC3E,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;IACjB,IAAI,CAAC,GAAG,GAAG;QAAE,OAAO,CAAC,CAAA;IACrB,IAAI,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM;QAAE,OAAO,CAAC,GAAG,GAAG,GAAG,MAAM,CAAA;IACnD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
'use client';"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.LimitActions = LimitActions;
|
|
4
5
|
exports.LimitedBanner = LimitedBanner;
|
|
5
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
/**
|
|
7
|
-
* LimitedBanner — the reader's usage is paused or refused: the server's message,
|
|
8
|
-
* the ways past it (Upgrade, Add prepaid credit) and, where the host has one, a
|
|
9
|
-
* quiet "See usage" to its usage settings. One line where it fits. Neutral
|
|
10
|
-
* chrome; the dot is the one status colour.
|
|
11
|
-
*/
|
|
12
7
|
const gui_1 = require("@hanzo/gui");
|
|
13
8
|
const lucide_icons_2_1 = require("@hanzogui/lucide-icons-2");
|
|
14
9
|
const button_1 = require("../backends/gui/button.cjs");
|
|
15
10
|
const slot_1 = require("../backends/gui/slot.cjs");
|
|
16
11
|
const gesture_1 = require("../backends/gui/gesture.cjs");
|
|
12
|
+
const limits_1 = require("./limits.cjs");
|
|
17
13
|
const go = (a) => {
|
|
18
|
-
if (typeof window !== 'undefined')
|
|
14
|
+
if (a.url && typeof window !== 'undefined')
|
|
19
15
|
window.location.assign(a.url);
|
|
20
16
|
};
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The server's actions in the order it sent them: the first is the one filled
|
|
19
|
+
* control, the rest quiet. Only pages are offered when the host takes no action.
|
|
20
|
+
*/
|
|
21
|
+
function LimitActions({ actions, onAction, children, }) {
|
|
22
|
+
const shown = onAction ? actions : actions.filter(limits_1.navigable);
|
|
23
|
+
if (!shown.length && !children)
|
|
24
|
+
return null;
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)(gui_1.XStack, { gap: "$2", shrink: 0, flexWrap: "wrap", items: "center", children: [shown.map((a, i) => ((0, jsx_runtime_1.jsx)(button_1.Button, { size: "sm", variant: i === 0 ? 'primary' : 'default', "data-kind": a.kind, onPress: () => (onAction ?? go)(a), children: a.label }, `${a.kind}:${a.url ?? a.model ?? i}`))), children] }));
|
|
26
|
+
}
|
|
27
|
+
function LimitedBanner({ message, actions = [], onAction, onUsage, onClose }) {
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)(gui_1.XStack, { role: "status", "aria-live": "polite", ...(0, slot_1.slot)('limited-banner'), width: "100%", items: "center", flexWrap: "wrap", gap: "$3", px: "$3", py: "$2.5", rounded: "$4", borderWidth: 1, borderColor: "$edge", bg: "$panel", children: [(0, jsx_runtime_1.jsxs)(gui_1.XStack, { flex: 1, minW: 200, items: "center", gap: "$2.5", children: [(0, jsx_runtime_1.jsx)(gui_1.View, { width: 8, height: 8, rounded: 4, bg: "$bad", shrink: 0, "aria-hidden": true }), (0, jsx_runtime_1.jsx)(gui_1.Text, { fontSize: "$2", color: "$ink", ...(0, slot_1.slot)('limited-banner-message'), children: message })] }), (0, jsx_runtime_1.jsx)(LimitActions, { actions: actions, onAction: onAction, children: onUsage ? ((0, jsx_runtime_1.jsx)(button_1.Button, { size: "sm", variant: "ghost", "data-kind": "usage", onPress: onUsage, children: "See usage" })) : null }), onClose ? ((0, jsx_runtime_1.jsx)(button_1.Button, { variant: "ghost", size: "icon", minH: 24, minW: 24, ...(0, gesture_1.touch)(24), "aria-label": "Dismiss", onPress: onClose, children: (0, jsx_runtime_1.jsx)(lucide_icons_2_1.X, { size: 14 }) })) : null] }));
|
|
23
29
|
}
|
|
@@ -1,12 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* LimitedBanner — the reader's usage is paused or refused: the server's message,
|
|
3
|
+
* the ways past it (Upgrade, Add prepaid credit) and, where the host has one, a
|
|
4
|
+
* quiet "See usage" to its usage settings. One line where it fits. Neutral
|
|
5
|
+
* chrome; the dot is the one status colour.
|
|
6
|
+
*/
|
|
7
|
+
import type { ReactNode } from 'react';
|
|
8
|
+
import { type LimitAction } from './limits.js';
|
|
2
9
|
export interface LimitedBannerProps {
|
|
3
10
|
message: string;
|
|
4
11
|
actions?: readonly LimitAction[];
|
|
5
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Takes an action. Without one only the pages (Upgrade, Add prepaid credit)
|
|
14
|
+
* are offered, and the browser goes to their URL: Continue with credits and a
|
|
15
|
+
* model switch need the host.
|
|
16
|
+
*/
|
|
6
17
|
onAction?: (action: LimitAction) => void;
|
|
7
18
|
/** Opens the host's usage settings; draws "See usage" when given. */
|
|
8
19
|
onUsage?: () => void;
|
|
9
20
|
onClose?: () => void;
|
|
10
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* The server's actions in the order it sent them: the first is the one filled
|
|
24
|
+
* control, the rest quiet. Only pages are offered when the host takes no action.
|
|
25
|
+
*/
|
|
26
|
+
export declare function LimitActions({ actions, onAction, children, }: {
|
|
27
|
+
actions: readonly LimitAction[];
|
|
28
|
+
onAction?: (action: LimitAction) => void;
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
}): import("react").JSX.Element | null;
|
|
11
31
|
export declare function LimitedBanner({ message, actions, onAction, onUsage, onClose }: LimitedBannerProps): import("react").JSX.Element;
|
|
12
32
|
//# sourceMappingURL=LimitedBanner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LimitedBanner.d.ts","sourceRoot":"","sources":["../../src/product/LimitedBanner.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LimitedBanner.d.ts","sourceRoot":"","sources":["../../src/product/LimitedBanner.tsx"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAMtC,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,UAAU,CAAA;AAEtD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,SAAS,WAAW,EAAE,CAAA;IAChC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAA;IACxC,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACrB;AAMD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,OAAO,EAAE,SAAS,WAAW,EAAE,CAAA;IAC/B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAA;IACxC,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,sCAmBA;AAED,wBAAgB,aAAa,CAAC,EAAE,OAAO,EAAE,OAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,kBAAkB,+BAqCtG"}
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
/**
|
|
4
|
-
* LimitedBanner — the reader's usage is paused or refused: the server's message,
|
|
5
|
-
* the ways past it (Upgrade, Add prepaid credit) and, where the host has one, a
|
|
6
|
-
* quiet "See usage" to its usage settings. One line where it fits. Neutral
|
|
7
|
-
* chrome; the dot is the one status colour.
|
|
8
|
-
*/
|
|
9
3
|
import { Text, View, XStack } from '@hanzo/gui';
|
|
10
4
|
import { X } from '@hanzogui/lucide-icons-2';
|
|
11
5
|
import { Button } from '../backends/gui/button.js';
|
|
12
6
|
import { slot } from '../backends/gui/slot.js';
|
|
13
7
|
import { touch } from '../backends/gui/gesture.js';
|
|
8
|
+
import { navigable } from './limits.js';
|
|
14
9
|
const go = (a) => {
|
|
15
|
-
if (typeof window !== 'undefined')
|
|
10
|
+
if (a.url && typeof window !== 'undefined')
|
|
16
11
|
window.location.assign(a.url);
|
|
17
12
|
};
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The server's actions in the order it sent them: the first is the one filled
|
|
15
|
+
* control, the rest quiet. Only pages are offered when the host takes no action.
|
|
16
|
+
*/
|
|
17
|
+
export function LimitActions({ actions, onAction, children, }) {
|
|
18
|
+
const shown = onAction ? actions : actions.filter(navigable);
|
|
19
|
+
if (!shown.length && !children)
|
|
20
|
+
return null;
|
|
21
|
+
return (_jsxs(XStack, { gap: "$2", shrink: 0, flexWrap: "wrap", items: "center", children: [shown.map((a, i) => (_jsx(Button, { size: "sm", variant: i === 0 ? 'primary' : 'default', "data-kind": a.kind, onPress: () => (onAction ?? go)(a), children: a.label }, `${a.kind}:${a.url ?? a.model ?? i}`))), children] }));
|
|
22
|
+
}
|
|
23
|
+
export function LimitedBanner({ message, actions = [], onAction, onUsage, onClose }) {
|
|
24
|
+
return (_jsxs(XStack, { role: "status", "aria-live": "polite", ...slot('limited-banner'), width: "100%", items: "center", flexWrap: "wrap", gap: "$3", px: "$3", py: "$2.5", rounded: "$4", borderWidth: 1, borderColor: "$edge", bg: "$panel", children: [_jsxs(XStack, { flex: 1, minW: 200, items: "center", gap: "$2.5", children: [_jsx(View, { width: 8, height: 8, rounded: 4, bg: "$bad", shrink: 0, "aria-hidden": true }), _jsx(Text, { fontSize: "$2", color: "$ink", ...slot('limited-banner-message'), children: message })] }), _jsx(LimitActions, { actions: actions, onAction: onAction, children: onUsage ? (_jsx(Button, { size: "sm", variant: "ghost", "data-kind": "usage", onPress: onUsage, children: "See usage" })) : null }), onClose ? (_jsx(Button, { variant: "ghost", size: "icon", minH: 24, minW: 24, ...touch(24), "aria-label": "Dismiss", onPress: onClose, children: _jsx(X, { size: 14 }) })) : null] }));
|
|
20
25
|
}
|
|
21
26
|
//# sourceMappingURL=LimitedBanner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LimitedBanner.js","sourceRoot":"","sources":["../../src/product/LimitedBanner.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;
|
|
1
|
+
{"version":3,"file":"LimitedBanner.js","sourceRoot":"","sources":["../../src/product/LimitedBanner.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AASZ,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAoB,MAAM,UAAU,CAAA;AAgBtD,MAAM,EAAE,GAAG,CAAC,CAAc,EAAE,EAAE;IAC5B,IAAI,CAAC,CAAC,GAAG,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAC3E,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,O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,CAAC,EACd,WAAW,EAAC,OAAO,EACnB,EAAE,EAAC,QAAQ,aAEX,MAAC,MAAM,IAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAC,QAAQ,EAAC,GAAG,EAAC,MAAM,aACnD,KAAC,IAAI,IAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAC,MAAM,EAAC,MAAM,EAAE,CAAC,wBAAgB,EAC1E,KAAC,IAAI,IAAC,QAAQ,EAAC,IAAI,EAAC,KAAK,EAAC,MAAM,KAAK,IAAI,CAAC,wBAAwB,CAAC,YAChE,OAAO,GACH,IACA,EACT,KAAC,YAAY,IAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,YAC/C,OAAO,CAAC,CAAC,CAAC,CACT,KAAC,MAAM,IAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAC,OAAO,eAAW,OAAO,EAAC,OAAO,EAAE,OAAO,0BAE3D,CACV,CAAC,CAAC,CAAC,IAAI,GACK,EACd,OAAO,CAAC,CAAC,CAAC,CACT,KAAC,MAAM,IAAC,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,KAAM,KAAK,CAAC,EAAE,CAAC,gBAAa,SAAS,EAAC,OAAO,EAAE,OAAO,YAC1G,KAAC,CAAC,IAAC,IAAI,EAAE,EAAE,GAAI,GACR,CACV,CAAC,CAAC,CAAC,IAAI,IACD,CACV,CAAA;AACH,CAAC"}
|
|
@@ -1,45 +1,58 @@
|
|
|
1
1
|
'use client';"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.FREE_TERMS = exports.PLAN_TERMS = void 0;
|
|
4
|
+
exports.CREDITS_TERMS = exports.FREE_TERMS = exports.PLAN_TERMS = void 0;
|
|
5
5
|
exports.PlanUsage = PlanUsage;
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
/**
|
|
8
8
|
* PlanUsage — the plan, its period, what it includes in plain words, a
|
|
9
|
-
* UsageMeter,
|
|
10
|
-
*
|
|
9
|
+
* UsageMeter, the org's choice to keep paying from credits once included usage
|
|
10
|
+
* runs out, and the server's ways to more. A paused class leads with its
|
|
11
|
+
* LimitedBanner. Shares only, never an amount or a count.
|
|
11
12
|
*/
|
|
13
|
+
const react_1 = require("react");
|
|
12
14
|
const gui_1 = require("@hanzo/gui");
|
|
13
|
-
const
|
|
15
|
+
const gui_2 = require("../backends/gui/index.cjs");
|
|
16
|
+
const switch_1 = require("../backends/gui/switch.cjs");
|
|
14
17
|
const slot_1 = require("../backends/gui/slot.cjs");
|
|
15
18
|
const LimitedBanner_1 = require("./LimitedBanner.cjs");
|
|
16
19
|
const UsageMeter_1 = require("./UsageMeter.cjs");
|
|
17
20
|
/** What a paid plan includes, and what happens past it. */
|
|
18
21
|
exports.PLAN_TERMS = [
|
|
19
22
|
'Your plan includes usage of premium and Hanzo models each period.',
|
|
20
|
-
'Beyond it, prepaid credit pays.',
|
|
21
|
-
'
|
|
23
|
+
'Beyond it, prepaid credit pays when you choose to continue with credits.',
|
|
24
|
+
'Otherwise you continue in limited mode on free models.',
|
|
22
25
|
];
|
|
23
26
|
/** What the free plan includes. */
|
|
24
27
|
exports.FREE_TERMS = [
|
|
25
28
|
'The free plan includes limited usage of free models.',
|
|
26
|
-
'Upgrade for premium and Hanzo models, or add
|
|
29
|
+
'Upgrade for premium and Hanzo models, or add credits to pay as you go.',
|
|
27
30
|
];
|
|
31
|
+
/** The opt-in, in one sentence. */
|
|
32
|
+
exports.CREDITS_TERMS = "When your plan's included usage runs out, keep using any model and pay from your credits.";
|
|
28
33
|
/** A slug as a name: "max-20x" reads "Max 20x". */
|
|
29
34
|
const named = (slug) => slug.split('-').map((w) => (w ? w[0].toUpperCase() + w.slice(1) : w)).join(' ');
|
|
30
35
|
const day = (iso) => {
|
|
31
36
|
const t = iso ? Date.parse(iso) : NaN;
|
|
32
37
|
return Number.isNaN(t) ? '' : new Date(t).toLocaleDateString('en-US', { timeZone: 'UTC', month: 'short', day: 'numeric' });
|
|
33
38
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
function Credits({ on, onCredits, creditsHref, addCreditsHref, }) {
|
|
40
|
+
const [busy, setBusy] = (0, react_1.useState)(false);
|
|
41
|
+
const [wrong, setWrong] = (0, react_1.useState)('');
|
|
42
|
+
const flip = (next) => {
|
|
43
|
+
setBusy(true);
|
|
44
|
+
setWrong('');
|
|
45
|
+
onCredits(next)
|
|
46
|
+
.catch((e) => setWrong(e instanceof Error && e.message ? e.message : 'That did not save. Try again.'))
|
|
47
|
+
.finally(() => setBusy(false));
|
|
48
|
+
};
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)(gui_1.YStack, { gap: "$2", ...(0, slot_1.slot)('plan-usage-credits'), children: [(0, jsx_runtime_1.jsxs)(gui_1.XStack, { gap: "$3", items: "center", justify: "space-between", children: [(0, jsx_runtime_1.jsx)(gui_1.Text, { fontSize: "$2", color: "$ink", flex: 1, minW: 0, children: exports.CREDITS_TERMS }), (0, jsx_runtime_1.jsx)(switch_1.Switch, { checked: on, disabled: busy, onCheckedChange: flip, "aria-label": "Continue with credits" })] }), creditsHref || addCreditsHref ? ((0, jsx_runtime_1.jsxs)(gui_1.XStack, { gap: "$4", flexWrap: "wrap", children: [creditsHref ? ((0, jsx_runtime_1.jsx)(gui_2.Anchor, { href: creditsHref, fontSize: "$2", color: "$soft", children: "Credits balance" })) : null, addCreditsHref ? ((0, jsx_runtime_1.jsx)(gui_2.Anchor, { href: addCreditsHref, fontSize: "$2", color: "$soft", children: "Add credits" })) : null] })) : null, wrong ? ((0, jsx_runtime_1.jsx)(gui_1.Text, { role: "alert", fontSize: "$2", color: "$bad", children: wrong })) : null] }));
|
|
50
|
+
}
|
|
51
|
+
function PlanUsage({ limits, plan, notice, onAction, onCredits, creditsHref, addCreditsHref, now }) {
|
|
39
52
|
const free = !limits.plan;
|
|
40
53
|
const name = plan || (free ? 'Free' : named(limits.plan));
|
|
41
54
|
const from = day(limits.period_start);
|
|
42
55
|
const to = day(limits.period_end);
|
|
43
56
|
const terms = free ? exports.FREE_TERMS : exports.PLAN_TERMS;
|
|
44
|
-
return ((0, jsx_runtime_1.jsxs)(gui_1.YStack, { gap: "$4", width: "100%", minW: 0, ...(0, slot_1.slot)('plan-usage'), children: [(0, jsx_runtime_1.jsxs)(gui_1.YStack, { gap: "$1", children: [(0, jsx_runtime_1.jsxs)(gui_1.Text, { fontSize: "$5", fontWeight: "600", color: "$ink", children: [name, " plan"] }), from && to ? ((0, jsx_runtime_1.jsxs)(gui_1.Text, { fontSize: "$2", color: "$soft", children: ["Current period ", from, " \u2013 ", to] })) : null] }), notice ? (0, jsx_runtime_1.jsx)(LimitedBanner_1.LimitedBanner, { message: notice.message, actions: notice.actions, onAction: onAction }) : null, (0, jsx_runtime_1.jsx)(UsageMeter_1.UsageMeter, { limits: limits, now: now }), (0, jsx_runtime_1.jsx)(gui_1.YStack, { gap: "$1", ...(0, slot_1.slot)('plan-usage-terms'), children: terms.map((line) => ((0, jsx_runtime_1.jsx)(gui_1.Text, { fontSize: "$2", color: "$soft", children: line }, line))) }),
|
|
57
|
+
return ((0, jsx_runtime_1.jsxs)(gui_1.YStack, { gap: "$4", width: "100%", minW: 0, ...(0, slot_1.slot)('plan-usage'), children: [(0, jsx_runtime_1.jsxs)(gui_1.YStack, { gap: "$1", children: [(0, jsx_runtime_1.jsxs)(gui_1.Text, { fontSize: "$5", fontWeight: "600", color: "$ink", children: [name, " plan"] }), from && to ? ((0, jsx_runtime_1.jsxs)(gui_1.Text, { fontSize: "$2", color: "$soft", children: ["Current period ", from, " \u2013 ", to] })) : null] }), notice ? (0, jsx_runtime_1.jsx)(LimitedBanner_1.LimitedBanner, { message: notice.message, actions: notice.actions, onAction: onAction }) : null, (0, jsx_runtime_1.jsx)(UsageMeter_1.UsageMeter, { limits: limits, now: now }), (0, jsx_runtime_1.jsx)(gui_1.YStack, { gap: "$1", ...(0, slot_1.slot)('plan-usage-terms'), children: terms.map((line) => ((0, jsx_runtime_1.jsx)(gui_1.Text, { fontSize: "$2", color: "$soft", children: line }, line))) }), limits.creditsAfterAllowance !== undefined && onCredits ? ((0, jsx_runtime_1.jsx)(Credits, { on: limits.creditsAfterAllowance, onCredits: onCredits, creditsHref: creditsHref, addCreditsHref: addCreditsHref })) : null, !notice ? (0, jsx_runtime_1.jsx)(LimitedBanner_1.LimitActions, { actions: limits.actions, onAction: onAction }) : null] }));
|
|
45
58
|
}
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import type { LimitAction, LimitNotice, Limits } from './limits.js';
|
|
2
2
|
/** What a paid plan includes, and what happens past it. */
|
|
3
|
-
export declare const PLAN_TERMS: readonly ['Your plan includes usage of premium and Hanzo models each period.', 'Beyond it, prepaid credit pays.', '
|
|
3
|
+
export declare const PLAN_TERMS: readonly ['Your plan includes usage of premium and Hanzo models each period.', 'Beyond it, prepaid credit pays when you choose to continue with credits.', 'Otherwise you continue in limited mode on free models.'];
|
|
4
4
|
/** What the free plan includes. */
|
|
5
|
-
export declare const FREE_TERMS: readonly ['The free plan includes limited usage of free models.', 'Upgrade for premium and Hanzo models, or add
|
|
5
|
+
export declare const FREE_TERMS: readonly ['The free plan includes limited usage of free models.', 'Upgrade for premium and Hanzo models, or add credits to pay as you go.'];
|
|
6
|
+
/** The opt-in, in one sentence. */
|
|
7
|
+
export declare const CREDITS_TERMS = "When your plan's included usage runs out, keep using any model and pay from your credits.";
|
|
6
8
|
export interface PlanUsageProps {
|
|
7
9
|
limits: Limits;
|
|
8
10
|
/** The plan's display name; the slug made readable when absent. */
|
|
9
11
|
plan?: string;
|
|
10
12
|
notice?: LimitNotice | null;
|
|
13
|
+
/** Takes an action; without one only the pages are offered. */
|
|
11
14
|
onAction?: (action: LimitAction) => void;
|
|
15
|
+
/** Writes the org's continue-with-credits choice; the switch shows only when the limits carry it. */
|
|
16
|
+
onCredits?: (on: boolean) => Promise<void>;
|
|
17
|
+
/** Where the org's credits balance is read. */
|
|
18
|
+
creditsHref?: string;
|
|
19
|
+
/** Where credits are added. */
|
|
20
|
+
addCreditsHref?: string;
|
|
12
21
|
now?: number;
|
|
13
22
|
}
|
|
14
|
-
export declare function PlanUsage({ limits, plan, notice, onAction, now }: PlanUsageProps): import("react").JSX.Element;
|
|
23
|
+
export declare function PlanUsage({ limits, plan, notice, onAction, onCredits, creditsHref, addCreditsHref, now }: PlanUsageProps): import("react").JSX.Element;
|
|
15
24
|
//# sourceMappingURL=PlanUsage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlanUsage.d.ts","sourceRoot":"","sources":["../../src/product/PlanUsage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlanUsage.d.ts","sourceRoot":"","sources":["../../src/product/PlanUsage.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEhE,2DAA2D;AAC3D,eAAO,MAAM,UAAU,YACrB,mEAAmE,EACnE,0EAA0E,EAC1E,wDAAwD,CAChD,CAAA;AAEV,mCAAmC;AACnC,eAAO,MAAM,UAAU,YACrB,sDAAsD,EACtD,wEAAwE,CAChE,CAAA;AAEV,mCAAmC;AACnC,eAAO,MAAM,aAAa,8FAA8F,CAAA;AAUxH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAA;IACxC,qGAAqG;IACrG,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1C,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,+BAA+B;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAqDD,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,EAAE,EAAE,cAAc,+BAiCxH"}
|
|
@@ -2,41 +2,54 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
/**
|
|
4
4
|
* PlanUsage — the plan, its period, what it includes in plain words, a
|
|
5
|
-
* UsageMeter,
|
|
6
|
-
*
|
|
5
|
+
* UsageMeter, the org's choice to keep paying from credits once included usage
|
|
6
|
+
* runs out, and the server's ways to more. A paused class leads with its
|
|
7
|
+
* LimitedBanner. Shares only, never an amount or a count.
|
|
7
8
|
*/
|
|
9
|
+
import { useState } from 'react';
|
|
8
10
|
import { Text, XStack, YStack } from '@hanzo/gui';
|
|
9
|
-
import {
|
|
11
|
+
import { Anchor } from '../backends/gui/index.js';
|
|
12
|
+
import { Switch } from '../backends/gui/switch.js';
|
|
10
13
|
import { slot } from '../backends/gui/slot.js';
|
|
11
|
-
import { LimitedBanner } from './LimitedBanner.js';
|
|
14
|
+
import { LimitActions, LimitedBanner } from './LimitedBanner.js';
|
|
12
15
|
import { UsageMeter } from './UsageMeter.js';
|
|
13
16
|
/** What a paid plan includes, and what happens past it. */
|
|
14
17
|
export const PLAN_TERMS = [
|
|
15
18
|
'Your plan includes usage of premium and Hanzo models each period.',
|
|
16
|
-
'Beyond it, prepaid credit pays.',
|
|
17
|
-
'
|
|
19
|
+
'Beyond it, prepaid credit pays when you choose to continue with credits.',
|
|
20
|
+
'Otherwise you continue in limited mode on free models.',
|
|
18
21
|
];
|
|
19
22
|
/** What the free plan includes. */
|
|
20
23
|
export const FREE_TERMS = [
|
|
21
24
|
'The free plan includes limited usage of free models.',
|
|
22
|
-
'Upgrade for premium and Hanzo models, or add
|
|
25
|
+
'Upgrade for premium and Hanzo models, or add credits to pay as you go.',
|
|
23
26
|
];
|
|
27
|
+
/** The opt-in, in one sentence. */
|
|
28
|
+
export const CREDITS_TERMS = "When your plan's included usage runs out, keep using any model and pay from your credits.";
|
|
24
29
|
/** A slug as a name: "max-20x" reads "Max 20x". */
|
|
25
30
|
const named = (slug) => slug.split('-').map((w) => (w ? w[0].toUpperCase() + w.slice(1) : w)).join(' ');
|
|
26
31
|
const day = (iso) => {
|
|
27
32
|
const t = iso ? Date.parse(iso) : NaN;
|
|
28
33
|
return Number.isNaN(t) ? '' : new Date(t).toLocaleDateString('en-US', { timeZone: 'UTC', month: 'short', day: 'numeric' });
|
|
29
34
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
function Credits({ on, onCredits, creditsHref, addCreditsHref, }) {
|
|
36
|
+
const [busy, setBusy] = useState(false);
|
|
37
|
+
const [wrong, setWrong] = useState('');
|
|
38
|
+
const flip = (next) => {
|
|
39
|
+
setBusy(true);
|
|
40
|
+
setWrong('');
|
|
41
|
+
onCredits(next)
|
|
42
|
+
.catch((e) => setWrong(e instanceof Error && e.message ? e.message : 'That did not save. Try again.'))
|
|
43
|
+
.finally(() => setBusy(false));
|
|
44
|
+
};
|
|
45
|
+
return (_jsxs(YStack, { gap: "$2", ...slot('plan-usage-credits'), children: [_jsxs(XStack, { gap: "$3", items: "center", justify: "space-between", children: [_jsx(Text, { fontSize: "$2", color: "$ink", flex: 1, minW: 0, children: CREDITS_TERMS }), _jsx(Switch, { checked: on, disabled: busy, onCheckedChange: flip, "aria-label": "Continue with credits" })] }), creditsHref || addCreditsHref ? (_jsxs(XStack, { gap: "$4", flexWrap: "wrap", children: [creditsHref ? (_jsx(Anchor, { href: creditsHref, fontSize: "$2", color: "$soft", children: "Credits balance" })) : null, addCreditsHref ? (_jsx(Anchor, { href: addCreditsHref, fontSize: "$2", color: "$soft", children: "Add credits" })) : null] })) : null, wrong ? (_jsx(Text, { role: "alert", fontSize: "$2", color: "$bad", children: wrong })) : null] }));
|
|
46
|
+
}
|
|
47
|
+
export function PlanUsage({ limits, plan, notice, onAction, onCredits, creditsHref, addCreditsHref, now }) {
|
|
35
48
|
const free = !limits.plan;
|
|
36
49
|
const name = plan || (free ? 'Free' : named(limits.plan));
|
|
37
50
|
const from = day(limits.period_start);
|
|
38
51
|
const to = day(limits.period_end);
|
|
39
52
|
const terms = free ? FREE_TERMS : PLAN_TERMS;
|
|
40
|
-
return (_jsxs(YStack, { gap: "$4", width: "100%", minW: 0, ...slot('plan-usage'), children: [_jsxs(YStack, { gap: "$1", children: [_jsxs(Text, { fontSize: "$5", fontWeight: "600", color: "$ink", children: [name, " plan"] }), from && to ? (_jsxs(Text, { fontSize: "$2", color: "$soft", children: ["Current period ", from, " \u2013 ", to] })) : null] }), notice ? _jsx(LimitedBanner, { message: notice.message, actions: notice.actions, onAction: onAction }) : null, _jsx(UsageMeter, { limits: limits, now: now }), _jsx(YStack, { gap: "$1", ...slot('plan-usage-terms'), children: terms.map((line) => (_jsx(Text, { fontSize: "$2", color: "$soft", children: line }, line))) }),
|
|
53
|
+
return (_jsxs(YStack, { gap: "$4", width: "100%", minW: 0, ...slot('plan-usage'), children: [_jsxs(YStack, { gap: "$1", children: [_jsxs(Text, { fontSize: "$5", fontWeight: "600", color: "$ink", children: [name, " plan"] }), from && to ? (_jsxs(Text, { fontSize: "$2", color: "$soft", children: ["Current period ", from, " \u2013 ", to] })) : null] }), notice ? _jsx(LimitedBanner, { message: notice.message, actions: notice.actions, onAction: onAction }) : null, _jsx(UsageMeter, { limits: limits, now: now }), _jsx(YStack, { gap: "$1", ...slot('plan-usage-terms'), children: terms.map((line) => (_jsx(Text, { fontSize: "$2", color: "$soft", children: line }, line))) }), limits.creditsAfterAllowance !== undefined && onCredits ? (_jsx(Credits, { on: limits.creditsAfterAllowance, onCredits: onCredits, creditsHref: creditsHref, addCreditsHref: addCreditsHref })) : null, !notice ? _jsx(LimitActions, { actions: limits.actions, onAction: onAction }) : null] }));
|
|
41
54
|
}
|
|
42
55
|
//# sourceMappingURL=PlanUsage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlanUsage.js","sourceRoot":"","sources":["../../src/product/PlanUsage.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ
|
|
1
|
+
{"version":3,"file":"PlanUsage.js","sourceRoot":"","sources":["../../src/product/PlanUsage.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAGzC,2DAA2D;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,mEAAmE;IACnE,0EAA0E;IAC1E,wDAAwD;CAChD,CAAA;AAEV,mCAAmC;AACnC,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,sDAAsD;IACtD,wEAAwE;CAChE,CAAA;AAEV,mCAAmC;AACnC,MAAM,CAAC,MAAM,aAAa,GAAG,2FAA2F,CAAA;AAExH,mDAAmD;AACnD,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EA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,MAAM,IAAC,GAAG,EAAC,IAAI,KAAK,IAAI,CAAC,kBAAkB,CAAC,YAC1C,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,KAAC,IAAI,IAAY,QAAQ,EAAC,IAAI,EAAC,KAAK,EAAC,OAAO,YACzC,IAAI,IADI,IAAI,CAER,CACR,CAAC,GACK,EACR,MAAM,CAAC,qBAAqB,KAAK,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,CACzD,KAAC,OAAO,IAAC,EAAE,EAAE,MAAM,CAAC,qBAAqB,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,GAAI,CAC9H,CAAC,CAAC,CAAC,IAAI,EACP,CAAC,MAAM,CAAC,CAAC,CAAC,KAAC,YAAY,IAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC,CAAC,CAAC,IAAI,IACxE,CACV,CAAA;AACH,CAAC"}
|
|
@@ -17,12 +17,10 @@ const limits_1 = require("./limits.cjs");
|
|
|
17
17
|
exports.STATE_COLOR = { ok: '$good', near: '$yellow10', limited: '$bad' };
|
|
18
18
|
/** What a class row says under its bar about who pays now. */
|
|
19
19
|
function caption(c) {
|
|
20
|
-
if (c.state === 'limited' && c.paying === 'none')
|
|
21
|
-
return 'Paused';
|
|
22
|
-
if (c.paying === 'prepaid')
|
|
23
|
-
return 'Paid from prepaid credit';
|
|
24
20
|
if (c.paying === 'credits')
|
|
25
|
-
return '
|
|
21
|
+
return 'Paying from credits';
|
|
22
|
+
if (c.state === 'limited' && (c.paying === 'none' || c.paying === 'free'))
|
|
23
|
+
return 'Paused';
|
|
26
24
|
if (c.state === 'near')
|
|
27
25
|
return 'Almost used';
|
|
28
26
|
return '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsageMeter.d.ts","sourceRoot":"","sources":["../../src/product/UsageMeter.tsx"],"names":[],"mappings":"AAUA,OAAO,EAA+C,KAAK,UAAU,EAAqC,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAEvI,oDAAoD;AACpD,eAAO,MAAM,WAAW;iBAAS,OAAO;mBAAQ,WAAW;sBAAW,MAAM;CAAgD,CAAA;
|
|
1
|
+
{"version":3,"file":"UsageMeter.d.ts","sourceRoot":"","sources":["../../src/product/UsageMeter.tsx"],"names":[],"mappings":"AAUA,OAAO,EAA+C,KAAK,UAAU,EAAqC,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAEvI,oDAAoD;AACpD,eAAO,MAAM,WAAW;iBAAS,OAAO;mBAAQ,WAAW;sBAAW,MAAM;CAAgD,CAAA;AAgC5H,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,iFAAiF;IACjF,OAAO,CAAC,EAAE,SAAS,UAAU,EAAE,CAAA;IAC/B,mDAAmD;IACnD,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IAClB,uDAAuD;IACvD,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,OAAiB,EAAE,IAAW,EAAE,GAAG,EAAE,EAAE,eAAe,sCAgD1F"}
|
|
@@ -13,12 +13,10 @@ import { CLASSES, CLASS_LABEL, when } from './limits.js';
|
|
|
13
13
|
export const STATE_COLOR = { ok: '$good', near: '$yellow10', limited: '$bad' };
|
|
14
14
|
/** What a class row says under its bar about who pays now. */
|
|
15
15
|
function caption(c) {
|
|
16
|
-
if (c.state === 'limited' && c.paying === 'none')
|
|
17
|
-
return 'Paused';
|
|
18
|
-
if (c.paying === 'prepaid')
|
|
19
|
-
return 'Paid from prepaid credit';
|
|
20
16
|
if (c.paying === 'credits')
|
|
21
|
-
return '
|
|
17
|
+
return 'Paying from credits';
|
|
18
|
+
if (c.state === 'limited' && (c.paying === 'none' || c.paying === 'free'))
|
|
19
|
+
return 'Paused';
|
|
22
20
|
if (c.state === 'near')
|
|
23
21
|
return 'Almost used';
|
|
24
22
|
return '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsageMeter.js","sourceRoot":"","sources":["../../src/product/UsageMeter.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;GAIG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAoF,MAAM,UAAU,CAAA;AAEvI,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAgD,CAAA;AAE5H,8DAA8D;AAC9D,SAAS,OAAO,CAAC,CAAa;IAC5B,IAAI,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"UsageMeter.js","sourceRoot":"","sources":["../../src/product/UsageMeter.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;GAIG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAoF,MAAM,UAAU,CAAA;AAEvI,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAgD,CAAA;AAE5H,8DAA8D;AAC9D,SAAS,OAAO,CAAC,CAAa;IAC5B,IAAI,CAAC,CAAC,M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CAAC,IAAI,IACD,CACV,CAAC,CAAC,CAAC,IAAI,EACP,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAC,OAAO,IAAC,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC,CAAC,CAAC,IAAI,KA5BxD,CAAC,CA6BL,CACV,CAAA;QACH,CAAC,CAAC,GACK,CACV,CAAA;AACH,CAAC"}
|
package/dist/product/limits.cjs
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
//
|
|
11
11
|
// No React, no gui: this loads in Node and in a server component.
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.worst = exports.CLASS_LABEL = exports.CLASSES = void 0;
|
|
13
|
+
exports.worst = exports.CLASS_LABEL = exports.CLASSES = exports.navigable = void 0;
|
|
14
14
|
exports.actionsOf = actionsOf;
|
|
15
15
|
exports.limitsOf = limitsOf;
|
|
16
16
|
exports.servedOf = servedOf;
|
|
@@ -20,6 +20,9 @@ exports.classesLabel = classesLabel;
|
|
|
20
20
|
exports.when = when;
|
|
21
21
|
exports.noticeOf = noticeOf;
|
|
22
22
|
exports.nearOf = nearOf;
|
|
23
|
+
/** The actions that are pages a browser can simply open. */
|
|
24
|
+
const navigable = (a) => (a.kind === 'upgrade' || a.kind === 'topup') && Boolean(a.url);
|
|
25
|
+
exports.navigable = navigable;
|
|
23
26
|
exports.CLASSES = ['premium', 'ours', 'free'];
|
|
24
27
|
exports.CLASS_LABEL = {
|
|
25
28
|
premium: 'Premium models',
|
|
@@ -27,8 +30,14 @@ exports.CLASS_LABEL = {
|
|
|
27
30
|
free: 'Free models',
|
|
28
31
|
};
|
|
29
32
|
const STATES = ['ok', 'near', 'limited'];
|
|
30
|
-
const PAYERS = ['plan', '
|
|
31
|
-
const
|
|
33
|
+
const PAYERS = ['plan', 'credits', 'free', 'none'];
|
|
34
|
+
const KINDS = ['upgrade', 'topup', 'credits', 'switch'];
|
|
35
|
+
const LABEL = {
|
|
36
|
+
upgrade: 'Upgrade',
|
|
37
|
+
topup: 'Add prepaid credit',
|
|
38
|
+
credits: 'Continue with credits',
|
|
39
|
+
switch: 'Switch model',
|
|
40
|
+
};
|
|
32
41
|
const RANK = { ok: 0, near: 1, limited: 2 };
|
|
33
42
|
const text = (v) => (typeof v === 'string' ? v : null);
|
|
34
43
|
const one = (set, v) => typeof v === 'string' && set.includes(v) ? v : null;
|
|
@@ -62,12 +71,18 @@ function actionsOf(v) {
|
|
|
62
71
|
return [];
|
|
63
72
|
return v.flatMap((a) => {
|
|
64
73
|
const o = record(a);
|
|
65
|
-
const kind = one(
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
const kind = one(KINDS, o?.kind);
|
|
75
|
+
if (!kind)
|
|
76
|
+
return [];
|
|
77
|
+
const url = text(o?.url) ?? undefined;
|
|
78
|
+
const model = text(o?.model) ?? undefined;
|
|
79
|
+
const plan = text(o?.plan) ?? undefined;
|
|
80
|
+
// A page with no address, or a switch to no model, is not an action.
|
|
81
|
+
if ((kind === 'upgrade' || kind === 'topup') && !url)
|
|
82
|
+
return [];
|
|
83
|
+
if (kind === 'switch' && !model)
|
|
68
84
|
return [];
|
|
69
|
-
|
|
70
|
-
return [{ kind, label: text(o?.label) || (kind === 'upgrade' ? 'Upgrade' : 'Add prepaid credit'), url, ...(plan ? { plan } : {}) }];
|
|
85
|
+
return [{ kind, label: text(o?.label) || LABEL[kind], ...(url ? { url } : {}), ...(model ? { model } : {}), ...(plan ? { plan } : {}) }];
|
|
71
86
|
});
|
|
72
87
|
}
|
|
73
88
|
const classList = (v) => Array.isArray(v) ? v.flatMap((c) => (one(exports.CLASSES, c) ? [c] : [])) : [];
|
|
@@ -117,6 +132,7 @@ function limitsOf(body) {
|
|
|
117
132
|
...(paused.length ? { paused } : {}),
|
|
118
133
|
actions: actionsOf(o?.actions),
|
|
119
134
|
upgrade: text(o?.upgrade) ?? undefined,
|
|
135
|
+
...(typeof o?.credits_after_allowance === 'boolean' ? { creditsAfterAllowance: o.credits_after_allowance } : {}),
|
|
120
136
|
};
|
|
121
137
|
}
|
|
122
138
|
/** The usage headers on a served call, or null when it carries none. */
|
|
@@ -128,7 +144,7 @@ function servedOf(headers) {
|
|
|
128
144
|
return {
|
|
129
145
|
state: usage ?? 'limited',
|
|
130
146
|
class: one(exports.CLASSES, headers.get('x-hanzo-usage-class')),
|
|
131
|
-
paidBy: one(
|
|
147
|
+
paidBy: one(PAYERS, headers.get('x-hanzo-paid-by')),
|
|
132
148
|
fallback,
|
|
133
149
|
reason: headers.get('x-hanzo-usage-reason') || null,
|
|
134
150
|
};
|
|
@@ -202,8 +218,10 @@ function when(iso, now = Date.now()) {
|
|
|
202
218
|
const PLAIN = {
|
|
203
219
|
paid_plan_required: 'Premium models need a paid plan.',
|
|
204
220
|
free_plan_cap: "You've used the free plan's usage for now.",
|
|
205
|
-
insufficient_balance: 'Your
|
|
221
|
+
insufficient_balance: 'Your credits have run out.',
|
|
206
222
|
};
|
|
223
|
+
/** A paused model as a sentence names it: a glob reads as its family ("claude-opus models"). */
|
|
224
|
+
const modelWords = (model, name) => model.endsWith('*') ? `${model.slice(0, -1).split('/').pop()?.replace(/[-.]$/, '')} models` : name(model);
|
|
207
225
|
/**
|
|
208
226
|
* What to tell a reader whose usage is paused or refused, or null when nothing
|
|
209
227
|
* is. A plan's included usage being used up reads as a pause until the reset;
|
|
@@ -223,14 +241,24 @@ function noticeOf(limits, heard, name = (id) => id, now = Date.now()) {
|
|
|
223
241
|
classes.add(served.class);
|
|
224
242
|
if (!refusal && !fallback && !limits?.limited && limits?.state !== 'limited')
|
|
225
243
|
return null;
|
|
226
|
-
const list = exports.CLASSES.filter((c) => classes.has(c));
|
|
227
244
|
const reason = refusal?.code || limits?.limited?.reason || served?.reason || '';
|
|
228
|
-
|
|
245
|
+
// One model capped inside a class that is not: the class stays open, so it is not listed.
|
|
246
|
+
const capped = reason === 'model_cap'
|
|
247
|
+
? (limits?.paused?.find((p) => fallback !== null && p.fallback === fallback) ?? limits?.paused?.[0] ?? null)
|
|
248
|
+
: null;
|
|
249
|
+
if (capped && served?.class)
|
|
250
|
+
classes.delete(served.class);
|
|
251
|
+
const list = exports.CLASSES.filter((c) => classes.has(c));
|
|
252
|
+
const resets = capped
|
|
253
|
+
? (capped.resets_at ?? refusal?.resets_at ?? null)
|
|
254
|
+
: earliest([...list.map((c) => resetOf(limits?.classes[c])), refusal?.resets_at ?? null]);
|
|
229
255
|
const paused = reason === 'plan_allowance_used' || (!reason && list.length > 0);
|
|
230
256
|
const until = when(resets, now);
|
|
231
|
-
const said =
|
|
232
|
-
? `${
|
|
233
|
-
:
|
|
257
|
+
const said = capped
|
|
258
|
+
? `${modelWords(capped.model, name)} ${capped.model.endsWith('*') ? 'are' : 'is'} paused${until ? ` until ${until}` : ''}.`
|
|
259
|
+
: paused
|
|
260
|
+
? `${classesLabel(list)} are paused${until ? ` until ${until}` : ''}.`
|
|
261
|
+
: refusal?.message || limits?.limited?.message || PLAIN[reason] || 'Usage is paused for now.';
|
|
234
262
|
return {
|
|
235
263
|
reason,
|
|
236
264
|
classes: list,
|