@carlonicora/nextjs-jsonapi 6.5.0 → 6.7.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 (107) hide show
  1. package/dist/{BlockNoteEditor-CT4XUXPC.js → BlockNoteEditor-BSFR2GPI.js} +19 -19
  2. package/dist/{BlockNoteEditor-CT4XUXPC.js.map → BlockNoteEditor-BSFR2GPI.js.map} +1 -1
  3. package/dist/{BlockNoteEditor-M6UQRVRK.mjs → BlockNoteEditor-HWJBQAKG.mjs} +4 -4
  4. package/dist/{BlockNoteViewer-XZJ5Y7WN.mjs → BlockNoteViewer-IIBUU7J7.mjs} +2 -2
  5. package/dist/{BlockNoteViewer-MFLWF3Y2.js → BlockNoteViewer-NHS6CCMS.js} +3 -3
  6. package/dist/{BlockNoteViewer-MFLWF3Y2.js.map → BlockNoteViewer-NHS6CCMS.js.map} +1 -1
  7. package/dist/{auth.interface-D5606g19.d.ts → auth.interface-B4tRE0k0.d.ts} +2 -0
  8. package/dist/{auth.interface-tsOuc0Fi.d.mts → auth.interface-DuX87BZ3.d.mts} +2 -0
  9. package/dist/billing/index.js +492 -492
  10. package/dist/billing/index.mjs +3 -3
  11. package/dist/{chunk-DSGP6GC3.js → chunk-3HOJNAZB.js} +8 -8
  12. package/dist/{chunk-DSGP6GC3.js.map → chunk-3HOJNAZB.js.map} +1 -1
  13. package/dist/{chunk-XZCCIKX3.js → chunk-6KE7UBYY.js} +504 -233
  14. package/dist/chunk-6KE7UBYY.js.map +1 -0
  15. package/dist/{chunk-QJIDORHM.js → chunk-73XWQA6U.js} +4 -4
  16. package/dist/{chunk-QJIDORHM.js.map → chunk-73XWQA6U.js.map} +1 -1
  17. package/dist/{chunk-DYOSXIEL.mjs → chunk-EC4PQ44E.mjs} +2 -2
  18. package/dist/{chunk-RUJCWOJE.mjs → chunk-OYRJ32KR.mjs} +2 -2
  19. package/dist/{chunk-Y7JIQNM6.js → chunk-PCCUPEBU.js} +1066 -873
  20. package/dist/chunk-PCCUPEBU.js.map +1 -0
  21. package/dist/{chunk-ELQHE2DK.js → chunk-PYDDFFQM.js} +3 -3
  22. package/dist/{chunk-ELQHE2DK.js.map → chunk-PYDDFFQM.js.map} +1 -1
  23. package/dist/{chunk-3FD6Y734.mjs → chunk-QNIWATQD.mjs} +272 -1
  24. package/dist/chunk-QNIWATQD.mjs.map +1 -0
  25. package/dist/{chunk-TIT4CJYQ.mjs → chunk-S4NKWMX5.mjs} +3729 -3536
  26. package/dist/chunk-S4NKWMX5.mjs.map +1 -0
  27. package/dist/{chunk-O2TEUH5S.mjs → chunk-XYKDBOCE.mjs} +2 -2
  28. package/dist/client/index.js +4 -4
  29. package/dist/client/index.mjs +3 -3
  30. package/dist/components/index.d.mts +39 -4
  31. package/dist/components/index.d.ts +39 -4
  32. package/dist/components/index.js +12 -4
  33. package/dist/components/index.js.map +1 -1
  34. package/dist/components/index.mjs +11 -3
  35. package/dist/contexts/index.js +4 -4
  36. package/dist/contexts/index.mjs +3 -3
  37. package/dist/core/index.d.mts +144 -5
  38. package/dist/core/index.d.ts +144 -5
  39. package/dist/core/index.js +18 -2
  40. package/dist/core/index.js.map +1 -1
  41. package/dist/core/index.mjs +17 -1
  42. package/dist/email-automations/index.js +92 -92
  43. package/dist/email-automations/index.mjs +3 -3
  44. package/dist/features/analytics/index.js +121 -121
  45. package/dist/features/analytics/index.mjs +4 -4
  46. package/dist/features/analytics/server.js +4 -4
  47. package/dist/features/analytics/server.mjs +2 -2
  48. package/dist/features/blog/index.js +150 -150
  49. package/dist/features/blog/index.mjs +3 -3
  50. package/dist/features/blog/server.js +16 -16
  51. package/dist/features/blog/server.mjs +1 -1
  52. package/dist/features/help/index.js +37 -37
  53. package/dist/features/help/index.mjs +3 -3
  54. package/dist/features/tokenusage/index.js +127 -127
  55. package/dist/features/tokenusage/index.mjs +4 -4
  56. package/dist/index.d.mts +3 -3
  57. package/dist/index.d.ts +3 -3
  58. package/dist/index.js +19 -3
  59. package/dist/index.js.map +1 -1
  60. package/dist/index.mjs +18 -2
  61. package/dist/{s3.service-CzFBDEuQ.d.mts → s3.service-CRGJbO-6.d.mts} +18 -2
  62. package/dist/{s3.service-BTCpmp5g.d.ts → s3.service-DZG-VyLY.d.ts} +18 -2
  63. package/dist/server/index.d.mts +2 -2
  64. package/dist/server/index.d.ts +2 -2
  65. package/dist/server/index.js +3 -3
  66. package/dist/server/index.mjs +2 -2
  67. package/messages/en.json +24 -0
  68. package/messages/it.json +24 -0
  69. package/package.json +1 -1
  70. package/src/components/index.ts +1 -0
  71. package/src/core/index.ts +6 -0
  72. package/src/core/registry/ModuleRegistry.ts +15 -0
  73. package/src/features/account-deletion/account-deletion.module.ts +13 -0
  74. package/src/features/account-deletion/components/AccountDeletionAdminTrigger.tsx +183 -0
  75. package/src/features/account-deletion/components/AccountDeletionCancelledNotice.tsx +51 -0
  76. package/src/features/account-deletion/components/AccountDeletionKeepContainer.tsx +74 -0
  77. package/src/features/account-deletion/components/index.ts +3 -0
  78. package/src/features/account-deletion/data/__tests__/AccountDeletion.spec.ts +89 -0
  79. package/src/features/account-deletion/data/account-deletion.interface.ts +22 -0
  80. package/src/features/account-deletion/data/account-deletion.service.ts +69 -0
  81. package/src/features/account-deletion/data/account-deletion.ts +90 -0
  82. package/src/features/account-deletion/data/index.ts +3 -0
  83. package/src/features/account-deletion/index.ts +4 -0
  84. package/src/features/account-deletion/utils/__tests__/account-deletion-notice.spec.ts +40 -0
  85. package/src/features/account-deletion/utils/account-deletion-notice.ts +27 -0
  86. package/src/features/account-deletion/utils/index.ts +1 -0
  87. package/src/features/auth/components/forms/Cookies.tsx +3 -0
  88. package/src/features/auth/components/forms/TwoFactorChallenge.tsx +2 -0
  89. package/src/features/auth/data/__tests__/auth.spec.ts +36 -0
  90. package/src/features/auth/data/__tests__/pending-registration.spec.ts +37 -0
  91. package/src/features/auth/data/auth.interface.ts +2 -0
  92. package/src/features/auth/data/auth.service.ts +23 -0
  93. package/src/features/auth/data/auth.ts +7 -0
  94. package/src/features/auth/data/index.ts +2 -0
  95. package/src/features/auth/data/pending-registration.interface.ts +10 -0
  96. package/src/features/auth/data/pending-registration.ts +57 -0
  97. package/src/features/auth/pending-registration.module.ts +9 -0
  98. package/src/features/user/contexts/UserContext.tsx +8 -0
  99. package/dist/chunk-3FD6Y734.mjs.map +0 -1
  100. package/dist/chunk-TIT4CJYQ.mjs.map +0 -1
  101. package/dist/chunk-XZCCIKX3.js.map +0 -1
  102. package/dist/chunk-Y7JIQNM6.js.map +0 -1
  103. /package/dist/{BlockNoteEditor-M6UQRVRK.mjs.map → BlockNoteEditor-HWJBQAKG.mjs.map} +0 -0
  104. /package/dist/{BlockNoteViewer-XZJ5Y7WN.mjs.map → BlockNoteViewer-IIBUU7J7.mjs.map} +0 -0
  105. /package/dist/{chunk-DYOSXIEL.mjs.map → chunk-EC4PQ44E.mjs.map} +0 -0
  106. /package/dist/{chunk-RUJCWOJE.mjs.map → chunk-OYRJ32KR.mjs.map} +0 -0
  107. /package/dist/{chunk-O2TEUH5S.mjs.map → chunk-XYKDBOCE.mjs.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkXZCCIKX3js = require('./chunk-XZCCIKX3.js');
3
+ var _chunk6KE7UBYYjs = require('./chunk-6KE7UBYY.js');
4
4
 
5
5
 
6
6
  var _chunk7QVYU63Ejs = require('./chunk-7QVYU63E.js');
@@ -43,7 +43,7 @@ function createUsageFormatters(locale, currency) {
43
43
  _chunk7QVYU63Ejs.__name.call(void 0, createUsageFormatters, "createUsageFormatters");
44
44
  function useUsageFormatters() {
45
45
  const locale = _nextintl.useLocale.call(void 0, );
46
- const currency = _chunkXZCCIKX3js.getTokenUsageCurrency.call(void 0, );
46
+ const currency = _chunk6KE7UBYYjs.getTokenUsageCurrency.call(void 0, );
47
47
  return _react.useMemo.call(void 0, () => createUsageFormatters(locale, currency), [locale, currency]);
48
48
  }
49
49
  _chunk7QVYU63Ejs.__name.call(void 0, useUsageFormatters, "useUsageFormatters");
@@ -112,4 +112,4 @@ _chunk7QVYU63Ejs.__name.call(void 0, percentageDelta, "percentageDelta");
112
112
 
113
113
 
114
114
  exports.createUsageFormatters = createUsageFormatters; exports.useUsageFormatters = useUsageFormatters; exports.metricValue = metricValue; exports.cacheHitPercentage = cacheHitPercentage; exports.percentageDelta = percentageDelta; exports.CATEGORICAL_CEILING = CATEGORICAL_CEILING; exports.OTHER_COLOR = OTHER_COLOR; exports.SEQUENTIAL_RAMP = SEQUENTIAL_RAMP; exports.seriesColor = seriesColor; exports.seriesTheme = seriesTheme;
115
- //# sourceMappingURL=chunk-ELQHE2DK.js.map
115
+ //# sourceMappingURL=chunk-PYDDFFQM.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-ELQHE2DK.js","../src/features/tokenusage/lib/formatters.ts","../src/features/tokenusage/lib/palette.ts","../src/features/tokenusage/lib/metrics.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACLA,qCAA0B;AAC1B,8BAAwB;AAsCjB,SAAS,qBAAA,CAAsB,MAAA,EAAgB,QAAA,EAAmC;AACvF,EAAA,MAAM,OAAA,mCACJ,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,EAAQ,EAAE,KAAA,EAAO,UAAA,EAAY,QAAA,EAAU,eAAA,EAAiB,eAAe,CAAC,CAAA,mBAC3F,aAAA,mBAAc,CAAC,CAAA,qBACf,IAAA,mBAAK,CAAC,IAAA,EAAA,GAAS,IAAA,CAAK,KAAA,IAAS,UAAU,CAAA,6BAAG,OAAA,UAAS,UAAA;AAExD,EAAA,MAAM,QAAA,kBAAU,qCAAA,CAAC,KAAA,EAAe,QAAA,EAAA,GAC9B,KAAA,CAAM,cAAA,CAAe,MAAA,EAAQ,EAAE,qBAAA,EAAuB,QAAA,EAAU,qBAAA,EAAuB,SAAS,CAAC,CAAA,EADnF,SAAA,CAAA;AAGhB,EAAA,MAAM,UAAA,EAAY,IAAI,IAAA,CAAK,cAAA,CAAe,MAAA,EAAQ,EAAE,GAAA,EAAK,SAAA,EAAW,KAAA,EAAO,OAAA,EAAS,QAAA,EAAU,MAAM,CAAC,CAAA;AACrG,EAAA,MAAM,YAAA,EAAc,IAAI,IAAA,CAAK,cAAA,CAAe,MAAA,EAAQ,EAAE,KAAA,EAAO,OAAA,EAAS,IAAA,EAAM,SAAA,EAAW,QAAA,EAAU,MAAM,CAAC,CAAA;AAKxG,EAAA,MAAM,cAAA,EAAgB,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,EAAQ,EAAE,QAAA,EAAU,SAAA,EAAW,wBAAA,EAA0B,EAAE,CAAC,CAAA;AACxG,EAAA,MAAM,SAAA,EAAW,IAAI,IAAA,CAAK,QAAA,CAAS,MAAM,CAAA;AAEzC,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IAEA,WAAA,CAAY,KAAA,EAAO,MAAA,EAAQ;AACzB,MAAA,GAAA,CAAI,OAAA,IAAW,MAAA,EAAQ,OAAO,CAAA,EAAA;AAIJ,MAAA;AACH,MAAA;AACzB,IAAA;AAE0B,IAAA;AACI,MAAA;AAC9B,IAAA;AAE6B,IAAA;AACF,MAAA;AAC3B,IAAA;AAEe,IAAA;AACe,MAAA;AAC9B,IAAA;AAE6B,IAAA;AACd,MAAA;AACU,MAAA;AACzB,IAAA;AAEc,IAAA;AACgB,MAAA;AAC9B,IAAA;AACF,EAAA;AACF;AAnDgB;AA0DsC;AAC3B,EAAA;AACR,EAAA;AACI,EAAA;AACvB;AAJgB;ADlDqB;AACA;AE0EQ;AAC3C,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACF;AAG4C;AAC1C,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACF;AAcmC;AAOR;AAcuB;AAUA;AAE3B;AAYsC;AACjC,EAAA;AACO,EAAA;AACnC;AAHgB;AAS4D;AACvC,EAAA;AACrC;AAFgB;AFhIqB;AACA;AG3DuC;AACxC,EAAA;AACD,EAAA;AACP,EAAA;AAC5B;AAJgB;AAUmC;AAC3B,EAAA;AACO,EAAA;AAC/B;AAHgB;AAYiC;AACzB,EAAA;AACQ,EAAA;AAChC;AAHgB;AHsDqB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-ELQHE2DK.js","sourcesContent":[null,"\"use client\";\n\nimport { useLocale } from \"next-intl\";\nimport { useMemo } from \"react\";\nimport type { Metric } from \"../data/tokenusage-admin.types\";\nimport { getTokenUsageCurrency } from \"./config\";\n\nexport type UsageFormatters = {\n /** Locale-aware fixed-decimal number, e.g. 9.46 → \"9,46\" in it-IT. */\n decimal(value: number, decimals: number): string;\n /** Currency for cost, 2 decimals for credits, whole numbers for tokens. */\n metricValue(value: number, metric: Metric): string;\n /** Currency with an explicit decimal count — the per-call tile needs 4. */\n currency(value: number, decimals: number): string;\n /** Percentage with one decimal by default, e.g. 60 → \"60,0 %\" in it-IT. */\n percent(value: number, decimals?: number): string;\n /** Compact notation for axis ticks, e.g. 1500000 → \"1,5 Mln\" in it-IT. */\n compact(value: number): string;\n /** A \"YYYY-MM-DD\" bucket key rendered as an axis or tooltip label, in UTC. */\n bucketDate(iso: string, granularity: \"day\" | \"week\" | \"month\"): string;\n /** Locale collation for client-side table sorting. */\n compare(a: string, b: string): number;\n};\n\n/**\n * Builds every formatter the token-usage surfaces need, for one locale and one\n * currency.\n *\n * A pure factory on purpose: it takes no React context, so the arithmetic and\n * the formatting are unit-testable without rendering, and a server component or\n * a test can construct a set for an arbitrary locale.\n *\n * The currency symbol is placed with a space rather than through\n * `style: \"currency\"`, which is what the previous hard-coded implementation\n * rendered (\"€ 9,46\"). Keeping that shape means a consuming app on EUR sees\n * byte-identical output after this refactor.\n *\n * `bucketDate` formats in UTC, always. The wire value is a `type: \"date\"` — a\n * calendar day — parsed to UTC midnight; reading it back with local getters\n * would shift the label a day early west of UTC.\n */\nexport function createUsageFormatters(locale: string, currency: string): UsageFormatters {\n const symbol =\n new Intl.NumberFormat(locale, { style: \"currency\", currency, currencyDisplay: \"narrowSymbol\" })\n .formatToParts(0)\n .find((part) => part.type === \"currency\")?.value ?? currency;\n\n const decimal = (value: number, decimals: number): string =>\n value.toLocaleString(locale, { minimumFractionDigits: decimals, maximumFractionDigits: decimals });\n\n const dayFormat = new Intl.DateTimeFormat(locale, { day: \"numeric\", month: \"short\", timeZone: \"UTC\" });\n const monthFormat = new Intl.DateTimeFormat(locale, { month: \"short\", year: \"numeric\", timeZone: \"UTC\" });\n // Axis ticks step by 1, 2, 2.5 or 5 times a power of ten, so a tick never needs\n // more than three significant digits. A fixed one-decimal cap rounded a 0.05\n // step into repeated labels (0.1, 0.1, 0.2, 0.2); significant digits keep every\n // tick distinct at any scale (0.05, 0.15, 1.25K).\n const compactFormat = new Intl.NumberFormat(locale, { notation: \"compact\", maximumSignificantDigits: 3 });\n const collator = new Intl.Collator(locale);\n\n return {\n decimal,\n\n metricValue(value, metric) {\n if (metric === \"cost\") return `${symbol} ${decimal(value, 2)}`;\n // Credits are stored to 4 decimals (round4(cost / creditCost)), but that\n // precision is noise to a reader comparing rows: one decimal is enough to\n // separate two values and keeps the columns narrow enough to scan.\n if (metric === \"credits\") return decimal(value, 1);\n return decimal(value, 0);\n },\n\n currency(value, decimals) {\n return `${symbol} ${decimal(value, decimals)}`;\n },\n\n percent(value, decimals = 1) {\n return `${decimal(value, decimals)} %`;\n },\n\n compact(value) {\n return compactFormat.format(value);\n },\n\n bucketDate(iso, granularity) {\n const date = new Date(`${iso}T00:00:00.000Z`);\n return granularity === \"month\" ? monthFormat.format(date) : dayFormat.format(date);\n },\n\n compare(a, b) {\n return collator.compare(a, b);\n },\n };\n}\n\n/**\n * The formatter set for the current request's locale and the app's configured\n * currency. Memoised on both, so the Intl objects are built once per locale\n * rather than on every render.\n */\nexport function useUsageFormatters(): UsageFormatters {\n const locale = useLocale();\n const currency = getTokenUsageCurrency();\n return useMemo(() => createUsageFormatters(locale, currency), [locale, currency]);\n}\n","/**\n * Chart palette for the administrative token-usage dashboard.\n *\n * Every value here is a documented step of the dataviz skill's reference ramps —\n * nothing was eyeballed, nothing was hand-mixed. The palette was run through the\n * skill's validator against THIS application's real chart surfaces in both modes.\n * The verbatim output is below.\n *\n * The surface is `--card`, NOT `--background`. Every chart that uses this palette\n * is painted inside a `<Card>`, so the card is the surface the marks actually sit\n * on — and in dark mode it is the *lighter* of the two (`oklch(0.205 0 0)` vs the\n * background's `oklch(0.145 0 0)`), which is the harder case for contrast. Taken\n * from `apps/web/src/app/globals.css` (narr8 declares two `:root`/`.dark` pairs;\n * the LATER pair wins, and it is the one read here) — light `oklch(1 0 0)`, dark\n * `oklch(0.205 0 0)`. a360ai declares the same two values.\n *\n * oklch→hex conversion: the algebraic inverse of the Björn Ottosson OKLab\n * matrices — the same matrices the validator applies in the forward direction —\n * giving light `#ffffff` and dark `#171717`. Cross-checked by feeding it the\n * previously recorded background value, which it reproduces exactly:\n * `oklch(0.145 0 0)` → `#0a0a0a`. ✓\n *\n * Light and dark are two SELECTED sets of steps, chosen for their own surface —\n * never one set with its lightness flipped at runtime. Consumers pick a set from\n * the resolved theme (`seriesColor(i, mode)` / `sequentialColor(i, mode)`).\n *\n * ---------------------------------------------------------------------------\n * VALIDATOR OUTPUT — dataviz `scripts/validate_palette.js`, run 2026-08-15\n * ---------------------------------------------------------------------------\n *\n * $ node scripts/validate_palette.js \"#2a78d6,#eb6834,#1baf7a,#eda100,#e87ba4,#008300,#4a3aa7\" --mode light --surface \"#ffffff\"\n *\n * Palette (light, surface #ffffff, categorical): 7 slots\n * [PASS] Lightness band all 7 inside L 0.43–0.77\n * [PASS] Chroma floor all 7 >= 0.1\n * [PASS] CVD separation worst adjacent #eda100↔#1baf7a ΔE 9.1 (protan) · tritan 5.8\n * [PASS] Normal-vision floor worst adjacent #e87ba4↔#eda100 ΔE 19.6 (normal)\n * [WARN] Contrast vs surface below 3:1 — relief required (visible labels or table view): [[\"#1baf7a\",2.82],[\"#eda100\",2.17],[\"#e87ba4\",2.69]]\n *\n * → ALL CHECKS PASS (CVD in the 6–8 floor band is legal ONLY with secondary encoding: direct labels, gaps, or texture)\n * scope: categorical palettes only. For a lone status/text color check WCAG text contrast; for a sequential ramp, lightness monotonicity.\n *\n * $ node scripts/validate_palette.js \"#3987e5,#d95926,#199e70,#c98500,#d55181,#008300,#9085e9\" --mode dark --surface \"#171717\"\n *\n * Palette (dark, surface #171717, categorical): 7 slots\n * [PASS] Lightness band all 7 inside L 0.48–0.67\n * [PASS] Chroma floor all 7 >= 0.1\n * [PASS] CVD separation worst adjacent #c98500↔#199e70 ΔE 8.4 (protan) · tritan 8.7\n * [PASS] Normal-vision floor worst adjacent #d55181↔#c98500 ΔE 19.3 (normal)\n * [PASS] Contrast vs surface all 7 >= 3:1\n *\n * → ALL CHECKS PASS (CVD in the 6–8 floor band is legal ONLY with secondary encoding: direct labels, gaps, or texture)\n * scope: categorical palettes only. For a lone status/text color check WCAG text contrast; for a sequential ramp, lightness monotonicity.\n *\n * $ node scripts/validate_palette.js \"#104281,#1c5cab,#2a78d6,#5598e7,#86b6ef\" --mode light --surface \"#ffffff\" --ordinal\n *\n * Palette (light, surface #ffffff, ordinal ramp): 5 slots\n * [PASS] Lightness monotone steps read light→dark\n * [PASS] Adjacent ΔL all gaps >= 0.06\n * [PASS] Light-end contrast #86b6ef at 2.11:1 vs surface\n * [PASS] Single hue hue spread 3°\n *\n * → ALL CHECKS PASS (ordinal: one hue, monotone L, visible step gaps, light end clears surface)\n *\n * $ node scripts/validate_palette.js \"#9ec5f4,#6da7ec,#3987e5,#256abf,#184f95\" --mode dark --surface \"#171717\" --ordinal\n *\n * Palette (dark, surface #171717, ordinal ramp): 5 slots\n * [PASS] Lightness monotone steps read light→dark\n * [PASS] Adjacent ΔL all gaps >= 0.06\n * [PASS] Light-end contrast #184f95 at 2.21:1 vs surface\n * [PASS] Single hue hue spread 3°\n *\n * → ALL CHECKS PASS (ordinal: one hue, monotone L, visible step gaps, light end clears surface)\n *\n * OTHER_COLOR is achromatic, so the categorical checks (which gate hue identity)\n * do not apply to it; it was gated on contrast alone with the validator's own\n * `contrast()` export: 3.59:1 on `#ffffff`, 4.99:1 on `#171717` — both clear 3:1.\n *\n * ---------------------------------------------------------------------------\n * WHAT THE RESULTS OBLIGE US TO DO\n * ---------------------------------------------------------------------------\n *\n * - NO COLOUR VALUE CHANGED in the move from `--background` to `--card`. Every\n * gate that passed on the background still passes on the card, so re-stepping\n * a hue would have been churn, not a fix. Only the recorded surface, the\n * recorded numbers and this prose changed.\n * - The dark set still clears 3:1 on the LIGHTER card surface: the worst slot is\n * green `#008300` at 3.63:1, and the ordinal ramp's surface-nearest step lands\n * at 2.21:1 (down from 2.44:1 on the background) — still above the 2:1 gate.\n * That headroom is thin, so a future card-surface lightening MUST re-run these\n * four commands rather than assume the set still holds.\n * - The light-mode contrast WARN is NOT dismissable. Three slots (aqua, yellow,\n * magenta) sit below 3:1 on white, so every surface that paints with this\n * palette MUST ship the relief channel: a visible legend, direct labels and a\n * tooltip carrying the value in text. The timeline chart and the breakdown\n * table both do. The light card is `#ffffff`, identical to the light\n * background, so this WARN is unchanged rather than newly incurred.\n * - CVD separation is measured on ADJACENT pairs, which is the correct pairlist\n * for stacked bars, grouped bars and lines — the only forms this palette paints.\n * A scatter / bubble / small-multiples chart would need `--pairs all`, which\n * caps the usable slot count at three; do not reuse this array there without\n * re-running the validator with that flag.\n */\n\n/** Which surface the colours are being painted on. */\nexport type ChartMode = \"light\" | \"dark\";\n\n/**\n * The chart surfaces the palette was validated against (globals.css `--card`).\n *\n * `--card`, never `--background`: the charts are painted inside a `<Card>`.\n */\nexport const CHART_SURFACE: Readonly<Record<ChartMode, string>> = {\n light: \"#ffffff\",\n dark: \"#171717\",\n};\n\n/**\n * Categorical slots, in FIXED order. Slot n is series n — the order is the\n * CVD-safety mechanism, not decoration, so it is never re-ordered and never\n * cycled. The two-series default (customer / platform) takes slots 0 and 1.\n *\n * Hues, in order: blue, orange, aqua, yellow, magenta, green, violet.\n */\nconst CATEGORICAL_LIGHT: readonly string[] = [\n \"#2a78d6\",\n \"#eb6834\",\n \"#1baf7a\",\n \"#eda100\",\n \"#e87ba4\",\n \"#008300\",\n \"#4a3aa7\",\n];\n\n/** The same seven hues, re-stepped for the dark surface. Not a lightness flip. */\nconst CATEGORICAL_DARK: readonly string[] = [\n \"#3987e5\",\n \"#d95926\",\n \"#199e70\",\n \"#c98500\",\n \"#d55181\",\n \"#008300\",\n \"#9085e9\",\n];\n\n/**\n * The default (light-surface) categorical set.\n *\n * Prefer `seriesColor(index, mode)` — this array exists for consumers that only\n * need the documented default order.\n */\nexport const CATEGORICAL: readonly string[] = CATEGORICAL_LIGHT;\n\n/**\n * How many series may carry their own identity hue. An 8th series is NEVER a\n * generated hue: it folds into `other`.\n */\nexport const CATEGORICAL_CEILING = CATEGORICAL_LIGHT.length;\n\n/**\n * The \"other\" rollup colour: deliberately achromatic so it reads as \"not an\n * identity\" beside the seven hues. Same step in both modes — it clears 3:1 on\n * both card surfaces (3.59:1 on `#ffffff`, 4.99:1 on `#171717`).\n */\nexport const OTHER_COLOR = \"#898781\";\n\n/**\n * Sequential (single-hue, blue) ramp for MAGNITUDE, indexed by rank position:\n * index 0 is rank 1 — the largest value — so the strongest step leads.\n *\n * On the light surface \"strongest\" is the darkest step; on the dark surface it\n * is the lightest. The anchor flips with the surface, which is why there are two\n * selected sets rather than one array reversed at runtime.\n *\n * Five steps, not eight: with the adjacent-ΔL ≥ 0.06 gate and the ≥ 2:1\n * surface-contrast gate on the step nearest the surface, the blue ramp fits\n * exactly five distinguishable steps. Consumers clamp past the end.\n */\nconst SEQUENTIAL_RAMP_LIGHT: readonly string[] = [\"#104281\", \"#1c5cab\", \"#2a78d6\", \"#5598e7\", \"#86b6ef\"];\n\nconst SEQUENTIAL_RAMP_DARK: readonly string[] = [\"#9ec5f4\", \"#6da7ec\", \"#3987e5\", \"#256abf\", \"#184f95\"];\n\n/**\n * The default (light-surface) sequential ramp.\n *\n * Prefer `sequentialColor(index, mode)` — this array exists for consumers that\n * only need the documented default.\n */\nexport const SEQUENTIAL_RAMP: readonly string[] = SEQUENTIAL_RAMP_LIGHT;\n\nconst categoricalSet = (mode: ChartMode): readonly string[] => (mode === \"dark\" ? CATEGORICAL_DARK : CATEGORICAL_LIGHT);\n\nconst sequentialSet = (mode: ChartMode): readonly string[] =>\n mode === \"dark\" ? SEQUENTIAL_RAMP_DARK : SEQUENTIAL_RAMP_LIGHT;\n\n/**\n * The identity colour for series `index`.\n *\n * Never generates a hue and never cycles: anything at or past the ceiling gets\n * `OTHER_COLOR`, because a series past the ceiling should already have been\n * folded into the \"other\" bucket by the caller.\n */\nexport function seriesColor(index: number, mode: ChartMode = \"light\"): string {\n if (index < 0 || index >= CATEGORICAL_CEILING) return OTHER_COLOR;\n return categoricalSet(mode)[index];\n}\n\n/**\n * Both mode steps for series `index`, shaped for a shadcn `ChartConfig` entry's\n * `theme` field.\n */\nexport function seriesTheme(index: number): { light: string; dark: string } {\n return { light: seriesColor(index, \"light\"), dark: seriesColor(index, \"dark\") };\n}\n\n/**\n * The magnitude colour for rank position `index`, clamped to the last step so a\n * long list keeps its weakest step rather than falling off the ramp.\n */\nexport function sequentialColor(index: number, mode: ChartMode = \"light\"): string {\n const ramp = sequentialSet(mode);\n const clamped = Math.min(Math.max(index, 0), ramp.length - 1);\n return ramp[clamped];\n}\n","import type { Metric } from \"../data/tokenusage-admin.types\";\n\n/**\n * Locale-free arithmetic for the token-usage surfaces.\n *\n * Everything that turns a number into a STRING lives in `./formatters` instead,\n * because it depends on the request's locale and the app's configured currency.\n * This file stays pure arithmetic so it needs neither.\n */\n\n/**\n * The metric field set every admin token-usage resource carries. Declared\n * structurally so it accepts the summary, timeline and breakdown interfaces\n * alike — all three expose exactly these getters.\n */\nexport type TokenUsageMetrics = {\n cost: number;\n credits: number;\n tokensIn: number;\n tokensOut: number;\n cached: number;\n calls: number;\n};\n\n/** Reads the single number a row contributes for the currently selected metric. */\nexport function metricValue(row: TokenUsageMetrics, metric: Metric): number {\n if (metric === \"cost\") return row.cost;\n if (metric === \"credits\") return row.credits;\n return row.tokensIn + row.tokensOut;\n}\n\n/**\n * Share of cached input tokens. Returns 0 rather than NaN when the window holds\n * no input tokens at all, so the tile renders \"0,0 %\" instead of \"NaN %\".\n */\nexport function cacheHitPercentage(cached: number, tokensIn: number): number {\n if (!tokensIn) return 0;\n return (cached / tokensIn) * 100;\n}\n\n/**\n * Percentage change of `current` against `previous`, rounded to a whole number.\n *\n * Returns `undefined` when the previous window is zero — there is no meaningful\n * percentage change from nothing, and rendering Infinity would be worse than\n * rendering nothing. Callers show an em dash in that slot.\n */\nexport function percentageDelta(current: number, previous: number): number | undefined {\n if (!previous) return undefined;\n return Math.round(((current - previous) / previous) * 100);\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-PYDDFFQM.js","../src/features/tokenusage/lib/formatters.ts","../src/features/tokenusage/lib/palette.ts","../src/features/tokenusage/lib/metrics.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACLA,qCAA0B;AAC1B,8BAAwB;AAsCjB,SAAS,qBAAA,CAAsB,MAAA,EAAgB,QAAA,EAAmC;AACvF,EAAA,MAAM,OAAA,mCACJ,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,EAAQ,EAAE,KAAA,EAAO,UAAA,EAAY,QAAA,EAAU,eAAA,EAAiB,eAAe,CAAC,CAAA,mBAC3F,aAAA,mBAAc,CAAC,CAAA,qBACf,IAAA,mBAAK,CAAC,IAAA,EAAA,GAAS,IAAA,CAAK,KAAA,IAAS,UAAU,CAAA,6BAAG,OAAA,UAAS,UAAA;AAExD,EAAA,MAAM,QAAA,kBAAU,qCAAA,CAAC,KAAA,EAAe,QAAA,EAAA,GAC9B,KAAA,CAAM,cAAA,CAAe,MAAA,EAAQ,EAAE,qBAAA,EAAuB,QAAA,EAAU,qBAAA,EAAuB,SAAS,CAAC,CAAA,EADnF,SAAA,CAAA;AAGhB,EAAA,MAAM,UAAA,EAAY,IAAI,IAAA,CAAK,cAAA,CAAe,MAAA,EAAQ,EAAE,GAAA,EAAK,SAAA,EAAW,KAAA,EAAO,OAAA,EAAS,QAAA,EAAU,MAAM,CAAC,CAAA;AACrG,EAAA,MAAM,YAAA,EAAc,IAAI,IAAA,CAAK,cAAA,CAAe,MAAA,EAAQ,EAAE,KAAA,EAAO,OAAA,EAAS,IAAA,EAAM,SAAA,EAAW,QAAA,EAAU,MAAM,CAAC,CAAA;AAKxG,EAAA,MAAM,cAAA,EAAgB,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,EAAQ,EAAE,QAAA,EAAU,SAAA,EAAW,wBAAA,EAA0B,EAAE,CAAC,CAAA;AACxG,EAAA,MAAM,SAAA,EAAW,IAAI,IAAA,CAAK,QAAA,CAAS,MAAM,CAAA;AAEzC,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IAEA,WAAA,CAAY,KAAA,EAAO,MAAA,EAAQ;AACzB,MAAA,GAAA,CAAI,OAAA,IAAW,MAAA,EAAQ,OAAO,CAAA,EAAA;AAIJ,MAAA;AACH,MAAA;AACzB,IAAA;AAE0B,IAAA;AACI,MAAA;AAC9B,IAAA;AAE6B,IAAA;AACF,MAAA;AAC3B,IAAA;AAEe,IAAA;AACe,MAAA;AAC9B,IAAA;AAE6B,IAAA;AACd,MAAA;AACU,MAAA;AACzB,IAAA;AAEc,IAAA;AACgB,MAAA;AAC9B,IAAA;AACF,EAAA;AACF;AAnDgB;AA0DsC;AAC3B,EAAA;AACR,EAAA;AACI,EAAA;AACvB;AAJgB;ADlDqB;AACA;AE0EQ;AAC3C,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACF;AAG4C;AAC1C,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACF;AAcmC;AAOR;AAcuB;AAUA;AAE3B;AAYsC;AACjC,EAAA;AACO,EAAA;AACnC;AAHgB;AAS4D;AACvC,EAAA;AACrC;AAFgB;AFhIqB;AACA;AG3DuC;AACxC,EAAA;AACD,EAAA;AACP,EAAA;AAC5B;AAJgB;AAUmC;AAC3B,EAAA;AACO,EAAA;AAC/B;AAHgB;AAYiC;AACzB,EAAA;AACQ,EAAA;AAChC;AAHgB;AHsDqB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-PYDDFFQM.js","sourcesContent":[null,"\"use client\";\n\nimport { useLocale } from \"next-intl\";\nimport { useMemo } from \"react\";\nimport type { Metric } from \"../data/tokenusage-admin.types\";\nimport { getTokenUsageCurrency } from \"./config\";\n\nexport type UsageFormatters = {\n /** Locale-aware fixed-decimal number, e.g. 9.46 → \"9,46\" in it-IT. */\n decimal(value: number, decimals: number): string;\n /** Currency for cost, 2 decimals for credits, whole numbers for tokens. */\n metricValue(value: number, metric: Metric): string;\n /** Currency with an explicit decimal count — the per-call tile needs 4. */\n currency(value: number, decimals: number): string;\n /** Percentage with one decimal by default, e.g. 60 → \"60,0 %\" in it-IT. */\n percent(value: number, decimals?: number): string;\n /** Compact notation for axis ticks, e.g. 1500000 → \"1,5 Mln\" in it-IT. */\n compact(value: number): string;\n /** A \"YYYY-MM-DD\" bucket key rendered as an axis or tooltip label, in UTC. */\n bucketDate(iso: string, granularity: \"day\" | \"week\" | \"month\"): string;\n /** Locale collation for client-side table sorting. */\n compare(a: string, b: string): number;\n};\n\n/**\n * Builds every formatter the token-usage surfaces need, for one locale and one\n * currency.\n *\n * A pure factory on purpose: it takes no React context, so the arithmetic and\n * the formatting are unit-testable without rendering, and a server component or\n * a test can construct a set for an arbitrary locale.\n *\n * The currency symbol is placed with a space rather than through\n * `style: \"currency\"`, which is what the previous hard-coded implementation\n * rendered (\"€ 9,46\"). Keeping that shape means a consuming app on EUR sees\n * byte-identical output after this refactor.\n *\n * `bucketDate` formats in UTC, always. The wire value is a `type: \"date\"` — a\n * calendar day — parsed to UTC midnight; reading it back with local getters\n * would shift the label a day early west of UTC.\n */\nexport function createUsageFormatters(locale: string, currency: string): UsageFormatters {\n const symbol =\n new Intl.NumberFormat(locale, { style: \"currency\", currency, currencyDisplay: \"narrowSymbol\" })\n .formatToParts(0)\n .find((part) => part.type === \"currency\")?.value ?? currency;\n\n const decimal = (value: number, decimals: number): string =>\n value.toLocaleString(locale, { minimumFractionDigits: decimals, maximumFractionDigits: decimals });\n\n const dayFormat = new Intl.DateTimeFormat(locale, { day: \"numeric\", month: \"short\", timeZone: \"UTC\" });\n const monthFormat = new Intl.DateTimeFormat(locale, { month: \"short\", year: \"numeric\", timeZone: \"UTC\" });\n // Axis ticks step by 1, 2, 2.5 or 5 times a power of ten, so a tick never needs\n // more than three significant digits. A fixed one-decimal cap rounded a 0.05\n // step into repeated labels (0.1, 0.1, 0.2, 0.2); significant digits keep every\n // tick distinct at any scale (0.05, 0.15, 1.25K).\n const compactFormat = new Intl.NumberFormat(locale, { notation: \"compact\", maximumSignificantDigits: 3 });\n const collator = new Intl.Collator(locale);\n\n return {\n decimal,\n\n metricValue(value, metric) {\n if (metric === \"cost\") return `${symbol} ${decimal(value, 2)}`;\n // Credits are stored to 4 decimals (round4(cost / creditCost)), but that\n // precision is noise to a reader comparing rows: one decimal is enough to\n // separate two values and keeps the columns narrow enough to scan.\n if (metric === \"credits\") return decimal(value, 1);\n return decimal(value, 0);\n },\n\n currency(value, decimals) {\n return `${symbol} ${decimal(value, decimals)}`;\n },\n\n percent(value, decimals = 1) {\n return `${decimal(value, decimals)} %`;\n },\n\n compact(value) {\n return compactFormat.format(value);\n },\n\n bucketDate(iso, granularity) {\n const date = new Date(`${iso}T00:00:00.000Z`);\n return granularity === \"month\" ? monthFormat.format(date) : dayFormat.format(date);\n },\n\n compare(a, b) {\n return collator.compare(a, b);\n },\n };\n}\n\n/**\n * The formatter set for the current request's locale and the app's configured\n * currency. Memoised on both, so the Intl objects are built once per locale\n * rather than on every render.\n */\nexport function useUsageFormatters(): UsageFormatters {\n const locale = useLocale();\n const currency = getTokenUsageCurrency();\n return useMemo(() => createUsageFormatters(locale, currency), [locale, currency]);\n}\n","/**\n * Chart palette for the administrative token-usage dashboard.\n *\n * Every value here is a documented step of the dataviz skill's reference ramps —\n * nothing was eyeballed, nothing was hand-mixed. The palette was run through the\n * skill's validator against THIS application's real chart surfaces in both modes.\n * The verbatim output is below.\n *\n * The surface is `--card`, NOT `--background`. Every chart that uses this palette\n * is painted inside a `<Card>`, so the card is the surface the marks actually sit\n * on — and in dark mode it is the *lighter* of the two (`oklch(0.205 0 0)` vs the\n * background's `oklch(0.145 0 0)`), which is the harder case for contrast. Taken\n * from `apps/web/src/app/globals.css` (narr8 declares two `:root`/`.dark` pairs;\n * the LATER pair wins, and it is the one read here) — light `oklch(1 0 0)`, dark\n * `oklch(0.205 0 0)`. a360ai declares the same two values.\n *\n * oklch→hex conversion: the algebraic inverse of the Björn Ottosson OKLab\n * matrices — the same matrices the validator applies in the forward direction —\n * giving light `#ffffff` and dark `#171717`. Cross-checked by feeding it the\n * previously recorded background value, which it reproduces exactly:\n * `oklch(0.145 0 0)` → `#0a0a0a`. ✓\n *\n * Light and dark are two SELECTED sets of steps, chosen for their own surface —\n * never one set with its lightness flipped at runtime. Consumers pick a set from\n * the resolved theme (`seriesColor(i, mode)` / `sequentialColor(i, mode)`).\n *\n * ---------------------------------------------------------------------------\n * VALIDATOR OUTPUT — dataviz `scripts/validate_palette.js`, run 2026-08-15\n * ---------------------------------------------------------------------------\n *\n * $ node scripts/validate_palette.js \"#2a78d6,#eb6834,#1baf7a,#eda100,#e87ba4,#008300,#4a3aa7\" --mode light --surface \"#ffffff\"\n *\n * Palette (light, surface #ffffff, categorical): 7 slots\n * [PASS] Lightness band all 7 inside L 0.43–0.77\n * [PASS] Chroma floor all 7 >= 0.1\n * [PASS] CVD separation worst adjacent #eda100↔#1baf7a ΔE 9.1 (protan) · tritan 5.8\n * [PASS] Normal-vision floor worst adjacent #e87ba4↔#eda100 ΔE 19.6 (normal)\n * [WARN] Contrast vs surface below 3:1 — relief required (visible labels or table view): [[\"#1baf7a\",2.82],[\"#eda100\",2.17],[\"#e87ba4\",2.69]]\n *\n * → ALL CHECKS PASS (CVD in the 6–8 floor band is legal ONLY with secondary encoding: direct labels, gaps, or texture)\n * scope: categorical palettes only. For a lone status/text color check WCAG text contrast; for a sequential ramp, lightness monotonicity.\n *\n * $ node scripts/validate_palette.js \"#3987e5,#d95926,#199e70,#c98500,#d55181,#008300,#9085e9\" --mode dark --surface \"#171717\"\n *\n * Palette (dark, surface #171717, categorical): 7 slots\n * [PASS] Lightness band all 7 inside L 0.48–0.67\n * [PASS] Chroma floor all 7 >= 0.1\n * [PASS] CVD separation worst adjacent #c98500↔#199e70 ΔE 8.4 (protan) · tritan 8.7\n * [PASS] Normal-vision floor worst adjacent #d55181↔#c98500 ΔE 19.3 (normal)\n * [PASS] Contrast vs surface all 7 >= 3:1\n *\n * → ALL CHECKS PASS (CVD in the 6–8 floor band is legal ONLY with secondary encoding: direct labels, gaps, or texture)\n * scope: categorical palettes only. For a lone status/text color check WCAG text contrast; for a sequential ramp, lightness monotonicity.\n *\n * $ node scripts/validate_palette.js \"#104281,#1c5cab,#2a78d6,#5598e7,#86b6ef\" --mode light --surface \"#ffffff\" --ordinal\n *\n * Palette (light, surface #ffffff, ordinal ramp): 5 slots\n * [PASS] Lightness monotone steps read light→dark\n * [PASS] Adjacent ΔL all gaps >= 0.06\n * [PASS] Light-end contrast #86b6ef at 2.11:1 vs surface\n * [PASS] Single hue hue spread 3°\n *\n * → ALL CHECKS PASS (ordinal: one hue, monotone L, visible step gaps, light end clears surface)\n *\n * $ node scripts/validate_palette.js \"#9ec5f4,#6da7ec,#3987e5,#256abf,#184f95\" --mode dark --surface \"#171717\" --ordinal\n *\n * Palette (dark, surface #171717, ordinal ramp): 5 slots\n * [PASS] Lightness monotone steps read light→dark\n * [PASS] Adjacent ΔL all gaps >= 0.06\n * [PASS] Light-end contrast #184f95 at 2.21:1 vs surface\n * [PASS] Single hue hue spread 3°\n *\n * → ALL CHECKS PASS (ordinal: one hue, monotone L, visible step gaps, light end clears surface)\n *\n * OTHER_COLOR is achromatic, so the categorical checks (which gate hue identity)\n * do not apply to it; it was gated on contrast alone with the validator's own\n * `contrast()` export: 3.59:1 on `#ffffff`, 4.99:1 on `#171717` — both clear 3:1.\n *\n * ---------------------------------------------------------------------------\n * WHAT THE RESULTS OBLIGE US TO DO\n * ---------------------------------------------------------------------------\n *\n * - NO COLOUR VALUE CHANGED in the move from `--background` to `--card`. Every\n * gate that passed on the background still passes on the card, so re-stepping\n * a hue would have been churn, not a fix. Only the recorded surface, the\n * recorded numbers and this prose changed.\n * - The dark set still clears 3:1 on the LIGHTER card surface: the worst slot is\n * green `#008300` at 3.63:1, and the ordinal ramp's surface-nearest step lands\n * at 2.21:1 (down from 2.44:1 on the background) — still above the 2:1 gate.\n * That headroom is thin, so a future card-surface lightening MUST re-run these\n * four commands rather than assume the set still holds.\n * - The light-mode contrast WARN is NOT dismissable. Three slots (aqua, yellow,\n * magenta) sit below 3:1 on white, so every surface that paints with this\n * palette MUST ship the relief channel: a visible legend, direct labels and a\n * tooltip carrying the value in text. The timeline chart and the breakdown\n * table both do. The light card is `#ffffff`, identical to the light\n * background, so this WARN is unchanged rather than newly incurred.\n * - CVD separation is measured on ADJACENT pairs, which is the correct pairlist\n * for stacked bars, grouped bars and lines — the only forms this palette paints.\n * A scatter / bubble / small-multiples chart would need `--pairs all`, which\n * caps the usable slot count at three; do not reuse this array there without\n * re-running the validator with that flag.\n */\n\n/** Which surface the colours are being painted on. */\nexport type ChartMode = \"light\" | \"dark\";\n\n/**\n * The chart surfaces the palette was validated against (globals.css `--card`).\n *\n * `--card`, never `--background`: the charts are painted inside a `<Card>`.\n */\nexport const CHART_SURFACE: Readonly<Record<ChartMode, string>> = {\n light: \"#ffffff\",\n dark: \"#171717\",\n};\n\n/**\n * Categorical slots, in FIXED order. Slot n is series n — the order is the\n * CVD-safety mechanism, not decoration, so it is never re-ordered and never\n * cycled. The two-series default (customer / platform) takes slots 0 and 1.\n *\n * Hues, in order: blue, orange, aqua, yellow, magenta, green, violet.\n */\nconst CATEGORICAL_LIGHT: readonly string[] = [\n \"#2a78d6\",\n \"#eb6834\",\n \"#1baf7a\",\n \"#eda100\",\n \"#e87ba4\",\n \"#008300\",\n \"#4a3aa7\",\n];\n\n/** The same seven hues, re-stepped for the dark surface. Not a lightness flip. */\nconst CATEGORICAL_DARK: readonly string[] = [\n \"#3987e5\",\n \"#d95926\",\n \"#199e70\",\n \"#c98500\",\n \"#d55181\",\n \"#008300\",\n \"#9085e9\",\n];\n\n/**\n * The default (light-surface) categorical set.\n *\n * Prefer `seriesColor(index, mode)` — this array exists for consumers that only\n * need the documented default order.\n */\nexport const CATEGORICAL: readonly string[] = CATEGORICAL_LIGHT;\n\n/**\n * How many series may carry their own identity hue. An 8th series is NEVER a\n * generated hue: it folds into `other`.\n */\nexport const CATEGORICAL_CEILING = CATEGORICAL_LIGHT.length;\n\n/**\n * The \"other\" rollup colour: deliberately achromatic so it reads as \"not an\n * identity\" beside the seven hues. Same step in both modes — it clears 3:1 on\n * both card surfaces (3.59:1 on `#ffffff`, 4.99:1 on `#171717`).\n */\nexport const OTHER_COLOR = \"#898781\";\n\n/**\n * Sequential (single-hue, blue) ramp for MAGNITUDE, indexed by rank position:\n * index 0 is rank 1 — the largest value — so the strongest step leads.\n *\n * On the light surface \"strongest\" is the darkest step; on the dark surface it\n * is the lightest. The anchor flips with the surface, which is why there are two\n * selected sets rather than one array reversed at runtime.\n *\n * Five steps, not eight: with the adjacent-ΔL ≥ 0.06 gate and the ≥ 2:1\n * surface-contrast gate on the step nearest the surface, the blue ramp fits\n * exactly five distinguishable steps. Consumers clamp past the end.\n */\nconst SEQUENTIAL_RAMP_LIGHT: readonly string[] = [\"#104281\", \"#1c5cab\", \"#2a78d6\", \"#5598e7\", \"#86b6ef\"];\n\nconst SEQUENTIAL_RAMP_DARK: readonly string[] = [\"#9ec5f4\", \"#6da7ec\", \"#3987e5\", \"#256abf\", \"#184f95\"];\n\n/**\n * The default (light-surface) sequential ramp.\n *\n * Prefer `sequentialColor(index, mode)` — this array exists for consumers that\n * only need the documented default.\n */\nexport const SEQUENTIAL_RAMP: readonly string[] = SEQUENTIAL_RAMP_LIGHT;\n\nconst categoricalSet = (mode: ChartMode): readonly string[] => (mode === \"dark\" ? CATEGORICAL_DARK : CATEGORICAL_LIGHT);\n\nconst sequentialSet = (mode: ChartMode): readonly string[] =>\n mode === \"dark\" ? SEQUENTIAL_RAMP_DARK : SEQUENTIAL_RAMP_LIGHT;\n\n/**\n * The identity colour for series `index`.\n *\n * Never generates a hue and never cycles: anything at or past the ceiling gets\n * `OTHER_COLOR`, because a series past the ceiling should already have been\n * folded into the \"other\" bucket by the caller.\n */\nexport function seriesColor(index: number, mode: ChartMode = \"light\"): string {\n if (index < 0 || index >= CATEGORICAL_CEILING) return OTHER_COLOR;\n return categoricalSet(mode)[index];\n}\n\n/**\n * Both mode steps for series `index`, shaped for a shadcn `ChartConfig` entry's\n * `theme` field.\n */\nexport function seriesTheme(index: number): { light: string; dark: string } {\n return { light: seriesColor(index, \"light\"), dark: seriesColor(index, \"dark\") };\n}\n\n/**\n * The magnitude colour for rank position `index`, clamped to the last step so a\n * long list keeps its weakest step rather than falling off the ramp.\n */\nexport function sequentialColor(index: number, mode: ChartMode = \"light\"): string {\n const ramp = sequentialSet(mode);\n const clamped = Math.min(Math.max(index, 0), ramp.length - 1);\n return ramp[clamped];\n}\n","import type { Metric } from \"../data/tokenusage-admin.types\";\n\n/**\n * Locale-free arithmetic for the token-usage surfaces.\n *\n * Everything that turns a number into a STRING lives in `./formatters` instead,\n * because it depends on the request's locale and the app's configured currency.\n * This file stays pure arithmetic so it needs neither.\n */\n\n/**\n * The metric field set every admin token-usage resource carries. Declared\n * structurally so it accepts the summary, timeline and breakdown interfaces\n * alike — all three expose exactly these getters.\n */\nexport type TokenUsageMetrics = {\n cost: number;\n credits: number;\n tokensIn: number;\n tokensOut: number;\n cached: number;\n calls: number;\n};\n\n/** Reads the single number a row contributes for the currently selected metric. */\nexport function metricValue(row: TokenUsageMetrics, metric: Metric): number {\n if (metric === \"cost\") return row.cost;\n if (metric === \"credits\") return row.credits;\n return row.tokensIn + row.tokensOut;\n}\n\n/**\n * Share of cached input tokens. Returns 0 rather than NaN when the window holds\n * no input tokens at all, so the tile renders \"0,0 %\" instead of \"NaN %\".\n */\nexport function cacheHitPercentage(cached: number, tokensIn: number): number {\n if (!tokensIn) return 0;\n return (cached / tokensIn) * 100;\n}\n\n/**\n * Percentage change of `current` against `previous`, rounded to a whole number.\n *\n * Returns `undefined` when the previous window is zero — there is no meaningful\n * percentage change from nothing, and rendering Infinity would be worse than\n * rendering nothing. Callers show an em dash in that slot.\n */\nexport function percentageDelta(current: number, previous: number): number | undefined {\n if (!previous) return undefined;\n return Math.round(((current - previous) / previous) * 100);\n}\n"]}
@@ -1038,6 +1038,14 @@ var ModuleRegistryClass = class {
1038
1038
  }
1039
1039
  return module;
1040
1040
  }
1041
+ /**
1042
+ * True when a module is registered under `name`. Never throws, so a component
1043
+ * can check for an opt-in module the app may not have registered.
1044
+ */
1045
+ has(name) {
1046
+ if (this._modules.size === 0) tryBootstrap();
1047
+ return this._modules.has(name);
1048
+ }
1041
1049
  findByName(moduleName) {
1042
1050
  if (this._modules.size === 0) {
1043
1051
  tryBootstrap();
@@ -2572,6 +2580,179 @@ function getValueFromPath(obj, path, userId) {
2572
2580
  }
2573
2581
  __name(getValueFromPath, "getValueFromPath");
2574
2582
 
2583
+ // src/features/account-deletion/data/account-deletion.ts
2584
+ import { v4 as v43 } from "uuid";
2585
+ var AccountDeletion = class extends AbstractApiData {
2586
+ static {
2587
+ __name(this, "AccountDeletion");
2588
+ }
2589
+ _requestedAt;
2590
+ _scheduledAt;
2591
+ _hasDeliverableEmail = false;
2592
+ _hasActiveSubscription = false;
2593
+ _deletesCompany = false;
2594
+ _ownedCount = 0;
2595
+ _otherTables;
2596
+ get requestedAt() {
2597
+ return this._requestedAt;
2598
+ }
2599
+ get scheduledAt() {
2600
+ return this._scheduledAt;
2601
+ }
2602
+ get hasDeliverableEmail() {
2603
+ return this._hasDeliverableEmail;
2604
+ }
2605
+ get hasActiveSubscription() {
2606
+ return this._hasActiveSubscription;
2607
+ }
2608
+ get deletesCompany() {
2609
+ return this._deletesCompany;
2610
+ }
2611
+ get ownedCount() {
2612
+ return this._ownedCount;
2613
+ }
2614
+ get otherTables() {
2615
+ return this._otherTables ?? [];
2616
+ }
2617
+ rehydrate(data) {
2618
+ super.rehydrate(data);
2619
+ const attributes = data.jsonApi.attributes ?? {};
2620
+ this._requestedAt = attributes.requestedAt ? new Date(attributes.requestedAt) : void 0;
2621
+ this._scheduledAt = attributes.scheduledAt ? new Date(attributes.scheduledAt) : void 0;
2622
+ this._hasDeliverableEmail = attributes.hasDeliverableEmail === true;
2623
+ this._hasActiveSubscription = attributes.hasActiveSubscription === true;
2624
+ this._deletesCompany = attributes.deletesCompany === true;
2625
+ this._ownedCount = typeof attributes.ownedCount === "number" ? attributes.ownedCount : 0;
2626
+ this._otherTables = Array.isArray(attributes.otherTables) ? attributes.otherTables : [];
2627
+ return this;
2628
+ }
2629
+ createJsonApi(data) {
2630
+ const response = {
2631
+ data: {
2632
+ type: Modules.AccountDeletion.name,
2633
+ id: data.id,
2634
+ attributes: {
2635
+ confirmation: data.confirmation
2636
+ },
2637
+ meta: {},
2638
+ relationships: {}
2639
+ },
2640
+ included: []
2641
+ };
2642
+ return response;
2643
+ }
2644
+ /**
2645
+ * Body of the public "Keep my account" call. The caller is not signed in and
2646
+ * has no id to send: the API validates a client UUID and ignores its value.
2647
+ */
2648
+ createKeepJsonApi(params) {
2649
+ return {
2650
+ data: {
2651
+ type: Modules.AccountDeletion.name,
2652
+ id: v43(),
2653
+ attributes: {
2654
+ token: params.token
2655
+ }
2656
+ }
2657
+ };
2658
+ }
2659
+ };
2660
+
2661
+ // src/features/account-deletion/account-deletion.module.ts
2662
+ var AccountDeletionModule = /* @__PURE__ */ __name((factory) => factory({
2663
+ name: "account-deletions",
2664
+ pageUrl: "/account-deletions",
2665
+ model: AccountDeletion
2666
+ }), "AccountDeletionModule");
2667
+
2668
+ // src/features/account-deletion/data/account-deletion.service.ts
2669
+ var AccountDeletionService = class extends AbstractService {
2670
+ static {
2671
+ __name(this, "AccountDeletionService");
2672
+ }
2673
+ /**
2674
+ * GET the signed-in user's deletion status and what a deletion would remove.
2675
+ */
2676
+ static async findMine() {
2677
+ return this.callApi({
2678
+ type: Modules.AccountDeletion,
2679
+ method: "GET" /* GET */,
2680
+ endpoint: new EndpointCreator({ endpoint: Modules.AccountDeletion, id: "me" }).generate()
2681
+ });
2682
+ }
2683
+ /**
2684
+ * GET another user's deletion status (platform administrators only).
2685
+ */
2686
+ static async findByUser(params) {
2687
+ return this.callApi({
2688
+ type: Modules.AccountDeletion,
2689
+ method: "GET" /* GET */,
2690
+ endpoint: new EndpointCreator({ endpoint: Modules.AccountDeletion, id: params.userId }).generate()
2691
+ });
2692
+ }
2693
+ /**
2694
+ * POST the signed-in user's own deletion request. `params.id` must be the
2695
+ * signed-in user's id.
2696
+ */
2697
+ static async request(params) {
2698
+ return this.callApi({
2699
+ type: Modules.AccountDeletion,
2700
+ method: "POST" /* POST */,
2701
+ endpoint: new EndpointCreator({ endpoint: Modules.AccountDeletion }).generate(),
2702
+ input: params
2703
+ });
2704
+ }
2705
+ /**
2706
+ * POST a deletion request on behalf of another user (platform administrators
2707
+ * only). Runs the same 7-day request as the user's own.
2708
+ */
2709
+ static async requestForUser(params) {
2710
+ return this.callApi({
2711
+ type: Modules.AccountDeletion,
2712
+ method: "POST" /* POST */,
2713
+ endpoint: new EndpointCreator({ endpoint: Modules.AccountDeletion, id: params.id }).generate(),
2714
+ input: params
2715
+ });
2716
+ }
2717
+ /**
2718
+ * POST the token from the "Keep my account" email link. Public: no session.
2719
+ * Throws on any failure, so the page can show the "link no longer works" text.
2720
+ */
2721
+ static async keep(params) {
2722
+ const accountDeletion = new AccountDeletion();
2723
+ await this.callApi({
2724
+ type: Modules.AccountDeletion,
2725
+ method: "POST" /* POST */,
2726
+ endpoint: new EndpointCreator({ endpoint: Modules.AccountDeletion, id: "keep" }).generate(),
2727
+ input: accountDeletion.createKeepJsonApi({ token: params.token }),
2728
+ overridesJsonApiCreation: true,
2729
+ // OK - model method provides proper structure
2730
+ suppressGlobalError: true
2731
+ });
2732
+ }
2733
+ };
2734
+
2735
+ // src/features/account-deletion/utils/account-deletion-notice.ts
2736
+ var ACCOUNT_DELETION_CANCELLED_KEY = "nja:accountDeletionCancelled";
2737
+ function markAccountDeletionCancelled() {
2738
+ try {
2739
+ sessionStorage.setItem(ACCOUNT_DELETION_CANCELLED_KEY, "1");
2740
+ } catch {
2741
+ }
2742
+ }
2743
+ __name(markAccountDeletionCancelled, "markAccountDeletionCancelled");
2744
+ function consumeAccountDeletionCancelled() {
2745
+ try {
2746
+ const value = sessionStorage.getItem(ACCOUNT_DELETION_CANCELLED_KEY);
2747
+ if (value === null) return false;
2748
+ sessionStorage.removeItem(ACCOUNT_DELETION_CANCELLED_KEY);
2749
+ return true;
2750
+ } catch {
2751
+ return false;
2752
+ }
2753
+ }
2754
+ __name(consumeAccountDeletionCancelled, "consumeAccountDeletionCancelled");
2755
+
2575
2756
  // src/features/auth/data/totp-authenticator.ts
2576
2757
  var TotpAuthenticator = class extends AbstractApiData {
2577
2758
  static {
@@ -3041,6 +3222,11 @@ var Auth = class extends AbstractApiData {
3041
3222
  _token;
3042
3223
  _refreshToken;
3043
3224
  _user;
3225
+ _deletionCancelled = false;
3226
+ /** True on the session created by the login that cancelled a pending account deletion. */
3227
+ get deletionCancelled() {
3228
+ return this._deletionCancelled;
3229
+ }
3044
3230
  get token() {
3045
3231
  if (!this._token) throw new Error("Token is not defined");
3046
3232
  return this._token;
@@ -3057,6 +3243,7 @@ var Auth = class extends AbstractApiData {
3057
3243
  super.rehydrate(data);
3058
3244
  this._token = data.jsonApi.attributes.token ?? void 0;
3059
3245
  this._refreshToken = data.jsonApi.attributes.refreshToken ?? void 0;
3246
+ this._deletionCancelled = data.jsonApi.attributes.deletionCancelled === true;
3060
3247
  this._user = this._readIncluded(data, "user", Modules.User);
3061
3248
  return this;
3062
3249
  }
@@ -3112,6 +3299,7 @@ var AuthService = class extends AbstractService {
3112
3299
  return challenge;
3113
3300
  }
3114
3301
  const auth = apiResponse.data;
3302
+ if (auth.deletionCancelled) markAccountDeletionCancelled();
3115
3303
  const handler = getTokenHandler();
3116
3304
  if (handler) {
3117
3305
  await handler.updateToken({
@@ -3214,6 +3402,23 @@ var AuthService = class extends AbstractService {
3214
3402
  });
3215
3403
  }
3216
3404
  }
3405
+ /**
3406
+ * Reads an OAuth sign-up waiting for consent. Throws an Error carrying
3407
+ * `status` (404 when the pending registration expired); callers catch it.
3408
+ */
3409
+ static async findPendingRegistration(params) {
3410
+ return this.callApi({
3411
+ type: Modules.PendingRegistration,
3412
+ method: "GET" /* GET */,
3413
+ endpoint: new EndpointCreator({
3414
+ endpoint: Modules.Auth,
3415
+ id: "oauth",
3416
+ childEndpoint: Modules.PendingRegistration,
3417
+ childId: params.pendingId
3418
+ }).generate(),
3419
+ suppressGlobalError: true
3420
+ });
3421
+ }
3217
3422
  static async completeOAuthRegistration(params) {
3218
3423
  const endpoint = new EndpointCreator({ endpoint: Modules.Auth, id: "oauth", childEndpoint: "complete" });
3219
3424
  const response = await JsonApiPost({
@@ -3546,6 +3751,57 @@ var TwoFactorService = class extends AbstractService {
3546
3751
  }
3547
3752
  };
3548
3753
 
3754
+ // src/features/auth/data/pending-registration.ts
3755
+ var PendingRegistration = class extends AbstractApiData {
3756
+ static {
3757
+ __name(this, "PendingRegistration");
3758
+ }
3759
+ _name;
3760
+ _email;
3761
+ _avatar;
3762
+ _provider;
3763
+ _hasPass;
3764
+ _emailInUse;
3765
+ get name() {
3766
+ return this._name ?? "";
3767
+ }
3768
+ get email() {
3769
+ return this._email ?? "";
3770
+ }
3771
+ get avatar() {
3772
+ return this._avatar;
3773
+ }
3774
+ get provider() {
3775
+ return this._provider ?? "";
3776
+ }
3777
+ get hasPass() {
3778
+ return this._hasPass ?? false;
3779
+ }
3780
+ get emailInUse() {
3781
+ return this._emailInUse ?? false;
3782
+ }
3783
+ rehydrate(data) {
3784
+ super.rehydrate(data);
3785
+ this._name = data.jsonApi.attributes.name;
3786
+ this._email = data.jsonApi.attributes.email;
3787
+ this._avatar = data.jsonApi.attributes.avatar ?? void 0;
3788
+ this._provider = data.jsonApi.attributes.provider;
3789
+ this._hasPass = data.jsonApi.attributes.hasPass ?? false;
3790
+ this._emailInUse = data.jsonApi.attributes.emailInUse ?? false;
3791
+ return this;
3792
+ }
3793
+ /** Read-only resource: the payload only identifies it. */
3794
+ createJsonApi(data) {
3795
+ return {
3796
+ data: {
3797
+ type: Modules.PendingRegistration.name,
3798
+ id: data.id,
3799
+ attributes: {}
3800
+ }
3801
+ };
3802
+ }
3803
+ };
3804
+
3549
3805
  // src/features/auth/enums/AuthComponent.ts
3550
3806
  var AuthComponent = /* @__PURE__ */ ((AuthComponent2) => {
3551
3807
  AuthComponent2[AuthComponent2["Login"] = 0] = "Login";
@@ -3573,6 +3829,13 @@ var TwoFactorStatusModule = /* @__PURE__ */ __name((factory) => factory({
3573
3829
  model: TwoFactorStatus
3574
3830
  }), "TwoFactorStatusModule");
3575
3831
 
3832
+ // src/features/auth/pending-registration.module.ts
3833
+ var PendingRegistrationModule = /* @__PURE__ */ __name((factory) => factory({
3834
+ name: "pending-registrations",
3835
+ pageUrl: "/auth/consent",
3836
+ model: PendingRegistration
3837
+ }), "PendingRegistrationModule");
3838
+
3576
3839
  // src/features/billing/data/billing.service.ts
3577
3840
  var BillingService = class extends AbstractService {
3578
3841
  static {
@@ -12147,6 +12410,12 @@ export {
12147
12410
  checkPermissions,
12148
12411
  checkPermissionsFromServer,
12149
12412
  getValueFromPath,
12413
+ AccountDeletion,
12414
+ AccountDeletionModule,
12415
+ AccountDeletionService,
12416
+ ACCOUNT_DELETION_CANCELLED_KEY,
12417
+ markAccountDeletionCancelled,
12418
+ consumeAccountDeletionCancelled,
12150
12419
  TotpAuthenticator,
12151
12420
  TotpAuthenticatorModule,
12152
12421
  TotpSetup,
@@ -12179,9 +12448,11 @@ export {
12179
12448
  AuthService,
12180
12449
  TwoFactorStatus,
12181
12450
  TwoFactorService,
12451
+ PendingRegistration,
12182
12452
  AuthComponent,
12183
12453
  AuthModule,
12184
12454
  TwoFactorStatusModule,
12455
+ PendingRegistrationModule,
12185
12456
  BillingService,
12186
12457
  Billing,
12187
12458
  SubscriptionStatus,
@@ -12392,4 +12663,4 @@ export {
12392
12663
  AuditLogService,
12393
12664
  AuditLogModule
12394
12665
  };
12395
- //# sourceMappingURL=chunk-3FD6Y734.mjs.map
12666
+ //# sourceMappingURL=chunk-QNIWATQD.mjs.map