@usethrottle/auth 0.3.0 → 0.4.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.
@@ -79,7 +79,7 @@ __export(components_exports, {
79
79
  module.exports = __toCommonJS(components_exports);
80
80
 
81
81
  // src/react/components/provider.tsx
82
- var import_react32 = require("react");
82
+ var import_react31 = require("react");
83
83
 
84
84
  // src/errors.ts
85
85
  var ThrottleAuthError = class extends Error {
@@ -459,6 +459,8 @@ function createAccount(auth) {
459
459
  getInvoicePdfUrl: (id) => call("GET", `/me/invoices/${seg(id)}/pdf`),
460
460
  listSubscriptions: (page) => call("GET", `/me/subscriptions${query(page)}`),
461
461
  getSubscription: (id) => call("GET", `/me/subscriptions/${seg(id)}`),
462
+ cancelOrder: (id, opts) => call("POST", `/me/orders/${seg(id)}/cancel`, opts),
463
+ requestOrderReturn: (id, input) => call("POST", `/me/orders/${seg(id)}/return-request`, input),
462
464
  cancelSubscription: (id, opts) => call("POST", `/me/subscriptions/${seg(id)}/cancel`, opts),
463
465
  pauseSubscription: (id) => call("POST", `/me/subscriptions/${seg(id)}/pause`),
464
466
  resumeSubscription: (id) => call("POST", `/me/subscriptions/${seg(id)}/resume`),
@@ -771,6 +773,24 @@ var THROTTLE_ELEMENT_KEYS = [
771
773
  "orderDetail.payButton",
772
774
  "orderDetail.trackButton",
773
775
  "orderDetail.reorderButton",
776
+ // Two-column detail layout, shared by the order and invoice pages.
777
+ "orderDetail.layout",
778
+ "orderDetail.main",
779
+ "orderDetail.rail",
780
+ "orderDetail.cancelButton",
781
+ "orderDetail.returnButton",
782
+ "orderDetail.invoiceButton",
783
+ "orderDetail.actions",
784
+ "invoiceDetail.layout",
785
+ "invoiceDetail.main",
786
+ "invoiceDetail.rail",
787
+ "invoiceDetail.lineItems",
788
+ "invoiceDetail.lineItem",
789
+ "invoiceDetail.orderLink",
790
+ "invoiceDetail.subscriptionLink",
791
+ "invoiceDetail.payButton",
792
+ "invoiceDetail.actions",
793
+ "fieldRow",
774
794
  "confirm.header",
775
795
  "confirm.title",
776
796
  "confirm.body",
@@ -920,6 +940,23 @@ function messageForError(err) {
920
940
  return "We could not find that.";
921
941
  case "payment_method_in_use":
922
942
  return e.message || "That payment method is in use and cannot be removed.";
943
+ // Order and return refusals. Every one of these is a state the buyer can
944
+ // see and act on — the order shipped, the money was taken, that quantity
945
+ // is already on another return — and the server's message names which and
946
+ // what to do instead. Flattening them to "Something went wrong" sent a
947
+ // buyer to support for something the screen could have answered. Same
948
+ // argument as payment_method_in_use above.
949
+ case "order_not_cancellable":
950
+ case "order_already_paid":
951
+ case "order_not_returnable":
952
+ case "quantity_exceeds_returnable":
953
+ case "no_items":
954
+ case "unknown_line_item":
955
+ case "return_rejected":
956
+ return e.message || "That change is not possible for this order.";
957
+ case "orders_unavailable":
958
+ case "returns_unavailable":
959
+ return "That is unavailable right now. Please contact support.";
923
960
  case "validation_error": {
924
961
  const first2 = e.details?.[0];
925
962
  if (first2?.path && first2?.message) {
@@ -1090,6 +1127,17 @@ var enUS = {
1090
1127
  payNow: "Pay now",
1091
1128
  track: "Track shipment",
1092
1129
  reorder: "Order again",
1130
+ cancelOrder: "Cancel order",
1131
+ cancelOrderConfirm: "Cancel this order?",
1132
+ cancelOrderBody: "This cannot be undone. Nothing has been charged, so there is nothing to refund.",
1133
+ cancelOrderAction: "Cancel order",
1134
+ requestReturn: "Request a return",
1135
+ requestReturnConfirm: "Request a return for this order?",
1136
+ requestReturnBody: "The merchant reviews your request and will be in touch. Nothing is refunded until they approve it.",
1137
+ requestReturnAction: "Send request",
1138
+ returnRequested: "Return requested. The merchant will be in touch.",
1139
+ downloadInvoice: "Download invoice",
1140
+ summary: "Summary",
1093
1141
  empty: "No orders yet",
1094
1142
  emptyDescription: "Orders you place will appear here.",
1095
1143
  gatedDescription: "Verify your email to see your order history.",
@@ -1153,6 +1201,12 @@ var enUS = {
1153
1201
  refunded: "Refunded",
1154
1202
  period: "Period",
1155
1203
  downloadButton: "Download PDF",
1204
+ items: "Items",
1205
+ summary: "Summary",
1206
+ viewOrder: "View order",
1207
+ viewSubscription: "View subscription",
1208
+ payButton: "Pay this invoice",
1209
+ billedTo: "Billed to",
1156
1210
  /** Display copy for `invoice.status` — the wire values are paid|open|void. */
1157
1211
  statusLabels: { paid: "Paid", open: "Open", void: "Void" },
1158
1212
  downloadUnavailable: "This invoice is not available to download right now."
@@ -1467,11 +1521,13 @@ var THROTTLE_STYLES = `
1467
1521
  align-items: center;
1468
1522
  justify-content: center;
1469
1523
  cursor: pointer;
1524
+ /* A label that wraps turns a control into a two-line block of text. */
1525
+ white-space: nowrap;
1470
1526
  transition: opacity var(--throttle-transition), background-color var(--throttle-transition), border-color var(--throttle-transition), filter var(--throttle-transition), box-shadow var(--throttle-transition);
1471
1527
  }
1472
1528
  .throttle-button:disabled { opacity: .55; cursor: not-allowed; }
1473
1529
  .throttle-button:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--throttle-color-background), 0 0 0 4px var(--throttle-color-primary); }
1474
- .throttle-button--primary { background: var(--throttle-color-primary); color: var(--throttle-color-primary-foreground); width: 100%; }
1530
+ .throttle-button--primary { background: var(--throttle-color-primary); color: var(--throttle-color-primary-foreground); width: var(--throttle-button-width, 100%); }
1475
1531
  .throttle-button--primary:hover:not(:disabled) { filter: brightness(0.92); }
1476
1532
  .throttle-button--secondary { background: var(--throttle-color-surface); color: var(--throttle-color-foreground); border-color: var(--throttle-color-border-control); }
1477
1533
  .throttle-button--secondary:hover:not(:disabled) { background: var(--throttle-color-muted); }
@@ -1590,6 +1646,7 @@ var THROTTLE_STYLES = `
1590
1646
  is near-white, so on a light host page it was rendering white-on-white. */
1591
1647
  .throttle-cardframe { width: 100%; min-height: 420px; border: 0; display: block; }
1592
1648
  .throttle-centre { display: flex; align-items: center; justify-content: center; min-height: 160px; }
1649
+ .throttle-fieldrow { display: grid; grid-template-columns: 1fr 1fr; gap: var(--throttle-space-4); align-items: start; }
1593
1650
  .throttle-section__title { font-size: var(--throttle-font-size-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--throttle-color-muted-foreground); margin: 0 0 var(--throttle-space-2); font-weight: 600; }
1594
1651
  .throttle-addresses { display: grid; grid-template-columns: 1fr 1fr; gap: var(--throttle-space-5); }
1595
1652
  .throttle-addressblock__line { margin: 0 0 2px; }
@@ -1635,7 +1692,12 @@ var THROTTLE_STYLES = `
1635
1692
  it span. Stretch it explicitly when stacked. */
1636
1693
  .throttle-account { flex-direction: column; align-items: stretch; gap: var(--throttle-space-4); }
1637
1694
  .throttle-addresses { grid-template-columns: 1fr; }
1695
+ .throttle-fieldrow { grid-template-columns: 1fr; }
1638
1696
  .throttle-tabs__rail { width: 100%; }
1697
+ /* One column, and the rail stops sticking \u2014 on a phone a sticky summary
1698
+ covers the very line items it is summarising. */
1699
+ .throttle-detail { grid-template-columns: 1fr; }
1700
+ .throttle-detail__rail { position: static; }
1639
1701
  }
1640
1702
 
1641
1703
  .throttle-table { width: 100%; border-collapse: collapse; text-align: left; }
@@ -1713,12 +1775,50 @@ var THROTTLE_STYLES = `
1713
1775
  padding: var(--throttle-space-3) 0;
1714
1776
  }
1715
1777
  .throttle-rowitem:first-child { border-top: none; padding-top: 0; }
1716
- .throttle-actions { display: flex; gap: var(--throttle-space-2); flex-wrap: wrap; }
1778
+ .throttle-actions {
1779
+ display: flex; gap: var(--throttle-space-2); flex-wrap: wrap; align-items: center;
1780
+ /* Primary buttons are full-width so a form's submit fills its card. In a row
1781
+ of sibling actions that same rule made every button claim 100% and then
1782
+ shrink to share the line, squeezing Resume to 59px so its label wrapped to
1783
+ two lines inside a 48px box. A custom property INHERITS to the buttons, so
1784
+ the row opts them back to content width without a descendant selector \u2014
1785
+ those outrank the merchant overrides in appearance.elements. */
1786
+ --throttle-button-width: auto;
1787
+ }
1717
1788
  .throttle-table__money { display: block; text-align: right; font-variant-numeric: tabular-nums; }
1718
- .throttle-lineitem { display: flex; align-items: center; gap: var(--throttle-space-3); padding: var(--throttle-space-2) 0; }
1789
+ .throttle-lineitem { display: flex; align-items: flex-start; gap: var(--throttle-space-3); padding: var(--throttle-space-2) 0; }
1790
+ /* The UA's 1em paragraph margins pushed a two-line item to 96px, so five
1791
+ items filled a screen with mostly whitespace. These carry the spacing
1792
+ instead. Separate classes, not a ".throttle-lineitem p" descendant
1793
+ selector -- those outrank the merchant's appearance.elements overrides. */
1794
+ .throttle-lineitem__desc { margin: var(--throttle-space-1) 0 0; color: var(--throttle-color-muted-foreground); }
1795
+ .throttle-lineitem__meta { margin: var(--throttle-space-1) 0 0; color: var(--throttle-color-muted-foreground); font-size: var(--throttle-font-size-sm); }
1719
1796
  .throttle-lineitem__image { width: 48px; height: 48px; object-fit: cover; border-radius: var(--throttle-radius-sm); flex: none; }
1720
1797
  .throttle-totals { display: flex; flex-direction: column; gap: var(--throttle-space-1); }
1721
1798
 
1799
+ /* Order and invoice detail: the record on the left, what it costs and what
1800
+ you can do about it on the right. The rail sticks so the total and the
1801
+ actions stay reachable on an order with thirty lines, which is exactly when
1802
+ a buyer most wants them. Collapses below, where a sticky rail would eat a
1803
+ phone screen. */
1804
+ .throttle-detail { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: var(--throttle-space-6); align-items: start; }
1805
+ .throttle-detail__main { display: flex; flex-direction: column; gap: var(--throttle-space-5); min-width: 0; }
1806
+ .throttle-detail__rail {
1807
+ display: flex; flex-direction: column; gap: var(--throttle-space-4);
1808
+ position: sticky; top: var(--throttle-space-4);
1809
+ padding: var(--throttle-space-4);
1810
+ border: var(--throttle-border-width) solid var(--throttle-color-border);
1811
+ border-radius: var(--throttle-radius-md);
1812
+ background: var(--throttle-color-surface);
1813
+ }
1814
+ /* The one number the buyer came for. */
1815
+ .throttle-detail__headline { font-size: var(--throttle-font-size-xl); font-weight: 600; line-height: 1.2; }
1816
+ .throttle-detail__section { display: flex; flex-direction: column; gap: var(--throttle-space-2); }
1817
+ .throttle-detail__label { font-size: var(--throttle-font-size-sm); font-weight: 500; color: var(--throttle-color-muted-foreground); letter-spacing: .04em; text-transform: uppercase; }
1818
+ /* A rail action column: full width, stacked, so the primary reads as primary. */
1819
+ .throttle-detail__actions { display: flex; flex-direction: column; gap: var(--throttle-space-2); --throttle-button-width: 100%; }
1820
+ .throttle-detail__link { display: inline-flex; align-items: center; gap: var(--throttle-space-1); }
1821
+
1722
1822
  @media (prefers-reduced-motion: reduce) {
1723
1823
  .throttle-button, .throttle-field__input, .throttle-dropdown__item, .throttle-dropdown__trigger, .throttle-tabs__tab, .throttle-table__row, .throttle-modal__close {
1724
1824
  transition: none;
@@ -1837,13 +1937,20 @@ function FieldGroup(props) {
1837
1937
  ] }, i)) });
1838
1938
  }
1839
1939
 
1840
- // src/react/components/primitives/Alert.tsx
1940
+ // src/react/components/primitives/FieldRow.tsx
1841
1941
  var import_jsx_runtime9 = require("react/jsx-runtime");
1942
+ function FieldRow({ children }) {
1943
+ const a = useAppearance();
1944
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ...a.el("fieldRow", "throttle-fieldrow"), children });
1945
+ }
1946
+
1947
+ // src/react/components/primitives/Alert.tsx
1948
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1842
1949
  function Alert(props) {
1843
1950
  const a = useAppearance();
1844
1951
  const Slot = a.slots.Alert;
1845
- if (Slot) return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { tone: props.tone, children: props.children });
1846
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1952
+ if (Slot) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { tone: props.tone, children: props.children });
1953
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1847
1954
  "p",
1848
1955
  {
1849
1956
  ...a.el("alert", `throttle-alert throttle-alert--${props.tone}`),
@@ -1854,11 +1961,11 @@ function Alert(props) {
1854
1961
  }
1855
1962
 
1856
1963
  // src/react/components/primitives/Skeleton.tsx
1857
- var import_jsx_runtime10 = require("react/jsx-runtime");
1964
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1858
1965
  function Skeleton(props) {
1859
1966
  const a = useAppearance();
1860
1967
  const rows = Array.from({ length: props.count ?? 1 });
1861
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { "aria-hidden": "true", className: "throttle-stack", children: rows.map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { ...a.el("skeleton", "throttle-skeleton") }, i)) });
1968
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { "aria-hidden": "true", className: "throttle-stack", children: rows.map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { ...a.el("skeleton", "throttle-skeleton") }, i)) });
1862
1969
  }
1863
1970
 
1864
1971
  // src/react/components/primitives/Modal.tsx
@@ -1867,10 +1974,10 @@ var import_react_dom = require("react-dom");
1867
1974
 
1868
1975
  // src/react/components/surface.tsx
1869
1976
  var import_react7 = require("react");
1870
- var import_jsx_runtime11 = require("react/jsx-runtime");
1977
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1871
1978
  var Ctx5 = (0, import_react7.createContext)("standalone");
1872
1979
  function SurfaceProvider(props) {
1873
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Ctx5.Provider, { value: props.value, children: props.children });
1980
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Ctx5.Provider, { value: props.value, children: props.children });
1874
1981
  }
1875
1982
  function useSurface() {
1876
1983
  return (0, import_react7.useContext)(Ctx5);
@@ -1880,7 +1987,7 @@ function useCardClass() {
1880
1987
  }
1881
1988
 
1882
1989
  // src/react/components/primitives/Modal.tsx
1883
- var import_jsx_runtime12 = require("react/jsx-runtime");
1990
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1884
1991
  var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
1885
1992
  function Modal(props) {
1886
1993
  const a = useAppearance();
@@ -1931,7 +2038,7 @@ function Modal(props) {
1931
2038
  }, [props.open, mounted]);
1932
2039
  if (!props.open || !mounted) return null;
1933
2040
  return (0, import_react_dom.createPortal)(
1934
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2041
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1935
2042
  "div",
1936
2043
  {
1937
2044
  ...a.el(props.overlayKey ?? "modal.overlay", "throttle-modal__overlay"),
@@ -1939,7 +2046,7 @@ function Modal(props) {
1939
2046
  onClick: (e) => {
1940
2047
  if (e.target === e.currentTarget) props.onClose();
1941
2048
  },
1942
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2049
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1943
2050
  "div",
1944
2051
  {
1945
2052
  ...a.el(props.containerKey ?? "modal.container", props.size === "compact" ? "throttle-modal__container throttle-modal__container--compact" : "throttle-modal__container"),
@@ -1949,7 +2056,7 @@ function Modal(props) {
1949
2056
  "aria-labelledby": props.labelledBy,
1950
2057
  tabIndex: -1,
1951
2058
  children: [
1952
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2059
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1953
2060
  "button",
1954
2061
  {
1955
2062
  ...a.el("modal.closeButton", "throttle-modal__close"),
@@ -1959,7 +2066,7 @@ function Modal(props) {
1959
2066
  children: "\xD7"
1960
2067
  }
1961
2068
  ),
1962
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SurfaceProvider, { value: "modal", children: props.children })
2069
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SurfaceProvider, { value: "modal", children: props.children })
1963
2070
  ]
1964
2071
  }
1965
2072
  )
@@ -1971,14 +2078,22 @@ function Modal(props) {
1971
2078
 
1972
2079
  // src/react/components/primitives/Confirm.tsx
1973
2080
  var import_react9 = require("react");
1974
- var import_jsx_runtime13 = require("react/jsx-runtime");
2081
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1975
2082
  var ConfirmContext = (0, import_react9.createContext)(null);
1976
- function ConfirmProvider({ children }) {
2083
+ function ConfirmProvider({
2084
+ children,
2085
+ stepUpOpen = false,
2086
+ onStepUpResolve
2087
+ }) {
1977
2088
  const [request2, setRequest] = (0, import_react9.useState)(null);
2089
+ const [password, setPassword] = (0, import_react9.useState)("");
1978
2090
  const { t } = useCopy();
1979
2091
  const a = useAppearance();
1980
2092
  const titleId = (0, import_react9.useId)();
1981
2093
  const settle = (0, import_react9.useRef)(null);
2094
+ (0, import_react9.useEffect)(() => {
2095
+ if (!stepUpOpen) setPassword("");
2096
+ }, [stepUpOpen]);
1982
2097
  const answer = (0, import_react9.useCallback)((value) => {
1983
2098
  settle.current?.(value);
1984
2099
  settle.current = null;
@@ -1991,14 +2106,52 @@ function ConfirmProvider({ children }) {
1991
2106
  settle.current = resolve;
1992
2107
  });
1993
2108
  }, []);
1994
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(ConfirmContext.Provider, { value: ask, children: [
2109
+ const showStepUp = stepUpOpen && Boolean(onStepUpResolve);
2110
+ const open = showStepUp || request2 !== null;
2111
+ const close = () => {
2112
+ if (showStepUp) onStepUpResolve(null);
2113
+ else answer(false);
2114
+ };
2115
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(ConfirmContext.Provider, { value: ask, children: [
1995
2116
  children,
1996
- request2 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Modal, { open: true, onClose: () => answer(false), labelledBy: titleId, size: "compact", children: [
1997
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { ...a.el("confirm.header", "throttle-modal__header"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h2", { id: titleId, ...a.el("confirm.title", "throttle-modal__title"), children: request2.title }) }),
1998
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { ...a.el("confirm.body", "throttle-modal__body"), children: [
1999
- request2.body ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "throttle-muted", children: request2.body }) : null,
2000
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "throttle-actions", children: [
2001
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2117
+ open ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Modal, { open: true, onClose: close, labelledBy: titleId, size: "compact", children: showStepUp ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("form", { onSubmit: (e) => {
2118
+ e.preventDefault();
2119
+ onStepUpResolve(password);
2120
+ }, children: [
2121
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ...a.el("confirm.header", "throttle-modal__header"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h2", { id: titleId, ...a.el("stepUp.title", "throttle-modal__title"), children: t.stepUp.title }) }),
2122
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { ...a.el("confirm.body", "throttle-modal__body"), children: [
2123
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "throttle-muted", children: t.stepUp.description }),
2124
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2125
+ Field,
2126
+ {
2127
+ label: t.stepUp.password,
2128
+ type: "password",
2129
+ autoComplete: "current-password",
2130
+ value: password,
2131
+ onChange: setPassword,
2132
+ required: true,
2133
+ elementKey: "stepUp.passwordField"
2134
+ }
2135
+ ),
2136
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "throttle-actions", children: [
2137
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button, { type: "submit", elementKey: "stepUp.submitButton", children: t.stepUp.submitButton }),
2138
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2139
+ Button,
2140
+ {
2141
+ variant: "secondary",
2142
+ elementKey: "stepUp.cancelButton",
2143
+ onClick: () => onStepUpResolve(null),
2144
+ children: t.stepUp.cancelButton
2145
+ }
2146
+ )
2147
+ ] })
2148
+ ] })
2149
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
2150
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ...a.el("confirm.header", "throttle-modal__header"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h2", { id: titleId, ...a.el("confirm.title", "throttle-modal__title"), children: request2.title }) }),
2151
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { ...a.el("confirm.body", "throttle-modal__body"), children: [
2152
+ request2.body ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "throttle-muted", children: request2.body }) : null,
2153
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "throttle-actions", children: [
2154
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2002
2155
  Button,
2003
2156
  {
2004
2157
  elementKey: "confirm.confirmButton",
@@ -2007,10 +2160,10 @@ function ConfirmProvider({ children }) {
2007
2160
  children: request2.confirmLabel ?? t.common.delete
2008
2161
  }
2009
2162
  ),
2010
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { elementKey: "confirm.cancelButton", variant: "secondary", onClick: () => answer(false), children: request2.cancelLabel ?? t.common.keepIt })
2163
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button, { elementKey: "confirm.cancelButton", variant: "secondary", onClick: () => answer(false), children: request2.cancelLabel ?? t.common.keepIt })
2011
2164
  ] })
2012
2165
  ] })
2013
- ] }) : null
2166
+ ] }) }) : null
2014
2167
  ] });
2015
2168
  }
2016
2169
  function useConfirm() {
@@ -2024,7 +2177,7 @@ function useConfirm() {
2024
2177
 
2025
2178
  // src/react/components/primitives/Dropdown.tsx
2026
2179
  var import_react10 = require("react");
2027
- var import_jsx_runtime14 = require("react/jsx-runtime");
2180
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2028
2181
  function Dropdown(props) {
2029
2182
  const a = useAppearance();
2030
2183
  const [open, setOpen] = (0, import_react10.useState)(false);
@@ -2057,8 +2210,8 @@ function Dropdown(props) {
2057
2210
  const next = (at + delta + items.length) % items.length;
2058
2211
  items[next < 0 ? items.length - 1 : next].focus();
2059
2212
  };
2060
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { ref: root, style: { position: "relative", display: "inline-block" }, children: [
2061
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2213
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { ref: root, style: { position: "relative", display: "inline-block" }, children: [
2214
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2062
2215
  "button",
2063
2216
  {
2064
2217
  ref: trigger,
@@ -2071,7 +2224,7 @@ function Dropdown(props) {
2071
2224
  children: props.trigger
2072
2225
  }
2073
2226
  ),
2074
- open ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2227
+ open ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2075
2228
  "div",
2076
2229
  {
2077
2230
  ref: menu,
@@ -2097,24 +2250,24 @@ function DropdownItem(props) {
2097
2250
  const a = useAppearance();
2098
2251
  const attrs = a.el(props.itemKey ?? "dropdown.item", "throttle-dropdown__item");
2099
2252
  if (props.href) {
2100
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("a", { ...attrs, role: "menuitem", href: props.href, tabIndex: -1, children: props.children });
2253
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("a", { ...attrs, role: "menuitem", href: props.href, tabIndex: -1, children: props.children });
2101
2254
  }
2102
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { ...attrs, role: "menuitem", type: "button", tabIndex: -1, onClick: props.onClick, children: props.children });
2255
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { ...attrs, role: "menuitem", type: "button", tabIndex: -1, onClick: props.onClick, children: props.children });
2103
2256
  }
2104
2257
  function DropdownSeparator() {
2105
2258
  const a = useAppearance();
2106
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("hr", { ...a.el("dropdown.separator", "throttle-dropdown__separator") });
2259
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("hr", { ...a.el("dropdown.separator", "throttle-dropdown__separator") });
2107
2260
  }
2108
2261
 
2109
2262
  // src/react/components/primitives/Tabs.tsx
2110
- var import_jsx_runtime15 = require("react/jsx-runtime");
2263
+ var import_jsx_runtime16 = require("react/jsx-runtime");
2111
2264
  function Tabs(props) {
2112
2265
  const a = useAppearance();
2113
2266
  const at = props.tabs.findIndex((t) => t.id === props.active);
2114
2267
  const vertical = props.orientation === "vertical";
2115
2268
  const listClass = vertical ? "throttle-tabs__rail" : "throttle-tabs__list";
2116
2269
  const itemClass = vertical ? "throttle-tabs__railitem" : "throttle-tabs__tab";
2117
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2270
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2118
2271
  "div",
2119
2272
  {
2120
2273
  ...a.el("tabs.list", listClass),
@@ -2133,7 +2286,7 @@ function Tabs(props) {
2133
2286
  children: props.tabs.map((tab) => {
2134
2287
  const selected = tab.id === props.active;
2135
2288
  const { className, ...rest } = a.el("tabs.tab", itemClass);
2136
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2289
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
2137
2290
  "button",
2138
2291
  {
2139
2292
  ...rest,
@@ -2158,16 +2311,16 @@ function Tabs(props) {
2158
2311
  }
2159
2312
 
2160
2313
  // src/react/components/primitives/DataTable.tsx
2161
- var import_jsx_runtime16 = require("react/jsx-runtime");
2314
+ var import_jsx_runtime17 = require("react/jsx-runtime");
2162
2315
  function DataTable(props) {
2163
2316
  const a = useAppearance();
2164
2317
  const clickable = Boolean(props.onRowClick);
2165
2318
  return (
2166
2319
  // Tables are the one thing allowed to be wider than the panel; it scrolls
2167
2320
  // rather than forcing the whole page to.
2168
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "throttle-table__scroll", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("table", { ...a.el(props.tableKey ?? "table", "throttle-table"), children: [
2169
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tr", { children: props.columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("th", { ...a.el("table.head", "throttle-table__head"), scope: "col", children: col.label }, col.key)) }) }),
2170
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tbody", { children: props.rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2321
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "throttle-table__scroll", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("table", { ...a.el(props.tableKey ?? "table", "throttle-table"), children: [
2322
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("tr", { children: props.columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("th", { ...a.el("table.head", "throttle-table__head"), scope: "col", children: col.label }, col.key)) }) }),
2323
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("tbody", { children: props.rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2171
2324
  "tr",
2172
2325
  {
2173
2326
  ...a.el(props.rowElementKey ?? "table.row", "throttle-table__row"),
@@ -2179,7 +2332,7 @@ function DataTable(props) {
2179
2332
  props.onRowClick(row);
2180
2333
  }
2181
2334
  } : void 0,
2182
- children: props.columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("td", { ...a.el("table.cell", "throttle-table__cell"), children: col.render ? col.render(row) : String(row[col.key] ?? "") }, col.key))
2335
+ children: props.columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("td", { ...a.el("table.cell", "throttle-table__cell"), children: col.render ? col.render(row) : String(row[col.key] ?? "") }, col.key))
2183
2336
  },
2184
2337
  props.rowKey(row)
2185
2338
  )) })
@@ -2188,99 +2341,54 @@ function DataTable(props) {
2188
2341
  }
2189
2342
 
2190
2343
  // src/react/components/primitives/EmptyState.tsx
2191
- var import_jsx_runtime17 = require("react/jsx-runtime");
2344
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2192
2345
  function EmptyState(props) {
2193
2346
  const a = useAppearance();
2194
2347
  const Slot = a.slots.EmptyState;
2195
- if (Slot) return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Slot, { title: props.title, description: props.description });
2196
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ...a.el("emptyState", "throttle-empty"), children: [
2197
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { ...a.el("emptyState.title", "throttle-empty__title"), children: props.title }),
2198
- props.description ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { ...a.el("emptyState.description", "throttle-empty__description"), children: props.description }) : null
2348
+ if (Slot) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Slot, { title: props.title, description: props.description });
2349
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { ...a.el("emptyState", "throttle-empty"), children: [
2350
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { ...a.el("emptyState.title", "throttle-empty__title"), children: props.title }),
2351
+ props.description ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { ...a.el("emptyState.description", "throttle-empty__description"), children: props.description }) : null
2199
2352
  ] });
2200
2353
  }
2201
2354
 
2202
2355
  // src/react/components/primitives/Avatar.tsx
2203
- var import_jsx_runtime18 = require("react/jsx-runtime");
2356
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2204
2357
  function Avatar(props) {
2205
2358
  const a = useAppearance();
2206
2359
  const Slot = a.slots.Avatar;
2207
- if (Slot) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Slot, { name: props.name, email: props.email });
2360
+ if (Slot) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Slot, { name: props.name, email: props.email });
2208
2361
  const initials = props.name.split(" ").map((part) => part.trim()[0]).filter(Boolean).slice(0, 2).join("") || props.email.trim()[0] || "?";
2209
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { ...a.el("avatar", "throttle-avatar"), title: props.email, children: initials.toUpperCase() });
2362
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { ...a.el("avatar", "throttle-avatar"), title: props.email, children: initials.toUpperCase() });
2210
2363
  }
2211
2364
 
2212
2365
  // src/react/components/primitives/Badge.tsx
2213
- var import_jsx_runtime19 = require("react/jsx-runtime");
2366
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2214
2367
  function Badge(props) {
2215
2368
  const a = useAppearance();
2216
2369
  const tone = props.tone ?? "neutral";
2217
2370
  const base = tone === "neutral" ? "throttle-badge" : `throttle-badge throttle-badge--${tone}`;
2218
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { ...a.el(props.elementKey ?? "badge", base), children: props.children });
2219
- }
2220
-
2221
- // src/react/components/auth/StepUpDialog.tsx
2222
- var import_react11 = require("react");
2223
- var import_jsx_runtime20 = require("react/jsx-runtime");
2224
- function StepUpDialog(props) {
2225
- const a = useAppearance();
2226
- const cardClass = useCardClass();
2227
- const { t } = useCopy();
2228
- const [password, setPassword] = (0, import_react11.useState)("");
2229
- const titleId = (0, import_react11.useId)();
2230
- (0, import_react11.useEffect)(() => {
2231
- if (!props.open) setPassword("");
2232
- }, [props.open]);
2233
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Modal, { open: props.open, onClose: () => props.onResolve(null), labelledBy: titleId, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { ...a.el("stepUp.root", cardClass), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2234
- "form",
2235
- {
2236
- onSubmit: (e) => {
2237
- e.preventDefault();
2238
- props.onResolve(password);
2239
- },
2240
- children: [
2241
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "throttle-card__header", children: [
2242
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h2", { id: titleId, ...a.el("stepUp.title", "throttle-card__title"), children: t.stepUp.title }),
2243
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "throttle-card__description", children: t.stepUp.description })
2244
- ] }),
2245
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(CardBody, { children: [
2246
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2247
- Field,
2248
- {
2249
- label: t.stepUp.password,
2250
- type: "password",
2251
- autoComplete: "current-password",
2252
- value: password,
2253
- onChange: setPassword,
2254
- required: true,
2255
- elementKey: "stepUp.passwordField"
2256
- }
2257
- ),
2258
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Button, { type: "submit", elementKey: "stepUp.submitButton", children: t.stepUp.submitButton }),
2259
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Button, { variant: "link", elementKey: "stepUp.cancelButton", onClick: () => props.onResolve(null), children: t.stepUp.cancelButton })
2260
- ] })
2261
- ]
2262
- }
2263
- ) }) });
2371
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { ...a.el(props.elementKey ?? "badge", base), children: props.children });
2264
2372
  }
2265
2373
 
2266
2374
  // src/react/components/auth/AuthModal.tsx
2267
- var import_react19 = require("react");
2375
+ var import_react18 = require("react");
2268
2376
 
2269
2377
  // src/react/components/auth/AuthFlow.tsx
2270
- var import_react18 = require("react");
2378
+ var import_react17 = require("react");
2271
2379
 
2272
2380
  // src/react/components/auth/SignIn.tsx
2273
- var import_react13 = require("react");
2381
+ var import_react12 = require("react");
2274
2382
 
2275
2383
  // src/react/components/useAction.ts
2276
- var import_react12 = require("react");
2384
+ var import_react11 = require("react");
2277
2385
  function useAction() {
2278
2386
  const { errorMessage } = useCopy();
2279
- const [submitting, setSubmitting] = (0, import_react12.useState)(false);
2280
- const [error, setError] = (0, import_react12.useState)(null);
2281
- const [notice, setNotice] = (0, import_react12.useState)(null);
2282
- const inFlight = (0, import_react12.useRef)(false);
2283
- const run = (0, import_react12.useCallback)(
2387
+ const [submitting, setSubmitting] = (0, import_react11.useState)(false);
2388
+ const [error, setError] = (0, import_react11.useState)(null);
2389
+ const [notice, setNotice] = (0, import_react11.useState)(null);
2390
+ const inFlight = (0, import_react11.useRef)(false);
2391
+ const run = (0, import_react11.useCallback)(
2284
2392
  async (fn) => {
2285
2393
  if (inFlight.current) return;
2286
2394
  inFlight.current = true;
@@ -2311,8 +2419,8 @@ function SignIn(props) {
2311
2419
  const { t } = useCopy(props.localization);
2312
2420
  const { auth } = useAuth();
2313
2421
  const { submitting, error, run } = useAction();
2314
- const [email, setEmail] = (0, import_react13.useState)("");
2315
- const [password, setPassword] = (0, import_react13.useState)("");
2422
+ const [email, setEmail] = (0, import_react12.useState)("");
2423
+ const [password, setPassword] = (0, import_react12.useState)("");
2316
2424
  const variant = props.variant ?? "quiet";
2317
2425
  const branded = variant === "branded";
2318
2426
  const grouped = variant === "grouped";
@@ -2393,7 +2501,7 @@ function SignIn(props) {
2393
2501
  }
2394
2502
 
2395
2503
  // src/react/components/auth/SignUp.tsx
2396
- var import_react14 = require("react");
2504
+ var import_react13 = require("react");
2397
2505
  var import_jsx_runtime22 = require("react/jsx-runtime");
2398
2506
  function SignUp(props) {
2399
2507
  const a = useAppearance(props.appearance);
@@ -2402,8 +2510,8 @@ function SignUp(props) {
2402
2510
  const { t } = useCopy(props.localization);
2403
2511
  const { auth } = useAuth();
2404
2512
  const { submitting, error, notice, run } = useAction();
2405
- const [email, setEmail] = (0, import_react14.useState)("");
2406
- const [password, setPassword] = (0, import_react14.useState)("");
2513
+ const [email, setEmail] = (0, import_react13.useState)("");
2514
+ const [password, setPassword] = (0, import_react13.useState)("");
2407
2515
  const variant = props.variant ?? "quiet";
2408
2516
  const branded = variant === "branded";
2409
2517
  const grouped = variant === "grouped";
@@ -2486,7 +2594,7 @@ function SignUp(props) {
2486
2594
  }
2487
2595
 
2488
2596
  // src/react/components/auth/ForgotPassword.tsx
2489
- var import_react15 = require("react");
2597
+ var import_react14 = require("react");
2490
2598
  var import_jsx_runtime23 = require("react/jsx-runtime");
2491
2599
  function ForgotPassword(props) {
2492
2600
  const a = useAppearance(props.appearance);
@@ -2495,7 +2603,7 @@ function ForgotPassword(props) {
2495
2603
  const { t } = useCopy(props.localization);
2496
2604
  const { auth } = useAuth();
2497
2605
  const { submitting, error, notice, run } = useAction();
2498
- const [email, setEmail] = (0, import_react15.useState)("");
2606
+ const [email, setEmail] = (0, import_react14.useState)("");
2499
2607
  const branded = (props.variant ?? "quiet") === "branded";
2500
2608
  const logo = useBrandLogo(props.logo);
2501
2609
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
@@ -2545,7 +2653,7 @@ function ForgotPassword(props) {
2545
2653
  }
2546
2654
 
2547
2655
  // src/react/components/auth/ResetPassword.tsx
2548
- var import_react16 = require("react");
2656
+ var import_react15 = require("react");
2549
2657
  var import_jsx_runtime24 = require("react/jsx-runtime");
2550
2658
  function ResetPassword(props) {
2551
2659
  const a = useAppearance(props.appearance);
@@ -2554,7 +2662,7 @@ function ResetPassword(props) {
2554
2662
  const { t } = useCopy(props.localization);
2555
2663
  const { auth } = useAuth();
2556
2664
  const { submitting, error, notice, run } = useAction();
2557
- const [password, setPassword] = (0, import_react16.useState)("");
2665
+ const [password, setPassword] = (0, import_react15.useState)("");
2558
2666
  const branded = (props.variant ?? "quiet") === "branded";
2559
2667
  const logo = useBrandLogo(props.logo);
2560
2668
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { ...a.el("resetPassword.root", cardClass), children: [
@@ -2606,7 +2714,7 @@ function ResetPassword(props) {
2606
2714
  }
2607
2715
 
2608
2716
  // src/react/components/auth/VerifyEmail.tsx
2609
- var import_react17 = require("react");
2717
+ var import_react16 = require("react");
2610
2718
  var import_jsx_runtime25 = require("react/jsx-runtime");
2611
2719
  function VerifyEmail(props) {
2612
2720
  const a = useAppearance(props.appearance);
@@ -2615,12 +2723,12 @@ function VerifyEmail(props) {
2615
2723
  const { t, errorMessage } = useCopy(props.localization);
2616
2724
  const { auth } = useAuth();
2617
2725
  const { submitting, notice, run } = useAction();
2618
- const [state, setState] = (0, import_react17.useState)(props.token ? "verifying" : "idle");
2619
- const [error, setError] = (0, import_react17.useState)(null);
2726
+ const [state, setState] = (0, import_react16.useState)(props.token ? "verifying" : "idle");
2727
+ const [error, setError] = (0, import_react16.useState)(null);
2620
2728
  const branded = (props.variant ?? "quiet") === "branded";
2621
2729
  const logo = useBrandLogo(props.logo);
2622
- const attempted = (0, import_react17.useRef)(null);
2623
- (0, import_react17.useEffect)(() => {
2730
+ const attempted = (0, import_react16.useRef)(null);
2731
+ (0, import_react16.useEffect)(() => {
2624
2732
  const token = props.token;
2625
2733
  if (!token || attempted.current === token) return;
2626
2734
  attempted.current = token;
@@ -2698,9 +2806,9 @@ function readLocation() {
2698
2806
  function AuthFlow(props) {
2699
2807
  const a = useAppearance(props.appearance);
2700
2808
  const controlled = props.view !== void 0;
2701
- const [internal, setInternal] = (0, import_react18.useState)(props.initialView ?? "signIn");
2702
- const [urlToken, setUrlToken] = (0, import_react18.useState)(void 0);
2703
- (0, import_react18.useEffect)(() => {
2809
+ const [internal, setInternal] = (0, import_react17.useState)(props.initialView ?? "signIn");
2810
+ const [urlToken, setUrlToken] = (0, import_react17.useState)(void 0);
2811
+ (0, import_react17.useEffect)(() => {
2704
2812
  const found = readLocation();
2705
2813
  if (found.token) setUrlToken(found.token);
2706
2814
  if (found.view && !controlled && props.initialView === void 0) setInternal(found.view);
@@ -2714,7 +2822,7 @@ function AuthFlow(props) {
2714
2822
  window.location.hash = HASH_FOR[next];
2715
2823
  }
2716
2824
  };
2717
- (0, import_react18.useEffect)(() => {
2825
+ (0, import_react17.useEffect)(() => {
2718
2826
  if (props.routing !== "hash" || typeof window === "undefined") return;
2719
2827
  const onHashChange = () => {
2720
2828
  if (controlled) return;
@@ -2751,7 +2859,7 @@ function AuthFlow(props) {
2751
2859
  var import_jsx_runtime27 = require("react/jsx-runtime");
2752
2860
  function AuthModal(props) {
2753
2861
  const scoped = useAppearanceProviderValue(props.appearance);
2754
- const titleId = (0, import_react19.useId)();
2862
+ const titleId = (0, import_react18.useId)();
2755
2863
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
2756
2864
  Modal,
2757
2865
  {
@@ -2779,13 +2887,13 @@ function AuthModal(props) {
2779
2887
  }
2780
2888
 
2781
2889
  // src/react/components/account/AccountModal.tsx
2782
- var import_react31 = require("react");
2890
+ var import_react30 = require("react");
2783
2891
 
2784
2892
  // src/react/components/account/AccountDashboard.tsx
2785
- var import_react30 = require("react");
2893
+ var import_react29 = require("react");
2786
2894
 
2787
2895
  // src/react/components/account/VerifyEmailBanner.tsx
2788
- var import_react20 = require("react");
2896
+ var import_react19 = require("react");
2789
2897
  var import_jsx_runtime28 = require("react/jsx-runtime");
2790
2898
  var DISMISS_KEY = "throttle-auth:verify-banner-dismissed";
2791
2899
  function readDismissed() {
@@ -2807,7 +2915,7 @@ function VerifyEmailBanner(props) {
2807
2915
  const { t } = useCopy(props.localization);
2808
2916
  const { auth, status, emailVerified } = useAuth();
2809
2917
  const { submitting, notice, error, run } = useAction();
2810
- const [dismissed, setDismissed] = (0, import_react20.useState)(readDismissed);
2918
+ const [dismissed, setDismissed] = (0, import_react19.useState)(readDismissed);
2811
2919
  if (status !== "authenticated" || emailVerified || dismissed) return null;
2812
2920
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { ...a.el("verifyBanner.root", "throttle-banner"), children: [
2813
2921
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { ...a.el("verifyBanner.message"), children: t.verifyBanner.message }),
@@ -2898,10 +3006,10 @@ var ACCOUNT_ICONS = {
2898
3006
  };
2899
3007
 
2900
3008
  // src/react/components/account/ProfilePanel.tsx
2901
- var import_react22 = require("react");
3009
+ var import_react21 = require("react");
2902
3010
 
2903
3011
  // src/react/hooks.ts
2904
- var import_react21 = require("react");
3012
+ var import_react20 = require("react");
2905
3013
  function asError(err) {
2906
3014
  if (err instanceof ThrottleAuthError) return err;
2907
3015
  const anyErr = err;
@@ -2913,19 +3021,19 @@ function asError(err) {
2913
3021
  }
2914
3022
  function useResource(empty, load, deps) {
2915
3023
  const { status, emailVerified } = useAuth();
2916
- const [data, setData] = (0, import_react21.useState)(empty);
2917
- const [isLoading, setIsLoading] = (0, import_react21.useState)(status === "loading");
2918
- const [error, setError] = (0, import_react21.useState)(null);
2919
- const gen = (0, import_react21.useRef)(0);
2920
- const alive = (0, import_react21.useRef)(true);
2921
- (0, import_react21.useEffect)(() => {
3024
+ const [data, setData] = (0, import_react20.useState)(empty);
3025
+ const [isLoading, setIsLoading] = (0, import_react20.useState)(status === "loading");
3026
+ const [error, setError] = (0, import_react20.useState)(null);
3027
+ const gen = (0, import_react20.useRef)(0);
3028
+ const alive = (0, import_react20.useRef)(true);
3029
+ (0, import_react20.useEffect)(() => {
2922
3030
  alive.current = true;
2923
3031
  return () => {
2924
3032
  alive.current = false;
2925
3033
  gen.current++;
2926
3034
  };
2927
3035
  }, []);
2928
- const refetch = (0, import_react21.useCallback)(async () => {
3036
+ const refetch = (0, import_react20.useCallback)(async () => {
2929
3037
  const mine = ++gen.current;
2930
3038
  setIsLoading(true);
2931
3039
  try {
@@ -2940,7 +3048,7 @@ function useResource(empty, load, deps) {
2940
3048
  if (alive.current && gen.current === mine) setIsLoading(false);
2941
3049
  }
2942
3050
  }, deps);
2943
- (0, import_react21.useEffect)(() => {
3051
+ (0, import_react20.useEffect)(() => {
2944
3052
  if (status !== "authenticated") {
2945
3053
  gen.current++;
2946
3054
  setData(empty);
@@ -2955,7 +3063,7 @@ function useResource(empty, load, deps) {
2955
3063
  function useCustomer() {
2956
3064
  const { account } = useAuth();
2957
3065
  const res = useResource(null, () => account.getProfile(), [account]);
2958
- const update = (0, import_react21.useCallback)(async (patch) => {
3066
+ const update = (0, import_react20.useCallback)(async (patch) => {
2959
3067
  await account.updateProfile(patch);
2960
3068
  await res.refetch();
2961
3069
  }, [account, res]);
@@ -3057,9 +3165,9 @@ function ProfilePanel(props) {
3057
3165
  const { status } = useAuth();
3058
3166
  const resource = useCustomer();
3059
3167
  const { submitting, error, notice, run } = useAction();
3060
- const [form, setForm] = (0, import_react22.useState)({ firstName: "", lastName: "", phone: "", company: "" });
3061
- const edited = (0, import_react22.useRef)(false);
3062
- (0, import_react22.useEffect)(() => {
3168
+ const [form, setForm] = (0, import_react21.useState)({ firstName: "", lastName: "", phone: "", company: "" });
3169
+ const edited = (0, import_react21.useRef)(false);
3170
+ (0, import_react21.useEffect)(() => {
3063
3171
  const c = resource.data;
3064
3172
  if (!c || edited.current) return;
3065
3173
  setForm({
@@ -3107,55 +3215,59 @@ function ProfilePanel(props) {
3107
3215
  hint: t.profile.emailReadOnly
3108
3216
  }
3109
3217
  ),
3110
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3111
- Field,
3112
- {
3113
- label: t.profile.firstName,
3114
- value: form.firstName,
3115
- autoComplete: "given-name",
3116
- onChange: (v) => {
3117
- edited.current = true;
3118
- setForm((f) => ({ ...f, firstName: v }));
3218
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(FieldRow, { children: [
3219
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3220
+ Field,
3221
+ {
3222
+ label: t.profile.firstName,
3223
+ value: form.firstName,
3224
+ autoComplete: "given-name",
3225
+ onChange: (v) => {
3226
+ edited.current = true;
3227
+ setForm((f) => ({ ...f, firstName: v }));
3228
+ }
3119
3229
  }
3120
- }
3121
- ),
3122
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3123
- Field,
3124
- {
3125
- label: t.profile.lastName,
3126
- value: form.lastName,
3127
- autoComplete: "family-name",
3128
- onChange: (v) => {
3129
- edited.current = true;
3130
- setForm((f) => ({ ...f, lastName: v }));
3230
+ ),
3231
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3232
+ Field,
3233
+ {
3234
+ label: t.profile.lastName,
3235
+ value: form.lastName,
3236
+ autoComplete: "family-name",
3237
+ onChange: (v) => {
3238
+ edited.current = true;
3239
+ setForm((f) => ({ ...f, lastName: v }));
3240
+ }
3131
3241
  }
3132
- }
3133
- ),
3134
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3135
- Field,
3136
- {
3137
- label: t.profile.phone,
3138
- type: "tel",
3139
- value: form.phone,
3140
- autoComplete: "tel",
3141
- onChange: (v) => {
3142
- edited.current = true;
3143
- setForm((f) => ({ ...f, phone: v }));
3242
+ )
3243
+ ] }),
3244
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(FieldRow, { children: [
3245
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3246
+ Field,
3247
+ {
3248
+ label: t.profile.phone,
3249
+ type: "tel",
3250
+ value: form.phone,
3251
+ autoComplete: "tel",
3252
+ onChange: (v) => {
3253
+ edited.current = true;
3254
+ setForm((f) => ({ ...f, phone: v }));
3255
+ }
3144
3256
  }
3145
- }
3146
- ),
3147
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3148
- Field,
3149
- {
3150
- label: t.profile.company,
3151
- value: form.company,
3152
- autoComplete: "organization",
3153
- onChange: (v) => {
3154
- edited.current = true;
3155
- setForm((f) => ({ ...f, company: v }));
3257
+ ),
3258
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3259
+ Field,
3260
+ {
3261
+ label: t.profile.company,
3262
+ value: form.company,
3263
+ autoComplete: "organization",
3264
+ onChange: (v) => {
3265
+ edited.current = true;
3266
+ setForm((f) => ({ ...f, company: v }));
3267
+ }
3156
3268
  }
3157
- }
3158
- ),
3269
+ )
3270
+ ] }),
3159
3271
  error ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Alert, { tone: "error", children: error }) : null,
3160
3272
  notice ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Alert, { tone: "success", children: notice }) : null,
3161
3273
  /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Button, { type: "submit", loading: submitting, elementKey: "profilePanel.submitButton", children: t.profile.saveButton })
@@ -3167,16 +3279,16 @@ function ProfilePanel(props) {
3167
3279
  }
3168
3280
 
3169
3281
  // src/react/components/account/AddressesPanel.tsx
3170
- var import_react24 = require("react");
3282
+ var import_react23 = require("react");
3171
3283
 
3172
3284
  // src/react/components/account/AddressForm.tsx
3173
- var import_react23 = require("react");
3285
+ var import_react22 = require("react");
3174
3286
  var import_jsx_runtime32 = require("react/jsx-runtime");
3175
3287
  function AddressForm(props) {
3176
3288
  const a = useAppearance();
3177
3289
  const { t } = useCopy();
3178
3290
  const i = props.initial;
3179
- const [form, setForm] = (0, import_react23.useState)({
3291
+ const [form, setForm] = (0, import_react22.useState)({
3180
3292
  label: i?.label ?? "",
3181
3293
  firstName: i?.firstName ?? "",
3182
3294
  lastName: i?.lastName ?? "",
@@ -3212,10 +3324,14 @@ function AddressForm(props) {
3212
3324
  });
3213
3325
  },
3214
3326
  children: [
3215
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.label, value: form.label, onChange: set("label") }),
3216
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.firstName, value: form.firstName, onChange: set("firstName"), autoComplete: "given-name" }),
3217
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.lastName, value: form.lastName, onChange: set("lastName"), autoComplete: "family-name" }),
3218
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.company, value: form.company, onChange: set("company"), autoComplete: "organization" }),
3327
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(FieldRow, { children: [
3328
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.label, value: form.label, onChange: set("label") }),
3329
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.company, value: form.company, onChange: set("company"), autoComplete: "organization" })
3330
+ ] }),
3331
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(FieldRow, { children: [
3332
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.firstName, value: form.firstName, onChange: set("firstName"), autoComplete: "given-name" }),
3333
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.lastName, value: form.lastName, onChange: set("lastName"), autoComplete: "family-name" })
3334
+ ] }),
3219
3335
  /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3220
3336
  Field,
3221
3337
  {
@@ -3235,36 +3351,40 @@ function AddressForm(props) {
3235
3351
  autoComplete: "address-line2"
3236
3352
  }
3237
3353
  ),
3238
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.city, value: form.city, onChange: set("city"), required: true, autoComplete: "address-level2" }),
3239
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3240
- Field,
3241
- {
3242
- label: t.addresses.stateProvince,
3243
- value: form.stateProvince,
3244
- onChange: set("stateProvince"),
3245
- autoComplete: "address-level1"
3246
- }
3247
- ),
3248
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3249
- Field,
3250
- {
3251
- label: t.addresses.postalCode,
3252
- value: form.postalCode,
3253
- onChange: set("postalCode"),
3254
- autoComplete: "postal-code"
3255
- }
3256
- ),
3257
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3258
- Field,
3259
- {
3260
- label: t.addresses.countryCode,
3261
- value: form.countryCode,
3262
- onChange: set("countryCode"),
3263
- required: true,
3264
- autoComplete: "country",
3265
- hint: "ISO 3166-1 alpha-2, e.g. GB"
3266
- }
3267
- ),
3354
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(FieldRow, { children: [
3355
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.city, value: form.city, onChange: set("city"), required: true, autoComplete: "address-level2" }),
3356
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3357
+ Field,
3358
+ {
3359
+ label: t.addresses.stateProvince,
3360
+ value: form.stateProvince,
3361
+ onChange: set("stateProvince"),
3362
+ autoComplete: "address-level1"
3363
+ }
3364
+ )
3365
+ ] }),
3366
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(FieldRow, { children: [
3367
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3368
+ Field,
3369
+ {
3370
+ label: t.addresses.postalCode,
3371
+ value: form.postalCode,
3372
+ onChange: set("postalCode"),
3373
+ autoComplete: "postal-code"
3374
+ }
3375
+ ),
3376
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3377
+ Field,
3378
+ {
3379
+ label: t.addresses.countryCode,
3380
+ value: form.countryCode,
3381
+ onChange: set("countryCode"),
3382
+ required: true,
3383
+ autoComplete: "country",
3384
+ hint: "ISO 3166-1 alpha-2, e.g. GB"
3385
+ }
3386
+ )
3387
+ ] }),
3268
3388
  /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.phone, type: "tel", value: form.phone, onChange: set("phone"), autoComplete: "tel" }),
3269
3389
  props.error ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Alert, { tone: "error", children: props.error }) : null,
3270
3390
  /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "throttle-actions", children: [
@@ -3285,7 +3405,7 @@ function AddressesPanel(props) {
3285
3405
  const resource = useAddresses();
3286
3406
  const { submitting, error, run } = useAction();
3287
3407
  const confirm = useConfirm();
3288
- const [editing, setEditing] = (0, import_react24.useState)(null);
3408
+ const [editing, setEditing] = (0, import_react23.useState)(null);
3289
3409
  const variant = props.variant ?? "rows";
3290
3410
  const rowsVariant = variant === "rows";
3291
3411
  const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
@@ -3416,23 +3536,23 @@ function AddressesPanel(props) {
3416
3536
  }
3417
3537
 
3418
3538
  // src/react/components/account/PaymentMethodsPanel.tsx
3419
- var import_react26 = require("react");
3539
+ var import_react25 = require("react");
3420
3540
 
3421
3541
  // src/react/components/account/AddCardDialog.tsx
3422
- var import_react25 = require("react");
3542
+ var import_react24 = require("react");
3423
3543
  var import_jsx_runtime34 = require("react/jsx-runtime");
3424
3544
  function AddCardDialog(props) {
3425
3545
  const { account } = useAuth();
3426
- const titleId = (0, import_react25.useId)();
3546
+ const titleId = (0, import_react24.useId)();
3427
3547
  const { t } = useCopy(props.localization);
3428
- const [src, setSrc] = (0, import_react25.useState)(null);
3429
- const [error, setError] = (0, import_react25.useState)(null);
3430
- const [busy, setBusy] = (0, import_react25.useState)(false);
3431
- const onAdded = (0, import_react25.useRef)(props.onAdded);
3432
- const onClose = (0, import_react25.useRef)(props.onClose);
3548
+ const [src, setSrc] = (0, import_react24.useState)(null);
3549
+ const [error, setError] = (0, import_react24.useState)(null);
3550
+ const [busy, setBusy] = (0, import_react24.useState)(false);
3551
+ const onAdded = (0, import_react24.useRef)(props.onAdded);
3552
+ const onClose = (0, import_react24.useRef)(props.onClose);
3433
3553
  onAdded.current = props.onAdded;
3434
3554
  onClose.current = props.onClose;
3435
- (0, import_react25.useEffect)(() => {
3555
+ (0, import_react24.useEffect)(() => {
3436
3556
  if (!props.open) {
3437
3557
  setSrc(null);
3438
3558
  setError(null);
@@ -3460,7 +3580,7 @@ function AddCardDialog(props) {
3460
3580
  live = false;
3461
3581
  };
3462
3582
  }, [props.open, account]);
3463
- (0, import_react25.useEffect)(() => {
3583
+ (0, import_react24.useEffect)(() => {
3464
3584
  if (!src) return;
3465
3585
  const frameOrigin = (() => {
3466
3586
  try {
@@ -3522,7 +3642,7 @@ function PaymentMethodsPanel(props) {
3522
3642
  const resource = useSavedCards();
3523
3643
  const { submitting, error, run } = useAction();
3524
3644
  const confirm = useConfirm();
3525
- const [adding, setAdding] = (0, import_react26.useState)(false);
3645
+ const [adding, setAdding] = (0, import_react25.useState)(false);
3526
3646
  const variant = props.variant ?? "rows";
3527
3647
  const rowsVariant = variant === "rows";
3528
3648
  const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
@@ -3637,7 +3757,7 @@ function PaymentMethodsPanel(props) {
3637
3757
  }
3638
3758
 
3639
3759
  // src/react/components/account/OrdersPanel.tsx
3640
- var import_react27 = require("react");
3760
+ var import_react26 = require("react");
3641
3761
 
3642
3762
  // src/react/components/format.ts
3643
3763
  function formatMoney(minorUnits, currency, locale) {
@@ -3743,17 +3863,25 @@ function OrderTimeline(props) {
3743
3863
  var import_jsx_runtime39 = require("react/jsx-runtime");
3744
3864
  var CAN_PAY = /* @__PURE__ */ new Set(["draft", "pending"]);
3745
3865
  var CAN_REORDER = /* @__PURE__ */ new Set(["fulfilled", "cancelled", "closed"]);
3866
+ var CAN_CANCEL = /* @__PURE__ */ new Set(["draft", "pending", "processing"]);
3867
+ var SETTLED_PAYMENT = /* @__PURE__ */ new Set(["captured", "paid", "partially_refunded", "refunded"]);
3868
+ var CAN_RETURN = /* @__PURE__ */ new Set(["fulfilled", "partially_fulfilled", "closed"]);
3746
3869
  function Line(props) {
3747
3870
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-row", children: [
3748
3871
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-muted", children: props.label }),
3749
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: props.value })
3872
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: props.strong ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("strong", { children: props.value }) : props.value })
3750
3873
  ] });
3751
3874
  }
3752
3875
  function OrderDetail(props) {
3753
3876
  const a = useAppearance(props.appearance);
3754
3877
  const scoped = useAppearanceProviderValue(props.appearance);
3755
3878
  const { t, locale } = useCopy(props.localization);
3879
+ const { account } = useAuth();
3756
3880
  const resource = useOrder(props.orderId);
3881
+ const { submitting, error, run } = useAction();
3882
+ const confirm = useConfirm();
3883
+ const allowCancel = props.allowCancel ?? true;
3884
+ const allowReturn = props.allowReturn ?? true;
3757
3885
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.root", "throttle-panel"), children: [
3758
3886
  props.onBack ? (
3759
3887
  // Wrapped on purpose. The panel is a column flex container, so a
@@ -3764,6 +3892,7 @@ function OrderDetail(props) {
3764
3892
  // those outrank the merchant overrides in `appearance.elements`.
3765
3893
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Button, { variant: "link", elementKey: "orderDetail.backButton", onClick: props.onBack, children: t.common.back }) })
3766
3894
  ) : null,
3895
+ error ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Alert, { tone: "error", children: error }) : null,
3767
3896
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3768
3897
  PanelState,
3769
3898
  {
@@ -3771,107 +3900,183 @@ function OrderDetail(props) {
3771
3900
  isEmpty: (o) => o === null,
3772
3901
  emptyTitle: t.orders.empty,
3773
3902
  skeletonRows: 5,
3774
- children: (order) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
3775
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-row", children: [
3776
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h3", { children: order.orderNumber }),
3777
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(OrderStatus, { status: order.status, paymentStatus: order.paymentStatus, t })
3778
- ] }),
3779
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "throttle-muted", children: formatDate(order.createdAt, locale) }),
3780
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { ...a.el("orderDetail.lineItems", "throttle-stack"), children: order.lineItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.lineItem", "throttle-lineitem"), children: [
3781
- item.imageUrl ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("img", { className: "throttle-lineitem__image", src: item.imageUrl, alt: "" }) : null,
3782
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { style: { flex: 1 }, children: [
3783
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("strong", { children: item.name }),
3784
- item.description ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "throttle-muted", children: item.description }) : null,
3785
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("p", { className: "throttle-muted", children: [
3786
- t.orders.quantity,
3787
- " ",
3788
- item.quantity,
3789
- " \xD7 ",
3790
- formatMoney(item.unitPrice, order.currency, locale)
3791
- ] })
3792
- ] }),
3793
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: formatMoney(item.total, order.currency, locale) })
3794
- ] }, item.id)) }),
3795
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.totals", "throttle-totals"), children: [
3796
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.subtotal, value: formatMoney(order.subtotal, order.currency, locale) }),
3797
- order.discountTotal ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.discount, value: formatMoney(-order.discountTotal, order.currency, locale) }) : null,
3798
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.shipping, value: formatMoney(order.shippingTotal, order.currency, locale) }),
3799
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.tax, value: formatMoney(order.taxTotal, order.currency, locale) }),
3800
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.total, value: formatMoney(order.total, order.currency, locale) })
3801
- ] }),
3802
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.addresses", "throttle-addresses"), children: [
3803
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3804
- AddressBlock,
3805
- {
3806
- heading: t.orders.shipTo,
3807
- address: order.shippingAddress,
3808
- elementKey: "orderDetail.shippingAddress"
3809
- }
3810
- ),
3811
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3812
- AddressBlock,
3813
- {
3814
- heading: t.orders.billTo,
3815
- address: order.billingAddress,
3816
- elementKey: "orderDetail.billingAddress"
3817
- }
3818
- )
3819
- ] }),
3820
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3821
- OrderTimeline,
3822
- {
3823
- heading: t.orders.history,
3824
- locale,
3825
- entries: orderTimeline(order, {
3826
- placed: t.orders.placed,
3827
- completed: t.orders.completed,
3828
- cancelled: t.orders.cancelledAt,
3829
- closed: t.orders.closedAt
3830
- })
3831
- }
3832
- ),
3833
- (() => {
3834
- const target = {
3835
- id: order.id,
3836
- orderNumber: order.orderNumber,
3837
- currency: order.currency,
3838
- lineItems: order.lineItems.map((li) => ({
3839
- name: li.name,
3840
- unitPrice: li.unitPrice,
3841
- quantity: li.quantity
3842
- }))
3843
- };
3844
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-actions", children: [
3845
- props.onPayNow && CAN_PAY.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3846
- Button,
3847
- {
3848
- elementKey: "orderDetail.payButton",
3849
- onClick: () => props.onPayNow(target),
3850
- children: t.orders.payNow
3851
- }
3852
- ) : null,
3853
- props.onTrackShipment && order.status === "partially_fulfilled" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3854
- Button,
3855
- {
3856
- variant: "secondary",
3857
- elementKey: "orderDetail.trackButton",
3858
- onClick: () => props.onTrackShipment(target),
3859
- children: t.orders.track
3860
- }
3861
- ) : null,
3862
- props.onReorder && CAN_REORDER.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3863
- Button,
3903
+ children: (order) => {
3904
+ const target = {
3905
+ id: order.id,
3906
+ orderNumber: order.orderNumber,
3907
+ currency: order.currency,
3908
+ lineItems: order.lineItems.map((li) => ({
3909
+ name: li.name,
3910
+ unitPrice: li.unitPrice,
3911
+ quantity: li.quantity
3912
+ }))
3913
+ };
3914
+ const money = (v) => formatMoney(v, order.currency, locale);
3915
+ const paid = SETTLED_PAYMENT.has(order.paymentStatus);
3916
+ const showCancel = allowCancel && CAN_CANCEL.has(order.status) && !paid;
3917
+ const showReturn = allowReturn && CAN_RETURN.has(order.status);
3918
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.layout", "throttle-detail"), children: [
3919
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.main", "throttle-detail__main"), children: [
3920
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-detail__section", children: [
3921
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-row", children: [
3922
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h3", { children: order.orderNumber }),
3923
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(OrderStatus, { status: order.status, paymentStatus: order.paymentStatus, t })
3924
+ ] }),
3925
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "throttle-muted", children: formatDate(order.createdAt, locale) })
3926
+ ] }),
3927
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-detail__section", children: [
3928
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-detail__label", children: t.orders.items }),
3929
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { ...a.el("orderDetail.lineItems", "throttle-stack"), children: order.lineItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.lineItem", "throttle-lineitem"), children: [
3930
+ item.imageUrl ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("img", { className: "throttle-lineitem__image", src: item.imageUrl, alt: "" }) : null,
3931
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { style: { flex: 1 }, children: [
3932
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("strong", { children: item.name }),
3933
+ item.description ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "throttle-lineitem__desc", children: item.description }) : null,
3934
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("p", { className: "throttle-lineitem__meta", children: [
3935
+ t.orders.quantity,
3936
+ " ",
3937
+ item.quantity,
3938
+ " \xD7 ",
3939
+ money(item.unitPrice)
3940
+ ] })
3941
+ ] }),
3942
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: money(item.total) })
3943
+ ] }, item.id)) })
3944
+ ] }),
3945
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3946
+ OrderTimeline,
3864
3947
  {
3865
- variant: "secondary",
3866
- elementKey: "orderDetail.reorderButton",
3867
- onClick: () => props.onReorder(target),
3868
- children: t.orders.reorder
3948
+ heading: t.orders.history,
3949
+ locale,
3950
+ entries: orderTimeline(order, {
3951
+ placed: t.orders.placed,
3952
+ completed: t.orders.completed,
3953
+ cancelled: t.orders.cancelledAt,
3954
+ closed: t.orders.closedAt
3955
+ })
3869
3956
  }
3870
- ) : null,
3871
- order.subscriptionId && props.onViewSubscription ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Button, { variant: "secondary", onClick: () => props.onViewSubscription(order.subscriptionId), children: t.orders.viewSubscription }) : null
3872
- ] });
3873
- })()
3874
- ] })
3957
+ ),
3958
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.addresses", "throttle-addresses"), children: [
3959
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3960
+ AddressBlock,
3961
+ {
3962
+ heading: t.orders.shipTo,
3963
+ address: order.shippingAddress,
3964
+ elementKey: "orderDetail.shippingAddress"
3965
+ }
3966
+ ),
3967
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3968
+ AddressBlock,
3969
+ {
3970
+ heading: t.orders.billTo,
3971
+ address: order.billingAddress,
3972
+ elementKey: "orderDetail.billingAddress"
3973
+ }
3974
+ )
3975
+ ] })
3976
+ ] }),
3977
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("aside", { ...a.el("orderDetail.rail", "throttle-detail__rail"), children: [
3978
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-detail__section", children: [
3979
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-detail__label", children: t.orders.total }),
3980
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-detail__headline", children: money(order.total) })
3981
+ ] }),
3982
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.totals", "throttle-totals"), children: [
3983
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.subtotal, value: money(order.subtotal) }),
3984
+ order.discountTotal ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.discount, value: money(-order.discountTotal) }) : null,
3985
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.shipping, value: money(order.shippingTotal) }),
3986
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.tax, value: money(order.taxTotal) })
3987
+ ] }),
3988
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.actions", "throttle-detail__actions"), children: [
3989
+ props.onPayNow && CAN_PAY.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Button, { elementKey: "orderDetail.payButton", onClick: () => props.onPayNow(target), children: t.orders.payNow }) : null,
3990
+ order.invoiceId ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3991
+ Button,
3992
+ {
3993
+ variant: "secondary",
3994
+ loading: submitting,
3995
+ elementKey: "orderDetail.invoiceButton",
3996
+ onClick: () => void run(async () => {
3997
+ const { url } = await account.getInvoicePdfUrl(order.invoiceId);
3998
+ const opened = window.open(url, "_blank", "noopener,noreferrer");
3999
+ if (!opened) window.location.assign(url);
4000
+ }),
4001
+ children: t.orders.downloadInvoice
4002
+ }
4003
+ ) : null,
4004
+ props.onTrackShipment && order.status === "partially_fulfilled" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4005
+ Button,
4006
+ {
4007
+ variant: "secondary",
4008
+ elementKey: "orderDetail.trackButton",
4009
+ onClick: () => props.onTrackShipment(target),
4010
+ children: t.orders.track
4011
+ }
4012
+ ) : null,
4013
+ props.onReorder && CAN_REORDER.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4014
+ Button,
4015
+ {
4016
+ variant: "secondary",
4017
+ elementKey: "orderDetail.reorderButton",
4018
+ onClick: () => props.onReorder(target),
4019
+ children: t.orders.reorder
4020
+ }
4021
+ ) : null,
4022
+ order.subscriptionId && props.onViewSubscription ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4023
+ Button,
4024
+ {
4025
+ variant: "secondary",
4026
+ onClick: () => props.onViewSubscription(order.subscriptionId),
4027
+ children: t.orders.viewSubscription
4028
+ }
4029
+ ) : null,
4030
+ showReturn ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4031
+ Button,
4032
+ {
4033
+ variant: "secondary",
4034
+ disabled: submitting,
4035
+ elementKey: "orderDetail.returnButton",
4036
+ onClick: () => void (async () => {
4037
+ if (!await confirm({
4038
+ title: t.orders.requestReturnConfirm,
4039
+ body: t.orders.requestReturnBody,
4040
+ confirmLabel: t.orders.requestReturnAction
4041
+ })) return;
4042
+ await run(async () => {
4043
+ await account.requestOrderReturn(order.id, {
4044
+ items: order.lineItems.map((li) => ({
4045
+ lineItemId: li.id,
4046
+ quantity: li.quantity
4047
+ }))
4048
+ });
4049
+ await resource.refetch();
4050
+ });
4051
+ })(),
4052
+ children: t.orders.requestReturn
4053
+ }
4054
+ ) : null,
4055
+ showCancel ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4056
+ Button,
4057
+ {
4058
+ variant: "danger",
4059
+ disabled: submitting,
4060
+ elementKey: "orderDetail.cancelButton",
4061
+ onClick: () => void (async () => {
4062
+ if (!await confirm({
4063
+ title: t.orders.cancelOrderConfirm,
4064
+ body: t.orders.cancelOrderBody,
4065
+ confirmLabel: t.orders.cancelOrderAction,
4066
+ tone: "danger"
4067
+ })) return;
4068
+ await run(async () => {
4069
+ await account.cancelOrder(order.id);
4070
+ await resource.refetch();
4071
+ });
4072
+ })(),
4073
+ children: t.orders.cancelOrder
4074
+ }
4075
+ ) : null
4076
+ ] })
4077
+ ] })
4078
+ ] });
4079
+ }
3875
4080
  }
3876
4081
  )
3877
4082
  ] }) }) });
@@ -3885,7 +4090,10 @@ function OrdersPanel(props) {
3885
4090
  const { t, locale } = useCopy(props.localization);
3886
4091
  const { emailVerified } = useAuth();
3887
4092
  const resource = useOrders();
3888
- const [openId, setOpenId] = (0, import_react27.useState)(null);
4093
+ const [openId, setOpenId] = (0, import_react26.useState)(props.initialOpenId ?? null);
4094
+ (0, import_react26.useEffect)(() => {
4095
+ if (props.initialOpenId) setOpenId(props.initialOpenId);
4096
+ }, [props.initialOpenId]);
3889
4097
  const variant = props.variant ?? "table";
3890
4098
  const rowsVariant = variant === "rows";
3891
4099
  const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
@@ -3900,6 +4108,8 @@ function OrdersPanel(props) {
3900
4108
  onReorder: props.onReorder,
3901
4109
  onTrackShipment: props.onTrackShipment,
3902
4110
  onViewSubscription: props.onViewSubscription,
4111
+ allowCancel: props.allowCancel,
4112
+ allowReturn: props.allowReturn,
3903
4113
  appearance: props.appearance,
3904
4114
  localization: props.localization
3905
4115
  }
@@ -3961,10 +4171,11 @@ function OrdersPanel(props) {
3961
4171
  }
3962
4172
 
3963
4173
  // src/react/components/account/InvoicesPanel.tsx
3964
- var import_react28 = require("react");
4174
+ var import_react27 = require("react");
3965
4175
 
3966
4176
  // src/react/components/account/InvoiceDetail.tsx
3967
4177
  var import_jsx_runtime41 = require("react/jsx-runtime");
4178
+ var PAYABLE = /* @__PURE__ */ new Set(["open"]);
3968
4179
  function Line2(props) {
3969
4180
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-row", children: [
3970
4181
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-muted", children: props.label }),
@@ -3980,54 +4191,111 @@ function InvoiceDetail(props) {
3980
4191
  const { submitting, error, run } = useAction();
3981
4192
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.root", "throttle-panel"), children: [
3982
4193
  props.onBack ? (
3983
- // Wrapped on purpose. The panel is a column flex container, so a
3984
- // direct child stretches to its full width however `width: auto`
3985
- // the link variant is — the control rendered 748px wide with a
3986
- // centred label. The wrapper takes the stretch; the button keeps
3987
- // its own width. A CSS fix would need a compound selector, and
3988
- // those outrank the merchant overrides in `appearance.elements`.
4194
+ // Wrapped on purpose — see OrderDetail's back button for why a
4195
+ // direct flex child stretched to 748px.
3989
4196
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Button, { variant: "link", elementKey: "invoiceDetail.backButton", onClick: props.onBack, children: t.common.back }) })
3990
4197
  ) : null,
3991
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelState, { resource, isEmpty: (i) => i === null, emptyTitle: t.invoices.empty, skeletonRows: 4, children: (invoice) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
3992
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-row", children: [
3993
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { children: invoice.number }),
3994
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(StatusBadge, { status: invoice.status, labels: t.invoices.statusLabels })
3995
- ] }),
3996
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.totals", "throttle-totals"), children: [
3997
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.issued, value: formatDate(invoice.issuedAt, locale) }),
3998
- invoice.dueAt ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.due, value: formatDate(invoice.dueAt, locale) }) : null,
3999
- invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4000
- Line2,
4001
- {
4002
- label: t.invoices.period,
4003
- value: `${formatDate(invoice.periodStart, locale)} \u2013 ${formatDate(invoice.periodEnd, locale)}`
4004
- }
4005
- ) : null,
4006
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.total, value: formatMoney(invoice.total, invoice.currency, locale) }),
4007
- invoice.amountRefunded ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4008
- Line2,
4009
- {
4010
- label: t.invoices.refunded,
4011
- value: formatMoney(invoice.amountRefunded, invoice.currency, locale)
4012
- }
4013
- ) : null
4014
- ] }),
4015
- error ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Alert, { tone: "error", children: error }) : null,
4016
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4017
- Button,
4018
- {
4019
- variant: "secondary",
4020
- loading: submitting,
4021
- elementKey: "invoiceDetail.downloadButton",
4022
- onClick: () => void run(async () => {
4023
- const { url } = await account.getInvoicePdfUrl(invoice.id);
4024
- const opened = window.open(url, "_blank", "noopener,noreferrer");
4025
- if (!opened) window.location.assign(url);
4026
- }),
4027
- children: t.invoices.downloadButton
4028
- }
4029
- )
4030
- ] }) })
4198
+ error ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Alert, { tone: "error", children: error }) : null,
4199
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelState, { resource, isEmpty: (i) => i === null, emptyTitle: t.invoices.empty, skeletonRows: 4, children: (invoice) => {
4200
+ const money = (v) => formatMoney(v, invoice.currency, locale);
4201
+ const lines = invoice.lineItems ?? [];
4202
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.layout", "throttle-detail"), children: [
4203
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.main", "throttle-detail__main"), children: [
4204
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-detail__section", children: [
4205
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-row", children: [
4206
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { children: invoice.number }),
4207
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(StatusBadge, { status: invoice.status, labels: t.invoices.statusLabels })
4208
+ ] }),
4209
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("p", { className: "throttle-muted", children: [
4210
+ t.invoices.issued,
4211
+ " ",
4212
+ formatDate(invoice.issuedAt, locale)
4213
+ ] })
4214
+ ] }),
4215
+ lines.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-detail__section", children: [
4216
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__label", children: t.invoices.items }),
4217
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { ...a.el("invoiceDetail.lineItems", "throttle-stack"), children: lines.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.lineItem", "throttle-lineitem"), children: [
4218
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { style: { flex: 1 }, children: [
4219
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("strong", { children: item.name }),
4220
+ item.description ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "throttle-lineitem__desc", children: item.description }) : null,
4221
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("p", { className: "throttle-lineitem__meta", children: [
4222
+ t.orders.quantity,
4223
+ " ",
4224
+ item.quantity,
4225
+ " \xD7 ",
4226
+ money(item.unitPrice)
4227
+ ] })
4228
+ ] }),
4229
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: money(item.total) })
4230
+ ] }, i)) })
4231
+ ] }) : null
4232
+ ] }),
4233
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("aside", { ...a.el("invoiceDetail.rail", "throttle-detail__rail"), children: [
4234
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-detail__section", children: [
4235
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__label", children: t.invoices.total }),
4236
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__headline", children: money(invoice.total) })
4237
+ ] }),
4238
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.totals", "throttle-totals"), children: [
4239
+ invoice.dueAt ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.due, value: formatDate(invoice.dueAt, locale) }) : null,
4240
+ invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4241
+ Line2,
4242
+ {
4243
+ label: t.invoices.period,
4244
+ value: `${formatDate(invoice.periodStart, locale)} \u2013 ${formatDate(invoice.periodEnd, locale)}`
4245
+ }
4246
+ ) : null,
4247
+ invoice.amountRefunded ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.refunded, value: money(invoice.amountRefunded) }) : null
4248
+ ] }),
4249
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.actions", "throttle-detail__actions"), children: [
4250
+ props.onPay && PAYABLE.has(invoice.status) ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4251
+ Button,
4252
+ {
4253
+ elementKey: "invoiceDetail.payButton",
4254
+ onClick: () => props.onPay({
4255
+ id: invoice.id,
4256
+ number: invoice.number,
4257
+ total: invoice.total,
4258
+ currency: invoice.currency
4259
+ }),
4260
+ children: t.invoices.payButton
4261
+ }
4262
+ ) : null,
4263
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4264
+ Button,
4265
+ {
4266
+ variant: "secondary",
4267
+ loading: submitting,
4268
+ elementKey: "invoiceDetail.downloadButton",
4269
+ onClick: () => void run(async () => {
4270
+ const { url } = await account.getInvoicePdfUrl(invoice.id);
4271
+ const opened = window.open(url, "_blank", "noopener,noreferrer");
4272
+ if (!opened) window.location.assign(url);
4273
+ }),
4274
+ children: t.invoices.downloadButton
4275
+ }
4276
+ ),
4277
+ invoice.orderId && props.onViewOrder ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4278
+ Button,
4279
+ {
4280
+ variant: "secondary",
4281
+ elementKey: "invoiceDetail.orderLink",
4282
+ onClick: () => props.onViewOrder(invoice.orderId),
4283
+ children: invoice.orderNumber ? `${t.invoices.viewOrder} ${invoice.orderNumber}` : t.invoices.viewOrder
4284
+ }
4285
+ ) : null,
4286
+ invoice.subscriptionId && props.onViewSubscription ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4287
+ Button,
4288
+ {
4289
+ variant: "secondary",
4290
+ elementKey: "invoiceDetail.subscriptionLink",
4291
+ onClick: () => props.onViewSubscription(invoice.subscriptionId),
4292
+ children: t.invoices.viewSubscription
4293
+ }
4294
+ ) : null
4295
+ ] })
4296
+ ] })
4297
+ ] });
4298
+ } })
4031
4299
  ] }) }) });
4032
4300
  }
4033
4301
 
@@ -4039,7 +4307,10 @@ function InvoicesPanel(props) {
4039
4307
  const { t, locale } = useCopy(props.localization);
4040
4308
  const { emailVerified } = useAuth();
4041
4309
  const resource = useInvoices();
4042
- const [openId, setOpenId] = (0, import_react28.useState)(null);
4310
+ const [openId, setOpenId] = (0, import_react27.useState)(props.initialOpenId ?? null);
4311
+ (0, import_react27.useEffect)(() => {
4312
+ if (props.initialOpenId) setOpenId(props.initialOpenId);
4313
+ }, [props.initialOpenId]);
4043
4314
  const variant = props.variant ?? "table";
4044
4315
  const rowsVariant = variant === "rows";
4045
4316
  const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
@@ -4050,6 +4321,9 @@ function InvoicesPanel(props) {
4050
4321
  {
4051
4322
  invoiceId: openId,
4052
4323
  onBack: () => setOpenId(null),
4324
+ onViewOrder: props.onViewOrder,
4325
+ onViewSubscription: props.onViewSubscription,
4326
+ onPay: props.onPay,
4053
4327
  appearance: props.appearance,
4054
4328
  localization: props.localization
4055
4329
  }
@@ -4110,7 +4384,7 @@ function InvoicesPanel(props) {
4110
4384
  var import_jsx_runtime43 = require("react/jsx-runtime");
4111
4385
  var CAN_PAUSE = /* @__PURE__ */ new Set(["active", "trialing"]);
4112
4386
  var CAN_RESUME = /* @__PURE__ */ new Set(["paused"]);
4113
- var CAN_CANCEL = /* @__PURE__ */ new Set(["active", "trialing", "paused", "past_due", "unpaid"]);
4387
+ var CAN_CANCEL2 = /* @__PURE__ */ new Set(["active", "trialing", "paused", "past_due", "unpaid"]);
4114
4388
  function SubscriptionsPanel(props) {
4115
4389
  const a = useAppearance(props.appearance);
4116
4390
  const scoped = useAppearanceProviderValue(props.appearance);
@@ -4123,7 +4397,7 @@ function SubscriptionsPanel(props) {
4123
4397
  const rowsVariant = variant === "rows";
4124
4398
  const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
4125
4399
  const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
4126
- const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
4400
+ const actionVariant = (base) => base;
4127
4401
  const confirmThen = (fn, ask) => () => {
4128
4402
  void (async () => {
4129
4403
  if (!await confirm({ ...ask, tone: ask.tone ?? "neutral" })) return;
@@ -4159,7 +4433,7 @@ function SubscriptionsPanel(props) {
4159
4433
  children: t.subscriptions.resumeButton
4160
4434
  }
4161
4435
  ) : null,
4162
- CAN_CANCEL.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4436
+ CAN_CANCEL2.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4163
4437
  Button,
4164
4438
  {
4165
4439
  variant: variantFor("secondary"),
@@ -4173,7 +4447,7 @@ function SubscriptionsPanel(props) {
4173
4447
  children: t.subscriptions.cancelAtPeriodEnd
4174
4448
  }
4175
4449
  ) : null,
4176
- CAN_CANCEL.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4450
+ CAN_CANCEL2.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4177
4451
  Button,
4178
4452
  {
4179
4453
  variant: variantFor("danger"),
@@ -4253,7 +4527,7 @@ function SubscriptionsPanel(props) {
4253
4527
  }
4254
4528
 
4255
4529
  // src/react/components/account/SecurityPanel.tsx
4256
- var import_react29 = require("react");
4530
+ var import_react28 = require("react");
4257
4531
 
4258
4532
  // src/react/components/account/device.ts
4259
4533
  var BROWSERS = [
@@ -4296,16 +4570,16 @@ function SecurityPanel(props) {
4296
4570
  const rowsVariant = variant === "rows";
4297
4571
  const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
4298
4572
  const revokeVariant = rowsVariant ? "linkDanger" : "danger";
4299
- const [password, setPassword] = (0, import_react29.useState)("");
4573
+ const [password, setPassword] = (0, import_react28.useState)("");
4300
4574
  const passwordAction = useAction();
4301
4575
  const sessionAction = useAction();
4302
- const [sessions, setSessions] = (0, import_react29.useState)(null);
4303
- const [listError, setListError] = (0, import_react29.useState)(null);
4304
- const errorMessageRef = (0, import_react29.useRef)(errorMessage);
4305
- (0, import_react29.useEffect)(() => {
4576
+ const [sessions, setSessions] = (0, import_react28.useState)(null);
4577
+ const [listError, setListError] = (0, import_react28.useState)(null);
4578
+ const errorMessageRef = (0, import_react28.useRef)(errorMessage);
4579
+ (0, import_react28.useEffect)(() => {
4306
4580
  errorMessageRef.current = errorMessage;
4307
4581
  });
4308
- const load = (0, import_react29.useCallback)(async () => {
4582
+ const load = (0, import_react28.useCallback)(async () => {
4309
4583
  try {
4310
4584
  setSessions(await auth.listSessions());
4311
4585
  setListError(null);
@@ -4313,7 +4587,7 @@ function SecurityPanel(props) {
4313
4587
  setListError(errorMessageRef.current(err));
4314
4588
  }
4315
4589
  }, [auth]);
4316
- (0, import_react29.useEffect)(() => {
4590
+ (0, import_react28.useEffect)(() => {
4317
4591
  void load();
4318
4592
  }, [load]);
4319
4593
  const others = (sessions ?? []).filter((s) => !s.current);
@@ -4461,9 +4735,10 @@ function AccountDashboard(props) {
4461
4735
  const { status } = useAuth();
4462
4736
  const shown = props.tabs ?? [...ACCOUNT_TABS];
4463
4737
  const controlled = props.tab !== void 0;
4464
- const [internal, setInternal] = (0, import_react30.useState)(shown[0] ?? "profile");
4465
- const idBase = (0, import_react30.useId)();
4466
- (0, import_react30.useEffect)(() => {
4738
+ const [internal, setInternal] = (0, import_react29.useState)(shown[0] ?? "profile");
4739
+ const [openOrderId, setOpenOrderId] = (0, import_react29.useState)(null);
4740
+ const idBase = (0, import_react29.useId)();
4741
+ (0, import_react29.useEffect)(() => {
4467
4742
  if (props.routing !== "hash" || typeof window === "undefined") return;
4468
4743
  const apply = () => {
4469
4744
  const next = TAB_FOR_HASH[window.location.hash] ?? shown[0];
@@ -4517,13 +4792,25 @@ function AccountDashboard(props) {
4517
4792
  {
4518
4793
  ...shared,
4519
4794
  variant: props.panelVariant,
4795
+ initialOpenId: openOrderId,
4520
4796
  onViewSubscription: () => go("subscriptions"),
4521
4797
  onPayNow: props.onPayNow,
4522
4798
  onReorder: props.onReorder,
4523
4799
  onTrackShipment: props.onTrackShipment
4524
4800
  }
4525
4801
  ) : null,
4526
- active === "invoices" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(InvoicesPanel, { ...shared, variant: props.panelVariant }) : null,
4802
+ active === "invoices" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4803
+ InvoicesPanel,
4804
+ {
4805
+ ...shared,
4806
+ variant: props.panelVariant,
4807
+ onViewOrder: (orderId) => {
4808
+ setOpenOrderId(orderId);
4809
+ go("orders");
4810
+ },
4811
+ onViewSubscription: () => go("subscriptions")
4812
+ }
4813
+ ) : null,
4527
4814
  active === "subscriptions" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SubscriptionsPanel, { ...shared, variant: props.panelVariant }) : null,
4528
4815
  active === "security" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SecurityPanel, { ...shared, variant: props.panelVariant }) : null
4529
4816
  ]
@@ -4547,7 +4834,7 @@ function AccountModal(props) {
4547
4834
  const a = useAppearance(props.appearance);
4548
4835
  const scoped = useAppearanceProviderValue(props.appearance);
4549
4836
  const { t } = useCopy(props.localization);
4550
- const titleId = (0, import_react31.useId)();
4837
+ const titleId = (0, import_react30.useId)();
4551
4838
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
4552
4839
  Modal,
4553
4840
  {
@@ -4574,9 +4861,9 @@ function warnOnce(key, message) {
4574
4861
  warned.add(key);
4575
4862
  console.warn(`[@usethrottle/auth] ${message}`);
4576
4863
  }
4577
- var ThrottleUIContext = (0, import_react32.createContext)(null);
4864
+ var ThrottleUIContext = (0, import_react31.createContext)(null);
4578
4865
  function useThrottle() {
4579
- const ctx = (0, import_react32.useContext)(ThrottleUIContext);
4866
+ const ctx = (0, import_react31.useContext)(ThrottleUIContext);
4580
4867
  if (!ctx) {
4581
4868
  warnOnce(
4582
4869
  "use-throttle-no-provider",
@@ -4611,51 +4898,51 @@ function ThrottleProvider(props) {
4611
4898
  __captureStepUp
4612
4899
  } = props;
4613
4900
  useInjectStyles(injectStyles);
4614
- const [stepUpOpen, setStepUpOpen] = (0, import_react32.useState)(false);
4615
- const resolveStepUp = (0, import_react32.useRef)(null);
4616
- const claimRef = (0, import_react32.useRef)(claimCartOnSignIn);
4901
+ const [stepUpOpen, setStepUpOpen] = (0, import_react31.useState)(false);
4902
+ const resolveStepUp = (0, import_react31.useRef)(null);
4903
+ const claimRef = (0, import_react31.useRef)(claimCartOnSignIn);
4617
4904
  claimRef.current = claimCartOnSignIn;
4618
- const [overlay, setOverlay] = (0, import_react32.useState)(null);
4619
- const overlayRestoreFocus = (0, import_react32.useRef)(null);
4620
- const [accountTabs, setAccountTabs] = (0, import_react32.useState)(void 0);
4621
- const onOverlaySuccess = (0, import_react32.useRef)(null);
4622
- const openSignIn = (0, import_react32.useCallback)((onSuccess) => {
4905
+ const [overlay, setOverlay] = (0, import_react31.useState)(null);
4906
+ const overlayRestoreFocus = (0, import_react31.useRef)(null);
4907
+ const [accountTabs, setAccountTabs] = (0, import_react31.useState)(void 0);
4908
+ const onOverlaySuccess = (0, import_react31.useRef)(null);
4909
+ const openSignIn = (0, import_react31.useCallback)((onSuccess) => {
4623
4910
  onOverlaySuccess.current = onSuccess ?? null;
4624
4911
  setOverlay("signIn");
4625
4912
  }, []);
4626
- const openSignUp = (0, import_react32.useCallback)((onSuccess) => {
4913
+ const openSignUp = (0, import_react31.useCallback)((onSuccess) => {
4627
4914
  onOverlaySuccess.current = onSuccess ?? null;
4628
4915
  setOverlay("signUp");
4629
4916
  }, []);
4630
- const openAccount = (0, import_react32.useCallback)((opts) => {
4917
+ const openAccount = (0, import_react31.useCallback)((opts) => {
4631
4918
  onOverlaySuccess.current = null;
4632
4919
  overlayRestoreFocus.current = opts?.restoreFocusTo ?? null;
4633
4920
  setAccountTabs(opts?.tabs);
4634
4921
  setOverlay("account");
4635
4922
  }, []);
4636
- const closeOverlay = (0, import_react32.useCallback)(() => {
4923
+ const closeOverlay = (0, import_react31.useCallback)(() => {
4637
4924
  onOverlaySuccess.current = null;
4638
4925
  overlayRestoreFocus.current = null;
4639
4926
  setOverlay(null);
4640
4927
  }, []);
4641
- const handleOverlaySuccess = (0, import_react32.useCallback)(() => {
4928
+ const handleOverlaySuccess = (0, import_react31.useCallback)(() => {
4642
4929
  const fn = onOverlaySuccess.current;
4643
4930
  onOverlaySuccess.current = null;
4644
4931
  setOverlay(null);
4645
4932
  fn?.();
4646
4933
  }, []);
4647
- const ui = (0, import_react32.useMemo)(
4934
+ const ui = (0, import_react31.useMemo)(
4648
4935
  () => ({ overlay, openSignIn, openSignUp, openAccount, close: closeOverlay }),
4649
4936
  [overlay, openSignIn, openSignUp, openAccount, closeOverlay]
4650
4937
  );
4651
- const askForStepUp = (0, import_react32.useCallback)(
4938
+ const askForStepUp = (0, import_react31.useCallback)(
4652
4939
  () => new Promise((resolve) => {
4653
4940
  resolveStepUp.current = resolve;
4654
4941
  setStepUpOpen(true);
4655
4942
  }),
4656
4943
  []
4657
4944
  );
4658
- const auth = (0, import_react32.useMemo)(() => {
4945
+ const auth = (0, import_react31.useMemo)(() => {
4659
4946
  __captureStepUp?.(askForStepUp);
4660
4947
  const client = injected ?? createThrottleAuth({ publishableKey, baseUrl, storage, onStepUpRequired: askForStepUp });
4661
4948
  const account = createAccount(client);
@@ -4688,9 +4975,8 @@ function ThrottleProvider(props) {
4688
4975
  resolve?.(password);
4689
4976
  };
4690
4977
  const authOverlayOpen = overlay === "signIn" || overlay === "signUp";
4691
- return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(AppearanceProvider, { value: appearance ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(LocalizationProvider, { value: localization ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(BrandLogoProvider, { value: logo ?? null, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ThrottleAuthProvider, { auth, publishableKey, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ConfirmProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(ThrottleUIContext.Provider, { value: ui, children: [
4978
+ return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(AppearanceProvider, { value: appearance ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(LocalizationProvider, { value: localization ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(BrandLogoProvider, { value: logo ?? null, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ThrottleAuthProvider, { auth, publishableKey, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ConfirmProvider, { stepUpOpen, onStepUpResolve: finishStepUp, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(ThrottleUIContext.Provider, { value: ui, children: [
4692
4979
  children,
4693
- /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(StepUpDialog, { open: stepUpOpen, onResolve: finishStepUp }),
4694
4980
  /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
4695
4981
  AuthModal,
4696
4982
  {
@@ -4706,9 +4992,13 @@ function ThrottleProvider(props) {
4706
4992
  ] }) }) }) }) }) });
4707
4993
  }
4708
4994
 
4995
+ // src/react/components/auth/StepUpDialog.tsx
4996
+ var import_react32 = require("react");
4997
+ var import_jsx_runtime48 = require("react/jsx-runtime");
4998
+
4709
4999
  // src/react/components/auth/SignInButton.tsx
4710
5000
  var import_react33 = require("react");
4711
- var import_jsx_runtime48 = require("react/jsx-runtime");
5001
+ var import_jsx_runtime49 = require("react/jsx-runtime");
4712
5002
  function SignInButton(props) {
4713
5003
  const a = useAppearance(props.appearance);
4714
5004
  const scoped = useAppearanceProviderValue(props.appearance);
@@ -4718,7 +5008,7 @@ function SignInButton(props) {
4718
5008
  const useShared = ui !== null && props.initialView === void 0;
4719
5009
  const label = props.children ?? t.signIn.submitButton;
4720
5010
  if (props.mode === "redirect") {
4721
- return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("a", { ...a.el("signInButton.root", "throttle-button throttle-button--primary"), href: props.url ?? "#", children: label }) }) });
5011
+ return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("a", { ...a.el("signInButton.root", "throttle-button throttle-button--primary"), href: props.url ?? "#", children: label }) }) });
4722
5012
  }
4723
5013
  const openModal = () => {
4724
5014
  if (useShared) ui.openSignIn(props.afterSignIn);
@@ -4728,10 +5018,10 @@ function SignInButton(props) {
4728
5018
  if (useShared) ui.close();
4729
5019
  else setLocalOpen(false);
4730
5020
  };
4731
- const trigger = props.asChild && (0, import_react33.isValidElement)(props.children) ? (0, import_react33.cloneElement)(props.children, { onClick: openModal }) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Button, { elementKey: "signInButton.root", onClick: openModal, children: label });
4732
- return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(AppearanceProvider, { value: scoped, children: [
4733
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { ...a.rootProps, children: trigger }),
4734
- !useShared ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5021
+ const trigger = props.asChild && (0, import_react33.isValidElement)(props.children) ? (0, import_react33.cloneElement)(props.children, { onClick: openModal }) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Button, { elementKey: "signInButton.root", onClick: openModal, children: label });
5022
+ return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(AppearanceProvider, { value: scoped, children: [
5023
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ...a.rootProps, children: trigger }),
5024
+ !useShared ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4735
5025
  AuthModal,
4736
5026
  {
4737
5027
  open: localOpen,
@@ -4750,7 +5040,7 @@ function SignInButton(props) {
4750
5040
 
4751
5041
  // src/react/components/auth/SignUpButton.tsx
4752
5042
  var import_react34 = require("react");
4753
- var import_jsx_runtime49 = require("react/jsx-runtime");
5043
+ var import_jsx_runtime50 = require("react/jsx-runtime");
4754
5044
  function SignUpButton(props) {
4755
5045
  const a = useAppearance(props.appearance);
4756
5046
  const scoped = useAppearanceProviderValue(props.appearance);
@@ -4760,7 +5050,7 @@ function SignUpButton(props) {
4760
5050
  const useShared = ui !== null && props.initialView === void 0;
4761
5051
  const label = props.children ?? t.signUp.submitButton;
4762
5052
  if (props.mode === "redirect") {
4763
- return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("a", { ...a.el("signUpButton.root", "throttle-button throttle-button--primary"), href: props.url ?? "#", children: label }) }) });
5053
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("a", { ...a.el("signUpButton.root", "throttle-button throttle-button--primary"), href: props.url ?? "#", children: label }) }) });
4764
5054
  }
4765
5055
  const openModal = () => {
4766
5056
  if (useShared) ui.openSignUp(props.afterSignUp);
@@ -4770,10 +5060,10 @@ function SignUpButton(props) {
4770
5060
  if (useShared) ui.close();
4771
5061
  else setLocalOpen(false);
4772
5062
  };
4773
- const trigger = props.asChild && (0, import_react34.isValidElement)(props.children) ? (0, import_react34.cloneElement)(props.children, { onClick: openModal }) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Button, { elementKey: "signUpButton.root", onClick: openModal, children: label });
4774
- return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(AppearanceProvider, { value: scoped, children: [
4775
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ...a.rootProps, children: trigger }),
4776
- !useShared ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5063
+ const trigger = props.asChild && (0, import_react34.isValidElement)(props.children) ? (0, import_react34.cloneElement)(props.children, { onClick: openModal }) : /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Button, { elementKey: "signUpButton.root", onClick: openModal, children: label });
5064
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(AppearanceProvider, { value: scoped, children: [
5065
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { ...a.rootProps, children: trigger }),
5066
+ !useShared ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
4777
5067
  AuthModal,
4778
5068
  {
4779
5069
  open: localOpen,
@@ -4791,14 +5081,14 @@ function SignUpButton(props) {
4791
5081
  }
4792
5082
 
4793
5083
  // src/react/components/auth/SignOutButton.tsx
4794
- var import_jsx_runtime50 = require("react/jsx-runtime");
5084
+ var import_jsx_runtime51 = require("react/jsx-runtime");
4795
5085
  function SignOutButton(props) {
4796
5086
  const a = useAppearance();
4797
5087
  const { auth } = useAuth();
4798
5088
  const { t } = useCopy(props.localization);
4799
5089
  const { submitting, run } = useAction();
4800
5090
  const label = props.children ?? (props.everywhere ? t.userButton.signOutAll : t.userButton.signOut);
4801
- return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5091
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4802
5092
  Button,
4803
5093
  {
4804
5094
  variant: "secondary",
@@ -4815,13 +5105,13 @@ function SignOutButton(props) {
4815
5105
  }
4816
5106
 
4817
5107
  // src/react/components/auth/SignInPage.tsx
4818
- var import_jsx_runtime51 = require("react/jsx-runtime");
5108
+ var import_jsx_runtime52 = require("react/jsx-runtime");
4819
5109
  function SignInPage(props) {
4820
5110
  const a = useAppearance(props.appearance);
4821
5111
  const scoped = useAppearanceProviderValue(props.appearance);
4822
- return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { ...a.el("signInPage.root", "throttle-page"), children: [
4823
- props.logo ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ...a.el("signInPage.logo", "throttle-page__logo"), children: props.logo }) : null,
4824
- /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
5112
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { ...a.el("signInPage.root", "throttle-page"), children: [
5113
+ props.logo ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...a.el("signInPage.logo", "throttle-page__logo"), children: props.logo }) : null,
5114
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
4825
5115
  SignIn,
4826
5116
  {
4827
5117
  onSuccess: props.onSuccess,
@@ -4831,18 +5121,18 @@ function SignInPage(props) {
4831
5121
  localization: props.localization
4832
5122
  }
4833
5123
  ),
4834
- props.footer ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ...a.el("signInPage.footer", "throttle-page__footer"), children: props.footer }) : null
5124
+ props.footer ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...a.el("signInPage.footer", "throttle-page__footer"), children: props.footer }) : null
4835
5125
  ] }) }) });
4836
5126
  }
4837
5127
 
4838
5128
  // src/react/components/auth/SignUpPage.tsx
4839
- var import_jsx_runtime52 = require("react/jsx-runtime");
5129
+ var import_jsx_runtime53 = require("react/jsx-runtime");
4840
5130
  function SignUpPage(props) {
4841
5131
  const a = useAppearance(props.appearance);
4842
5132
  const scoped = useAppearanceProviderValue(props.appearance);
4843
- return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { ...a.el("signUpPage.root", "throttle-page"), children: [
4844
- props.logo ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...a.el("signUpPage.logo", "throttle-page__logo"), children: props.logo }) : null,
4845
- /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
5133
+ return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { ...a.el("signUpPage.root", "throttle-page"), children: [
5134
+ props.logo ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { ...a.el("signUpPage.logo", "throttle-page__logo"), children: props.logo }) : null,
5135
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
4846
5136
  SignUp,
4847
5137
  {
4848
5138
  onSuccess: props.onSuccess,
@@ -4851,31 +5141,31 @@ function SignUpPage(props) {
4851
5141
  localization: props.localization
4852
5142
  }
4853
5143
  ),
4854
- props.footer ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...a.el("signUpPage.footer", "throttle-page__footer"), children: props.footer }) : null
5144
+ props.footer ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { ...a.el("signUpPage.footer", "throttle-page__footer"), children: props.footer }) : null
4855
5145
  ] }) }) });
4856
5146
  }
4857
5147
 
4858
5148
  // src/react/components/guards.tsx
4859
- var import_jsx_runtime53 = require("react/jsx-runtime");
5149
+ var import_jsx_runtime54 = require("react/jsx-runtime");
4860
5150
  function SignedIn(props) {
4861
5151
  const { status } = useAuth();
4862
- return status === "authenticated" ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: props.children }) : null;
5152
+ return status === "authenticated" ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_jsx_runtime54.Fragment, { children: props.children }) : null;
4863
5153
  }
4864
5154
  function SignedOut(props) {
4865
5155
  const { status } = useAuth();
4866
- return status === "unauthenticated" ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: props.children }) : null;
5156
+ return status === "unauthenticated" ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_jsx_runtime54.Fragment, { children: props.children }) : null;
4867
5157
  }
4868
5158
  function Protect(props) {
4869
5159
  const { status, emailVerified } = useAuth();
4870
5160
  if (status === "loading") return null;
4871
- if (status !== "authenticated") return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: props.fallback ?? null });
4872
- if (props.requireVerified && !emailVerified) return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: props.fallback ?? null });
4873
- return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: props.children });
5161
+ if (status !== "authenticated") return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_jsx_runtime54.Fragment, { children: props.fallback ?? null });
5162
+ if (props.requireVerified && !emailVerified) return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_jsx_runtime54.Fragment, { children: props.fallback ?? null });
5163
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_jsx_runtime54.Fragment, { children: props.children });
4874
5164
  }
4875
5165
 
4876
5166
  // src/react/components/UserButton.tsx
4877
5167
  var import_react35 = require("react");
4878
- var import_jsx_runtime54 = require("react/jsx-runtime");
5168
+ var import_jsx_runtime55 = require("react/jsx-runtime");
4879
5169
  function UserButtonRoot(props) {
4880
5170
  const a = useAppearance(props.appearance);
4881
5171
  const scoped = useAppearanceProviderValue(props.appearance);
@@ -4895,25 +5185,25 @@ function UserButtonRoot(props) {
4895
5185
  };
4896
5186
  if (status !== "authenticated" || !customer) return null;
4897
5187
  const name = [customer.firstName, customer.lastName].filter(Boolean).join(" ");
4898
- return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("span", { ref: rootRef, ...a.el("userButton.root"), children: [
4899
- /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
5188
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("span", { ref: rootRef, ...a.el("userButton.root"), children: [
5189
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
4900
5190
  Dropdown,
4901
5191
  {
4902
5192
  label: t.userButton.openMenu,
4903
5193
  triggerKey: "userButton.trigger",
4904
5194
  menuKey: "userButton.menu",
4905
- trigger: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Avatar, { name, email: customer.email }),
5195
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Avatar, { name, email: customer.email }),
4906
5196
  children: [
4907
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { ...a.el("userButton.identity", "throttle-dropdown__item"), children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("span", { children: [
4908
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { ...a.el("userButton.email"), children: customer.email }),
4909
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("br", {}),
4910
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Badge, { tone: emailVerified ? "success" : "warning", elementKey: "userButton.badge", children: emailVerified ? t.userButton.verified : t.userButton.unverified })
5197
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { ...a.el("userButton.identity", "throttle-dropdown__item"), children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("span", { children: [
5198
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { ...a.el("userButton.email"), children: customer.email }),
5199
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("br", {}),
5200
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Badge, { tone: emailVerified ? "success" : "warning", elementKey: "userButton.badge", children: emailVerified ? t.userButton.verified : t.userButton.unverified })
4911
5201
  ] }) }),
4912
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DropdownSeparator, {}),
4913
- props.mode === "navigate" ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DropdownItem, { itemKey: "userButton.manageButton", href: props.accountUrl ?? "#", children: t.userButton.manage }) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DropdownItem, { itemKey: "userButton.manageButton", onClick: openAccount, children: t.userButton.manage }),
5202
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(DropdownSeparator, {}),
5203
+ props.mode === "navigate" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(DropdownItem, { itemKey: "userButton.manageButton", href: props.accountUrl ?? "#", children: t.userButton.manage }) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(DropdownItem, { itemKey: "userButton.manageButton", onClick: openAccount, children: t.userButton.manage }),
4914
5204
  props.children,
4915
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DropdownSeparator, {}),
4916
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
5205
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(DropdownSeparator, {}),
5206
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
4917
5207
  DropdownItem,
4918
5208
  {
4919
5209
  itemKey: "userButton.signOutButton",
@@ -4921,7 +5211,7 @@ function UserButtonRoot(props) {
4921
5211
  children: t.userButton.signOut
4922
5212
  }
4923
5213
  ),
4924
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
5214
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
4925
5215
  DropdownItem,
4926
5216
  {
4927
5217
  itemKey: "userButton.signOutAllButton",
@@ -4932,7 +5222,7 @@ function UserButtonRoot(props) {
4932
5222
  ]
4933
5223
  }
4934
5224
  ),
4935
- props.mode !== "navigate" && !ui ? /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
5225
+ props.mode !== "navigate" && !ui ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
4936
5226
  Modal,
4937
5227
  {
4938
5228
  open: accountOpen,
@@ -4940,8 +5230,8 @@ function UserButtonRoot(props) {
4940
5230
  labelledBy: titleId,
4941
5231
  restoreFocusTo: openerRef.current,
4942
5232
  children: [
4943
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("h2", { id: titleId, style: { padding: "16px 16px 0", margin: 0 }, children: t.account.title }),
4944
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: { padding: 16 }, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
5233
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("h2", { id: titleId, style: { padding: "16px 16px 0", margin: 0 }, children: t.account.title }),
5234
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { style: { padding: 16 }, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
4945
5235
  AccountDashboard,
4946
5236
  {
4947
5237
  tabs: props.tabs,
@@ -4955,13 +5245,13 @@ function UserButtonRoot(props) {
4955
5245
  ] }) }) });
4956
5246
  }
4957
5247
  function UserButtonLink(props) {
4958
- return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(DropdownItem, { itemKey: "userButton.item", href: props.href, children: [
5248
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(DropdownItem, { itemKey: "userButton.item", href: props.href, children: [
4959
5249
  props.icon,
4960
5250
  props.label
4961
5251
  ] });
4962
5252
  }
4963
5253
  function UserButtonAction(props) {
4964
- return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(DropdownItem, { itemKey: "userButton.item", onClick: props.onClick, children: [
5254
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(DropdownItem, { itemKey: "userButton.item", onClick: props.onClick, children: [
4965
5255
  props.icon,
4966
5256
  props.label
4967
5257
  ] });