@openrails/billing-ui 0.272.0 → 0.274.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 (160) hide show
  1. package/dist/admin/components/customer-search.d.ts +5 -0
  2. package/dist/admin/components/missing-record.d.ts +6 -0
  3. package/dist/admin/components/status-badge.d.ts +1 -0
  4. package/dist/admin/context.d.ts +20 -2
  5. package/dist/admin/lib/api/endpoints.d.ts +3 -1
  6. package/dist/admin/lib/api/index.d.ts +2 -0
  7. package/dist/admin/lib/api/types.d.ts +2 -0
  8. package/dist/admin/lib/capabilities.d.ts +4 -0
  9. package/dist/admin/lib/dialog-width.d.ts +4 -3
  10. package/dist/admin/lib/error-text.d.ts +4 -0
  11. package/dist/admin/lib/mutations.d.ts +6 -1
  12. package/dist/admin/lib/queries.d.ts +3 -0
  13. package/dist/admin/lib/tile-grids.d.ts +6 -0
  14. package/dist/admin/messages.d.ts +89 -0
  15. package/dist/admin/pages/payments/index.d.ts +1 -2
  16. package/dist/admin/pages/subscriptions/index.d.ts +1 -2
  17. package/dist/{admin-attempts-DyDDt-qw.js → admin-attempts-Dzipkstg.js} +145 -144
  18. package/dist/admin-attempts-Dzipkstg.js.map +1 -0
  19. package/dist/{admin-auth-1aZIgXiS.js → admin-auth-BCl_Tv3t.js} +2 -2
  20. package/dist/{admin-auth-1aZIgXiS.js.map → admin-auth-BCl_Tv3t.js.map} +1 -1
  21. package/dist/{admin-badge-pgG6D9-a.js → admin-badge-kmYQM9Ge.js} +2 -2
  22. package/dist/{admin-badge-pgG6D9-a.js.map → admin-badge-kmYQM9Ge.js.map} +1 -1
  23. package/dist/{admin-button-CrcYk5r0.js → admin-button-Cq9ZfX4R.js} +2 -2
  24. package/dist/{admin-button-CrcYk5r0.js.map → admin-button-Cq9ZfX4R.js.map} +1 -1
  25. package/dist/{admin-capabilities-BDcZeHL_.js → admin-capabilities-k5fQZhN9.js} +35 -14
  26. package/dist/admin-capabilities-k5fQZhN9.js.map +1 -0
  27. package/dist/{admin-card-DvTMc5Se.js → admin-card-C8k67jJv.js} +2 -2
  28. package/dist/{admin-card-DvTMc5Se.js.map → admin-card-C8k67jJv.js.map} +1 -1
  29. package/dist/{admin-catalog-BlF5mnu4.js → admin-catalog-CON-GwKL.js} +286 -286
  30. package/dist/{admin-catalog-BlF5mnu4.js.map → admin-catalog-CON-GwKL.js.map} +1 -1
  31. package/dist/{admin-cursor-pager-CIb3Jw2F.js → admin-cursor-pager-DqFruoNu.js} +6 -6
  32. package/dist/{admin-cursor-pager-CIb3Jw2F.js.map → admin-cursor-pager-DqFruoNu.js.map} +1 -1
  33. package/dist/admin-customer-search-CJHB80rg.js +117 -0
  34. package/dist/admin-customer-search-CJHB80rg.js.map +1 -0
  35. package/dist/{admin-customers-EpfoWDh-.js → admin-customers-CWWOrcVR.js} +18 -17
  36. package/dist/{admin-customers-EpfoWDh-.js.map → admin-customers-CWWOrcVR.js.map} +1 -1
  37. package/dist/admin-dashboard-BiShWFk2.js +456 -0
  38. package/dist/admin-dashboard-BiShWFk2.js.map +1 -0
  39. package/dist/admin-data-table-CdsjYJh5.js +107 -0
  40. package/dist/admin-data-table-CdsjYJh5.js.map +1 -0
  41. package/dist/admin-detail-BWSC1aCH.js +338 -0
  42. package/dist/admin-detail-BWSC1aCH.js.map +1 -0
  43. package/dist/admin-detail-CKRtK43V.js +728 -0
  44. package/dist/admin-detail-CKRtK43V.js.map +1 -0
  45. package/dist/admin-detail-CMmhZQ2A.js +346 -0
  46. package/dist/admin-detail-CMmhZQ2A.js.map +1 -0
  47. package/dist/admin-detail-CiONe1Pt.js +1357 -0
  48. package/dist/admin-detail-CiONe1Pt.js.map +1 -0
  49. package/dist/{admin-detail-3wFIDPNB.js → admin-detail-Cyuf_i9U.js} +62 -62
  50. package/dist/{admin-detail-3wFIDPNB.js.map → admin-detail-Cyuf_i9U.js.map} +1 -1
  51. package/dist/{admin-dialog-BSRf9Zre.js → admin-dialog-Ch7rTOCr.js} +3 -3
  52. package/dist/{admin-dialog-BSRf9Zre.js.map → admin-dialog-Ch7rTOCr.js.map} +1 -1
  53. package/dist/admin-dialog-width-CC7QHT1p.js +6 -0
  54. package/dist/admin-dialog-width-CC7QHT1p.js.map +1 -0
  55. package/dist/{admin-dropdown-menu-D0E5rwmn.js → admin-dropdown-menu-Bah3f8AZ.js} +2 -2
  56. package/dist/{admin-dropdown-menu-D0E5rwmn.js.map → admin-dropdown-menu-Bah3f8AZ.js.map} +1 -1
  57. package/dist/{admin-fact-card-BPSVhS15.js → admin-fact-card-Bt__Cd_U.js} +2 -2
  58. package/dist/{admin-fact-card-BPSVhS15.js.map → admin-fact-card-Bt__Cd_U.js.map} +1 -1
  59. package/dist/{admin-health-D0L5Kig7.js → admin-health-pzTO6_0v.js} +249 -248
  60. package/dist/admin-health-pzTO6_0v.js.map +1 -0
  61. package/dist/{admin-imports-CgZB5JAV.js → admin-imports-tT5et8-V.js} +62 -62
  62. package/dist/{admin-imports-CgZB5JAV.js.map → admin-imports-tT5et8-V.js.map} +1 -1
  63. package/dist/{admin-input-DJAK9nmk.js → admin-input-DvRZy_2a.js} +2 -2
  64. package/dist/{admin-input-DJAK9nmk.js.map → admin-input-DvRZy_2a.js.map} +1 -1
  65. package/dist/{admin-label-aviN9Gng.js → admin-label-QZtWJGH-.js} +2 -2
  66. package/dist/{admin-label-aviN9Gng.js.map → admin-label-QZtWJGH-.js.map} +1 -1
  67. package/dist/{admin-linked-table-row-BGr7JXeM.js → admin-linked-table-row-6jkCKwMn.js} +4 -4
  68. package/dist/{admin-linked-table-row-BGr7JXeM.js.map → admin-linked-table-row-6jkCKwMn.js.map} +1 -1
  69. package/dist/{admin-map-dialog-DS2Wz6G3.js → admin-map-dialog-BV54mvMQ.js} +22 -22
  70. package/dist/{admin-map-dialog-DS2Wz6G3.js.map → admin-map-dialog-BV54mvMQ.js.map} +1 -1
  71. package/dist/{admin-metering-D-e-37Jn.js → admin-metering-Bv5EcX6M.js} +306 -306
  72. package/dist/{admin-metering-D-e-37Jn.js.map → admin-metering-Bv5EcX6M.js.map} +1 -1
  73. package/dist/admin-missing-record-BXqGFDt3.js +42 -0
  74. package/dist/admin-missing-record-BXqGFDt3.js.map +1 -0
  75. package/dist/admin-ops-h3RjpcNu.js +356 -0
  76. package/dist/admin-ops-h3RjpcNu.js.map +1 -0
  77. package/dist/admin-orders-DYxPiuTl.js +192 -0
  78. package/dist/admin-orders-DYxPiuTl.js.map +1 -0
  79. package/dist/{admin-parked-B8xHkV2e.js → admin-parked-ClKA60d5.js} +51 -51
  80. package/dist/{admin-parked-B8xHkV2e.js.map → admin-parked-ClKA60d5.js.map} +1 -1
  81. package/dist/admin-payments-BlIuy3wL.js +220 -0
  82. package/dist/admin-payments-BlIuy3wL.js.map +1 -0
  83. package/dist/{admin-price-detail-CSI5oKdb.js → admin-price-detail-BjWYU5A-.js} +98 -98
  84. package/dist/{admin-price-detail-CSI5oKdb.js.map → admin-price-detail-BjWYU5A-.js.map} +1 -1
  85. package/dist/{admin-price-wizard-CBEcNGvP.js → admin-price-wizard-CTbkbmYc.js} +61 -61
  86. package/dist/{admin-price-wizard-CBEcNGvP.js.map → admin-price-wizard-CTbkbmYc.js.map} +1 -1
  87. package/dist/{admin-proposals-Cuj7tvaM.js → admin-proposals-Ci9Q8j7Y.js} +64 -64
  88. package/dist/{admin-proposals-Cuj7tvaM.js.map → admin-proposals-Ci9Q8j7Y.js.map} +1 -1
  89. package/dist/{admin-provider-prices-B6vwnVPi.js → admin-provider-prices-B6Ayq-eN.js} +66 -66
  90. package/dist/{admin-provider-prices-B6vwnVPi.js.map → admin-provider-prices-B6Ayq-eN.js.map} +1 -1
  91. package/dist/{admin-range-picker-De36L-AP.js → admin-range-picker-nfflPp21.js} +9 -9
  92. package/dist/{admin-range-picker-De36L-AP.js.map → admin-range-picker-nfflPp21.js.map} +1 -1
  93. package/dist/{admin-records-H0MlhEVY.js → admin-records-CrTCorWH.js} +43 -43
  94. package/dist/{admin-records-H0MlhEVY.js.map → admin-records-CrTCorWH.js.map} +1 -1
  95. package/dist/{admin-reports-BFGS_PWf.js → admin-reports-BO6wrvtw.js} +50 -50
  96. package/dist/{admin-reports-BFGS_PWf.js.map → admin-reports-BO6wrvtw.js.map} +1 -1
  97. package/dist/{admin-select-BUcEU5Rg.js → admin-select-DvfJ80Rg.js} +2 -2
  98. package/dist/{admin-select-BUcEU5Rg.js.map → admin-select-DvfJ80Rg.js.map} +1 -1
  99. package/dist/{admin-settings-DYC-c7mJ.js → admin-settings-BOoTzhyf.js} +332 -332
  100. package/dist/admin-settings-BOoTzhyf.js.map +1 -0
  101. package/dist/{admin-shared-lfIUEbPY.js → admin-shared-BbGT_qTo.js} +21 -21
  102. package/dist/{admin-shared-lfIUEbPY.js.map → admin-shared-BbGT_qTo.js.map} +1 -1
  103. package/dist/{admin-skeleton-B0yzYY_X.js → admin-skeleton-B2a4ScVE.js} +2 -2
  104. package/dist/{admin-skeleton-B0yzYY_X.js.map → admin-skeleton-B2a4ScVE.js.map} +1 -1
  105. package/dist/admin-status-badge-Bp6cssXY.js +51 -0
  106. package/dist/admin-status-badge-Bp6cssXY.js.map +1 -0
  107. package/dist/admin-subscriptions-D9JmoicC.js +275 -0
  108. package/dist/admin-subscriptions-D9JmoicC.js.map +1 -0
  109. package/dist/{admin-switch-DDorugaw.js → admin-switch-DBBxJRZP.js} +2 -2
  110. package/dist/{admin-switch-DDorugaw.js.map → admin-switch-DBBxJRZP.js.map} +1 -1
  111. package/dist/{admin-table-BU6Tie69.js → admin-table-CPDoVfK4.js} +2 -2
  112. package/dist/{admin-table-BU6Tie69.js.map → admin-table-CPDoVfK4.js.map} +1 -1
  113. package/dist/{admin-tabs-D5lqdVcC.js → admin-tabs-DDUv3kiu.js} +2 -2
  114. package/dist/{admin-tabs-D5lqdVcC.js.map → admin-tabs-DDUv3kiu.js.map} +1 -1
  115. package/dist/{admin-textarea-Dc6lnEub.js → admin-textarea-d3fu_waS.js} +2 -2
  116. package/dist/{admin-textarea-Dc6lnEub.js.map → admin-textarea-d3fu_waS.js.map} +1 -1
  117. package/dist/admin-tile-grids-CzGpidd9.js +6 -0
  118. package/dist/admin-tile-grids-CzGpidd9.js.map +1 -0
  119. package/dist/{admin-typed-confirm-dialog-Bk6XxmPb.js → admin-typed-confirm-dialog-BVklYjFo.js} +11 -11
  120. package/dist/{admin-typed-confirm-dialog-Bk6XxmPb.js.map → admin-typed-confirm-dialog-BVklYjFo.js.map} +1 -1
  121. package/dist/{admin-utils-B9eEBNsR.js → admin-utils-DTT53IpS.js} +266 -223
  122. package/dist/admin-utils-DTT53IpS.js.map +1 -0
  123. package/dist/{admin-widget-viz-8aukE3v_.js → admin-widget-viz-Exsqz3Dw.js} +165 -128
  124. package/dist/admin-widget-viz-Exsqz3Dw.js.map +1 -0
  125. package/dist/admin.css +1 -1
  126. package/dist/admin.js +531 -405
  127. package/dist/admin.js.map +1 -1
  128. package/dist/index.js +1 -1
  129. package/dist/styles.css +1 -1
  130. package/package.json +1 -1
  131. package/dist/admin-attempts-DyDDt-qw.js.map +0 -1
  132. package/dist/admin-capabilities-BDcZeHL_.js.map +0 -1
  133. package/dist/admin-dashboard-CJE63yz4.js +0 -420
  134. package/dist/admin-dashboard-CJE63yz4.js.map +0 -1
  135. package/dist/admin-data-table-hvFcJepL.js +0 -96
  136. package/dist/admin-data-table-hvFcJepL.js.map +0 -1
  137. package/dist/admin-detail-BRP6pL7t.js +0 -328
  138. package/dist/admin-detail-BRP6pL7t.js.map +0 -1
  139. package/dist/admin-detail-CRzFb_pa.js +0 -1331
  140. package/dist/admin-detail-CRzFb_pa.js.map +0 -1
  141. package/dist/admin-detail-QLxU8r-5.js +0 -344
  142. package/dist/admin-detail-QLxU8r-5.js.map +0 -1
  143. package/dist/admin-detail-pPC8Q9l-.js +0 -710
  144. package/dist/admin-detail-pPC8Q9l-.js.map +0 -1
  145. package/dist/admin-dialog-width-BPrgdYlj.js +0 -6
  146. package/dist/admin-dialog-width-BPrgdYlj.js.map +0 -1
  147. package/dist/admin-health-D0L5Kig7.js.map +0 -1
  148. package/dist/admin-ops-CQP4TzWM.js +0 -235
  149. package/dist/admin-ops-CQP4TzWM.js.map +0 -1
  150. package/dist/admin-orders-BJ7W5S8P.js +0 -192
  151. package/dist/admin-orders-BJ7W5S8P.js.map +0 -1
  152. package/dist/admin-payments-CzkzqYA1.js +0 -246
  153. package/dist/admin-payments-CzkzqYA1.js.map +0 -1
  154. package/dist/admin-settings-DYC-c7mJ.js.map +0 -1
  155. package/dist/admin-status-badge-0-K37EfN.js +0 -43
  156. package/dist/admin-status-badge-0-K37EfN.js.map +0 -1
  157. package/dist/admin-subscriptions-CvW-YFs0.js +0 -301
  158. package/dist/admin-subscriptions-CvW-YFs0.js.map +0 -1
  159. package/dist/admin-utils-B9eEBNsR.js.map +0 -1
  160. package/dist/admin-widget-viz-8aukE3v_.js.map +0 -1
@@ -0,0 +1,1357 @@
1
+ import { E as e, O as t, _ as n, c as r, f as i, p as a, r as o, s, t as c } from "./admin-utils-DTT53IpS.js";
2
+ import { t as l } from "./admin-button-Cq9ZfX4R.js";
3
+ import { t as u } from "./admin-input-DvRZy_2a.js";
4
+ import { a as d, s as f } from "./admin-capabilities-k5fQZhN9.js";
5
+ import { t as p } from "./admin-auth-BCl_Tv3t.js";
6
+ import { a as m, i as h, n as g, o as _, s as v, t as y, u as b } from "./admin-format-DoohJ7Fg.js";
7
+ import { n as x } from "./admin-confirm-katGq0Qo.js";
8
+ import { t as S } from "./admin-badge-kmYQM9Ge.js";
9
+ import { t as C } from "./admin-status-badge-Bp6cssXY.js";
10
+ import { t as w } from "./admin-form-field-errors-hbUMIriS.js";
11
+ import { a as T, i as E, n as ee, r as D, t as O } from "./admin-select-DvfJ80Rg.js";
12
+ import { n as k, t as A } from "./admin-cursor-pager-DqFruoNu.js";
13
+ import { a as j, n as M, o as N, r as P, s as F, t as te } from "./admin-table-CPDoVfK4.js";
14
+ import { t as I } from "./admin-linked-table-row-6jkCKwMn.js";
15
+ import { a as L, i as R, n as z, o as B, r as V, s as ne, t as H } from "./admin-dialog-Ch7rTOCr.js";
16
+ import { t as U } from "./admin-label-QZtWJGH-.js";
17
+ import { n as re, r as ie } from "./admin-dialog-width-CC7QHT1p.js";
18
+ import { a as W, o as G, r as K, t as q } from "./admin-card-C8k67jJv.js";
19
+ import "./admin-tile-grids-CzGpidd9.js";
20
+ import { n as ae, t as oe } from "./admin-invoice-profile-model-Cgjy3zV8.js";
21
+ import { t as se } from "./admin-dunning-B2zgtrOo.js";
22
+ import { t as ce } from "./admin-missing-record-BXqGFDt3.js";
23
+ import * as J from "react";
24
+ import { useState as le } from "react";
25
+ import { useMutation as Y, useQuery as X, useQueryClient as Z } from "@tanstack/react-query";
26
+ import { Fragment as ue, jsx as Q, jsxs as $ } from "react/jsx-runtime";
27
+ import { HugeiconsIcon as de } from "@hugeicons/react";
28
+ import { Add01Icon as fe, ArrowLeft01Icon as pe, Delete02Icon as me, Refresh01Icon as he } from "@hugeicons/core-free-icons";
29
+ import { useForm as ge } from "@tanstack/react-form";
30
+ //#region src/admin/pages/customers/invoice-profile.tsx
31
+ function _e({ customerId: t }) {
32
+ let { orderQueries: r } = a(), i = d(), s = X(r.profile(t));
33
+ return /* @__PURE__ */ $(q, { children: [/* @__PURE__ */ Q(W, { children: /* @__PURE__ */ Q(G, { children: /* @__PURE__ */ Q(e, { id: "Invoice profile" }) }) }), /* @__PURE__ */ $(K, { children: [/* @__PURE__ */ Q(o, {
34
+ className: "text-sm underline",
35
+ to: `/orders?customer_id=${t}&origin=usage`,
36
+ children: /* @__PURE__ */ Q(e, { id: "View customer usage orders" })
37
+ }), s.isPending ? /* @__PURE__ */ Q("p", { children: /* @__PURE__ */ Q(e, { id: "Loading invoice profile…" }) }) : s.error ? /* @__PURE__ */ Q("p", {
38
+ role: "alert",
39
+ className: "text-destructive",
40
+ children: n(s.error).text
41
+ }) : /* @__PURE__ */ Q(ve, {
42
+ customerId: t,
43
+ profile: s.data,
44
+ readOnly: !i
45
+ }, t)] })] });
46
+ }
47
+ function ve({ customerId: n, profile: r, readOnly: i = !1 }) {
48
+ let { id: o, text: s } = t(), { invoiceProfileMutation: c } = a(), [d, f] = le(() => ae(r)), [p, m] = le(null), [h, g] = le(!1), _ = Z(), v = Y(c(_, n)), y = (e) => {
49
+ f((t) => ({
50
+ ...t,
51
+ ...e
52
+ })), g(!1);
53
+ };
54
+ async function b() {
55
+ m(null), g(!1);
56
+ try {
57
+ await v.mutateAsync(oe(d, r)), g(!0);
58
+ } catch (e) {
59
+ m(e instanceof Error ? e.message : "Invoice profile update failed.");
60
+ }
61
+ }
62
+ return /* @__PURE__ */ $("form", {
63
+ className: "mt-4 space-y-4",
64
+ onSubmit: (e) => {
65
+ e.preventDefault(), v.isPending || b();
66
+ },
67
+ children: [
68
+ /* @__PURE__ */ Q("p", {
69
+ className: "text-sm text-muted-foreground",
70
+ children: /* @__PURE__ */ Q(e, { id: "Terms and billing facts for future usage orders. Billed orders keep their original snapshots. Tax details are recorded; no tax is calculated." })
71
+ }),
72
+ /* @__PURE__ */ $("fieldset", {
73
+ disabled: i || v.isPending,
74
+ className: "space-y-4",
75
+ children: [
76
+ /* @__PURE__ */ $("div", {
77
+ className: "grid gap-3 sm:grid-cols-2",
78
+ children: [/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(U, {
79
+ htmlFor: o("invoice-profile-terms"),
80
+ children: /* @__PURE__ */ Q(e, { id: "Payment terms (days)" })
81
+ }), /* @__PURE__ */ Q(u, {
82
+ id: o("invoice-profile-terms"),
83
+ type: "number",
84
+ min: 0,
85
+ step: 1,
86
+ value: d.terms,
87
+ onChange: (e) => y({ terms: e.target.value })
88
+ })] }), /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(U, {
89
+ htmlFor: o("invoice-profile-method"),
90
+ children: /* @__PURE__ */ Q(e, { id: "Collection method" })
91
+ }), /* @__PURE__ */ $("select", {
92
+ id: o("invoice-profile-method"),
93
+ className: "h-9 w-full rounded-md border bg-background px-2",
94
+ value: d.method,
95
+ onChange: (e) => y({ method: e.target.value }),
96
+ children: [/* @__PURE__ */ Q("option", {
97
+ value: "charge_automatically",
98
+ children: /* @__PURE__ */ Q(e, { id: "Saved payment method" })
99
+ }), /* @__PURE__ */ Q("option", {
100
+ value: "send_invoice",
101
+ children: /* @__PURE__ */ Q(e, { id: "Manual remittance" })
102
+ })]
103
+ })] })]
104
+ }),
105
+ /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(U, {
106
+ htmlFor: o("invoice-profile-po"),
107
+ children: /* @__PURE__ */ Q(e, { id: "Purchase order" })
108
+ }), /* @__PURE__ */ Q(u, {
109
+ id: o("invoice-profile-po"),
110
+ value: d.po,
111
+ onChange: (e) => y({ po: e.target.value })
112
+ })] }),
113
+ /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(U, {
114
+ htmlFor: o("invoice-profile-memo"),
115
+ children: /* @__PURE__ */ Q(e, { id: "Invoice memo" })
116
+ }), /* @__PURE__ */ Q(u, {
117
+ id: o("invoice-profile-memo"),
118
+ value: d.memo,
119
+ onChange: (e) => y({ memo: e.target.value })
120
+ })] }),
121
+ /* @__PURE__ */ $("div", {
122
+ className: "space-y-2",
123
+ children: [
124
+ /* @__PURE__ */ Q("p", {
125
+ className: "text-sm font-medium",
126
+ children: /* @__PURE__ */ Q(e, { id: "Billing contacts" })
127
+ }),
128
+ d.contacts.map((t, n) => /* @__PURE__ */ $("div", {
129
+ className: "flex gap-2",
130
+ children: [
131
+ /* @__PURE__ */ Q(u, {
132
+ "aria-label": `Contact ${n + 1} name`,
133
+ placeholder: s("Name"),
134
+ value: t.name,
135
+ onChange: (e) => y({ contacts: d.contacts.map((t, r) => r === n ? {
136
+ ...t,
137
+ name: e.target.value
138
+ } : t) })
139
+ }),
140
+ /* @__PURE__ */ Q(u, {
141
+ "aria-label": `Contact ${n + 1} email`,
142
+ type: "email",
143
+ placeholder: s("Email"),
144
+ value: t.email,
145
+ onChange: (e) => y({ contacts: d.contacts.map((t, r) => r === n ? {
146
+ ...t,
147
+ email: e.target.value
148
+ } : t) })
149
+ }),
150
+ /* @__PURE__ */ Q(l, {
151
+ type: "button",
152
+ variant: "outline",
153
+ "aria-label": `Remove contact ${n + 1}`,
154
+ onClick: () => y({ contacts: d.contacts.filter((e, t) => t !== n) }),
155
+ children: /* @__PURE__ */ Q(e, { id: "Remove" })
156
+ })
157
+ ]
158
+ }, n)),
159
+ /* @__PURE__ */ Q(l, {
160
+ type: "button",
161
+ variant: "outline",
162
+ onClick: () => y({ contacts: [...d.contacts, {
163
+ name: "",
164
+ email: ""
165
+ }] }),
166
+ children: /* @__PURE__ */ Q(e, { id: "Add contact" })
167
+ })
168
+ ]
169
+ }),
170
+ /* @__PURE__ */ $("div", {
171
+ className: "space-y-2",
172
+ children: [
173
+ /* @__PURE__ */ Q("p", {
174
+ className: "text-sm font-medium",
175
+ children: /* @__PURE__ */ Q(e, { id: "Tax details" })
176
+ }),
177
+ d.tax.map((t, n) => /* @__PURE__ */ $("div", {
178
+ className: "flex gap-2",
179
+ children: [
180
+ /* @__PURE__ */ Q(u, {
181
+ "aria-label": `Tax detail ${n + 1} name`,
182
+ placeholder: s("Name, such as tax_id"),
183
+ value: t.key,
184
+ onChange: (e) => y({ tax: d.tax.map((t, r) => r === n ? {
185
+ ...t,
186
+ key: e.target.value
187
+ } : t) })
188
+ }),
189
+ /* @__PURE__ */ Q(u, {
190
+ "aria-label": `Tax detail ${n + 1} value`,
191
+ placeholder: s("Value"),
192
+ value: t.value,
193
+ onChange: (e) => y({ tax: d.tax.map((t, r) => r === n ? {
194
+ ...t,
195
+ value: e.target.value
196
+ } : t) })
197
+ }),
198
+ /* @__PURE__ */ Q(l, {
199
+ type: "button",
200
+ variant: "outline",
201
+ "aria-label": `Remove tax detail ${n + 1}`,
202
+ onClick: () => y({ tax: d.tax.filter((e, t) => t !== n) }),
203
+ children: /* @__PURE__ */ Q(e, { id: "Remove" })
204
+ })
205
+ ]
206
+ }, n)),
207
+ /* @__PURE__ */ Q(l, {
208
+ type: "button",
209
+ variant: "outline",
210
+ onClick: () => y({ tax: [...d.tax, {
211
+ key: "",
212
+ value: ""
213
+ }] }),
214
+ children: /* @__PURE__ */ Q(e, { id: "Add tax detail" })
215
+ })
216
+ ]
217
+ })
218
+ ]
219
+ }),
220
+ p && /* @__PURE__ */ Q("p", {
221
+ role: "alert",
222
+ className: "text-destructive",
223
+ children: p
224
+ }),
225
+ h && /* @__PURE__ */ Q("p", {
226
+ role: "status",
227
+ className: "text-sm",
228
+ children: /* @__PURE__ */ Q(e, { id: "Invoice profile saved. Billed orders were not changed." })
229
+ }),
230
+ !i && /* @__PURE__ */ Q(l, {
231
+ type: "submit",
232
+ disabled: v.isPending,
233
+ children: v.isPending ? "Saving…" : "Save invoice profile"
234
+ })
235
+ ]
236
+ });
237
+ }
238
+ //#endregion
239
+ //#region src/admin/pages/customers/default-card-badges.tsx
240
+ function ye({ currencies: t = [] }) {
241
+ return /* @__PURE__ */ Q(ue, { children: t.map((t) => /* @__PURE__ */ $(S, {
242
+ variant: "secondary",
243
+ className: "mt-1 mr-1",
244
+ children: [/* @__PURE__ */ Q(e, { id: "Default · " }), t]
245
+ }, t)) });
246
+ }
247
+ //#endregion
248
+ //#region src/admin/pages/customers/credit-form.ts
249
+ function be(e, t = Date.now()) {
250
+ let n = y(e.amount, e.decimals);
251
+ if (n === null || BigInt(n) <= 0n) throw Error(`Enter a positive amount with at most ${e.decimals} decimal places, within the supported range.`);
252
+ let r = e.currency.trim();
253
+ if (!r) throw Error("Select a currency.");
254
+ let i;
255
+ if (e.expires) {
256
+ let n = new Date(e.expires).getTime();
257
+ if (!Number.isFinite(n) || n <= t) throw Error("Expiry must be a valid future date.");
258
+ i = new Date(n).toISOString();
259
+ }
260
+ return {
261
+ amount: n,
262
+ currency: r,
263
+ source: "admin",
264
+ source_id: e.sourceID,
265
+ expires_at: i,
266
+ description: e.description.trim() || void 0
267
+ };
268
+ }
269
+ function xe(e) {
270
+ return (e.state === "active" || e.state === "scheduled") && /^\d+$/.test(e.remaining_amount) && BigInt(e.remaining_amount) > 0n;
271
+ }
272
+ function Se(e, t) {
273
+ if (!xe(e)) throw Error("This grant has no remaining credit to revoke.");
274
+ if (t = t.trim(), !t || t.length > 500) throw Error("Enter a reason of up to 500 characters.");
275
+ return {
276
+ grant: e.id,
277
+ reason: t
278
+ };
279
+ }
280
+ //#endregion
281
+ //#region src/admin/pages/customers/credits.tsx
282
+ function Ce({ customerId: e, currencies: t }) {
283
+ let { activeMerchant: n } = p(), r = n?.slug ?? "";
284
+ return /* @__PURE__ */ Q(we, {
285
+ merchant: r,
286
+ customer: e,
287
+ initialCurrency: t[0] ?? "USD"
288
+ }, `${r}:${e}`);
289
+ }
290
+ function we({ merchant: r, customer: i, initialCurrency: o }) {
291
+ let { id: s, text: c } = t(), { creditQueries: f } = a(), p = d(), [m, h] = J.useState(o), [y, x] = J.useState(o), S = k(m, 25), C = k(m, 25), [w, T] = J.useState(!1), [E, ee] = J.useState(null), D = X(f.grants(r, i, m, S.size, S.cursor)), O = X(f.transactions(r, i, m, C.size, C.cursor)), I = g(m);
292
+ return /* @__PURE__ */ $(q, { children: [
293
+ /* @__PURE__ */ $(W, {
294
+ className: "gap-3",
295
+ children: [
296
+ /* @__PURE__ */ $("div", {
297
+ className: "flex items-center justify-between gap-3",
298
+ children: [/* @__PURE__ */ Q(G, {
299
+ className: "text-sm",
300
+ children: /* @__PURE__ */ Q(e, { id: "Credits" })
301
+ }), p && /* @__PURE__ */ Q(l, {
302
+ variant: "outline",
303
+ size: "sm",
304
+ disabled: I === void 0,
305
+ onClick: () => T(!0),
306
+ children: /* @__PURE__ */ Q(e, { id: "Grant credit" })
307
+ })]
308
+ }),
309
+ /* @__PURE__ */ $("form", {
310
+ className: "flex max-w-sm items-end gap-2",
311
+ onSubmit: (e) => {
312
+ e.preventDefault();
313
+ let t = y.trim();
314
+ t && h(t.toUpperCase());
315
+ },
316
+ children: [/* @__PURE__ */ $("div", {
317
+ className: "grid gap-1",
318
+ children: [/* @__PURE__ */ Q(U, {
319
+ htmlFor: s("credit-currency"),
320
+ children: /* @__PURE__ */ Q(e, { id: "Currency" })
321
+ }), /* @__PURE__ */ Q(u, {
322
+ id: s("credit-currency"),
323
+ value: y,
324
+ onChange: (e) => x(e.target.value),
325
+ placeholder: c("USD")
326
+ })]
327
+ }), /* @__PURE__ */ Q(l, {
328
+ type: "submit",
329
+ variant: "outline",
330
+ size: "sm",
331
+ children: /* @__PURE__ */ Q(e, { id: "View" })
332
+ })]
333
+ }),
334
+ I === void 0 && /* @__PURE__ */ $("p", {
335
+ className: "text-xs text-muted-foreground",
336
+ children: [m, /* @__PURE__ */ Q(e, { id: " is not a supported currency." })]
337
+ })
338
+ ]
339
+ }),
340
+ /* @__PURE__ */ $(K, {
341
+ className: "grid gap-6",
342
+ children: [/* @__PURE__ */ $("section", {
343
+ "aria-label": c("Credit grants"),
344
+ children: [
345
+ /* @__PURE__ */ $("h3", {
346
+ className: "mb-2 text-sm font-medium",
347
+ children: [/* @__PURE__ */ Q(e, { id: "Grants · " }), m]
348
+ }),
349
+ D.isLoading ? /* @__PURE__ */ Q("p", {
350
+ className: "text-sm text-muted-foreground",
351
+ children: /* @__PURE__ */ Q(e, { id: "Loading grants…" })
352
+ }) : D.error ? /* @__PURE__ */ Q("p", {
353
+ role: "alert",
354
+ className: "text-sm text-destructive",
355
+ children: n(D.error).text
356
+ }) : D.data?.data.length ? /* @__PURE__ */ Q("div", {
357
+ className: "overflow-x-auto",
358
+ children: /* @__PURE__ */ $(te, { children: [/* @__PURE__ */ Q(N, { children: /* @__PURE__ */ $(F, { children: [
359
+ /* @__PURE__ */ Q(j, { children: /* @__PURE__ */ Q(e, { id: "Grant" }) }),
360
+ /* @__PURE__ */ Q(j, { children: /* @__PURE__ */ Q(e, { id: "Original" }) }),
361
+ /* @__PURE__ */ Q(j, { children: /* @__PURE__ */ Q(e, { id: "Remaining" }) }),
362
+ /* @__PURE__ */ Q(j, { children: /* @__PURE__ */ Q(e, { id: "Spent" }) }),
363
+ /* @__PURE__ */ Q(j, { children: /* @__PURE__ */ Q(e, { id: "Expired" }) }),
364
+ /* @__PURE__ */ Q(j, { children: /* @__PURE__ */ Q(e, { id: "Revoked" }) }),
365
+ /* @__PURE__ */ Q(j, { children: /* @__PURE__ */ Q(e, { id: "State" }) }),
366
+ /* @__PURE__ */ Q(j, { children: /* @__PURE__ */ Q(e, { id: "Expires" }) }),
367
+ /* @__PURE__ */ Q(j, {})
368
+ ] }) }), /* @__PURE__ */ Q(M, { children: D.data.data.map((t) => /* @__PURE__ */ $(F, { children: [
369
+ /* @__PURE__ */ $(P, { children: [
370
+ /* @__PURE__ */ Q("span", {
371
+ title: t.id,
372
+ children: b(t.id)
373
+ }),
374
+ /* @__PURE__ */ Q("div", {
375
+ className: "text-xs text-muted-foreground",
376
+ children: _(t.created_at)
377
+ }),
378
+ /* @__PURE__ */ Q("div", {
379
+ className: "text-xs text-muted-foreground",
380
+ children: t.description ?? t.source_type
381
+ })
382
+ ] }),
383
+ [
384
+ t.amount,
385
+ t.remaining_amount,
386
+ t.spent_amount,
387
+ t.expired_amount,
388
+ t.revoked_amount
389
+ ].map((e, n) => /* @__PURE__ */ Q(P, {
390
+ className: "tabular-nums",
391
+ children: v(e, t.currency)
392
+ }, n)),
393
+ /* @__PURE__ */ Q(P, { children: t.state }),
394
+ /* @__PURE__ */ Q(P, { children: t.expires_at ? _(t.expires_at) : "No expiry" }),
395
+ /* @__PURE__ */ Q(P, { children: p && /* @__PURE__ */ Q(l, {
396
+ size: "sm",
397
+ variant: "outline",
398
+ disabled: !xe(t),
399
+ onClick: () => ee(t),
400
+ children: /* @__PURE__ */ Q(e, { id: "Revoke" })
401
+ }) })
402
+ ] }, t.id)) })] })
403
+ }) : /* @__PURE__ */ Q("p", {
404
+ className: "text-sm text-muted-foreground",
405
+ children: /* @__PURE__ */ Q(e, { id: "No credit grants in this currency." })
406
+ }),
407
+ /* @__PURE__ */ Q(A, {
408
+ pages: S,
409
+ rows: D.data?.data?.length ?? 0,
410
+ nextCursor: D.data?.next_cursor,
411
+ busy: D.isFetching
412
+ })
413
+ ]
414
+ }), /* @__PURE__ */ $("section", {
415
+ "aria-label": c("Credit transaction ledger"),
416
+ children: [
417
+ /* @__PURE__ */ $("h3", {
418
+ className: "mb-2 text-sm font-medium",
419
+ children: [/* @__PURE__ */ Q(e, { id: "Transaction ledger · " }), m]
420
+ }),
421
+ O.isLoading ? /* @__PURE__ */ Q("p", {
422
+ className: "text-sm text-muted-foreground",
423
+ children: /* @__PURE__ */ Q(e, { id: "Loading transactions…" })
424
+ }) : O.error ? /* @__PURE__ */ Q("p", {
425
+ role: "alert",
426
+ className: "text-sm text-destructive",
427
+ children: n(O.error).text
428
+ }) : O.data?.data.length ? /* @__PURE__ */ $(te, { children: [/* @__PURE__ */ Q(N, { children: /* @__PURE__ */ $(F, { children: [
429
+ /* @__PURE__ */ Q(j, { children: /* @__PURE__ */ Q(e, { id: "Date" }) }),
430
+ /* @__PURE__ */ Q(j, { children: /* @__PURE__ */ Q(e, { id: "Type" }) }),
431
+ /* @__PURE__ */ Q(j, { children: /* @__PURE__ */ Q(e, { id: "Amount" }) }),
432
+ /* @__PURE__ */ Q(j, { children: /* @__PURE__ */ Q(e, { id: "Source" }) })
433
+ ] }) }), /* @__PURE__ */ Q(M, { children: O.data.data.map((e) => /* @__PURE__ */ $(F, { children: [
434
+ /* @__PURE__ */ Q(P, {
435
+ title: e.id,
436
+ children: _(e.created_at)
437
+ }),
438
+ /* @__PURE__ */ Q(P, { children: e.type.replaceAll("_", " ") }),
439
+ /* @__PURE__ */ Q(P, {
440
+ className: "tabular-nums",
441
+ children: v(e.amount, e.currency)
442
+ }),
443
+ /* @__PURE__ */ Q(P, { children: e.source || "—" })
444
+ ] }, e.id)) })] }) : /* @__PURE__ */ Q("p", {
445
+ className: "text-sm text-muted-foreground",
446
+ children: /* @__PURE__ */ Q(e, { id: "No transactions in this currency." })
447
+ }),
448
+ /* @__PURE__ */ Q(A, {
449
+ pages: C,
450
+ rows: O.data?.data?.length ?? 0,
451
+ nextCursor: O.data?.next_cursor,
452
+ busy: O.isFetching
453
+ })
454
+ ]
455
+ })]
456
+ }),
457
+ w && I !== void 0 && /* @__PURE__ */ Q(Te, {
458
+ merchant: r,
459
+ customer: i,
460
+ currency: m,
461
+ decimals: I,
462
+ onClose: () => T(!1)
463
+ }),
464
+ E && /* @__PURE__ */ Q(Ee, {
465
+ merchant: r,
466
+ customer: i,
467
+ grant: E,
468
+ onClose: () => ee(null)
469
+ })
470
+ ] });
471
+ }
472
+ function Te({ merchant: r, customer: i, currency: o, decimals: s, onClose: c }) {
473
+ let { toast: d, creditMutations: f } = a(), { id: p } = t(), m = Z(), h = Y(f.grant(m, r, i)), [g, _] = J.useState(""), [v, y] = J.useState(""), [b, x] = J.useState(""), [S] = J.useState(() => crypto.randomUUID()), [C, w] = J.useState("");
474
+ return /* @__PURE__ */ Q(H, {
475
+ open: !0,
476
+ onOpenChange: (e) => {
477
+ !e && !h.isPending && c();
478
+ },
479
+ children: /* @__PURE__ */ $(z, {
480
+ className: re,
481
+ children: [/* @__PURE__ */ $(L, { children: [/* @__PURE__ */ Q(B, { children: /* @__PURE__ */ Q(e, { id: "Grant credit" }) }), /* @__PURE__ */ $(V, { children: [
482
+ /* @__PURE__ */ Q(e, { id: "Add credit in " }),
483
+ o,
484
+ /* @__PURE__ */ Q(e, { id: " to this customer." })
485
+ ] })] }), /* @__PURE__ */ $("form", {
486
+ className: "grid gap-4",
487
+ onSubmit: async (e) => {
488
+ e.preventDefault(), w("");
489
+ try {
490
+ let e = be({
491
+ amount: g,
492
+ currency: o,
493
+ decimals: s,
494
+ expires: v,
495
+ description: b,
496
+ sourceID: S
497
+ });
498
+ await h.mutateAsync(e), d.success("Credit granted"), c();
499
+ } catch (e) {
500
+ w(n(e).text);
501
+ }
502
+ },
503
+ children: [
504
+ /* @__PURE__ */ $("div", {
505
+ className: "grid gap-1",
506
+ children: [/* @__PURE__ */ $(U, {
507
+ htmlFor: p("grant-amount"),
508
+ children: [
509
+ /* @__PURE__ */ Q(e, { id: "Amount (" }),
510
+ o,
511
+ ")"
512
+ ]
513
+ }), /* @__PURE__ */ Q(u, {
514
+ id: p("grant-amount"),
515
+ inputMode: "decimal",
516
+ value: g,
517
+ onChange: (e) => _(e.target.value),
518
+ autoFocus: !0
519
+ })]
520
+ }),
521
+ /* @__PURE__ */ $("div", {
522
+ className: "grid gap-1",
523
+ children: [/* @__PURE__ */ Q(U, {
524
+ htmlFor: p("grant-expiry"),
525
+ children: /* @__PURE__ */ Q(e, { id: "Expires (optional)" })
526
+ }), /* @__PURE__ */ Q(u, {
527
+ id: p("grant-expiry"),
528
+ type: "datetime-local",
529
+ value: v,
530
+ onChange: (e) => y(e.target.value)
531
+ })]
532
+ }),
533
+ /* @__PURE__ */ $("div", {
534
+ className: "grid gap-1",
535
+ children: [/* @__PURE__ */ Q(U, {
536
+ htmlFor: p("grant-description"),
537
+ children: /* @__PURE__ */ Q(e, { id: "Description (optional)" })
538
+ }), /* @__PURE__ */ Q(u, {
539
+ id: p("grant-description"),
540
+ value: b,
541
+ onChange: (e) => x(e.target.value),
542
+ maxLength: 500
543
+ })]
544
+ }),
545
+ C && /* @__PURE__ */ Q("p", {
546
+ role: "alert",
547
+ className: "text-sm text-destructive",
548
+ children: C
549
+ }),
550
+ /* @__PURE__ */ $(R, { children: [/* @__PURE__ */ Q(l, {
551
+ type: "button",
552
+ variant: "outline",
553
+ disabled: h.isPending,
554
+ onClick: c,
555
+ children: /* @__PURE__ */ Q(e, { id: "Cancel" })
556
+ }), /* @__PURE__ */ Q(l, {
557
+ type: "submit",
558
+ disabled: h.isPending,
559
+ children: h.isPending ? "Granting…" : "Grant credit"
560
+ })] })
561
+ ]
562
+ })]
563
+ })
564
+ });
565
+ }
566
+ function Ee({ merchant: r, customer: i, grant: o, onClose: s }) {
567
+ let { toast: c, creditMutations: d } = a(), { id: f } = t(), p = Z(), m = Y(d.revoke(p, r, i)), [h, g] = J.useState(""), [_, y] = J.useState("");
568
+ return /* @__PURE__ */ Q(H, {
569
+ open: !0,
570
+ onOpenChange: (e) => {
571
+ !e && !m.isPending && s();
572
+ },
573
+ children: /* @__PURE__ */ $(z, {
574
+ className: re,
575
+ children: [/* @__PURE__ */ $(L, { children: [/* @__PURE__ */ Q(B, { children: /* @__PURE__ */ Q(e, { id: "Revoke remaining credit" }) }), /* @__PURE__ */ $(V, { children: [
576
+ /* @__PURE__ */ Q(e, { id: "Revoke the unspent remainder of" }),
577
+ " ",
578
+ v(o.remaining_amount, o.currency),
579
+ /* @__PURE__ */ Q(e, { id: ". Active holds may prevent revocation. Payment refunds are managed separately." })
580
+ ] })] }), /* @__PURE__ */ $("form", {
581
+ className: "grid gap-4",
582
+ onSubmit: async (e) => {
583
+ e.preventDefault(), y("");
584
+ try {
585
+ let e = await m.mutateAsync(Se(o, h));
586
+ c.success(e.replayed ? "Credit was already revoked" : `${v(e.revoked_amount, e.currency)} revoked`), s();
587
+ } catch (e) {
588
+ y(n(e).text);
589
+ }
590
+ },
591
+ children: [
592
+ /* @__PURE__ */ $("div", {
593
+ className: "grid gap-1",
594
+ children: [/* @__PURE__ */ Q(U, {
595
+ htmlFor: f("revoke-reason"),
596
+ children: /* @__PURE__ */ Q(e, { id: "Reason" })
597
+ }), /* @__PURE__ */ Q(u, {
598
+ id: f("revoke-reason"),
599
+ value: h,
600
+ onChange: (e) => g(e.target.value),
601
+ maxLength: 500,
602
+ autoFocus: !0
603
+ })]
604
+ }),
605
+ _ && /* @__PURE__ */ Q("p", {
606
+ role: "alert",
607
+ className: "text-sm text-destructive",
608
+ children: _
609
+ }),
610
+ /* @__PURE__ */ $(R, { children: [/* @__PURE__ */ Q(l, {
611
+ type: "button",
612
+ variant: "outline",
613
+ disabled: m.isPending,
614
+ onClick: s,
615
+ children: /* @__PURE__ */ Q(e, { id: "Cancel" })
616
+ }), /* @__PURE__ */ Q(l, {
617
+ type: "submit",
618
+ variant: "destructive",
619
+ disabled: !xe(o) || m.isPending,
620
+ children: m.isPending ? "Revoking…" : "Revoke credit"
621
+ })] })
622
+ ]
623
+ })]
624
+ })
625
+ });
626
+ }
627
+ //#endregion
628
+ //#region src/admin/pages/customers/grant-duration.ts
629
+ var De = [
630
+ {
631
+ value: "1",
632
+ label: "1 day",
633
+ days: 1
634
+ },
635
+ {
636
+ value: "7",
637
+ label: "7 days",
638
+ days: 7
639
+ },
640
+ {
641
+ value: "30",
642
+ label: "30 days",
643
+ days: 30
644
+ },
645
+ {
646
+ value: "365",
647
+ label: "365 days",
648
+ days: 365
649
+ },
650
+ {
651
+ value: "until",
652
+ label: "Until a date"
653
+ },
654
+ {
655
+ value: "never",
656
+ label: "Never expires"
657
+ }
658
+ ], Oe = (e) => e.toISOString().slice(0, 10);
659
+ function ke(e, t, n = /* @__PURE__ */ new Date()) {
660
+ if (e === "never") return {};
661
+ if (e === "until") {
662
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(t) || t < Oe(n)) return null;
663
+ let e = /* @__PURE__ */ new Date(`${t}T00:00:00Z`);
664
+ return e.setUTCDate(e.getUTCDate() + 1), { endsAt: e.toISOString() };
665
+ }
666
+ let r = De.find((t) => t.value === e);
667
+ return r && "days" in r ? { hours: r.days * 24 } : null;
668
+ }
669
+ //#endregion
670
+ //#region src/admin/pages/customers/detail.tsx
671
+ function Ae() {
672
+ let { text: n } = t(), { props: c } = i(), { adminQueries: u } = a(), p = d(), m = f(), { customerId: h = "" } = r(), g = s(), { data: y, isPending: b, error: x } = X(u.customer(h));
673
+ return b ? /* @__PURE__ */ Q("p", {
674
+ className: "text-sm text-muted-foreground",
675
+ children: /* @__PURE__ */ Q(e, { id: "Loading…" })
676
+ }) : y ? /* @__PURE__ */ $("div", {
677
+ className: "flex min-w-0 flex-col gap-4",
678
+ children: [
679
+ /* @__PURE__ */ $("div", {
680
+ className: "flex flex-wrap items-center gap-3",
681
+ children: [
682
+ /* @__PURE__ */ Q(l, {
683
+ variant: "ghost",
684
+ size: "icon",
685
+ onClick: () => g(-1),
686
+ "aria-label": n("Back"),
687
+ children: /* @__PURE__ */ Q(de, {
688
+ icon: pe,
689
+ className: "size-4"
690
+ })
691
+ }),
692
+ /* @__PURE__ */ $("div", {
693
+ className: "min-w-0 flex-1",
694
+ children: [/* @__PURE__ */ Q("h1", {
695
+ className: "text-2xl font-semibold tracking-tight [overflow-wrap:anywhere]",
696
+ children: y.contact?.name || y.contact?.email || "Customer"
697
+ }), /* @__PURE__ */ $("p", {
698
+ className: "text-xs [overflow-wrap:anywhere] text-muted-foreground",
699
+ children: [
700
+ y.id,
701
+ /* @__PURE__ */ Q(e, { id: " · since " }),
702
+ _(y.created_at),
703
+ /* @__PURE__ */ Q(e, { id: " · last seen" }),
704
+ " ",
705
+ _(y.last_seen_at)
706
+ ]
707
+ })]
708
+ }),
709
+ p && /* @__PURE__ */ Q("div", {
710
+ className: "flex gap-2 @max-[36rem]/page:w-full",
711
+ children: /* @__PURE__ */ Q(Le, { customerId: h })
712
+ })
713
+ ]
714
+ }),
715
+ /* @__PURE__ */ Q(Re, { contact: y.contact }),
716
+ c.userHref && /* @__PURE__ */ Q("a", {
717
+ className: "underline",
718
+ href: c.userHref(y.id),
719
+ children: /* @__PURE__ */ Q(e, { id: "View user account" })
720
+ }),
721
+ c.customerPanels?.(y),
722
+ y.balances.length > 0 && /* @__PURE__ */ Q("div", {
723
+ className: "grid gap-3 grid-cols-[minmax(0,1fr)] @min-[20.75rem]/page:grid-cols-2 @min-[42.25rem]/page:grid-cols-4",
724
+ children: y.balances.map((t) => /* @__PURE__ */ $(q, { children: [/* @__PURE__ */ Q(W, {
725
+ className: "pb-1",
726
+ children: /* @__PURE__ */ $(G, {
727
+ className: "text-xs font-normal text-muted-foreground uppercase",
728
+ children: [t.currency, /* @__PURE__ */ Q(e, { id: " balance" })]
729
+ })
730
+ }), /* @__PURE__ */ $(K, { children: [/* @__PURE__ */ Q("p", {
731
+ className: "text-lg font-semibold",
732
+ children: v(t.balance_amount, t.currency)
733
+ }), /* @__PURE__ */ $("p", {
734
+ className: "text-xs text-muted-foreground",
735
+ children: [
736
+ /* @__PURE__ */ Q(e, { id: "held " }),
737
+ v(t.held_amount, t.currency),
738
+ /* @__PURE__ */ Q(e, { id: " · owed" }),
739
+ " ",
740
+ v(t.owed_amount, t.currency)
741
+ ]
742
+ })] })] }, t.currency))
743
+ }),
744
+ y.balances.some((e) => BigInt(e.owed_amount) > 0n) && /* @__PURE__ */ Q("p", {
745
+ className: "text-sm",
746
+ children: /* @__PURE__ */ Q(o, {
747
+ className: "underline-offset-2 hover:underline",
748
+ to: `/orders?customer_id=${y.id}&origin=usage&overdue=true`,
749
+ children: /* @__PURE__ */ Q(e, { id: "Overdue usage orders" })
750
+ })
751
+ }),
752
+ m?.credit && /* @__PURE__ */ Q(Ce, {
753
+ customerId: h,
754
+ currencies: y.balances.map((e) => e.currency)
755
+ }),
756
+ m?.usage && /* @__PURE__ */ Q(_e, { customerId: h }),
757
+ /* @__PURE__ */ $("div", {
758
+ className: "grid gap-4 @min-[56rem]/page:grid-cols-3 @min-[56rem]/page:items-start",
759
+ children: [/* @__PURE__ */ $("div", {
760
+ className: "grid gap-4 @min-[56rem]/page:col-span-2",
761
+ children: [
762
+ /* @__PURE__ */ Q(je, { customerId: h }),
763
+ /* @__PURE__ */ Q(Me, { customerId: h }),
764
+ /* @__PURE__ */ Q(Ne, { customerId: h })
765
+ ]
766
+ }), /* @__PURE__ */ $("div", {
767
+ className: "grid gap-4",
768
+ children: [/* @__PURE__ */ Q(Pe, { customerId: h }), /* @__PURE__ */ Q(Fe, { customerId: h })]
769
+ })]
770
+ })
771
+ ]
772
+ }) : /* @__PURE__ */ Q(ce, {
773
+ title: "Customer not found",
774
+ error: x,
775
+ back: "/customers",
776
+ backLabel: "Customers"
777
+ });
778
+ }
779
+ function je({ customerId: t }) {
780
+ let { adminQueries: n } = a(), r = k(t, 25), { data: i, isFetching: s } = X(n.customerSubscriptions(t, r.size, r.cursor)), c = i?.data ?? [];
781
+ return /* @__PURE__ */ $(q, { children: [/* @__PURE__ */ Q(W, { children: /* @__PURE__ */ Q(G, {
782
+ className: "text-sm",
783
+ children: /* @__PURE__ */ Q(e, { id: "Subscriptions" })
784
+ }) }), /* @__PURE__ */ $(K, {
785
+ className: "grid gap-3",
786
+ children: [c.length === 0 ? /* @__PURE__ */ Q("p", {
787
+ className: "text-sm text-muted-foreground",
788
+ children: /* @__PURE__ */ Q(e, { id: "No subscriptions." })
789
+ }) : /* @__PURE__ */ $(te, { children: [/* @__PURE__ */ Q(N, { children: /* @__PURE__ */ $(F, {
790
+ className: "hover:bg-transparent",
791
+ children: [
792
+ /* @__PURE__ */ Q(j, {
793
+ className: "text-muted-foreground",
794
+ children: /* @__PURE__ */ Q(e, { id: "Subscription" })
795
+ }),
796
+ /* @__PURE__ */ Q(j, {
797
+ className: "text-muted-foreground",
798
+ children: /* @__PURE__ */ Q(e, { id: "Status" })
799
+ }),
800
+ /* @__PURE__ */ Q(j, {
801
+ className: "text-muted-foreground @max-[36rem]/page:hidden",
802
+ children: /* @__PURE__ */ Q(e, { id: "Rail" })
803
+ }),
804
+ /* @__PURE__ */ Q(j, {
805
+ className: "text-muted-foreground",
806
+ children: /* @__PURE__ */ Q(e, { id: "Period ends" })
807
+ }),
808
+ /* @__PURE__ */ Q(j, {
809
+ className: "text-muted-foreground @max-[36rem]/page:hidden",
810
+ children: /* @__PURE__ */ Q(e, { id: "Dunning" })
811
+ })
812
+ ]
813
+ }) }), /* @__PURE__ */ Q(M, { children: c.map((e) => /* @__PURE__ */ $(I, {
814
+ to: `/subscriptions/${e.id}`,
815
+ children: [
816
+ /* @__PURE__ */ Q(P, { children: /* @__PURE__ */ Q(o, {
817
+ className: "text-xs underline-offset-2 hover:underline",
818
+ to: `/subscriptions/${e.id}`,
819
+ children: b(e.id, 13)
820
+ }) }),
821
+ /* @__PURE__ */ Q(P, { children: /* @__PURE__ */ Q(C, { status: e.status }) }),
822
+ /* @__PURE__ */ Q(P, {
823
+ className: "@max-[36rem]/page:hidden",
824
+ children: e.rail
825
+ }),
826
+ /* @__PURE__ */ Q(P, {
827
+ className: "tabular-nums @max-[36rem]/page:whitespace-normal",
828
+ children: _(e.current_period_ends_at)
829
+ }),
830
+ /* @__PURE__ */ Q(P, {
831
+ className: "text-xs @max-[36rem]/page:hidden",
832
+ children: e.dunning ? se(e.dunning) : "—"
833
+ })
834
+ ]
835
+ }, e.id)) })] }), /* @__PURE__ */ Q(A, {
836
+ pages: r,
837
+ rows: i?.data?.length ?? 0,
838
+ nextCursor: i?.next_cursor,
839
+ busy: s
840
+ })]
841
+ })] });
842
+ }
843
+ function Me({ customerId: t }) {
844
+ let { adminQueries: n } = a(), r = k(t, 25), { data: i, isFetching: s } = X(n.customerPayments(t, r.size, r.cursor)), c = i?.data ?? [];
845
+ return /* @__PURE__ */ $(q, { children: [/* @__PURE__ */ Q(W, { children: /* @__PURE__ */ Q(G, {
846
+ className: "text-sm",
847
+ children: /* @__PURE__ */ Q(e, { id: "Payments" })
848
+ }) }), /* @__PURE__ */ $(K, {
849
+ className: "grid gap-3",
850
+ children: [c.length === 0 ? /* @__PURE__ */ Q("p", {
851
+ className: "text-sm text-muted-foreground",
852
+ children: /* @__PURE__ */ Q(e, { id: "No payments." })
853
+ }) : /* @__PURE__ */ $(te, { children: [/* @__PURE__ */ Q(N, { children: /* @__PURE__ */ $(F, {
854
+ className: "hover:bg-transparent",
855
+ children: [
856
+ /* @__PURE__ */ Q(j, {
857
+ className: "text-muted-foreground",
858
+ children: /* @__PURE__ */ Q(e, { id: "Payment" })
859
+ }),
860
+ /* @__PURE__ */ Q(j, {
861
+ className: "text-muted-foreground",
862
+ children: /* @__PURE__ */ Q(e, { id: "Status" })
863
+ }),
864
+ /* @__PURE__ */ Q(j, {
865
+ className: "text-muted-foreground",
866
+ children: /* @__PURE__ */ Q(e, { id: "Amount" })
867
+ }),
868
+ /* @__PURE__ */ Q(j, {
869
+ className: "text-muted-foreground @max-[36rem]/page:hidden",
870
+ children: /* @__PURE__ */ Q(e, { id: "Kind" })
871
+ }),
872
+ /* @__PURE__ */ Q(j, {
873
+ className: "text-muted-foreground @max-[36rem]/page:hidden",
874
+ children: /* @__PURE__ */ Q(e, { id: "Rail" })
875
+ }),
876
+ /* @__PURE__ */ Q(j, {
877
+ className: "text-muted-foreground @max-[36rem]/page:hidden",
878
+ children: /* @__PURE__ */ Q(e, { id: "Purchased" })
879
+ })
880
+ ]
881
+ }) }), /* @__PURE__ */ Q(M, { children: c.map((e) => /* @__PURE__ */ $(I, {
882
+ to: `/payments/${e.id}`,
883
+ children: [
884
+ /* @__PURE__ */ Q(P, { children: /* @__PURE__ */ Q(o, {
885
+ className: "text-xs underline-offset-2 hover:underline",
886
+ to: `/payments/${e.id}`,
887
+ children: b(e.id, 13)
888
+ }) }),
889
+ /* @__PURE__ */ Q(P, { children: /* @__PURE__ */ Q(C, { status: e.status }) }),
890
+ /* @__PURE__ */ Q(P, {
891
+ className: "tabular-nums",
892
+ children: v(e.amount, e.currency)
893
+ }),
894
+ /* @__PURE__ */ Q(P, {
895
+ className: "@max-[36rem]/page:hidden",
896
+ children: e.kind
897
+ }),
898
+ /* @__PURE__ */ Q(P, {
899
+ className: "@max-[36rem]/page:hidden",
900
+ children: e.rail ?? e.channel
901
+ }),
902
+ /* @__PURE__ */ Q(P, {
903
+ className: "tabular-nums @max-[36rem]/page:hidden",
904
+ children: _(e.created_at)
905
+ })
906
+ ]
907
+ }, e.id)) })] }), /* @__PURE__ */ Q(A, {
908
+ pages: r,
909
+ rows: i?.data?.length ?? 0,
910
+ nextCursor: i?.next_cursor,
911
+ busy: s
912
+ })]
913
+ })] });
914
+ }
915
+ function Ne({ customerId: n }) {
916
+ let { adminQueries: r, queryKeys: i, deleteCustomerPaymentMethod: o, toast: s, toastApiError: u } = a(), { text: f } = t(), p = d(), g = x(), _ = Z(), v = Y({
917
+ mutationFn: (e) => o(n, e),
918
+ onSuccess: () => _.invalidateQueries({ queryKey: [...i.customer(n), "payment-methods"] }),
919
+ onError: (e) => u(e, "Remove payment method")
920
+ }), y = k(n, 25), { data: b, isFetching: C } = X(r.customerPaymentMethodsPage(n, y.size, y.cursor)), w = b?.data ?? [];
921
+ return /* @__PURE__ */ $(q, { children: [/* @__PURE__ */ $(W, { children: [/* @__PURE__ */ Q(G, {
922
+ className: "text-sm",
923
+ children: /* @__PURE__ */ Q(e, { id: "Payment methods" })
924
+ }), /* @__PURE__ */ $(l, {
925
+ variant: "ghost",
926
+ size: "sm",
927
+ disabled: C,
928
+ onClick: async () => {
929
+ await _.invalidateQueries({ queryKey: [...i.customer(n), "payment-methods"] }), s.success(f("Payment methods are up to date"));
930
+ },
931
+ children: [/* @__PURE__ */ Q(de, {
932
+ icon: he,
933
+ className: c("size-3.5", C && "animate-spin")
934
+ }), f(C ? "Refreshing…" : "Refresh payment methods")]
935
+ })] }), /* @__PURE__ */ $(K, {
936
+ className: "grid gap-3",
937
+ children: [w.length === 0 ? /* @__PURE__ */ Q("p", {
938
+ className: "text-sm text-muted-foreground",
939
+ children: /* @__PURE__ */ Q(e, { id: "No payment methods on file." })
940
+ }) : /* @__PURE__ */ Q("div", {
941
+ className: "flex flex-wrap gap-3",
942
+ children: w.map((t) => /* @__PURE__ */ $("div", {
943
+ className: "rounded-md border p-3 text-sm",
944
+ children: [
945
+ /* @__PURE__ */ Q("p", {
946
+ className: "font-medium",
947
+ children: h(t.card)
948
+ }),
949
+ /* @__PURE__ */ $("p", {
950
+ className: "text-xs text-muted-foreground",
951
+ children: [
952
+ t.rail,
953
+ /* @__PURE__ */ Q(e, { id: " · exp " }),
954
+ m(t.card)
955
+ ]
956
+ }),
957
+ /* @__PURE__ */ Q(ye, { currencies: t.default_currencies ?? [] }),
958
+ p && t.rail === "nmi" && t.status !== "removed" && /* @__PURE__ */ Q(l, {
959
+ size: "sm",
960
+ variant: "outline",
961
+ className: "mt-2",
962
+ disabled: v.isPending,
963
+ onClick: async () => {
964
+ await g({
965
+ title: "Remove this saved card?",
966
+ description: "The vault will remove the card once no active subscription or payment uses it. Transaction history remains.",
967
+ confirmLabel: "Remove saved card"
968
+ }) && v.mutate(t.id);
969
+ },
970
+ children: "Remove saved card"
971
+ }),
972
+ t.health.expiry_status && t.health.expiry_status !== "valid" && /* @__PURE__ */ Q(S, {
973
+ variant: "secondary",
974
+ className: "bg-held-surface text-held mt-1",
975
+ children: t.health.expiry_status
976
+ })
977
+ ]
978
+ }, t.id))
979
+ }), /* @__PURE__ */ Q(A, {
980
+ pages: y,
981
+ rows: b?.data?.length ?? 0,
982
+ nextCursor: b?.next_cursor,
983
+ busy: C
984
+ })]
985
+ })] });
986
+ }
987
+ function Pe({ customerId: t }) {
988
+ let { adminQueries: n } = a(), r = k(t, 25), { data: i, isFetching: o } = X(n.customerEntitlements(t, r.size, r.cursor)), s = i?.data ?? [];
989
+ return /* @__PURE__ */ $(q, { children: [/* @__PURE__ */ Q(W, { children: /* @__PURE__ */ Q(G, {
990
+ className: "text-sm",
991
+ children: /* @__PURE__ */ Q(e, { id: "Entitlements" })
992
+ }) }), /* @__PURE__ */ $(K, {
993
+ className: "grid gap-3",
994
+ children: [
995
+ /* @__PURE__ */ Q("p", {
996
+ className: "text-xs text-muted-foreground",
997
+ children: /* @__PURE__ */ Q(e, { id: "The keys of the products this customer holds now." })
998
+ }),
999
+ s.length === 0 ? /* @__PURE__ */ Q("p", {
1000
+ className: "text-sm text-muted-foreground",
1001
+ children: /* @__PURE__ */ Q(e, { id: "No entitlements." })
1002
+ }) : /* @__PURE__ */ Q("div", {
1003
+ className: "flex flex-wrap gap-2",
1004
+ children: s.map((e) => /* @__PURE__ */ Q(S, {
1005
+ variant: "secondary",
1006
+ children: e.entitlement
1007
+ }, e.entitlement))
1008
+ }),
1009
+ /* @__PURE__ */ Q(A, {
1010
+ pages: r,
1011
+ rows: i?.data?.length ?? 0,
1012
+ nextCursor: i?.next_cursor,
1013
+ busy: o
1014
+ })
1015
+ ]
1016
+ })] });
1017
+ }
1018
+ function Fe({ customerId: n }) {
1019
+ let { text: r } = t(), { adminQueries: i } = a(), o = d(), s = k(n, 25), { data: c, isFetching: l } = X(i.customerProductAccess(n, s.size, s.cursor)), u = c?.data ?? [];
1020
+ return /* @__PURE__ */ $(q, { children: [/* @__PURE__ */ Q(W, { children: /* @__PURE__ */ Q(G, {
1021
+ className: "text-sm",
1022
+ children: /* @__PURE__ */ Q(e, { id: "Product access" })
1023
+ }) }), /* @__PURE__ */ $(K, {
1024
+ className: "grid gap-3",
1025
+ children: [u.length === 0 ? /* @__PURE__ */ Q("p", {
1026
+ className: "text-sm text-muted-foreground",
1027
+ children: /* @__PURE__ */ Q(e, { id: "No product access." })
1028
+ }) : /* @__PURE__ */ Q("div", {
1029
+ className: "grid gap-4",
1030
+ children: u.map((e) => /* @__PURE__ */ $("div", {
1031
+ className: "flex min-w-0 items-start gap-3",
1032
+ children: [/* @__PURE__ */ $("div", {
1033
+ className: "min-w-0 flex-1",
1034
+ children: [
1035
+ /* @__PURE__ */ $("div", {
1036
+ className: "flex min-w-0 items-center gap-2",
1037
+ children: [/* @__PURE__ */ Q("p", {
1038
+ className: "truncate text-sm font-medium",
1039
+ children: e.product_name || b(e.product_id, 13)
1040
+ }), /* @__PURE__ */ Q(C, { status: e.status })]
1041
+ }),
1042
+ /* @__PURE__ */ Q("p", {
1043
+ className: "mt-1 text-xs text-muted-foreground",
1044
+ children: e.source_type === "grant" ? `Granted (${e.grant_reason ?? "staff"})${e.note ? `: ${e.note}` : ""}` : e.source_type
1045
+ }),
1046
+ /* @__PURE__ */ Q("p", {
1047
+ className: "text-xs text-muted-foreground tabular-nums",
1048
+ children: e.ends_at ? `Ends ${_(e.ends_at)}` : "No end date"
1049
+ })
1050
+ ]
1051
+ }), o && /* @__PURE__ */ Q(Ie, {
1052
+ customerId: n,
1053
+ grantId: e.id,
1054
+ label: r("Revoke product access")
1055
+ })]
1056
+ }, e.id))
1057
+ }), /* @__PURE__ */ Q(A, {
1058
+ pages: s,
1059
+ rows: c?.data?.length ?? 0,
1060
+ nextCursor: c?.next_cursor,
1061
+ busy: l
1062
+ })]
1063
+ })] });
1064
+ }
1065
+ function Ie({ customerId: n, grantId: r, label: i }) {
1066
+ let { toast: o, toastApiError: s, adminMutations: c } = a(), { id: d } = t(), f = Z(), p = Y(c.revokeCustomerProductAccess(f, n)), [m, h] = J.useState(!1), [g, _] = J.useState("");
1067
+ return /* @__PURE__ */ $(H, {
1068
+ open: m,
1069
+ onOpenChange: h,
1070
+ children: [/* @__PURE__ */ Q(ne, { render: /* @__PURE__ */ Q(l, {
1071
+ variant: "ghost",
1072
+ size: "icon",
1073
+ "aria-label": i,
1074
+ children: /* @__PURE__ */ Q(de, {
1075
+ icon: me,
1076
+ className: "size-4 text-destructive"
1077
+ })
1078
+ }) }), /* @__PURE__ */ $(z, {
1079
+ className: ie,
1080
+ children: [
1081
+ /* @__PURE__ */ $(L, { children: [/* @__PURE__ */ Q(B, { children: /* @__PURE__ */ Q(e, { id: "Take the product back" }) }), /* @__PURE__ */ Q(V, { children: /* @__PURE__ */ Q(e, { id: "The customer loses its entitlements now. The grant stays on record with your reason." }) })] }),
1082
+ /* @__PURE__ */ $("div", {
1083
+ className: "flex flex-col gap-1.5",
1084
+ children: [/* @__PURE__ */ Q(U, {
1085
+ htmlFor: d("revoke-access-reason"),
1086
+ children: /* @__PURE__ */ Q(e, { id: "Reason" })
1087
+ }), /* @__PURE__ */ Q(u, {
1088
+ id: d("revoke-access-reason"),
1089
+ value: g,
1090
+ onChange: (e) => _(e.target.value),
1091
+ maxLength: 500
1092
+ })]
1093
+ }),
1094
+ /* @__PURE__ */ $(R, { children: [/* @__PURE__ */ Q(l, {
1095
+ variant: "outline",
1096
+ onClick: () => h(!1),
1097
+ children: /* @__PURE__ */ Q(e, { id: "Cancel" })
1098
+ }), /* @__PURE__ */ Q(l, {
1099
+ variant: "destructive",
1100
+ disabled: !g.trim() || p.isPending,
1101
+ onClick: async () => {
1102
+ try {
1103
+ await p.mutateAsync({
1104
+ grantId: r,
1105
+ reason: g.trim()
1106
+ }), o.success("Product access revoked"), h(!1);
1107
+ } catch (e) {
1108
+ s(e, i);
1109
+ }
1110
+ },
1111
+ children: p.isPending ? "Revoking…" : "Revoke"
1112
+ })] })
1113
+ ]
1114
+ })]
1115
+ });
1116
+ }
1117
+ function Le({ customerId: n }) {
1118
+ let { toast: r, toastApiError: i, adminMutations: o, adminQueries: s } = a(), { id: c, text: d } = t(), [f, p] = J.useState(!1), m = Z(), h = Y(o.grantCustomerProductAccess(m, n)), { data: g } = X({
1119
+ ...s.allProducts(),
1120
+ enabled: f
1121
+ }), _ = ge({
1122
+ defaultValues: {
1123
+ productId: "",
1124
+ duration: "30",
1125
+ until: "",
1126
+ note: ""
1127
+ },
1128
+ onSubmit: async ({ value: e }) => {
1129
+ let t = ke(e.duration, e.until);
1130
+ if (t) try {
1131
+ await h.mutateAsync({
1132
+ productId: e.productId,
1133
+ ...t,
1134
+ note: e.note.trim() || void 0
1135
+ }), r.success("Product access granted"), v(!1);
1136
+ } catch (e) {
1137
+ i(e, "Grant product access");
1138
+ }
1139
+ }
1140
+ }), v = (e) => {
1141
+ p(e), e || (_.reset(), h.reset());
1142
+ };
1143
+ return /* @__PURE__ */ $(H, {
1144
+ open: f,
1145
+ onOpenChange: v,
1146
+ children: [/* @__PURE__ */ Q(ne, { render: /* @__PURE__ */ $(l, {
1147
+ variant: "outline",
1148
+ size: "sm",
1149
+ children: [/* @__PURE__ */ Q(de, {
1150
+ icon: fe,
1151
+ className: "size-4"
1152
+ }), /* @__PURE__ */ Q(e, { id: " Product access" })]
1153
+ }) }), /* @__PURE__ */ $(z, {
1154
+ className: ie,
1155
+ children: [/* @__PURE__ */ $(L, { children: [/* @__PURE__ */ Q(B, { children: /* @__PURE__ */ Q(e, { id: "Grant product access" }) }), /* @__PURE__ */ Q(V, { children: /* @__PURE__ */ Q(e, { id: "Give this customer one of your products without a payment. They hold its keys while the grant lasts, including keys you add to the product later." }) })] }), /* @__PURE__ */ $("form", {
1156
+ onSubmit: (e) => {
1157
+ e.preventDefault(), e.stopPropagation(), _.handleSubmit();
1158
+ },
1159
+ className: "grid gap-4",
1160
+ children: [/* @__PURE__ */ $("div", {
1161
+ className: "grid gap-3",
1162
+ children: [
1163
+ /* @__PURE__ */ Q(_.Field, {
1164
+ name: "productId",
1165
+ validators: { onChange: ({ value: e }) => e ? void 0 : "Pick a product" },
1166
+ children: (t) => /* @__PURE__ */ $("div", {
1167
+ className: "grid gap-1.5",
1168
+ children: [
1169
+ /* @__PURE__ */ Q(U, {
1170
+ htmlFor: c("pa-product"),
1171
+ children: /* @__PURE__ */ Q(e, { id: "Product" })
1172
+ }),
1173
+ /* @__PURE__ */ $(O, {
1174
+ value: t.state.value,
1175
+ onValueChange: (e) => t.handleChange(e ?? ""),
1176
+ children: [/* @__PURE__ */ Q(E, {
1177
+ className: "w-full",
1178
+ id: c("pa-product"),
1179
+ "aria-invalid": t.state.meta.errors.length > 0,
1180
+ children: /* @__PURE__ */ Q(T, { placeholder: d("Pick a product") })
1181
+ }), /* @__PURE__ */ Q(ee, { children: (g?.data ?? []).map((e) => /* @__PURE__ */ $(D, {
1182
+ value: e.id,
1183
+ children: [
1184
+ e.display_name,
1185
+ " (",
1186
+ e.key,
1187
+ ")"
1188
+ ]
1189
+ }, e.id)) })]
1190
+ }),
1191
+ /* @__PURE__ */ Q(w, { errors: t.state.meta.errors })
1192
+ ]
1193
+ })
1194
+ }),
1195
+ /* @__PURE__ */ Q(_.Field, {
1196
+ name: "duration",
1197
+ children: (t) => /* @__PURE__ */ $("div", {
1198
+ className: "grid gap-1.5",
1199
+ children: [
1200
+ /* @__PURE__ */ Q(U, {
1201
+ htmlFor: c("pa-duration"),
1202
+ children: /* @__PURE__ */ Q(e, { id: "How long it lasts" })
1203
+ }),
1204
+ /* @__PURE__ */ Q("p", {
1205
+ className: "text-[13px] text-muted-foreground",
1206
+ children: /* @__PURE__ */ Q(e, { id: "Days are added after any access they already have." })
1207
+ }),
1208
+ /* @__PURE__ */ $(O, {
1209
+ items: De.map((e) => ({
1210
+ value: e.value,
1211
+ label: e.label
1212
+ })),
1213
+ value: t.state.value,
1214
+ onValueChange: (e) => {
1215
+ e && t.handleChange(e);
1216
+ },
1217
+ children: [/* @__PURE__ */ Q(E, {
1218
+ className: "w-full",
1219
+ id: c("pa-duration"),
1220
+ children: /* @__PURE__ */ Q(T, {})
1221
+ }), /* @__PURE__ */ Q(ee, { children: De.map((e) => /* @__PURE__ */ Q(D, {
1222
+ value: e.value,
1223
+ children: e.label
1224
+ }, e.value)) })]
1225
+ })
1226
+ ]
1227
+ })
1228
+ }),
1229
+ /* @__PURE__ */ Q(_.Subscribe, {
1230
+ selector: (e) => e.values.duration,
1231
+ children: (t) => t === "until" ? /* @__PURE__ */ Q(_.Field, {
1232
+ name: "until",
1233
+ validators: { onChange: ({ value: e }) => ke("until", e) ? void 0 : "Pick today or a later date" },
1234
+ children: (t) => /* @__PURE__ */ $("div", {
1235
+ className: "grid gap-1.5",
1236
+ children: [
1237
+ /* @__PURE__ */ Q(U, {
1238
+ htmlFor: c("pa-until"),
1239
+ children: /* @__PURE__ */ Q(e, { id: "Last day (UTC)" })
1240
+ }),
1241
+ /* @__PURE__ */ Q(u, {
1242
+ id: c("pa-until"),
1243
+ type: "date",
1244
+ min: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
1245
+ value: t.state.value,
1246
+ onBlur: t.handleBlur,
1247
+ onChange: (e) => t.handleChange(e.target.value),
1248
+ "aria-invalid": t.state.meta.errors.length > 0
1249
+ }),
1250
+ /* @__PURE__ */ Q(w, { errors: t.state.meta.errors })
1251
+ ]
1252
+ })
1253
+ }) : null
1254
+ }),
1255
+ /* @__PURE__ */ Q(_.Field, {
1256
+ name: "note",
1257
+ children: (t) => /* @__PURE__ */ $("div", {
1258
+ className: "grid gap-1.5",
1259
+ children: [/* @__PURE__ */ Q(U, {
1260
+ htmlFor: c("pa-note"),
1261
+ children: /* @__PURE__ */ Q(e, { id: "Note" })
1262
+ }), /* @__PURE__ */ Q(u, {
1263
+ id: c("pa-note"),
1264
+ value: t.state.value,
1265
+ onBlur: t.handleBlur,
1266
+ onChange: (e) => t.handleChange(e.target.value),
1267
+ placeholder: d("Why it was granted")
1268
+ })]
1269
+ })
1270
+ })
1271
+ ]
1272
+ }), /* @__PURE__ */ Q(R, { children: /* @__PURE__ */ Q(_.Subscribe, {
1273
+ selector: (e) => [
1274
+ e.values.productId,
1275
+ e.canSubmit,
1276
+ e.isSubmitting,
1277
+ ke(e.values.duration, e.values.until) !== null
1278
+ ],
1279
+ children: ([t, n, r, i]) => /* @__PURE__ */ $(ue, { children: [/* @__PURE__ */ Q(l, {
1280
+ type: "button",
1281
+ variant: "outline",
1282
+ disabled: r,
1283
+ onClick: () => v(!1),
1284
+ children: /* @__PURE__ */ Q(e, { id: "Cancel" })
1285
+ }), /* @__PURE__ */ Q(l, {
1286
+ type: "submit",
1287
+ disabled: !t || !n || r || !i,
1288
+ children: r ? "Granting…" : "Grant access"
1289
+ })] })
1290
+ }) })]
1291
+ })]
1292
+ })]
1293
+ });
1294
+ }
1295
+ function Re({ contact: n }) {
1296
+ let { text: r } = t();
1297
+ return /* @__PURE__ */ $(q, { children: [/* @__PURE__ */ Q(W, {
1298
+ className: "pb-1",
1299
+ children: /* @__PURE__ */ Q(G, {
1300
+ className: "text-sm",
1301
+ children: /* @__PURE__ */ Q(e, { id: "Contact" })
1302
+ })
1303
+ }), /* @__PURE__ */ Q(K, {
1304
+ className: "text-sm",
1305
+ children: n ? /* @__PURE__ */ $("dl", {
1306
+ className: "grid grid-cols-[auto_1fr] gap-x-4 gap-y-1",
1307
+ children: [
1308
+ /* @__PURE__ */ Q("dt", {
1309
+ className: "text-muted-foreground",
1310
+ children: /* @__PURE__ */ Q(e, { id: "Email" })
1311
+ }),
1312
+ /* @__PURE__ */ Q("dd", {
1313
+ className: "truncate",
1314
+ children: n.email ?? "—"
1315
+ }),
1316
+ /* @__PURE__ */ Q("dt", {
1317
+ className: "text-muted-foreground",
1318
+ children: /* @__PURE__ */ Q(e, { id: "Name" })
1319
+ }),
1320
+ /* @__PURE__ */ Q("dd", {
1321
+ className: "truncate",
1322
+ children: n.name ?? "—"
1323
+ }),
1324
+ /* @__PURE__ */ Q("dt", {
1325
+ className: "text-muted-foreground",
1326
+ children: /* @__PURE__ */ Q(e, { id: "Username" })
1327
+ }),
1328
+ /* @__PURE__ */ Q("dd", {
1329
+ className: "truncate",
1330
+ children: n.username ?? "—"
1331
+ }),
1332
+ n.active !== null && /* @__PURE__ */ $(ue, { children: [/* @__PURE__ */ Q("dt", {
1333
+ className: "text-muted-foreground",
1334
+ children: /* @__PURE__ */ Q(e, { id: "Directory" })
1335
+ }), /* @__PURE__ */ Q("dd", { children: /* @__PURE__ */ Q(S, {
1336
+ variant: n.active ? "secondary" : "outline",
1337
+ children: n.active ? "Active" : "Deactivated"
1338
+ }) })] }),
1339
+ /* @__PURE__ */ Q("dt", {
1340
+ className: "text-muted-foreground",
1341
+ children: /* @__PURE__ */ Q(e, { id: "Last updated" })
1342
+ }),
1343
+ /* @__PURE__ */ Q("dd", {
1344
+ className: "tabular-nums",
1345
+ children: n.synced_at ? _(n.synced_at) : r("Current, read from your directory")
1346
+ })
1347
+ ]
1348
+ }) : /* @__PURE__ */ Q("p", {
1349
+ className: "text-muted-foreground",
1350
+ children: /* @__PURE__ */ Q(e, { id: "Your directory holds no contact for this customer." })
1351
+ })
1352
+ })] });
1353
+ }
1354
+ //#endregion
1355
+ export { Ae as CustomerDetailPage };
1356
+
1357
+ //# sourceMappingURL=admin-detail-CiONe1Pt.js.map