@openrails/billing-ui 0.254.0 → 0.256.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 (52) hide show
  1. package/README.md +6 -5
  2. package/dist/account/cancel-dialog.d.ts +2 -2
  3. package/dist/account/subscriptions-panel.d.ts +1 -2
  4. package/dist/admin/lib/api/types.d.ts +1 -1
  5. package/dist/admin/messages.d.ts +8 -5
  6. package/dist/admin/pages/catalog/price-format.d.ts +3 -1
  7. package/dist/admin/pages/catalog/psp-links.d.ts +1 -1
  8. package/dist/{admin-catalog-rrFZd5N8.js → admin-catalog-C0QRANp7.js} +8 -11
  9. package/dist/{admin-catalog-rrFZd5N8.js.map → admin-catalog-C0QRANp7.js.map} +1 -1
  10. package/dist/{admin-detail-Cq59e14B.js → admin-detail-qetSqVDt.js} +2 -2
  11. package/dist/{admin-detail-Cq59e14B.js.map → admin-detail-qetSqVDt.js.map} +1 -1
  12. package/dist/{admin-price-detail-Bwk9PXHP.js → admin-price-detail-C9CJwLeM.js} +101 -128
  13. package/dist/admin-price-detail-C9CJwLeM.js.map +1 -0
  14. package/dist/{admin-price-format-DM1qORWI.js → admin-price-format-BVUpDoSC.js} +5 -1
  15. package/dist/admin-price-format-BVUpDoSC.js.map +1 -0
  16. package/dist/{admin-price-wizard-ByD7j8mB.js → admin-price-wizard-DAkDGWkH.js} +123 -124
  17. package/dist/admin-price-wizard-DAkDGWkH.js.map +1 -0
  18. package/dist/admin.css +1 -1
  19. package/dist/admin.js +13 -10
  20. package/dist/admin.js.map +1 -1
  21. package/dist/client/client.d.ts +4 -4
  22. package/dist/client/generated/error-codes.d.ts +1 -1
  23. package/dist/client/generated/routes.d.ts +29 -12
  24. package/dist/client/generated/wire.d.ts +62 -21
  25. package/dist/client/types.d.ts +119 -20
  26. package/dist/{client-B301IAQD.js → client-Bs2YY-PV.js} +19 -3
  27. package/dist/client-Bs2YY-PV.js.map +1 -0
  28. package/dist/client.js +1 -1
  29. package/dist/{hooks-DARbMTwv.js → hooks-CCA-6uEa.js} +134 -123
  30. package/dist/{hooks-DARbMTwv.js.map → hooks-CCA-6uEa.js.map} +1 -1
  31. package/dist/index.js +729 -716
  32. package/dist/index.js.map +1 -1
  33. package/dist/locales/de.js +1 -0
  34. package/dist/locales/de.js.map +1 -1
  35. package/dist/locales/en.d.ts +1 -0
  36. package/dist/locales/en.js +1 -0
  37. package/dist/locales/en.js.map +1 -1
  38. package/dist/locales/es.js +1 -0
  39. package/dist/locales/es.js.map +1 -1
  40. package/dist/locales/ja.js +1 -0
  41. package/dist/locales/ja.js.map +1 -1
  42. package/dist/locales/ko.js +1 -0
  43. package/dist/locales/ko.js.map +1 -1
  44. package/dist/locales/zh.js +1 -0
  45. package/dist/locales/zh.js.map +1 -1
  46. package/dist/react/hooks.d.ts +3 -4
  47. package/dist/react.js +1 -1
  48. package/package.json +1 -1
  49. package/dist/admin-price-detail-Bwk9PXHP.js.map +0 -1
  50. package/dist/admin-price-format-DM1qORWI.js.map +0 -1
  51. package/dist/admin-price-wizard-ByD7j8mB.js.map +0 -1
  52. package/dist/client-B301IAQD.js.map +0 -1
@@ -4,63 +4,63 @@ import { t as i } from "./admin-input-DO5lvCLL.js";
4
4
  import { c as a, l as o, s } from "./admin-format-DoohJ7Fg.js";
5
5
  import { t as c } from "./admin-form-field-errors-hbUMIriS.js";
6
6
  import { t as l } from "./admin-badge-VCGbnfiN.js";
7
- import { a as u, i as d, n as f, o as p, r as m, s as h, t as g } from "./admin-dialog-Ffx95AIT.js";
8
- import { t as _ } from "./admin-label-BzJpr3lg.js";
9
- import { n as v } from "./admin-dialog-width-BPrgdYlj.js";
10
- import { n as y } from "./admin-price-format-DM1qORWI.js";
11
- import * as b from "react";
12
- import { useMutation as x, useQuery as ee, useQueryClient as S } from "@tanstack/react-query";
13
- import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
14
- import { useForm as E } from "@tanstack/react-form";
7
+ import { a as u, i as d, n as f, o as ee, r as p, s as m, t as h } from "./admin-dialog-Ffx95AIT.js";
8
+ import { t as g } from "./admin-label-BzJpr3lg.js";
9
+ import { n as _ } from "./admin-dialog-width-BPrgdYlj.js";
10
+ import { n as v } from "./admin-price-format-BVUpDoSC.js";
11
+ import * as y from "react";
12
+ import { useMutation as b, useQuery as te, useQueryClient as x } from "@tanstack/react-query";
13
+ import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
14
+ import { useForm as T } from "@tanstack/react-form";
15
15
  //#region src/admin/pages/catalog/price-wizard-logic.ts
16
- function D(e, t) {
16
+ function E(e, t) {
17
17
  let n = BigInt(e), r = BigInt(t);
18
18
  return n > r ? "increase" : n < r ? "decrease" : "unchanged";
19
19
  }
20
- function O(e) {
20
+ function D(e) {
21
21
  return e === "decrease" ? "migrate" : "grandfather";
22
22
  }
23
- function k(e, t, n) {
23
+ function O(e, t, n) {
24
24
  if (e !== "increase") return null;
25
25
  let r = new Date(t);
26
26
  return r.setUTCDate(r.getUTCDate() + n), r;
27
27
  }
28
- function te(e, t, n) {
29
- return k(e, t, n) ?? t;
28
+ function k(e, t, n) {
29
+ return O(e, t, n) ?? t;
30
30
  }
31
- function ne(e, t, n, r) {
32
- let i = k(e, n, r);
31
+ function A(e, t, n, r) {
32
+ let i = O(e, n, r);
33
33
  return !i || t.getTime() >= i.getTime();
34
34
  }
35
- var A = (e) => new Date(e).toLocaleDateString(void 0, {
35
+ var j = (e) => new Date(e).toLocaleDateString(void 0, {
36
36
  month: "short",
37
37
  day: "numeric",
38
38
  year: "numeric"
39
39
  });
40
- function j(e) {
40
+ function M(e) {
41
41
  let { newAmount: t, currentAmount: n, currency: r, affectedCount: i, plan: a, now: o } = e, c = s(t, r), l = s(n, r), u = `New subscribers pay ${c} immediately.`;
42
42
  if (i === 0) return `${u} No existing subscribers are on a prior version of this price.`;
43
43
  let d = `${i.toLocaleString()} existing subscriber${i === 1 ? "" : "s"}`;
44
- return a.mode === "grandfather" ? `${u} ${d} keep ${l} forever (grandfathered).` : new Date(a.effectiveAt).getTime() <= o.getTime() ? `${u} ${d} move to ${c} at their next renewal. Notices go out on confirm.` : `${u} ${d} keep ${l} until ${A(a.effectiveAt)}, then move to ${c} at their next renewal. Notices go out on confirm.`;
44
+ return a.mode === "grandfather" ? `${u} ${d} keep ${l} forever (grandfathered).` : new Date(a.effectiveAt).getTime() <= o.getTime() ? `${u} ${d} move to ${c} at their next renewal. Notices go out on confirm.` : `${u} ${d} keep ${l} until ${j(a.effectiveAt)}, then move to ${c} at their next renewal. Notices go out on confirm.`;
45
45
  }
46
46
  //#endregion
47
47
  //#region src/admin/pages/catalog/price-wizard.tsx
48
- var M = (e) => e.toISOString().slice(0, 10), N = (e, t) => ({
48
+ var N = (e) => e.toISOString().slice(0, 10), P = (e, t) => ({
49
49
  amountInput: o(t?.new_amount ?? e.unit_amount, e.currency),
50
50
  mode: t?.migration ? "migrate" : "grandfather",
51
- effectiveAt: t?.migration?.effective_at ? M(new Date(t.migration.effective_at)) : ""
51
+ effectiveAt: t?.migration?.effective_at ? N(new Date(t.migration.effective_at)) : ""
52
52
  });
53
- function P({ price: o, productName: A, productKey: P, draft: F, onDone: re }) {
54
- let { toast: I, toastApiError: L, adminMutations: R, adminQueries: z } = t(), { id: B } = e(), V = S(), [H, U] = b.useState(() => !!F), [W, G] = b.useState(() => F ? 3 : 1), K = x(R.previewPriceChange()), q = x(R.changePrice(V)), J = K.data?.matched ?? F?.affected_count ?? null, { data: Y } = ee({
53
+ function F({ price: o, productName: j, productKey: F, draft: I, onDone: ne }) {
54
+ let { toast: re, toastApiError: L, adminMutations: R, adminQueries: z } = t(), { id: B } = e(), V = x(), [H, U] = y.useState(() => !!I), [W, G] = y.useState(() => I ? 3 : 1), K = b(R.previewPriceChange()), q = b(R.changePrice(V)), J = K.data?.matched ?? I?.affected_count ?? null, { data: Y } = te({
55
55
  ...z.merchantConfiguration(),
56
56
  enabled: H
57
- }), X = Y?.reprice_notice_window_days ?? 30, [Z] = b.useState(() => /* @__PURE__ */ new Date()), Q = E({
58
- defaultValues: N(o, F),
57
+ }), X = Y?.reprice_notice_window_days ?? 30, [Z] = y.useState(() => /* @__PURE__ */ new Date()), Q = T({
58
+ defaultValues: P(o, I),
59
59
  onSubmit: async ({ value: e }) => {
60
- if (!P || o.customer_amount) return;
60
+ if (!F || o.customer_amount) return;
61
61
  let t = a(e.amountInput, o.currency);
62
62
  if (!(t === null || BigInt(t) <= 0n)) try {
63
- let n = await q.mutateAsync({
63
+ await q.mutateAsync({
64
64
  price: {
65
65
  product_id: o.product_id,
66
66
  unit_amount: t,
@@ -70,112 +70,111 @@ function P({ price: o, productName: A, productKey: P, draft: F, onDone: re }) {
70
70
  trial_unit_amount: o.trial_unit_amount ?? void 0,
71
71
  trial_duration_hours: o.trial_duration_hours ?? void 0,
72
72
  key: o.key,
73
- psps: Object.fromEntries(Object.keys(o.psps ?? {}).map((e) => [e, {}])),
73
+ sell_via: o.sell_via ?? void 0,
74
74
  expected_revision: o.revision
75
75
  },
76
76
  migration: e.mode === "migrate" ? {
77
- productKey: P,
77
+ productKey: F,
78
78
  priceKey: o.key,
79
79
  effectiveAt: new Date(e.effectiveAt).toISOString()
80
80
  } : void 0
81
- });
82
- n.pending_manual_actions?.length ? I.warning(`Price updated. One step is left for you: ${n.pending_manual_actions.map((e) => `${e.psp}: ${e.hint}`).join(". ")}`) : I.success(e.mode === "migrate" ? "Price updated and migration scheduled" : "Price updated"), $(!1), re?.();
81
+ }), re.success(e.mode === "migrate" ? "Price updated and migration scheduled" : "Price updated"), $(!1), ne?.();
83
82
  } catch (e) {
84
83
  L(e, "Change price");
85
84
  }
86
85
  }
87
86
  }), ie = () => {
88
- G(1), Q.reset(N(o)), K.reset();
87
+ G(1), Q.reset(P(o)), K.reset();
89
88
  }, $ = (e) => {
90
89
  e || ie(), U(e);
91
90
  }, ae = () => {
92
- if (!P || o.customer_amount) return;
93
- let e = D(a(Q.state.values.amountInput, o.currency) ?? o.unit_amount, o.unit_amount);
94
- Q.setFieldValue("mode", O(e)), Q.setFieldValue("effectiveAt", M(te(e, Z, X))), G(2), K.reset(), K.mutate({
95
- productKey: P,
91
+ if (!F || o.customer_amount) return;
92
+ let e = E(a(Q.state.values.amountInput, o.currency) ?? o.unit_amount, o.unit_amount);
93
+ Q.setFieldValue("mode", D(e)), Q.setFieldValue("effectiveAt", N(k(e, Z, X))), G(2), K.reset(), K.mutate({
94
+ productKey: F,
96
95
  priceKey: o.key
97
96
  }, { onError: (e) => L(e, "Preview affected subscribers") });
98
97
  };
99
- return o.archived || !P || o.customer_amount ? /* @__PURE__ */ w(r, {
98
+ return o.archived || !F || o.customer_amount ? /* @__PURE__ */ C(r, {
100
99
  variant: "outline",
101
100
  size: "sm",
102
101
  disabled: !0,
103
102
  title: o.customer_amount ? "This price lets customers choose an amount. Change its limits through a catalog application or the client." : o.archived ? "This is an archived version. Change the current price for this key instead." : "Load the product before changing its price.",
104
- children: /* @__PURE__ */ w(n, { id: "Change price" })
105
- }) : /* @__PURE__ */ T(g, {
103
+ children: /* @__PURE__ */ C(n, { id: "Change price" })
104
+ }) : /* @__PURE__ */ w(h, {
106
105
  open: H,
107
106
  onOpenChange: $,
108
- children: [!F && /* @__PURE__ */ w(h, { render: /* @__PURE__ */ w(r, {
107
+ children: [!I && /* @__PURE__ */ C(m, { render: /* @__PURE__ */ C(r, {
109
108
  variant: "outline",
110
109
  size: "sm",
111
- children: /* @__PURE__ */ w(n, { id: "Change price" })
112
- }) }), /* @__PURE__ */ w(f, {
113
- className: v,
114
- children: /* @__PURE__ */ w("form", {
110
+ children: /* @__PURE__ */ C(n, { id: "Change price" })
111
+ }) }), /* @__PURE__ */ C(f, {
112
+ className: _,
113
+ children: /* @__PURE__ */ C("form", {
115
114
  className: "grid gap-4",
116
115
  onSubmit: (e) => {
117
116
  e.preventDefault(), e.stopPropagation(), W === 3 && Q.handleSubmit();
118
117
  },
119
- children: /* @__PURE__ */ w(Q.Subscribe, {
118
+ children: /* @__PURE__ */ C(Q.Subscribe, {
120
119
  selector: (e) => [e.values, e.isSubmitting],
121
120
  children: ([e, t]) => {
122
- let f = a(e.amountInput, o.currency) ?? o.unit_amount, h = D(f, o.unit_amount), g = k(h, Z, X), v = e.mode !== "migrate" || !!e.effectiveAt && ne(h, new Date(e.effectiveAt), Z, X);
123
- return /* @__PURE__ */ T(C, { children: [
124
- /* @__PURE__ */ T(u, { children: [/* @__PURE__ */ T(p, {
121
+ let f = a(e.amountInput, o.currency) ?? o.unit_amount, m = E(f, o.unit_amount), h = O(m, Z, X), _ = e.mode !== "migrate" || !!e.effectiveAt && A(m, new Date(e.effectiveAt), Z, X);
122
+ return /* @__PURE__ */ w(S, { children: [
123
+ /* @__PURE__ */ w(u, { children: [/* @__PURE__ */ w(ee, {
125
124
  className: "flex items-center gap-2",
126
125
  children: [
127
- /* @__PURE__ */ w(n, { id: "Change price for " }),
128
- A,
129
- F && /* @__PURE__ */ w(l, {
126
+ /* @__PURE__ */ C(n, { id: "Change price for " }),
127
+ j,
128
+ I && /* @__PURE__ */ C(l, {
130
129
  variant: "secondary",
131
- children: /* @__PURE__ */ w(n, { id: "drafted by copilot" })
130
+ children: /* @__PURE__ */ C(n, { id: "drafted by copilot" })
132
131
  })
133
132
  ]
134
- }), /* @__PURE__ */ T(m, { children: [
135
- /* @__PURE__ */ w(n, { id: "Step " }),
133
+ }), /* @__PURE__ */ w(p, { children: [
134
+ /* @__PURE__ */ C(n, { id: "Step " }),
136
135
  W,
137
- /* @__PURE__ */ w(n, { id: " of 3:" }),
136
+ /* @__PURE__ */ C(n, { id: " of 3:" }),
138
137
  " ",
139
138
  W === 1 ? "new amount" : W === 2 ? "migration plan" : "review"
140
139
  ] })] }),
141
- W === 1 && /* @__PURE__ */ T("div", {
140
+ W === 1 && /* @__PURE__ */ w("div", {
142
141
  className: "grid gap-3",
143
142
  children: [
144
- /* @__PURE__ */ T("div", {
143
+ /* @__PURE__ */ w("div", {
145
144
  className: "grid grid-cols-2 gap-3 text-sm",
146
- children: [/* @__PURE__ */ T("div", { children: [/* @__PURE__ */ w("p", {
145
+ children: [/* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("p", {
147
146
  className: "text-xs text-muted-foreground uppercase",
148
- children: /* @__PURE__ */ w(n, { id: "Current amount" })
149
- }), /* @__PURE__ */ w("p", {
147
+ children: /* @__PURE__ */ C(n, { id: "Current amount" })
148
+ }), /* @__PURE__ */ C("p", {
150
149
  className: "font-medium",
151
150
  children: s(o.unit_amount, o.currency)
152
- })] }), /* @__PURE__ */ T("div", { children: [/* @__PURE__ */ w("p", {
151
+ })] }), /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("p", {
153
152
  className: "text-xs text-muted-foreground uppercase",
154
- children: /* @__PURE__ */ w(n, { id: "Currency · interval" })
155
- }), /* @__PURE__ */ T("p", {
153
+ children: /* @__PURE__ */ C(n, { id: "Currency · interval" })
154
+ }), /* @__PURE__ */ w("p", {
156
155
  className: "font-medium",
157
156
  children: [
158
157
  o.currency.toUpperCase(),
159
158
  " ·",
160
159
  " ",
161
- y(o)
160
+ v(o)
162
161
  ]
163
162
  })] })]
164
163
  }),
165
- /* @__PURE__ */ w(Q.Field, {
164
+ /* @__PURE__ */ C(Q.Field, {
166
165
  name: "amountInput",
167
166
  validators: { onBlur: ({ value: e }) => {
168
167
  let t = a(e, o.currency);
169
168
  if (t === null || BigInt(t) <= 0n) return "Enter an amount greater than zero.";
170
169
  } },
171
- children: (e) => /* @__PURE__ */ T("div", {
170
+ children: (e) => /* @__PURE__ */ w("div", {
172
171
  className: "grid gap-1.5",
173
172
  children: [
174
- /* @__PURE__ */ w(_, {
173
+ /* @__PURE__ */ C(g, {
175
174
  htmlFor: B("wiz-amount"),
176
- children: /* @__PURE__ */ w(n, { id: "New amount (major units)" })
175
+ children: /* @__PURE__ */ C(n, { id: "New amount (major units)" })
177
176
  }),
178
- /* @__PURE__ */ w(i, {
177
+ /* @__PURE__ */ C(i, {
179
178
  id: B("wiz-amount"),
180
179
  type: "number",
181
180
  step: "any",
@@ -185,127 +184,127 @@ function P({ price: o, productName: A, productKey: P, draft: F, onDone: re }) {
185
184
  onChange: (t) => e.handleChange(t.target.value),
186
185
  autoFocus: !0
187
186
  }),
188
- /* @__PURE__ */ w(c, { errors: e.state.meta.errors })
187
+ /* @__PURE__ */ C(c, { errors: e.state.meta.errors })
189
188
  ]
190
189
  })
191
190
  }),
192
- h !== "unchanged" && /* @__PURE__ */ T("p", {
191
+ m !== "unchanged" && /* @__PURE__ */ w("p", {
193
192
  className: "text-sm text-muted-foreground",
194
193
  children: [
195
- /* @__PURE__ */ w(n, { id: "This is a price" }),
194
+ /* @__PURE__ */ C(n, { id: "This is a price" }),
196
195
  " ",
197
- /* @__PURE__ */ w("span", {
196
+ /* @__PURE__ */ C("span", {
198
197
  className: "font-medium text-foreground",
199
- children: h === "increase" ? "increase" : "decrease"
198
+ children: m === "increase" ? "increase" : "decrease"
200
199
  }),
201
- /* @__PURE__ */ w(n, { id: ". Currency and interval stay locked to the current price." })
200
+ /* @__PURE__ */ C(n, { id: ". Currency and interval stay locked to the current price." })
202
201
  ]
203
202
  })
204
203
  ]
205
204
  }),
206
- W === 2 && /* @__PURE__ */ T("div", {
205
+ W === 2 && /* @__PURE__ */ w("div", {
207
206
  className: "grid gap-3",
208
207
  children: [
209
- /* @__PURE__ */ w("p", {
208
+ /* @__PURE__ */ C("p", {
210
209
  className: "text-sm",
211
210
  children: J === null && K.isPending ? "Checking affected subscribers…" : `${(J ?? 0).toLocaleString()} active subscription${J === 1 ? "" : "s"} on prior versions of ${o.key}.`
212
211
  }),
213
- /* @__PURE__ */ w(Q.Field, {
212
+ /* @__PURE__ */ C(Q.Field, {
214
213
  name: "mode",
215
- children: (e) => /* @__PURE__ */ T("div", {
214
+ children: (e) => /* @__PURE__ */ w("div", {
216
215
  className: "grid gap-2",
217
- children: [/* @__PURE__ */ T("label", {
216
+ children: [/* @__PURE__ */ w("label", {
218
217
  className: "flex items-start gap-2 rounded-md border p-3 text-sm",
219
- children: [/* @__PURE__ */ w("input", {
218
+ children: [/* @__PURE__ */ C("input", {
220
219
  type: "radio",
221
220
  name: e.name,
222
221
  className: "mt-1",
223
222
  checked: e.state.value === "grandfather",
224
223
  onChange: () => e.handleChange("grandfather")
225
- }), /* @__PURE__ */ T("span", { children: [
226
- /* @__PURE__ */ w("span", {
224
+ }), /* @__PURE__ */ w("span", { children: [
225
+ /* @__PURE__ */ C("span", {
227
226
  className: "font-medium",
228
- children: /* @__PURE__ */ w(n, { id: "Grandfather." })
227
+ children: /* @__PURE__ */ C(n, { id: "Grandfather." })
229
228
  }),
230
229
  " ",
231
- /* @__PURE__ */ w(n, { id: "Existing subscribers keep the current price." }),
232
- h === "increase" && /* @__PURE__ */ w(l, {
230
+ /* @__PURE__ */ C(n, { id: "Existing subscribers keep the current price." }),
231
+ m === "increase" && /* @__PURE__ */ C(l, {
233
232
  variant: "secondary",
234
233
  className: "ml-2",
235
- children: /* @__PURE__ */ w(n, { id: "default" })
234
+ children: /* @__PURE__ */ C(n, { id: "default" })
236
235
  })
237
236
  ] })]
238
- }), /* @__PURE__ */ T("label", {
237
+ }), /* @__PURE__ */ w("label", {
239
238
  className: "flex items-start gap-2 rounded-md border p-3 text-sm",
240
- children: [/* @__PURE__ */ w("input", {
239
+ children: [/* @__PURE__ */ C("input", {
241
240
  type: "radio",
242
241
  name: e.name,
243
242
  className: "mt-1",
244
243
  checked: e.state.value === "migrate",
245
244
  onChange: () => e.handleChange("migrate")
246
- }), /* @__PURE__ */ T("span", { children: [
247
- /* @__PURE__ */ w("span", {
245
+ }), /* @__PURE__ */ w("span", { children: [
246
+ /* @__PURE__ */ C("span", {
248
247
  className: "font-medium",
249
- children: /* @__PURE__ */ w(n, { id: "Migrate." })
248
+ children: /* @__PURE__ */ C(n, { id: "Migrate." })
250
249
  }),
251
250
  " ",
252
- /* @__PURE__ */ w(n, { id: "Move everyone to the new price at their first renewal on or after a date you choose." }),
253
- h === "decrease" && /* @__PURE__ */ w(l, {
251
+ /* @__PURE__ */ C(n, { id: "Move everyone to the new price at their first renewal on or after a date you choose." }),
252
+ m === "decrease" && /* @__PURE__ */ C(l, {
254
253
  variant: "secondary",
255
254
  className: "ml-2",
256
- children: /* @__PURE__ */ w(n, { id: "default" })
255
+ children: /* @__PURE__ */ C(n, { id: "default" })
257
256
  })
258
257
  ] })]
259
258
  })]
260
259
  })
261
260
  }),
262
- e.mode === "migrate" && /* @__PURE__ */ w(Q.Field, {
261
+ e.mode === "migrate" && /* @__PURE__ */ C(Q.Field, {
263
262
  name: "effectiveAt",
264
- children: (e) => /* @__PURE__ */ T("div", {
263
+ children: (e) => /* @__PURE__ */ w("div", {
265
264
  className: "grid gap-1.5",
266
265
  children: [
267
- /* @__PURE__ */ w(_, {
266
+ /* @__PURE__ */ C(g, {
268
267
  htmlFor: B("wiz-effective"),
269
- children: /* @__PURE__ */ w(n, { id: "Effective date" })
268
+ children: /* @__PURE__ */ C(n, { id: "Effective date" })
270
269
  }),
271
- /* @__PURE__ */ w(i, {
270
+ /* @__PURE__ */ C(i, {
272
271
  id: B("wiz-effective"),
273
272
  type: "date",
274
273
  value: e.state.value,
275
- min: g ? M(g) : void 0,
274
+ min: h ? N(h) : void 0,
276
275
  onBlur: e.handleBlur,
277
276
  onChange: (t) => e.handleChange(t.target.value)
278
277
  }),
279
- h === "increase" ? /* @__PURE__ */ T("p", {
278
+ m === "increase" ? /* @__PURE__ */ w("p", {
280
279
  className: "text-xs text-muted-foreground",
281
280
  children: [
282
- /* @__PURE__ */ w(n, { id: "Must be at least " }),
281
+ /* @__PURE__ */ C(n, { id: "Must be at least " }),
283
282
  X,
284
- /* @__PURE__ */ w(n, { id: " days away. Card networks require that much notice before a price goes up. You can change the number in Settings." })
283
+ /* @__PURE__ */ C(n, { id: " days away. Card networks require that much notice before a price goes up. You can change the number in Settings." })
285
284
  ]
286
- }) : /* @__PURE__ */ w("p", {
285
+ }) : /* @__PURE__ */ C("p", {
287
286
  className: "text-xs text-muted-foreground",
288
- children: /* @__PURE__ */ w(n, { id: "A price going down needs no notice, so today is fine." })
287
+ children: /* @__PURE__ */ C(n, { id: "A price going down needs no notice, so today is fine." })
289
288
  }),
290
- !v && /* @__PURE__ */ w("p", {
289
+ !_ && /* @__PURE__ */ C("p", {
291
290
  className: "text-xs text-destructive",
292
291
  role: "alert",
293
- children: /* @__PURE__ */ w(n, { id: "Pick a later date." })
292
+ children: /* @__PURE__ */ C(n, { id: "Pick a later date." })
294
293
  }),
295
- /* @__PURE__ */ w("p", {
294
+ /* @__PURE__ */ C("p", {
296
295
  className: "text-xs text-muted-foreground",
297
- children: /* @__PURE__ */ w(n, { id: "A reprice_scheduled notice is queued for every affected subscriber as soon as you confirm." })
296
+ children: /* @__PURE__ */ C(n, { id: "A reprice_scheduled notice is queued for every affected subscriber as soon as you confirm." })
298
297
  })
299
298
  ]
300
299
  })
301
300
  })
302
301
  ]
303
302
  }),
304
- W === 3 && /* @__PURE__ */ w("div", {
303
+ W === 3 && /* @__PURE__ */ C("div", {
305
304
  className: "grid gap-3",
306
- children: /* @__PURE__ */ w("p", {
305
+ children: /* @__PURE__ */ C("p", {
307
306
  className: "rounded-md border bg-muted/40 p-3 text-sm",
308
- children: j({
307
+ children: M({
309
308
  newAmount: f,
310
309
  currentAmount: o.unit_amount,
311
310
  currency: o.currency,
@@ -318,27 +317,27 @@ function P({ price: o, productName: A, productKey: P, draft: F, onDone: re }) {
318
317
  })
319
318
  })
320
319
  }),
321
- /* @__PURE__ */ T(d, { children: [
322
- W > 1 && /* @__PURE__ */ w(r, {
320
+ /* @__PURE__ */ w(d, { children: [
321
+ W > 1 && /* @__PURE__ */ C(r, {
323
322
  type: "button",
324
323
  variant: "outline",
325
324
  disabled: t,
326
325
  onClick: () => G((e) => e - 1),
327
- children: /* @__PURE__ */ w(n, { id: "Back" })
326
+ children: /* @__PURE__ */ C(n, { id: "Back" })
328
327
  }),
329
- W === 1 && /* @__PURE__ */ w(r, {
328
+ W === 1 && /* @__PURE__ */ C(r, {
330
329
  type: "button",
331
- disabled: !e.amountInput || h === "unchanged" || BigInt(f) <= 0n,
330
+ disabled: !e.amountInput || m === "unchanged" || BigInt(f) <= 0n,
332
331
  onClick: ae,
333
- children: /* @__PURE__ */ w(n, { id: "Next" })
332
+ children: /* @__PURE__ */ C(n, { id: "Next" })
334
333
  }),
335
- W === 2 && /* @__PURE__ */ w(r, {
334
+ W === 2 && /* @__PURE__ */ C(r, {
336
335
  type: "button",
337
- disabled: !v || K.isPending,
336
+ disabled: !_ || K.isPending,
338
337
  onClick: () => G(3),
339
- children: /* @__PURE__ */ w(n, { id: "Next" })
338
+ children: /* @__PURE__ */ C(n, { id: "Next" })
340
339
  }),
341
- W === 3 && /* @__PURE__ */ w(r, {
340
+ W === 3 && /* @__PURE__ */ C(r, {
342
341
  type: "submit",
343
342
  disabled: t,
344
343
  children: t ? "Working…" : "Confirm"
@@ -352,6 +351,6 @@ function P({ price: o, productName: A, productKey: P, draft: F, onDone: re }) {
352
351
  });
353
352
  }
354
353
  //#endregion
355
- export { P as t };
354
+ export { F as t };
356
355
 
357
- //# sourceMappingURL=admin-price-wizard-ByD7j8mB.js.map
356
+ //# sourceMappingURL=admin-price-wizard-DAkDGWkH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-price-wizard-DAkDGWkH.js","names":[],"sources":["../src/admin/pages/catalog/price-wizard-logic.ts","../src/admin/pages/catalog/price-wizard.tsx"],"sourcesContent":["// Pure logic for the price-change wizard, kept apart from React for unit tests.\nimport { formatNativeAmount } from \"#orck/admin/lib/format\"\n\nexport type PriceDirection = \"increase\" | \"decrease\" | \"unchanged\"\n\nexport function detectDirection(\n newAmount: string,\n currentAmount: string\n): PriceDirection {\n const next = BigInt(newAmount)\n const current = BigInt(currentAmount)\n if (next > current) return \"increase\"\n if (next < current) return \"decrease\"\n return \"unchanged\"\n}\n\nexport type MigrationMode = \"grandfather\" | \"migrate\"\n\n// DEFAULT_NOTICE_WINDOW_DAYS is the fallback until the merchant's\n// reprice_notice_window_days loads; it mirrors\n// subscriptions.DefaultPriceIncreaseNoticeDays so the UI never under-gates.\n// The server enforces the window too (price_increase_notice_too_short).\nexport const DEFAULT_NOTICE_WINDOW_DAYS = 30\n\n// defaultMigrationMode is the direction-aware Step 2 default: an increase\n// grandfathers (no new action), a decrease migrates now (never grandfathered).\nexport function defaultMigrationMode(direction: PriceDirection): MigrationMode {\n return direction === \"decrease\" ? \"migrate\" : \"grandfather\"\n}\n\n// minEffectiveDate is the earliest allowed migration date, or null when there\n// is no minimum (a decrease needs no notice).\nexport function minEffectiveDate(\n direction: PriceDirection,\n now: Date,\n noticeWindowDays: number\n): Date | null {\n if (direction !== \"increase\") return null\n const min = new Date(now)\n min.setUTCDate(min.getUTCDate() + noticeWindowDays)\n return min\n}\n\n// defaultEffectiveDate is Step 2's pre-filled migration date: the notice\n// window's floor for an increase, \"now\" for a decrease.\nexport function defaultEffectiveDate(\n direction: PriceDirection,\n now: Date,\n noticeWindowDays: number\n): Date {\n return minEffectiveDate(direction, now, noticeWindowDays) ?? now\n}\n\n// isEffectiveDateValid enforces the console-side notice-window gate: an\n// increase+migrate plan may not pick a date inside the notice window.\nexport function isEffectiveDateValid(\n direction: PriceDirection,\n effectiveAt: Date,\n now: Date,\n noticeWindowDays: number\n): boolean {\n const min = minEffectiveDate(direction, now, noticeWindowDays)\n return !min || effectiveAt.getTime() >= min.getTime()\n}\n\nexport interface MigrationPlan {\n mode: MigrationMode\n // ISO instant; only meaningful when mode === \"migrate\".\n effectiveAt: string\n}\n\nconst dateLabel = (iso: string) =>\n new Date(iso).toLocaleDateString(undefined, {\n month: \"short\",\n day: \"numeric\",\n year: \"numeric\",\n })\n\n// buildReviewText renders Step 3's plan in words, e.g. \"New subscribers pay $12\n// immediately. 1,204 existing subscribers keep $10 until Sep 1, then move to\n// $12 at their next renewal. Notices go out on confirm.\"\nexport function buildReviewText(params: {\n newAmount: string\n currentAmount: string\n currency: string\n affectedCount: number\n plan: MigrationPlan\n now: Date\n}): string {\n const { newAmount, currentAmount, currency, affectedCount, plan, now } =\n params\n const newLabel = formatNativeAmount(newAmount, currency)\n const oldLabel = formatNativeAmount(currentAmount, currency)\n const lead = `New subscribers pay ${newLabel} immediately.`\n\n if (affectedCount === 0) {\n return `${lead} No existing subscribers are on a prior version of this price.`\n }\n const subj = `${affectedCount.toLocaleString()} existing subscriber${affectedCount === 1 ? \"\" : \"s\"}`\n\n if (plan.mode === \"grandfather\") {\n return `${lead} ${subj} keep ${oldLabel} forever (grandfathered).`\n }\n\n // The engine notifies each affected subscriber at schedule time, however\n // far out effective_at is: always say so.\n const effective = new Date(plan.effectiveAt)\n const immediate = effective.getTime() <= now.getTime()\n if (immediate) {\n return `${lead} ${subj} move to ${newLabel} at their next renewal. Notices go out on confirm.`\n }\n return `${lead} ${subj} keep ${oldLabel} until ${dateLabel(plan.effectiveAt)}, then move to ${newLabel} at their next renewal. Notices go out on confirm.`\n}\n","import { AdminMessage, useAdminUI } from \"#orck/admin/ui-context\"\nimport { useAdminServices } from \"#orck/admin/context\"\nimport * as React from \"react\"\n\nimport { useForm } from \"@tanstack/react-form\"\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\"\n\nimport { FormFieldErrors } from \"#orck/admin/components/form-field-errors\"\nimport { Badge } from \"#orck/admin/components/ui/badge\"\nimport { Button } from \"#orck/admin/components/ui/button\"\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n} from \"#orck/admin/components/ui/dialog\"\nimport { Input } from \"#orck/admin/components/ui/input\"\nimport { Label } from \"#orck/admin/components/ui/label\"\nimport type { PriceChangeDraft } from \"#orck/admin/lib/api/copilot\"\nimport { DIALOG_FORM } from \"#orck/admin/lib/dialog-width\"\nimport type { Price } from \"#orck/client/generated/wire\"\nimport {\n formatNativeAmount,\n nativeAmountFromInput,\n nativeAmountToInput,\n} from \"#orck/admin/lib/format\"\n\nimport { priceIntervalLabel } from \"#orck/admin/pages/catalog/price-format\"\nimport {\n buildReviewText,\n defaultEffectiveDate,\n defaultMigrationMode,\n DEFAULT_NOTICE_WINDOW_DAYS,\n detectDirection,\n isEffectiveDateValid,\n minEffectiveDate,\n type MigrationMode,\n} from \"#orck/admin/pages/catalog/price-wizard-logic\"\n\nconst toDateInputValue = (d: Date) => d.toISOString().slice(0, 10)\n\nconst priceChangeFormValues = (price: Price, draft?: PriceChangeDraft) => ({\n amountInput: nativeAmountToInput(\n draft?.new_amount ?? price.unit_amount,\n price.currency\n ),\n mode: (draft?.migration ? \"migrate\" : \"grandfather\") as MigrationMode,\n effectiveAt: draft?.migration?.effective_at\n ? toDateInputValue(new Date(draft.migration.effective_at))\n : \"\",\n})\n\n// PriceChangeWizard is the #777 console price-change wizard — the ONLY\n// amount-edit affordance on a price. Three steps: new amount -> migration\n// plan (direction-aware defaults, live affected-count preview, notice-window\n// gate on increase+migrate) -> review in words, then confirm applies the\n// catalog price update followed (if migrating) by the price migration.\n//\n// draft (#779): when the catalog copilot proposed this change, the dialog\n// opens PRE-FILLED straight at Step 3 (review) — the affected count already\n// rode in the draft, so no extra preview call is needed. Confirm behaves\n// EXACTLY as a hand-typed change (the same create-price and price-migration\n// calls).\nexport function PriceChangeWizard({\n price,\n productName,\n productKey,\n draft,\n onDone,\n}: {\n price: Price\n productName: string\n productKey: string | undefined\n draft?: PriceChangeDraft\n onDone?: () => void\n}) {\n const { toast, toastApiError, adminMutations, adminQueries } =\n useAdminServices()\n\n const { id: adminId } = useAdminUI()\n\n const queryClient = useQueryClient()\n const [open, setOpen] = React.useState(() => !!draft)\n const [step, setStep] = React.useState<1 | 2 | 3>(() => (draft ? 3 : 1))\n const previewPriceChange = useMutation(adminMutations.previewPriceChange())\n const changePrice = useMutation(adminMutations.changePrice(queryClient))\n const affectedCount =\n previewPriceChange.data?.matched ?? draft?.affected_count ?? null\n const { data: configuration } = useQuery({\n ...adminQueries.merchantConfiguration(),\n enabled: open,\n })\n const noticeWindowDays =\n configuration?.reprice_notice_window_days ?? DEFAULT_NOTICE_WINDOW_DAYS\n\n const [now] = React.useState(() => new Date())\n const form = useForm({\n defaultValues: priceChangeFormValues(price, draft),\n onSubmit: async ({ value }) => {\n if (!productKey || price.customer_amount) return\n const newAmount = nativeAmountFromInput(value.amountInput, price.currency)\n if (newAmount === null || BigInt(newAmount) <= 0n) return\n\n try {\n await changePrice.mutateAsync({\n price: {\n product_id: price.product_id,\n unit_amount: newAmount,\n currency: price.currency,\n access_duration_hours: price.access_duration_hours ?? undefined,\n billing_interval_hours: price.billing_interval_hours ?? undefined,\n trial_unit_amount: price.trial_unit_amount ?? undefined,\n trial_duration_hours: price.trial_duration_hours ?? undefined,\n key: price.key,\n sell_via: price.sell_via ?? undefined,\n expected_revision: price.revision,\n },\n migration:\n value.mode === \"migrate\"\n ? {\n productKey,\n priceKey: price.key,\n effectiveAt: new Date(value.effectiveAt).toISOString(),\n }\n : undefined,\n })\n toast.success(\n value.mode === \"migrate\"\n ? \"Price updated and migration scheduled\"\n : \"Price updated\"\n )\n handleOpenChange(false)\n onDone?.()\n } catch (err) {\n toastApiError(err, \"Change price\")\n }\n },\n })\n\n const reset = () => {\n setStep(1)\n form.reset(priceChangeFormValues(price))\n previewPriceChange.reset()\n }\n\n const handleOpenChange = (next: boolean) => {\n if (!next) {\n reset()\n }\n setOpen(next)\n }\n\n const enterStep2 = () => {\n if (!productKey || price.customer_amount) return\n const amount = nativeAmountFromInput(\n form.state.values.amountInput,\n price.currency\n )\n const direction = detectDirection(\n amount ?? price.unit_amount,\n price.unit_amount\n )\n form.setFieldValue(\"mode\", defaultMigrationMode(direction))\n form.setFieldValue(\n \"effectiveAt\",\n toDateInputValue(defaultEffectiveDate(direction, now, noticeWindowDays))\n )\n setStep(2)\n previewPriceChange.reset()\n previewPriceChange.mutate(\n { productKey, priceKey: price.key },\n { onError: (err) => toastApiError(err, \"Preview affected subscribers\") }\n )\n }\n\n // Archived (prior-version) rows are history, not the editable current\n // price. Each product/key pair has exactly one live edit target.\n // Wait for the product before allowing previews or scheduling a migration.\n if (price.archived || !productKey || price.customer_amount) {\n return (\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled\n title={\n price.customer_amount\n ? \"This price lets customers choose an amount. Change its limits through a catalog application or the client.\"\n : price.archived\n ? \"This is an archived version. Change the current price for this key instead.\"\n : \"Load the product before changing its price.\"\n }\n >\n <AdminMessage id={\"Change price\"} />\n </Button>\n )\n }\n\n return (\n <Dialog open={open} onOpenChange={handleOpenChange}>\n {!draft && (\n <DialogTrigger\n render={\n <Button variant=\"outline\" size=\"sm\">\n <AdminMessage id={\"Change price\"} />\n </Button>\n }\n />\n )}\n <DialogContent className={DIALOG_FORM}>\n <form\n className=\"grid gap-4\"\n onSubmit={(event) => {\n event.preventDefault()\n event.stopPropagation()\n if (step !== 3) return\n void form.handleSubmit()\n }}\n >\n <form.Subscribe\n selector={(state) => [state.values, state.isSubmitting] as const}\n >\n {([values, isSubmitting]) => {\n const newAmount =\n nativeAmountFromInput(values.amountInput, price.currency) ??\n price.unit_amount\n const direction = detectDirection(newAmount, price.unit_amount)\n const minDate = minEffectiveDate(direction, now, noticeWindowDays)\n const dateValid =\n values.mode !== \"migrate\" ||\n (!!values.effectiveAt &&\n isEffectiveDateValid(\n direction,\n new Date(values.effectiveAt),\n now,\n noticeWindowDays\n ))\n\n return (\n <>\n <DialogHeader>\n <DialogTitle className=\"flex items-center gap-2\">\n <AdminMessage id={\"Change price for \"} />\n {productName}\n {draft && (\n <Badge variant=\"secondary\">\n <AdminMessage id={\"drafted by copilot\"} />\n </Badge>\n )}\n </DialogTitle>\n <DialogDescription>\n <AdminMessage id={\"Step \"} />\n {step}\n <AdminMessage id={\" of 3:\"} />{\" \"}\n {step === 1\n ? \"new amount\"\n : step === 2\n ? \"migration plan\"\n : \"review\"}\n </DialogDescription>\n </DialogHeader>\n\n {step === 1 && (\n <div className=\"grid gap-3\">\n <div className=\"grid grid-cols-2 gap-3 text-sm\">\n <div>\n <p className=\"text-xs text-muted-foreground uppercase\">\n <AdminMessage id={\"Current amount\"} />\n </p>\n <p className=\"font-medium\">\n {formatNativeAmount(\n price.unit_amount,\n price.currency\n )}\n </p>\n </div>\n <div>\n <p className=\"text-xs text-muted-foreground uppercase\">\n <AdminMessage id={\"Currency · interval\"} />\n </p>\n <p className=\"font-medium\">\n {price.currency.toUpperCase()} ·{\" \"}\n {priceIntervalLabel(price)}\n </p>\n </div>\n </div>\n <form.Field\n name=\"amountInput\"\n validators={{\n onBlur: ({ value }) => {\n const amount = nativeAmountFromInput(\n value,\n price.currency\n )\n if (amount === null || BigInt(amount) <= 0n) {\n return \"Enter an amount greater than zero.\"\n }\n return undefined\n },\n }}\n >\n {(field) => (\n <div className=\"grid gap-1.5\">\n <Label htmlFor={adminId(\"wiz-amount\")}>\n <AdminMessage id={\"New amount (major units)\"} />\n </Label>\n <Input\n id={adminId(\"wiz-amount\")}\n type=\"number\"\n step=\"any\"\n min=\"0\"\n value={field.state.value}\n onBlur={field.handleBlur}\n onChange={(event) =>\n field.handleChange(event.target.value)\n }\n autoFocus\n />\n <FormFieldErrors errors={field.state.meta.errors} />\n </div>\n )}\n </form.Field>\n {direction !== \"unchanged\" && (\n <p className=\"text-sm text-muted-foreground\">\n <AdminMessage id={\"This is a price\"} />{\" \"}\n <span className=\"font-medium text-foreground\">\n {direction === \"increase\" ? \"increase\" : \"decrease\"}\n </span>\n <AdminMessage\n id={\n \". Currency and interval stay locked to the current price.\"\n }\n />\n </p>\n )}\n </div>\n )}\n\n {step === 2 && (\n <div className=\"grid gap-3\">\n <p className=\"text-sm\">\n {affectedCount === null && previewPriceChange.isPending\n ? \"Checking affected subscribers…\"\n : `${(affectedCount ?? 0).toLocaleString()} active subscription${affectedCount === 1 ? \"\" : \"s\"} on prior versions of ${price.key}.`}\n </p>\n <form.Field name=\"mode\">\n {(field) => (\n <div className=\"grid gap-2\">\n <label className=\"flex items-start gap-2 rounded-md border p-3 text-sm\">\n <input\n type=\"radio\"\n name={field.name}\n className=\"mt-1\"\n checked={field.state.value === \"grandfather\"}\n onChange={() =>\n field.handleChange(\"grandfather\")\n }\n />\n <span>\n <span className=\"font-medium\">\n <AdminMessage id={\"Grandfather.\"} />\n </span>{\" \"}\n <AdminMessage\n id={\n \"Existing subscribers keep the current price.\"\n }\n />\n {direction === \"increase\" && (\n <Badge variant=\"secondary\" className=\"ml-2\">\n <AdminMessage id={\"default\"} />\n </Badge>\n )}\n </span>\n </label>\n <label className=\"flex items-start gap-2 rounded-md border p-3 text-sm\">\n <input\n type=\"radio\"\n name={field.name}\n className=\"mt-1\"\n checked={field.state.value === \"migrate\"}\n onChange={() => field.handleChange(\"migrate\")}\n />\n <span>\n <span className=\"font-medium\">\n <AdminMessage id={\"Migrate.\"} />\n </span>{\" \"}\n <AdminMessage\n id={\n \"Move everyone to the new price at their first renewal on or after a date you choose.\"\n }\n />\n {direction === \"decrease\" && (\n <Badge variant=\"secondary\" className=\"ml-2\">\n <AdminMessage id={\"default\"} />\n </Badge>\n )}\n </span>\n </label>\n </div>\n )}\n </form.Field>\n {values.mode === \"migrate\" && (\n <form.Field name=\"effectiveAt\">\n {(field) => (\n <div className=\"grid gap-1.5\">\n <Label htmlFor={adminId(\"wiz-effective\")}>\n <AdminMessage id={\"Effective date\"} />\n </Label>\n <Input\n id={adminId(\"wiz-effective\")}\n type=\"date\"\n value={field.state.value}\n min={\n minDate\n ? toDateInputValue(minDate)\n : undefined\n }\n onBlur={field.handleBlur}\n onChange={(event) =>\n field.handleChange(event.target.value)\n }\n />\n {direction === \"increase\" ? (\n <p className=\"text-xs text-muted-foreground\">\n <AdminMessage id={\"Must be at least \"} />\n {noticeWindowDays}\n <AdminMessage\n id={\n \" days away. Card networks require that much notice before a price goes up. You can change the number in Settings.\"\n }\n />\n </p>\n ) : (\n <p className=\"text-xs text-muted-foreground\">\n <AdminMessage\n id={\n \"A price going down needs no notice, so today is fine.\"\n }\n />\n </p>\n )}\n {!dateValid && (\n <p\n className=\"text-xs text-destructive\"\n role=\"alert\"\n >\n <AdminMessage id={\"Pick a later date.\"} />\n </p>\n )}\n <p className=\"text-xs text-muted-foreground\">\n <AdminMessage\n id={\n \"A reprice_scheduled notice is queued for every affected subscriber as soon as you confirm.\"\n }\n />\n </p>\n </div>\n )}\n </form.Field>\n )}\n </div>\n )}\n\n {step === 3 && (\n <div className=\"grid gap-3\">\n <p className=\"rounded-md border bg-muted/40 p-3 text-sm\">\n {buildReviewText({\n newAmount,\n currentAmount: price.unit_amount,\n currency: price.currency,\n affectedCount: affectedCount ?? 0,\n plan: {\n mode: values.mode,\n effectiveAt:\n values.mode === \"migrate\"\n ? new Date(values.effectiveAt).toISOString()\n : \"\",\n },\n now,\n })}\n </p>\n </div>\n )}\n\n <DialogFooter>\n {step > 1 && (\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={isSubmitting}\n onClick={() => setStep((value) => (value - 1) as 1 | 2)}\n >\n <AdminMessage id={\"Back\"} />\n </Button>\n )}\n {step === 1 && (\n <Button\n type=\"button\"\n disabled={\n !values.amountInput ||\n direction === \"unchanged\" ||\n BigInt(newAmount) <= 0n\n }\n onClick={enterStep2}\n >\n <AdminMessage id={\"Next\"} />\n </Button>\n )}\n {step === 2 && (\n <Button\n type=\"button\"\n disabled={!dateValid || previewPriceChange.isPending}\n onClick={() => setStep(3)}\n >\n <AdminMessage id={\"Next\"} />\n </Button>\n )}\n {step === 3 && (\n <Button type=\"submit\" disabled={isSubmitting}>\n {isSubmitting ? \"Working…\" : \"Confirm\"}\n </Button>\n )}\n </DialogFooter>\n </>\n )\n }}\n </form.Subscribe>\n </form>\n </DialogContent>\n </Dialog>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;AAKA,SAAgB,EACd,GACA,GACgB;CAChB,IAAM,IAAO,OAAO,CAAS,GACvB,IAAU,OAAO,CAAa;CAGpC,OAFI,IAAO,IAAgB,aACvB,IAAO,IAAgB,aACpB;AACT;AAYA,SAAgB,EAAqB,GAA0C;CAC7E,OAAO,MAAc,a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