@carlonicora/nextjs-jsonapi 4.0.7 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/{BlockNoteEditor-J7EF7BRX.js → BlockNoteEditor-6CBMNJPU.js} +9 -9
  2. package/dist/{BlockNoteEditor-J7EF7BRX.js.map → BlockNoteEditor-6CBMNJPU.js.map} +1 -1
  3. package/dist/{BlockNoteEditor-KOHN3SSR.mjs → BlockNoteEditor-7N66JABP.mjs} +2 -2
  4. package/dist/billing/index.js +335 -335
  5. package/dist/billing/index.mjs +1 -1
  6. package/dist/{chunk-3W3VVX2N.mjs → chunk-HQKTQBUC.mjs} +89 -29
  7. package/dist/chunk-HQKTQBUC.mjs.map +1 -0
  8. package/dist/{chunk-3M7D6NXU.js → chunk-MJVEKDM4.js} +320 -260
  9. package/dist/chunk-MJVEKDM4.js.map +1 -0
  10. package/dist/client/index.js +2 -2
  11. package/dist/client/index.mjs +1 -1
  12. package/dist/components/index.d.mts +10 -1
  13. package/dist/components/index.d.ts +10 -1
  14. package/dist/components/index.js +4 -2
  15. package/dist/components/index.js.map +1 -1
  16. package/dist/components/index.mjs +3 -1
  17. package/dist/contexts/index.js +2 -2
  18. package/dist/contexts/index.mjs +1 -1
  19. package/dist/features/analytics/index.js +88 -88
  20. package/dist/features/analytics/index.mjs +1 -1
  21. package/dist/features/help/index.js +31 -31
  22. package/dist/features/help/index.mjs +1 -1
  23. package/dist/features/tokenusage/index.js +75 -75
  24. package/dist/features/tokenusage/index.mjs +1 -1
  25. package/dist/next-config/index.d.mts +8 -1
  26. package/dist/next-config/index.d.ts +8 -1
  27. package/dist/next-config/index.js +31 -9
  28. package/dist/next-config/index.js.map +1 -1
  29. package/dist/next-config/index.mjs +31 -9
  30. package/dist/next-config/index.mjs.map +1 -1
  31. package/package.json +1 -1
  32. package/src/features/company/components/details/CompanyContent.tsx +9 -2
  33. package/src/features/company/components/forms/CompanyEditor.tsx +2 -0
  34. package/src/features/company/hooks/useSubscriptionStatus.test.ts +76 -10
  35. package/src/features/company/hooks/useSubscriptionStatus.ts +9 -9
  36. package/src/features/how-to/components/containers/HowToCommand.spec.tsx +79 -6
  37. package/src/features/how-to/components/containers/HowToCommand.tsx +12 -2
  38. package/src/features/how-to/components/forms/HowToSelector.spec.tsx +85 -0
  39. package/src/features/how-to/components/forms/HowToSelector.tsx +1 -0
  40. package/src/features/role/components/forms/UserRoleAdd.spec.tsx +71 -0
  41. package/src/features/role/components/forms/UserRoleAdd.tsx +1 -0
  42. package/src/features/user/components/forms/UserSelector.spec.tsx +85 -0
  43. package/src/features/user/components/forms/UserSelector.tsx +1 -0
  44. package/src/features/user/components/lists/UserListInAdd.spec.tsx +84 -0
  45. package/src/features/user/components/lists/UserListInAdd.tsx +1 -0
  46. package/src/features/user/components/widgets/UserSearchPopover.spec.tsx +68 -0
  47. package/src/features/user/components/widgets/UserSearchPopover.tsx +1 -0
  48. package/src/next-config/__tests__/createNextConfig.test.ts +45 -3
  49. package/src/next-config/csp.ts +25 -4
  50. package/src/next-config/index.ts +19 -12
  51. package/src/shadcnui/custom/multi-select.spec.tsx +70 -0
  52. package/src/shadcnui/custom/multi-select.tsx +26 -2
  53. package/src/shadcnui/custom/multiple-selector.spec.tsx +111 -0
  54. package/src/shadcnui/custom/multiple-selector.tsx +33 -10
  55. package/src/shadcnui/ui/command.spec.ts +26 -0
  56. package/src/shadcnui/ui/command.tsx +13 -1
  57. package/dist/chunk-3M7D6NXU.js.map +0 -1
  58. package/dist/chunk-3W3VVX2N.mjs.map +0 -1
  59. /package/dist/{BlockNoteEditor-KOHN3SSR.mjs.map → BlockNoteEditor-7N66JABP.mjs.map} +0 -0
@@ -37,7 +37,7 @@ var _chunkC2WQXUL5js = require('../../chunk-C2WQXUL5.js');
37
37
 
38
38
 
39
39
 
40
- var _chunk3M7D6NXUjs = require('../../chunk-3M7D6NXU.js');
40
+ var _chunkMJVEKDM4js = require('../../chunk-MJVEKDM4.js');
41
41
  require('../../chunk-7ZRQOLSV.js');
42
42
  require('../../chunk-G4JR3SFV.js');
43
43
 
@@ -82,7 +82,7 @@ function TokenUsageAdminFilterBar({ granularity, companyId, metric, companies, o
82
82
  };
83
83
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap items-center gap-2", children: [
84
84
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "max-md:w-full max-md:[&_#date]:w-full", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
85
- _chunk3M7D6NXUjs.DateRangeSelector,
85
+ _chunkMJVEKDM4js.DateRangeSelector,
86
86
  {
87
87
  onDateChange: (range) => {
88
88
  if (!_optionalChain([range, 'optionalAccess', _ => _.from]) || !_optionalChain([range, 'optionalAccess', _2 => _2.to])) return;
@@ -117,16 +117,16 @@ function TokenUsageAdminFilterBar({ granularity, companyId, metric, companies, o
117
117
  }
118
118
  ),
119
119
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
120
- _chunk3M7D6NXUjs.Select,
120
+ _chunkMJVEKDM4js.Select,
121
121
  {
122
122
  items: companyItems,
123
123
  value: _nullishCoalesce(companyId, () => ( ALL_COMPANIES)),
124
124
  onValueChange: (value) => onChange({ companyId: !value || value === ALL_COMPANIES ? void 0 : value }),
125
125
  children: [
126
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectTrigger, { className: "w-56", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectValue, { placeholder: t("token_usage.admin.all_companies") }) }),
127
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.SelectContent, { children: [
128
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectItem, { value: ALL_COMPANIES, children: t("token_usage.admin.all_companies") }),
129
- companies.map((company) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectItem, { value: company.id, children: company.label }, company.id))
126
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.SelectTrigger, { className: "w-56", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.SelectValue, { placeholder: t("token_usage.admin.all_companies") }) }),
127
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.SelectContent, { children: [
128
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.SelectItem, { value: ALL_COMPANIES, children: t("token_usage.admin.all_companies") }),
129
+ companies.map((company) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.SelectItem, { value: company.id, children: company.label }, company.id))
130
130
  ] })
131
131
  ]
132
132
  }
@@ -149,7 +149,7 @@ function Segmented({
149
149
  children: options.map((option) => {
150
150
  const selected = option.value === value;
151
151
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
152
- _chunk3M7D6NXUjs.Button,
152
+ _chunkMJVEKDM4js.Button,
153
153
  {
154
154
  type: "button",
155
155
  size: "sm",
@@ -231,7 +231,7 @@ var TokenUsageAdminProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
231
231
  pageUrl = TOKEN_USAGE_ADMIN_PAGE_URL
232
232
  }) => {
233
233
  const t = _nextintl.useTranslations.call(void 0, );
234
- const generateUrl = _chunk3M7D6NXUjs.usePageUrlGenerator.call(void 0, );
234
+ const generateUrl = _chunkMJVEKDM4js.usePageUrlGenerator.call(void 0, );
235
235
  const [filters, setFilterState] = _react.useState.call(void 0, () => {
236
236
  const range = defaultRange();
237
237
  return {
@@ -349,7 +349,7 @@ var TokenUsageAdminProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
349
349
  error
350
350
  ]
351
351
  );
352
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageAdminContext.Provider, { value: contextValue, children }) });
352
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageAdminContext.Provider, { value: contextValue, children }) });
353
353
  }, "TokenUsageAdminProvider");
354
354
  var useTokenUsageAdmin = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
355
355
  const ctx = _react.useContext.call(void 0, TokenUsageAdminContext);
@@ -446,7 +446,7 @@ function LeadTile({
446
446
  previousLabel,
447
447
  decimal
448
448
  }) {
449
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { "data-testid": testId, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.CardContent, { className: "grid gap-1", children: [
449
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.Card, { "data-testid": testId, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.CardContent, { className: "grid gap-1", children: [
450
450
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: label }),
451
451
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-primary text-xl font-semibold tabular-nums", children: value }),
452
452
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-center gap-1", children: [
@@ -463,7 +463,7 @@ function SupportingTile({
463
463
  delta,
464
464
  decimal
465
465
  }) {
466
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { "data-testid": testId, size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.CardContent, { className: "grid gap-1", children: [
466
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.Card, { "data-testid": testId, size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.CardContent, { className: "grid gap-1", children: [
467
467
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: label }),
468
468
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-center gap-2", children: [
469
469
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium tabular-nums", children: value }),
@@ -560,8 +560,8 @@ function TokenUsageBreakdownTable({ rows, metric }) {
560
560
  // The package's <Table> wraps itself in an `overflow-x-clip` container, which
561
561
  // would swallow the overflow before this scroller ever saw it — hence the
562
562
  // child override. Wide metric tables must scroll, never widen the page.
563
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-x-auto [&_[data-slot=table-container]]:overflow-x-visible", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Table, { children: [
564
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableRow, { children: columns.map((column) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableHead, { className: _chunk5PNDDYGLjs.cn.call(void 0, column.numeric && "text-end"), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
563
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-x-auto [&_[data-slot=table-container]]:overflow-x-visible", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.Table, { children: [
564
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.TableHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.TableRow, { children: columns.map((column) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.TableHead, { className: _chunk5PNDDYGLjs.cn.call(void 0, column.numeric && "text-end"), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
565
565
  "button",
566
566
  {
567
567
  type: "button",
@@ -576,20 +576,20 @@ function TokenUsageBreakdownTable({ rows, metric }) {
576
576
  ]
577
577
  }
578
578
  ) }, column.key)) }) }),
579
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableBody, { children: sortedRows.map((row) => {
579
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.TableBody, { children: sortedRows.map((row) => {
580
580
  const value = _chunkC2WQXUL5js.metricValue.call(void 0, row, metric);
581
581
  const share = total > 0 ? value / total * 100 : 0;
582
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.TableRow, { "data-testid": `breakdown-row-${row.id}`, children: [
583
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-xs", children: row.id === "other" ? t("token_usage.admin.other") : row.label }),
584
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-muted-foreground text-xs", children: _nullishCoalesce(row.sublabel, () => ( "")) }),
585
- showActiveUsers && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: row.activeUsers === void 0 ? "" : decimal(row.activeUsers, 0) }),
586
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.calls, 0) }),
587
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.tokensIn, 0) }),
588
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.tokensOut, 0) }),
589
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: percent(_chunkC2WQXUL5js.cacheHitPercentage.call(void 0, row.cached, row.tokensIn)) }),
590
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: formatValue(row.cost, "cost") }),
591
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: formatValue(row.credits, "credits") }),
592
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.TableCell, { className: "text-end text-xs tabular-nums", children: percent(share) })
582
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.TableRow, { "data-testid": `breakdown-row-${row.id}`, children: [
583
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.TableCell, { className: "text-xs", children: row.id === "other" ? t("token_usage.admin.other") : row.label }),
584
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.TableCell, { className: "text-muted-foreground text-xs", children: _nullishCoalesce(row.sublabel, () => ( "")) }),
585
+ showActiveUsers && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.TableCell, { className: "text-end text-xs tabular-nums", children: row.activeUsers === void 0 ? "" : decimal(row.activeUsers, 0) }),
586
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.calls, 0) }),
587
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.tokensIn, 0) }),
588
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.tokensOut, 0) }),
589
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.TableCell, { className: "text-end text-xs tabular-nums", children: percent(_chunkC2WQXUL5js.cacheHitPercentage.call(void 0, row.cached, row.tokensIn)) }),
590
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.TableCell, { className: "text-end text-xs tabular-nums", children: formatValue(row.cost, "cost") }),
591
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.TableCell, { className: "text-end text-xs tabular-nums", children: formatValue(row.credits, "credits") }),
592
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.TableCell, { className: "text-end text-xs tabular-nums", children: percent(share) })
593
593
  ] }, row.id);
594
594
  }) })
595
595
  ] }) })
@@ -757,7 +757,7 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
757
757
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className, dir: "ltr", children: [
758
758
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "sr-only", "data-testid": "timeline-data", children: JSON.stringify(chartData) }),
759
759
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "sr-only", "data-testid": "timeline-series", children: JSON.stringify(seriesKeys) }),
760
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.ChartContainer, { config: chartConfig, className: "aspect-auto h-72 w-full", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _recharts.BarChart, { accessibilityLayer: true, data: chartData, margin: { top: 8, right: 8, bottom: 0, left: 0 }, children: [
760
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.ChartContainer, { config: chartConfig, className: "aspect-auto h-72 w-full", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _recharts.BarChart, { accessibilityLayer: true, data: chartData, margin: { top: 8, right: 8, bottom: 0, left: 0 }, children: [
761
761
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _recharts.CartesianGrid, { vertical: false }),
762
762
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
763
763
  _recharts.XAxis,
@@ -781,10 +781,10 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
781
781
  }
782
782
  ),
783
783
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
784
- _chunk3M7D6NXUjs.ChartTooltip,
784
+ _chunkMJVEKDM4js.ChartTooltip,
785
785
  {
786
786
  content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
787
- _chunk3M7D6NXUjs.ChartTooltipContent,
787
+ _chunkMJVEKDM4js.ChartTooltipContent,
788
788
  {
789
789
  labelFormatter: (value) => bucketDate(String(value), granularity),
790
790
  valueFormatter: (value) => formatValue(Number(value), metric),
@@ -793,7 +793,7 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
793
793
  )
794
794
  }
795
795
  ),
796
- seriesKeys.length >= 2 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.ChartLegend, { content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.ChartLegendContent, {}) }) : null,
796
+ seriesKeys.length >= 2 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.ChartLegend, { content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.ChartLegendContent, {}) }) : null,
797
797
  seriesKeys.map((series, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
798
798
  _recharts.Bar,
799
799
  {
@@ -845,19 +845,19 @@ function TokenUsageAdminContainer() {
845
845
  [t]
846
846
  );
847
847
  if (error) {
848
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) }) }) }) });
848
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) }) }) }) });
849
849
  }
850
- if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.RoundPageContainer, { fullWidth: true, forceHeader: true });
850
+ if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.RoundPageContainer, { fullWidth: true, forceHeader: true });
851
851
  const emptyLabel = t("token_usage.admin.no_data");
852
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-4 p-4", children: [
852
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-4 p-4", children: [
853
853
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageAdminTiles, { summary, metric: filters.metric, singleCustomerMode: hidePlatform }),
854
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
855
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: [
856
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.admin.usage_over_time") }),
857
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardAction, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
854
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.Card, { children: [
855
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.CardHeader, { children: [
856
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardTitle, { children: t("token_usage.admin.usage_over_time") }),
857
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardAction, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
858
858
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.admin.stack_by") }),
859
859
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
860
- _chunk3M7D6NXUjs.Select,
860
+ _chunkMJVEKDM4js.Select,
861
861
  {
862
862
  items: stackByItems,
863
863
  value: filters.stackBy,
@@ -865,29 +865,29 @@ function TokenUsageAdminContainer() {
865
865
  if (value) setFilters({ stackBy: value });
866
866
  },
867
867
  children: [
868
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectTrigger, { size: "sm", className: "w-36", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectValue, {}) }),
869
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectContent, { children: STACK_BY_VALUES.map((value) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SelectItem, { value, children: stackByItems[value] }, value)) })
868
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.SelectTrigger, { size: "sm", className: "w-36", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.SelectValue, {}) }),
869
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.SelectContent, { children: STACK_BY_VALUES.map((value) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.SelectItem, { value, children: stackByItems[value] }, value)) })
870
870
  ]
871
871
  }
872
872
  )
873
873
  ] }) })
874
874
  ] }),
875
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageTimelineChart, { rows: timeline, metric: filters.metric, stackBy: filters.stackBy }) })
875
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageTimelineChart, { rows: timeline, metric: filters.metric, stackBy: filters.stackBy }) })
876
876
  ] }),
877
877
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-4 md:grid-cols-2", children: [
878
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
879
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.admin.by_company") }) }),
880
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byCompany, metric: filters.metric, emptyLabel }) })
878
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.Card, { children: [
879
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardTitle, { children: t("token_usage.admin.by_company") }) }),
880
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byCompany, metric: filters.metric, emptyLabel }) })
881
881
  ] }),
882
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
883
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.admin.by_user") }) }),
884
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byUser, metric: filters.metric, emptyLabel }) })
882
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.Card, { children: [
883
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardTitle, { children: t("token_usage.admin.by_user") }) }),
884
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byUser, metric: filters.metric, emptyLabel }) })
885
885
  ] })
886
886
  ] }),
887
887
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunk5PNDDYGLjs.cn.call(void 0, "grid gap-4", !hidePlatform && "md:grid-cols-2"), children: [
888
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
889
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.admin.customer_by_operation") }) }),
890
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
888
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.Card, { children: [
889
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardTitle, { children: t("token_usage.admin.customer_by_operation") }) }),
890
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
891
891
  TokenUsageRankedBar,
892
892
  {
893
893
  rows: byCustomerOperation,
@@ -897,9 +897,9 @@ function TokenUsageAdminContainer() {
897
897
  }
898
898
  ) })
899
899
  ] }),
900
- !hidePlatform && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
901
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.admin.platform_by_operation") }) }),
902
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
900
+ !hidePlatform && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.Card, { children: [
901
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardTitle, { children: t("token_usage.admin.platform_by_operation") }) }),
902
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
903
903
  TokenUsageRankedBar,
904
904
  {
905
905
  rows: byOperation,
@@ -910,9 +910,9 @@ function TokenUsageAdminContainer() {
910
910
  ) })
911
911
  ] })
912
912
  ] }),
913
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
914
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.admin.detail") }) }),
915
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageBreakdownTable, { rows: byCompany, metric: filters.metric }) })
913
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.Card, { children: [
914
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardTitle, { children: t("token_usage.admin.detail") }) }),
915
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageBreakdownTable, { rows: byCompany, metric: filters.metric }) })
916
916
  ] })
917
917
  ] }) });
918
918
  }
@@ -1033,7 +1033,7 @@ var TOKEN_USAGE_REPORT_I18N_KEYS = [
1033
1033
 
1034
1034
  function TokenUsageReportFilterBar({ onChange }) {
1035
1035
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-help": "tokenusage.filters", className: "flex flex-wrap items-center gap-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1036
- _chunk3M7D6NXUjs.DateRangeSelector,
1036
+ _chunkMJVEKDM4js.DateRangeSelector,
1037
1037
  {
1038
1038
  onDateChange: (range) => {
1039
1039
  if (!_optionalChain([range, 'optionalAccess', _5 => _5.from]) || !_optionalChain([range, 'optionalAccess', _6 => _6.to])) return;
@@ -1066,7 +1066,7 @@ var TokenUsageReportProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
1066
1066
  pageUrl = TOKEN_USAGE_REPORT_PAGE_URL
1067
1067
  }) => {
1068
1068
  const t = _nextintl.useTranslations.call(void 0, );
1069
- const generateUrl = _chunk3M7D6NXUjs.usePageUrlGenerator.call(void 0, );
1069
+ const generateUrl = _chunkMJVEKDM4js.usePageUrlGenerator.call(void 0, );
1070
1070
  const [filters, setFilterState] = _react.useState.call(void 0, () => {
1071
1071
  const range = defaultRange2();
1072
1072
  return { from: _nullishCoalesce(initialFrom, () => ( range.from)), to: _nullishCoalesce(initialTo, () => ( range.to)) };
@@ -1130,7 +1130,7 @@ var TokenUsageReportProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
1130
1130
  () => ({ summary, timeline, byOperation, byTarget, targetPanelTitleKey, filters, setFilters, isLoading, error }),
1131
1131
  [summary, timeline, byOperation, byTarget, targetPanelTitleKey, filters, setFilters, isLoading, error]
1132
1132
  );
1133
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageReportContext.Provider, { value: contextValue, children }) });
1133
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageReportContext.Provider, { value: contextValue, children }) });
1134
1134
  }, "TokenUsageReportProvider");
1135
1135
  var useTokenUsageReport = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
1136
1136
  const ctx = _react.useContext.call(void 0, TokenUsageReportContext);
@@ -1158,7 +1158,7 @@ function TokenUsageReportTiles({ summary, metric, balances }) {
1158
1158
  const monthlyColor = monthlyPercentage > 75 ? "text-success" : monthlyPercentage >= 5 ? "text-warning" : "text-destructive";
1159
1159
  const whole = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (value) => decimal(Math.max(0, Math.floor(value)), 0), "whole");
1160
1160
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-3", children: [
1161
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { "data-testid": "tile-used", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.CardContent, { className: "grid gap-1", children: [
1161
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.Card, { "data-testid": "tile-used", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.CardContent, { className: "grid gap-1", children: [
1162
1162
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.used_in_period") }),
1163
1163
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-primary text-xl font-semibold tabular-nums", children: formatValue(_chunkC2WQXUL5js.metricValue.call(void 0, current, metric), metric) }),
1164
1164
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-center gap-1", children: [
@@ -1174,7 +1174,7 @@ function TokenUsageReportTiles({ summary, metric, balances }) {
1174
1174
  ] })
1175
1175
  ] }) }),
1176
1176
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-3 sm:grid-cols-3", children: [
1177
- balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { "data-testid": "tile-monthly", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.CardContent, { className: "grid gap-1", children: [
1177
+ balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.Card, { "data-testid": "tile-monthly", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.CardContent, { className: "grid gap-1", children: [
1178
1178
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.monthly_left") }),
1179
1179
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-baseline gap-1", children: [
1180
1180
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "data-testid": "tile-monthly-value", className: _chunk5PNDDYGLjs.cn.call(void 0, "text-sm font-medium tabular-nums", monthlyColor), children: whole(balances.availableMonthlyCredits) }),
@@ -1184,11 +1184,11 @@ function TokenUsageReportTiles({ summary, metric, balances }) {
1184
1184
  ] })
1185
1185
  ] })
1186
1186
  ] }) }),
1187
- balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { "data-testid": "tile-extra", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.CardContent, { className: "grid gap-1", children: [
1187
+ balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.Card, { "data-testid": "tile-extra", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.CardContent, { className: "grid gap-1", children: [
1188
1188
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.extra_credits") }),
1189
1189
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium tabular-nums", children: whole(balances.availableExtraCredits) })
1190
1190
  ] }) }),
1191
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { "data-testid": "tile-calls", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.CardContent, { className: "grid gap-1", children: [
1191
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.Card, { "data-testid": "tile-calls", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.CardContent, { className: "grid gap-1", children: [
1192
1192
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.calls") }),
1193
1193
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium tabular-nums", children: decimal(current.calls, 0) })
1194
1194
  ] }) })
@@ -1230,21 +1230,21 @@ function TokenUsageReportContainer({ balances = null }) {
1230
1230
  const t = _nextintl.useTranslations.call(void 0, );
1231
1231
  const { summary, timeline, byOperation, byTarget, isLoading, error, targetPanelTitleKey } = useTokenUsageReport();
1232
1232
  if (error) {
1233
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) }) }) }) });
1233
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) }) }) }) });
1234
1234
  }
1235
- if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.RoundPageContainer, { fullWidth: true, forceHeader: true });
1235
+ if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.RoundPageContainer, { fullWidth: true, forceHeader: true });
1236
1236
  const emptyLabel = t("token_usage.report.no_data");
1237
1237
  const targetTitle = targetPanelTitleKey && byTarget.length > 0 ? t(targetPanelTitleKey) : void 0;
1238
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-4 p-4", children: [
1238
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-4 p-4", children: [
1239
1239
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageReportTiles, { summary, metric: "credits", balances }),
1240
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
1241
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.report.usage_over_time") }) }),
1242
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageTimelineChart, { rows: timeline, metric: "credits", stackBy: "type" }) })
1240
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.Card, { children: [
1241
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardTitle, { children: t("token_usage.report.usage_over_time") }) }),
1242
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageTimelineChart, { rows: timeline, metric: "credits", stackBy: "type" }) })
1243
1243
  ] }),
1244
1244
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunk5PNDDYGLjs.cn.call(void 0, "grid gap-4", targetTitle && "md:grid-cols-2"), children: [
1245
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
1246
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: t("token_usage.report.by_operation") }) }),
1247
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1245
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.Card, { children: [
1246
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardTitle, { children: t("token_usage.report.by_operation") }) }),
1247
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1248
1248
  TokenUsageRankedBar,
1249
1249
  {
1250
1250
  rows: byOperation,
@@ -1254,9 +1254,9 @@ function TokenUsageReportContainer({ balances = null }) {
1254
1254
  }
1255
1255
  ) })
1256
1256
  ] }),
1257
- targetTitle && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3M7D6NXUjs.Card, { children: [
1258
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardTitle, { children: targetTitle }) }),
1259
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3M7D6NXUjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byTarget, metric: "credits", emptyLabel }) })
1257
+ targetTitle && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkMJVEKDM4js.Card, { children: [
1258
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardTitle, { children: targetTitle }) }),
1259
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMJVEKDM4js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byTarget, metric: "credits", emptyLabel }) })
1260
1260
  ] })
1261
1261
  ] })
1262
1262
  ] }) });
@@ -37,7 +37,7 @@ import {
37
37
  TableHeader,
38
38
  TableRow,
39
39
  usePageUrlGenerator
40
- } from "../../chunk-3W3VVX2N.mjs";
40
+ } from "../../chunk-HQKTQBUC.mjs";
41
41
  import "../../chunk-XTOEN5GN.mjs";
42
42
  import "../../chunk-PW42LRSL.mjs";
43
43
  import {
@@ -17,6 +17,13 @@ interface CspOptions {
17
17
  services?: CspService[];
18
18
  csp?: Partial<Record<CspDirective, string[]>>;
19
19
  }
20
+ /**
21
+ * Origins of the app's own servers, the API and the corpus, from
22
+ * `NEXT_PUBLIC_API_URL` and `NEXT_PUBLIC_CORPUS_URL`. They serve every stored
23
+ * object link, so images and frames must be allowed from them. Unset or invalid
24
+ * URLs are skipped; the result has no duplicates.
25
+ */
26
+ declare function listAppOrigins(env: NodeJS.ProcessEnv): string[];
20
27
  declare function buildCsp(options: CspOptions, env: NodeJS.ProcessEnv): string;
21
28
 
22
29
  interface NjaNextConfigOptions {
@@ -40,4 +47,4 @@ interface NjaNextConfigOptions {
40
47
  }
41
48
  declare function createNextConfig(options: NjaNextConfigOptions): NextConfig;
42
49
 
43
- export { type CspDirective, type CspService, type NjaNextConfigOptions, buildCsp, createNextConfig };
50
+ export { type CspDirective, type CspService, type NjaNextConfigOptions, buildCsp, createNextConfig, listAppOrigins };
@@ -17,6 +17,13 @@ interface CspOptions {
17
17
  services?: CspService[];
18
18
  csp?: Partial<Record<CspDirective, string[]>>;
19
19
  }
20
+ /**
21
+ * Origins of the app's own servers, the API and the corpus, from
22
+ * `NEXT_PUBLIC_API_URL` and `NEXT_PUBLIC_CORPUS_URL`. They serve every stored
23
+ * object link, so images and frames must be allowed from them. Unset or invalid
24
+ * URLs are skipped; the result has no duplicates.
25
+ */
26
+ declare function listAppOrigins(env: NodeJS.ProcessEnv): string[];
20
27
  declare function buildCsp(options: CspOptions, env: NodeJS.ProcessEnv): string;
21
28
 
22
29
  interface NjaNextConfigOptions {
@@ -40,4 +47,4 @@ interface NjaNextConfigOptions {
40
47
  }
41
48
  declare function createNextConfig(options: NjaNextConfigOptions): NextConfig;
42
49
 
43
- export { type CspDirective, type CspService, type NjaNextConfigOptions, buildCsp, createNextConfig };
50
+ export { type CspDirective, type CspService, type NjaNextConfigOptions, buildCsp, createNextConfig, listAppOrigins };
@@ -32,17 +32,31 @@ function listImageSources(env) {
32
32
  return env.IMAGE_SOURCES ? env.IMAGE_SOURCES.split(",").map((s) => s.trim()) : [];
33
33
  }
34
34
  _chunk7QVYU63Ejs.__name.call(void 0, listImageSources, "listImageSources");
35
+ function listAppOrigins(env) {
36
+ const origins = [];
37
+ for (const url of [env.NEXT_PUBLIC_API_URL, env.NEXT_PUBLIC_CORPUS_URL]) {
38
+ if (!url) continue;
39
+ try {
40
+ const { origin } = new URL(url.trim());
41
+ if (origin !== "null" && !origins.includes(origin)) origins.push(origin);
42
+ } catch (e) {
43
+ }
44
+ }
45
+ return origins;
46
+ }
47
+ _chunk7QVYU63Ejs.__name.call(void 0, listAppOrigins, "listAppOrigins");
35
48
  function buildCsp(options, env) {
36
49
  const apiUrl = env.NEXT_PUBLIC_API_URL || "";
37
50
  const imageSources = listImageSources(env);
51
+ const appOrigins = listAppOrigins(env);
38
52
  const services = _nullishCoalesce(options.services, () => ( []));
39
53
  const fetchDirectives = {
40
54
  // Scripts: self, and unsafe-inline/eval for Next.js
41
55
  "script-src": { base: ["'self'", "'unsafe-inline'", "'unsafe-eval'"], fromEnv: [] },
42
56
  // Styles: self and unsafe-inline for styled-components/emotion
43
57
  "style-src": { base: ["'self'", "'unsafe-inline'"], fromEnv: [] },
44
- // Images: self, data URIs, blobs, and configured image sources
45
- "img-src": { base: ["'self'", "data:", "blob:"], fromEnv: imageSources },
58
+ // Images: self, data URIs, blobs, configured image sources, and the api/corpus origins
59
+ "img-src": { base: ["'self'", "data:", "blob:"], fromEnv: [...imageSources, ...appOrigins] },
46
60
  // Fonts: self
47
61
  "font-src": { base: ["'self'"], fromEnv: [] },
48
62
  // Connect: self, API (http + ws for socket.io), and storage (for uploads)
@@ -56,8 +70,8 @@ function buildCsp(options, env) {
56
70
  ...imageSources
57
71
  ]
58
72
  },
59
- // Frames: self
60
- "frame-src": { base: ["'self'"], fromEnv: [] },
73
+ // Frames: self, and the api/corpus origins (inline previews of stored objects)
74
+ "frame-src": { base: ["'self'"], fromEnv: appOrigins },
61
75
  // Worker sources: self and blob (for Web Workers with dynamic imports)
62
76
  "worker-src": { base: ["'self'", "blob:"], fromEnv: [] }
63
77
  };
@@ -149,14 +163,21 @@ _chunk7QVYU63Ejs.__name.call(void 0, buildSecurityHeaders, "buildSecurityHeaders
149
163
 
150
164
  // src/next-config/index.ts
151
165
  function parseImageSources(env) {
152
- return env.IMAGE_SOURCES ? env.IMAGE_SOURCES.split(",").map((url) => {
153
- const { hostname, protocol, port } = new URL(url.trim());
154
- return {
166
+ const imageSources = env.IMAGE_SOURCES ? env.IMAGE_SOURCES.split(",").map((url) => url.trim()) : [];
167
+ const patterns = [];
168
+ for (const url of [...imageSources, ...listAppOrigins(env)]) {
169
+ const { hostname, protocol, port } = new URL(url);
170
+ const pattern = {
155
171
  protocol: protocol.replace(":", ""),
156
172
  hostname,
157
173
  port: port || void 0
158
174
  };
159
- }) : [];
175
+ const seen = patterns.some(
176
+ (p) => p.protocol === pattern.protocol && p.hostname === pattern.hostname && p.port === pattern.port
177
+ );
178
+ if (!seen) patterns.push(pattern);
179
+ }
180
+ return patterns;
160
181
  }
161
182
  _chunk7QVYU63Ejs.__name.call(void 0, parseImageSources, "parseImageSources");
162
183
  function createNextConfig(options) {
@@ -229,5 +250,6 @@ _chunk7QVYU63Ejs.__name.call(void 0, createNextConfig, "createNextConfig");
229
250
 
230
251
 
231
252
 
232
- exports.buildCsp = buildCsp; exports.createNextConfig = createNextConfig;
253
+
254
+ exports.buildCsp = buildCsp; exports.createNextConfig = createNextConfig; exports.listAppOrigins = listAppOrigins;
233
255
  //# sourceMappingURL=index.js.map