@arbidocs/blocks 0.5.156 → 0.5.158
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/{ConnectedCallDock-SD4DKTMX.cjs → ConnectedCallDock-ML4ZTABN.cjs} +21 -21
- package/dist/{ConnectedCallDock-SD4DKTMX.cjs.map → ConnectedCallDock-ML4ZTABN.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-2FLGH3JB.cjs → ConnectedCallRoom-GBTP2LT2.cjs} +14 -14
- package/dist/{ConnectedCallRoom-2FLGH3JB.cjs.map → ConnectedCallRoom-GBTP2LT2.cjs.map} +1 -1
- package/dist/{ConnectedNativeDocxComparison-G3AIBKSN.cjs → ConnectedNativeDocxComparison-JB77U5MF.cjs} +17 -17
- package/dist/{ConnectedNativeDocxComparison-G3AIBKSN.cjs.map → ConnectedNativeDocxComparison-JB77U5MF.cjs.map} +1 -1
- package/dist/{ConnectedPresentation-J42JPUVR.cjs → ConnectedPresentation-SQZJG6ZG.cjs} +16 -16
- package/dist/{ConnectedPresentation-J42JPUVR.cjs.map → ConnectedPresentation-SQZJG6ZG.cjs.map} +1 -1
- package/dist/{ConnectedProductionSetDialog-LB5B7OXR.cjs → ConnectedProductionSetDialog-7J4T3L6U.cjs} +3 -3
- package/dist/{ConnectedProductionSetDialog-LB5B7OXR.cjs.map → ConnectedProductionSetDialog-7J4T3L6U.cjs.map} +1 -1
- package/dist/{ConnectedSlidesTab-BYS7HFNK.cjs → ConnectedSlidesTab-VLRDE7YI.cjs} +14 -14
- package/dist/{ConnectedSlidesTab-BYS7HFNK.cjs.map → ConnectedSlidesTab-VLRDE7YI.cjs.map} +1 -1
- package/dist/{ConnectedStreamedWordArtifact-ISNLUTAT.cjs → ConnectedStreamedWordArtifact-HL7PQWLF.cjs} +17 -17
- package/dist/{ConnectedStreamedWordArtifact-ISNLUTAT.cjs.map → ConnectedStreamedWordArtifact-HL7PQWLF.cjs.map} +1 -1
- package/dist/{DocumentReviewCard-7ZH575KX.cjs → DocumentReviewCard-KYC4PXXF.cjs} +16 -16
- package/dist/{DocumentReviewCard-7ZH575KX.cjs.map → DocumentReviewCard-KYC4PXXF.cjs.map} +1 -1
- package/dist/{FilesViewerDialog-6RWJSZZV.cjs → FilesViewerDialog-SHS35TMG.cjs} +46 -46
- package/dist/{FilesViewerDialog-6RWJSZZV.cjs.map → FilesViewerDialog-SHS35TMG.cjs.map} +1 -1
- package/dist/RechartsRenderer-KFHFIEIQ.cjs +347 -0
- package/dist/RechartsRenderer-KFHFIEIQ.cjs.map +1 -0
- package/dist/TimeSeriesDrawing-UHDFZPYG.cjs +166 -0
- package/dist/TimeSeriesDrawing-UHDFZPYG.cjs.map +1 -0
- package/dist/{WorkspaceTableView-NMERZJZZ.cjs → WorkspaceTableView-BO3N2NYC.cjs} +8 -8
- package/dist/{WorkspaceTableView-NMERZJZZ.cjs.map → WorkspaceTableView-BO3N2NYC.cjs.map} +1 -1
- package/dist/agents/index.cjs +285 -285
- package/dist/agents/tasks/WorkflowsTable.js +10 -6
- package/dist/agents/tasks/WorkflowsTable.js.map +2 -2
- package/dist/{ai-QFY4LYQZ.cjs → ai-NFZHPSS2.cjs} +25 -25
- package/dist/ai-NFZHPSS2.cjs.map +1 -0
- package/dist/calls/index.cjs +120 -120
- package/dist/chat/index.cjs +1 -1
- package/dist/{chunk-K7GBHLLY.cjs → chunk-2I7Z3XFC.cjs} +10 -10
- package/dist/{chunk-K7GBHLLY.cjs.map → chunk-2I7Z3XFC.cjs.map} +1 -1
- package/dist/{chunk-UJHQ4DA4.cjs → chunk-4GT4JLKS.cjs} +6 -6
- package/dist/{chunk-UJHQ4DA4.cjs.map → chunk-4GT4JLKS.cjs.map} +1 -1
- package/dist/{chunk-6I5HHWCD.cjs → chunk-4RR7ZZPD.cjs} +50 -8
- package/dist/chunk-4RR7ZZPD.cjs.map +1 -0
- package/dist/{chunk-WOVNXJK5.cjs → chunk-5AQHL4E3.cjs} +3 -3
- package/dist/{chunk-WOVNXJK5.cjs.map → chunk-5AQHL4E3.cjs.map} +1 -1
- package/dist/{chunk-GK3U3FWY.cjs → chunk-5HPUGSTJ.cjs} +15 -14
- package/dist/chunk-5HPUGSTJ.cjs.map +1 -0
- package/dist/{chunk-EG3DPKXM.cjs → chunk-6AFAYGJW.cjs} +5 -5
- package/dist/{chunk-EG3DPKXM.cjs.map → chunk-6AFAYGJW.cjs.map} +1 -1
- package/dist/{chunk-44M4FI2N.cjs → chunk-AEAK3ZBS.cjs} +58 -6
- package/dist/chunk-AEAK3ZBS.cjs.map +1 -0
- package/dist/{chunk-V4B2GSC6.cjs → chunk-ATHPGGUH.cjs} +50 -50
- package/dist/{chunk-V4B2GSC6.cjs.map → chunk-ATHPGGUH.cjs.map} +1 -1
- package/dist/{chunk-WQ2KG4LS.cjs → chunk-BCU65RJM.cjs} +3 -3
- package/dist/{chunk-WQ2KG4LS.cjs.map → chunk-BCU65RJM.cjs.map} +1 -1
- package/dist/{chunk-7UPEFZCV.cjs → chunk-C6EMTQHQ.cjs} +12 -12
- package/dist/{chunk-7UPEFZCV.cjs.map → chunk-C6EMTQHQ.cjs.map} +1 -1
- package/dist/{chunk-B2L3XNZH.cjs → chunk-CMPCSONE.cjs} +4 -4
- package/dist/{chunk-B2L3XNZH.cjs.map → chunk-CMPCSONE.cjs.map} +1 -1
- package/dist/{chunk-TD5V5BZ3.cjs → chunk-DN6VM5M5.cjs} +6 -6
- package/dist/{chunk-TD5V5BZ3.cjs.map → chunk-DN6VM5M5.cjs.map} +1 -1
- package/dist/{chunk-U4YOVI5D.cjs → chunk-FDIZWCYF.cjs} +6 -6
- package/dist/{chunk-U4YOVI5D.cjs.map → chunk-FDIZWCYF.cjs.map} +1 -1
- package/dist/{chunk-4I4IYVC6.cjs → chunk-FX5TZ6JU.cjs} +13 -9
- package/dist/chunk-FX5TZ6JU.cjs.map +1 -0
- package/dist/{chunk-U6JUIJTP.cjs → chunk-GHPLRXB4.cjs} +28 -28
- package/dist/{chunk-U6JUIJTP.cjs.map → chunk-GHPLRXB4.cjs.map} +1 -1
- package/dist/{chunk-DCD4OHDF.cjs → chunk-GOKS55KC.cjs} +28 -28
- package/dist/{chunk-DCD4OHDF.cjs.map → chunk-GOKS55KC.cjs.map} +1 -1
- package/dist/{chunk-HJHDKS4V.cjs → chunk-GP4UC2K4.cjs} +7 -7
- package/dist/{chunk-HJHDKS4V.cjs.map → chunk-GP4UC2K4.cjs.map} +1 -1
- package/dist/{chunk-UD3LPATQ.cjs → chunk-HKKNHHBB.cjs} +6 -6
- package/dist/{chunk-UD3LPATQ.cjs.map → chunk-HKKNHHBB.cjs.map} +1 -1
- package/dist/{chunk-HGD4B7GO.cjs → chunk-IO3MNT4N.cjs} +4 -4
- package/dist/{chunk-HGD4B7GO.cjs.map → chunk-IO3MNT4N.cjs.map} +1 -1
- package/dist/{chunk-AHUEBRLX.cjs → chunk-JEHGTPS2.cjs} +4 -4
- package/dist/{chunk-AHUEBRLX.cjs.map → chunk-JEHGTPS2.cjs.map} +1 -1
- package/dist/{chunk-6P4U63HO.cjs → chunk-KAKEFIDS.cjs} +13 -13
- package/dist/{chunk-6P4U63HO.cjs.map → chunk-KAKEFIDS.cjs.map} +1 -1
- package/dist/{chunk-M24FBUAP.cjs → chunk-KMMKGJPX.cjs} +4 -4
- package/dist/{chunk-M24FBUAP.cjs.map → chunk-KMMKGJPX.cjs.map} +1 -1
- package/dist/{chunk-G3MRW4WB.cjs → chunk-LK4TQBV6.cjs} +3 -3
- package/dist/{chunk-G3MRW4WB.cjs.map → chunk-LK4TQBV6.cjs.map} +1 -1
- package/dist/{chunk-PTT5MZ7O.cjs → chunk-MQS2PCCN.cjs} +69 -69
- package/dist/{chunk-PTT5MZ7O.cjs.map → chunk-MQS2PCCN.cjs.map} +1 -1
- package/dist/{chunk-CYWOL2LS.cjs → chunk-MSFWSDRS.cjs} +3 -3
- package/dist/{chunk-CYWOL2LS.cjs.map → chunk-MSFWSDRS.cjs.map} +1 -1
- package/dist/{chunk-FNBUFKHE.cjs → chunk-N2YOVDEN.cjs} +15 -15
- package/dist/{chunk-FNBUFKHE.cjs.map → chunk-N2YOVDEN.cjs.map} +1 -1
- package/dist/{chunk-PD47L6KS.cjs → chunk-NBKYVMAK.cjs} +4 -4
- package/dist/{chunk-PD47L6KS.cjs.map → chunk-NBKYVMAK.cjs.map} +1 -1
- package/dist/{chunk-Q7G2W5VQ.cjs → chunk-NPY5XQSN.cjs} +4 -4
- package/dist/{chunk-Q7G2W5VQ.cjs.map → chunk-NPY5XQSN.cjs.map} +1 -1
- package/dist/{chunk-73KNWWBW.cjs → chunk-P4KNRU7Y.cjs} +48 -48
- package/dist/{chunk-73KNWWBW.cjs.map → chunk-P4KNRU7Y.cjs.map} +1 -1
- package/dist/{chunk-BNHFDXJI.cjs → chunk-PC2ZGCSX.cjs} +36 -36
- package/dist/{chunk-BNHFDXJI.cjs.map → chunk-PC2ZGCSX.cjs.map} +1 -1
- package/dist/{chunk-HLUZMXEZ.cjs → chunk-QAPDDRE4.cjs} +64 -64
- package/dist/{chunk-HLUZMXEZ.cjs.map → chunk-QAPDDRE4.cjs.map} +1 -1
- package/dist/{chunk-PBPO54KZ.cjs → chunk-QEMGGJB6.cjs} +97 -5
- package/dist/chunk-QEMGGJB6.cjs.map +1 -0
- package/dist/chunk-S3UNLRVM.cjs +87 -0
- package/dist/chunk-S3UNLRVM.cjs.map +1 -0
- package/dist/{chunk-V27WLYTG.cjs → chunk-UEQNTXWV.cjs} +3 -3
- package/dist/{chunk-V27WLYTG.cjs.map → chunk-UEQNTXWV.cjs.map} +1 -1
- package/dist/{chunk-PIWXX2M4.cjs → chunk-UOE6VC36.cjs} +11 -11
- package/dist/{chunk-PIWXX2M4.cjs.map → chunk-UOE6VC36.cjs.map} +1 -1
- package/dist/{chunk-DYIZ7W4P.cjs → chunk-VBSEYTRN.cjs} +3 -3
- package/dist/{chunk-DYIZ7W4P.cjs.map → chunk-VBSEYTRN.cjs.map} +1 -1
- package/dist/{chunk-LLVE5TST.cjs → chunk-VJRO6J37.cjs} +3 -3
- package/dist/{chunk-LLVE5TST.cjs.map → chunk-VJRO6J37.cjs.map} +1 -1
- package/dist/{chunk-GF6AYAMI.cjs → chunk-XBZP5J24.cjs} +7 -7
- package/dist/{chunk-GF6AYAMI.cjs.map → chunk-XBZP5J24.cjs.map} +1 -1
- package/dist/{chunk-JARBYN6Z.cjs → chunk-Y3OI7ZP7.cjs} +3 -3
- package/dist/{chunk-JARBYN6Z.cjs.map → chunk-Y3OI7ZP7.cjs.map} +1 -1
- package/dist/{chunk-YO7GDNEW.cjs → chunk-YFO2VHYQ.cjs} +108 -17
- package/dist/chunk-YFO2VHYQ.cjs.map +1 -0
- package/dist/connect/docx.cjs +20 -20
- package/dist/connect/index.cjs +1133 -1204
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/viewer.cjs +34 -34
- package/dist/connection/dashboards/DashboardPanel.js +1 -1
- package/dist/connection/dashboards/DashboardPanel.js.map +2 -2
- package/dist/connection/dashboards/PanelEditor.d.ts +4 -0
- package/dist/connection/dashboards/PanelEditor.js +45 -3
- package/dist/connection/dashboards/PanelEditor.js.map +2 -2
- package/dist/connection/export/ConnectedExportPanel.js +12 -7
- package/dist/connection/export/ConnectedExportPanel.js.map +2 -2
- package/dist/connection/export/transfer-text.d.ts +5 -0
- package/dist/connection/export/transfer-text.js +6 -1
- package/dist/connection/export/transfer-text.js.map +2 -2
- package/dist/connection/pages/PageTransferDialog.js +19 -2
- package/dist/connection/pages/PageTransferDialog.js.map +2 -2
- package/dist/dashboards/ChartRenderer.js +3 -2
- package/dist/dashboards/ChartRenderer.js.map +2 -2
- package/dist/dashboards/RechartsRenderer.js +171 -2
- package/dist/dashboards/RechartsRenderer.js.map +2 -2
- package/dist/dashboards/chartModel.d.ts +52 -2
- package/dist/dashboards/chartModel.js +95 -3
- package/dist/dashboards/chartModel.js.map +2 -2
- package/dist/dashboards/index.cjs +773 -24
- package/dist/dashboards/index.cjs.map +1 -1
- package/dist/dashboards/index.d.ts +3 -2
- package/dist/dashboards/index.js +9 -2
- package/dist/dashboards/index.js.map +2 -2
- package/dist/dashboards/monitor/LogViewer.d.ts +47 -0
- package/dist/dashboards/monitor/LogViewer.js +279 -0
- package/dist/dashboards/monitor/LogViewer.js.map +7 -0
- package/dist/dashboards/monitor/RequestTimeline.d.ts +68 -0
- package/dist/dashboards/monitor/RequestTimeline.js +228 -0
- package/dist/dashboards/monitor/RequestTimeline.js.map +7 -0
- package/dist/dashboards/monitor/StackedBar.d.ts +41 -0
- package/dist/dashboards/monitor/StackedBar.js +131 -0
- package/dist/dashboards/monitor/StackedBar.js.map +7 -0
- package/dist/dashboards/monitor/TimeSeriesChart.d.ts +60 -0
- package/dist/dashboards/monitor/TimeSeriesChart.js +116 -0
- package/dist/dashboards/monitor/TimeSeriesChart.js.map +7 -0
- package/dist/dashboards/monitor/TimeSeriesDrawing.d.ts +14 -0
- package/dist/dashboards/monitor/TimeSeriesDrawing.js +173 -0
- package/dist/dashboards/monitor/TimeSeriesDrawing.js.map +7 -0
- package/dist/dashboards/monitor/index.d.ts +10 -0
- package/dist/dashboards/monitor/index.js +44 -0
- package/dist/dashboards/monitor/index.js.map +7 -0
- package/dist/dashboards/monitor/units.d.ts +30 -0
- package/dist/dashboards/monitor/units.js +85 -0
- package/dist/dashboards/monitor/units.js.map +7 -0
- package/dist/embed/index.cjs +40 -40
- package/dist/files/TransferParts.d.ts +18 -1
- package/dist/files/TransferParts.js +55 -3
- package/dist/files/TransferParts.js.map +2 -2
- package/dist/files/index.cjs +231 -227
- package/dist/files/index.d.ts +1 -1
- package/dist/files/index.js +2 -0
- package/dist/files/index.js.map +2 -2
- package/dist/index.cjs +1612 -1612
- package/dist/pages/index.cjs +47 -32
- package/dist/pages/index.cjs.map +1 -1
- package/dist/settings/index.cjs +137 -137
- package/dist/shell/index.cjs +81 -81
- package/dist/studio/index.cjs +36 -36
- package/dist/studio/index.cjs.map +1 -1
- package/dist/studio/widgets.js +1 -1
- package/dist/studio/widgets.js.map +2 -2
- package/dist/styles.css +1 -1
- package/dist/workflow-canvas/index.cjs +58 -58
- package/dist/workflow-canvas/index.cjs.map +1 -1
- package/dist/workflow-canvas/trigger.d.ts +5 -1
- package/dist/workflow-canvas/trigger.js +1 -1
- package/dist/workflow-canvas/trigger.js.map +2 -2
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/dist/RechartsRenderer-EPVL5QZA.cjs +0 -186
- package/dist/RechartsRenderer-EPVL5QZA.cjs.map +0 -1
- package/dist/ai-QFY4LYQZ.cjs.map +0 -1
- package/dist/chunk-44M4FI2N.cjs.map +0 -1
- package/dist/chunk-4I4IYVC6.cjs.map +0 -1
- package/dist/chunk-6I5HHWCD.cjs.map +0 -1
- package/dist/chunk-GK3U3FWY.cjs.map +0 -1
- package/dist/chunk-PBPO54KZ.cjs.map +0 -1
- package/dist/chunk-YO7GDNEW.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunkQEMGGJB6_cjs = require('./chunk-QEMGGJB6.cjs');
|
|
5
5
|
var chunk2P7VH2SK_cjs = require('./chunk-2P7VH2SK.cjs');
|
|
6
6
|
var chunkIPSHAMO2_cjs = require('./chunk-IPSHAMO2.cjs');
|
|
7
7
|
var chunk46LX6EQT_cjs = require('./chunk-46LX6EQT.cjs');
|
|
@@ -54,7 +54,7 @@ function DashboardCell({
|
|
|
54
54
|
}
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
|
-
var loadRecharts = () => import('./RechartsRenderer-
|
|
57
|
+
var loadRecharts = () => import('./RechartsRenderer-KFHFIEIQ.cjs');
|
|
58
58
|
var RechartsRenderer = react.lazy(loadRecharts);
|
|
59
59
|
function preloadChartRenderer() {
|
|
60
60
|
void loadRecharts();
|
|
@@ -73,18 +73,19 @@ function ChartTable({
|
|
|
73
73
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cn("overflow-auto", fill ? "h-full min-h-0" : "max-h-72"), children: /* @__PURE__ */ jsxRuntime.jsxs("table", { id, className: "w-full text-left text-xs", "data-slot": "chart-table", children: [
|
|
74
74
|
/* @__PURE__ */ jsxRuntime.jsx("caption", { className: "sr-only", children: caption }),
|
|
75
75
|
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "border-b border-border text-muted-foreground", children: [
|
|
76
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: "py-1.5 pr-3 font-medium", children: model.xLabel }),
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: "py-1.5 pr-3 font-medium", children: model.scatter ? model.scatter.labelName : model.xLabel }),
|
|
77
77
|
model.series.map((s) => /* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: "py-1.5 pr-3 text-right font-medium", children: s.label }, s.id))
|
|
78
78
|
] }) }),
|
|
79
79
|
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: model.categories.map((category, i) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "border-b border-border/60 last:border-0", children: [
|
|
80
80
|
/* @__PURE__ */ jsxRuntime.jsx("th", { scope: "row", className: "py-1.5 pr-3 font-normal text-foreground", children: category }),
|
|
81
|
-
model.series.map((s) => /* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-1.5 pr-3 text-right tabular-nums text-foreground", children: s.values[i] === null ? "\u2013" : model.format(s.values[i]) }, s.id))
|
|
81
|
+
model.series.map((s) => /* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-1.5 pr-3 text-right tabular-nums text-foreground", children: s.values[i] === null ? "\u2013" : (s.format ?? model.format)(s.values[i]) }, s.id))
|
|
82
82
|
] }, `${category}-${i}`)) })
|
|
83
83
|
] }) });
|
|
84
84
|
}
|
|
85
85
|
function Legend({ model, other }) {
|
|
86
|
+
if (model.scatter) return null;
|
|
86
87
|
const pie = model.type === "pie" || model.type === "donut";
|
|
87
|
-
const items = pie ? model.categories.map((label, i) => ({ label, color:
|
|
88
|
+
const items = pie ? model.categories.map((label, i) => ({ label, color: chunkQEMGGJB6_cjs.sliceColors(model, other)[i] })) : model.series.map((s) => ({ label: s.label, color: s.color }));
|
|
88
89
|
if (!pie && items.length < 2) return null;
|
|
89
90
|
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex flex-wrap justify-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: items.map((item, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "inline-flex items-center gap-1.5", children: [
|
|
90
91
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -183,7 +184,7 @@ function cellText(value, field, l, formatters) {
|
|
|
183
184
|
if (Array.isArray(value)) return value.join(", ");
|
|
184
185
|
if (typeof value === "boolean") return value ? l.yes : l.no;
|
|
185
186
|
if (field.type === "number" && typeof value === "number")
|
|
186
|
-
return
|
|
187
|
+
return chunkQEMGGJB6_cjs.formatterOf(field, formatters)(value);
|
|
187
188
|
if (field.type === "date" && typeof value === "string") return chunkIPSHAMO2_cjs.fmtDate(value);
|
|
188
189
|
return String(value);
|
|
189
190
|
}
|
|
@@ -451,7 +452,7 @@ function itemTitle({ item, name }) {
|
|
|
451
452
|
return ITEM_LABELS[item.kind] ?? item.kind;
|
|
452
453
|
}
|
|
453
454
|
var PANEL_FORMATTERS = {
|
|
454
|
-
...
|
|
455
|
+
...chunkQEMGGJB6_cjs.DEFAULT_UNIT_FORMATTERS,
|
|
455
456
|
gbp: (v) => react$1.formatGbp(v),
|
|
456
457
|
bytes: (v) => formatBytes(v)
|
|
457
458
|
};
|
|
@@ -460,7 +461,7 @@ var DEFAULT_DASHBOARD_PANEL_LABELS = {
|
|
|
460
461
|
openDatabases: "Open databases",
|
|
461
462
|
noWorkspace: "Open a workspace to see this."
|
|
462
463
|
};
|
|
463
|
-
var DRAWN = /* @__PURE__ */ new Set(["bar", "line", "area", "pie", "donut"]);
|
|
464
|
+
var DRAWN = /* @__PURE__ */ new Set(["bar", "line", "area", "pie", "donut", "scatter"]);
|
|
464
465
|
function kindOf(panel) {
|
|
465
466
|
return panel.chart.type === "metric" ? "metric" : panel.chart.type === "table" ? "table" : "chart";
|
|
466
467
|
}
|
|
@@ -496,14 +497,14 @@ function SourcePanel({
|
|
|
496
497
|
const op = chart.aggregate ?? "count";
|
|
497
498
|
return {
|
|
498
499
|
kind: "metric",
|
|
499
|
-
value:
|
|
500
|
-
format:
|
|
500
|
+
value: chunkQEMGGJB6_cjs.metricValueOf(dataset) ?? (op === "count" || op === "sum" ? 0 : null),
|
|
501
|
+
format: chunkQEMGGJB6_cjs.formatterOf(valueField, formatters)
|
|
501
502
|
};
|
|
502
503
|
}
|
|
503
504
|
if (DRAWN.has(chart.type)) {
|
|
504
505
|
return {
|
|
505
506
|
kind: "chart",
|
|
506
|
-
model:
|
|
507
|
+
model: chunkQEMGGJB6_cjs.chartModelOf({ ...chart, type: chart.type }, dataset, {
|
|
507
508
|
fields,
|
|
508
509
|
formatters,
|
|
509
510
|
otherLabel: other
|
|
@@ -513,7 +514,7 @@ function SourcePanel({
|
|
|
513
514
|
if (chart.x) {
|
|
514
515
|
return {
|
|
515
516
|
kind: "groups",
|
|
516
|
-
model:
|
|
517
|
+
model: chunkQEMGGJB6_cjs.chartModelOf({ ...chart, type: "bar" }, dataset, {
|
|
517
518
|
fields,
|
|
518
519
|
formatters,
|
|
519
520
|
otherLabel: other
|
|
@@ -611,5 +612,5 @@ exports.kindRows = kindRows;
|
|
|
611
612
|
exports.reducedRateNote = reducedRateNote;
|
|
612
613
|
exports.usedOfLimit = usedOfLimit;
|
|
613
614
|
exports.usedPct = usedPct;
|
|
614
|
-
//# sourceMappingURL=chunk-
|
|
615
|
-
//# sourceMappingURL=chunk-
|
|
615
|
+
//# sourceMappingURL=chunk-5HPUGSTJ.cjs.map
|
|
616
|
+
//# sourceMappingURL=chunk-5HPUGSTJ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dashboards/DashboardGrid.tsx","../src/dashboards/ChartRenderer.tsx","../src/dashboards/PanelView.tsx","../src/connection/storage/storage-labels.ts","../src/connection/dashboards/DashboardPanel.tsx"],"names":["jsx","cn","lazy","jsxs","sliceColors","useState","useId","Suspense","formatterOf","fmtDate","DataTable","AlertTriangle","ChartNoAxesColumn","MetricCard","Card","formatFileSize","DEFAULT_UNIT_FORMATTERS","formatGbp","useBlocksEnvironment","useEffect","usePanelDataset","useMemo","metricValueOf","chartModelOf","Button","useDataSources","useArbiSessionState"],"mappings":";;;;;;;;;;;;;AAQA,IAAM,KAAA,GAAQ;AAAA,EACZ,eAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF,CAAA;AAGO,SAAS,gBAAgB,KAAA,EAAmC;AACjE,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,EAAA,EAAI,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,KAAA,IAAS,CAAC,CAAC,CAAC,CAAA;AACzD;AASO,SAAS,aAAA,CAAc,EAAE,QAAA,EAAU,SAAA,EAAW,QAAO,EAAuB;AACjF,EAAA,uBACEA,cAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAWC,KAAA,CAAG,wCAAA,EAA0C,SAAS,CAAA;AAAA,MACjE,WAAA,EAAU,WAAA;AAAA,MACV,aAAA,EAAa,MAAA;AAAA,MAEZ;AAAA;AAAA,GACH;AAEJ;AAGO,SAAS,aAAA,CAAc;AAAA,EAC5B,KAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA,EAIG;AACD,EAAA,uBACED,cAAA;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QACf,KAAK,KAAA,CAAM,GAAA;AAAA,QACX,WAAW,KAAA,CAAM,SAAA;AAAA,QACjB,QAAQ,KAAA,CAAM;AAAA;AAAA,KAChB;AAAA,EAEJ;AACA,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,uBACEA,cAAAA;AAAA,MAAC,SAAA;AAAA,MAAA;AAAA,QACC,IAAA,EAAM,MAAA,CAAO,KAAA,CAAM,KAAK,CAAA;AAAA,QACxB,KAAA,EAAO,MAAM,KAAA,CAAM,KAAA;AAAA,QACnB,KAAA,EAAM,OAAA;AAAA,QACN,aAAa,CAAA,CAAE,aAAA,GAAgB,KAAA,CAAM,KAAA,CAAM,OAAO,EAAE,CAAA;AAAA,QACpD,SAAS,KAAA,CAAM,OAAA;AAAA,QACf,MAAA,EAAQ,CAAA;AAAA,QACR,KAAK,KAAA,CAAM,GAAA;AAAA,QACX,WAAW,KAAA,CAAM,SAAA;AAAA,QACjB,QAAQ,KAAA,CAAM;AAAA;AAAA,KAChB;AAAA,EAEJ;AAEA,EAAA,uBACEA,cAAAA,CAAC,WAAA,EAAA,EAA4B,MAAA,EAAgB,UAAA,EAAwB,QAAQ,CAAA,EAAI,GAAG,KAAA,EAAA,EAAlE,MAAA,CAAO,EAAkE,CAAA;AAE/F","file":"chunk-5HPUGSTJ.cjs","sourcesContent":["/**\n * `DashboardGrid`: a responsive 12-column grid of panels. Each child spans `width` columns on a wide\n * screen and the full width on a phone, where panels stack in order.\n */\nimport type { ReactNode } from 'react'\nimport { cn } from '@arbidocs/react/ui'\n\n/** Literal classes (the stylesheet is generated from the source): `md:col-span-1…12`. */\nconst SPANS = [\n 'md:col-span-1',\n 'md:col-span-2',\n 'md:col-span-3',\n 'md:col-span-4',\n 'md:col-span-5',\n 'md:col-span-6',\n 'md:col-span-7',\n 'md:col-span-8',\n 'md:col-span-9',\n 'md:col-span-10',\n 'md:col-span-11',\n 'md:col-span-12',\n] as const\n\n/** A width in grid columns, kept within 1…12 (default 6, half the row). */\nexport function clampPanelWidth(width: number | undefined): number {\n return Math.min(12, Math.max(1, Math.round(width ?? 6)))\n}\n\nexport interface DashboardGridProps {\n children?: ReactNode\n className?: string\n testId?: string\n}\n\n/** The grid. Wrap each panel in a `DashboardCell`. */\nexport function DashboardGrid({ children, className, testId }: DashboardGridProps) {\n return (\n <div\n className={cn('grid grid-cols-1 gap-4 md:grid-cols-12', className)}\n data-slot=\"dashboard\"\n data-testid={testId}\n >\n {children}\n </div>\n )\n}\n\n/** One cell of the grid, `width` columns wide on a wide screen. */\nexport function DashboardCell({\n width,\n children,\n className,\n}: {\n width?: number\n children?: ReactNode\n className?: string\n}) {\n return (\n <div\n className={cn('col-span-1 min-w-0', SPANS[clampPanelWidth(width) - 1], className)}\n data-slot=\"dashboard-cell\"\n >\n {children}\n </div>\n )\n}\n","/**\n * `ChartRenderer`: draws a `ChartModel`. The drawing library is loaded on demand (a skeleton shows\n * meanwhile), so a page fetches it only when a chart is on screen. Beside the drawing: a legend in\n * the theme's text colours, and a table of the same values one click away (for screen readers,\n * copying, or when colours are hard to tell apart).\n */\nimport { lazy, Suspense, useId, useState } from 'react'\nimport { cn } from '@arbidocs/react/ui'\nimport { sliceColors, type ChartModel } from './chartModel'\n\nconst loadRecharts = () => import('./RechartsRenderer')\nconst RechartsRenderer = lazy(loadRecharts)\n\n/**\n * Start fetching the drawing library now (a chart panel calls it as its data starts loading), so\n * the code arrives alongside the data instead of only after it. Safe to call often: the module\n * is fetched once.\n */\nexport function preloadChartRenderer(): void {\n void loadRecharts()\n}\n\nexport interface ChartRendererLabels {\n showTable: string\n showChart: string\n other: string\n}\n\nexport const DEFAULT_CHART_RENDERER_LABELS: ChartRendererLabels = {\n showTable: 'Show table',\n showChart: 'Show chart',\n other: 'Other',\n}\n\nexport interface ChartRendererProps {\n model: ChartModel\n ariaLabel: string\n /** The plot's height in px (default 240), or `fill`: whatever its box leaves (a page's tile). */\n height?: number | 'fill'\n /** Start on the table. */\n defaultView?: 'chart' | 'table'\n labels?: Partial<ChartRendererLabels>\n className?: string\n testId?: string\n}\n\n/** The values as a table: a row per category, a column per series. */\nexport function ChartTable({\n model,\n caption,\n id,\n fill,\n}: {\n model: ChartModel\n caption: string\n id?: string\n /** Scroll within the box it is in (a page's tile), not a fixed height. */\n fill?: boolean\n}) {\n return (\n <div className={cn('overflow-auto', fill ? 'h-full min-h-0' : 'max-h-72')}>\n <table id={id} className=\"w-full text-left text-xs\" data-slot=\"chart-table\">\n <caption className=\"sr-only\">{caption}</caption>\n <thead>\n <tr className=\"border-b border-border text-muted-foreground\">\n <th scope=\"col\" className=\"py-1.5 pr-3 font-medium\">\n {model.scatter ? model.scatter.labelName : model.xLabel}\n </th>\n {model.series.map((s) => (\n <th key={s.id} scope=\"col\" className=\"py-1.5 pr-3 text-right font-medium\">\n {s.label}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {model.categories.map((category, i) => (\n <tr key={`${category}-${i}`} className=\"border-b border-border/60 last:border-0\">\n <th scope=\"row\" className=\"py-1.5 pr-3 font-normal text-foreground\">\n {category}\n </th>\n {model.series.map((s) => (\n <td key={s.id} className=\"py-1.5 pr-3 text-right tabular-nums text-foreground\">\n {s.values[i] === null ? '–' : (s.format ?? model.format)(s.values[i] as number)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )\n}\n\nfunction Legend({ model, other }: { model: ChartModel; other: string }) {\n // A scatter's points are labelled on the plot; its two series are its axes, not a legend.\n if (model.scatter) return null\n const pie = model.type === 'pie' || model.type === 'donut'\n const items = pie\n ? model.categories.map((label, i) => ({ label, color: sliceColors(model, other)[i] }))\n : model.series.map((s) => ({ label: s.label, color: s.color }))\n if (!pie && items.length < 2) return null\n return (\n <ul className=\"flex flex-wrap justify-center gap-x-4 gap-y-1 text-xs text-muted-foreground\">\n {items.map((item, i) => (\n <li key={`${item.label}-${i}`} className=\"inline-flex items-center gap-1.5\">\n <span\n aria-hidden=\"true\"\n className=\"inline-block size-2 rounded-full\"\n style={{ background: item.color }}\n />\n {item.label}\n </li>\n ))}\n </ul>\n )\n}\n\nexport function ChartRenderer({\n model,\n ariaLabel,\n height = 240,\n defaultView = 'chart',\n labels,\n className,\n testId,\n}: ChartRendererProps) {\n const l = { ...DEFAULT_CHART_RENDERER_LABELS, ...labels }\n const [view, setView] = useState(defaultView)\n const tableId = useId()\n const fill = height === 'fill'\n return (\n <figure\n className={cn('flex min-w-0 max-w-full flex-col gap-2', fill && 'h-full min-h-0', className)}\n data-slot=\"dashboard-chart\"\n data-type={model.type}\n data-testid={testId}\n >\n {view === 'table' ? (\n <div className={cn(fill && 'min-h-0 flex-1')}>\n <ChartTable model={model} caption={ariaLabel} id={tableId} fill={fill} />\n </div>\n ) : (\n <div\n className={cn('min-w-0', fill && 'min-h-0 flex-1')}\n style={fill ? undefined : { height }}\n role=\"figure\"\n aria-label={ariaLabel}\n >\n <Suspense\n fallback={\n <div\n className=\"size-full animate-pulse rounded-md bg-muted\"\n data-slot=\"chart-loading\"\n />\n }\n >\n <RechartsRenderer\n model={model}\n ariaLabel={ariaLabel}\n height={fill ? '100%' : height}\n otherLabel={l.other}\n />\n </Suspense>\n </div>\n )}\n <figcaption className=\"flex flex-wrap items-center justify-between gap-2\">\n <Legend model={model} other={l.other} />\n <button\n type=\"button\"\n className=\"ml-auto rounded-sm text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring print:hidden\"\n aria-controls={view === 'table' ? tableId : undefined}\n aria-pressed={view === 'table'}\n onClick={() => setView(view === 'table' ? 'chart' : 'table')}\n >\n {view === 'table' ? l.showChart : l.showTable}\n </button>\n </figcaption>\n </figure>\n )\n}\n","/**\n * `PanelView`: one dashboard panel as it looks, from data already in hand: a metric tile, a chart\n * or a table, each with its loading, empty and error state. Presentational: `DashboardPanel` reads\n * the data and renders this.\n */\nimport type { ReactNode } from 'react'\nimport { AlertTriangle, ChartNoAxesColumn } from 'lucide-react'\nimport type { DatasetField, DatasetRow, DatasetValue } from '@arbidocs/react'\nimport { Card, cn } from '@arbidocs/react/ui'\nimport { DataTable, type Column } from '../components/DataTable'\nimport { MetricCard } from '../components/MetricCard'\nimport { fmtDate } from '../lib/format'\nimport { ChartRenderer, ChartTable, type ChartRendererLabels } from './ChartRenderer'\nimport { formatterOf, type ChartModel, type UnitFormatters } from './chartModel'\n\nexport type PanelState = 'loading' | 'empty' | 'error' | 'ready'\n\nexport interface PanelViewLabels extends ChartRendererLabels {\n /** While the panel's data is still being read. */\n loading: string\n empty: string\n error: string\n /** Under a table cut short: \"Showing 50 of 1,200 rows\". */\n showingRows: (shown: number, total: number) => string\n yes: string\n no: string\n}\n\nexport const DEFAULT_PANEL_VIEW_LABELS: PanelViewLabels = {\n showTable: 'Show table',\n showChart: 'Show chart',\n other: 'Other',\n loading: 'Loading…',\n empty: 'Nothing to show yet.',\n error: 'This panel could not be loaded.',\n showingRows: (shown, total) =>\n `Showing ${shown.toLocaleString('en-GB')} of ${total.toLocaleString('en-GB')} rows`,\n yes: 'Yes',\n no: 'No',\n}\n\n/** What a panel shows when ready. */\nexport type PanelBody =\n | { kind: 'metric'; value: number | null; format: (value: number) => string }\n | { kind: 'chart'; model: ChartModel }\n /** A table of groups (a chart model shown as a table). */\n | { kind: 'groups'; model: ChartModel }\n /** A table of records. */\n | { kind: 'records'; fields: readonly DatasetField[]; rows: readonly DatasetRow[] }\n\nexport interface PanelViewProps {\n /** What the panel is (it shows as one before its data is in). */\n kind: 'metric' | 'chart' | 'table'\n title: string\n description?: string\n state: PanelState\n body?: PanelBody\n /** The error's own words, shown under the panel's. */\n errorDetail?: string\n /** Shown in the empty state (a link to where data comes from). */\n emptyAction?: ReactNode\n /** Buttons in the panel's corner (edit, remove), for a dashboard being edited. */\n actions?: ReactNode\n /** A metric's tile, with the theme accent token of its icon. */\n metricAccent?: string\n /** `card` (default): a card with the title; `plain`: no card (a chart placed in a page). */\n variant?: 'card' | 'plain'\n /** Most records a table shows. Default 50. */\n maxRows?: number\n /**\n * Fit the box it is given (a page's tile, any size): the chart takes the room left, a table\n * scrolls inside, nothing spills out. Default: the panel's own heights.\n */\n fit?: boolean\n formatters?: UnitFormatters\n labels?: Partial<PanelViewLabels>\n className?: string\n testId?: string\n}\n\nfunction cellText(\n value: DatasetValue | undefined,\n field: DatasetField,\n l: PanelViewLabels,\n formatters?: UnitFormatters\n): string {\n if (value === null || value === undefined || value === '') return '–'\n if (Array.isArray(value)) return value.join(', ')\n if (typeof value === 'boolean') return value ? l.yes : l.no\n if (field.type === 'number' && typeof value === 'number')\n return formatterOf(field, formatters)(value)\n if (field.type === 'date' && typeof value === 'string') return fmtDate(value)\n return String(value)\n}\n\nfunction RecordsTable({\n fields,\n rows,\n maxRows,\n l,\n formatters,\n fit,\n testId,\n}: {\n fit?: boolean\n fields: readonly DatasetField[]\n rows: readonly DatasetRow[]\n maxRows: number\n l: PanelViewLabels\n formatters?: UnitFormatters\n testId?: string\n}) {\n const shown = rows.slice(0, maxRows).map((row, i) => ({ row, i }))\n const columns: Column<{ row: DatasetRow; i: number }>[] = fields.map((field) => ({\n key: field.id,\n header: field.label,\n align: field.type === 'number' ? 'right' : 'left',\n render: ({ row }) => cellText(row[field.id], field, l, formatters),\n className: field.type === 'number' ? 'tabular-nums' : undefined,\n }))\n return (\n <div className={cn('space-y-1', fit && 'flex h-full min-h-0 flex-col')}>\n <div className={cn('overflow-auto', fit ? 'min-h-0 flex-1' : 'max-h-80')}>\n <DataTable\n columns={columns}\n rows={shown}\n getRowId={({ i }) => String(i)}\n area={testId ?? 'dashboard-panel'}\n emptyTitle={l.empty}\n className=\"border-0\"\n />\n </div>\n {rows.length > maxRows && (\n <p className=\"text-xs text-muted-foreground\">{l.showingRows(maxRows, rows.length)}</p>\n )}\n </div>\n )\n}\n\nfunction Message({\n tone,\n text,\n detail,\n action,\n fit,\n testId,\n}: {\n fit?: boolean\n tone: 'empty' | 'error'\n text: string\n detail?: string\n action?: ReactNode\n testId?: string\n}) {\n const Icon = tone === 'error' ? AlertTriangle : ChartNoAxesColumn\n return (\n <div\n className={cn(\n 'flex flex-col items-center justify-center gap-2 text-center',\n fit ? 'h-full min-h-0 overflow-hidden py-2' : 'min-h-40 py-6'\n )}\n role={tone === 'error' ? 'alert' : undefined}\n data-testid={testId}\n >\n <Icon\n className={cn('size-6', tone === 'error' ? 'text-destructive' : 'text-muted-foreground/50')}\n />\n <p className={cn('text-sm', tone === 'error' ? 'text-destructive' : 'text-muted-foreground')}>\n {text}\n </p>\n {detail && <p className=\"max-w-sm text-xs text-muted-foreground\">{detail}</p>}\n {action}\n </div>\n )\n}\n\nexport function PanelView({\n kind,\n title,\n description,\n state,\n body,\n errorDetail,\n emptyAction,\n actions,\n metricAccent,\n variant = 'card',\n maxRows = 50,\n fit = false,\n formatters,\n labels,\n className,\n testId,\n}: PanelViewProps) {\n const l = { ...DEFAULT_PANEL_VIEW_LABELS, ...labels }\n\n // A metric is the KPI tile itself.\n if (kind === 'metric') {\n const metric = body?.kind === 'metric' ? body : undefined\n const hint =\n state === 'error' ? (\n <span className=\"text-destructive\">\n {l.error}\n {errorDetail && ` ${errorDetail}`}\n </span>\n ) : state === 'empty' ? (\n l.empty\n ) : state === 'loading' ? (\n l.loading\n ) : (\n description\n )\n return (\n <div className={cn('relative h-full', className)} data-slot=\"dashboard-panel\">\n <MetricCard\n label={title}\n value={\n metric && metric.value !== null && state === 'ready' ? metric.format(metric.value) : '—'\n }\n hint={hint}\n isLoading={state === 'loading'}\n accent={metricAccent}\n // The edit buttons sit in the corner: the label starts below them.\n className={cn('h-full', actions && 'pt-11')}\n testId={testId}\n />\n {actions && <div className=\"absolute right-2 top-2 flex gap-1\">{actions}</div>}\n </div>\n )\n }\n\n let content: ReactNode\n if (state === 'loading') {\n content = (\n <div\n className={cn(\n 'flex items-center justify-center rounded-md bg-muted/50 text-sm text-muted-foreground',\n fit ? 'h-full min-h-0' : 'h-60'\n )}\n role=\"status\"\n data-slot=\"panel-loading\"\n data-testid={testId && `${testId}-loading`}\n >\n <span className=\"animate-pulse\">{l.loading}</span>\n </div>\n )\n } else if (state === 'error') {\n content = (\n <Message\n fit={fit}\n tone=\"error\"\n text={l.error}\n detail={errorDetail}\n testId={testId && `${testId}-error`}\n />\n )\n } else if (state === 'empty' || !body || body.kind === 'metric') {\n content = (\n <Message\n fit={fit}\n tone=\"empty\"\n text={l.empty}\n action={emptyAction}\n testId={testId && `${testId}-empty`}\n />\n )\n } else if (body.kind === 'chart') {\n content = (\n <ChartRenderer\n model={body.model}\n height={fit ? 'fill' : undefined}\n ariaLabel={title}\n labels={l}\n testId={testId && `${testId}-chart`}\n />\n )\n } else if (body.kind === 'groups') {\n content = <ChartTable model={body.model} caption={title} fill={fit} />\n } else {\n content = (\n <RecordsTable\n fit={fit}\n fields={body.fields}\n rows={body.rows}\n maxRows={maxRows}\n l={l}\n formatters={formatters}\n testId={testId}\n />\n )\n }\n\n const header = (\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0\">\n <h3 className=\"truncate text-sm font-semibold text-foreground\">{title}</h3>\n {description && <p className=\"mt-0.5 text-xs text-muted-foreground\">{description}</p>}\n </div>\n {actions && <div className=\"flex shrink-0 gap-1\">{actions}</div>}\n </div>\n )\n if (variant === 'plain') {\n return (\n <section\n className={cn('flex min-w-0 flex-col gap-3', className)}\n data-slot=\"dashboard-panel\"\n data-testid={testId}\n aria-busy={state === 'loading' || undefined}\n >\n {header}\n <div className=\"min-w-0\">{content}</div>\n </section>\n )\n }\n return (\n <Card\n variant=\"elevated\"\n className={cn(\n 'flex h-full min-w-0 flex-col gap-3 rounded-xl p-5',\n fit && 'overflow-hidden',\n className\n )}\n data-slot=\"dashboard-panel\"\n data-testid={testId}\n aria-busy={state === 'loading' || undefined}\n >\n {header}\n <div className={cn('min-w-0 flex-1', fit && 'min-h-0')}>{content}</div>\n </Card>\n )\n}\n","/**\n * How storage kinds read to people. A document's objects come as `document` (its current file), `version`\n * (earlier versions' files) and `derived` (previews, thumbnails, search index files), plus `coedit` (live\n * editing state); everything a person stores outside a project's workspaces is billed to their personal project.\n */\n\nimport { formatFileSize } from '@arbidocs/sdk/browser'\nimport type { StorageItem, StorageKindUsage } from '@arbidocs/react'\n\nexport const KIND_LABELS: Record<string, string> = {\n document: 'Documents',\n version: 'Earlier versions',\n derived: 'Previews & processing',\n coedit: 'Editing state',\n mail: 'Mail',\n mail_draft: 'Mail drafts',\n chat_attachment: 'Chat attachments',\n recording: 'Call recordings',\n other: 'Other',\n}\n\n/** One item's kind, singular (\"Document\", \"Email\", …). */\nexport const ITEM_LABELS: Record<string, string> = {\n document: 'Document',\n mail: 'Email',\n mail_draft: 'Mail draft',\n chat_attachment: 'Chat attachment',\n recording: 'Call recording',\n other: 'Other file',\n}\n\nexport const MAIL_FOLDER_LABELS: Record<string, string> = {\n inbox: 'Inbox',\n sent: 'Sent',\n outbox: 'Outbox',\n drafts: 'Drafts',\n archive: 'Archive',\n trash: 'Trash',\n}\n\nexport const formatBytes = (bytes: number | null | undefined) => formatFileSize(bytes ?? 0)\n\n/** \"1.2 GB of 5.0 GB\" — or just the used part when there is no limit. */\nexport function usedOfLimit(bytes: number, limit: number | null | undefined): string {\n return limit ? `${formatBytes(bytes)} of ${formatBytes(limit)}` : `${formatBytes(bytes)} used`\n}\n\nexport function usedPct(bytes: number, limit: number | null | undefined): number {\n return limit ? (bytes / limit) * 100 : 0\n}\n\nexport interface KindRow {\n kind: string\n label: string\n bytes: number\n trashBytes: number\n}\n\n/** A project's kinds, largest first, each labelled. */\nexport function kindRows(kinds: StorageKindUsage[]): KindRow[] {\n return [...kinds]\n .filter((k) => k.bytes > 0)\n .sort((a, b) => b.bytes - a.bytes)\n .map((k) => ({\n kind: k.kind,\n label: KIND_LABELS[k.kind] ?? k.kind,\n bytes: k.bytes,\n trashBytes: k.trash_bytes,\n }))\n}\n\n/** Deletion keeps things in Recently deleted (in archive storage, counted at 10%) until the monthly purge. */\nexport const RECENTLY_DELETED_NOTE =\n 'Deleted items stay in Recently deleted, counted at 10% of their size, until they are removed for good 30–60 days later.'\n\n/** \"Archived and Recently deleted count at 10% of their size.\" — the server's reduced rate. */\nexport function reducedRateNote(rate: number): string {\n return `Archived workspaces and Recently deleted count at ${Math.round(rate * 100)}% of their size.`\n}\n\nexport interface StorageItemRow {\n item: StorageItem\n /** A document's decrypted name (when its workspace's key is available), else undefined. */\n name?: string\n}\n\n/** What an item is called: its name when known, else what it is and where. */\nexport function itemTitle({ item, name }: StorageItemRow): string {\n if (name) return name\n if (item.kind === 'mail') {\n return `Email in ${MAIL_FOLDER_LABELS[item.folder ?? ''] ?? item.folder ?? 'Mail'}`\n }\n return ITEM_LABELS[item.kind] ?? item.kind\n}\n","/**\n * `DashboardPanel`: one panel of a dashboard, from its `PanelSpec`. It looks its source up in the\n * host's registry (`useDataSources`), reads the dataset the spec asks for (`usePanelDataset`:\n * grouped and measured by the source) and shows it through `PanelView`.\n */\nimport { useEffect, useMemo, type ReactNode } from 'react'\nimport {\n formatGbp,\n useArbiSessionState,\n useDataSources,\n usePanelDataset,\n type DataSource,\n type PanelSpec,\n} from '@arbidocs/react'\nimport { Button } from '@arbidocs/react/ui'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { formatBytes } from '../storage/storage-labels'\nimport {\n chartModelOf,\n DEFAULT_UNIT_FORMATTERS,\n formatterOf,\n metricValueOf,\n type DrawnChartType,\n type UnitFormatters,\n} from '../../dashboards/chartModel'\nimport { preloadChartRenderer } from '../../dashboards/ChartRenderer'\nimport { PanelView, type PanelBody, type PanelViewLabels } from '../../dashboards/PanelView'\n\n/** The package's formatters: the one £ formatter for AI usage, and file sizes. */\nexport const PANEL_FORMATTERS: UnitFormatters = {\n ...DEFAULT_UNIT_FORMATTERS,\n gbp: (v) => formatGbp(v),\n bytes: (v) => formatBytes(v),\n}\n\nexport interface DashboardPanelLabels extends PanelViewLabels {\n /** A panel whose source the host does not offer. */\n unknownSource: (id: string) => string\n /** The empty state's link to the databases (where data is created or imported). */\n openDatabases: string\n /** A panel over workspace data (documents, threads…) while no workspace is open. */\n noWorkspace: string\n}\n\nexport const DEFAULT_DASHBOARD_PANEL_LABELS: Partial<DashboardPanelLabels> = {\n unknownSource: (id) => `This panel reads “${id}”, which is not available here.`,\n openDatabases: 'Open databases',\n noWorkspace: 'Open a workspace to see this.',\n}\n\nexport interface DashboardPanelProps {\n panel: PanelSpec\n /** Buttons in the panel's corner (a dashboard being edited). */\n actions?: ReactNode\n /** Don't read data (an editor showing the panel's frame only). */\n enabled?: boolean\n /** `plain`: no card around it (a chart placed in a page). */\n variant?: 'card' | 'plain'\n /** Fit the box it is given (a page's tile): see `PanelView`'s `fit`. */\n fit?: boolean\n formatters?: UnitFormatters\n labels?: Partial<DashboardPanelLabels>\n className?: string\n testId?: string\n}\n\nconst DRAWN = new Set(['bar', 'line', 'area', 'pie', 'donut', 'scatter'])\n\nfunction kindOf(panel: PanelSpec): 'metric' | 'chart' | 'table' {\n return panel.chart.type === 'metric' ? 'metric' : panel.chart.type === 'table' ? 'table' : 'chart'\n}\n\nfunction SourcePanel({\n source,\n panel,\n actions,\n enabled,\n variant,\n fit,\n formatters,\n labels,\n className,\n testId,\n}: DashboardPanelProps & { source: DataSource; labels: Partial<DashboardPanelLabels> }) {\n const environment = useBlocksEnvironment()\n const { chart } = panel\n // A drawn chart fetches its drawing code while its data loads, not after.\n const drawn = DRAWN.has(chart.type) && enabled !== false\n useEffect(() => {\n if (drawn) preloadChartRenderer()\n }, [drawn])\n const { dataset, fields, isLoading, error } = usePanelDataset(\n source,\n panel.source.params,\n chart,\n { enabled }\n )\n const body = useMemo((): PanelBody | undefined => {\n if (!dataset) return undefined\n const other = labels.other\n if (chart.type === 'metric') {\n const valueField = dataset.fields.find((f) => f.id === 'value')\n // Nothing matched: a count or a sum of nothing is 0; an average of nothing has no value.\n const op = chart.aggregate ?? 'count'\n return {\n kind: 'metric',\n value: metricValueOf(dataset) ?? (op === 'count' || op === 'sum' ? 0 : null),\n format: formatterOf(valueField, formatters),\n }\n }\n if (DRAWN.has(chart.type)) {\n return {\n kind: 'chart',\n model: chartModelOf({ ...chart, type: chart.type as DrawnChartType }, dataset, {\n fields,\n formatters,\n otherLabel: other,\n }),\n }\n }\n if (chart.x) {\n return {\n kind: 'groups',\n model: chartModelOf({ ...chart, type: 'bar' }, dataset, {\n fields,\n formatters,\n otherLabel: other,\n }),\n }\n }\n const shown = chart.columns?.length\n ? chart.columns.flatMap((id) => dataset.fields.filter((f) => f.id === id))\n : dataset.fields\n return { kind: 'records', fields: shown, rows: dataset.rows }\n }, [dataset, chart, fields, formatters, labels.other])\n\n const state = error\n ? 'error'\n : !dataset\n ? isLoading\n ? 'loading'\n : 'empty'\n : chart.type !== 'metric' && dataset.rows.length === 0\n ? 'empty'\n : 'ready'\n\n const emptyAction =\n source.id === 'database' && environment.openDatabases ? (\n <Button variant=\"outline\" size=\"sm\" onClick={() => environment.openDatabases?.()}>\n {labels.openDatabases}\n </Button>\n ) : undefined\n\n return (\n <PanelView\n kind={kindOf(panel)}\n title={panel.title}\n description={panel.description}\n state={state}\n body={body}\n errorDetail={error instanceof Error ? error.message : undefined}\n emptyAction={emptyAction}\n actions={actions}\n variant={variant}\n fit={fit}\n formatters={formatters}\n labels={labels}\n className={className}\n testId={testId}\n />\n )\n}\n\nexport function DashboardPanel({\n formatters = PANEL_FORMATTERS,\n labels,\n ...props\n}: DashboardPanelProps) {\n const registry = useDataSources()\n const l = { ...DEFAULT_DASHBOARD_PANEL_LABELS, ...labels }\n const source = registry.get(props.panel.source.id)\n const workspaceId = useArbiSessionState((s) => s.workspaceId)\n const scope =\n typeof source?.scope === 'function'\n ? source.scope(props.panel.source.params ?? {})\n : source?.scope\n if (scope === 'workspace' && !workspaceId) {\n return (\n <PanelView\n kind={kindOf(props.panel)}\n title={props.panel.title}\n state=\"empty\"\n actions={props.actions}\n labels={{ ...l, empty: l.noWorkspace ?? l.empty }}\n variant={props.variant}\n fit={props.fit}\n className={props.className}\n testId={props.testId}\n />\n )\n }\n if (!source) {\n return (\n <PanelView\n kind={kindOf(props.panel)}\n title={props.panel.title}\n state=\"error\"\n errorDetail={l.unknownSource?.(props.panel.source.id)}\n actions={props.actions}\n labels={l}\n fit={props.fit}\n className={props.className}\n testId={props.testId}\n />\n )\n }\n // Keyed by source: a source's hooks differ from another's, so a new source mounts afresh.\n return (\n <SourcePanel key={source.id} source={source} formatters={formatters} labels={l} {...props} />\n )\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var chunkE5TPRRAW_cjs = require('./chunk-E5TPRRAW.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkJEHGTPS2_cjs = require('./chunk-JEHGTPS2.cjs');
|
|
6
6
|
var chunkNZNBJF3M_cjs = require('./chunk-NZNBJF3M.cjs');
|
|
7
7
|
var chunk3YZKDCWY_cjs = require('./chunk-3YZKDCWY.cjs');
|
|
8
8
|
var react = require('@arbidocs/react');
|
|
@@ -355,7 +355,7 @@ function planBadgeView(project) {
|
|
|
355
355
|
}
|
|
356
356
|
function projectGroupBilling(project, { isOwned, stripeEnabled }) {
|
|
357
357
|
if (!project) return {};
|
|
358
|
-
const planBadge = isOwned && stripeEnabled ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
358
|
+
const planBadge = isOwned && stripeEnabled ? /* @__PURE__ */ jsxRuntime.jsx(chunkJEHGTPS2_cjs.PlanBadge, { ...planBadgeView(project) }) : void 0;
|
|
359
359
|
const quotaItems = project.quotas ? getQuotaItems(project.quotas) : [];
|
|
360
360
|
const readout = project.quotas ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
361
361
|
chunkE5TPRRAW_cjs.ProjectReadout,
|
|
@@ -365,7 +365,7 @@ function projectGroupBilling(project, { isOwned, stripeEnabled }) {
|
|
|
365
365
|
testId: `project-usage-${project.external_id}`,
|
|
366
366
|
// Bare numbers without plans for sale: a glance beside the name, not the Plan & Usage detail.
|
|
367
367
|
node: /* @__PURE__ */ jsxRuntime.jsx(
|
|
368
|
-
|
|
368
|
+
chunkJEHGTPS2_cjs.QuotaMeter,
|
|
369
369
|
{
|
|
370
370
|
items: quotaItems,
|
|
371
371
|
size: "sm",
|
|
@@ -449,5 +449,5 @@ exports.totalWithTaxWord = totalWithTaxWord;
|
|
|
449
449
|
exports.useBillingSupport = useBillingSupport;
|
|
450
450
|
exports.useRewardBalance = useRewardBalance;
|
|
451
451
|
exports.useSelfExtId = useSelfExtId;
|
|
452
|
-
//# sourceMappingURL=chunk-
|
|
453
|
-
//# sourceMappingURL=chunk-
|
|
452
|
+
//# sourceMappingURL=chunk-6AFAYGJW.cjs.map
|
|
453
|
+
//# sourceMappingURL=chunk-6AFAYGJW.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/billing/reward-balance.ts","../src/connection/billing/support.ts","../src/connection/billing/addon-pricing.ts","../src/connection/billing/plan-constants.ts","../src/connection/billing/quota-items.ts","../src/connection/billing/api-error.ts","../src/connection/billing/tax-quote.ts","../src/connection/billing/plan-pricing.ts","../src/connection/billing/plan-badge.ts","../src/connection/workspace-list/projectBilling.tsx"],"names":["useUserSettings","useHost","useArbi","formatGbp","PoundSterling","HardDrive","Users","gbp","jsx","PlanBadge","ProjectReadout","QuotaMeter","ProjectBreakdown","UsageMeter"],"mappings":";;;;;;;;;;AAoBO,SAAS,gBAAA,GAAyC;AACvD,EAAA,MAAM,EAAE,IAAA,EAAK,GAAIA,sBAAgB,EAAE,cAAA,EAAgB,UAAU,CAAA;AAE7D,EAAA,MAAM,KAAK,IAAA,EAAM,cAAA;AACjB,EAAA,IAAI,CAAC,MAAM,CAAC,EAAA,CAAG,UAAU,EAAA,CAAG,MAAA,IAAU,GAAG,OAAO,IAAA;AAChD,EAAA,OAAO,EAAE,MAAA,EAAQ,EAAA,CAAG,QAAQ,QAAA,EAAU,EAAA,CAAG,YAAY,KAAA,EAAM;AAC7D;AAGO,SAAS,WAAA,CAAY,KAAA,EAAe,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ACd,KAAA,EAAO,SAAA;AAAA,MACP,MAAA,EACE,OAAA,GACI,UAAA,CAAW,GAAA,CAAI,CAAC,EAAE,GAAA,EAAK,IAAA,EAAM,KAAA,EAAO,WAAA,EAAa,GAAA,EAAI,qBACnDJ,cAAA;AAAA,QAACK,4BAAA;AAAA,QAAA;AAAA,UAEC,IAAA;AAAA,UACA,KAAA;AAAA,UACA,KAAA,EAAO,WAAA;AAAA,UACP;AAAA,SAAA;AAAA,QAJK;AAAA,OAMR,CAAA,GACD,MAAA;AAAA,MAEN,QAAA,EAAU;AAAA,QACR,KAAA,EAAO,WAAA;AAAA,QACP,KAAA,EACE,QAAQ,kBAAA,IAAsB,IAAA,GAC1B,aACA,OAAA,CAAQ,kBAAA,CAAmB,eAAe,OAAO;AAAA;AACzD;AAAA,GACF;AAEF,EAAA,OAAO,EAAE,SAAA,EAAW,OAAA,EAAS,SAAA,EAAU;AACzC","file":"chunk-EG3DPKXM.cjs","sourcesContent":["/**\n * Reward-balance logic (hook + money formatter).\n *\n * A user's reward balance is their available account balance — a single GLOBAL per-user\n * number, the Stripe customer account balance mirrored read-only into\n * `settings.extra_discount`. It auto-applies to the user's NEXT invoice.\n *\n * \"Rewards\" is the broad concept: the balance can be fed by several sources (referral\n * reward is just one). The referral pricing surfaces of the billing kit\n * speak to the referral source specifically; this module owns the balance itself.\n */\n\nimport { useUserSettings } from '@arbidocs/react'\n\nexport interface RewardBalance {\n amount: number // minor units (e.g. pennies) of available account balance\n currency: string\n}\n\n/** The user's available reward balance (all sources), or null if none. */\nexport function useRewardBalance(): RewardBalance | null {\n const { data } = useUserSettings({ refetchOnMount: 'always' })\n // Backend mirrors this read-only as { amount, currency }; schema types it as a loose object.\n const ed = data?.extra_discount as { amount?: number; currency?: string } | null | undefined\n if (!ed || !ed.amount || ed.amount <= 0) return null\n return { amount: ed.amount, currency: ed.currency || 'gbp' }\n}\n\n/** Format minor units as a localized money string, e.g. `£20` (whole) or `£29.99`. */\nexport function formatMoney(cents: number, currency = 'gbp'): string {\n const value = cents / 100\n const isWhole = Number.isInteger(value)\n const c = currency.toLowerCase()\n const symbol =\n c === 'usd' ? '$' : c === 'gbp' ? '£' : c === 'eur' ? '€' : currency.toUpperCase() + ' '\n return `${symbol}${value.toLocaleString('en-US', {\n minimumFractionDigits: isWhole ? 0 : 2,\n maximumFractionDigits: isWhole ? 0 : 2,\n })}`\n}\n","/**\n * What a host adds to the billing kit. Selling plans needs Stripe, which stays the host's: whether\n * this deployment sells plans (a publishable key is configured), and its embedded checkout. It is the\n * host configuration's `billing`; without it nothing is for sale: projects show their limits and\n * usage only.\n */\nimport type { ReactNode } from 'react'\nimport { useArbi } from '@arbidocs/react'\nimport { useHost } from '../../provider/host'\n\nexport interface BillingCheckoutSupport {\n /** Load the host's Stripe (lazily, when a checkout opens); `null` when it cannot. */\n load(): Promise<unknown> | null\n /** Stripe's embedded checkout for a session, on the loaded Stripe. */\n render(stripe: unknown, session: { clientSecret: string; onComplete: () => void }): ReactNode\n}\n\nexport interface BillingSupport {\n /** This deployment sells plans (Stripe is configured). */\n stripeEnabled: boolean\n checkout?: BillingCheckoutSupport\n}\n\nconst NOT_FOR_SALE: BillingSupport = { stripeEnabled: false }\n\nexport function useBillingSupport(): BillingSupport {\n return useHost().billing ?? NOT_FOR_SALE\n}\n\n/** The signed-in user's id (`usr-…`), to tell the projects they own from the others. */\nexport function useSelfExtId(): string | undefined {\n const arbi = useArbi()\n return arbi.isLoggedIn ? (arbi.user.identity()?.externalId ?? undefined) : undefined\n}\n","/** Add-on block price helpers (VAT-inclusive pence from `project.addons`). */\n\nimport { formatGbp } from '@arbidocs/react'\nimport type { components } from '@arbidocs/client'\nimport type { AddonKind } from './useAddonPurchase'\nimport { formatMoney } from './reward-balance'\n\ntype ProjectAddons = components['schemas']['ProjectAddons']\n\nconst gbp = (pence: number) => formatMoney(pence, 'gbp')\n\n/** \"3 Nov 2026\". */\nexport function formatPeriodEnd(unix: number | null | undefined): string | null {\n if (!unix) return null\n return new Date(unix * 1000).toLocaleDateString('en-GB', {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n })\n}\n\n/** What one more block of this kind costs right now, incl. UK VAT. */\nexport function addonPricePence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage' ? addons.ai_block_price_pence : addons.storage_block_price_pence\n}\n\n/** The same price ex VAT. */\nfunction addonPriceExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_price_ex_vat_pence\n : addons.storage_block_price_ex_vat_pence\n}\n\n/**\n * The PUT /addons/settings body (the monthly usage cap and the automatic add-on trigger) from the current add-on\n * state with the given changes applied.\n */\nexport function addonSettingsBody(\n addons: ProjectAddons,\n change: Partial<{\n spend_cap_pence: number | null\n auto_topup_threshold_gbp: number\n }> = {}\n) {\n return {\n spend_cap_pence: addons.spend_cap_pence ?? null,\n auto_topup_threshold_gbp: addons.auto_topup_threshold_gbp,\n ...change,\n }\n}\n\n/**\n * Of `count` blocks of a kind, how many are on an earlier catalogue's price (legacy, at their old size: £10 of AI\n * usage or 10 GB) and how many on today's. A reduction removes today's blocks first, so the legacy ones are the\n * last kept.\n */\nexport function splitBlocks(\n kind: AddonKind,\n count: number,\n addons: ProjectAddons\n): { legacy: number; current: number } {\n const granted =\n (kind === 'ai_usage' ? addons.legacy_ai_blocks : addons.legacy_storage_blocks) ?? 0\n const legacy = Math.max(0, Math.min(granted, count))\n return { legacy, current: count - legacy }\n}\n\n/** One block's size: \"£20 of AI credits\" / \"20 GB\" (legacy: \"£10\" / \"10 GB\"). */\nfunction blockSize(kind: AddonKind, addons: ProjectAddons, legacy: boolean): string {\n if (kind === 'ai_usage') {\n return formatGbp(legacy ? (addons.legacy_block_ai_gbp ?? 10) : addons.block_ai_gbp)\n }\n return `${legacy ? (addons.legacy_block_storage_gb ?? 10) : addons.block_storage_gb} GB`\n}\n\n/**\n * \"2 × £20 of AI credits\", \"1 × £10 + 1 × £20 of AI credits\", \"1 × 10 GB + 2 × 20 GB\": `count` blocks of a kind, the\n * legacy ones (kept last on a reduction) at their old size.\n */\nexport function blocksLabel(kind: AddonKind, count: number, addons: ProjectAddons): string {\n const { legacy, current } = splitBlocks(kind, count, addons)\n const parts = [\n ...(legacy > 0 ? [`${legacy} × ${blockSize(kind, addons, true)}`] : []),\n ...(current > 0 || legacy === 0 ? [`${current} × ${blockSize(kind, addons, false)}`] : []),\n ]\n return `${parts.join(' + ')}${kind === 'ai_usage' ? ' of AI credits' : ''}`\n}\n\n/**\n * Bounds for \"Reduce from next period\": keep `min`..`current` blocks. `next` is what renews\n * now (a pending reduction, or the current count). Storage can't go below what usage needs.\n */\nexport function reduceBounds(\n kind: AddonKind,\n addons: ProjectAddons\n): { min: number; current: number; next: number } {\n const current = kind === 'ai_usage' ? addons.ai_blocks : addons.storage_blocks\n const pending = kind === 'ai_usage' ? addons.ai_blocks_next : addons.storage_blocks_next\n const min = 0\n return { min, current, next: pending ?? current }\n}\n\n/** One block's monthly-equivalent price ex VAT: AI credits and storage are priced separately. */\nfunction blockMonthlyExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_monthly_ex_vat_pence\n : addons.storage_block_monthly_ex_vat_pence\n}\n\n/** What one block renews at per billing period, ex VAT (annual: 12 × the monthly price). */\nfunction blockPeriodExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_period_ex_vat_pence\n : addons.storage_block_period_ex_vat_pence\n}\n\n/** What one add-on renews at: \"£20/month ex VAT\" or \"£180/year ex VAT\". */\nfunction blockRenewalShort(kind: AddonKind, addons: ProjectAddons, isAnnual: boolean): string {\n return `${gbp(blockPeriodExVatPence(kind, addons))}/${isAnnual ? 'year' : 'month'} ex VAT`\n}\n\n/** The extra line annual subscriptions show beside an AI credits add-on or upgrade price. */\nexport const ANNUAL_PREMIUM_AI_NOTE = 'No markup on Premium AI on annual subscriptions'\n\n/** The confirm dialog's figures: charged now (incl. / ex VAT), what it covers until, then what renews. */\nexport function addonCharge(\n kind: AddonKind,\n addons: ProjectAddons,\n isAnnual: boolean,\n periodEnd: number | null | undefined\n): { now: string; nowExVat: string; nowVat: string; until: string | null; then: string } {\n return {\n now: gbp(addonPricePence(kind, addons)),\n nowExVat: gbp(addonPriceExVatPence(kind, addons)),\n nowVat: gbp(addonPricePence(kind, addons) - addonPriceExVatPence(kind, addons)),\n until: isAnnual ? formatPeriodEnd(periodEnd) : null,\n then: blockRenewalShort(kind, addons, isAnnual),\n }\n}\n\n/** Why automatic top-ups stopped (one line; the price of a step is on the Add button). */\nexport const CAP_REACHED_MESSAGE = 'Usage cap reached: no more automatic top-ups this month.'\n\n/** The £0 usage cap: no automatic top-ups (adding by hand still works). */\nexport const ZERO_BUDGET_MESSAGE = 'Automatic top-ups are off (£0 usage cap).'\n\n/** The usage cap's heading wherever it is edited or shown. */\nexport const USAGE_CAP_LABEL = 'Auto-upgrade limit'\n\n/** Automatic-upgrade spending is separate from explicitly selected allowances. */\nexport const USAGE_CAP_HELP =\n 'Your auto-upgrade limit covers extra monthly spend beyond your selected subscription and add-ons. ' +\n '£0 turns automatic upgrades off. You can adjust usage add-ons with + and −. ' +\n 'Additions show the charge before you confirm; reductions apply next billing period, ' +\n 'provided your storage and collaborators fit. Prices are ex VAT.'\n\n/** A £0 cap turns automatic top-ups off (manual adds still work). */\nexport function isAddonBudgetZero(addons: Pick<ProjectAddons, 'spend_cap_pence'>): boolean {\n return addons.spend_cap_pence === 0\n}\n\n/**\n * How much more of a resource automatic top-ups may add this month before the usage cap stops them, in the\n * resource's unit (£ of AI credits / GB): the whole blocks the cap left pays for at today's ex-VAT price. `null` =\n * no limit; 0 with a £0 cap or when not even one block fits.\n */\nexport function autoRoom(kind: AddonKind, addons: ProjectAddons): number | null {\n const left = addons.cap_left_pence\n if (left == null) return addons.spend_cap_pence === 0 ? 0 : null\n const price = blockMonthlyExVatPence(kind, addons)\n if (price <= 0) return 0\n const blocks = Math.floor(left / price)\n return blocks * (kind === 'ai_usage' ? addons.block_ai_gbp : addons.block_storage_gb)\n}\n\n/** The size of the block a one-step reduction removes from what renews (today's blocks go first). */\nexport function nextRemovedBlockSize(kind: AddonKind, addons: ProjectAddons): number {\n const { next } = reduceBounds(kind, addons)\n const { current } = splitBlocks(kind, next, addons)\n if (kind === 'ai_usage') {\n return current > 0 ? addons.block_ai_gbp : (addons.legacy_block_ai_gbp ?? 10)\n }\n return current > 0 ? addons.block_storage_gb : (addons.legacy_block_storage_gb ?? 10)\n}\n\n/**\n * Pounds typed into a usage cap field → pence. '' → the default (null); invalid → undefined.\n * Equal to the default is also sent as null (\"keep the default\").\n */\nexport function parseBudgetPounds(value: string): number | null | undefined {\n if (value.trim() === '') return null\n const n = Number(value)\n if (!Number.isFinite(n) || n < 0) return undefined\n return Math.round(n * 100)\n}\n\n/** Toast after saving the usage cap. */\nexport function budgetSavedMessage(capPence: number | null): string {\n if (capPence == null) return 'Usage cap: no limit'\n if (capPence === 0) return 'Usage cap: £0 (no automatic top-ups)'\n return `Usage cap: ${gbp(capPence)} a month`\n}\n\nconst gbText = (n: number) => `${Math.round(n * 10) / 10} GB`\n\n/** \"£20 of AI credits\" / \"20 GB\". */\nexport function stepLabel(kind: AddonKind, size: number): string {\n return kind === 'ai_usage' ? `${formatGbp(size)} of AI credits` : gbText(size)\n}\n\n/** The PUT /addons/next-period body that renews `keep` blocks of `kind` (the other kind unchanged). */\nexport function nextPeriodBody(kind: AddonKind, keep: number) {\n return kind === 'ai_usage'\n ? { ai_blocks: keep, storage_blocks: null }\n : { ai_blocks: null, storage_blocks: keep }\n}\n\n/**\n * The \"+\" step's price line, ex VAT: \"£20/month · today £20\" (annual: \"£15/month · today £150\");\n * storage, charged for the rest of the period: \"£20/month · prorated today £8.33\".\n */\nexport function addStepCaption(kind: AddonKind, addons: ProjectAddons): string {\n const now = gbp(addonPriceExVatPence(kind, addons))\n const today = kind === 'storage' ? `prorated today ${now}` : `today ${now}`\n return `${gbp(blockMonthlyExVatPence(kind, addons))}/month · ${today}`\n}\n","/** Pro's allowance per month (one licence) — must match the backend. Legacy multi-pack plans get it per pack.\n * The live numbers for an existing project come from `project.addons`; these are only for\n * describing the plan before a project exists (new-project dialog, upgrade picker). */\nexport const PRO_AI_GBP = 10\nexport const PRO_STORAGE_GB = 5\nexport const PRO_COLLABORATORS = 1\nexport const COLLABORATOR_BLOCK_SIZE = 5\n\n/**\n * Add-on block sizes (£20 of AI credits or 20 GB), the same on every plan. Their prices come from the\n * products API (`addon_prices`) before a project exists, and from `project.addons` after.\n */\nexport const ADDON_BLOCK_AI_GBP = 20\nexport const STORAGE_BLOCK_GB = 20\n\n/** Default monthly usage cap for a new Pro project (pence); it limits automatic top-ups only. 0 = no automatic\n * top-ups, null = no limit. */\nexport const DEFAULT_SPEND_CAP_PENCE = 10000\n\n/** The automatic add-on triggers when less than this much AI credits (£) remains; the backend minimum. */\nexport const MIN_AUTO_TOPUP_THRESHOLD_GBP = 1\n\n/** Free-tier quotas — must match backend FREE_* constants in src/constants.py\n * (FREE_AI_GBP=1, FREE_STORAGE_GB=0.05 → 50 MB, FREE_COLLABORATORS=0). */\nexport const FREE_AI_GBP = 1\nexport const FREE_STORAGE_MB = 50\nexport const FREE_COLLABORATORS = 0\n\n/** Collaborator limits at or above this are \"unlimited\" (the backend reports 999 for dev). */\nexport const UNLIMITED_COLLABORATORS = 999\n\n/**\n * Suggested initial daily per-user AI credits cap (£), pre-filled when creating\n * a new project. The user can clear it to create a project with no cap.\n * Backend treats null as \"no enforcement\" — there is no server-side default.\n */\nexport const SUGGESTED_DAILY_CAP_PER_USER = 10\n","/**\n * Quota display — single source of truth.\n *\n * Builds the icon / label / formatted used-of-limit strings for a project's\n * quotas (AI credits in £, storage, collaborators). Shared by QuotaBadges and the\n * project tooltip so the numbers and units can never disagree (storage in GB on\n * plans of 1 GB or more, MB below).\n */\n\nimport { HardDrive, PoundSterling, Users } from 'lucide-react'\nimport { formatGbp } from '@arbidocs/react'\nimport type { QuotaMeterItem } from '../../settings'\nimport type { components } from '@arbidocs/client'\nimport { UNLIMITED_COLLABORATORS } from './plan-constants'\n\ntype Quotas = components['schemas']['ProjectResponse']['quotas']\n\nconst fmt = (v: number) => Math.round(v).toLocaleString('en-US')\n\n/** \"May 31, 2025\" — the one format every AI-usage-reset mention uses. */\nexport function formatResetDate(unixTimestamp: number | null | undefined): string | null {\n if (!unixTimestamp) return null\n const date = new Date(unixTimestamp * 1000)\n return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })\n}\n\n/**\n * When the project's AI credits allowance next resets, as a unix timestamp.\n * Pro projects report it directly (`addons.ai_usage_reset_at` — monthly, even on an\n * annual plan); monthly subscriptions otherwise reset with the billing period\n * (`current_period_end`); free projects reset on the backend-stamped signup\n * anniversary (`quotas.budget_reset_at`). Only a FUTURE date is returned — a stale\n * past stamp would read as a bug, not a promise.\n */\nexport function aiUsageResetTimestamp(project: {\n quotas?: { budget_reset_at?: number | null } | null\n current_period_end?: number | null\n plan_interval?: string | null\n addons?: { ai_usage_reset_at?: number | null } | null\n}): number | null {\n // An annual period end is a year away — never a monthly AI credits reset.\n const periodEnd = project.plan_interval === 'year' ? null : project.current_period_end\n const ts =\n project.addons?.ai_usage_reset_at ?? periodEnd ?? project.quotas?.budget_reset_at ?? null\n return ts && ts * 1000 > Date.now() ? ts : null\n}\n\n// Defensive: a quota field may be missing on partial/empty payloads — treat it\n// as 0 / 0 rather than crashing the whole row.\nconst quota = (q?: { used?: number; limit?: number }) => ({\n used: q?.used ?? 0,\n limit: q?.limit ?? 0,\n})\n/** GB from 1 GB plans up (\"2.4 GB\", \"5 GB\"), MB below (\"50 MB\"); `unit: false` drops the unit. */\nfunction storageText(gbValue: number, limitGb: number, unit = true): string {\n if (limitGb >= 1) {\n const n = Math.round(gbValue * 10) / 10\n return `${n.toLocaleString('en-US')}${unit ? ' GB' : ''}`\n }\n return `${fmt(gbValue * 1000)}${unit ? ' MB' : ''}`\n}\nconst pctOf = (used: number, limit: number) => (limit > 0 ? (used / limit) * 100 : 0)\n\nexport function getQuotaItems(quotas: Quotas): QuotaMeterItem[] {\n const aiUsage = quota(quotas?.ai_usage)\n const storage = quota(quotas?.storage_gb)\n const collaborators = quota(quotas?.collaborators)\n const unlimitedCollaborators = collaborators.limit === UNLIMITED_COLLABORATORS\n return [\n {\n key: 'ai-usage',\n icon: PoundSterling,\n label: 'AI credits',\n used: formatGbp(aiUsage.used),\n usedOfLimit: `${formatGbp(aiUsage.used)} / ${formatGbp(aiUsage.limit)}`,\n pct: pctOf(aiUsage.used, aiUsage.limit),\n },\n {\n key: 'storage',\n icon: HardDrive,\n label: 'Storage',\n used: storageText(storage.used, storage.limit),\n usedOfLimit: `${storageText(storage.used, storage.limit, false)} / ${storageText(\n storage.limit,\n storage.limit\n )}`,\n pct: pctOf(storage.used, storage.limit),\n },\n {\n key: 'collaborators',\n icon: Users,\n label: 'Collaborators',\n used: fmt(collaborators.used),\n usedOfLimit: unlimitedCollaborators\n ? `${fmt(collaborators.used)} / Unlimited`\n : `${fmt(collaborators.used)} / ${fmt(collaborators.limit)}`,\n // Zero seats (Free) IS the cap: 0 / 0 shows a full destructive bar,\n // because you can't add anyone — the truth the upgrade door answers.\n // (Only when the quota is actually present; a missing field on a\n // partial payload stays an empty bar, not a false alarm.)\n pct: unlimitedCollaborators\n ? 0\n : quotas?.collaborators && collaborators.limit === 0\n ? 100\n : pctOf(collaborators.used, collaborators.limit),\n },\n ]\n}\n","/**\n * The `detail` of a refused billing call: the response body's `detail` (a string, or the\n * `{code, message}` of a payment refusal), whether the error is an SDK `ArbiApiError` (body in\n * `apiError`) or the body itself.\n */\nexport function apiErrorDetail(error: unknown): unknown {\n const body = (error as { apiError?: unknown } | null)?.apiError ?? error\n return (body as { detail?: unknown } | null)?.detail\n}\n","/**\n * Tax-inclusive totals from the backend's Stripe Tax quotes (`TaxQuoteResponse`, plan-change\n * previews, add-on quotes): \"£48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\", \"£40.00 · no VAT\n * (reverse charge)\", \"£40.00 · no tax\".\n */\n\nimport type { ProjectPlanQuoteResponse } from '@arbidocs/client'\nimport { apiErrorDetail } from './api-error'\n\nexport type TaxQuote = ProjectPlanQuoteResponse\n\n/** Countries whose tax depends on the postcode: the field is shown up front. */\nexport const POSTCODE_COUNTRIES: readonly string[] = ['US', 'CA']\n\n/** The quote error that asks for a ZIP / postal code. */\nexport const TAX_LOCATION_INVALID = 'TAX_LOCATION_INVALID'\n\n/** \"£42.00\" — always pence, so the parts of a total add up on screen. */\nexport function money2(pence: number, currency = 'gbp'): string {\n const symbol = { gbp: '£', usd: '$', eur: '€' }[currency.toLowerCase()] ?? `${currency} `\n return `${symbol}${(pence / 100).toLocaleString('en-GB', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })}`\n}\n\nexport interface TaxParts {\n subtotal: number\n tax: number\n total: number\n /** \"VAT 20%\"; null when no tax is due. */\n label?: string | null\n reverseCharge?: boolean\n}\n\n/** \"VAT\" for a VAT label, else \"tax\". */\nfunction taxKind(label: string | null | undefined): string {\n return /^vat\\b/i.test(label ?? '') ? 'VAT' : 'tax'\n}\n\n/** What follows the total: \"incl. VAT (£40.00 + £8.00 VAT 20%)\", \"· no VAT (reverse charge)\", \"· no tax\". */\nexport function taxDetail({ subtotal, tax, label, reverseCharge }: TaxParts): string {\n if (reverseCharge) return '· no VAT (reverse charge)'\n if (tax <= 0) return '· no tax'\n return `incl. ${taxKind(label)} (${money2(subtotal)} + ${money2(tax)} ${label ?? 'tax'})`\n}\n\n/** \"£48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\", \"£40.00 · no VAT (reverse charge)\", \"£40.00 · no tax\". */\nexport function taxSummary(parts: TaxParts): string {\n return `${money2(parts.total)} ${taxDetail(parts)}`\n}\n\n/** \"£21.00 incl. VAT\" / \"£17.50\" — a total with only the word for its tax. */\nexport function totalWithTaxWord({ total, tax, label }: TaxParts): string {\n return tax > 0 ? `${money2(total)} incl. ${taxKind(label)}` : money2(total)\n}\n\n/** The parts of a quote response. */\nexport function quoteParts(quote: TaxQuote): TaxParts {\n return {\n subtotal: quote.subtotal_pence,\n tax: quote.tax_pence,\n total: quote.total_pence,\n label: quote.tax_label,\n reverseCharge: quote.reverse_charge,\n }\n}\n\n/** \"Total today £48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\". */\nexport function quoteTotalLine(quote: TaxQuote): string {\n if (quote.tax_calculated === false) return `Total today ${money2(quote.total_pence)} ex VAT`\n return `Total today ${taxSummary(quoteParts(quote))}`\n}\n\n/** The API error code (`detail.code`) and message, if any. */\nexport function quoteError(error: unknown): { code?: string; message?: string } {\n const detail = apiErrorDetail(error)\n if (detail && typeof detail === 'object') {\n const { code, message } = detail as { code?: unknown; message?: unknown }\n return {\n code: typeof code === 'string' ? code : undefined,\n message: typeof message === 'string' ? message : undefined,\n }\n }\n return { message: typeof detail === 'string' ? detail : undefined }\n}\n","/**\n * Pro plan price helpers. Prices come from Stripe via GET /v1/user/products (source of truth).\n * One plan is sold: Pro, one licence (£10 of AI credits + 5 GB a month). Each price lists\n * `pack_prices` for that one licence — `amount` incl. UK VAT and `amount_ex_vat` — and\n * `addon_prices` (one add-on block on that interval). Display them as-is.\n * Legacy subscriptions with several packs keep working; their name and price come from the project.\n */\n\nimport type { components } from '@arbidocs/client'\nimport { formatGbp } from '@arbidocs/react'\nimport { formatMoney } from './reward-balance'\nimport { formatPeriodEnd } from './addon-pricing'\nimport { taxSummary } from './tax-quote'\n\ntype PlanChangePreview = components['schemas']['PlanChangePreview']\ntype ProductPrice = components['schemas']['ProductPrice']\ntype ProductResponse = components['schemas']['ProductResponse']\ntype PackPrice = components['schemas']['PackPrice']\ntype AddonPrice = components['schemas']['AddonPrice']\n\nexport type PlanInterval = 'month' | 'year'\n\nconst gbp = (pence: number) => formatMoney(pence, 'gbp')\n\n/** The headline price: \"£40 ex VAT\". */\nexport function plusVat(exVatPence: number, currency = 'gbp'): string {\n return `${formatMoney(exVatPence, currency)} ex VAT`\n}\n\n/** The one licence Pro sells. Other pack counts exist only on legacy subscriptions (displayed, not sold). */\nexport const PRO_PACKS = 1\n\n/** A plan the pickers offer. */\nexport type PlanChoice = 'free' | 'pro'\n\n/** Packs per plan choice (0 = Free). */\nexport const PLAN_CHOICE_PACKS: Record<PlanChoice, number> = {\n free: 0,\n pro: PRO_PACKS,\n}\n\n/** \"Free\" (0), \"Pro\" (1), otherwise \"Pro ×N\" (a legacy multi-pack plan; the API's own name wins). */\nexport function planNameForPacks(packs: number | null | undefined): string {\n const n = packs ?? 0\n if (n <= 0) return 'Free'\n if (n === PRO_PACKS) return 'Pro'\n return `Pro ×${n}`\n}\n\n/** The plan-change panel's fixed lines, each with a test id. */\nexport interface PlanChangeLine {\n id: 'pay-today' | 'from' | 'current-until' | 'no-change' | 'awaiting-bank'\n text: string\n}\n\n/**\n * What a plan change costs, from the backend's Stripe invoice preview (taxed for the customer's\n * address), as fixed lines:\n * - \"Pay today £42.00 incl. VAT (£35.00 + £7.00 VAT 20%)\" (\"Pay today £0\" for a change that waits)\n * - \"From 16 Nov 2026: £210.00 incl. VAT (£175.00 + £35.00 VAT 20%) a month\"\n * - \"Current subscription until 16 Nov 2026\" for a change that waits for the period end.\n * \"No change\" when the selection is what the project already has; \"Waiting for your bank\" while\n * an earlier upgrade payment awaits 3-D Secure.\n */\nexport function planPreviewLines(preview: PlanChangePreview): PlanChangeLine[] {\n if (preview.unchanged) return [{ id: 'no-change', text: 'No change' }]\n const date = formatPeriodEnd(preview.next_renewal_at)\n const cadence = preview.interval === 'year' ? 'year' : 'month'\n const lines: PlanChangeLine[] = [\n preview.awaiting_confirmation\n ? { id: 'awaiting-bank', text: 'Waiting for your bank' }\n : {\n id: 'pay-today',\n text: preview.effective_now\n ? `Pay today ${taxSummary({\n subtotal: preview.due_now_ex_vat_pence,\n tax: preview.due_now_tax_pence,\n total: preview.due_now_pence,\n label: preview.tax_label,\n })}`\n : `Pay today ${gbp(0)}`,\n },\n {\n id: 'from',\n text: `${date ? `From ${date}` : 'From renewal'}: ${taxSummary({\n subtotal: preview.next_renewal_ex_vat_pence,\n tax: preview.next_renewal_tax_pence,\n total: preview.next_renewal_pence,\n label: preview.tax_label,\n })} a ${cadence}`,\n },\n ]\n if (!preview.effective_now) {\n lines.push({ id: 'current-until', text: `Current subscription until ${date ?? 'renewal'}` })\n }\n return lines\n}\n\n/** Stand-in for \"Pay today\" when the preview failed for an upgrade. */\nexport const PAY_TODAY_UNPRICED = 'Pay today: the difference for the rest of this period'\n\n/** One add-on block's price on this interval's plan price (`addon_prices`), if listed. */\nexport function addonPrice(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): AddonPrice | undefined {\n return price?.addon_prices?.find((p) => p.kind === kind)\n}\n\n/** Per add-on block of `kind` per month, ex VAT (annual subscriptions: the monthly equivalent). */\nexport function addonMonthlyExVat(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): number | undefined {\n return addonPrice(price, kind)?.monthly_ex_vat\n}\n\n/** What a checkout buys: \"Pro\", \"Pro + 2 × £20 of AI credits + 1 × 20 GB\". */\nexport function checkoutItemsLabel(\n aiBlocks: number,\n storageBlocks: number,\n collaboratorBlocks = 0,\n price?: ProductPrice\n): string {\n const ai = addonPrice(price, 'ai_usage')?.ai_gbp\n const storage = addonPrice(price, 'storage')?.storage_gb\n const collaborators = price?.addon_prices?.find((p) => p.kind === 'collaborators')?.collaborators\n return [\n 'Pro',\n aiBlocks > 0 &&\n (ai != null\n ? `${aiBlocks} × ${formatGbp(ai)} of AI credits`\n : `${aiBlocks} AI credits add-ons`),\n storageBlocks > 0 &&\n (storage != null ? `${storageBlocks} × ${storage} GB` : `${storageBlocks} storage add-ons`),\n collaboratorBlocks > 0 &&\n (collaborators != null\n ? `${collaboratorBlocks * collaborators} extra collaborators`\n : `${collaboratorBlocks} collaborator add-ons`),\n ]\n .filter(Boolean)\n .join(' + ')\n}\n\n/** The price of `packs` packs on this interval's price, if Stripe lists it (only one licence is listed). */\nexport function packPrice(\n price: ProductPrice | undefined,\n packs: number = PRO_PACKS\n): PackPrice | undefined {\n return price?.pack_prices?.find((p) => p.packs === packs)\n}\n\nexport interface ProPrices {\n monthly?: ProductPrice\n annual?: ProductPrice\n}\n\n/** The Pro product's monthly and annual prices (default price per interval wins). */\nexport function findProPrices(products: ProductResponse[] | undefined): ProPrices {\n const prices = products?.[0]?.prices ?? []\n const pick = (interval: PlanInterval) =>\n prices.find((p) => p.interval === interval && p.default_price) ??\n prices.find((p) => p.interval === interval)\n return { monthly: pick('month'), annual: pick('year') }\n}\n\n/** Annual savings vs 12 × monthly, as a whole percent (e.g. £360 vs £480 → 25). */\nexport function calcSavingsPercent(\n monthlyPrice: ProductPrice | undefined,\n annualPrice: ProductPrice | undefined\n): number | null {\n const monthly = packPrice(monthlyPrice)?.amount ?? monthlyPrice?.amount\n const annual = packPrice(annualPrice)?.amount ?? annualPrice?.amount\n if (monthly == null || annual == null || monthly === 0) return null\n const savings = Math.round(((monthly * 12 - annual) / (monthly * 12)) * 100)\n return savings > 0 ? savings : null\n}\n\n/** Most add-on blocks of each kind a checkout may include (the backend's limit). */\nexport const MAX_CHECKOUT_BLOCKS = 100\n\n/** \"£20/month ex VAT each\", annual: \"£180/year ex VAT each\": one block on the chosen interval. */\nexport function checkoutBlockPriceText(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage'\n): string | null {\n const block = addonPrice(price, kind)\n if (!block) return null\n const currency = price?.currency ?? 'gbp'\n return price?.interval === 'year'\n ? `${formatMoney(block.amount_ex_vat, currency)}/year ex VAT each`\n : `${formatMoney(block.amount_ex_vat, currency)}/month ex VAT each`\n}\n","import type { PlanBadgeProps } from '../../settings'\nimport type { components } from '@arbidocs/client'\nimport { planNameForPacks } from './plan-pricing'\n\ntype ProjectBillingFields = Pick<\n components['schemas']['ProjectResponse'],\n 'subscription' | 'plan_interval'\n> &\n Partial<Pick<components['schemas']['ProjectResponse'], 'packs' | 'addons'>>\n\n/** A project is on Pro when it has a billing interval (null = Free or checkout pending). */\nexport function isProProject(project: Pick<ProjectBillingFields, 'plan_interval'>): boolean {\n return project.plan_interval != null\n}\n\n/** \"Pro\", or a legacy multi-pack plan's name (\"Pro ×N\") — the API's name when it sends one (owner view). */\nexport function proTierName(project: ProjectBillingFields): string {\n return project.addons?.plan_name || planNameForPacks(Math.max(project.packs ?? 1, 1))\n}\n\n/** \"Free\", \"Pro monthly\", \"Pro annual\", \"Pro ×3 monthly\" (legacy) or \"Dev\" — the full plan name. */\nexport function planName(project: ProjectBillingFields): string {\n if (project.subscription === 'dev') return 'Dev'\n if (project.subscription === 'suspended') return 'Subscription ended'\n if (!isProProject(project)) return 'Free'\n return `${proTierName(project)} ${project.plan_interval === 'year' ? 'annual' : 'monthly'}`\n}\n\n/**\n * Maps a project's billing state to the `PlanBadge` block's label + tone.\n * Pro reads as accent, Free/dev as neutral, payment trouble or cancelling as pending.\n */\nexport function planBadgeView(\n project: ProjectBillingFields\n): Pick<PlanBadgeProps, 'label' | 'tone'> {\n const { subscription } = project\n const label =\n subscription === 'suspended'\n ? 'Subscription ended'\n : subscription === 'canceled'\n ? 'Cancelling'\n : subscription === 'dev'\n ? 'Dev'\n : isProProject(project)\n ? proTierName(project)\n : 'Free'\n\n const tone =\n subscription === 'dev'\n ? 'dev'\n : subscription === 'suspended' || subscription === 'canceled' || subscription === 'past_due'\n ? 'pending'\n : isProProject(project)\n ? 'paid'\n : 'free'\n\n return { label, tone }\n}\n","/**\n * What a project's group in the workspace list says about the project itself: its plan badge (own\n * projects, where plans are sold), the usage readout beside its name, and the plan and limits\n * breakdown behind the name. One source for the cards' bands and the table's headings.\n */\nimport type { ReactNode } from 'react'\nimport type { LucideIcon } from 'lucide-react'\nimport type { components } from '@arbidocs/client'\nimport { UsageMeter } from '../../components/UsageMeter'\nimport { PlanBadge, QuotaMeter } from '../../settings'\nimport { ProjectBreakdown, ProjectReadout } from '../../home/ProjectBandParts'\nimport { planBadgeView } from '../billing/plan-badge'\nimport { getQuotaItems } from '../billing/quota-items'\n\ntype Project = components['schemas']['ProjectResponse']\n\nexport interface ProjectGroupBilling {\n /** The plan badge: own projects only, where plans are sold. */\n planBadge?: ReactNode\n /** Subscription and usage, right after the name (projects with quotas). */\n readout?: ReactNode\n /** The plan and limits panel behind the name; meters for own projects only. */\n breakdown?: ReactNode\n}\n\nexport function projectGroupBilling(\n project: Project | undefined,\n { isOwned, stripeEnabled }: { isOwned: boolean; stripeEnabled: boolean }\n): ProjectGroupBilling {\n if (!project) return {}\n const planBadge = isOwned && stripeEnabled ? <PlanBadge {...planBadgeView(project)} /> : undefined\n const quotaItems = project.quotas ? getQuotaItems(project.quotas) : []\n const readout = project.quotas ? (\n <ProjectReadout\n plan={\n planBadge ? { badge: planBadge, testId: `project-tier-${project.external_id}` } : undefined\n }\n usage={{\n testId: `project-usage-${project.external_id}`,\n // Bare numbers without plans for sale: a glance beside the name, not the Plan & Usage detail.\n node: (\n <QuotaMeter\n items={quotaItems}\n size=\"sm\"\n showTooltips={false}\n showBars={stripeEnabled}\n showPercent={false}\n />\n ),\n }}\n />\n ) : (\n planBadge\n )\n const breakdown = (\n <ProjectBreakdown\n name={project.name}\n badge={planBadge}\n meters={\n isOwned\n ? quotaItems.map(({ key, icon, label, usedOfLimit, pct }) => (\n <UsageMeter\n key={key}\n icon={icon as LucideIcon}\n label={label}\n value={usedOfLimit}\n pct={pct}\n />\n ))\n : undefined\n }\n dailyCap={{\n label: 'Daily cap',\n value:\n project.daily_cap_per_user == null\n ? 'No limit'\n : project.daily_cap_per_user.toLocaleString('en-US'),\n }}\n />\n )\n return { planBadge, readout, breakdown }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/connection/billing/reward-balance.ts","../src/connection/billing/support.ts","../src/connection/billing/addon-pricing.ts","../src/connection/billing/plan-constants.ts","../src/connection/billing/quota-items.ts","../src/connection/billing/api-error.ts","../src/connection/billing/tax-quote.ts","../src/connection/billing/plan-pricing.ts","../src/connection/billing/plan-badge.ts","../src/connection/workspace-list/projectBilling.tsx"],"names":["useUserSettings","useHost","useArbi","formatGbp","PoundSterling","HardDrive","Users","gbp","jsx","PlanBadge","ProjectReadout","QuotaMeter","ProjectBreakdown","UsageMeter"],"mappings":";;;;;;;;;;AAoBO,SAAS,gBAAA,GAAyC;AACvD,EAAA,MAAM,EAAE,IAAA,EAAK,GAAIA,sBAAgB,EAAE,cAAA,EAAgB,UAAU,CAAA;AAE7D,EAAA,MAAM,KAAK,IAAA,EAAM,cAAA;AACjB,EAAA,IAAI,CAAC,MAAM,CAAC,EAAA,CAAG,UAAU,EAAA,CAAG,MAAA,IAAU,GAAG,OAAO,IAAA;AAChD,EAAA,OAAO,EAAE,MAAA,EAAQ,EAAA,CAAG,QAAQ,QAAA,EAAU,EAAA,CAAG,YAAY,KAAA,EAAM;AAC7D;AAGO,SAAS,WAAA,CAAY,KAAA,EAAe,QAAA,GAAW,KAAA,EAAe;AACnE,EAAA,MAAM,QAAQ,KAAA,GAAQ,GAAA;AACtB,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA;AACtC,EAAA,MAAM,CAAA,GAAI,SAAS,WAAA,EAAY;AAC/B,EAAA,MAAM,MAAA,GACJ,CAAA,KAAM,KAAA,GAAQ,GAAA,GAAM,CAAA,KAAM,KAAA,GAAQ,MAAA,GAAM,CAAA,KAAM,KAAA,GAAQ,QAAA,GAAM,QAAA,CAAS,WAAA,EAAY,GAAI,GAAA;AACvF,EAAA,OAAO,CAAA,EAAG,MAAM,CAAA,EAAG,KAAA,CAAM,eAAe,OAAA,EAAS;AAAA,IAC/C,qBAAA,EAAuB,UAAU,CAAA,GAAI,CAAA;AAAA,IACrC,qBAAA,EAAuB,UAAU,CAAA,GAAI;AAAA,GACtC,CAAC,CAAA,CAAA;AACJ;AChBA,IAAM,YAAA,GAA+B,EAAE,aAAA,EAAe,KAAA,EAAM;AAErD,SAAS,iBAAA,G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AAA,GAAY,EAAE,KAAA,EAAO,SAAA,EAAW,QAAQ,CAAA,aAAA,EAAgB,OAAA,CAAQ,WAAW,CAAA,CAAA,EAAG,GAAI,MAAA;AAAA,MAEpF,KAAA,EAAO;AAAA,QACL,MAAA,EAAQ,CAAA,cAAA,EAAiB,OAAA,CAAQ,WAAW,CAAA,CAAA;AAAA;AAAA,QAE5C,IAAA,kBACEF,cAAA;AAAA,UAACG,4BAAA;AAAA,UAAA;AAAA,YACC,KAAA,EAAO,UAAA;AAAA,YACP,IAAA,EAAK,IAAA;AAAA,YACL,YAAA,EAAc,KAAA;AAAA,YACd,QAAA,EAAU,aAAA;AAAA,YACV,WAAA,EAAa;AAAA;AAAA;AACf;AAEJ;AAAA,GACF,GAEA,SAAA;AAEF,EAAA,MAAM,SAAA,mBACJH,cAAA;AAAA,IAACI,kCAAA;AAAA,IAAA;AAAA,MACC,MAAM,OAAA,CAAQ,IAAA;AAAA,MACd,KAAA,EAAO,SAAA;AAAA,MACP,MAAA,EACE,OAAA,GACI,UAAA,CAAW,GAAA,CAAI,CAAC,EAAE,GAAA,EAAK,IAAA,EAAM,KAAA,EAAO,WAAA,EAAa,GAAA,EAAI,qBACnDJ,cAAA;AAAA,QAACK,4BAAA;AAAA,QAAA;AAAA,UAEC,IAAA;AAAA,UACA,KAAA;AAAA,UACA,KAAA,EAAO,WAAA;AAAA,UACP;AAAA,SAAA;AAAA,QAJK;AAAA,OAMR,CAAA,GACD,MAAA;AAAA,MAEN,QAAA,EAAU;AAAA,QACR,KAAA,EAAO,WAAA;AAAA,QACP,KAAA,EACE,QAAQ,kBAAA,IAAsB,IAAA,GAC1B,aACA,OAAA,CAAQ,kBAAA,CAAmB,eAAe,OAAO;AAAA;AACzD;AAAA,GACF;AAEF,EAAA,OAAO,EAAE,SAAA,EAAW,OAAA,EAAS,SAAA,EAAU;AACzC","file":"chunk-6AFAYGJW.cjs","sourcesContent":["/**\n * Reward-balance logic (hook + money formatter).\n *\n * A user's reward balance is their available account balance — a single GLOBAL per-user\n * number, the Stripe customer account balance mirrored read-only into\n * `settings.extra_discount`. It auto-applies to the user's NEXT invoice.\n *\n * \"Rewards\" is the broad concept: the balance can be fed by several sources (referral\n * reward is just one). The referral pricing surfaces of the billing kit\n * speak to the referral source specifically; this module owns the balance itself.\n */\n\nimport { useUserSettings } from '@arbidocs/react'\n\nexport interface RewardBalance {\n amount: number // minor units (e.g. pennies) of available account balance\n currency: string\n}\n\n/** The user's available reward balance (all sources), or null if none. */\nexport function useRewardBalance(): RewardBalance | null {\n const { data } = useUserSettings({ refetchOnMount: 'always' })\n // Backend mirrors this read-only as { amount, currency }; schema types it as a loose object.\n const ed = data?.extra_discount as { amount?: number; currency?: string } | null | undefined\n if (!ed || !ed.amount || ed.amount <= 0) return null\n return { amount: ed.amount, currency: ed.currency || 'gbp' }\n}\n\n/** Format minor units as a localized money string, e.g. `£20` (whole) or `£29.99`. */\nexport function formatMoney(cents: number, currency = 'gbp'): string {\n const value = cents / 100\n const isWhole = Number.isInteger(value)\n const c = currency.toLowerCase()\n const symbol =\n c === 'usd' ? '$' : c === 'gbp' ? '£' : c === 'eur' ? '€' : currency.toUpperCase() + ' '\n return `${symbol}${value.toLocaleString('en-US', {\n minimumFractionDigits: isWhole ? 0 : 2,\n maximumFractionDigits: isWhole ? 0 : 2,\n })}`\n}\n","/**\n * What a host adds to the billing kit. Selling plans needs Stripe, which stays the host's: whether\n * this deployment sells plans (a publishable key is configured), and its embedded checkout. It is the\n * host configuration's `billing`; without it nothing is for sale: projects show their limits and\n * usage only.\n */\nimport type { ReactNode } from 'react'\nimport { useArbi } from '@arbidocs/react'\nimport { useHost } from '../../provider/host'\n\nexport interface BillingCheckoutSupport {\n /** Load the host's Stripe (lazily, when a checkout opens); `null` when it cannot. */\n load(): Promise<unknown> | null\n /** Stripe's embedded checkout for a session, on the loaded Stripe. */\n render(stripe: unknown, session: { clientSecret: string; onComplete: () => void }): ReactNode\n}\n\nexport interface BillingSupport {\n /** This deployment sells plans (Stripe is configured). */\n stripeEnabled: boolean\n checkout?: BillingCheckoutSupport\n}\n\nconst NOT_FOR_SALE: BillingSupport = { stripeEnabled: false }\n\nexport function useBillingSupport(): BillingSupport {\n return useHost().billing ?? NOT_FOR_SALE\n}\n\n/** The signed-in user's id (`usr-…`), to tell the projects they own from the others. */\nexport function useSelfExtId(): string | undefined {\n const arbi = useArbi()\n return arbi.isLoggedIn ? (arbi.user.identity()?.externalId ?? undefined) : undefined\n}\n","/** Add-on block price helpers (VAT-inclusive pence from `project.addons`). */\n\nimport { formatGbp } from '@arbidocs/react'\nimport type { components } from '@arbidocs/client'\nimport type { AddonKind } from './useAddonPurchase'\nimport { formatMoney } from './reward-balance'\n\ntype ProjectAddons = components['schemas']['ProjectAddons']\n\nconst gbp = (pence: number) => formatMoney(pence, 'gbp')\n\n/** \"3 Nov 2026\". */\nexport function formatPeriodEnd(unix: number | null | undefined): string | null {\n if (!unix) return null\n return new Date(unix * 1000).toLocaleDateString('en-GB', {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n })\n}\n\n/** What one more block of this kind costs right now, incl. UK VAT. */\nexport function addonPricePence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage' ? addons.ai_block_price_pence : addons.storage_block_price_pence\n}\n\n/** The same price ex VAT. */\nfunction addonPriceExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_price_ex_vat_pence\n : addons.storage_block_price_ex_vat_pence\n}\n\n/**\n * The PUT /addons/settings body (the monthly usage cap and the automatic add-on trigger) from the current add-on\n * state with the given changes applied.\n */\nexport function addonSettingsBody(\n addons: ProjectAddons,\n change: Partial<{\n spend_cap_pence: number | null\n auto_topup_threshold_gbp: number\n }> = {}\n) {\n return {\n spend_cap_pence: addons.spend_cap_pence ?? null,\n auto_topup_threshold_gbp: addons.auto_topup_threshold_gbp,\n ...change,\n }\n}\n\n/**\n * Of `count` blocks of a kind, how many are on an earlier catalogue's price (legacy, at their old size: £10 of AI\n * usage or 10 GB) and how many on today's. A reduction removes today's blocks first, so the legacy ones are the\n * last kept.\n */\nexport function splitBlocks(\n kind: AddonKind,\n count: number,\n addons: ProjectAddons\n): { legacy: number; current: number } {\n const granted =\n (kind === 'ai_usage' ? addons.legacy_ai_blocks : addons.legacy_storage_blocks) ?? 0\n const legacy = Math.max(0, Math.min(granted, count))\n return { legacy, current: count - legacy }\n}\n\n/** One block's size: \"£20 of AI credits\" / \"20 GB\" (legacy: \"£10\" / \"10 GB\"). */\nfunction blockSize(kind: AddonKind, addons: ProjectAddons, legacy: boolean): string {\n if (kind === 'ai_usage') {\n return formatGbp(legacy ? (addons.legacy_block_ai_gbp ?? 10) : addons.block_ai_gbp)\n }\n return `${legacy ? (addons.legacy_block_storage_gb ?? 10) : addons.block_storage_gb} GB`\n}\n\n/**\n * \"2 × £20 of AI credits\", \"1 × £10 + 1 × £20 of AI credits\", \"1 × 10 GB + 2 × 20 GB\": `count` blocks of a kind, the\n * legacy ones (kept last on a reduction) at their old size.\n */\nexport function blocksLabel(kind: AddonKind, count: number, addons: ProjectAddons): string {\n const { legacy, current } = splitBlocks(kind, count, addons)\n const parts = [\n ...(legacy > 0 ? [`${legacy} × ${blockSize(kind, addons, true)}`] : []),\n ...(current > 0 || legacy === 0 ? [`${current} × ${blockSize(kind, addons, false)}`] : []),\n ]\n return `${parts.join(' + ')}${kind === 'ai_usage' ? ' of AI credits' : ''}`\n}\n\n/**\n * Bounds for \"Reduce from next period\": keep `min`..`current` blocks. `next` is what renews\n * now (a pending reduction, or the current count). Storage can't go below what usage needs.\n */\nexport function reduceBounds(\n kind: AddonKind,\n addons: ProjectAddons\n): { min: number; current: number; next: number } {\n const current = kind === 'ai_usage' ? addons.ai_blocks : addons.storage_blocks\n const pending = kind === 'ai_usage' ? addons.ai_blocks_next : addons.storage_blocks_next\n const min = 0\n return { min, current, next: pending ?? current }\n}\n\n/** One block's monthly-equivalent price ex VAT: AI credits and storage are priced separately. */\nfunction blockMonthlyExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_monthly_ex_vat_pence\n : addons.storage_block_monthly_ex_vat_pence\n}\n\n/** What one block renews at per billing period, ex VAT (annual: 12 × the monthly price). */\nfunction blockPeriodExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_period_ex_vat_pence\n : addons.storage_block_period_ex_vat_pence\n}\n\n/** What one add-on renews at: \"£20/month ex VAT\" or \"£180/year ex VAT\". */\nfunction blockRenewalShort(kind: AddonKind, addons: ProjectAddons, isAnnual: boolean): string {\n return `${gbp(blockPeriodExVatPence(kind, addons))}/${isAnnual ? 'year' : 'month'} ex VAT`\n}\n\n/** The extra line annual subscriptions show beside an AI credits add-on or upgrade price. */\nexport const ANNUAL_PREMIUM_AI_NOTE = 'No markup on Premium AI on annual subscriptions'\n\n/** The confirm dialog's figures: charged now (incl. / ex VAT), what it covers until, then what renews. */\nexport function addonCharge(\n kind: AddonKind,\n addons: ProjectAddons,\n isAnnual: boolean,\n periodEnd: number | null | undefined\n): { now: string; nowExVat: string; nowVat: string; until: string | null; then: string } {\n return {\n now: gbp(addonPricePence(kind, addons)),\n nowExVat: gbp(addonPriceExVatPence(kind, addons)),\n nowVat: gbp(addonPricePence(kind, addons) - addonPriceExVatPence(kind, addons)),\n until: isAnnual ? formatPeriodEnd(periodEnd) : null,\n then: blockRenewalShort(kind, addons, isAnnual),\n }\n}\n\n/** Why automatic top-ups stopped (one line; the price of a step is on the Add button). */\nexport const CAP_REACHED_MESSAGE = 'Usage cap reached: no more automatic top-ups this month.'\n\n/** The £0 usage cap: no automatic top-ups (adding by hand still works). */\nexport const ZERO_BUDGET_MESSAGE = 'Automatic top-ups are off (£0 usage cap).'\n\n/** The usage cap's heading wherever it is edited or shown. */\nexport const USAGE_CAP_LABEL = 'Auto-upgrade limit'\n\n/** Automatic-upgrade spending is separate from explicitly selected allowances. */\nexport const USAGE_CAP_HELP =\n 'Your auto-upgrade limit covers extra monthly spend beyond your selected subscription and add-ons. ' +\n '£0 turns automatic upgrades off. You can adjust usage add-ons with + and −. ' +\n 'Additions show the charge before you confirm; reductions apply next billing period, ' +\n 'provided your storage and collaborators fit. Prices are ex VAT.'\n\n/** A £0 cap turns automatic top-ups off (manual adds still work). */\nexport function isAddonBudgetZero(addons: Pick<ProjectAddons, 'spend_cap_pence'>): boolean {\n return addons.spend_cap_pence === 0\n}\n\n/**\n * How much more of a resource automatic top-ups may add this month before the usage cap stops them, in the\n * resource's unit (£ of AI credits / GB): the whole blocks the cap left pays for at today's ex-VAT price. `null` =\n * no limit; 0 with a £0 cap or when not even one block fits.\n */\nexport function autoRoom(kind: AddonKind, addons: ProjectAddons): number | null {\n const left = addons.cap_left_pence\n if (left == null) return addons.spend_cap_pence === 0 ? 0 : null\n const price = blockMonthlyExVatPence(kind, addons)\n if (price <= 0) return 0\n const blocks = Math.floor(left / price)\n return blocks * (kind === 'ai_usage' ? addons.block_ai_gbp : addons.block_storage_gb)\n}\n\n/** The size of the block a one-step reduction removes from what renews (today's blocks go first). */\nexport function nextRemovedBlockSize(kind: AddonKind, addons: ProjectAddons): number {\n const { next } = reduceBounds(kind, addons)\n const { current } = splitBlocks(kind, next, addons)\n if (kind === 'ai_usage') {\n return current > 0 ? addons.block_ai_gbp : (addons.legacy_block_ai_gbp ?? 10)\n }\n return current > 0 ? addons.block_storage_gb : (addons.legacy_block_storage_gb ?? 10)\n}\n\n/**\n * Pounds typed into a usage cap field → pence. '' → the default (null); invalid → undefined.\n * Equal to the default is also sent as null (\"keep the default\").\n */\nexport function parseBudgetPounds(value: string): number | null | undefined {\n if (value.trim() === '') return null\n const n = Number(value)\n if (!Number.isFinite(n) || n < 0) return undefined\n return Math.round(n * 100)\n}\n\n/** Toast after saving the usage cap. */\nexport function budgetSavedMessage(capPence: number | null): string {\n if (capPence == null) return 'Usage cap: no limit'\n if (capPence === 0) return 'Usage cap: £0 (no automatic top-ups)'\n return `Usage cap: ${gbp(capPence)} a month`\n}\n\nconst gbText = (n: number) => `${Math.round(n * 10) / 10} GB`\n\n/** \"£20 of AI credits\" / \"20 GB\". */\nexport function stepLabel(kind: AddonKind, size: number): string {\n return kind === 'ai_usage' ? `${formatGbp(size)} of AI credits` : gbText(size)\n}\n\n/** The PUT /addons/next-period body that renews `keep` blocks of `kind` (the other kind unchanged). */\nexport function nextPeriodBody(kind: AddonKind, keep: number) {\n return kind === 'ai_usage'\n ? { ai_blocks: keep, storage_blocks: null }\n : { ai_blocks: null, storage_blocks: keep }\n}\n\n/**\n * The \"+\" step's price line, ex VAT: \"£20/month · today £20\" (annual: \"£15/month · today £150\");\n * storage, charged for the rest of the period: \"£20/month · prorated today £8.33\".\n */\nexport function addStepCaption(kind: AddonKind, addons: ProjectAddons): string {\n const now = gbp(addonPriceExVatPence(kind, addons))\n const today = kind === 'storage' ? `prorated today ${now}` : `today ${now}`\n return `${gbp(blockMonthlyExVatPence(kind, addons))}/month · ${today}`\n}\n","/** Pro's allowance per month (one licence) — must match the backend. Legacy multi-pack plans get it per pack.\n * The live numbers for an existing project come from `project.addons`; these are only for\n * describing the plan before a project exists (new-project dialog, upgrade picker). */\nexport const PRO_AI_GBP = 10\nexport const PRO_STORAGE_GB = 5\nexport const PRO_COLLABORATORS = 1\nexport const COLLABORATOR_BLOCK_SIZE = 5\n\n/**\n * Add-on block sizes (£20 of AI credits or 20 GB), the same on every plan. Their prices come from the\n * products API (`addon_prices`) before a project exists, and from `project.addons` after.\n */\nexport const ADDON_BLOCK_AI_GBP = 20\nexport const STORAGE_BLOCK_GB = 20\n\n/** Default monthly usage cap for a new Pro project (pence); it limits automatic top-ups only. 0 = no automatic\n * top-ups, null = no limit. */\nexport const DEFAULT_SPEND_CAP_PENCE = 10000\n\n/** The automatic add-on triggers when less than this much AI credits (£) remains; the backend minimum. */\nexport const MIN_AUTO_TOPUP_THRESHOLD_GBP = 1\n\n/** Free-tier quotas — must match backend FREE_* constants in src/constants.py\n * (FREE_AI_GBP=1, FREE_STORAGE_GB=0.05 → 50 MB, FREE_COLLABORATORS=0). */\nexport const FREE_AI_GBP = 1\nexport const FREE_STORAGE_MB = 50\nexport const FREE_COLLABORATORS = 0\n\n/** Collaborator limits at or above this are \"unlimited\" (the backend reports 999 for dev). */\nexport const UNLIMITED_COLLABORATORS = 999\n\n/**\n * Suggested initial daily per-user AI credits cap (£), pre-filled when creating\n * a new project. The user can clear it to create a project with no cap.\n * Backend treats null as \"no enforcement\" — there is no server-side default.\n */\nexport const SUGGESTED_DAILY_CAP_PER_USER = 10\n","/**\n * Quota display — single source of truth.\n *\n * Builds the icon / label / formatted used-of-limit strings for a project's\n * quotas (AI credits in £, storage, collaborators). Shared by QuotaBadges and the\n * project tooltip so the numbers and units can never disagree (storage in GB on\n * plans of 1 GB or more, MB below).\n */\n\nimport { HardDrive, PoundSterling, Users } from 'lucide-react'\nimport { formatGbp } from '@arbidocs/react'\nimport type { QuotaMeterItem } from '../../settings'\nimport type { components } from '@arbidocs/client'\nimport { UNLIMITED_COLLABORATORS } from './plan-constants'\n\ntype Quotas = components['schemas']['ProjectResponse']['quotas']\n\nconst fmt = (v: number) => Math.round(v).toLocaleString('en-US')\n\n/** \"May 31, 2025\" — the one format every AI-usage-reset mention uses. */\nexport function formatResetDate(unixTimestamp: number | null | undefined): string | null {\n if (!unixTimestamp) return null\n const date = new Date(unixTimestamp * 1000)\n return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })\n}\n\n/**\n * When the project's AI credits allowance next resets, as a unix timestamp.\n * Pro projects report it directly (`addons.ai_usage_reset_at` — monthly, even on an\n * annual plan); monthly subscriptions otherwise reset with the billing period\n * (`current_period_end`); free projects reset on the backend-stamped signup\n * anniversary (`quotas.budget_reset_at`). Only a FUTURE date is returned — a stale\n * past stamp would read as a bug, not a promise.\n */\nexport function aiUsageResetTimestamp(project: {\n quotas?: { budget_reset_at?: number | null } | null\n current_period_end?: number | null\n plan_interval?: string | null\n addons?: { ai_usage_reset_at?: number | null } | null\n}): number | null {\n // An annual period end is a year away — never a monthly AI credits reset.\n const periodEnd = project.plan_interval === 'year' ? null : project.current_period_end\n const ts =\n project.addons?.ai_usage_reset_at ?? periodEnd ?? project.quotas?.budget_reset_at ?? null\n return ts && ts * 1000 > Date.now() ? ts : null\n}\n\n// Defensive: a quota field may be missing on partial/empty payloads — treat it\n// as 0 / 0 rather than crashing the whole row.\nconst quota = (q?: { used?: number; limit?: number }) => ({\n used: q?.used ?? 0,\n limit: q?.limit ?? 0,\n})\n/** GB from 1 GB plans up (\"2.4 GB\", \"5 GB\"), MB below (\"50 MB\"); `unit: false` drops the unit. */\nfunction storageText(gbValue: number, limitGb: number, unit = true): string {\n if (limitGb >= 1) {\n const n = Math.round(gbValue * 10) / 10\n return `${n.toLocaleString('en-US')}${unit ? ' GB' : ''}`\n }\n return `${fmt(gbValue * 1000)}${unit ? ' MB' : ''}`\n}\nconst pctOf = (used: number, limit: number) => (limit > 0 ? (used / limit) * 100 : 0)\n\nexport function getQuotaItems(quotas: Quotas): QuotaMeterItem[] {\n const aiUsage = quota(quotas?.ai_usage)\n const storage = quota(quotas?.storage_gb)\n const collaborators = quota(quotas?.collaborators)\n const unlimitedCollaborators = collaborators.limit === UNLIMITED_COLLABORATORS\n return [\n {\n key: 'ai-usage',\n icon: PoundSterling,\n label: 'AI credits',\n used: formatGbp(aiUsage.used),\n usedOfLimit: `${formatGbp(aiUsage.used)} / ${formatGbp(aiUsage.limit)}`,\n pct: pctOf(aiUsage.used, aiUsage.limit),\n },\n {\n key: 'storage',\n icon: HardDrive,\n label: 'Storage',\n used: storageText(storage.used, storage.limit),\n usedOfLimit: `${storageText(storage.used, storage.limit, false)} / ${storageText(\n storage.limit,\n storage.limit\n )}`,\n pct: pctOf(storage.used, storage.limit),\n },\n {\n key: 'collaborators',\n icon: Users,\n label: 'Collaborators',\n used: fmt(collaborators.used),\n usedOfLimit: unlimitedCollaborators\n ? `${fmt(collaborators.used)} / Unlimited`\n : `${fmt(collaborators.used)} / ${fmt(collaborators.limit)}`,\n // Zero seats (Free) IS the cap: 0 / 0 shows a full destructive bar,\n // because you can't add anyone — the truth the upgrade door answers.\n // (Only when the quota is actually present; a missing field on a\n // partial payload stays an empty bar, not a false alarm.)\n pct: unlimitedCollaborators\n ? 0\n : quotas?.collaborators && collaborators.limit === 0\n ? 100\n : pctOf(collaborators.used, collaborators.limit),\n },\n ]\n}\n","/**\n * The `detail` of a refused billing call: the response body's `detail` (a string, or the\n * `{code, message}` of a payment refusal), whether the error is an SDK `ArbiApiError` (body in\n * `apiError`) or the body itself.\n */\nexport function apiErrorDetail(error: unknown): unknown {\n const body = (error as { apiError?: unknown } | null)?.apiError ?? error\n return (body as { detail?: unknown } | null)?.detail\n}\n","/**\n * Tax-inclusive totals from the backend's Stripe Tax quotes (`TaxQuoteResponse`, plan-change\n * previews, add-on quotes): \"£48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\", \"£40.00 · no VAT\n * (reverse charge)\", \"£40.00 · no tax\".\n */\n\nimport type { ProjectPlanQuoteResponse } from '@arbidocs/client'\nimport { apiErrorDetail } from './api-error'\n\nexport type TaxQuote = ProjectPlanQuoteResponse\n\n/** Countries whose tax depends on the postcode: the field is shown up front. */\nexport const POSTCODE_COUNTRIES: readonly string[] = ['US', 'CA']\n\n/** The quote error that asks for a ZIP / postal code. */\nexport const TAX_LOCATION_INVALID = 'TAX_LOCATION_INVALID'\n\n/** \"£42.00\" — always pence, so the parts of a total add up on screen. */\nexport function money2(pence: number, currency = 'gbp'): string {\n const symbol = { gbp: '£', usd: '$', eur: '€' }[currency.toLowerCase()] ?? `${currency} `\n return `${symbol}${(pence / 100).toLocaleString('en-GB', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })}`\n}\n\nexport interface TaxParts {\n subtotal: number\n tax: number\n total: number\n /** \"VAT 20%\"; null when no tax is due. */\n label?: string | null\n reverseCharge?: boolean\n}\n\n/** \"VAT\" for a VAT label, else \"tax\". */\nfunction taxKind(label: string | null | undefined): string {\n return /^vat\\b/i.test(label ?? '') ? 'VAT' : 'tax'\n}\n\n/** What follows the total: \"incl. VAT (£40.00 + £8.00 VAT 20%)\", \"· no VAT (reverse charge)\", \"· no tax\". */\nexport function taxDetail({ subtotal, tax, label, reverseCharge }: TaxParts): string {\n if (reverseCharge) return '· no VAT (reverse charge)'\n if (tax <= 0) return '· no tax'\n return `incl. ${taxKind(label)} (${money2(subtotal)} + ${money2(tax)} ${label ?? 'tax'})`\n}\n\n/** \"£48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\", \"£40.00 · no VAT (reverse charge)\", \"£40.00 · no tax\". */\nexport function taxSummary(parts: TaxParts): string {\n return `${money2(parts.total)} ${taxDetail(parts)}`\n}\n\n/** \"£21.00 incl. VAT\" / \"£17.50\" — a total with only the word for its tax. */\nexport function totalWithTaxWord({ total, tax, label }: TaxParts): string {\n return tax > 0 ? `${money2(total)} incl. ${taxKind(label)}` : money2(total)\n}\n\n/** The parts of a quote response. */\nexport function quoteParts(quote: TaxQuote): TaxParts {\n return {\n subtotal: quote.subtotal_pence,\n tax: quote.tax_pence,\n total: quote.total_pence,\n label: quote.tax_label,\n reverseCharge: quote.reverse_charge,\n }\n}\n\n/** \"Total today £48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\". */\nexport function quoteTotalLine(quote: TaxQuote): string {\n if (quote.tax_calculated === false) return `Total today ${money2(quote.total_pence)} ex VAT`\n return `Total today ${taxSummary(quoteParts(quote))}`\n}\n\n/** The API error code (`detail.code`) and message, if any. */\nexport function quoteError(error: unknown): { code?: string; message?: string } {\n const detail = apiErrorDetail(error)\n if (detail && typeof detail === 'object') {\n const { code, message } = detail as { code?: unknown; message?: unknown }\n return {\n code: typeof code === 'string' ? code : undefined,\n message: typeof message === 'string' ? message : undefined,\n }\n }\n return { message: typeof detail === 'string' ? detail : undefined }\n}\n","/**\n * Pro plan price helpers. Prices come from Stripe via GET /v1/user/products (source of truth).\n * One plan is sold: Pro, one licence (£10 of AI credits + 5 GB a month). Each price lists\n * `pack_prices` for that one licence — `amount` incl. UK VAT and `amount_ex_vat` — and\n * `addon_prices` (one add-on block on that interval). Display them as-is.\n * Legacy subscriptions with several packs keep working; their name and price come from the project.\n */\n\nimport type { components } from '@arbidocs/client'\nimport { formatGbp } from '@arbidocs/react'\nimport { formatMoney } from './reward-balance'\nimport { formatPeriodEnd } from './addon-pricing'\nimport { taxSummary } from './tax-quote'\n\ntype PlanChangePreview = components['schemas']['PlanChangePreview']\ntype ProductPrice = components['schemas']['ProductPrice']\ntype ProductResponse = components['schemas']['ProductResponse']\ntype PackPrice = components['schemas']['PackPrice']\ntype AddonPrice = components['schemas']['AddonPrice']\n\nexport type PlanInterval = 'month' | 'year'\n\nconst gbp = (pence: number) => formatMoney(pence, 'gbp')\n\n/** The headline price: \"£40 ex VAT\". */\nexport function plusVat(exVatPence: number, currency = 'gbp'): string {\n return `${formatMoney(exVatPence, currency)} ex VAT`\n}\n\n/** The one licence Pro sells. Other pack counts exist only on legacy subscriptions (displayed, not sold). */\nexport const PRO_PACKS = 1\n\n/** A plan the pickers offer. */\nexport type PlanChoice = 'free' | 'pro'\n\n/** Packs per plan choice (0 = Free). */\nexport const PLAN_CHOICE_PACKS: Record<PlanChoice, number> = {\n free: 0,\n pro: PRO_PACKS,\n}\n\n/** \"Free\" (0), \"Pro\" (1), otherwise \"Pro ×N\" (a legacy multi-pack plan; the API's own name wins). */\nexport function planNameForPacks(packs: number | null | undefined): string {\n const n = packs ?? 0\n if (n <= 0) return 'Free'\n if (n === PRO_PACKS) return 'Pro'\n return `Pro ×${n}`\n}\n\n/** The plan-change panel's fixed lines, each with a test id. */\nexport interface PlanChangeLine {\n id: 'pay-today' | 'from' | 'current-until' | 'no-change' | 'awaiting-bank'\n text: string\n}\n\n/**\n * What a plan change costs, from the backend's Stripe invoice preview (taxed for the customer's\n * address), as fixed lines:\n * - \"Pay today £42.00 incl. VAT (£35.00 + £7.00 VAT 20%)\" (\"Pay today £0\" for a change that waits)\n * - \"From 16 Nov 2026: £210.00 incl. VAT (£175.00 + £35.00 VAT 20%) a month\"\n * - \"Current subscription until 16 Nov 2026\" for a change that waits for the period end.\n * \"No change\" when the selection is what the project already has; \"Waiting for your bank\" while\n * an earlier upgrade payment awaits 3-D Secure.\n */\nexport function planPreviewLines(preview: PlanChangePreview): PlanChangeLine[] {\n if (preview.unchanged) return [{ id: 'no-change', text: 'No change' }]\n const date = formatPeriodEnd(preview.next_renewal_at)\n const cadence = preview.interval === 'year' ? 'year' : 'month'\n const lines: PlanChangeLine[] = [\n preview.awaiting_confirmation\n ? { id: 'awaiting-bank', text: 'Waiting for your bank' }\n : {\n id: 'pay-today',\n text: preview.effective_now\n ? `Pay today ${taxSummary({\n subtotal: preview.due_now_ex_vat_pence,\n tax: preview.due_now_tax_pence,\n total: preview.due_now_pence,\n label: preview.tax_label,\n })}`\n : `Pay today ${gbp(0)}`,\n },\n {\n id: 'from',\n text: `${date ? `From ${date}` : 'From renewal'}: ${taxSummary({\n subtotal: preview.next_renewal_ex_vat_pence,\n tax: preview.next_renewal_tax_pence,\n total: preview.next_renewal_pence,\n label: preview.tax_label,\n })} a ${cadence}`,\n },\n ]\n if (!preview.effective_now) {\n lines.push({ id: 'current-until', text: `Current subscription until ${date ?? 'renewal'}` })\n }\n return lines\n}\n\n/** Stand-in for \"Pay today\" when the preview failed for an upgrade. */\nexport const PAY_TODAY_UNPRICED = 'Pay today: the difference for the rest of this period'\n\n/** One add-on block's price on this interval's plan price (`addon_prices`), if listed. */\nexport function addonPrice(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): AddonPrice | undefined {\n return price?.addon_prices?.find((p) => p.kind === kind)\n}\n\n/** Per add-on block of `kind` per month, ex VAT (annual subscriptions: the monthly equivalent). */\nexport function addonMonthlyExVat(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): number | undefined {\n return addonPrice(price, kind)?.monthly_ex_vat\n}\n\n/** What a checkout buys: \"Pro\", \"Pro + 2 × £20 of AI credits + 1 × 20 GB\". */\nexport function checkoutItemsLabel(\n aiBlocks: number,\n storageBlocks: number,\n collaboratorBlocks = 0,\n price?: ProductPrice\n): string {\n const ai = addonPrice(price, 'ai_usage')?.ai_gbp\n const storage = addonPrice(price, 'storage')?.storage_gb\n const collaborators = price?.addon_prices?.find((p) => p.kind === 'collaborators')?.collaborators\n return [\n 'Pro',\n aiBlocks > 0 &&\n (ai != null\n ? `${aiBlocks} × ${formatGbp(ai)} of AI credits`\n : `${aiBlocks} AI credits add-ons`),\n storageBlocks > 0 &&\n (storage != null ? `${storageBlocks} × ${storage} GB` : `${storageBlocks} storage add-ons`),\n collaboratorBlocks > 0 &&\n (collaborators != null\n ? `${collaboratorBlocks * collaborators} extra collaborators`\n : `${collaboratorBlocks} collaborator add-ons`),\n ]\n .filter(Boolean)\n .join(' + ')\n}\n\n/** The price of `packs` packs on this interval's price, if Stripe lists it (only one licence is listed). */\nexport function packPrice(\n price: ProductPrice | undefined,\n packs: number = PRO_PACKS\n): PackPrice | undefined {\n return price?.pack_prices?.find((p) => p.packs === packs)\n}\n\nexport interface ProPrices {\n monthly?: ProductPrice\n annual?: ProductPrice\n}\n\n/** The Pro product's monthly and annual prices (default price per interval wins). */\nexport function findProPrices(products: ProductResponse[] | undefined): ProPrices {\n const prices = products?.[0]?.prices ?? []\n const pick = (interval: PlanInterval) =>\n prices.find((p) => p.interval === interval && p.default_price) ??\n prices.find((p) => p.interval === interval)\n return { monthly: pick('month'), annual: pick('year') }\n}\n\n/** Annual savings vs 12 × monthly, as a whole percent (e.g. £360 vs £480 → 25). */\nexport function calcSavingsPercent(\n monthlyPrice: ProductPrice | undefined,\n annualPrice: ProductPrice | undefined\n): number | null {\n const monthly = packPrice(monthlyPrice)?.amount ?? monthlyPrice?.amount\n const annual = packPrice(annualPrice)?.amount ?? annualPrice?.amount\n if (monthly == null || annual == null || monthly === 0) return null\n const savings = Math.round(((monthly * 12 - annual) / (monthly * 12)) * 100)\n return savings > 0 ? savings : null\n}\n\n/** Most add-on blocks of each kind a checkout may include (the backend's limit). */\nexport const MAX_CHECKOUT_BLOCKS = 100\n\n/** \"£20/month ex VAT each\", annual: \"£180/year ex VAT each\": one block on the chosen interval. */\nexport function checkoutBlockPriceText(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage'\n): string | null {\n const block = addonPrice(price, kind)\n if (!block) return null\n const currency = price?.currency ?? 'gbp'\n return price?.interval === 'year'\n ? `${formatMoney(block.amount_ex_vat, currency)}/year ex VAT each`\n : `${formatMoney(block.amount_ex_vat, currency)}/month ex VAT each`\n}\n","import type { PlanBadgeProps } from '../../settings'\nimport type { components } from '@arbidocs/client'\nimport { planNameForPacks } from './plan-pricing'\n\ntype ProjectBillingFields = Pick<\n components['schemas']['ProjectResponse'],\n 'subscription' | 'plan_interval'\n> &\n Partial<Pick<components['schemas']['ProjectResponse'], 'packs' | 'addons'>>\n\n/** A project is on Pro when it has a billing interval (null = Free or checkout pending). */\nexport function isProProject(project: Pick<ProjectBillingFields, 'plan_interval'>): boolean {\n return project.plan_interval != null\n}\n\n/** \"Pro\", or a legacy multi-pack plan's name (\"Pro ×N\") — the API's name when it sends one (owner view). */\nexport function proTierName(project: ProjectBillingFields): string {\n return project.addons?.plan_name || planNameForPacks(Math.max(project.packs ?? 1, 1))\n}\n\n/** \"Free\", \"Pro monthly\", \"Pro annual\", \"Pro ×3 monthly\" (legacy) or \"Dev\" — the full plan name. */\nexport function planName(project: ProjectBillingFields): string {\n if (project.subscription === 'dev') return 'Dev'\n if (project.subscription === 'suspended') return 'Subscription ended'\n if (!isProProject(project)) return 'Free'\n return `${proTierName(project)} ${project.plan_interval === 'year' ? 'annual' : 'monthly'}`\n}\n\n/**\n * Maps a project's billing state to the `PlanBadge` block's label + tone.\n * Pro reads as accent, Free/dev as neutral, payment trouble or cancelling as pending.\n */\nexport function planBadgeView(\n project: ProjectBillingFields\n): Pick<PlanBadgeProps, 'label' | 'tone'> {\n const { subscription } = project\n const label =\n subscription === 'suspended'\n ? 'Subscription ended'\n : subscription === 'canceled'\n ? 'Cancelling'\n : subscription === 'dev'\n ? 'Dev'\n : isProProject(project)\n ? proTierName(project)\n : 'Free'\n\n const tone =\n subscription === 'dev'\n ? 'dev'\n : subscription === 'suspended' || subscription === 'canceled' || subscription === 'past_due'\n ? 'pending'\n : isProProject(project)\n ? 'paid'\n : 'free'\n\n return { label, tone }\n}\n","/**\n * What a project's group in the workspace list says about the project itself: its plan badge (own\n * projects, where plans are sold), the usage readout beside its name, and the plan and limits\n * breakdown behind the name. One source for the cards' bands and the table's headings.\n */\nimport type { ReactNode } from 'react'\nimport type { LucideIcon } from 'lucide-react'\nimport type { components } from '@arbidocs/client'\nimport { UsageMeter } from '../../components/UsageMeter'\nimport { PlanBadge, QuotaMeter } from '../../settings'\nimport { ProjectBreakdown, ProjectReadout } from '../../home/ProjectBandParts'\nimport { planBadgeView } from '../billing/plan-badge'\nimport { getQuotaItems } from '../billing/quota-items'\n\ntype Project = components['schemas']['ProjectResponse']\n\nexport interface ProjectGroupBilling {\n /** The plan badge: own projects only, where plans are sold. */\n planBadge?: ReactNode\n /** Subscription and usage, right after the name (projects with quotas). */\n readout?: ReactNode\n /** The plan and limits panel behind the name; meters for own projects only. */\n breakdown?: ReactNode\n}\n\nexport function projectGroupBilling(\n project: Project | undefined,\n { isOwned, stripeEnabled }: { isOwned: boolean; stripeEnabled: boolean }\n): ProjectGroupBilling {\n if (!project) return {}\n const planBadge = isOwned && stripeEnabled ? <PlanBadge {...planBadgeView(project)} /> : undefined\n const quotaItems = project.quotas ? getQuotaItems(project.quotas) : []\n const readout = project.quotas ? (\n <ProjectReadout\n plan={\n planBadge ? { badge: planBadge, testId: `project-tier-${project.external_id}` } : undefined\n }\n usage={{\n testId: `project-usage-${project.external_id}`,\n // Bare numbers without plans for sale: a glance beside the name, not the Plan & Usage detail.\n node: (\n <QuotaMeter\n items={quotaItems}\n size=\"sm\"\n showTooltips={false}\n showBars={stripeEnabled}\n showPercent={false}\n />\n ),\n }}\n />\n ) : (\n planBadge\n )\n const breakdown = (\n <ProjectBreakdown\n name={project.name}\n badge={planBadge}\n meters={\n isOwned\n ? quotaItems.map(({ key, icon, label, usedOfLimit, pct }) => (\n <UsageMeter\n key={key}\n icon={icon as LucideIcon}\n label={label}\n value={usedOfLimit}\n pct={pct}\n />\n ))\n : undefined\n }\n dailyCap={{\n label: 'Daily cap',\n value:\n project.daily_cap_per_user == null\n ? 'No limit'\n : project.daily_cap_per_user.toLocaleString('en-US'),\n }}\n />\n )\n return { planBadge, readout, breakdown }\n}\n"]}
|