@schematichq/schematic-components 1.1.0 → 1.1.2
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.
- package/dist/schematic-components.cjs.js +314 -240
- package/dist/schematic-components.d.ts +164 -3
- package/dist/schematic-components.esm.js +184 -110
- package/package.json +3 -3
|
@@ -1900,15 +1900,21 @@ __export(index_exports, {
|
|
|
1900
1900
|
module.exports = __toCommonJS(index_exports);
|
|
1901
1901
|
|
|
1902
1902
|
// src/components/elements/button/Button.tsx
|
|
1903
|
-
var
|
|
1903
|
+
var import_react39 = require("react");
|
|
1904
1904
|
|
|
1905
1905
|
// src/components/layout/card/Card.tsx
|
|
1906
|
-
var
|
|
1906
|
+
var import_react23 = require("react");
|
|
1907
1907
|
|
|
1908
1908
|
// src/const/components.ts
|
|
1909
1909
|
var VISIBLE_ENTITLEMENT_COUNT = 4;
|
|
1910
1910
|
var MAX_VISIBLE_INVOICE_COUNT = 12;
|
|
1911
1911
|
|
|
1912
|
+
// src/const/date.ts
|
|
1913
|
+
var SECONDS_IN_MS = 1e3;
|
|
1914
|
+
var MINUTES_IN_MS = SECONDS_IN_MS * 60;
|
|
1915
|
+
var HOURS_IN_MS = MINUTES_IN_MS * 60;
|
|
1916
|
+
var DAYS_IN_MS = HOURS_IN_MS * 24;
|
|
1917
|
+
|
|
1912
1918
|
// src/const/debounce.ts
|
|
1913
1919
|
var debounceOptions = {
|
|
1914
1920
|
leading: true,
|
|
@@ -6433,7 +6439,7 @@ var hasLoadedNamespace2 = (ns, i18n, options2 = {}) => {
|
|
|
6433
6439
|
return i18n.hasLoadedNamespace(ns, {
|
|
6434
6440
|
lng: options2.lng,
|
|
6435
6441
|
precheck: (i18nInstance2, loadNotPending) => {
|
|
6436
|
-
if (options2.bindI18n
|
|
6442
|
+
if (options2.bindI18n && options2.bindI18n.indexOf("languageChanging") > -1 && i18nInstance2.services.backendConnector.backend && i18nInstance2.isLanguageChangingTo && !loadNotPending(i18nInstance2.isLanguageChangingTo, ns)) return false;
|
|
6437
6443
|
}
|
|
6438
6444
|
});
|
|
6439
6445
|
};
|
|
@@ -6604,7 +6610,7 @@ var useTranslation = (ns, props = {}) => {
|
|
|
6604
6610
|
if (bindI18nStore) i18n?.store.on(bindI18nStore, boundReset);
|
|
6605
6611
|
return () => {
|
|
6606
6612
|
isMounted.current = false;
|
|
6607
|
-
if (i18n) bindI18n?.split(" ").forEach((e2) => i18n.off(e2, boundReset));
|
|
6613
|
+
if (i18n && bindI18n) bindI18n?.split(" ").forEach((e2) => i18n.off(e2, boundReset));
|
|
6608
6614
|
if (bindI18nStore && i18n) bindI18nStore.split(" ").forEach((e2) => i18n.store.off(e2, boundReset));
|
|
6609
6615
|
};
|
|
6610
6616
|
}, [i18n, joinedNS]);
|
|
@@ -6746,7 +6752,7 @@ var en_default = {
|
|
|
6746
6752
|
"There was a problem retrieving your invoices.": "There was a problem retrieving your invoices.",
|
|
6747
6753
|
"Tiers apply progressively as quantity increases.": "Tiers apply progressively as quantity increases.",
|
|
6748
6754
|
Total: "Total",
|
|
6749
|
-
"Trial ends in": "Trial ends in {{
|
|
6755
|
+
"Trial ends in": "Trial ends in {{amount}} {{units}}",
|
|
6750
6756
|
"Trial in progress": "Trial in progress",
|
|
6751
6757
|
"Trial selected": "Trial selected",
|
|
6752
6758
|
Trial: "Trial",
|
|
@@ -8391,6 +8397,54 @@ function PlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8391
8397
|
};
|
|
8392
8398
|
}
|
|
8393
8399
|
|
|
8400
|
+
// src/api/checkoutexternal/models/StripeEmbedInfo.ts
|
|
8401
|
+
function StripeEmbedInfoFromJSON(json) {
|
|
8402
|
+
return StripeEmbedInfoFromJSONTyped(json, false);
|
|
8403
|
+
}
|
|
8404
|
+
function StripeEmbedInfoFromJSONTyped(json, ignoreDiscriminator) {
|
|
8405
|
+
if (json == null) {
|
|
8406
|
+
return json;
|
|
8407
|
+
}
|
|
8408
|
+
return {
|
|
8409
|
+
accountId: json["account_id"] == null ? void 0 : json["account_id"],
|
|
8410
|
+
publishableKey: json["publishable_key"] == null ? void 0 : json["publishable_key"],
|
|
8411
|
+
schematicPublishableKey: json["schematic_publishable_key"],
|
|
8412
|
+
setupIntentClientSecret: json["setup_intent_client_secret"] == null ? void 0 : json["setup_intent_client_secret"]
|
|
8413
|
+
};
|
|
8414
|
+
}
|
|
8415
|
+
|
|
8416
|
+
// src/api/checkoutexternal/models/CreditCompanyGrantView.ts
|
|
8417
|
+
function CreditCompanyGrantViewFromJSON(json) {
|
|
8418
|
+
return CreditCompanyGrantViewFromJSONTyped(json, false);
|
|
8419
|
+
}
|
|
8420
|
+
function CreditCompanyGrantViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
8421
|
+
if (json == null) {
|
|
8422
|
+
return json;
|
|
8423
|
+
}
|
|
8424
|
+
return {
|
|
8425
|
+
billingCreditBundleId: json["billing_credit_bundle_id"] == null ? void 0 : json["billing_credit_bundle_id"],
|
|
8426
|
+
billingCreditId: json["billing_credit_id"],
|
|
8427
|
+
companyId: json["company_id"],
|
|
8428
|
+
companyName: json["company_name"],
|
|
8429
|
+
createdAt: new Date(json["created_at"]),
|
|
8430
|
+
creditName: json["credit_name"],
|
|
8431
|
+
expiresAt: json["expires_at"] == null ? void 0 : new Date(json["expires_at"]),
|
|
8432
|
+
grantReason: json["grant_reason"],
|
|
8433
|
+
id: json["id"],
|
|
8434
|
+
planId: json["plan_id"] == null ? void 0 : json["plan_id"],
|
|
8435
|
+
planName: json["plan_name"] == null ? void 0 : json["plan_name"],
|
|
8436
|
+
price: json["price"] == null ? void 0 : BillingProductPriceResponseDataFromJSON(json["price"]),
|
|
8437
|
+
quantity: json["quantity"],
|
|
8438
|
+
quantityRemaining: json["quantity_remaining"],
|
|
8439
|
+
quantityUsed: json["quantity_used"],
|
|
8440
|
+
sourceLabel: json["source_label"],
|
|
8441
|
+
updatedAt: new Date(json["updated_at"]),
|
|
8442
|
+
validFrom: json["valid_from"] == null ? void 0 : new Date(json["valid_from"]),
|
|
8443
|
+
zeroedOutDate: json["zeroed_out_date"] == null ? void 0 : new Date(json["zeroed_out_date"]),
|
|
8444
|
+
zeroedOutReason: json["zeroed_out_reason"] == null ? void 0 : json["zeroed_out_reason"]
|
|
8445
|
+
};
|
|
8446
|
+
}
|
|
8447
|
+
|
|
8394
8448
|
// src/api/checkoutexternal/models/UsageBasedEntitlementResponseData.ts
|
|
8395
8449
|
function UsageBasedEntitlementResponseDataFromJSON(json) {
|
|
8396
8450
|
return UsageBasedEntitlementResponseDataFromJSONTyped(json, false);
|
|
@@ -8478,20 +8532,6 @@ function FeatureUsageDetailResponseDataFromJSONTyped(json, ignoreDiscriminator)
|
|
|
8478
8532
|
};
|
|
8479
8533
|
}
|
|
8480
8534
|
|
|
8481
|
-
// src/api/checkoutexternal/models/StripeEmbedInfo.ts
|
|
8482
|
-
function StripeEmbedInfoFromJSON(json) {
|
|
8483
|
-
return StripeEmbedInfoFromJSONTyped(json, false);
|
|
8484
|
-
}
|
|
8485
|
-
function StripeEmbedInfoFromJSONTyped(json, ignoreDiscriminator) {
|
|
8486
|
-
if (json == null) {
|
|
8487
|
-
return json;
|
|
8488
|
-
}
|
|
8489
|
-
return {
|
|
8490
|
-
publishableKey: json["publishable_key"],
|
|
8491
|
-
setupIntentClientSecret: json["setup_intent_client_secret"] == null ? void 0 : json["setup_intent_client_secret"]
|
|
8492
|
-
};
|
|
8493
|
-
}
|
|
8494
|
-
|
|
8495
8535
|
// src/api/checkoutexternal/models/ComponentHydrateResponseData.ts
|
|
8496
8536
|
function ComponentHydrateResponseDataFromJSON(json) {
|
|
8497
8537
|
return ComponentHydrateResponseDataFromJSONTyped(json, false);
|
|
@@ -8517,6 +8557,9 @@ function ComponentHydrateResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8517
8557
|
creditBundles: json["credit_bundles"].map(
|
|
8518
8558
|
BillingCreditBundleViewFromJSON
|
|
8519
8559
|
),
|
|
8560
|
+
creditGrants: json["credit_grants"].map(
|
|
8561
|
+
CreditCompanyGrantViewFromJSON
|
|
8562
|
+
),
|
|
8520
8563
|
defaultPlan: json["default_plan"] == null ? void 0 : PlanDetailResponseDataFromJSON(json["default_plan"]),
|
|
8521
8564
|
featureUsage: json["feature_usage"] == null ? void 0 : FeatureUsageDetailResponseDataFromJSON(json["feature_usage"]),
|
|
8522
8565
|
stripeEmbed: json["stripe_embed"] == null ? void 0 : StripeEmbedInfoFromJSON(json["stripe_embed"]),
|
|
@@ -8535,7 +8578,9 @@ function SetupIntentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8535
8578
|
return json;
|
|
8536
8579
|
}
|
|
8537
8580
|
return {
|
|
8538
|
-
|
|
8581
|
+
accountId: json["account_id"] == null ? void 0 : json["account_id"],
|
|
8582
|
+
publishableKey: json["publishable_key"] == null ? void 0 : json["publishable_key"],
|
|
8583
|
+
schematicPublishableKey: json["schematic_publishable_key"],
|
|
8539
8584
|
setupIntentClientSecret: json["setup_intent_client_secret"] == null ? void 0 : json["setup_intent_client_secret"]
|
|
8540
8585
|
};
|
|
8541
8586
|
}
|
|
@@ -10143,7 +10188,7 @@ var EmbedProvider = ({
|
|
|
10143
10188
|
});
|
|
10144
10189
|
const customHeaders = (0, import_react12.useMemo)(
|
|
10145
10190
|
() => ({
|
|
10146
|
-
"X-Schematic-Components-Version": "1.1.
|
|
10191
|
+
"X-Schematic-Components-Version": "1.1.2",
|
|
10147
10192
|
"X-Schematic-Session-ID": sessionIdRef.current
|
|
10148
10193
|
}),
|
|
10149
10194
|
[]
|
|
@@ -10538,26 +10583,49 @@ function useRequest(fn) {
|
|
|
10538
10583
|
}
|
|
10539
10584
|
|
|
10540
10585
|
// src/hooks/useTrialEnd.ts
|
|
10586
|
+
var import_react17 = require("react");
|
|
10541
10587
|
function useTrialEnd() {
|
|
10588
|
+
const { t: t2 } = useTranslation();
|
|
10542
10589
|
const { data } = useEmbed();
|
|
10543
|
-
const
|
|
10544
|
-
|
|
10545
|
-
|
|
10546
|
-
|
|
10547
|
-
|
|
10548
|
-
|
|
10549
|
-
|
|
10550
|
-
|
|
10551
|
-
|
|
10590
|
+
const { endDate, formatted } = (0, import_react17.useMemo)(() => {
|
|
10591
|
+
const billingSubscription = isCheckoutData(data) ? data.company?.billingSubscription : void 0;
|
|
10592
|
+
const end = typeof billingSubscription?.trialEnd === "number" ? new Date(billingSubscription.trialEnd * 1e3) : void 0;
|
|
10593
|
+
let formatted2;
|
|
10594
|
+
if (end) {
|
|
10595
|
+
const today = /* @__PURE__ */ new Date();
|
|
10596
|
+
const difference = end.getTime() - today.getTime();
|
|
10597
|
+
let amount;
|
|
10598
|
+
let unit;
|
|
10599
|
+
if (difference >= DAYS_IN_MS) {
|
|
10600
|
+
amount = Math.floor(difference / DAYS_IN_MS);
|
|
10601
|
+
unit = "day";
|
|
10602
|
+
} else if (difference >= HOURS_IN_MS) {
|
|
10603
|
+
amount = Math.floor(difference / HOURS_IN_MS);
|
|
10604
|
+
unit = "hour";
|
|
10605
|
+
} else if (difference >= MINUTES_IN_MS) {
|
|
10606
|
+
amount = Math.floor(difference / MINUTES_IN_MS);
|
|
10607
|
+
unit = "minute";
|
|
10608
|
+
} else {
|
|
10609
|
+
amount = Math.floor(difference / SECONDS_IN_MS);
|
|
10610
|
+
unit = "second";
|
|
10611
|
+
}
|
|
10612
|
+
formatted2 = t2("Trial ends in", {
|
|
10613
|
+
amount,
|
|
10614
|
+
units: pluralize(unit, amount)
|
|
10615
|
+
});
|
|
10616
|
+
}
|
|
10617
|
+
return { endDate: end, formatted: formatted2 };
|
|
10618
|
+
}, [t2, data]);
|
|
10619
|
+
return { endDate, formatted };
|
|
10552
10620
|
}
|
|
10553
10621
|
|
|
10554
10622
|
// src/hooks/useWrapChildren.ts
|
|
10555
|
-
var
|
|
10623
|
+
var import_react18 = require("react");
|
|
10556
10624
|
function useWrapChildren(elements) {
|
|
10557
|
-
const [shouldWrap, setShouldWrap] = (0,
|
|
10625
|
+
const [shouldWrap, setShouldWrap] = (0, import_react18.useState)(
|
|
10558
10626
|
() => new Array(elements.length).fill(false)
|
|
10559
10627
|
);
|
|
10560
|
-
(0,
|
|
10628
|
+
(0, import_react18.useLayoutEffect)(() => {
|
|
10561
10629
|
const rowShouldWrap = (parent) => [...parent.children].some(
|
|
10562
10630
|
(el) => el instanceof HTMLElement && el.previousElementSibling instanceof HTMLElement && el.offsetLeft <= el.previousElementSibling.offsetLeft
|
|
10563
10631
|
);
|
|
@@ -11068,7 +11136,7 @@ var Input = dt.input(({ theme, $size = "md", $variant = "filled" }) => {
|
|
|
11068
11136
|
});
|
|
11069
11137
|
|
|
11070
11138
|
// src/components/ui/modal/Modal.tsx
|
|
11071
|
-
var
|
|
11139
|
+
var import_react19 = require("react");
|
|
11072
11140
|
|
|
11073
11141
|
// src/components/ui/modal/styles.ts
|
|
11074
11142
|
var Overlay = dt(Box)`
|
|
@@ -11133,12 +11201,12 @@ var Modal2 = ({
|
|
|
11133
11201
|
}) => {
|
|
11134
11202
|
const { setLayout } = useEmbed();
|
|
11135
11203
|
const isLightBackground = useIsLightBackground();
|
|
11136
|
-
const ref = (0,
|
|
11137
|
-
const handleClose = (0,
|
|
11204
|
+
const ref = (0, import_react19.useRef)(null);
|
|
11205
|
+
const handleClose = (0, import_react19.useCallback)(() => {
|
|
11138
11206
|
setLayout("portal");
|
|
11139
11207
|
onClose?.();
|
|
11140
11208
|
}, [setLayout, onClose]);
|
|
11141
|
-
(0,
|
|
11209
|
+
(0, import_react19.useLayoutEffect)(() => {
|
|
11142
11210
|
contentRef?.current?.focus({ preventScroll: true });
|
|
11143
11211
|
}, [contentRef]);
|
|
11144
11212
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Container, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
@@ -11168,7 +11236,7 @@ var Modal2 = ({
|
|
|
11168
11236
|
Modal2.displayName = "Modal";
|
|
11169
11237
|
|
|
11170
11238
|
// src/components/ui/modal/ModalHeader.tsx
|
|
11171
|
-
var
|
|
11239
|
+
var import_react20 = require("react");
|
|
11172
11240
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
11173
11241
|
var ModalHeader = ({
|
|
11174
11242
|
children,
|
|
@@ -11177,7 +11245,7 @@ var ModalHeader = ({
|
|
|
11177
11245
|
}) => {
|
|
11178
11246
|
const { settings, setLayout } = useEmbed();
|
|
11179
11247
|
const isLightBackground = useIsLightBackground();
|
|
11180
|
-
const handleClose = (0,
|
|
11248
|
+
const handleClose = (0, import_react20.useCallback)(() => {
|
|
11181
11249
|
setLayout("portal");
|
|
11182
11250
|
onClose?.();
|
|
11183
11251
|
}, [setLayout, onClose]);
|
|
@@ -11234,7 +11302,7 @@ var ModalHeader = ({
|
|
|
11234
11302
|
};
|
|
11235
11303
|
|
|
11236
11304
|
// src/components/ui/progress-bar/ProgressBar.tsx
|
|
11237
|
-
var
|
|
11305
|
+
var import_react21 = require("react");
|
|
11238
11306
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
11239
11307
|
var progressColorMap = [
|
|
11240
11308
|
"blue",
|
|
@@ -11244,7 +11312,7 @@ var progressColorMap = [
|
|
|
11244
11312
|
"red",
|
|
11245
11313
|
"red"
|
|
11246
11314
|
];
|
|
11247
|
-
var ProgressBar = (0,
|
|
11315
|
+
var ProgressBar = (0, import_react21.forwardRef)(
|
|
11248
11316
|
({
|
|
11249
11317
|
progress,
|
|
11250
11318
|
value,
|
|
@@ -11289,7 +11357,7 @@ var ProgressBar = (0, import_react20.forwardRef)(
|
|
|
11289
11357
|
)
|
|
11290
11358
|
}
|
|
11291
11359
|
),
|
|
11292
|
-
total && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { $size: 14, $weight: 500, children: [
|
|
11360
|
+
total > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { $size: 14, $weight: 500, children: [
|
|
11293
11361
|
formatNumber(value),
|
|
11294
11362
|
"/",
|
|
11295
11363
|
formatNumber(total)
|
|
@@ -11366,7 +11434,7 @@ var Text = dt.span.withConfig({
|
|
|
11366
11434
|
|
|
11367
11435
|
// src/components/ui/tooltip/Tooltip.tsx
|
|
11368
11436
|
var import_debounce2 = __toESM(require_debounce());
|
|
11369
|
-
var
|
|
11437
|
+
var import_react22 = require("react");
|
|
11370
11438
|
var import_react_dom = require("react-dom");
|
|
11371
11439
|
|
|
11372
11440
|
// src/components/ui/tooltip/styles.ts
|
|
@@ -11520,10 +11588,10 @@ var Tooltip = ({
|
|
|
11520
11588
|
position: position2 = "top",
|
|
11521
11589
|
...rest
|
|
11522
11590
|
}) => {
|
|
11523
|
-
const ref = (0,
|
|
11524
|
-
const [show, setShow] = (0,
|
|
11525
|
-
const [coords2, setCoords] = (0,
|
|
11526
|
-
const updateCoords = (0,
|
|
11591
|
+
const ref = (0, import_react22.useRef)(null);
|
|
11592
|
+
const [show, setShow] = (0, import_react22.useState)(false);
|
|
11593
|
+
const [coords2, setCoords] = (0, import_react22.useState)({ x: 0, y: 0 });
|
|
11594
|
+
const updateCoords = (0, import_react22.useCallback)(() => {
|
|
11527
11595
|
if (ref.current) {
|
|
11528
11596
|
const { top: offsetTop, left: offsetLeft } = document.body.getBoundingClientRect();
|
|
11529
11597
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -11541,14 +11609,14 @@ var Tooltip = ({
|
|
|
11541
11609
|
});
|
|
11542
11610
|
}
|
|
11543
11611
|
}, [position2]);
|
|
11544
|
-
(0,
|
|
11612
|
+
(0, import_react22.useLayoutEffect)(() => {
|
|
11545
11613
|
const handleResize = (0, import_debounce2.default)(updateCoords, EVENT_DEBOUNCE_TIMEOUT);
|
|
11546
11614
|
window.addEventListener("resize", handleResize);
|
|
11547
11615
|
return () => {
|
|
11548
11616
|
window.removeEventListener("resize", handleResize);
|
|
11549
11617
|
};
|
|
11550
11618
|
}, [updateCoords]);
|
|
11551
|
-
(0,
|
|
11619
|
+
(0, import_react22.useLayoutEffect)(() => {
|
|
11552
11620
|
updateCoords();
|
|
11553
11621
|
}, [updateCoords, show]);
|
|
11554
11622
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
@@ -11610,7 +11678,7 @@ var StyledCard = dt.div(({ theme }) => {
|
|
|
11610
11678
|
|
|
11611
11679
|
// src/components/layout/card/Card.tsx
|
|
11612
11680
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
11613
|
-
var Card = (0,
|
|
11681
|
+
var Card = (0, import_react23.forwardRef)(
|
|
11614
11682
|
({ children, className }, ref) => {
|
|
11615
11683
|
const { settings, isPending } = useEmbed();
|
|
11616
11684
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(StyledCard, { ref, className, children: [
|
|
@@ -11638,7 +11706,7 @@ var Card = (0, import_react22.forwardRef)(
|
|
|
11638
11706
|
Card.displayName = "Card";
|
|
11639
11707
|
|
|
11640
11708
|
// src/components/layout/column/Column.tsx
|
|
11641
|
-
var
|
|
11709
|
+
var import_react24 = require("react");
|
|
11642
11710
|
|
|
11643
11711
|
// src/components/layout/column/styles.ts
|
|
11644
11712
|
var StyledColumn = dt.div`
|
|
@@ -11647,15 +11715,15 @@ var StyledColumn = dt.div`
|
|
|
11647
11715
|
|
|
11648
11716
|
// src/components/layout/column/Column.tsx
|
|
11649
11717
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
11650
|
-
var Column = (0,
|
|
11718
|
+
var Column = (0, import_react24.forwardRef)(
|
|
11651
11719
|
({ children, basis, ...props }, ref) => {
|
|
11652
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyledColumn, { ref, ...props, children:
|
|
11720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyledColumn, { ref, ...props, children: import_react24.Children.count(children) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Card, { children }) : children });
|
|
11653
11721
|
}
|
|
11654
11722
|
);
|
|
11655
11723
|
Column.displayName = "Column";
|
|
11656
11724
|
|
|
11657
11725
|
// src/components/layout/root/Root.tsx
|
|
11658
|
-
var
|
|
11726
|
+
var import_react25 = require("react");
|
|
11659
11727
|
|
|
11660
11728
|
// src/components/layout/root/styles.ts
|
|
11661
11729
|
var Container = dt.div`
|
|
@@ -11692,7 +11760,7 @@ var Container = dt.div`
|
|
|
11692
11760
|
|
|
11693
11761
|
// src/components/layout/root/Root.tsx
|
|
11694
11762
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
11695
|
-
var Root = (0,
|
|
11763
|
+
var Root = (0, import_react25.forwardRef)(
|
|
11696
11764
|
({ data, settings, ...props }, ref) => {
|
|
11697
11765
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Container, { ref, ...props });
|
|
11698
11766
|
}
|
|
@@ -11701,14 +11769,14 @@ Root.displayName = "Root";
|
|
|
11701
11769
|
|
|
11702
11770
|
// src/components/layout/viewport/Viewport.tsx
|
|
11703
11771
|
var import_debounce3 = __toESM(require_debounce());
|
|
11704
|
-
var
|
|
11772
|
+
var import_react38 = require("react");
|
|
11705
11773
|
var import_react_dom2 = require("react-dom");
|
|
11706
11774
|
|
|
11707
11775
|
// src/components/shared/checkout-dialog/CheckoutDialog.tsx
|
|
11708
|
-
var
|
|
11776
|
+
var import_react30 = require("react");
|
|
11709
11777
|
|
|
11710
11778
|
// src/components/shared/sidebar/Sidebar.tsx
|
|
11711
|
-
var
|
|
11779
|
+
var import_react27 = require("react");
|
|
11712
11780
|
|
|
11713
11781
|
// src/components/shared/sidebar/EntitlementRow.tsx
|
|
11714
11782
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
@@ -11782,7 +11850,7 @@ var EntitlementRow = (entitlement) => {
|
|
|
11782
11850
|
};
|
|
11783
11851
|
|
|
11784
11852
|
// src/components/shared/sidebar/Proration.tsx
|
|
11785
|
-
var
|
|
11853
|
+
var import_react26 = require("react");
|
|
11786
11854
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
11787
11855
|
var Proration = ({
|
|
11788
11856
|
currency,
|
|
@@ -11790,7 +11858,7 @@ var Proration = ({
|
|
|
11790
11858
|
selectedPlan
|
|
11791
11859
|
}) => {
|
|
11792
11860
|
const { t: t2 } = useTranslation();
|
|
11793
|
-
const [open, setOpen] = (0,
|
|
11861
|
+
const [open, setOpen] = (0, import_react26.useState)(false);
|
|
11794
11862
|
const toggle = (e2) => {
|
|
11795
11863
|
e2.preventDefault();
|
|
11796
11864
|
e2.stopPropagation();
|
|
@@ -12038,7 +12106,7 @@ var Sidebar = ({
|
|
|
12038
12106
|
billingSubscription,
|
|
12039
12107
|
paymentMethod,
|
|
12040
12108
|
trialPaymentMethodRequired
|
|
12041
|
-
} = (0,
|
|
12109
|
+
} = (0, import_react27.useMemo)(() => {
|
|
12042
12110
|
if (isCheckoutData(data)) {
|
|
12043
12111
|
const currentEntitlements2 = data.featureUsage?.features || [];
|
|
12044
12112
|
return {
|
|
@@ -12076,7 +12144,7 @@ var Sidebar = ({
|
|
|
12076
12144
|
trialPaymentMethodRequired: false
|
|
12077
12145
|
};
|
|
12078
12146
|
}, [data, planPeriod]);
|
|
12079
|
-
const { payInAdvanceEntitlements } = (0,
|
|
12147
|
+
const { payInAdvanceEntitlements } = (0, import_react27.useMemo)(() => {
|
|
12080
12148
|
const payAsYouGoEntitlements = [];
|
|
12081
12149
|
const payInAdvanceEntitlements2 = usageBasedEntitlements.filter(
|
|
12082
12150
|
(entitlement) => {
|
|
@@ -12088,7 +12156,7 @@ var Sidebar = ({
|
|
|
12088
12156
|
);
|
|
12089
12157
|
return { payAsYouGoEntitlements, payInAdvanceEntitlements: payInAdvanceEntitlements2 };
|
|
12090
12158
|
}, [usageBasedEntitlements]);
|
|
12091
|
-
const subscriptionPrice = (0,
|
|
12159
|
+
const subscriptionPrice = (0, import_react27.useMemo)(() => {
|
|
12092
12160
|
let planPrice;
|
|
12093
12161
|
let currency;
|
|
12094
12162
|
if (selectedPlan) {
|
|
@@ -12116,7 +12184,7 @@ var Sidebar = ({
|
|
|
12116
12184
|
total += payInAdvanceCost;
|
|
12117
12185
|
return formatCurrency(total, currency);
|
|
12118
12186
|
}, [selectedPlan, currentPlan, planPeriod, addOns, payInAdvanceEntitlements]);
|
|
12119
|
-
const { amountOff, dueNow, newCharges, percentOff, periodStart, proration } = (0,
|
|
12187
|
+
const { amountOff, dueNow, newCharges, percentOff, periodStart, proration } = (0, import_react27.useMemo)(() => {
|
|
12120
12188
|
return {
|
|
12121
12189
|
amountOff: charges?.amountOff ?? 0,
|
|
12122
12190
|
dueNow: charges?.dueNow ?? 0,
|
|
@@ -12126,7 +12194,7 @@ var Sidebar = ({
|
|
|
12126
12194
|
proration: charges?.proration ?? 0
|
|
12127
12195
|
};
|
|
12128
12196
|
}, [charges]);
|
|
12129
|
-
const handleCheckout = (0,
|
|
12197
|
+
const handleCheckout = (0, import_react27.useCallback)(async () => {
|
|
12130
12198
|
const planId = selectedPlan?.id;
|
|
12131
12199
|
const priceId = (planPeriod === "year" ? selectedPlan?.yearlyPrice : selectedPlan?.monthlyPrice)?.id;
|
|
12132
12200
|
try {
|
|
@@ -12191,7 +12259,7 @@ var Sidebar = ({
|
|
|
12191
12259
|
willTrialWithoutPaymentMethod,
|
|
12192
12260
|
promoCode
|
|
12193
12261
|
]);
|
|
12194
|
-
const handleUnsubscribe = (0,
|
|
12262
|
+
const handleUnsubscribe = (0, import_react27.useCallback)(async () => {
|
|
12195
12263
|
try {
|
|
12196
12264
|
setError(void 0);
|
|
12197
12265
|
setIsLoading(true);
|
|
@@ -12205,7 +12273,7 @@ var Sidebar = ({
|
|
|
12205
12273
|
}
|
|
12206
12274
|
}, [t2, unsubscribe, setError, setIsLoading, setLayout]);
|
|
12207
12275
|
const selectedAddOns = addOns.filter((addOn) => addOn.isSelected);
|
|
12208
|
-
const updatedUsageBasedEntitlements = (0,
|
|
12276
|
+
const updatedUsageBasedEntitlements = (0, import_react27.useMemo)(() => {
|
|
12209
12277
|
const changedUsageBasedEntitlements = [];
|
|
12210
12278
|
const addedUsageBasedEntitlements = selectedPlan ? usageBasedEntitlements.reduce(
|
|
12211
12279
|
(acc, selected) => {
|
|
@@ -12840,7 +12908,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
|
|
|
12840
12908
|
};
|
|
12841
12909
|
|
|
12842
12910
|
// src/components/shared/checkout-dialog/Checkout.tsx
|
|
12843
|
-
var
|
|
12911
|
+
var import_react28 = require("react");
|
|
12844
12912
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
12845
12913
|
var Checkout = ({
|
|
12846
12914
|
isPaymentMethodRequired,
|
|
@@ -12849,7 +12917,7 @@ var Checkout = ({
|
|
|
12849
12917
|
}) => {
|
|
12850
12918
|
const { t: t2 } = useTranslation();
|
|
12851
12919
|
const isLightBackground = useIsLightBackground();
|
|
12852
|
-
const [discount, setDiscount] = (0,
|
|
12920
|
+
const [discount, setDiscount] = (0, import_react28.useState)("");
|
|
12853
12921
|
if (!isPaymentMethodRequired) {
|
|
12854
12922
|
return null;
|
|
12855
12923
|
}
|
|
@@ -12988,12 +13056,12 @@ var Navigation = ({
|
|
|
12988
13056
|
};
|
|
12989
13057
|
|
|
12990
13058
|
// src/components/shared/checkout-dialog/Plan.tsx
|
|
12991
|
-
var
|
|
13059
|
+
var import_react29 = require("react");
|
|
12992
13060
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
12993
13061
|
var Selected = ({ isCurrent = false, isTrial = false }) => {
|
|
12994
13062
|
const { t: t2 } = useTranslation();
|
|
12995
13063
|
const { settings } = useEmbed();
|
|
12996
|
-
const text = (0,
|
|
13064
|
+
const text = (0, import_react29.useMemo)(() => {
|
|
12997
13065
|
if (isCurrent) {
|
|
12998
13066
|
return isTrial ? t2("Trial in progress") : t2("Current plan");
|
|
12999
13067
|
}
|
|
@@ -13029,7 +13097,7 @@ var PlanButtonGroup = ({
|
|
|
13029
13097
|
}) => {
|
|
13030
13098
|
const { t: t2 } = useTranslation();
|
|
13031
13099
|
const { data } = useEmbed();
|
|
13032
|
-
const { isCurrentPlan, isValidPlan, isTrialing } = (0,
|
|
13100
|
+
const { isCurrentPlan, isValidPlan, isTrialing } = (0, import_react29.useMemo)(() => {
|
|
13033
13101
|
if (isCheckoutData(data)) {
|
|
13034
13102
|
return {
|
|
13035
13103
|
isCurrentPlan: data.company?.plan?.id === plan.id,
|
|
@@ -13139,10 +13207,10 @@ var Plan = ({
|
|
|
13139
13207
|
const { t: t2 } = useTranslation();
|
|
13140
13208
|
const { data, settings } = useEmbed();
|
|
13141
13209
|
const isLightBackground = useIsLightBackground();
|
|
13142
|
-
const [entitlementCounts, setEntitlementCounts] = (0,
|
|
13210
|
+
const [entitlementCounts, setEntitlementCounts] = (0, import_react29.useState)(
|
|
13143
13211
|
() => plans.reduce(entitlementCountsReducer, {})
|
|
13144
13212
|
);
|
|
13145
|
-
const isTrialing = (0,
|
|
13213
|
+
const isTrialing = (0, import_react29.useMemo)(
|
|
13146
13214
|
() => isCheckoutData(data) && data.subscription?.status === "trialing",
|
|
13147
13215
|
[data]
|
|
13148
13216
|
);
|
|
@@ -13161,7 +13229,7 @@ var Plan = ({
|
|
|
13161
13229
|
return prev2;
|
|
13162
13230
|
});
|
|
13163
13231
|
};
|
|
13164
|
-
(0,
|
|
13232
|
+
(0, import_react29.useEffect)(() => {
|
|
13165
13233
|
setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
|
|
13166
13234
|
}, [plans]);
|
|
13167
13235
|
const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
|
|
@@ -13631,29 +13699,29 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
13631
13699
|
const { t: t2 } = useTranslation();
|
|
13632
13700
|
const { data, checkoutState, previewCheckout } = useEmbed();
|
|
13633
13701
|
const isLightBackground = useIsLightBackground();
|
|
13634
|
-
const contentRef = (0,
|
|
13635
|
-
const checkoutRef = (0,
|
|
13636
|
-
const [charges, setCharges] = (0,
|
|
13637
|
-
const [paymentMethodId, setPaymentMethodId] = (0,
|
|
13702
|
+
const contentRef = (0, import_react30.useRef)(null);
|
|
13703
|
+
const checkoutRef = (0, import_react30.useRef)(null);
|
|
13704
|
+
const [charges, setCharges] = (0, import_react30.useState)();
|
|
13705
|
+
const [paymentMethodId, setPaymentMethodId] = (0, import_react30.useState)(
|
|
13638
13706
|
() => {
|
|
13639
13707
|
if (isCheckoutData(data)) {
|
|
13640
13708
|
return (data.subscription?.paymentMethod || data.company?.defaultPaymentMethod)?.externalId;
|
|
13641
13709
|
}
|
|
13642
13710
|
}
|
|
13643
13711
|
);
|
|
13644
|
-
const [isLoading, setIsLoading] = (0,
|
|
13645
|
-
const [error, setError] = (0,
|
|
13646
|
-
const currentPeriod = (0,
|
|
13712
|
+
const [isLoading, setIsLoading] = (0, import_react30.useState)(false);
|
|
13713
|
+
const [error, setError] = (0, import_react30.useState)();
|
|
13714
|
+
const currentPeriod = (0, import_react30.useMemo)(
|
|
13647
13715
|
() => checkoutState?.period || isCheckoutData(data) && data.company?.plan?.planPeriod || "month",
|
|
13648
13716
|
[data, checkoutState?.period]
|
|
13649
13717
|
);
|
|
13650
|
-
const [planPeriod, setPlanPeriod] = (0,
|
|
13718
|
+
const [planPeriod, setPlanPeriod] = (0, import_react30.useState)(currentPeriod);
|
|
13651
13719
|
const {
|
|
13652
13720
|
plans: availablePlans,
|
|
13653
13721
|
addOns: availableAddOns,
|
|
13654
13722
|
periods: availablePeriods
|
|
13655
13723
|
} = useAvailablePlans(planPeriod);
|
|
13656
|
-
const { currentPlanId, currentEntitlements, trialPaymentMethodRequired } = (0,
|
|
13724
|
+
const { currentPlanId, currentEntitlements, trialPaymentMethodRequired } = (0, import_react30.useMemo)(() => {
|
|
13657
13725
|
if (isCheckoutData(data)) {
|
|
13658
13726
|
return {
|
|
13659
13727
|
currentPlanId: data.company?.plan?.id,
|
|
@@ -13667,7 +13735,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
13667
13735
|
trialPaymentMethodRequired: false
|
|
13668
13736
|
};
|
|
13669
13737
|
}, [data]);
|
|
13670
|
-
const [selectedPlan, setSelectedPlan] = (0,
|
|
13738
|
+
const [selectedPlan, setSelectedPlan] = (0, import_react30.useState)(
|
|
13671
13739
|
() => {
|
|
13672
13740
|
const currentSelectedPlan = availablePlans.find(
|
|
13673
13741
|
(plan) => checkoutState?.planId ? plan.id === checkoutState.planId : isHydratedPlan(plan) && plan.current
|
|
@@ -13675,8 +13743,8 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
13675
13743
|
return currentSelectedPlan;
|
|
13676
13744
|
}
|
|
13677
13745
|
);
|
|
13678
|
-
const [shouldTrial, setShouldTrial] = (0,
|
|
13679
|
-
const [addOns, setAddOns] = (0,
|
|
13746
|
+
const [shouldTrial, setShouldTrial] = (0, import_react30.useState)(false);
|
|
13747
|
+
const [addOns, setAddOns] = (0, import_react30.useState)(() => {
|
|
13680
13748
|
if (isCheckoutData(data)) {
|
|
13681
13749
|
return availableAddOns.map((addOn) => ({
|
|
13682
13750
|
...addOn,
|
|
@@ -13687,7 +13755,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
13687
13755
|
}
|
|
13688
13756
|
return [];
|
|
13689
13757
|
});
|
|
13690
|
-
const [usageBasedEntitlements, setUsageBasedEntitlements] = (0,
|
|
13758
|
+
const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react30.useState)(
|
|
13691
13759
|
() => (selectedPlan?.entitlements || []).reduce(
|
|
13692
13760
|
createActiveUsageBasedEntitlementsReducer(
|
|
13693
13761
|
currentEntitlements,
|
|
@@ -13696,20 +13764,20 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
13696
13764
|
[]
|
|
13697
13765
|
)
|
|
13698
13766
|
);
|
|
13699
|
-
const payInAdvanceEntitlements = (0,
|
|
13767
|
+
const payInAdvanceEntitlements = (0, import_react30.useMemo)(
|
|
13700
13768
|
() => usageBasedEntitlements.filter(
|
|
13701
13769
|
(entitlement) => entitlement.priceBehavior === "pay_in_advance" /* PayInAdvance */
|
|
13702
13770
|
),
|
|
13703
13771
|
[usageBasedEntitlements]
|
|
13704
13772
|
);
|
|
13705
|
-
const [promoCode, setPromoCode] = (0,
|
|
13706
|
-
const [isPaymentMethodRequired, setIsPaymentMethodRequired] = (0,
|
|
13707
|
-
const willTrialWithoutPaymentMethod = (0,
|
|
13773
|
+
const [promoCode, setPromoCode] = (0, import_react30.useState)(null);
|
|
13774
|
+
const [isPaymentMethodRequired, setIsPaymentMethodRequired] = (0, import_react30.useState)(false);
|
|
13775
|
+
const willTrialWithoutPaymentMethod = (0, import_react30.useMemo)(
|
|
13708
13776
|
() => shouldTrial && !trialPaymentMethodRequired,
|
|
13709
13777
|
[shouldTrial, trialPaymentMethodRequired]
|
|
13710
13778
|
);
|
|
13711
13779
|
const isSelectedPlanTrialable = isHydratedPlan(selectedPlan) && selectedPlan.isTrialable && selectedPlan.companyCanTrial;
|
|
13712
|
-
const checkoutStages = (0,
|
|
13780
|
+
const checkoutStages = (0, import_react30.useMemo)(() => {
|
|
13713
13781
|
const stages = [];
|
|
13714
13782
|
if (availablePlans) {
|
|
13715
13783
|
stages.push({
|
|
@@ -13754,7 +13822,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
13754
13822
|
isSelectedPlanTrialable,
|
|
13755
13823
|
isPaymentMethodRequired
|
|
13756
13824
|
]);
|
|
13757
|
-
const [checkoutStage, setCheckoutStage] = (0,
|
|
13825
|
+
const [checkoutStage, setCheckoutStage] = (0, import_react30.useState)(() => {
|
|
13758
13826
|
if (checkoutState?.addOnId) {
|
|
13759
13827
|
return "addons";
|
|
13760
13828
|
}
|
|
@@ -13766,7 +13834,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
13766
13834
|
}
|
|
13767
13835
|
return "plan";
|
|
13768
13836
|
});
|
|
13769
|
-
const handlePreviewCheckout = (0,
|
|
13837
|
+
const handlePreviewCheckout = (0, import_react30.useCallback)(
|
|
13770
13838
|
async (updates) => {
|
|
13771
13839
|
const period = updates.period || planPeriod;
|
|
13772
13840
|
const plan = updates.plan || selectedPlan;
|
|
@@ -13862,7 +13930,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
13862
13930
|
promoCode
|
|
13863
13931
|
]
|
|
13864
13932
|
);
|
|
13865
|
-
const selectPlan = (0,
|
|
13933
|
+
const selectPlan = (0, import_react30.useCallback)(
|
|
13866
13934
|
(updates) => {
|
|
13867
13935
|
const plan = updates.plan;
|
|
13868
13936
|
const period = updates.period || planPeriod;
|
|
@@ -13913,7 +13981,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
13913
13981
|
handlePreviewCheckout
|
|
13914
13982
|
]
|
|
13915
13983
|
);
|
|
13916
|
-
const changePlanPeriod = (0,
|
|
13984
|
+
const changePlanPeriod = (0, import_react30.useCallback)(
|
|
13917
13985
|
(period) => {
|
|
13918
13986
|
if (period !== planPeriod) {
|
|
13919
13987
|
setPlanPeriod(period);
|
|
@@ -13922,7 +13990,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
13922
13990
|
},
|
|
13923
13991
|
[planPeriod, setPlanPeriod, handlePreviewCheckout]
|
|
13924
13992
|
);
|
|
13925
|
-
const toggleAddOn = (0,
|
|
13993
|
+
const toggleAddOn = (0, import_react30.useCallback)(
|
|
13926
13994
|
(id) => {
|
|
13927
13995
|
setAddOns((prev2) => {
|
|
13928
13996
|
const updated = prev2.map((addOn) => ({
|
|
@@ -13935,7 +14003,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
13935
14003
|
},
|
|
13936
14004
|
[handlePreviewCheckout]
|
|
13937
14005
|
);
|
|
13938
|
-
const updateUsageBasedEntitlementQuantity = (0,
|
|
14006
|
+
const updateUsageBasedEntitlementQuantity = (0, import_react30.useCallback)(
|
|
13939
14007
|
(id, updatedQuantity) => {
|
|
13940
14008
|
setUsageBasedEntitlements((prev2) => {
|
|
13941
14009
|
const updated = prev2.map(
|
|
@@ -13954,18 +14022,18 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
13954
14022
|
},
|
|
13955
14023
|
[handlePreviewCheckout]
|
|
13956
14024
|
);
|
|
13957
|
-
const updatePromoCode = (0,
|
|
14025
|
+
const updatePromoCode = (0, import_react30.useCallback)(
|
|
13958
14026
|
async (code) => {
|
|
13959
14027
|
handlePreviewCheckout({ promoCode: code });
|
|
13960
14028
|
},
|
|
13961
14029
|
[handlePreviewCheckout]
|
|
13962
14030
|
);
|
|
13963
|
-
(0,
|
|
14031
|
+
(0, import_react30.useEffect)(() => {
|
|
13964
14032
|
if (selectedPlan) {
|
|
13965
14033
|
selectPlan({ plan: selectedPlan, period: currentPeriod });
|
|
13966
14034
|
}
|
|
13967
14035
|
}, []);
|
|
13968
|
-
(0,
|
|
14036
|
+
(0, import_react30.useEffect)(() => {
|
|
13969
14037
|
setAddOns((prevAddOns) => {
|
|
13970
14038
|
return availableAddOns.filter((availAddOn) => {
|
|
13971
14039
|
if (!selectedPlan) {
|
|
@@ -13987,7 +14055,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
13987
14055
|
});
|
|
13988
14056
|
});
|
|
13989
14057
|
}, [availableAddOns, data?.addOnCompatibilities, selectedPlan]);
|
|
13990
|
-
(0,
|
|
14058
|
+
(0, import_react30.useEffect)(() => {
|
|
13991
14059
|
if (charges) {
|
|
13992
14060
|
checkoutRef.current?.scrollTo({
|
|
13993
14061
|
top: 0,
|
|
@@ -13996,7 +14064,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
13996
14064
|
});
|
|
13997
14065
|
}
|
|
13998
14066
|
}, [charges]);
|
|
13999
|
-
(0,
|
|
14067
|
+
(0, import_react30.useLayoutEffect)(() => {
|
|
14000
14068
|
contentRef.current?.scrollTo({
|
|
14001
14069
|
top: 0,
|
|
14002
14070
|
left: 0,
|
|
@@ -14171,11 +14239,11 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
14171
14239
|
};
|
|
14172
14240
|
|
|
14173
14241
|
// src/components/shared/payment-dialog/PaymentDialog.tsx
|
|
14174
|
-
var
|
|
14242
|
+
var import_react31 = require("react");
|
|
14175
14243
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
14176
14244
|
var PaymentDialog = ({ top = 0 }) => {
|
|
14177
14245
|
const { t: t2 } = useTranslation();
|
|
14178
|
-
const contentRef = (0,
|
|
14246
|
+
const contentRef = (0, import_react31.useRef)(null);
|
|
14179
14247
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Modal2, { size: "md", top, contentRef, children: [
|
|
14180
14248
|
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ModalHeader, { bordered: true, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Text, { $size: 18, children: t2("Edit payment method") }) }),
|
|
14181
14249
|
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PaymentMethodDetails, {})
|
|
@@ -14184,16 +14252,16 @@ var PaymentDialog = ({ top = 0 }) => {
|
|
|
14184
14252
|
|
|
14185
14253
|
// src/components/shared/payment-form/PaymentForm.tsx
|
|
14186
14254
|
var import_react_stripe_js = require("@stripe/react-stripe-js");
|
|
14187
|
-
var
|
|
14255
|
+
var import_react32 = require("react");
|
|
14188
14256
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
14189
14257
|
var PaymentForm = ({ onConfirm }) => {
|
|
14190
14258
|
const { t: t2 } = useTranslation();
|
|
14191
14259
|
const stripe = (0, import_react_stripe_js.useStripe)();
|
|
14192
14260
|
const elements = (0, import_react_stripe_js.useElements)();
|
|
14193
|
-
const [message, setMessage] = (0,
|
|
14194
|
-
const [isLoading, setIsLoading] = (0,
|
|
14195
|
-
const [isConfirmed, setIsConfirmed] = (0,
|
|
14196
|
-
const [isComplete, setIsComplete] = (0,
|
|
14261
|
+
const [message, setMessage] = (0, import_react32.useState)();
|
|
14262
|
+
const [isLoading, setIsLoading] = (0, import_react32.useState)(false);
|
|
14263
|
+
const [isConfirmed, setIsConfirmed] = (0, import_react32.useState)(false);
|
|
14264
|
+
const [isComplete, setIsComplete] = (0, import_react32.useState)(false);
|
|
14197
14265
|
const handleSubmit = async (event) => {
|
|
14198
14266
|
event.preventDefault();
|
|
14199
14267
|
if (!stripe || !elements) {
|
|
@@ -14264,7 +14332,7 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
14264
14332
|
};
|
|
14265
14333
|
|
|
14266
14334
|
// src/components/shared/period-toggle/PeriodToggle.tsx
|
|
14267
|
-
var
|
|
14335
|
+
var import_react33 = require("react");
|
|
14268
14336
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
14269
14337
|
var PeriodToggle = ({
|
|
14270
14338
|
options: options2,
|
|
@@ -14275,7 +14343,7 @@ var PeriodToggle = ({
|
|
|
14275
14343
|
const { t: t2 } = useTranslation();
|
|
14276
14344
|
const { settings } = useEmbed();
|
|
14277
14345
|
const isLightBackground = useIsLightBackground();
|
|
14278
|
-
const savingsPercentage = (0,
|
|
14346
|
+
const savingsPercentage = (0, import_react33.useMemo)(() => {
|
|
14279
14347
|
if (selectedPlan) {
|
|
14280
14348
|
const monthlyBillingPrice = getPlanPrice(selectedPlan, "month");
|
|
14281
14349
|
const yearlyBillingPrice = getPlanPrice(selectedPlan, "year");
|
|
@@ -14355,10 +14423,10 @@ var PeriodToggle = ({
|
|
|
14355
14423
|
};
|
|
14356
14424
|
|
|
14357
14425
|
// src/components/shared/pricing-tiers-tooltip/PricingTiersTooltip.tsx
|
|
14358
|
-
var
|
|
14426
|
+
var import_react35 = require("react");
|
|
14359
14427
|
|
|
14360
14428
|
// src/components/shared/pricing-tiers-tooltip/PriceText.tsx
|
|
14361
|
-
var
|
|
14429
|
+
var import_react34 = require("react");
|
|
14362
14430
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
14363
14431
|
var PriceText = ({
|
|
14364
14432
|
feature,
|
|
@@ -14367,7 +14435,7 @@ var PriceText = ({
|
|
|
14367
14435
|
flatAmount = 0,
|
|
14368
14436
|
perUnitPrice = 0
|
|
14369
14437
|
}) => {
|
|
14370
|
-
const text = (0,
|
|
14438
|
+
const text = (0, import_react34.useMemo)(() => {
|
|
14371
14439
|
if (!flatAmount && perUnitPrice) {
|
|
14372
14440
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
14373
14441
|
formatCurrency(perUnitPrice, currency),
|
|
@@ -14415,7 +14483,7 @@ var PricingTiersTooltip = ({
|
|
|
14415
14483
|
const { t: t2 } = useTranslation();
|
|
14416
14484
|
const { settings } = useEmbed();
|
|
14417
14485
|
const isLightBackground = useIsLightBackground();
|
|
14418
|
-
const tiers = (0,
|
|
14486
|
+
const tiers = (0, import_react35.useMemo)(() => {
|
|
14419
14487
|
let start = 1;
|
|
14420
14488
|
return priceTiers.map((tier) => {
|
|
14421
14489
|
const { upTo, ...rest } = tier;
|
|
@@ -14474,7 +14542,7 @@ var PricingTiersTooltip = ({
|
|
|
14474
14542
|
index
|
|
14475
14543
|
);
|
|
14476
14544
|
}) }),
|
|
14477
|
-
tiersMode && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
14545
|
+
(tiersMode === "volume" /* Volume */ || tiersMode === "graduated" /* Graduated */) && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
14478
14546
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
14479
14547
|
"hr",
|
|
14480
14548
|
{
|
|
@@ -14488,7 +14556,7 @@ var PricingTiersTooltip = ({
|
|
|
14488
14556
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Text, { children: [
|
|
14489
14557
|
"\u2139\uFE0F",
|
|
14490
14558
|
" ",
|
|
14491
|
-
tiersMode === "volume" ? t2("Price by unit based on final tier reached.") : t2("Tiers apply progressively as quantity increases.")
|
|
14559
|
+
tiersMode === "volume" /* Volume */ ? t2("Price by unit based on final tier reached.") : t2("Tiers apply progressively as quantity increases.")
|
|
14492
14560
|
] }) })
|
|
14493
14561
|
] })
|
|
14494
14562
|
] }),
|
|
@@ -14499,13 +14567,13 @@ var PricingTiersTooltip = ({
|
|
|
14499
14567
|
};
|
|
14500
14568
|
|
|
14501
14569
|
// src/components/shared/tiered-pricing-details/TieredPricingDetails.tsx
|
|
14502
|
-
var
|
|
14570
|
+
var import_react36 = require("react");
|
|
14503
14571
|
var TieredPricingDetails = ({
|
|
14504
14572
|
entitlement,
|
|
14505
14573
|
period
|
|
14506
14574
|
}) => {
|
|
14507
14575
|
const { t: t2 } = useTranslation();
|
|
14508
|
-
const { currency, flatAmount, perUnitPrice, upTo } = (0,
|
|
14576
|
+
const { currency, flatAmount, perUnitPrice, upTo } = (0, import_react36.useMemo)(() => {
|
|
14509
14577
|
const { currency: currency2, priceTier } = getEntitlementPrice(entitlement, period) || {};
|
|
14510
14578
|
const { flatAmount: flatAmount2, perUnitPrice: perUnitPrice2, perUnitPriceDecimal, upTo: upTo2 } = priceTier?.[0] || {};
|
|
14511
14579
|
return {
|
|
@@ -14553,15 +14621,15 @@ var TieredPricingDetails = ({
|
|
|
14553
14621
|
};
|
|
14554
14622
|
|
|
14555
14623
|
// src/components/shared/unsubscribe-dialog/UnsubscribeDialog.tsx
|
|
14556
|
-
var
|
|
14624
|
+
var import_react37 = require("react");
|
|
14557
14625
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
14558
14626
|
var UnsubscribeDialog = ({ top = 0 }) => {
|
|
14559
14627
|
const { t: t2 } = useTranslation();
|
|
14560
14628
|
const { data, setCheckoutState } = useEmbed();
|
|
14561
|
-
const contentRef = (0,
|
|
14562
|
-
const [error, setError] = (0,
|
|
14563
|
-
const [isLoading, setIsLoading] = (0,
|
|
14564
|
-
const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = (0,
|
|
14629
|
+
const contentRef = (0, import_react37.useRef)(null);
|
|
14630
|
+
const [error, setError] = (0, import_react37.useState)();
|
|
14631
|
+
const [isLoading, setIsLoading] = (0, import_react37.useState)(false);
|
|
14632
|
+
const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = (0, import_react37.useMemo)(() => {
|
|
14565
14633
|
if (isCheckoutData(data)) {
|
|
14566
14634
|
return {
|
|
14567
14635
|
planPeriod: data.company?.plan?.planPeriod || "month",
|
|
@@ -14582,7 +14650,7 @@ var UnsubscribeDialog = ({ top = 0 }) => {
|
|
|
14582
14650
|
};
|
|
14583
14651
|
}, [data]);
|
|
14584
14652
|
const { plans: availablePlans, addOns: availableAddOns } = useAvailablePlans(planPeriod);
|
|
14585
|
-
const selectedPlan = (0,
|
|
14653
|
+
const selectedPlan = (0, import_react37.useMemo)(
|
|
14586
14654
|
() => availablePlans.find((plan) => plan.id === currentPlan?.id),
|
|
14587
14655
|
[currentPlan?.id, availablePlans]
|
|
14588
14656
|
);
|
|
@@ -14591,7 +14659,7 @@ var UnsubscribeDialog = ({ top = 0 }) => {
|
|
|
14591
14659
|
createActiveUsageBasedEntitlementsReducer(currentEntitlements, planPeriod),
|
|
14592
14660
|
[]
|
|
14593
14661
|
);
|
|
14594
|
-
const addOns = (0,
|
|
14662
|
+
const addOns = (0, import_react37.useMemo)(
|
|
14595
14663
|
() => availableAddOns.map((available) => ({
|
|
14596
14664
|
...available,
|
|
14597
14665
|
isSelected: currentAddOns.some((current) => available.id === current.id) ?? false
|
|
@@ -14628,9 +14696,9 @@ var UnsubscribeDialog = ({ top = 0 }) => {
|
|
|
14628
14696
|
"You will retain access to your plan until the end of the billing period, on"
|
|
14629
14697
|
),
|
|
14630
14698
|
" ",
|
|
14631
|
-
|
|
14699
|
+
toPrettyDate(cancelDate, {
|
|
14632
14700
|
month: "numeric"
|
|
14633
|
-
})
|
|
14701
|
+
})
|
|
14634
14702
|
] })
|
|
14635
14703
|
] }),
|
|
14636
14704
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(Flex, { $flexDirection: "column", $flexWrap: "wrap", $gap: "0.5rem", children: [
|
|
@@ -14830,17 +14898,17 @@ var StyledViewport = dt.div.withConfig({
|
|
|
14830
14898
|
|
|
14831
14899
|
// src/components/layout/viewport/Viewport.tsx
|
|
14832
14900
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
14833
|
-
var Viewport = (0,
|
|
14901
|
+
var Viewport = (0, import_react38.forwardRef)(
|
|
14834
14902
|
({ children, portal, ...props }, ref) => {
|
|
14835
14903
|
const { data, layout, settings } = useEmbed();
|
|
14836
|
-
const [top, setTop] = (0,
|
|
14837
|
-
const { canCheckout, isBadgeVisible } = (0,
|
|
14904
|
+
const [top, setTop] = (0, import_react38.useState)(0);
|
|
14905
|
+
const { canCheckout, isBadgeVisible } = (0, import_react38.useMemo)(() => {
|
|
14838
14906
|
return {
|
|
14839
14907
|
canCheckout: data?.capabilities?.checkout ?? true,
|
|
14840
14908
|
isBadgeVisible: !data?.capabilities?.badgeVisibility || settings.badge?.visibility !== "hidden"
|
|
14841
14909
|
};
|
|
14842
14910
|
}, [data, settings]);
|
|
14843
|
-
(0,
|
|
14911
|
+
(0, import_react38.useLayoutEffect)(() => {
|
|
14844
14912
|
const parent = portal || document.body;
|
|
14845
14913
|
const setModalY = (0, import_debounce3.default)(() => {
|
|
14846
14914
|
const value = Math.abs(
|
|
@@ -14887,7 +14955,7 @@ var resolveDesignProps = (props) => {
|
|
|
14887
14955
|
}
|
|
14888
14956
|
};
|
|
14889
14957
|
};
|
|
14890
|
-
var ButtonElement = (0,
|
|
14958
|
+
var ButtonElement = (0, import_react39.forwardRef)(({ children, className, ...rest }, ref) => {
|
|
14891
14959
|
const props = resolveDesignProps(rest);
|
|
14892
14960
|
const buttonStyles2 = {
|
|
14893
14961
|
primary: {
|
|
@@ -14932,10 +15000,10 @@ var ButtonElement = (0, import_react38.forwardRef)(({ children, className, ...re
|
|
|
14932
15000
|
ButtonElement.displayName = "Button";
|
|
14933
15001
|
|
|
14934
15002
|
// src/components/elements/included-features/IncludedFeatures.tsx
|
|
14935
|
-
var
|
|
15003
|
+
var import_react41 = require("react");
|
|
14936
15004
|
|
|
14937
15005
|
// src/components/elements/included-features/UsageDetails.tsx
|
|
14938
|
-
var
|
|
15006
|
+
var import_react40 = require("react");
|
|
14939
15007
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
14940
15008
|
var UsageDetails = ({
|
|
14941
15009
|
entitlement,
|
|
@@ -14952,14 +15020,14 @@ var UsageDetails = ({
|
|
|
14952
15020
|
} = entitlement;
|
|
14953
15021
|
const { t: t2 } = useTranslation();
|
|
14954
15022
|
const { data } = useEmbed();
|
|
14955
|
-
const period = (0,
|
|
15023
|
+
const period = (0, import_react40.useMemo)(() => {
|
|
14956
15024
|
return isCheckoutData(data) && typeof data.company?.plan?.planPeriod === "string" ? data.company.plan.planPeriod : void 0;
|
|
14957
15025
|
}, [data]);
|
|
14958
|
-
const { billingPrice, cost, currentTier } = (0,
|
|
15026
|
+
const { billingPrice, cost, currentTier } = (0, import_react40.useMemo)(
|
|
14959
15027
|
() => getUsageDetails(entitlement, period),
|
|
14960
15028
|
[entitlement, period]
|
|
14961
15029
|
);
|
|
14962
|
-
const text = (0,
|
|
15030
|
+
const text = (0, import_react40.useMemo)(() => {
|
|
14963
15031
|
if (!feature) {
|
|
14964
15032
|
return;
|
|
14965
15033
|
}
|
|
@@ -15019,7 +15087,7 @@ var UsageDetails = ({
|
|
|
15019
15087
|
billingPrice,
|
|
15020
15088
|
currentTier?.to
|
|
15021
15089
|
]);
|
|
15022
|
-
const usageText = (0,
|
|
15090
|
+
const usageText = (0, import_react40.useMemo)(() => {
|
|
15023
15091
|
if (!feature) {
|
|
15024
15092
|
return;
|
|
15025
15093
|
}
|
|
@@ -15028,7 +15096,7 @@ var UsageDetails = ({
|
|
|
15028
15096
|
let index = 0;
|
|
15029
15097
|
if (priceBehavior === "pay_in_advance" /* PayInAdvance */ && typeof period === "string" && typeof price === "number") {
|
|
15030
15098
|
acc.push(
|
|
15031
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
15099
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react40.Fragment, { children: [
|
|
15032
15100
|
formatCurrency(price, currency),
|
|
15033
15101
|
"/",
|
|
15034
15102
|
packageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
|
|
@@ -15043,7 +15111,7 @@ var UsageDetails = ({
|
|
|
15043
15111
|
index += 1;
|
|
15044
15112
|
} else if ((priceBehavior === "pay_as_you_go" /* PayAsYouGo */ || priceBehavior === "overage" /* Overage */ || priceBehavior === "tier" /* Tiered */) && typeof usage === "number") {
|
|
15045
15113
|
acc.push(
|
|
15046
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
15114
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react40.Fragment, { children: [
|
|
15047
15115
|
usage,
|
|
15048
15116
|
" ",
|
|
15049
15117
|
getFeatureName(feature, usage),
|
|
@@ -15056,14 +15124,14 @@ var UsageDetails = ({
|
|
|
15056
15124
|
if (acc) {
|
|
15057
15125
|
if (typeof cost === "number" && cost > 0) {
|
|
15058
15126
|
acc.push(
|
|
15059
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
15127
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react40.Fragment, { children: [
|
|
15060
15128
|
" \u2022 ",
|
|
15061
15129
|
formatCurrency(cost, currency)
|
|
15062
15130
|
] }, index)
|
|
15063
15131
|
);
|
|
15064
15132
|
index += 1;
|
|
15065
15133
|
if (feature.featureType === "trait" /* Trait */ && typeof period === "string") {
|
|
15066
|
-
acc.push(/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
15134
|
+
acc.push(/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react40.Fragment, { children: [
|
|
15067
15135
|
"/",
|
|
15068
15136
|
shortenPeriod(period)
|
|
15069
15137
|
] }, index));
|
|
@@ -15148,15 +15216,15 @@ function resolveDesignProps2(props) {
|
|
|
15148
15216
|
visibleFeatures: props.visibleFeatures
|
|
15149
15217
|
};
|
|
15150
15218
|
}
|
|
15151
|
-
var IncludedFeatures = (0,
|
|
15219
|
+
var IncludedFeatures = (0, import_react41.forwardRef)(({ className, ...rest }, ref) => {
|
|
15152
15220
|
const props = resolveDesignProps2(rest);
|
|
15153
15221
|
const { t: t2 } = useTranslation();
|
|
15154
15222
|
const { data, settings } = useEmbed();
|
|
15155
|
-
const elements = (0,
|
|
15223
|
+
const elements = (0, import_react41.useRef)([]);
|
|
15156
15224
|
const shouldWrapChildren = useWrapChildren(elements.current);
|
|
15157
15225
|
const isLightBackground = useIsLightBackground();
|
|
15158
|
-
const [showCount, setShowCount] = (0,
|
|
15159
|
-
const { plan, addOns, featureUsage } = (0,
|
|
15226
|
+
const [showCount, setShowCount] = (0, import_react41.useState)(VISIBLE_ENTITLEMENT_COUNT);
|
|
15227
|
+
const { plan, addOns, featureUsage } = (0, import_react41.useMemo)(() => {
|
|
15160
15228
|
if (isCheckoutData(data)) {
|
|
15161
15229
|
const orderedFeatureUsage = props.visibleFeatures?.reduce(
|
|
15162
15230
|
(acc, id) => {
|
|
@@ -15292,7 +15360,7 @@ var IncludedFeatures = (0, import_react40.forwardRef)(({ className, ...rest }, r
|
|
|
15292
15360
|
IncludedFeatures.displayName = "IncludedFeatures";
|
|
15293
15361
|
|
|
15294
15362
|
// src/components/elements/invoices/Invoices.tsx
|
|
15295
|
-
var
|
|
15363
|
+
var import_react42 = require("react");
|
|
15296
15364
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
15297
15365
|
function resolveDesignProps3(props) {
|
|
15298
15366
|
return {
|
|
@@ -15325,15 +15393,15 @@ function formatInvoices(invoices) {
|
|
|
15325
15393
|
url: url || void 0
|
|
15326
15394
|
}));
|
|
15327
15395
|
}
|
|
15328
|
-
var Invoices = (0,
|
|
15396
|
+
var Invoices = (0, import_react42.forwardRef)(({ className, data, ...rest }, ref) => {
|
|
15329
15397
|
const props = resolveDesignProps3(rest);
|
|
15330
15398
|
const { t: t2 } = useTranslation();
|
|
15331
15399
|
const { listInvoices, settings } = useEmbed();
|
|
15332
|
-
const [isLoading, setIsLoading] = (0,
|
|
15333
|
-
const [error, setError] = (0,
|
|
15334
|
-
const [invoices, setInvoices] = (0,
|
|
15335
|
-
const [listSize, setListSize] = (0,
|
|
15336
|
-
const getInvoices = (0,
|
|
15400
|
+
const [isLoading, setIsLoading] = (0, import_react42.useState)(false);
|
|
15401
|
+
const [error, setError] = (0, import_react42.useState)();
|
|
15402
|
+
const [invoices, setInvoices] = (0, import_react42.useState)(() => formatInvoices(data));
|
|
15403
|
+
const [listSize, setListSize] = (0, import_react42.useState)(props.limit.number);
|
|
15404
|
+
const getInvoices = (0, import_react42.useCallback)(async () => {
|
|
15337
15405
|
try {
|
|
15338
15406
|
setError(void 0);
|
|
15339
15407
|
setIsLoading(true);
|
|
@@ -15352,10 +15420,10 @@ var Invoices = (0, import_react41.forwardRef)(({ className, data, ...rest }, ref
|
|
|
15352
15420
|
(prev2) => prev2 !== props.limit.number ? props.limit.number : MAX_VISIBLE_INVOICE_COUNT
|
|
15353
15421
|
);
|
|
15354
15422
|
};
|
|
15355
|
-
(0,
|
|
15423
|
+
(0, import_react42.useEffect)(() => {
|
|
15356
15424
|
getInvoices();
|
|
15357
15425
|
}, [getInvoices]);
|
|
15358
|
-
(0,
|
|
15426
|
+
(0, import_react42.useEffect)(() => {
|
|
15359
15427
|
setInvoices(formatInvoices(data));
|
|
15360
15428
|
}, [data]);
|
|
15361
15429
|
if (invoices.length === 0) {
|
|
@@ -15435,7 +15503,7 @@ var Invoices = (0, import_react41.forwardRef)(({ className, data, ...rest }, ref
|
|
|
15435
15503
|
Invoices.displayName = "Invoices";
|
|
15436
15504
|
|
|
15437
15505
|
// src/components/elements/metered-features/MeteredFeatures.tsx
|
|
15438
|
-
var
|
|
15506
|
+
var import_react43 = require("react");
|
|
15439
15507
|
|
|
15440
15508
|
// src/components/elements/metered-features/Meter.tsx
|
|
15441
15509
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
@@ -15486,7 +15554,7 @@ var PriceDetails = ({
|
|
|
15486
15554
|
tiersMode: billingPrice?.tiersMode || void 0,
|
|
15487
15555
|
currentTierPerUnitPrice: typeof currentTier?.perUnitPriceDecimal === "string" ? Number(currentTier?.perUnitPriceDecimal) : currentTier?.perUnitPrice
|
|
15488
15556
|
};
|
|
15489
|
-
if (
|
|
15557
|
+
if (!feature || typeof currentTierPerUnitPrice !== "number") {
|
|
15490
15558
|
return null;
|
|
15491
15559
|
}
|
|
15492
15560
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
@@ -15633,14 +15701,14 @@ function resolveDesignProps4(props) {
|
|
|
15633
15701
|
visibleFeatures: props.visibleFeatures
|
|
15634
15702
|
};
|
|
15635
15703
|
}
|
|
15636
|
-
var MeteredFeatures = (0,
|
|
15704
|
+
var MeteredFeatures = (0, import_react43.forwardRef)(({ className, ...rest }, ref) => {
|
|
15637
15705
|
const props = resolveDesignProps4(rest);
|
|
15638
|
-
const elements = (0,
|
|
15706
|
+
const elements = (0, import_react43.useRef)([]);
|
|
15639
15707
|
const shouldWrapChildren = useWrapChildren(elements.current);
|
|
15640
15708
|
const { t: t2 } = useTranslation();
|
|
15641
15709
|
const { data, settings, setCheckoutState } = useEmbed();
|
|
15642
15710
|
const isLightBackground = useIsLightBackground();
|
|
15643
|
-
const { meteredFeatures, period } = (0,
|
|
15711
|
+
const { meteredFeatures, period } = (0, import_react43.useMemo)(() => {
|
|
15644
15712
|
if (isCheckoutData(data)) {
|
|
15645
15713
|
const period2 = typeof data.company?.plan?.planPeriod === "string" ? data.company?.plan?.planPeriod : void 0;
|
|
15646
15714
|
const orderedFeatureUsage = props.visibleFeatures?.reduce(
|
|
@@ -15776,10 +15844,10 @@ var MeteredFeatures = (0, import_react42.forwardRef)(({ className, ...rest }, re
|
|
|
15776
15844
|
MeteredFeatures.displayName = "MeteredFeatures";
|
|
15777
15845
|
|
|
15778
15846
|
// src/components/elements/payment-method/PaymentMethod.tsx
|
|
15779
|
-
var
|
|
15847
|
+
var import_react45 = require("react");
|
|
15780
15848
|
|
|
15781
15849
|
// src/components/elements/payment-method/PaymentMethodElement.tsx
|
|
15782
|
-
var
|
|
15850
|
+
var import_react44 = require("react");
|
|
15783
15851
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
15784
15852
|
var PaymentElement2 = ({
|
|
15785
15853
|
iconName,
|
|
@@ -15899,7 +15967,7 @@ var PaymentListElement = ({
|
|
|
15899
15967
|
}) => {
|
|
15900
15968
|
const isLightBackground = useIsLightBackground();
|
|
15901
15969
|
const { iconName, iconTitle, label, paymentLast4 } = getPaymentMethodData(paymentMethod);
|
|
15902
|
-
const expirationDate = (0,
|
|
15970
|
+
const expirationDate = (0, import_react44.useMemo)(() => {
|
|
15903
15971
|
const { cardExpMonth, cardExpYear } = paymentMethod;
|
|
15904
15972
|
if (!cardExpMonth || !cardExpYear) {
|
|
15905
15973
|
return;
|
|
@@ -15984,10 +16052,10 @@ var resolveDesignProps5 = (props) => {
|
|
|
15984
16052
|
}
|
|
15985
16053
|
};
|
|
15986
16054
|
};
|
|
15987
|
-
var PaymentMethod = (0,
|
|
16055
|
+
var PaymentMethod = (0, import_react45.forwardRef)(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
|
|
15988
16056
|
const props = resolveDesignProps5(rest);
|
|
15989
16057
|
const { data, setLayout } = useEmbed();
|
|
15990
|
-
const { paymentMethod, monthsToExpiration } = (0,
|
|
16058
|
+
const { paymentMethod, monthsToExpiration } = (0, import_react45.useMemo)(() => {
|
|
15991
16059
|
if (isCheckoutData(data)) {
|
|
15992
16060
|
const paymentMethod2 = data.subscription?.paymentMethod || data.company?.defaultPaymentMethod;
|
|
15993
16061
|
let monthsToExpiration2;
|
|
@@ -16068,7 +16136,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
16068
16136
|
}
|
|
16069
16137
|
stripe._registerWrapper({
|
|
16070
16138
|
name: "stripe-js",
|
|
16071
|
-
version: "7.
|
|
16139
|
+
version: "7.6.1",
|
|
16072
16140
|
startTime
|
|
16073
16141
|
});
|
|
16074
16142
|
};
|
|
@@ -16143,7 +16211,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
|
16143
16211
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
16144
16212
|
var expectedVersion = RELEASE_TRAIN;
|
|
16145
16213
|
if (isTestKey && version !== expectedVersion) {
|
|
16146
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.
|
|
16214
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.6.1", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
16147
16215
|
}
|
|
16148
16216
|
var stripe = maybeStripe.apply(void 0, args);
|
|
16149
16217
|
registerWrapper(stripe, startTime);
|
|
@@ -16180,7 +16248,7 @@ var loadStripe = function loadStripe2() {
|
|
|
16180
16248
|
};
|
|
16181
16249
|
|
|
16182
16250
|
// src/components/elements/payment-method/PaymentMethodDetails.tsx
|
|
16183
|
-
var
|
|
16251
|
+
var import_react46 = require("react");
|
|
16184
16252
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
16185
16253
|
var resolveDesignProps6 = () => {
|
|
16186
16254
|
return {
|
|
@@ -16206,7 +16274,7 @@ var PaymentMethodDetails = ({
|
|
|
16206
16274
|
updatePaymentMethod,
|
|
16207
16275
|
deletePaymentMethod
|
|
16208
16276
|
} = useEmbed();
|
|
16209
|
-
const { defaultPaymentMethod, paymentMethods, subscription } = (0,
|
|
16277
|
+
const { defaultPaymentMethod, paymentMethods, subscription } = (0, import_react46.useMemo)(() => {
|
|
16210
16278
|
if (isCheckoutData(data)) {
|
|
16211
16279
|
return {
|
|
16212
16280
|
defaultPaymentMethod: data.company?.defaultPaymentMethod,
|
|
@@ -16221,14 +16289,14 @@ var PaymentMethodDetails = ({
|
|
|
16221
16289
|
};
|
|
16222
16290
|
}, [data]);
|
|
16223
16291
|
const isLightBackground = useIsLightBackground();
|
|
16224
|
-
const [isLoading, setIsLoading] = (0,
|
|
16225
|
-
const [error, setError] = (0,
|
|
16226
|
-
const [showPaymentForm, setShowPaymentForm] = (0,
|
|
16227
|
-
const [stripe, setStripe] = (0,
|
|
16228
|
-
const [setupIntent, setSetupIntent] = (0,
|
|
16229
|
-
const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0,
|
|
16230
|
-
const [currentPaymentMethod, setCurrentPaymentMethod] = (0,
|
|
16231
|
-
const monthsToExpiration = (0,
|
|
16292
|
+
const [isLoading, setIsLoading] = (0, import_react46.useState)(false);
|
|
16293
|
+
const [error, setError] = (0, import_react46.useState)();
|
|
16294
|
+
const [showPaymentForm, setShowPaymentForm] = (0, import_react46.useState)(false);
|
|
16295
|
+
const [stripe, setStripe] = (0, import_react46.useState)(null);
|
|
16296
|
+
const [setupIntent, setSetupIntent] = (0, import_react46.useState)();
|
|
16297
|
+
const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react46.useState)(false);
|
|
16298
|
+
const [currentPaymentMethod, setCurrentPaymentMethod] = (0, import_react46.useState)(subscription?.paymentMethod || defaultPaymentMethod);
|
|
16299
|
+
const monthsToExpiration = (0, import_react46.useMemo)(() => {
|
|
16232
16300
|
let expiration;
|
|
16233
16301
|
if (typeof currentPaymentMethod?.cardExpYear === "number" && typeof currentPaymentMethod?.cardExpMonth === "number") {
|
|
16234
16302
|
const today = /* @__PURE__ */ new Date();
|
|
@@ -16251,7 +16319,7 @@ var PaymentMethodDetails = ({
|
|
|
16251
16319
|
const toggleShowPaymentMethods = () => {
|
|
16252
16320
|
setShowDifferentPaymentMethods((prev2) => !prev2);
|
|
16253
16321
|
};
|
|
16254
|
-
const initializePaymentMethod = (0,
|
|
16322
|
+
const initializePaymentMethod = (0, import_react46.useCallback)(async () => {
|
|
16255
16323
|
try {
|
|
16256
16324
|
setIsLoading(true);
|
|
16257
16325
|
const response = await createSetupIntent();
|
|
@@ -16267,7 +16335,7 @@ var PaymentMethodDetails = ({
|
|
|
16267
16335
|
setIsLoading(false);
|
|
16268
16336
|
}
|
|
16269
16337
|
}, [t2, createSetupIntent]);
|
|
16270
|
-
const handleUpdatePaymentMethod = (0,
|
|
16338
|
+
const handleUpdatePaymentMethod = (0, import_react46.useCallback)(
|
|
16271
16339
|
async (paymentMethodId) => {
|
|
16272
16340
|
try {
|
|
16273
16341
|
setIsLoading(true);
|
|
@@ -16286,7 +16354,7 @@ var PaymentMethodDetails = ({
|
|
|
16286
16354
|
},
|
|
16287
16355
|
[t2, setPaymentMethodId, updatePaymentMethod]
|
|
16288
16356
|
);
|
|
16289
|
-
const handleDeletePaymentMethod = (0,
|
|
16357
|
+
const handleDeletePaymentMethod = (0, import_react46.useCallback)(
|
|
16290
16358
|
async (paymentMethodId) => {
|
|
16291
16359
|
try {
|
|
16292
16360
|
setIsLoading(true);
|
|
@@ -16299,12 +16367,17 @@ var PaymentMethodDetails = ({
|
|
|
16299
16367
|
},
|
|
16300
16368
|
[t2, deletePaymentMethod]
|
|
16301
16369
|
);
|
|
16302
|
-
(0,
|
|
16303
|
-
if (!stripe && setupIntent
|
|
16304
|
-
|
|
16370
|
+
(0, import_react46.useEffect)(() => {
|
|
16371
|
+
if (!stripe && setupIntent) {
|
|
16372
|
+
const publishableKey = setupIntent.publishableKey || setupIntent.schematicPublishableKey;
|
|
16373
|
+
const stripeOptions = {};
|
|
16374
|
+
if (setupIntent.accountId) {
|
|
16375
|
+
stripeOptions.stripeAccount = setupIntent.accountId;
|
|
16376
|
+
}
|
|
16377
|
+
setStripe(loadStripe(publishableKey, stripeOptions));
|
|
16305
16378
|
}
|
|
16306
|
-
}, [stripe, setupIntent
|
|
16307
|
-
(0,
|
|
16379
|
+
}, [stripe, setupIntent]);
|
|
16380
|
+
(0, import_react46.useEffect)(() => {
|
|
16308
16381
|
if (!setupIntent && (!currentPaymentMethod || showPaymentForm)) {
|
|
16309
16382
|
initializePaymentMethod();
|
|
16310
16383
|
}
|
|
@@ -16440,7 +16513,7 @@ var PaymentMethodDetails = ({
|
|
|
16440
16513
|
},
|
|
16441
16514
|
paymentMethod.id
|
|
16442
16515
|
)) }),
|
|
16443
|
-
(!setupIntent || !currentPaymentMethod
|
|
16516
|
+
(!setupIntent || !currentPaymentMethod) && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
16444
16517
|
Button,
|
|
16445
16518
|
{
|
|
16446
16519
|
type: "button",
|
|
@@ -16460,7 +16533,7 @@ var PaymentMethodDetails = ({
|
|
|
16460
16533
|
};
|
|
16461
16534
|
|
|
16462
16535
|
// src/components/elements/plan-manager/PlanManager.tsx
|
|
16463
|
-
var
|
|
16536
|
+
var import_react48 = require("react");
|
|
16464
16537
|
|
|
16465
16538
|
// src/components/elements/plan-manager/AddOn.tsx
|
|
16466
16539
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
@@ -16474,7 +16547,7 @@ var AddOn = ({ addOn, currency, layout }) => {
|
|
|
16474
16547
|
$gap: "1rem",
|
|
16475
16548
|
children: [
|
|
16476
16549
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Text, { display: layout.addOns.fontStyle, children: addOn.name }),
|
|
16477
|
-
addOn.planPrice && addOn.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(Text, { children: [
|
|
16550
|
+
typeof addOn.planPrice === "number" && addOn.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(Text, { children: [
|
|
16478
16551
|
formatCurrency(addOn.planPrice, currency),
|
|
16479
16552
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("sub", { children: addOn.planPeriod == "one-time" ? shortenPeriod(addOn.planPeriod) : `/${shortenPeriod(addOn.planPeriod)}` })
|
|
16480
16553
|
] })
|
|
@@ -16484,7 +16557,7 @@ var AddOn = ({ addOn, currency, layout }) => {
|
|
|
16484
16557
|
};
|
|
16485
16558
|
|
|
16486
16559
|
// src/components/elements/plan-manager/UsageDetails.tsx
|
|
16487
|
-
var
|
|
16560
|
+
var import_react47 = require("react");
|
|
16488
16561
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
16489
16562
|
var UsageDetails2 = ({
|
|
16490
16563
|
entitlement,
|
|
@@ -16498,18 +16571,18 @@ var UsageDetails2 = ({
|
|
|
16498
16571
|
limit,
|
|
16499
16572
|
amount = 0,
|
|
16500
16573
|
cost = 0
|
|
16501
|
-
} = (0,
|
|
16574
|
+
} = (0, import_react47.useMemo)(
|
|
16502
16575
|
() => getUsageDetails(entitlement, period),
|
|
16503
16576
|
[entitlement, period]
|
|
16504
16577
|
);
|
|
16505
|
-
const description = (0,
|
|
16578
|
+
const description = (0, import_react47.useMemo)(() => {
|
|
16506
16579
|
const acc = [];
|
|
16507
16580
|
let index = 0;
|
|
16508
16581
|
if (entitlement.priceBehavior === "overage" /* Overage */) {
|
|
16509
16582
|
acc.push(
|
|
16510
|
-
amount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
16583
|
+
amount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_react47.Fragment, { children: t2("X additional", {
|
|
16511
16584
|
amount
|
|
16512
|
-
}) }, index) : /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
16585
|
+
}) }, index) : /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_react47.Fragment, { children: [
|
|
16513
16586
|
t2("Additional"),
|
|
16514
16587
|
": "
|
|
16515
16588
|
] }, index)
|
|
@@ -16520,7 +16593,7 @@ var UsageDetails2 = ({
|
|
|
16520
16593
|
if (entitlement.priceBehavior !== "tier" /* Tiered */ && entitlement.feature && typeof price === "number" && !amount) {
|
|
16521
16594
|
const packageSize = billingPrice?.packageSize ?? 1;
|
|
16522
16595
|
acc.push(
|
|
16523
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
16596
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_react47.Fragment, { children: [
|
|
16524
16597
|
formatCurrency(price, billingPrice?.currency),
|
|
16525
16598
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("sub", { children: [
|
|
16526
16599
|
"/",
|
|
@@ -16621,12 +16694,12 @@ var resolveDesignProps7 = (props) => {
|
|
|
16621
16694
|
}
|
|
16622
16695
|
};
|
|
16623
16696
|
};
|
|
16624
|
-
var PlanManager = (0,
|
|
16697
|
+
var PlanManager = (0, import_react48.forwardRef)(({ children, className, portal, ...rest }, ref) => {
|
|
16625
16698
|
const props = resolveDesignProps7(rest);
|
|
16626
16699
|
const { t: t2 } = useTranslation();
|
|
16627
16700
|
const { data, settings, setCheckoutState } = useEmbed();
|
|
16628
16701
|
const isLightBackground = useIsLightBackground();
|
|
16629
|
-
const
|
|
16702
|
+
const trialEnd = useTrialEnd();
|
|
16630
16703
|
const {
|
|
16631
16704
|
currentPlan,
|
|
16632
16705
|
currentAddOns,
|
|
@@ -16635,7 +16708,7 @@ var PlanManager = (0, import_react47.forwardRef)(({ children, className, portal,
|
|
|
16635
16708
|
defaultPlan,
|
|
16636
16709
|
featureUsage,
|
|
16637
16710
|
trialPaymentMethodRequired
|
|
16638
|
-
} = (0,
|
|
16711
|
+
} = (0, import_react48.useMemo)(() => {
|
|
16639
16712
|
if (isCheckoutData(data)) {
|
|
16640
16713
|
return {
|
|
16641
16714
|
currentPlan: data.company?.plan,
|
|
@@ -16657,11 +16730,11 @@ var PlanManager = (0, import_react47.forwardRef)(({ children, className, portal,
|
|
|
16657
16730
|
trialPaymentMethodRequired: false
|
|
16658
16731
|
};
|
|
16659
16732
|
}, [data]);
|
|
16660
|
-
const usageBasedEntitlements = (0,
|
|
16733
|
+
const usageBasedEntitlements = (0, import_react48.useMemo)(
|
|
16661
16734
|
() => featureUsage.filter((usage) => typeof usage.priceBehavior === "string"),
|
|
16662
16735
|
[featureUsage]
|
|
16663
16736
|
);
|
|
16664
|
-
const { subscriptionCurrency, willSubscriptionCancel, isTrialSubscription } = (0,
|
|
16737
|
+
const { subscriptionCurrency, willSubscriptionCancel, isTrialSubscription } = (0, import_react48.useMemo)(() => {
|
|
16665
16738
|
const subscriptionCurrency2 = billingSubscription?.currency;
|
|
16666
16739
|
const isTrialSubscription2 = billingSubscription?.status === "trialing";
|
|
16667
16740
|
const willSubscriptionCancel2 = typeof billingSubscription?.cancelAt === "number" && billingSubscription?.cancelAtPeriodEnd === true;
|
|
@@ -16683,7 +16756,7 @@ var PlanManager = (0, import_react47.forwardRef)(({ children, className, portal,
|
|
|
16683
16756
|
$textAlign: "center",
|
|
16684
16757
|
$backgroundColor: isLightBackground ? darken(settings.theme.card.background, 0.04) : lighten(settings.theme.card.background, 0.04),
|
|
16685
16758
|
children: [
|
|
16686
|
-
|
|
16759
|
+
typeof trialEnd.formatted !== "undefined" && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Text, { as: "h3", display: "heading3", children: trialEnd.formatted }),
|
|
16687
16760
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Text, { as: "p", $size: 0.8125 * settings.theme.typography.text.fontSize, children: trialPaymentMethodRequired ? t2("After the trial, subscribe") : defaultPlan ? t2("After the trial, cancel", {
|
|
16688
16761
|
defaultPlanName: defaultPlan?.name
|
|
16689
16762
|
}) : t2("After the trial, cancel no default", {
|
|
@@ -16702,7 +16775,7 @@ var PlanManager = (0, import_react47.forwardRef)(({ children, className, portal,
|
|
|
16702
16775
|
$backgroundColor: isLightBackground ? darken(settings.theme.card.background, 0.04) : lighten(settings.theme.card.background, 0.04),
|
|
16703
16776
|
children: [
|
|
16704
16777
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Text, { as: "h3", display: "heading3", children: t2("Subscription canceled") }),
|
|
16705
|
-
billingSubscription?.cancelAt && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
16778
|
+
typeof billingSubscription?.cancelAt === "number" && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
16706
16779
|
Text,
|
|
16707
16780
|
{
|
|
16708
16781
|
as: "p",
|
|
@@ -16825,17 +16898,17 @@ var PlanManager = (0, import_react47.forwardRef)(({ children, className, portal,
|
|
|
16825
16898
|
PlanManager.displayName = "PlanManager";
|
|
16826
16899
|
|
|
16827
16900
|
// src/components/elements/pricing-table/PricingTable.tsx
|
|
16828
|
-
var
|
|
16901
|
+
var import_react51 = require("react");
|
|
16829
16902
|
|
|
16830
16903
|
// src/components/elements/pricing-table/AddOn.tsx
|
|
16831
|
-
var
|
|
16904
|
+
var import_react49 = require("react");
|
|
16832
16905
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
16833
16906
|
var AddOn2 = ({ addOn, sharedProps, selectedPeriod }) => {
|
|
16834
16907
|
const { layout } = sharedProps;
|
|
16835
16908
|
const { t: t2 } = useTranslation();
|
|
16836
16909
|
const { data, settings, setCheckoutState } = useEmbed();
|
|
16837
16910
|
const isLightBackground = useIsLightBackground();
|
|
16838
|
-
const { currentAddOns, canCheckout, isStandalone, showCallToAction } = (0,
|
|
16911
|
+
const { currentAddOns, canCheckout, isStandalone, showCallToAction } = (0, import_react49.useMemo)(() => {
|
|
16839
16912
|
if (isCheckoutData(data)) {
|
|
16840
16913
|
return {
|
|
16841
16914
|
currentAddOns: data.company?.addOns || [],
|
|
@@ -16998,7 +17071,7 @@ var AddOn2 = ({ addOn, sharedProps, selectedPeriod }) => {
|
|
|
16998
17071
|
};
|
|
16999
17072
|
|
|
17000
17073
|
// src/components/elements/pricing-table/Plan.tsx
|
|
17001
|
-
var
|
|
17074
|
+
var import_react50 = require("react");
|
|
17002
17075
|
|
|
17003
17076
|
// src/components/elements/pricing-table/Entitlement.tsx
|
|
17004
17077
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
@@ -17130,7 +17203,7 @@ var Plan2 = ({
|
|
|
17130
17203
|
const { t: t2 } = useTranslation();
|
|
17131
17204
|
const { data, settings, setCheckoutState } = useEmbed();
|
|
17132
17205
|
const isLightBackground = useIsLightBackground();
|
|
17133
|
-
const
|
|
17206
|
+
const trialEnd = useTrialEnd();
|
|
17134
17207
|
const {
|
|
17135
17208
|
currentPeriod,
|
|
17136
17209
|
canCheckout,
|
|
@@ -17138,11 +17211,11 @@ var Plan2 = ({
|
|
|
17138
17211
|
willSubscriptionCancel,
|
|
17139
17212
|
isStandalone,
|
|
17140
17213
|
showCallToAction
|
|
17141
|
-
} = (0,
|
|
17214
|
+
} = (0, import_react50.useMemo)(() => {
|
|
17142
17215
|
if (isCheckoutData(data)) {
|
|
17143
17216
|
const billingSubscription = data.company?.billingSubscription;
|
|
17144
17217
|
const isTrialSubscription2 = billingSubscription?.status === "trialing";
|
|
17145
|
-
const willSubscriptionCancel2 = billingSubscription?.cancelAt;
|
|
17218
|
+
const willSubscriptionCancel2 = typeof billingSubscription?.cancelAt === "number";
|
|
17146
17219
|
return {
|
|
17147
17220
|
currentPeriod: data.company?.plan?.planPeriod || "month",
|
|
17148
17221
|
canCheckout: data.capabilities?.checkout ?? true,
|
|
@@ -17234,7 +17307,7 @@ var Plan2 = ({
|
|
|
17234
17307
|
{
|
|
17235
17308
|
$size: 0.75 * settings.theme.typography.text.fontSize,
|
|
17236
17309
|
$color: hexToHSL(settings.theme.primary).l > 50 ? "#000000" : "#FFFFFF",
|
|
17237
|
-
children: isTrialSubscription && !willSubscriptionCancel &&
|
|
17310
|
+
children: isTrialSubscription && !willSubscriptionCancel && typeof trialEnd !== "undefined" ? trialEnd.formatted : t2("Active")
|
|
17238
17311
|
}
|
|
17239
17312
|
)
|
|
17240
17313
|
}
|
|
@@ -17413,11 +17486,11 @@ var resolveDesignProps8 = (props) => {
|
|
|
17413
17486
|
}
|
|
17414
17487
|
};
|
|
17415
17488
|
};
|
|
17416
|
-
var PricingTable = (0,
|
|
17489
|
+
var PricingTable = (0, import_react51.forwardRef)(({ className, callToActionUrl, onCallToAction, ...rest }, ref) => {
|
|
17417
17490
|
const props = resolveDesignProps8(rest);
|
|
17418
17491
|
const { t: t2 } = useTranslation();
|
|
17419
17492
|
const { data, settings, hydratePublic } = useEmbed();
|
|
17420
|
-
const { currentPeriod, isStandalone } = (0,
|
|
17493
|
+
const { currentPeriod, isStandalone } = (0, import_react51.useMemo)(() => {
|
|
17421
17494
|
if (isCheckoutData(data)) {
|
|
17422
17495
|
const billingSubscription = data.company?.billingSubscription;
|
|
17423
17496
|
const isTrialSubscription = billingSubscription?.status === "trialing";
|
|
@@ -17442,9 +17515,9 @@ var PricingTable = (0, import_react50.forwardRef)(({ className, callToActionUrl,
|
|
|
17442
17515
|
showCallToAction: typeof callToActionUrl === "string"
|
|
17443
17516
|
};
|
|
17444
17517
|
}, [data, callToActionUrl]);
|
|
17445
|
-
const [selectedPeriod, setSelectedPeriod] = (0,
|
|
17518
|
+
const [selectedPeriod, setSelectedPeriod] = (0, import_react51.useState)(currentPeriod);
|
|
17446
17519
|
const { plans, addOns, periods } = useAvailablePlans(selectedPeriod);
|
|
17447
|
-
const [entitlementCounts, setEntitlementCounts] = (0,
|
|
17520
|
+
const [entitlementCounts, setEntitlementCounts] = (0, import_react51.useState)(
|
|
17448
17521
|
() => plans.reduce(entitlementCountsReducer, {})
|
|
17449
17522
|
);
|
|
17450
17523
|
const handleToggleShowAll = (id) => {
|
|
@@ -17462,15 +17535,15 @@ var PricingTable = (0, import_react50.forwardRef)(({ className, callToActionUrl,
|
|
|
17462
17535
|
return prev2;
|
|
17463
17536
|
});
|
|
17464
17537
|
};
|
|
17465
|
-
(0,
|
|
17538
|
+
(0, import_react51.useEffect)(() => {
|
|
17466
17539
|
if (isStandalone) {
|
|
17467
17540
|
hydratePublic();
|
|
17468
17541
|
}
|
|
17469
17542
|
}, [isStandalone, hydratePublic]);
|
|
17470
|
-
(0,
|
|
17543
|
+
(0, import_react51.useEffect)(() => {
|
|
17471
17544
|
setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
|
|
17472
17545
|
}, [plans]);
|
|
17473
|
-
const Wrapper = isStandalone ? Container :
|
|
17546
|
+
const Wrapper = isStandalone ? Container : import_react51.Fragment;
|
|
17474
17547
|
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
17475
17548
|
FussyChild,
|
|
17476
17549
|
{
|
|
@@ -17591,7 +17664,7 @@ var PricingTable = (0, import_react50.forwardRef)(({ className, callToActionUrl,
|
|
|
17591
17664
|
PricingTable.displayName = "PricingTable";
|
|
17592
17665
|
|
|
17593
17666
|
// src/components/elements/text/Text.tsx
|
|
17594
|
-
var
|
|
17667
|
+
var import_react52 = require("react");
|
|
17595
17668
|
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
17596
17669
|
var resolveDesignProps9 = (props) => {
|
|
17597
17670
|
return {
|
|
@@ -17602,7 +17675,7 @@ var resolveDesignProps9 = (props) => {
|
|
|
17602
17675
|
}
|
|
17603
17676
|
};
|
|
17604
17677
|
};
|
|
17605
|
-
var TextElement = (0,
|
|
17678
|
+
var TextElement = (0, import_react52.forwardRef)(({ children, className, ...rest }, ref) => {
|
|
17606
17679
|
const props = resolveDesignProps9(rest);
|
|
17607
17680
|
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Element, { as: Flex, ref, className, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
17608
17681
|
Text,
|
|
@@ -17617,7 +17690,7 @@ var TextElement = (0, import_react51.forwardRef)(({ children, className, ...rest
|
|
|
17617
17690
|
TextElement.displayName = "Text";
|
|
17618
17691
|
|
|
17619
17692
|
// src/components/elements/unsubscribe-button/UnsubscribeButton.tsx
|
|
17620
|
-
var
|
|
17693
|
+
var import_react53 = require("react");
|
|
17621
17694
|
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
17622
17695
|
var buttonStyles = {
|
|
17623
17696
|
primary: {
|
|
@@ -17644,11 +17717,11 @@ var resolveDesignProps10 = (props) => {
|
|
|
17644
17717
|
}
|
|
17645
17718
|
};
|
|
17646
17719
|
};
|
|
17647
|
-
var UnsubscribeButton = (0,
|
|
17720
|
+
var UnsubscribeButton = (0, import_react53.forwardRef)(({ children, className, ...rest }, ref) => {
|
|
17648
17721
|
const props = resolveDesignProps10(rest);
|
|
17649
17722
|
const { t: t2 } = useTranslation();
|
|
17650
17723
|
const { data, setLayout } = useEmbed();
|
|
17651
|
-
const hasActiveSubscription = (0,
|
|
17724
|
+
const hasActiveSubscription = (0, import_react53.useMemo)(() => {
|
|
17652
17725
|
return isCheckoutData(data) && data.subscription && data.subscription.status !== "cancelled" && !data.subscription.cancelAt;
|
|
17653
17726
|
}, [data]);
|
|
17654
17727
|
if (!hasActiveSubscription) {
|
|
@@ -17683,7 +17756,7 @@ var UnsubscribeButton = (0, import_react52.forwardRef)(({ children, className, .
|
|
|
17683
17756
|
UnsubscribeButton.displayName = "UnsubscribeButton";
|
|
17684
17757
|
|
|
17685
17758
|
// src/components/elements/upcoming-bill/UpcomingBill.tsx
|
|
17686
|
-
var
|
|
17759
|
+
var import_react54 = require("react");
|
|
17687
17760
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
17688
17761
|
function resolveDesignProps11(props) {
|
|
17689
17762
|
return {
|
|
@@ -17703,15 +17776,15 @@ function resolveDesignProps11(props) {
|
|
|
17703
17776
|
}
|
|
17704
17777
|
};
|
|
17705
17778
|
}
|
|
17706
|
-
var UpcomingBill = (0,
|
|
17779
|
+
var UpcomingBill = (0, import_react54.forwardRef)(({ className, ...rest }, ref) => {
|
|
17707
17780
|
const props = resolveDesignProps11(rest);
|
|
17708
17781
|
const { t: t2 } = useTranslation();
|
|
17709
17782
|
const { data, settings, getUpcomingInvoice } = useEmbed();
|
|
17710
17783
|
const isLightBackground = useIsLightBackground();
|
|
17711
|
-
const [isLoading, setIsLoading] = (0,
|
|
17712
|
-
const [error, setError] = (0,
|
|
17713
|
-
const [upcomingInvoice, setUpcomingInvoice] = (0,
|
|
17714
|
-
const discounts = (0,
|
|
17784
|
+
const [isLoading, setIsLoading] = (0, import_react54.useState)(false);
|
|
17785
|
+
const [error, setError] = (0, import_react54.useState)();
|
|
17786
|
+
const [upcomingInvoice, setUpcomingInvoice] = (0, import_react54.useState)();
|
|
17787
|
+
const discounts = (0, import_react54.useMemo)(() => {
|
|
17715
17788
|
return (isCheckoutData(data) && data.subscription?.discounts || []).map(
|
|
17716
17789
|
(discount) => ({
|
|
17717
17790
|
couponId: discount.couponId,
|
|
@@ -17723,7 +17796,7 @@ var UpcomingBill = (0, import_react53.forwardRef)(({ className, ...rest }, ref)
|
|
|
17723
17796
|
})
|
|
17724
17797
|
);
|
|
17725
17798
|
}, [data]);
|
|
17726
|
-
const getInvoice = (0,
|
|
17799
|
+
const getInvoice = (0, import_react54.useCallback)(async () => {
|
|
17727
17800
|
if (isCheckoutData(data) && data.component?.id && data.subscription && !data.subscription.cancelAt) {
|
|
17728
17801
|
try {
|
|
17729
17802
|
setError(void 0);
|
|
@@ -17739,7 +17812,7 @@ var UpcomingBill = (0, import_react53.forwardRef)(({ className, ...rest }, ref)
|
|
|
17739
17812
|
}
|
|
17740
17813
|
}
|
|
17741
17814
|
}, [data, getUpcomingInvoice]);
|
|
17742
|
-
(0,
|
|
17815
|
+
(0, import_react54.useEffect)(() => {
|
|
17743
17816
|
getInvoice();
|
|
17744
17817
|
}, [getInvoice]);
|
|
17745
17818
|
if (!isCheckoutData(data) || !data.subscription || data.subscription.cancelAt) {
|
|
@@ -17839,6 +17912,7 @@ var UpcomingBill = (0, import_react53.forwardRef)(({ className, ...rest }, ref)
|
|
|
17839
17912
|
}) : t2("Amount off", {
|
|
17840
17913
|
amount: formatCurrency(
|
|
17841
17914
|
discount.amountOff,
|
|
17915
|
+
// we already checked for `number` type
|
|
17842
17916
|
discount?.currency
|
|
17843
17917
|
)
|
|
17844
17918
|
}) }) })
|
|
@@ -22037,10 +22111,10 @@ var { Inflate, inflate, inflateRaw, ungzip } = inflate_1$1;
|
|
|
22037
22111
|
var inflate_1 = inflate;
|
|
22038
22112
|
|
|
22039
22113
|
// src/components/embed/Embed.tsx
|
|
22040
|
-
var
|
|
22114
|
+
var import_react56 = require("react");
|
|
22041
22115
|
|
|
22042
22116
|
// src/components/embed/renderer.ts
|
|
22043
|
-
var
|
|
22117
|
+
var import_react55 = require("react");
|
|
22044
22118
|
var components = {
|
|
22045
22119
|
Root,
|
|
22046
22120
|
Viewport,
|
|
@@ -22104,7 +22178,7 @@ function createRenderer(options2) {
|
|
|
22104
22178
|
const { className, ...rest } = props;
|
|
22105
22179
|
const resolvedProps = component === "div" ? rest : props;
|
|
22106
22180
|
const resolvedChildren = children.map(renderNode);
|
|
22107
|
-
return (0,
|
|
22181
|
+
return (0, import_react55.createElement)(
|
|
22108
22182
|
component,
|
|
22109
22183
|
{
|
|
22110
22184
|
key: index,
|
|
@@ -22152,8 +22226,8 @@ var Error2 = ({ message }) => {
|
|
|
22152
22226
|
);
|
|
22153
22227
|
};
|
|
22154
22228
|
var SchematicEmbed = ({ id, accessToken }) => {
|
|
22155
|
-
const [children, setChildren] = (0,
|
|
22156
|
-
const theme = (0,
|
|
22229
|
+
const [children, setChildren] = (0, import_react56.useState)(/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Loading, {}));
|
|
22230
|
+
const theme = (0, import_react56.useContext)(et);
|
|
22157
22231
|
const {
|
|
22158
22232
|
data,
|
|
22159
22233
|
error,
|
|
@@ -22164,17 +22238,17 @@ var SchematicEmbed = ({ id, accessToken }) => {
|
|
|
22164
22238
|
setAccessToken,
|
|
22165
22239
|
updateSettings
|
|
22166
22240
|
} = useEmbed();
|
|
22167
|
-
(0,
|
|
22241
|
+
(0, import_react56.useEffect)(() => {
|
|
22168
22242
|
if (accessToken) {
|
|
22169
22243
|
setAccessToken(accessToken);
|
|
22170
22244
|
}
|
|
22171
22245
|
}, [accessToken, setAccessToken]);
|
|
22172
|
-
(0,
|
|
22246
|
+
(0, import_react56.useEffect)(() => {
|
|
22173
22247
|
if (id && stale) {
|
|
22174
22248
|
hydrateComponent(id);
|
|
22175
22249
|
}
|
|
22176
22250
|
}, [id, hydrateComponent, stale]);
|
|
22177
|
-
(0,
|
|
22251
|
+
(0, import_react56.useEffect)(() => {
|
|
22178
22252
|
const renderer = createRenderer();
|
|
22179
22253
|
try {
|
|
22180
22254
|
if (isCheckoutData(data) && data.component?.ast) {
|