@schematichq/schematic-react 0.2.0-rc.4 → 0.2.0-rc.6
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-react.cjs.js +1492 -1088
- package/dist/schematic-react.d.ts +32 -36
- package/dist/schematic-react.esm.js +1476 -1078
- package/package.json +2 -2
@@ -6192,6 +6192,11 @@ var Qe = function() {
|
|
6192
6192
|
}();
|
6193
6193
|
var et = o.createContext(void 0);
|
6194
6194
|
var tt = et.Consumer;
|
6195
|
+
function nt() {
|
6196
|
+
var e = c(et);
|
6197
|
+
if (!e) throw he(18);
|
6198
|
+
return e;
|
6199
|
+
}
|
6195
6200
|
function ot(e) {
|
6196
6201
|
var n = o.useContext(et), r2 = i(function() {
|
6197
6202
|
return function(e2, n2) {
|
@@ -6339,6 +6344,12 @@ function ft(n) {
|
|
6339
6344
|
}
|
6340
6345
|
return o.memo(l2);
|
6341
6346
|
}
|
6347
|
+
function mt(t) {
|
6348
|
+
for (var n = [], o2 = 1; o2 < arguments.length; o2++) n[o2 - 1] = arguments[o2];
|
6349
|
+
"undefined" != typeof navigator && "ReactNative" === navigator.product && console.warn("`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.");
|
6350
|
+
var r2 = ae(lt.apply(void 0, __spreadArray([t], n, false))), s2 = $(r2);
|
6351
|
+
return new We(s2, r2);
|
6352
|
+
}
|
6342
6353
|
var vt = function() {
|
6343
6354
|
function e() {
|
6344
6355
|
var e2 = this;
|
@@ -6407,7 +6418,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
6407
6418
|
}
|
6408
6419
|
stripe._registerWrapper({
|
6409
6420
|
name: "stripe-js",
|
6410
|
-
version: "4.
|
6421
|
+
version: "4.4.0",
|
6411
6422
|
startTime
|
6412
6423
|
});
|
6413
6424
|
};
|
@@ -7307,6 +7318,7 @@ function InvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
7307
7318
|
environmentId: json["environment_id"],
|
7308
7319
|
externalId: json["external_id"],
|
7309
7320
|
id: json["id"],
|
7321
|
+
paymentMethodExternalId: json["payment_method_external_id"] == null ? void 0 : json["payment_method_external_id"],
|
7310
7322
|
subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
|
7311
7323
|
subtotal: json["subtotal"],
|
7312
7324
|
updatedAt: new Date(json["updated_at"])
|
@@ -7332,7 +7344,6 @@ function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
7332
7344
|
environmentId: json["environment_id"],
|
7333
7345
|
externalId: json["external_id"],
|
7334
7346
|
id: json["id"],
|
7335
|
-
invoiceExternalId: json["invoice_external_id"] == null ? void 0 : json["invoice_external_id"],
|
7336
7347
|
paymentMethodType: json["payment_method_type"],
|
7337
7348
|
subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
|
7338
7349
|
updatedAt: new Date(json["updated_at"])
|
@@ -7957,33 +7968,6 @@ function parseEditorState(data) {
|
|
7957
7968
|
});
|
7958
7969
|
return arr;
|
7959
7970
|
}
|
7960
|
-
async function fetchComponent(id, api) {
|
7961
|
-
const settings = { ...defaultSettings };
|
7962
|
-
const nodes = [];
|
7963
|
-
const response = await api.hydrateComponent({ componentId: id });
|
7964
|
-
const { data } = response;
|
7965
|
-
if (data.component?.ast) {
|
7966
|
-
const compressed = data.component.ast;
|
7967
|
-
const json = inflate_1(Uint8Array.from(Object.values(compressed)), {
|
7968
|
-
to: "string"
|
7969
|
-
});
|
7970
|
-
const ast = getEditorState(json);
|
7971
|
-
if (ast) {
|
7972
|
-
(0, import_lodash.default)(settings, ast.ROOT.props.settings);
|
7973
|
-
nodes.push(...parseEditorState(ast));
|
7974
|
-
}
|
7975
|
-
}
|
7976
|
-
let stripe = null;
|
7977
|
-
if (data.stripeEmbed?.publishableKey) {
|
7978
|
-
stripe = loadStripe(data.stripeEmbed.publishableKey);
|
7979
|
-
}
|
7980
|
-
return {
|
7981
|
-
data,
|
7982
|
-
nodes,
|
7983
|
-
settings,
|
7984
|
-
stripe
|
7985
|
-
};
|
7986
|
-
}
|
7987
7971
|
var EmbedContext = createContext({
|
7988
7972
|
api: null,
|
7989
7973
|
data: {
|
@@ -7994,6 +7978,9 @@ var EmbedContext = createContext({
|
|
7994
7978
|
stripe: null,
|
7995
7979
|
layout: "portal",
|
7996
7980
|
error: void 0,
|
7981
|
+
isPending: false,
|
7982
|
+
hydrate: () => {
|
7983
|
+
},
|
7997
7984
|
setData: () => {
|
7998
7985
|
},
|
7999
7986
|
updateSettings: () => {
|
@@ -8020,7 +8007,10 @@ var EmbedProvider = ({
|
|
8020
8007
|
settings: { ...defaultSettings },
|
8021
8008
|
stripe: null,
|
8022
8009
|
layout: "portal",
|
8010
|
+
isPending: false,
|
8023
8011
|
error: void 0,
|
8012
|
+
hydrate: () => {
|
8013
|
+
},
|
8024
8014
|
setData: () => {
|
8025
8015
|
},
|
8026
8016
|
updateSettings: () => {
|
@@ -8031,51 +8021,55 @@ var EmbedProvider = ({
|
|
8031
8021
|
}
|
8032
8022
|
};
|
8033
8023
|
});
|
8034
|
-
|
8035
|
-
|
8036
|
-
|
8037
|
-
|
8038
|
-
|
8039
|
-
|
8040
|
-
|
8041
|
-
|
8042
|
-
|
8043
|
-
|
8044
|
-
|
8045
|
-
|
8046
|
-
|
8047
|
-
|
8048
|
-
|
8049
|
-
|
8050
|
-
|
8051
|
-
|
8052
|
-
|
8053
|
-
|
8054
|
-
if (!id || !state.api) {
|
8055
|
-
return;
|
8056
|
-
}
|
8057
|
-
fetchComponent(id, state.api).then(async (resolvedData) => {
|
8058
|
-
setState((prev2) => ({ ...prev2, ...resolvedData }));
|
8059
|
-
}).catch((error) => setState((prev2) => ({ ...prev2, error })));
|
8060
|
-
}, [id, state.api]);
|
8061
|
-
useEffect(() => {
|
8062
|
-
const fontSet = /* @__PURE__ */ new Set([]);
|
8063
|
-
Object.values(state.settings.theme.typography).forEach(({ fontFamily }) => {
|
8064
|
-
fontSet.add(fontFamily);
|
8065
|
-
});
|
8066
|
-
if (fontSet.size > 0) {
|
8067
|
-
const src = `https://fonts.googleapis.com/css2?${[...fontSet].map((fontFamily) => `family=${fontFamily}&display=swap`).join("&")}`;
|
8068
|
-
if (styleRef.current) {
|
8069
|
-
styleRef.current.href = src;
|
8024
|
+
const hydrate = useCallback(async () => {
|
8025
|
+
setState((prev2) => ({ ...prev2, isPending: true, error: void 0 }));
|
8026
|
+
try {
|
8027
|
+
const nodes = [];
|
8028
|
+
const settings = { ...defaultSettings };
|
8029
|
+
if (!id || !state.api) {
|
8030
|
+
throw new Error("Invalid component id or api instance.");
|
8031
|
+
}
|
8032
|
+
const response = await state.api.hydrateComponent({ componentId: id });
|
8033
|
+
const { data } = response;
|
8034
|
+
if (data.component?.ast) {
|
8035
|
+
const compressed = data.component.ast;
|
8036
|
+
const json = inflate_1(Uint8Array.from(Object.values(compressed)), {
|
8037
|
+
to: "string"
|
8038
|
+
});
|
8039
|
+
const ast = getEditorState(json);
|
8040
|
+
if (ast) {
|
8041
|
+
(0, import_lodash.default)(settings, ast.ROOT.props.settings);
|
8042
|
+
nodes.push(...parseEditorState(ast));
|
8043
|
+
}
|
8070
8044
|
}
|
8045
|
+
let stripe = null;
|
8046
|
+
if (data.stripeEmbed?.publishableKey) {
|
8047
|
+
stripe = loadStripe(data.stripeEmbed.publishableKey);
|
8048
|
+
}
|
8049
|
+
setState((prev2) => ({
|
8050
|
+
...prev2,
|
8051
|
+
data,
|
8052
|
+
nodes,
|
8053
|
+
settings,
|
8054
|
+
stripe,
|
8055
|
+
isPending: false
|
8056
|
+
}));
|
8057
|
+
} catch (error) {
|
8058
|
+
setState((prev2) => ({
|
8059
|
+
...prev2,
|
8060
|
+
isPending: false,
|
8061
|
+
error: error instanceof Error ? error : new Error("An unknown error occurred.")
|
8062
|
+
}));
|
8071
8063
|
}
|
8072
|
-
}, [state.
|
8064
|
+
}, [id, state.api]);
|
8073
8065
|
const setData = useCallback(
|
8074
8066
|
(data) => {
|
8075
8067
|
setState((prev2) => {
|
8076
|
-
const
|
8077
|
-
|
8078
|
-
|
8068
|
+
const updatedData = (0, import_lodash.default)({}, prev2.data, { ...data });
|
8069
|
+
return {
|
8070
|
+
...prev2,
|
8071
|
+
data: updatedData
|
8072
|
+
};
|
8079
8073
|
});
|
8080
8074
|
},
|
8081
8075
|
[setState]
|
@@ -8083,9 +8077,11 @@ var EmbedProvider = ({
|
|
8083
8077
|
const updateSettings = useCallback(
|
8084
8078
|
(settings) => {
|
8085
8079
|
setState((prev2) => {
|
8086
|
-
const
|
8087
|
-
|
8088
|
-
|
8080
|
+
const updatedSettings = (0, import_lodash.default)({}, prev2.settings, { ...settings });
|
8081
|
+
return {
|
8082
|
+
...prev2,
|
8083
|
+
settings: updatedSettings
|
8084
|
+
};
|
8089
8085
|
});
|
8090
8086
|
},
|
8091
8087
|
[setState]
|
@@ -8108,6 +8104,40 @@ var EmbedProvider = ({
|
|
8108
8104
|
},
|
8109
8105
|
[setState]
|
8110
8106
|
);
|
8107
|
+
useEffect(() => {
|
8108
|
+
const element = document.getElementById("schematic-fonts");
|
8109
|
+
if (element) {
|
8110
|
+
return void (styleRef.current = element);
|
8111
|
+
}
|
8112
|
+
const style = document.createElement("link");
|
8113
|
+
style.id = "schematic-fonts";
|
8114
|
+
style.rel = "stylesheet";
|
8115
|
+
document.head.appendChild(style);
|
8116
|
+
styleRef.current = style;
|
8117
|
+
}, []);
|
8118
|
+
useEffect(() => {
|
8119
|
+
if (!accessToken) {
|
8120
|
+
return;
|
8121
|
+
}
|
8122
|
+
const config = new Configuration({ ...apiConfig, apiKey: accessToken });
|
8123
|
+
const api = new CheckoutApi(config);
|
8124
|
+
setState((prev2) => ({ ...prev2, api }));
|
8125
|
+
}, [accessToken, apiConfig]);
|
8126
|
+
useEffect(() => {
|
8127
|
+
hydrate();
|
8128
|
+
}, [hydrate]);
|
8129
|
+
useEffect(() => {
|
8130
|
+
const fontSet = /* @__PURE__ */ new Set([]);
|
8131
|
+
Object.values(state.settings.theme.typography).forEach(({ fontFamily }) => {
|
8132
|
+
fontSet.add(fontFamily);
|
8133
|
+
});
|
8134
|
+
if (fontSet.size > 0) {
|
8135
|
+
const src = `https://fonts.googleapis.com/css2?${[...fontSet].map((fontFamily) => `family=${fontFamily}&display=swap`).join("&")}`;
|
8136
|
+
if (styleRef.current) {
|
8137
|
+
styleRef.current.href = src;
|
8138
|
+
}
|
8139
|
+
}
|
8140
|
+
}, [state.settings.theme.typography]);
|
8111
8141
|
const renderChildren = () => {
|
8112
8142
|
if (state.stripe) {
|
8113
8143
|
return /* @__PURE__ */ jsx(
|
@@ -8160,6 +8190,8 @@ var EmbedProvider = ({
|
|
8160
8190
|
stripe: state.stripe,
|
8161
8191
|
layout: state.layout,
|
8162
8192
|
error: state.error,
|
8193
|
+
isPending: state.isPending,
|
8194
|
+
hydrate,
|
8163
8195
|
setData,
|
8164
8196
|
updateSettings,
|
8165
8197
|
setStripe,
|
@@ -8740,19 +8772,36 @@ function v4(options, buf, offset) {
|
|
8740
8772
|
}
|
8741
8773
|
var v4_default = v4;
|
8742
8774
|
var import_polyfill = __toESM2(require_browser_polyfill());
|
8775
|
+
function contextString(context) {
|
8776
|
+
const sortedContext = Object.keys(context).reduce((acc, key) => {
|
8777
|
+
const sortedKeys = Object.keys(
|
8778
|
+
context[key] || {}
|
8779
|
+
).sort();
|
8780
|
+
const sortedObj = sortedKeys.reduce((obj, sortedKey) => {
|
8781
|
+
obj[sortedKey] = context[key][sortedKey];
|
8782
|
+
return obj;
|
8783
|
+
}, {});
|
8784
|
+
acc[key] = sortedObj;
|
8785
|
+
return acc;
|
8786
|
+
}, {});
|
8787
|
+
return JSON.stringify(sortedContext);
|
8788
|
+
}
|
8743
8789
|
var anonymousIdKey = "schematicId";
|
8744
8790
|
var Schematic = class {
|
8745
8791
|
apiKey;
|
8746
8792
|
apiUrl = "https://api.schematichq.com";
|
8747
|
-
webSocketUrl = "wss://api.schematichq.com";
|
8748
|
-
eventUrl = "https://c.schematichq.com";
|
8749
8793
|
conn = null;
|
8750
8794
|
context = {};
|
8751
8795
|
eventQueue;
|
8796
|
+
eventUrl = "https://c.schematichq.com";
|
8797
|
+
flagListener;
|
8798
|
+
flagValueListeners = {};
|
8799
|
+
isPending = true;
|
8800
|
+
isPendingListeners = /* @__PURE__ */ new Set();
|
8752
8801
|
storage;
|
8753
8802
|
useWebSocket = false;
|
8754
8803
|
values = {};
|
8755
|
-
|
8804
|
+
webSocketUrl = "wss://api.schematichq.com";
|
8756
8805
|
constructor(apiKey, options) {
|
8757
8806
|
this.apiKey = apiKey;
|
8758
8807
|
this.eventQueue = [];
|
@@ -8772,12 +8821,14 @@ var Schematic = class {
|
|
8772
8821
|
if (options?.webSocketUrl !== void 0) {
|
8773
8822
|
this.webSocketUrl = options.webSocketUrl;
|
8774
8823
|
}
|
8775
|
-
if (window?.addEventListener) {
|
8824
|
+
if (typeof window !== "undefined" && window?.addEventListener) {
|
8776
8825
|
window.addEventListener("beforeunload", () => {
|
8777
8826
|
this.flushEventQueue();
|
8778
8827
|
});
|
8779
8828
|
}
|
8780
8829
|
}
|
8830
|
+
// Get value for a single flag
|
8831
|
+
// If in websocket mode, return the local value, otherwise make an API call
|
8781
8832
|
async checkFlag(options) {
|
8782
8833
|
const { fallback = false, key } = options;
|
8783
8834
|
const context = options.context || this.context;
|
@@ -8805,7 +8856,7 @@ var Schematic = class {
|
|
8805
8856
|
return fallback;
|
8806
8857
|
});
|
8807
8858
|
}
|
8808
|
-
// Make
|
8859
|
+
// Make an API call to fetch all flag values for a given context (use if not in websocket mode)
|
8809
8860
|
checkFlags = async (context) => {
|
8810
8861
|
context = context || this.context;
|
8811
8862
|
const requestUrl = `${this.apiUrl}/flags/check`;
|
@@ -8835,18 +8886,6 @@ var Schematic = class {
|
|
8835
8886
|
return false;
|
8836
8887
|
});
|
8837
8888
|
};
|
8838
|
-
cleanup = async () => {
|
8839
|
-
if (this.conn) {
|
8840
|
-
try {
|
8841
|
-
const socket = await this.conn;
|
8842
|
-
socket.close();
|
8843
|
-
} catch (error) {
|
8844
|
-
console.error("Error during cleanup:", error);
|
8845
|
-
} finally {
|
8846
|
-
this.conn = null;
|
8847
|
-
}
|
8848
|
-
}
|
8849
|
-
};
|
8850
8889
|
// Send an identify event
|
8851
8890
|
identify = (body) => {
|
8852
8891
|
this.setContext({
|
@@ -8864,12 +8903,16 @@ var Schematic = class {
|
|
8864
8903
|
this.context = context;
|
8865
8904
|
return Promise.resolve();
|
8866
8905
|
}
|
8867
|
-
|
8868
|
-
this.
|
8906
|
+
try {
|
8907
|
+
this.setIsPending(true);
|
8908
|
+
if (!this.conn) {
|
8909
|
+
this.conn = this.wsConnect();
|
8910
|
+
}
|
8911
|
+
const socket = await this.conn;
|
8912
|
+
await this.wsSendMessage(socket, context);
|
8913
|
+
} catch (error) {
|
8914
|
+
console.error("Error setting Schematic context:", error);
|
8869
8915
|
}
|
8870
|
-
return this.conn.then((socket) => {
|
8871
|
-
return this.wsSendMessage(socket, context);
|
8872
|
-
});
|
8873
8916
|
};
|
8874
8917
|
// Send track event
|
8875
8918
|
track = (body) => {
|
@@ -8881,6 +8924,9 @@ var Schematic = class {
|
|
8881
8924
|
user: user ?? this.context.user
|
8882
8925
|
});
|
8883
8926
|
};
|
8927
|
+
/**
|
8928
|
+
* Event processing
|
8929
|
+
*/
|
8884
8930
|
flushEventQueue = () => {
|
8885
8931
|
while (this.eventQueue.length > 0) {
|
8886
8932
|
const event = this.eventQueue.shift();
|
@@ -8936,6 +8982,22 @@ var Schematic = class {
|
|
8936
8982
|
this.eventQueue.push(event);
|
8937
8983
|
return Promise.resolve();
|
8938
8984
|
};
|
8985
|
+
/**
|
8986
|
+
* Websocket management
|
8987
|
+
*/
|
8988
|
+
cleanup = async () => {
|
8989
|
+
if (this.conn) {
|
8990
|
+
try {
|
8991
|
+
const socket = await this.conn;
|
8992
|
+
socket.close();
|
8993
|
+
} catch (error) {
|
8994
|
+
console.error("Error during cleanup:", error);
|
8995
|
+
} finally {
|
8996
|
+
this.conn = null;
|
8997
|
+
}
|
8998
|
+
}
|
8999
|
+
};
|
9000
|
+
// Open a websocket connection
|
8939
9001
|
wsConnect = () => {
|
8940
9002
|
return new Promise((resolve, reject) => {
|
8941
9003
|
const wsUrl = `${this.webSocketUrl}/flags/bootstrap`;
|
@@ -8951,6 +9013,8 @@ var Schematic = class {
|
|
8951
9013
|
};
|
8952
9014
|
});
|
8953
9015
|
};
|
9016
|
+
// Send a message on the websocket indicating interest in a particular evaluation context
|
9017
|
+
// and wait for the initial set of flag values to be returned
|
8954
9018
|
wsSendMessage = (socket, context) => {
|
8955
9019
|
return new Promise((resolve, reject) => {
|
8956
9020
|
if (contextString(context) == contextString(this.context)) {
|
@@ -8968,16 +9032,17 @@ var Schematic = class {
|
|
8968
9032
|
(message.flags ?? []).forEach(
|
8969
9033
|
(flag) => {
|
8970
9034
|
this.values[contextString(context)][flag.flag] = flag.value;
|
9035
|
+
this.notifyFlagValueListeners(flag.flag);
|
8971
9036
|
}
|
8972
9037
|
);
|
8973
9038
|
if (this.flagListener) {
|
8974
|
-
this.flagListener(this.
|
9039
|
+
this.flagListener(this.getFlagValues());
|
8975
9040
|
}
|
9041
|
+
this.setIsPending(false);
|
8976
9042
|
if (!resolved) {
|
8977
9043
|
resolved = true;
|
8978
9044
|
resolve();
|
8979
9045
|
}
|
8980
|
-
socket.removeEventListener("message", messageHandler);
|
8981
9046
|
};
|
8982
9047
|
socket.addEventListener("message", messageHandler);
|
8983
9048
|
socket.send(
|
@@ -8996,118 +9061,156 @@ var Schematic = class {
|
|
8996
9061
|
}
|
8997
9062
|
});
|
8998
9063
|
};
|
9064
|
+
/**
|
9065
|
+
* State management
|
9066
|
+
*/
|
9067
|
+
// isPending state
|
9068
|
+
getIsPending = () => {
|
9069
|
+
return this.isPending;
|
9070
|
+
};
|
9071
|
+
addIsPendingListener = (listener) => {
|
9072
|
+
this.isPendingListeners.add(listener);
|
9073
|
+
return () => {
|
9074
|
+
this.isPendingListeners.delete(listener);
|
9075
|
+
};
|
9076
|
+
};
|
9077
|
+
setIsPending = (isPending) => {
|
9078
|
+
this.isPending = isPending;
|
9079
|
+
this.isPendingListeners.forEach((listener) => listener());
|
9080
|
+
};
|
9081
|
+
// flagValues state
|
9082
|
+
getFlagValue = (flagKey) => {
|
9083
|
+
const values = this.getFlagValues();
|
9084
|
+
return values[flagKey];
|
9085
|
+
};
|
9086
|
+
getFlagValues = () => {
|
9087
|
+
const contextStr = contextString(this.context);
|
9088
|
+
return this.values[contextStr] ?? {};
|
9089
|
+
};
|
9090
|
+
addFlagValueListener = (flagKey, listener) => {
|
9091
|
+
if (!(flagKey in this.flagValueListeners)) {
|
9092
|
+
this.flagValueListeners[flagKey] = /* @__PURE__ */ new Set();
|
9093
|
+
}
|
9094
|
+
this.flagValueListeners[flagKey].add(listener);
|
9095
|
+
return () => {
|
9096
|
+
this.flagValueListeners[flagKey].delete(listener);
|
9097
|
+
};
|
9098
|
+
};
|
9099
|
+
notifyFlagValueListeners = (flagKey) => {
|
9100
|
+
const listeners = this.flagValueListeners?.[flagKey] ?? [];
|
9101
|
+
listeners.forEach((listener) => listener());
|
9102
|
+
};
|
8999
9103
|
};
|
9000
|
-
function contextString(context) {
|
9001
|
-
const sortedContext = Object.keys(context).reduce((acc, key) => {
|
9002
|
-
const sortedKeys = Object.keys(
|
9003
|
-
context[key] || {}
|
9004
|
-
).sort();
|
9005
|
-
const sortedObj = sortedKeys.reduce((obj, sortedKey) => {
|
9006
|
-
obj[sortedKey] = context[key][sortedKey];
|
9007
|
-
return obj;
|
9008
|
-
}, {});
|
9009
|
-
acc[key] = sortedObj;
|
9010
|
-
return acc;
|
9011
|
-
}, {});
|
9012
|
-
return JSON.stringify(sortedContext);
|
9013
|
-
}
|
9014
9104
|
|
9015
9105
|
// src/context/schematic.tsx
|
9016
|
-
import { createContext as createContext2, useEffect as useEffect2, useMemo
|
9106
|
+
import React, { createContext as createContext2, useEffect as useEffect2, useMemo } from "react";
|
9017
9107
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
9018
|
-
var SchematicContext = createContext2(
|
9019
|
-
|
9020
|
-
|
9108
|
+
var SchematicContext = createContext2(
|
9109
|
+
null
|
9110
|
+
);
|
9021
9111
|
var SchematicProvider = ({
|
9022
9112
|
children,
|
9023
9113
|
client: providedClient,
|
9024
9114
|
publishableKey,
|
9025
9115
|
...clientOpts
|
9026
9116
|
}) => {
|
9027
|
-
const
|
9028
|
-
|
9029
|
-
const memoizedClientOpts = useMemo(
|
9030
|
-
() => clientOpts,
|
9031
|
-
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
9032
|
-
[JSON.stringify(clientOpts)]
|
9033
|
-
);
|
9034
|
-
const { useWebSocket = true } = clientOpts;
|
9035
|
-
useEffect2(() => {
|
9036
|
-
let cleanupFunction;
|
9117
|
+
const client = useMemo(() => {
|
9118
|
+
const { useWebSocket = true } = clientOpts;
|
9037
9119
|
if (providedClient) {
|
9038
|
-
|
9039
|
-
|
9040
|
-
|
9041
|
-
|
9042
|
-
|
9043
|
-
|
9044
|
-
|
9045
|
-
|
9046
|
-
|
9047
|
-
|
9048
|
-
|
9049
|
-
});
|
9050
|
-
setClient(newClient);
|
9051
|
-
cleanupFunction = () => {
|
9052
|
-
newClient.cleanup().catch((error) => {
|
9120
|
+
return providedClient;
|
9121
|
+
}
|
9122
|
+
return new Schematic(publishableKey, {
|
9123
|
+
useWebSocket,
|
9124
|
+
...clientOpts
|
9125
|
+
});
|
9126
|
+
}, [providedClient, publishableKey, clientOpts]);
|
9127
|
+
useEffect2(() => {
|
9128
|
+
return () => {
|
9129
|
+
if (!providedClient) {
|
9130
|
+
client.cleanup().catch((error) => {
|
9053
9131
|
console.error("Error during cleanup:", error);
|
9054
9132
|
});
|
9055
|
-
}
|
9056
|
-
}
|
9057
|
-
|
9058
|
-
|
9059
|
-
|
9060
|
-
|
9061
|
-
|
9062
|
-
|
9133
|
+
}
|
9134
|
+
};
|
9135
|
+
}, [client, providedClient]);
|
9136
|
+
const contextValue = useMemo(
|
9137
|
+
() => ({
|
9138
|
+
client
|
9139
|
+
}),
|
9140
|
+
[client]
|
9141
|
+
);
|
9063
9142
|
return /* @__PURE__ */ jsx2(SchematicContext.Provider, { value: contextValue, children });
|
9064
9143
|
};
|
9144
|
+
var useSchematic = () => {
|
9145
|
+
const context = React.useContext(SchematicContext);
|
9146
|
+
if (context === null) {
|
9147
|
+
throw new Error("useSchematic must be used within a SchematicProvider");
|
9148
|
+
}
|
9149
|
+
return context;
|
9150
|
+
};
|
9065
9151
|
|
9066
9152
|
// src/hooks/embed.ts
|
9067
9153
|
import { useContext } from "react";
|
9068
9154
|
var useEmbed = () => useContext(EmbedContext);
|
9069
9155
|
|
9070
9156
|
// src/hooks/schematic.ts
|
9071
|
-
import {
|
9072
|
-
var useSchematic = () => useContext2(SchematicContext);
|
9157
|
+
import { useMemo as useMemo2, useSyncExternalStore, useCallback as useCallback2 } from "react";
|
9073
9158
|
var useSchematicClient = (opts) => {
|
9074
9159
|
const schematic = useSchematic();
|
9075
9160
|
const { client } = opts ?? {};
|
9076
|
-
|
9077
|
-
|
9078
|
-
|
9079
|
-
|
9161
|
+
return useMemo2(() => {
|
9162
|
+
if (client) {
|
9163
|
+
return client;
|
9164
|
+
}
|
9165
|
+
return schematic.client;
|
9166
|
+
}, [client, schematic.client]);
|
9080
9167
|
};
|
9081
9168
|
var useSchematicContext = (opts) => {
|
9082
9169
|
const client = useSchematicClient(opts);
|
9083
|
-
|
9084
|
-
|
9170
|
+
return useMemo2(
|
9171
|
+
() => ({
|
9172
|
+
setContext: client.setContext.bind(client)
|
9173
|
+
}),
|
9174
|
+
[client]
|
9175
|
+
);
|
9085
9176
|
};
|
9086
9177
|
var useSchematicEvents = (opts) => {
|
9087
9178
|
const client = useSchematicClient(opts);
|
9088
|
-
const
|
9089
|
-
|
9179
|
+
const track = useCallback2(
|
9180
|
+
(...args) => client.track(...args),
|
9181
|
+
[client]
|
9182
|
+
);
|
9183
|
+
const identify = useCallback2(
|
9184
|
+
(...args) => client.identify(...args),
|
9185
|
+
[client]
|
9186
|
+
);
|
9187
|
+
return useMemo2(() => ({ track, identify }), [track, identify]);
|
9090
9188
|
};
|
9091
9189
|
var useSchematicFlag = (key, opts) => {
|
9092
|
-
const
|
9093
|
-
const
|
9094
|
-
const
|
9095
|
-
|
9096
|
-
|
9097
|
-
|
9098
|
-
|
9099
|
-
|
9100
|
-
|
9101
|
-
|
9102
|
-
|
9103
|
-
|
9104
|
-
|
9105
|
-
|
9106
|
-
|
9190
|
+
const client = useSchematicClient(opts);
|
9191
|
+
const fallback = opts?.fallback ?? false;
|
9192
|
+
const subscribe = useCallback2(
|
9193
|
+
(callback) => client.addFlagValueListener(key, callback),
|
9194
|
+
[client, key]
|
9195
|
+
);
|
9196
|
+
const getSnapshot = useCallback2(() => {
|
9197
|
+
const value = client.getFlagValue(key);
|
9198
|
+
return typeof value === "undefined" ? fallback : value;
|
9199
|
+
}, [client, key, fallback]);
|
9200
|
+
return useSyncExternalStore(subscribe, getSnapshot);
|
9201
|
+
};
|
9202
|
+
var useSchematicIsPending = (opts) => {
|
9203
|
+
const client = useSchematicClient(opts);
|
9204
|
+
const subscribe = useCallback2(
|
9205
|
+
(callback) => client.addIsPendingListener(callback),
|
9206
|
+
[client]
|
9207
|
+
);
|
9208
|
+
const getSnapshot = useCallback2(() => client.getIsPending(), [client]);
|
9209
|
+
return useSyncExternalStore(subscribe, getSnapshot);
|
9107
9210
|
};
|
9108
9211
|
|
9109
9212
|
// src/components/elements/plan-manager/PlanManager.tsx
|
9110
|
-
import { forwardRef, useMemo as
|
9213
|
+
import { forwardRef, useMemo as useMemo6 } from "react";
|
9111
9214
|
import { createPortal } from "react-dom";
|
9112
9215
|
|
9113
9216
|
// src/utils/color.ts
|
@@ -9189,7 +9292,7 @@ function hslToHex({ h, s: s2, l: l2 }) {
|
|
9189
9292
|
}
|
9190
9293
|
function adjustLightness(color, amount) {
|
9191
9294
|
const { h, s: s2, l: l2 } = hexToHSL(color);
|
9192
|
-
return hslToHex({ h, s: s2, l: Math.max(Math.min(l2 + amount, 100), 0) });
|
9295
|
+
return hslToHex({ h, s: s2, l: Math.max(Math.min(l2 + amount * 100, 100), 0) });
|
9193
9296
|
}
|
9194
9297
|
function lighten(color, amount) {
|
9195
9298
|
return adjustLightness(color, amount);
|
@@ -9419,6 +9522,7 @@ var Container = dt.div`
|
|
9419
9522
|
align-items: center;
|
9420
9523
|
flex-shrink: 0;
|
9421
9524
|
border-radius: 9999px;
|
9525
|
+
|
9422
9526
|
${({ $size }) => {
|
9423
9527
|
const base = 24;
|
9424
9528
|
let scale = 1;
|
@@ -9436,6 +9540,15 @@ var Container = dt.div`
|
|
9436
9540
|
case "lg":
|
9437
9541
|
scale *= 1.75;
|
9438
9542
|
break;
|
9543
|
+
case "xl":
|
9544
|
+
scale *= 2;
|
9545
|
+
break;
|
9546
|
+
case "2xl":
|
9547
|
+
scale *= 2.5;
|
9548
|
+
break;
|
9549
|
+
case "3xl":
|
9550
|
+
scale *= 3;
|
9551
|
+
break;
|
9439
9552
|
}
|
9440
9553
|
return lt`
|
9441
9554
|
font-size: ${base * scale / TEXT_BASE_SIZE}rem;
|
@@ -9444,12 +9557,19 @@ var Container = dt.div`
|
|
9444
9557
|
height: ${(base + 8) * scale / TEXT_BASE_SIZE}rem;
|
9445
9558
|
`;
|
9446
9559
|
}}
|
9560
|
+
|
9447
9561
|
${({ $variant, $colors }) => $variant === "outline" ? lt`
|
9448
|
-
color: ${$colors[0]};
|
9449
9562
|
background-color: transparent;
|
9563
|
+
|
9564
|
+
${Icon} {
|
9565
|
+
color: ${$colors[0]};
|
9566
|
+
}
|
9450
9567
|
` : lt`
|
9451
|
-
color: ${$colors[0]};
|
9452
9568
|
background-color: ${$colors[1]};
|
9569
|
+
|
9570
|
+
${Icon} {
|
9571
|
+
color: ${$colors[0]};
|
9572
|
+
}
|
9453
9573
|
`}
|
9454
9574
|
`;
|
9455
9575
|
|
@@ -9471,57 +9591,175 @@ var IconRound = ({
|
|
9471
9591
|
return /* @__PURE__ */ jsx5(Container, { $size: size, $variant: variant, $colors: colors, ...props, children: /* @__PURE__ */ jsx5(Icon2, { name }) });
|
9472
9592
|
};
|
9473
9593
|
|
9474
|
-
// src/components/ui/
|
9475
|
-
|
9476
|
-
|
9477
|
-
|
9478
|
-
|
9479
|
-
|
9480
|
-
|
9481
|
-
|
9482
|
-
|
9483
|
-
|
9484
|
-
|
9485
|
-
|
9486
|
-
|
9487
|
-
|
9488
|
-
|
9489
|
-
|
9490
|
-
|
9491
|
-
|
9492
|
-
|
9493
|
-
orange: "#DB6769",
|
9494
|
-
red: "#EF4444"
|
9495
|
-
};
|
9496
|
-
return /* @__PURE__ */ jsxs2(
|
9497
|
-
Container2,
|
9594
|
+
// src/components/ui/modal/Modal.tsx
|
9595
|
+
import { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo3, useRef as useRef2 } from "react";
|
9596
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
9597
|
+
var Modal = ({ children, size = "auto", onClose }) => {
|
9598
|
+
const theme = nt();
|
9599
|
+
const { setLayout } = useEmbed();
|
9600
|
+
const ref = useRef2(null);
|
9601
|
+
const isLightBackground = useMemo3(() => {
|
9602
|
+
return hexToHSL(theme.card.background).l > 50;
|
9603
|
+
}, [theme.card.background]);
|
9604
|
+
const handleClose = useCallback3(() => {
|
9605
|
+
setLayout("portal");
|
9606
|
+
onClose?.();
|
9607
|
+
}, [setLayout, onClose]);
|
9608
|
+
useEffect3(() => {
|
9609
|
+
ref.current?.focus();
|
9610
|
+
}, []);
|
9611
|
+
return /* @__PURE__ */ jsx6(
|
9612
|
+
Box,
|
9498
9613
|
{
|
9499
|
-
|
9500
|
-
|
9501
|
-
|
9502
|
-
|
9503
|
-
|
9504
|
-
|
9505
|
-
|
9506
|
-
|
9507
|
-
|
9614
|
+
ref,
|
9615
|
+
tabIndex: 0,
|
9616
|
+
onClick: (event) => {
|
9617
|
+
if (event.target === event.currentTarget) {
|
9618
|
+
handleClose();
|
9619
|
+
}
|
9620
|
+
},
|
9621
|
+
onKeyDown: (event) => {
|
9622
|
+
if (event.key === "Escape") {
|
9623
|
+
handleClose();
|
9624
|
+
}
|
9625
|
+
},
|
9626
|
+
$position: "absolute",
|
9627
|
+
$top: "50%",
|
9628
|
+
$left: "50%",
|
9629
|
+
$zIndex: "999999",
|
9630
|
+
$transform: "translate(-50%, -50%)",
|
9631
|
+
$width: "100%",
|
9632
|
+
$height: "100%",
|
9633
|
+
$backgroundColor: isLightBackground ? "hsl(0, 0%, 85%)" : "hsl(0, 0%, 15%)",
|
9634
|
+
$overflow: "hidden",
|
9635
|
+
children: /* @__PURE__ */ jsx6(
|
9636
|
+
Flex,
|
9637
|
+
{
|
9638
|
+
$position: "relative",
|
9639
|
+
$top: "50%",
|
9640
|
+
$left: "50%",
|
9641
|
+
$transform: "translate(-50%, -50%)",
|
9642
|
+
$flexDirection: "column",
|
9643
|
+
$overflow: "hidden",
|
9644
|
+
...size === "auto" ? { $width: "min-content", $height: "min-content" } : {
|
9645
|
+
$width: "100%",
|
9646
|
+
$height: "100%",
|
9647
|
+
$maxWidth: "1366px",
|
9648
|
+
$maxHeight: "768px"
|
9649
|
+
},
|
9650
|
+
$backgroundColor: theme.card.background,
|
9651
|
+
$borderRadius: "0.5rem",
|
9652
|
+
$boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
|
9653
|
+
id: "select-plan-dialog",
|
9654
|
+
role: "dialog",
|
9655
|
+
"aria-labelledby": "select-plan-dialog-label",
|
9656
|
+
"aria-modal": "true",
|
9657
|
+
children
|
9658
|
+
}
|
9659
|
+
)
|
9660
|
+
}
|
9661
|
+
);
|
9662
|
+
};
|
9663
|
+
|
9664
|
+
// src/components/ui/modal/ModalHeader.tsx
|
9665
|
+
import { useCallback as useCallback4, useMemo as useMemo4 } from "react";
|
9666
|
+
import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
9667
|
+
var ModalHeader = ({
|
9668
|
+
children,
|
9669
|
+
bordered = false,
|
9670
|
+
onClose
|
9671
|
+
}) => {
|
9672
|
+
const theme = nt();
|
9673
|
+
const { setLayout } = useEmbed();
|
9674
|
+
const isLightBackground = useMemo4(() => {
|
9675
|
+
return hexToHSL(theme.card.background).l > 50;
|
9676
|
+
}, [theme.card.background]);
|
9677
|
+
const handleClose = useCallback4(() => {
|
9678
|
+
setLayout("portal");
|
9679
|
+
onClose?.();
|
9680
|
+
}, [setLayout, onClose]);
|
9681
|
+
return /* @__PURE__ */ jsxs2(
|
9682
|
+
Flex,
|
9683
|
+
{
|
9684
|
+
$justifyContent: "space-between",
|
9685
|
+
$alignItems: "center",
|
9686
|
+
$flexShrink: "0",
|
9687
|
+
$gap: "1rem",
|
9688
|
+
$height: "5rem",
|
9689
|
+
$padding: "0 1.5rem 0 3rem",
|
9690
|
+
...bordered && {
|
9691
|
+
$borderBottomWidth: "1px",
|
9692
|
+
$borderBottomStyle: "solid",
|
9693
|
+
$borderBottomColor: isLightBackground ? "hsla(0, 0%, 0%, 0.15)" : "hsla(0, 0%, 100%, 0.15)"
|
9694
|
+
},
|
9695
|
+
children: [
|
9696
|
+
children,
|
9697
|
+
/* @__PURE__ */ jsx7(Box, { $cursor: "pointer", onClick: handleClose, children: /* @__PURE__ */ jsx7(
|
9698
|
+
Icon2,
|
9699
|
+
{
|
9700
|
+
name: "close",
|
9701
|
+
style: {
|
9702
|
+
fontSize: 36,
|
9703
|
+
color: isLightBackground ? "hsla(0, 0%, 0%, 0.275)" : "hsla(0, 0%, 100%, 0.275)"
|
9704
|
+
}
|
9705
|
+
}
|
9706
|
+
) })
|
9707
|
+
]
|
9708
|
+
}
|
9709
|
+
);
|
9710
|
+
};
|
9711
|
+
|
9712
|
+
// src/components/ui/progress-bar/styles.ts
|
9713
|
+
var Container2 = dt(Flex)`
|
9714
|
+
position: relative;
|
9715
|
+
`;
|
9716
|
+
|
9717
|
+
// src/components/ui/progress-bar/ProgressBar.tsx
|
9718
|
+
import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
9719
|
+
var ProgressBar = ({
|
9720
|
+
progress,
|
9721
|
+
value,
|
9722
|
+
total = 0,
|
9723
|
+
color = "gray",
|
9724
|
+
barWidth = "100%",
|
9725
|
+
...props
|
9726
|
+
}) => {
|
9727
|
+
const barColorMap = {
|
9728
|
+
gray: "#9CA3AF",
|
9729
|
+
blue: "#2563EB",
|
9730
|
+
yellow: "#FFAA06",
|
9731
|
+
orange: "#DB6769",
|
9732
|
+
red: "#EF4444"
|
9733
|
+
};
|
9734
|
+
return /* @__PURE__ */ jsxs3(
|
9735
|
+
Container2,
|
9736
|
+
{
|
9737
|
+
$alignItems: "center",
|
9738
|
+
$gap: `${16 / TEXT_BASE_SIZE}rem`,
|
9739
|
+
...props,
|
9740
|
+
children: [
|
9741
|
+
/* @__PURE__ */ jsx8(
|
9742
|
+
Flex,
|
9743
|
+
{
|
9744
|
+
$position: "relative",
|
9745
|
+
$alignItems: "center",
|
9508
9746
|
$width: `${barWidth}`,
|
9509
9747
|
$maxWidth: "100%",
|
9510
|
-
children: /* @__PURE__ */
|
9748
|
+
children: /* @__PURE__ */ jsx8(
|
9511
9749
|
Flex,
|
9512
9750
|
{
|
9513
9751
|
$position: "relative",
|
9514
9752
|
$overflow: "hidden",
|
9515
9753
|
$width: "100%",
|
9516
9754
|
$height: `${8 / TEXT_BASE_SIZE}rem`,
|
9517
|
-
$
|
9755
|
+
$backgroundColor: "#F2F4F7",
|
9518
9756
|
$borderRadius: "9999px",
|
9519
|
-
children: /* @__PURE__ */
|
9757
|
+
children: /* @__PURE__ */ jsx8(
|
9520
9758
|
Box,
|
9521
9759
|
{
|
9522
9760
|
$width: `${Math.min(progress, 100)}%`,
|
9523
9761
|
$height: "100%",
|
9524
|
-
$
|
9762
|
+
$backgroundColor: barColorMap[color],
|
9525
9763
|
$borderRadius: "9999px"
|
9526
9764
|
}
|
9527
9765
|
)
|
@@ -9529,7 +9767,7 @@ var ProgressBar = ({
|
|
9529
9767
|
)
|
9530
9768
|
}
|
9531
9769
|
),
|
9532
|
-
total !== 0 && /* @__PURE__ */
|
9770
|
+
total !== 0 && /* @__PURE__ */ jsxs3(Text, { $size: 14, $weight: 500, children: [
|
9533
9771
|
value,
|
9534
9772
|
"/",
|
9535
9773
|
total
|
@@ -9540,16 +9778,10 @@ var ProgressBar = ({
|
|
9540
9778
|
};
|
9541
9779
|
|
9542
9780
|
// src/components/elements/plan-manager/CheckoutDialog.tsx
|
9543
|
-
import {
|
9544
|
-
useEffect as useEffect4,
|
9545
|
-
useMemo as useMemo2,
|
9546
|
-
useRef as useRef2,
|
9547
|
-
useState as useState5,
|
9548
|
-
useCallback as useCallback2
|
9549
|
-
} from "react";
|
9781
|
+
import { useEffect as useEffect4, useMemo as useMemo5, useState as useState3 } from "react";
|
9550
9782
|
|
9551
9783
|
// src/components/elements/plan-manager/PaymentForm.tsx
|
9552
|
-
import { useState as
|
9784
|
+
import { useState as useState2 } from "react";
|
9553
9785
|
import {
|
9554
9786
|
LinkAuthenticationElement,
|
9555
9787
|
PaymentElement
|
@@ -9564,7 +9796,18 @@ var StyledButton = dt(Button2)`
|
|
9564
9796
|
width: 100%;
|
9565
9797
|
${({ disabled, $color = "primary", theme }) => {
|
9566
9798
|
const { l: l2 } = hexToHSL(theme[$color]);
|
9567
|
-
|
9799
|
+
let textColor;
|
9800
|
+
let colorFn;
|
9801
|
+
if (l2 > 50) {
|
9802
|
+
textColor = "#000000";
|
9803
|
+
colorFn = lighten;
|
9804
|
+
} else {
|
9805
|
+
textColor = "#FFFFFF";
|
9806
|
+
colorFn = darken;
|
9807
|
+
}
|
9808
|
+
if (disabled) {
|
9809
|
+
textColor = colorFn(textColor, 42.5);
|
9810
|
+
}
|
9568
9811
|
return lt`
|
9569
9812
|
color: ${textColor};
|
9570
9813
|
|
@@ -9575,35 +9818,47 @@ var StyledButton = dt(Button2)`
|
|
9575
9818
|
}};
|
9576
9819
|
|
9577
9820
|
${({ disabled, $color = "primary", theme, $variant = "filled" }) => {
|
9578
|
-
|
9821
|
+
let color = theme[$color];
|
9822
|
+
if (disabled) {
|
9823
|
+
const { l: l2 } = hexToHSL(theme.card.background);
|
9824
|
+
color = hslToHex({ h: 0, s: 0, l: l2 });
|
9825
|
+
color = l2 > 50 ? darken(color, 0.075) : lighten(color, 0.15);
|
9826
|
+
}
|
9579
9827
|
return $variant === "filled" ? lt`
|
9580
9828
|
background-color: ${color};
|
9581
9829
|
border-color: ${color};
|
9582
9830
|
` : lt`
|
9583
9831
|
background-color: transparent;
|
9584
|
-
border-color:
|
9585
|
-
color:
|
9832
|
+
border-color: ${color};
|
9833
|
+
color: ${color};
|
9834
|
+
|
9586
9835
|
${Text} {
|
9587
|
-
color:
|
9836
|
+
color: ${color};
|
9588
9837
|
}
|
9589
9838
|
`;
|
9590
9839
|
}}
|
9591
9840
|
|
9592
|
-
&:hover {
|
9593
|
-
|
9594
|
-
|
9841
|
+
&:disabled:hover {
|
9842
|
+
cursor: not-allowed;
|
9843
|
+
}
|
9844
|
+
|
9845
|
+
&:not(:disabled):hover {
|
9846
|
+
${({ $color = "primary", theme, $variant = "filled" }) => {
|
9595
9847
|
const specified = theme[$color];
|
9596
|
-
const lightened = lighten(specified, 15);
|
9597
|
-
const color =
|
9848
|
+
const lightened = lighten(specified, 0.15);
|
9849
|
+
const color = specified === lightened ? darken(specified, 0.15) : lightened;
|
9850
|
+
const { l: l2 } = hexToHSL(theme[$color]);
|
9851
|
+
const textColor = l2 > 50 ? "#000000" : "#FFFFFF";
|
9598
9852
|
return $variant === "filled" ? lt`
|
9599
9853
|
background-color: ${color};
|
9600
9854
|
border-color: ${color};
|
9601
9855
|
` : lt`
|
9602
9856
|
background-color: ${color};
|
9603
9857
|
border-color: ${color};
|
9604
|
-
color:
|
9858
|
+
color: ${textColor};
|
9859
|
+
|
9605
9860
|
${Text} {
|
9606
|
-
color:
|
9861
|
+
color: ${textColor};
|
9607
9862
|
}
|
9608
9863
|
`;
|
9609
9864
|
}}
|
@@ -9613,35 +9868,35 @@ var StyledButton = dt(Button2)`
|
|
9613
9868
|
switch ($size) {
|
9614
9869
|
case "sm":
|
9615
9870
|
return lt`
|
9616
|
-
font-size: ${15 /
|
9617
|
-
padding: ${12 /
|
9618
|
-
border-radius: ${6 /
|
9871
|
+
font-size: ${15 / TEXT_BASE_SIZE}rem;
|
9872
|
+
padding: ${12 / TEXT_BASE_SIZE}rem 0;
|
9873
|
+
border-radius: ${6 / TEXT_BASE_SIZE}rem;
|
9619
9874
|
`;
|
9620
9875
|
case "md":
|
9621
9876
|
return lt`
|
9622
|
-
font-size: ${17 /
|
9623
|
-
padding: ${16 /
|
9624
|
-
border-radius: ${8 /
|
9877
|
+
font-size: ${17 / TEXT_BASE_SIZE}rem;
|
9878
|
+
padding: ${16 / TEXT_BASE_SIZE}rem 0;
|
9879
|
+
border-radius: ${8 / TEXT_BASE_SIZE}rem;
|
9625
9880
|
`;
|
9626
9881
|
case "lg":
|
9627
9882
|
return lt`
|
9628
|
-
font-size: ${19 /
|
9629
|
-
padding: ${20 /
|
9630
|
-
border-radius: ${10 /
|
9883
|
+
font-size: ${19 / TEXT_BASE_SIZE}rem;
|
9884
|
+
padding: ${20 / TEXT_BASE_SIZE}rem 0;
|
9885
|
+
border-radius: ${10 / TEXT_BASE_SIZE}rem;
|
9631
9886
|
`;
|
9632
9887
|
}
|
9633
9888
|
}}
|
9634
9889
|
`;
|
9635
9890
|
|
9636
9891
|
// src/components/elements/plan-manager/PaymentForm.tsx
|
9637
|
-
import { jsx as
|
9892
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
9638
9893
|
var PaymentForm = ({ plan, period, onConfirm }) => {
|
9639
9894
|
const stripe = useStripe();
|
9640
9895
|
const elements = useElements();
|
9641
9896
|
const { api, data } = useEmbed();
|
9642
|
-
const [message, setMessage] =
|
9643
|
-
const [isLoading, setIsLoading] =
|
9644
|
-
const [isConfirmed, setIsConfirmed] =
|
9897
|
+
const [message, setMessage] = useState2(null);
|
9898
|
+
const [isLoading, setIsLoading] = useState2(false);
|
9899
|
+
const [isConfirmed, setIsConfirmed] = useState2(false);
|
9645
9900
|
const handleSubmit = async (event) => {
|
9646
9901
|
event.preventDefault();
|
9647
9902
|
const priceId = period === "month" ? plan.monthlyPrice?.id : plan.yearlyPrice?.id;
|
@@ -9650,6 +9905,7 @@ var PaymentForm = ({ plan, period, onConfirm }) => {
|
|
9650
9905
|
}
|
9651
9906
|
setIsLoading(true);
|
9652
9907
|
setIsConfirmed(false);
|
9908
|
+
setMessage(null);
|
9653
9909
|
try {
|
9654
9910
|
const { setupIntent, error } = await stripe.confirmSetup({
|
9655
9911
|
elements,
|
@@ -9665,20 +9921,14 @@ var PaymentForm = ({ plan, period, onConfirm }) => {
|
|
9665
9921
|
}
|
9666
9922
|
if (error?.type === "card_error" || error?.type === "validation_error") {
|
9667
9923
|
setMessage(error.message);
|
9668
|
-
} else {
|
9669
|
-
setMessage("An unexpected error occured.");
|
9670
9924
|
}
|
9671
|
-
setIsLoading(false);
|
9672
9925
|
} catch (error) {
|
9673
|
-
|
9674
|
-
|
9675
|
-
} else {
|
9676
|
-
setMessage("An unexpected error occured.");
|
9677
|
-
}
|
9926
|
+
setMessage("A problem occurred while saving your payment method.");
|
9927
|
+
} finally {
|
9678
9928
|
setIsLoading(false);
|
9679
9929
|
}
|
9680
9930
|
};
|
9681
|
-
return /* @__PURE__ */
|
9931
|
+
return /* @__PURE__ */ jsxs4(
|
9682
9932
|
"form",
|
9683
9933
|
{
|
9684
9934
|
id: "payment-form",
|
@@ -9691,27 +9941,15 @@ var PaymentForm = ({ plan, period, onConfirm }) => {
|
|
9691
9941
|
overflowY: "auto"
|
9692
9942
|
},
|
9693
9943
|
children: [
|
9694
|
-
/* @__PURE__ */
|
9695
|
-
|
9696
|
-
{
|
9697
|
-
$fontSize: "18px",
|
9698
|
-
$marginBottom: "1.5rem",
|
9699
|
-
$display: "inline-block",
|
9700
|
-
$width: "100%",
|
9701
|
-
children: [
|
9702
|
-
"Add payment method",
|
9703
|
-
" "
|
9704
|
-
]
|
9705
|
-
}
|
9706
|
-
),
|
9707
|
-
/* @__PURE__ */ jsx7(
|
9944
|
+
/* @__PURE__ */ jsx9(Box, { $width: "100%", $marginBottom: "1.5rem", children: /* @__PURE__ */ jsx9(Text, { $size: 18, children: "Add payment method" }) }),
|
9945
|
+
/* @__PURE__ */ jsx9(
|
9708
9946
|
Flex,
|
9709
9947
|
{
|
9710
9948
|
$flexDirection: "column",
|
9711
9949
|
$gap: "1.5rem",
|
9712
|
-
$marginBottom: "1.5rem",
|
9713
9950
|
$width: "100%",
|
9714
|
-
|
9951
|
+
$marginBottom: "1.5rem",
|
9952
|
+
children: /* @__PURE__ */ jsx9(
|
9715
9953
|
LinkAuthenticationElement,
|
9716
9954
|
{
|
9717
9955
|
id: "link-authentication-element"
|
@@ -9719,512 +9957,247 @@ var PaymentForm = ({ plan, period, onConfirm }) => {
|
|
9719
9957
|
)
|
9720
9958
|
}
|
9721
9959
|
),
|
9722
|
-
/* @__PURE__ */
|
9723
|
-
|
9724
|
-
message && /* @__PURE__ */ jsx7("div", { id: "payment-message", children: message })
|
9725
|
-
] }),
|
9726
|
-
/* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(
|
9960
|
+
/* @__PURE__ */ jsx9(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ jsx9(PaymentElement, { id: "payment-element" }) }),
|
9961
|
+
/* @__PURE__ */ jsx9(
|
9727
9962
|
StyledButton,
|
9728
9963
|
{
|
9729
9964
|
id: "submit",
|
9730
9965
|
disabled: isLoading || !stripe || !elements || !data.stripeEmbed?.publishableKey || !data.stripeEmbed?.setupIntentClientSecret || isConfirmed,
|
9731
9966
|
$size: "md",
|
9732
9967
|
$color: "primary",
|
9733
|
-
children: /* @__PURE__ */
|
9968
|
+
children: /* @__PURE__ */ jsx9(Text, { id: "button-text", children: isLoading ? "Loading" : "Save payment method" })
|
9734
9969
|
}
|
9735
|
-
)
|
9970
|
+
),
|
9971
|
+
message && /* @__PURE__ */ jsx9(Box, { $margin: "1rem 0", children: /* @__PURE__ */ jsx9(Text, { id: "payment-message", $size: 15, $weight: 500, $color: "#DB6669", children: message }) })
|
9736
9972
|
]
|
9737
9973
|
}
|
9738
9974
|
);
|
9739
9975
|
};
|
9740
9976
|
|
9741
9977
|
// src/components/elements/plan-manager/CheckoutDialog.tsx
|
9742
|
-
import { Fragment, jsx as
|
9743
|
-
var OverlayHeader = ({
|
9744
|
-
children,
|
9745
|
-
onClose
|
9746
|
-
}) => {
|
9747
|
-
const { setLayout } = useEmbed();
|
9748
|
-
const handleClose = useCallback2(() => {
|
9749
|
-
setLayout("portal");
|
9750
|
-
onClose?.();
|
9751
|
-
}, [setLayout, onClose]);
|
9752
|
-
return /* @__PURE__ */ jsxs4(
|
9753
|
-
Flex,
|
9754
|
-
{
|
9755
|
-
$paddingLeft: "2.5rem",
|
9756
|
-
$paddingRight: "2.5rem",
|
9757
|
-
$padding: ".75rem 2.5rem",
|
9758
|
-
$flexDirection: "row",
|
9759
|
-
$justifyContent: "space-between",
|
9760
|
-
$alignItems: "center",
|
9761
|
-
$borderBottom: "1px solid #DEDEDE",
|
9762
|
-
$gap: "1rem",
|
9763
|
-
$backgroundColor: "#FFFFFF",
|
9764
|
-
$borderRadius: ".5rem .5rem 0 0",
|
9765
|
-
children: [
|
9766
|
-
children,
|
9767
|
-
/* @__PURE__ */ jsx8("div", { children: /* @__PURE__ */ jsx8(Box, { $cursor: "pointer", onClick: handleClose, children: /* @__PURE__ */ jsx8(Icon2, { name: "close", style: { fontSize: 36, color: "#B8B8B8" } }) }) })
|
9768
|
-
]
|
9769
|
-
}
|
9770
|
-
);
|
9771
|
-
};
|
9772
|
-
var OverlayWrapper = ({
|
9773
|
-
children,
|
9774
|
-
size = "lg",
|
9775
|
-
onClose
|
9776
|
-
}) => {
|
9777
|
-
const { setLayout } = useEmbed();
|
9778
|
-
const ref = useRef2(null);
|
9779
|
-
const sizeWidthMap = {
|
9780
|
-
md: "700px",
|
9781
|
-
lg: "75%"
|
9782
|
-
};
|
9783
|
-
const sizeHeighthMap = {
|
9784
|
-
md: "auto",
|
9785
|
-
lg: "75%"
|
9786
|
-
};
|
9787
|
-
const sizeMaxWidthMap = {
|
9788
|
-
md: "auto",
|
9789
|
-
lg: "1140px"
|
9790
|
-
};
|
9791
|
-
const handleClose = useCallback2(() => {
|
9792
|
-
setLayout("portal");
|
9793
|
-
onClose?.();
|
9794
|
-
}, [setLayout, onClose]);
|
9795
|
-
useEffect4(() => {
|
9796
|
-
ref.current?.focus();
|
9797
|
-
}, []);
|
9798
|
-
return /* @__PURE__ */ jsx8(
|
9799
|
-
Box,
|
9800
|
-
{
|
9801
|
-
ref,
|
9802
|
-
tabIndex: 0,
|
9803
|
-
onClick: (event) => {
|
9804
|
-
if (event.target === event.currentTarget) {
|
9805
|
-
handleClose();
|
9806
|
-
}
|
9807
|
-
},
|
9808
|
-
onKeyDown: (event) => {
|
9809
|
-
if (event.key === "Escape") {
|
9810
|
-
handleClose();
|
9811
|
-
}
|
9812
|
-
},
|
9813
|
-
$position: "absolute",
|
9814
|
-
$top: "50%",
|
9815
|
-
$left: "50%",
|
9816
|
-
$zIndex: "999999",
|
9817
|
-
$transform: "translate(-50%, -50%)",
|
9818
|
-
$width: "100%",
|
9819
|
-
$height: "100%",
|
9820
|
-
$backgroundColor: "#D9D9D9",
|
9821
|
-
$overflow: "hidden",
|
9822
|
-
children: /* @__PURE__ */ jsx8(
|
9823
|
-
Flex,
|
9824
|
-
{
|
9825
|
-
$position: "relative",
|
9826
|
-
$top: "50%",
|
9827
|
-
$left: "50%",
|
9828
|
-
$transform: "translate(-50%, -50%)",
|
9829
|
-
$flexDirection: "column",
|
9830
|
-
$maxWidth: sizeMaxWidthMap[size],
|
9831
|
-
$width: sizeWidthMap[size],
|
9832
|
-
$height: sizeHeighthMap[size],
|
9833
|
-
$backgroundColor: "#FBFBFB",
|
9834
|
-
$borderBottom: "1px solid #DEDEDE",
|
9835
|
-
$borderRadius: "8px",
|
9836
|
-
$boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
|
9837
|
-
id: "select-plan-dialog",
|
9838
|
-
role: "dialog",
|
9839
|
-
"aria-labelledby": "select-plan-dialog-label",
|
9840
|
-
"aria-modal": "true",
|
9841
|
-
children
|
9842
|
-
}
|
9843
|
-
)
|
9844
|
-
}
|
9845
|
-
);
|
9846
|
-
};
|
9847
|
-
var OverlaySideBar = ({
|
9848
|
-
pricePeriod,
|
9849
|
-
setPricePeriod,
|
9850
|
-
checkoutStage,
|
9851
|
-
setCheckoutStage,
|
9852
|
-
currentPlan,
|
9853
|
-
selectedPlan,
|
9854
|
-
paymentMethodId
|
9855
|
-
}) => {
|
9856
|
-
const { api } = useEmbed();
|
9857
|
-
const savingsPercentage = useMemo2(() => {
|
9858
|
-
if (selectedPlan && pricePeriod === "month") {
|
9859
|
-
const monthly = (selectedPlan?.monthlyPrice?.price || 0) * 12;
|
9860
|
-
const yearly = selectedPlan?.yearlyPrice?.price || 0;
|
9861
|
-
return Math.round((monthly - yearly) / monthly * 1e4) / 100;
|
9862
|
-
}
|
9863
|
-
return 0;
|
9864
|
-
}, [selectedPlan, pricePeriod]);
|
9865
|
-
return /* @__PURE__ */ jsxs4(
|
9866
|
-
Flex,
|
9867
|
-
{
|
9868
|
-
$flexDirection: "column",
|
9869
|
-
$background: "white",
|
9870
|
-
$borderRadius: "0 0 0.5rem",
|
9871
|
-
$maxWidth: "275px",
|
9872
|
-
$height: "100%",
|
9873
|
-
$boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
|
9874
|
-
children: [
|
9875
|
-
/* @__PURE__ */ jsxs4(
|
9876
|
-
Flex,
|
9877
|
-
{
|
9878
|
-
$flexDirection: "column",
|
9879
|
-
$position: "relative",
|
9880
|
-
$gap: "1rem",
|
9881
|
-
$width: "100%",
|
9882
|
-
$height: "auto",
|
9883
|
-
$padding: "1.5rem",
|
9884
|
-
$borderBottom: "1px solid #DEDEDE",
|
9885
|
-
children: [
|
9886
|
-
/* @__PURE__ */ jsx8(Flex, { $flexDirection: "row", $justifyContent: "space-between", children: /* @__PURE__ */ jsx8(Text, { $size: 20, $weight: 600, children: "Subscription" }) }),
|
9887
|
-
/* @__PURE__ */ jsxs4(
|
9888
|
-
Flex,
|
9889
|
-
{
|
9890
|
-
$flexDirection: "row",
|
9891
|
-
$border: "1px solid #D9D9D9",
|
9892
|
-
$borderRadius: "40px",
|
9893
|
-
$fontSize: "12px",
|
9894
|
-
$textAlign: "center",
|
9895
|
-
$cursor: "pointer",
|
9896
|
-
children: [
|
9897
|
-
/* @__PURE__ */ jsx8(
|
9898
|
-
Box,
|
9899
|
-
{
|
9900
|
-
onClick: () => setPricePeriod("month"),
|
9901
|
-
$padding: ".25rem .5rem",
|
9902
|
-
$flex: "1",
|
9903
|
-
$fontWeight: pricePeriod === "month" ? "600" : "400",
|
9904
|
-
$backgroundColor: pricePeriod === "month" ? "#DDDDDD" : "white",
|
9905
|
-
$borderRadius: "40px",
|
9906
|
-
children: "Billed monthly"
|
9907
|
-
}
|
9908
|
-
),
|
9909
|
-
/* @__PURE__ */ jsx8(
|
9910
|
-
Box,
|
9911
|
-
{
|
9912
|
-
onClick: () => setPricePeriod("year"),
|
9913
|
-
$padding: ".25rem .5rem",
|
9914
|
-
$flex: "1",
|
9915
|
-
$fontWeight: pricePeriod === "year" ? "600" : "400",
|
9916
|
-
$backgroundColor: pricePeriod === "year" ? "#DDDDDD" : "white",
|
9917
|
-
$borderRadius: "40px",
|
9918
|
-
children: "Billed yearly"
|
9919
|
-
}
|
9920
|
-
)
|
9921
|
-
]
|
9922
|
-
}
|
9923
|
-
),
|
9924
|
-
savingsPercentage > 0 && /* @__PURE__ */ jsxs4(Box, { $fontSize: "11px", $color: "#194BFB", children: [
|
9925
|
-
"Save up to ",
|
9926
|
-
savingsPercentage,
|
9927
|
-
"% with yearly billing"
|
9928
|
-
] })
|
9929
|
-
]
|
9930
|
-
}
|
9931
|
-
),
|
9932
|
-
/* @__PURE__ */ jsxs4(
|
9933
|
-
Flex,
|
9934
|
-
{
|
9935
|
-
$flexDirection: "column",
|
9936
|
-
$position: "relative",
|
9937
|
-
$gap: "1rem",
|
9938
|
-
$width: "100%",
|
9939
|
-
$height: "auto",
|
9940
|
-
$padding: "1.5rem",
|
9941
|
-
$flex: "1",
|
9942
|
-
$borderBottom: "1px solid #DEDEDE",
|
9943
|
-
children: [
|
9944
|
-
/* @__PURE__ */ jsx8(Box, { $fontSize: "14px", $color: "#5D5D5D", children: "Plan" }),
|
9945
|
-
/* @__PURE__ */ jsxs4(
|
9946
|
-
Flex,
|
9947
|
-
{
|
9948
|
-
$flexDirection: "column",
|
9949
|
-
$fontSize: "14px",
|
9950
|
-
$color: "#5D5D5D",
|
9951
|
-
$gap: ".5rem",
|
9952
|
-
children: [
|
9953
|
-
currentPlan && /* @__PURE__ */ jsxs4(
|
9954
|
-
Flex,
|
9955
|
-
{
|
9956
|
-
$flexDirection: "row",
|
9957
|
-
$alignItems: "center",
|
9958
|
-
$justifyContent: "space-between",
|
9959
|
-
$fontSize: "14px",
|
9960
|
-
$color: "#5D5D5D",
|
9961
|
-
children: [
|
9962
|
-
/* @__PURE__ */ jsx8(Flex, { $fontSize: "14px", $color: "#5D5D5D", children: currentPlan.name }),
|
9963
|
-
typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ jsxs4(Flex, { $fontSize: "12px", $color: "#000000", children: [
|
9964
|
-
formatCurrency(currentPlan.planPrice),
|
9965
|
-
"/",
|
9966
|
-
currentPlan.planPeriod
|
9967
|
-
] })
|
9968
|
-
]
|
9969
|
-
}
|
9970
|
-
),
|
9971
|
-
selectedPlan && /* @__PURE__ */ jsxs4(Fragment, { children: [
|
9972
|
-
/* @__PURE__ */ jsx8(
|
9973
|
-
Box,
|
9974
|
-
{
|
9975
|
-
$width: "100%",
|
9976
|
-
$textAlign: "left",
|
9977
|
-
$opacity: "50%",
|
9978
|
-
$marginBottom: "-.25rem",
|
9979
|
-
$marginTop: "-.25rem",
|
9980
|
-
children: /* @__PURE__ */ jsx8(
|
9981
|
-
Icon2,
|
9982
|
-
{
|
9983
|
-
name: "arrow-down",
|
9984
|
-
style: {
|
9985
|
-
display: "inline-block"
|
9986
|
-
}
|
9987
|
-
}
|
9988
|
-
)
|
9989
|
-
}
|
9990
|
-
),
|
9991
|
-
/* @__PURE__ */ jsxs4(
|
9992
|
-
Flex,
|
9993
|
-
{
|
9994
|
-
$flexDirection: "row",
|
9995
|
-
$alignItems: "center",
|
9996
|
-
$justifyContent: "space-between",
|
9997
|
-
$fontSize: "14px",
|
9998
|
-
$color: "#5D5D5D",
|
9999
|
-
children: [
|
10000
|
-
/* @__PURE__ */ jsx8(Flex, { $fontSize: "14px", $color: "#000000", $fontWeight: "600", children: selectedPlan.name }),
|
10001
|
-
/* @__PURE__ */ jsxs4(Flex, { $fontSize: "12px", $color: "#000000", children: [
|
10002
|
-
formatCurrency(
|
10003
|
-
(pricePeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
|
10004
|
-
),
|
10005
|
-
"/",
|
10006
|
-
pricePeriod
|
10007
|
-
] })
|
10008
|
-
]
|
10009
|
-
}
|
10010
|
-
)
|
10011
|
-
] })
|
10012
|
-
]
|
10013
|
-
}
|
10014
|
-
)
|
10015
|
-
]
|
10016
|
-
}
|
10017
|
-
),
|
10018
|
-
/* @__PURE__ */ jsxs4(
|
10019
|
-
Flex,
|
10020
|
-
{
|
10021
|
-
$flexDirection: "column",
|
10022
|
-
$position: "relative",
|
10023
|
-
$gap: ".75rem",
|
10024
|
-
$width: "100%",
|
10025
|
-
$height: "auto",
|
10026
|
-
$padding: "1.5rem",
|
10027
|
-
children: [
|
10028
|
-
selectedPlan && /* @__PURE__ */ jsxs4(
|
10029
|
-
Flex,
|
10030
|
-
{
|
10031
|
-
$fontSize: "12px",
|
10032
|
-
$color: "#5D5D5D",
|
10033
|
-
$justifyContent: "space-between",
|
10034
|
-
children: [
|
10035
|
-
/* @__PURE__ */ jsxs4(Box, { $fontSize: "12px", $color: "#5D5D5D", children: [
|
10036
|
-
"Monthly total:",
|
10037
|
-
" "
|
10038
|
-
] }),
|
10039
|
-
/* @__PURE__ */ jsxs4(Box, { $fontSize: "12px", $color: "#000000", children: [
|
10040
|
-
formatCurrency(
|
10041
|
-
(pricePeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
|
10042
|
-
),
|
10043
|
-
"/",
|
10044
|
-
pricePeriod
|
10045
|
-
] })
|
10046
|
-
]
|
10047
|
-
}
|
10048
|
-
),
|
10049
|
-
checkoutStage === "plan" ? /* @__PURE__ */ jsx8(
|
10050
|
-
StyledButton,
|
10051
|
-
{
|
10052
|
-
$size: "sm",
|
10053
|
-
onClick: () => {
|
10054
|
-
setCheckoutStage("checkout");
|
10055
|
-
},
|
10056
|
-
...!selectedPlan && { disabled: true },
|
10057
|
-
children: /* @__PURE__ */ jsxs4(Flex, { $gap: "0.5rem", $alignItems: "center", $justifyContent: "center", children: [
|
10058
|
-
/* @__PURE__ */ jsx8("span", { children: "Next: Checkout" }),
|
10059
|
-
/* @__PURE__ */ jsx8(Icon2, { name: "arrow-right" })
|
10060
|
-
] })
|
10061
|
-
}
|
10062
|
-
) : /* @__PURE__ */ jsx8(
|
10063
|
-
StyledButton,
|
10064
|
-
{
|
10065
|
-
disabled: !api || !selectedPlan || selectedPlan?.id === currentPlan?.id || !paymentMethodId,
|
10066
|
-
onClick: async () => {
|
10067
|
-
const priceId = (pricePeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.id;
|
10068
|
-
if (!api || !selectedPlan || !priceId || !paymentMethodId) {
|
10069
|
-
return;
|
10070
|
-
}
|
10071
|
-
await api.checkout({
|
10072
|
-
changeSubscriptionRequestBody: {
|
10073
|
-
newPlanId: selectedPlan.id,
|
10074
|
-
newPriceId: priceId,
|
10075
|
-
paymentMethodId
|
10076
|
-
}
|
10077
|
-
});
|
10078
|
-
},
|
10079
|
-
$size: "md",
|
10080
|
-
children: "Pay now"
|
10081
|
-
}
|
10082
|
-
),
|
10083
|
-
/* @__PURE__ */ jsx8(Box, { $fontSize: "12px", $color: "#5D5D5D", children: "Discounts & credits applied at checkout" })
|
10084
|
-
]
|
10085
|
-
}
|
10086
|
-
)
|
10087
|
-
]
|
10088
|
-
}
|
10089
|
-
);
|
10090
|
-
};
|
9978
|
+
import { Fragment, jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
|
10091
9979
|
var CheckoutDialog = () => {
|
10092
|
-
const [checkoutStage, setCheckoutStage] =
|
9980
|
+
const [checkoutStage, setCheckoutStage] = useState3(
|
10093
9981
|
"plan"
|
10094
9982
|
);
|
10095
|
-
const [planPeriod, setPlanPeriod] =
|
10096
|
-
const [selectedPlan, setSelectedPlan] =
|
10097
|
-
const [paymentMethodId, setPaymentMethodId] =
|
10098
|
-
const
|
10099
|
-
const
|
9983
|
+
const [planPeriod, setPlanPeriod] = useState3("month");
|
9984
|
+
const [selectedPlan, setSelectedPlan] = useState3();
|
9985
|
+
const [paymentMethodId, setPaymentMethodId] = useState3();
|
9986
|
+
const [isLoading, setIsLoading] = useState3(false);
|
9987
|
+
const [isCheckoutComplete, setIsCheckoutComplete] = useState3(false);
|
9988
|
+
const [error, setError] = useState3();
|
9989
|
+
const theme = nt();
|
9990
|
+
const { api, data, hydrate, setLayout } = useEmbed();
|
9991
|
+
const { currentPlan, availablePlans } = useMemo5(() => {
|
10100
9992
|
return {
|
10101
9993
|
currentPlan: data.company?.plan,
|
10102
9994
|
availablePlans: data.activePlans
|
10103
9995
|
};
|
10104
9996
|
}, [data.company, data.activePlans]);
|
10105
|
-
|
10106
|
-
|
10107
|
-
|
10108
|
-
|
9997
|
+
const savingsPercentage = useMemo5(() => {
|
9998
|
+
if (selectedPlan) {
|
9999
|
+
const monthly = (selectedPlan?.monthlyPrice?.price || 0) * 12;
|
10000
|
+
const yearly = selectedPlan?.yearlyPrice?.price || 0;
|
10001
|
+
return Math.round((monthly - yearly) / monthly * 1e4) / 100;
|
10002
|
+
}
|
10003
|
+
return 0;
|
10004
|
+
}, [selectedPlan]);
|
10005
|
+
const isLightBackground = useMemo5(() => {
|
10006
|
+
return hexToHSL(theme.card.background).l > 50;
|
10007
|
+
}, [theme.card.background]);
|
10008
|
+
useEffect4(() => {
|
10009
|
+
if (isCheckoutComplete && api && data.component?.id) {
|
10010
|
+
hydrate();
|
10011
|
+
}
|
10012
|
+
}, [isCheckoutComplete, api, data.component?.id, hydrate]);
|
10013
|
+
return /* @__PURE__ */ jsxs5(Modal, { size: isCheckoutComplete ? "auto" : "lg", children: [
|
10014
|
+
/* @__PURE__ */ jsx10(ModalHeader, { bordered: !isCheckoutComplete, children: /* @__PURE__ */ jsx10(Flex, { $gap: "1rem", children: !isCheckoutComplete && /* @__PURE__ */ jsxs5(Fragment, { children: [
|
10015
|
+
/* @__PURE__ */ jsxs5(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
|
10016
|
+
checkoutStage === "plan" ? /* @__PURE__ */ jsx10(
|
10109
10017
|
Box,
|
10110
10018
|
{
|
10111
|
-
$width:
|
10112
|
-
$height:
|
10113
|
-
$
|
10114
|
-
$
|
10115
|
-
$
|
10019
|
+
$width: `${20 / TEXT_BASE_SIZE}rem`,
|
10020
|
+
$height: `${20 / TEXT_BASE_SIZE}rem`,
|
10021
|
+
$borderWidth: "2px",
|
10022
|
+
$borderStyle: "solid",
|
10023
|
+
$borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.25)",
|
10024
|
+
$borderRadius: "9999px"
|
10116
10025
|
}
|
10117
|
-
) : /* @__PURE__ */
|
10026
|
+
) : /* @__PURE__ */ jsx10(
|
10118
10027
|
IconRound,
|
10119
10028
|
{
|
10120
10029
|
name: "check",
|
10030
|
+
colors: [
|
10031
|
+
theme.card.background,
|
10032
|
+
isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.25)"
|
10033
|
+
],
|
10121
10034
|
style: {
|
10122
|
-
|
10123
|
-
|
10124
|
-
|
10125
|
-
width: "1rem",
|
10126
|
-
height: "1rem"
|
10035
|
+
fontSize: `${16 / TEXT_BASE_SIZE}rem`,
|
10036
|
+
width: `${20 / TEXT_BASE_SIZE}rem`,
|
10037
|
+
height: `${20 / TEXT_BASE_SIZE}rem`
|
10127
10038
|
}
|
10128
10039
|
}
|
10129
10040
|
),
|
10130
|
-
/* @__PURE__ */
|
10131
|
-
|
10041
|
+
/* @__PURE__ */ jsx10(
|
10042
|
+
Box,
|
10132
10043
|
{
|
10133
10044
|
tabIndex: 0,
|
10134
|
-
...checkoutStage
|
10135
|
-
|
10136
|
-
|
10137
|
-
|
10138
|
-
} : {
|
10139
|
-
style: {
|
10140
|
-
cursor: "pointer"
|
10141
|
-
},
|
10142
|
-
onClick: () => setCheckoutStage("plan")
|
10045
|
+
...checkoutStage !== "plan" && {
|
10046
|
+
onClick: () => setCheckoutStage("plan"),
|
10047
|
+
$opacity: "0.6375",
|
10048
|
+
$cursor: "pointer"
|
10143
10049
|
},
|
10144
|
-
children:
|
10145
|
-
|
10146
|
-
|
10147
|
-
|
10148
|
-
|
10149
|
-
|
10150
|
-
|
10151
|
-
|
10050
|
+
children: /* @__PURE__ */ jsx10(
|
10051
|
+
Text,
|
10052
|
+
{
|
10053
|
+
$font: theme.typography.text.fontFamily,
|
10054
|
+
$size: 19,
|
10055
|
+
$weight: checkoutStage === "plan" ? 600 : 400,
|
10056
|
+
$color: theme.typography.text.color,
|
10057
|
+
children: "1. Select plan"
|
10058
|
+
}
|
10059
|
+
)
|
10152
10060
|
}
|
10153
10061
|
)
|
10154
10062
|
] }),
|
10155
|
-
/* @__PURE__ */
|
10156
|
-
|
10063
|
+
/* @__PURE__ */ jsx10(
|
10064
|
+
Icon2,
|
10065
|
+
{
|
10066
|
+
name: "chevron-right",
|
10067
|
+
style: {
|
10068
|
+
fontSize: 16,
|
10069
|
+
color: isLightBackground ? "hsla(0, 0%, 0%, 0.175)" : "hsla(0, 0%, 100%, 0.35)"
|
10070
|
+
}
|
10071
|
+
}
|
10072
|
+
),
|
10073
|
+
/* @__PURE__ */ jsxs5(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
|
10074
|
+
/* @__PURE__ */ jsx10(
|
10157
10075
|
Box,
|
10158
10076
|
{
|
10159
|
-
$width:
|
10160
|
-
$height:
|
10161
|
-
$
|
10162
|
-
$
|
10163
|
-
$
|
10077
|
+
$width: `${20 / TEXT_BASE_SIZE}rem`,
|
10078
|
+
$height: `${20 / TEXT_BASE_SIZE}rem`,
|
10079
|
+
$borderWidth: "2px",
|
10080
|
+
$borderStyle: "solid",
|
10081
|
+
$borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.25)",
|
10082
|
+
$borderRadius: "9999px"
|
10164
10083
|
}
|
10165
10084
|
),
|
10166
|
-
/* @__PURE__ */
|
10167
|
-
|
10085
|
+
/* @__PURE__ */ jsx10(
|
10086
|
+
Box,
|
10168
10087
|
{
|
10169
10088
|
tabIndex: 0,
|
10170
|
-
...checkoutStage
|
10171
|
-
|
10172
|
-
fontWeight: "700"
|
10173
|
-
}
|
10089
|
+
...checkoutStage !== "checkout" && {
|
10090
|
+
$opacity: "0.6375"
|
10174
10091
|
},
|
10175
|
-
children:
|
10092
|
+
children: /* @__PURE__ */ jsx10(
|
10093
|
+
Text,
|
10094
|
+
{
|
10095
|
+
$font: theme.typography.text.fontFamily,
|
10096
|
+
$size: 19,
|
10097
|
+
$weight: checkoutStage === "plan" ? 600 : 400,
|
10098
|
+
$color: theme.typography.text.color,
|
10099
|
+
children: "2. Checkout"
|
10100
|
+
}
|
10101
|
+
)
|
10176
10102
|
}
|
10177
10103
|
)
|
10178
10104
|
] })
|
10179
|
-
] }) }),
|
10180
|
-
/* @__PURE__ */
|
10181
|
-
|
10105
|
+
] }) }) }),
|
10106
|
+
isCheckoutComplete && /* @__PURE__ */ jsxs5(
|
10107
|
+
Flex,
|
10108
|
+
{
|
10109
|
+
$flexDirection: "column",
|
10110
|
+
$justifyContent: "center",
|
10111
|
+
$alignItems: "center",
|
10112
|
+
$flexGrow: "1",
|
10113
|
+
$gap: `${32 / TEXT_BASE_SIZE}rem`,
|
10114
|
+
$padding: `${32 / TEXT_BASE_SIZE}rem ${40 / TEXT_BASE_SIZE}rem`,
|
10115
|
+
$whiteSpace: "nowrap",
|
10116
|
+
children: [
|
10117
|
+
/* @__PURE__ */ jsx10(
|
10118
|
+
IconRound,
|
10119
|
+
{
|
10120
|
+
name: "check",
|
10121
|
+
size: "3xl",
|
10122
|
+
colors: [
|
10123
|
+
theme.card.background,
|
10124
|
+
isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.125)"
|
10125
|
+
]
|
10126
|
+
}
|
10127
|
+
),
|
10128
|
+
/* @__PURE__ */ jsx10(
|
10129
|
+
Text,
|
10130
|
+
{
|
10131
|
+
as: "h1",
|
10132
|
+
$font: theme.typography.heading1.fontFamily,
|
10133
|
+
$size: theme.typography.heading1.fontSize,
|
10134
|
+
$weight: theme.typography.heading1.fontWeight,
|
10135
|
+
$color: theme.typography.heading1.color,
|
10136
|
+
children: "Subscription updated!"
|
10137
|
+
}
|
10138
|
+
),
|
10139
|
+
/* @__PURE__ */ jsx10(StyledButton, { onClick: () => setLayout("portal"), children: "Close" })
|
10140
|
+
]
|
10141
|
+
}
|
10142
|
+
),
|
10143
|
+
!isCheckoutComplete && /* @__PURE__ */ jsxs5(Flex, { $position: "relative", $height: "calc(100% - 5rem)", children: [
|
10144
|
+
/* @__PURE__ */ jsxs5(
|
10182
10145
|
Flex,
|
10183
10146
|
{
|
10184
10147
|
$flexDirection: "column",
|
10148
|
+
$flexGrow: "1",
|
10185
10149
|
$gap: "1rem",
|
10186
10150
|
$padding: "2rem 2.5rem 2rem 2.5rem",
|
10187
|
-
$backgroundColor: "
|
10188
|
-
$borderRadius: "0 0.5rem 0",
|
10151
|
+
$backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.025)" : "hsla(0, 0%, 100%, 0.025)",
|
10189
10152
|
$flex: "1",
|
10190
|
-
$
|
10153
|
+
$overflow: "auto",
|
10191
10154
|
children: [
|
10192
|
-
checkoutStage === "plan" && /* @__PURE__ */
|
10193
|
-
/* @__PURE__ */
|
10194
|
-
/* @__PURE__ */
|
10155
|
+
checkoutStage === "plan" && /* @__PURE__ */ jsxs5(Fragment, { children: [
|
10156
|
+
/* @__PURE__ */ jsxs5(Flex, { $flexDirection: "column", $gap: "1rem", $marginBottom: "1rem", children: [
|
10157
|
+
/* @__PURE__ */ jsx10(
|
10195
10158
|
Text,
|
10196
10159
|
{
|
10197
|
-
as: "
|
10160
|
+
as: "h3",
|
10198
10161
|
id: "select-plan-dialog-label",
|
10199
|
-
$
|
10200
|
-
$
|
10162
|
+
$font: theme.typography.heading3.fontFamily,
|
10163
|
+
$size: theme.typography.heading3.fontSize,
|
10164
|
+
$weight: theme.typography.heading3.fontWeight,
|
10165
|
+
$color: theme.typography.heading3.color,
|
10166
|
+
$marginBottom: "0.5rem",
|
10201
10167
|
children: "Select plan"
|
10202
10168
|
}
|
10203
10169
|
),
|
10204
|
-
/* @__PURE__ */
|
10170
|
+
/* @__PURE__ */ jsx10(
|
10205
10171
|
Text,
|
10206
10172
|
{
|
10207
10173
|
as: "p",
|
10208
10174
|
id: "select-plan-dialog-description",
|
10209
|
-
$
|
10210
|
-
$
|
10175
|
+
$font: theme.typography.text.fontFamily,
|
10176
|
+
$size: theme.typography.text.fontSize,
|
10177
|
+
$weight: theme.typography.text.fontWeight,
|
10178
|
+
$color: theme.typography.text.color,
|
10211
10179
|
children: "Choose your base plan"
|
10212
10180
|
}
|
10213
10181
|
)
|
10214
10182
|
] }),
|
10215
|
-
/* @__PURE__ */
|
10216
|
-
return /* @__PURE__ */
|
10183
|
+
/* @__PURE__ */ jsx10(Flex, { $flexWrap: "wrap", $gap: "1rem", $flexGrow: "1", children: availablePlans?.map((plan) => {
|
10184
|
+
return /* @__PURE__ */ jsxs5(
|
10217
10185
|
Flex,
|
10218
10186
|
{
|
10219
|
-
$height: "100%",
|
10220
10187
|
$flexDirection: "column",
|
10221
|
-
$
|
10222
|
-
$
|
10223
|
-
$
|
10224
|
-
$
|
10225
|
-
$
|
10188
|
+
$width: "100%",
|
10189
|
+
$minWidth: "280px",
|
10190
|
+
$maxWidth: `calc(${100 / 3}% - 1rem)`,
|
10191
|
+
$backgroundColor: theme.card.background,
|
10192
|
+
$outlineWidth: "2px",
|
10193
|
+
$outlineStyle: "solid",
|
10194
|
+
$outlineColor: plan.id === selectedPlan?.id ? theme.primary : "transparent",
|
10195
|
+
$borderRadius: `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`,
|
10196
|
+
...theme.card.hasShadow && {
|
10197
|
+
$boxShadow: "0px 1px 3px rgba(16, 24, 40, 0.1), 0px 1px 20px rgba(16, 24, 40, 0.06)"
|
10198
|
+
},
|
10226
10199
|
children: [
|
10227
|
-
/* @__PURE__ */
|
10200
|
+
/* @__PURE__ */ jsxs5(
|
10228
10201
|
Flex,
|
10229
10202
|
{
|
10230
10203
|
$flexDirection: "column",
|
@@ -10232,38 +10205,40 @@ var CheckoutDialog = () => {
|
|
10232
10205
|
$gap: "1rem",
|
10233
10206
|
$width: "100%",
|
10234
10207
|
$height: "auto",
|
10235
|
-
$padding:
|
10236
|
-
$
|
10208
|
+
$padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
|
10209
|
+
$borderBottomWidth: "1px",
|
10210
|
+
$borderStyle: "solid",
|
10211
|
+
$borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.175)" : "hsla(0, 0%, 100%, 0.175)",
|
10237
10212
|
children: [
|
10238
|
-
/* @__PURE__ */
|
10239
|
-
/* @__PURE__ */
|
10240
|
-
/* @__PURE__ */
|
10241
|
-
/* @__PURE__ */
|
10213
|
+
/* @__PURE__ */ jsx10(Text, { $size: 20, $weight: 600, children: plan.name }),
|
10214
|
+
/* @__PURE__ */ jsx10(Text, { $size: 14, children: plan.description }),
|
10215
|
+
/* @__PURE__ */ jsxs5(Text, { children: [
|
10216
|
+
/* @__PURE__ */ jsx10(Box, { $display: "inline-block", $fontSize: "1.5rem", children: formatCurrency(
|
10242
10217
|
(planPeriod === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0
|
10243
10218
|
) }),
|
10244
|
-
/* @__PURE__ */
|
10219
|
+
/* @__PURE__ */ jsxs5(Box, { $display: "inline-block", $fontSize: "0.75rem", children: [
|
10245
10220
|
"/",
|
10246
10221
|
planPeriod
|
10247
10222
|
] })
|
10248
10223
|
] }),
|
10249
|
-
(plan.current || plan.id === currentPlan?.id) && /* @__PURE__ */
|
10224
|
+
(plan.current || plan.id === currentPlan?.id) && /* @__PURE__ */ jsx10(
|
10250
10225
|
Flex,
|
10251
10226
|
{
|
10252
10227
|
$position: "absolute",
|
10253
10228
|
$right: "1rem",
|
10254
10229
|
$top: "1rem",
|
10255
|
-
$fontSize: ".625rem",
|
10256
|
-
$color: "
|
10257
|
-
$backgroundColor:
|
10258
|
-
$borderRadius: "
|
10259
|
-
$padding: ".125rem .85rem",
|
10230
|
+
$fontSize: "0.625rem",
|
10231
|
+
$color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
|
10232
|
+
$backgroundColor: theme.primary,
|
10233
|
+
$borderRadius: "9999px",
|
10234
|
+
$padding: "0.125rem 0.85rem",
|
10260
10235
|
children: "Current plan"
|
10261
10236
|
}
|
10262
10237
|
)
|
10263
10238
|
]
|
10264
10239
|
}
|
10265
10240
|
),
|
10266
|
-
/* @__PURE__ */
|
10241
|
+
/* @__PURE__ */ jsx10(
|
10267
10242
|
Flex,
|
10268
10243
|
{
|
10269
10244
|
$flexDirection: "column",
|
@@ -10274,21 +10249,32 @@ var CheckoutDialog = () => {
|
|
10274
10249
|
$height: "auto",
|
10275
10250
|
$padding: "1.5rem",
|
10276
10251
|
children: plan.features.map((feature) => {
|
10277
|
-
return /* @__PURE__ */
|
10278
|
-
|
10279
|
-
|
10280
|
-
|
10281
|
-
|
10282
|
-
|
10283
|
-
|
10284
|
-
|
10285
|
-
|
10286
|
-
|
10287
|
-
|
10252
|
+
return /* @__PURE__ */ jsxs5(
|
10253
|
+
Flex,
|
10254
|
+
{
|
10255
|
+
$flexShrink: "0",
|
10256
|
+
$gap: "1rem",
|
10257
|
+
children: [
|
10258
|
+
/* @__PURE__ */ jsx10(
|
10259
|
+
IconRound,
|
10260
|
+
{
|
10261
|
+
name: feature.icon,
|
10262
|
+
size: "tn",
|
10263
|
+
colors: [
|
10264
|
+
theme.primary,
|
10265
|
+
isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.0625)"
|
10266
|
+
]
|
10267
|
+
}
|
10268
|
+
),
|
10269
|
+
/* @__PURE__ */ jsx10(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx10(Text, { $size: 12, children: feature.name }) })
|
10270
|
+
]
|
10271
|
+
},
|
10272
|
+
feature.id
|
10273
|
+
);
|
10288
10274
|
})
|
10289
10275
|
}
|
10290
10276
|
),
|
10291
|
-
/* @__PURE__ */
|
10277
|
+
/* @__PURE__ */ jsxs5(
|
10292
10278
|
Flex,
|
10293
10279
|
{
|
10294
10280
|
$flexDirection: "column",
|
@@ -10298,7 +10284,7 @@ var CheckoutDialog = () => {
|
|
10298
10284
|
$height: "auto",
|
10299
10285
|
$padding: "1.5rem",
|
10300
10286
|
children: [
|
10301
|
-
plan.id === selectedPlan?.id && /* @__PURE__ */
|
10287
|
+
plan.id === selectedPlan?.id && /* @__PURE__ */ jsxs5(
|
10302
10288
|
Flex,
|
10303
10289
|
{
|
10304
10290
|
$justifyContent: "center",
|
@@ -10307,39 +10293,38 @@ var CheckoutDialog = () => {
|
|
10307
10293
|
$fontSize: "0.9375rem",
|
10308
10294
|
$padding: "0.625rem 0",
|
10309
10295
|
children: [
|
10310
|
-
/* @__PURE__ */
|
10296
|
+
/* @__PURE__ */ jsx10(
|
10311
10297
|
Icon2,
|
10312
10298
|
{
|
10313
10299
|
name: "check-rounded",
|
10314
10300
|
style: {
|
10315
10301
|
fontSize: 20,
|
10316
10302
|
lineHeight: "1",
|
10317
|
-
color:
|
10303
|
+
color: theme.primary
|
10318
10304
|
}
|
10319
10305
|
}
|
10320
10306
|
),
|
10321
|
-
/* @__PURE__ */
|
10322
|
-
|
10307
|
+
/* @__PURE__ */ jsx10(
|
10308
|
+
Text,
|
10323
10309
|
{
|
10324
|
-
|
10325
|
-
|
10326
|
-
lineHeight: "1.4"
|
10327
|
-
},
|
10310
|
+
$lineHeight: "1.4",
|
10311
|
+
$color: theme.typography.text.color,
|
10328
10312
|
children: "Selected"
|
10329
10313
|
}
|
10330
10314
|
)
|
10331
10315
|
]
|
10332
10316
|
}
|
10333
10317
|
),
|
10334
|
-
!(plan.current || plan.id === currentPlan?.id) && plan.id !== selectedPlan?.id && /* @__PURE__ */
|
10318
|
+
!(plan.current || plan.id === currentPlan?.id) && plan.id !== selectedPlan?.id && /* @__PURE__ */ jsx10(
|
10335
10319
|
StyledButton,
|
10336
10320
|
{
|
10321
|
+
disabled: plan.valid === false,
|
10322
|
+
...plan.valid === true && {
|
10323
|
+
onClick: () => setSelectedPlan(plan)
|
10324
|
+
},
|
10337
10325
|
$size: "sm",
|
10338
10326
|
$color: "primary",
|
10339
10327
|
$variant: "outline",
|
10340
|
-
onClick: () => {
|
10341
|
-
setSelectedPlan(plan);
|
10342
|
-
},
|
10343
10328
|
children: "Select"
|
10344
10329
|
}
|
10345
10330
|
)
|
@@ -10352,7 +10337,7 @@ var CheckoutDialog = () => {
|
|
10352
10337
|
);
|
10353
10338
|
}) })
|
10354
10339
|
] }),
|
10355
|
-
selectedPlan && checkoutStage === "checkout" && /* @__PURE__ */
|
10340
|
+
selectedPlan && checkoutStage === "checkout" && /* @__PURE__ */ jsx10(
|
10356
10341
|
PaymentForm,
|
10357
10342
|
{
|
10358
10343
|
plan: selectedPlan,
|
@@ -10365,16 +10350,345 @@ var CheckoutDialog = () => {
|
|
10365
10350
|
]
|
10366
10351
|
}
|
10367
10352
|
),
|
10368
|
-
/* @__PURE__ */
|
10369
|
-
|
10353
|
+
/* @__PURE__ */ jsxs5(
|
10354
|
+
Flex,
|
10370
10355
|
{
|
10371
|
-
|
10372
|
-
|
10373
|
-
|
10374
|
-
|
10375
|
-
|
10376
|
-
|
10377
|
-
|
10356
|
+
$flexDirection: "column",
|
10357
|
+
$backgroundColor: theme.card.background,
|
10358
|
+
$borderRadius: "0 0 0.5rem",
|
10359
|
+
$width: "21.5rem",
|
10360
|
+
$boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
|
10361
|
+
children: [
|
10362
|
+
/* @__PURE__ */ jsxs5(
|
10363
|
+
Flex,
|
10364
|
+
{
|
10365
|
+
$flexDirection: "column",
|
10366
|
+
$position: "relative",
|
10367
|
+
$gap: "1rem",
|
10368
|
+
$width: "100%",
|
10369
|
+
$height: "auto",
|
10370
|
+
$padding: "1.5rem",
|
10371
|
+
$borderBottomWidth: "1px",
|
10372
|
+
$borderStyle: "solid",
|
10373
|
+
$borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)",
|
10374
|
+
children: [
|
10375
|
+
/* @__PURE__ */ jsx10(Flex, { $justifyContent: "space-between", children: /* @__PURE__ */ jsx10(
|
10376
|
+
Text,
|
10377
|
+
{
|
10378
|
+
as: "h3",
|
10379
|
+
$font: theme.typography.heading3.fontFamily,
|
10380
|
+
$size: theme.typography.heading3.fontSize,
|
10381
|
+
$weight: theme.typography.heading3.fontWeight,
|
10382
|
+
$color: theme.typography.heading3.color,
|
10383
|
+
children: "Subscription"
|
10384
|
+
}
|
10385
|
+
) }),
|
10386
|
+
/* @__PURE__ */ jsxs5(
|
10387
|
+
Flex,
|
10388
|
+
{
|
10389
|
+
$borderWidth: "1px",
|
10390
|
+
$borderStyle: "solid",
|
10391
|
+
$borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)",
|
10392
|
+
$borderRadius: "2.5rem",
|
10393
|
+
$cursor: "pointer",
|
10394
|
+
children: [
|
10395
|
+
/* @__PURE__ */ jsx10(
|
10396
|
+
Flex,
|
10397
|
+
{
|
10398
|
+
onClick: () => setPlanPeriod("month"),
|
10399
|
+
$justifyContent: "center",
|
10400
|
+
$alignItems: "center",
|
10401
|
+
$padding: "0.25rem 0.5rem",
|
10402
|
+
$flex: "1",
|
10403
|
+
...planPeriod === "month" && {
|
10404
|
+
$backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.075)" : "hsla(0, 0%, 100%, 0.15)"
|
10405
|
+
},
|
10406
|
+
$borderRadius: "2.5rem",
|
10407
|
+
children: /* @__PURE__ */ jsx10(
|
10408
|
+
Text,
|
10409
|
+
{
|
10410
|
+
$font: theme.typography.text.fontFamily,
|
10411
|
+
$size: 14,
|
10412
|
+
$weight: planPeriod === "month" ? 600 : 400,
|
10413
|
+
$color: theme.typography.text.color,
|
10414
|
+
children: "Billed monthly"
|
10415
|
+
}
|
10416
|
+
)
|
10417
|
+
}
|
10418
|
+
),
|
10419
|
+
/* @__PURE__ */ jsx10(
|
10420
|
+
Flex,
|
10421
|
+
{
|
10422
|
+
onClick: () => setPlanPeriod("year"),
|
10423
|
+
$justifyContent: "center",
|
10424
|
+
$alignItems: "center",
|
10425
|
+
$padding: "0.25rem 0.5rem",
|
10426
|
+
$flex: "1",
|
10427
|
+
...planPeriod === "year" && {
|
10428
|
+
$backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.075)" : "hsla(0, 0%, 100%, 0.15)"
|
10429
|
+
},
|
10430
|
+
$borderRadius: "2.5rem",
|
10431
|
+
children: /* @__PURE__ */ jsx10(
|
10432
|
+
Text,
|
10433
|
+
{
|
10434
|
+
$font: theme.typography.text.fontFamily,
|
10435
|
+
$size: 14,
|
10436
|
+
$weight: planPeriod === "year" ? 600 : 400,
|
10437
|
+
$color: theme.typography.text.color,
|
10438
|
+
children: "Billed yearly"
|
10439
|
+
}
|
10440
|
+
)
|
10441
|
+
}
|
10442
|
+
)
|
10443
|
+
]
|
10444
|
+
}
|
10445
|
+
),
|
10446
|
+
savingsPercentage > 0 && /* @__PURE__ */ jsx10(Box, { children: /* @__PURE__ */ jsx10(
|
10447
|
+
Text,
|
10448
|
+
{
|
10449
|
+
$font: theme.typography.text.fontFamily,
|
10450
|
+
$size: 11,
|
10451
|
+
$weight: theme.typography.text.fontWeight,
|
10452
|
+
$color: theme.primary,
|
10453
|
+
children: planPeriod === "month" ? `Save up to ${savingsPercentage}% with yearly billing` : `You are saving ${savingsPercentage}% with yearly billing`
|
10454
|
+
}
|
10455
|
+
) })
|
10456
|
+
]
|
10457
|
+
}
|
10458
|
+
),
|
10459
|
+
/* @__PURE__ */ jsxs5(
|
10460
|
+
Flex,
|
10461
|
+
{
|
10462
|
+
$flexDirection: "column",
|
10463
|
+
$position: "relative",
|
10464
|
+
$gap: "1rem",
|
10465
|
+
$width: "100%",
|
10466
|
+
$height: "auto",
|
10467
|
+
$padding: "1.5rem",
|
10468
|
+
$flex: "1",
|
10469
|
+
$borderBottomWidth: "1px",
|
10470
|
+
$borderStyle: "solid",
|
10471
|
+
$borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)",
|
10472
|
+
children: [
|
10473
|
+
/* @__PURE__ */ jsx10(Box, { $opacity: "0.625", children: /* @__PURE__ */ jsx10(
|
10474
|
+
Text,
|
10475
|
+
{
|
10476
|
+
$font: theme.typography.text.fontFamily,
|
10477
|
+
$size: 14,
|
10478
|
+
$weight: theme.typography.text.fontWeight,
|
10479
|
+
$color: theme.typography.text.color,
|
10480
|
+
children: "Plan"
|
10481
|
+
}
|
10482
|
+
) }),
|
10483
|
+
/* @__PURE__ */ jsxs5(Flex, { $flexDirection: "column", $gap: "0.5rem", children: [
|
10484
|
+
currentPlan && /* @__PURE__ */ jsxs5(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
|
10485
|
+
/* @__PURE__ */ jsx10(
|
10486
|
+
Flex,
|
10487
|
+
{
|
10488
|
+
...selectedPlan && {
|
10489
|
+
$opacity: "0.625",
|
10490
|
+
$textDecoration: "line-through"
|
10491
|
+
},
|
10492
|
+
children: /* @__PURE__ */ jsx10(
|
10493
|
+
Text,
|
10494
|
+
{
|
10495
|
+
$font: theme.typography.heading4.fontFamily,
|
10496
|
+
$size: theme.typography.heading4.fontSize,
|
10497
|
+
$weight: theme.typography.heading4.fontWeight,
|
10498
|
+
$color: theme.typography.heading4.color,
|
10499
|
+
children: currentPlan.name
|
10500
|
+
}
|
10501
|
+
)
|
10502
|
+
}
|
10503
|
+
),
|
10504
|
+
typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ jsx10(Flex, { children: /* @__PURE__ */ jsxs5(
|
10505
|
+
Text,
|
10506
|
+
{
|
10507
|
+
$font: theme.typography.text.fontFamily,
|
10508
|
+
$size: theme.typography.text.fontSize,
|
10509
|
+
$weight: theme.typography.text.fontWeight,
|
10510
|
+
$color: theme.typography.text.color,
|
10511
|
+
children: [
|
10512
|
+
formatCurrency(currentPlan.planPrice),
|
10513
|
+
"/",
|
10514
|
+
currentPlan.planPeriod
|
10515
|
+
]
|
10516
|
+
}
|
10517
|
+
) })
|
10518
|
+
] }),
|
10519
|
+
selectedPlan && /* @__PURE__ */ jsxs5(Fragment, { children: [
|
10520
|
+
/* @__PURE__ */ jsx10(
|
10521
|
+
Box,
|
10522
|
+
{
|
10523
|
+
$width: "100%",
|
10524
|
+
$textAlign: "left",
|
10525
|
+
$opacity: "50%",
|
10526
|
+
$marginBottom: "-0.25rem",
|
10527
|
+
$marginTop: "-0.25rem",
|
10528
|
+
children: /* @__PURE__ */ jsx10(
|
10529
|
+
Icon2,
|
10530
|
+
{
|
10531
|
+
name: "arrow-down",
|
10532
|
+
style: {
|
10533
|
+
display: "inline-block"
|
10534
|
+
}
|
10535
|
+
}
|
10536
|
+
)
|
10537
|
+
}
|
10538
|
+
),
|
10539
|
+
/* @__PURE__ */ jsxs5(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
|
10540
|
+
/* @__PURE__ */ jsx10(Flex, { children: /* @__PURE__ */ jsx10(
|
10541
|
+
Text,
|
10542
|
+
{
|
10543
|
+
$font: theme.typography.heading4.fontFamily,
|
10544
|
+
$size: theme.typography.heading4.fontSize,
|
10545
|
+
$weight: theme.typography.heading4.fontWeight,
|
10546
|
+
$color: theme.typography.heading4.color,
|
10547
|
+
children: selectedPlan.name
|
10548
|
+
}
|
10549
|
+
) }),
|
10550
|
+
/* @__PURE__ */ jsx10(Flex, { children: /* @__PURE__ */ jsxs5(
|
10551
|
+
Text,
|
10552
|
+
{
|
10553
|
+
$font: theme.typography.text.fontFamily,
|
10554
|
+
$size: theme.typography.text.fontSize,
|
10555
|
+
$weight: theme.typography.text.fontWeight,
|
10556
|
+
$color: theme.typography.text.color,
|
10557
|
+
children: [
|
10558
|
+
formatCurrency(
|
10559
|
+
(planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
|
10560
|
+
),
|
10561
|
+
"/",
|
10562
|
+
planPeriod
|
10563
|
+
]
|
10564
|
+
}
|
10565
|
+
) })
|
10566
|
+
] })
|
10567
|
+
] })
|
10568
|
+
] })
|
10569
|
+
]
|
10570
|
+
}
|
10571
|
+
),
|
10572
|
+
/* @__PURE__ */ jsxs5(
|
10573
|
+
Flex,
|
10574
|
+
{
|
10575
|
+
$flexDirection: "column",
|
10576
|
+
$position: "relative",
|
10577
|
+
$gap: "1rem",
|
10578
|
+
$width: "100%",
|
10579
|
+
$height: "auto",
|
10580
|
+
$padding: "1.5rem",
|
10581
|
+
children: [
|
10582
|
+
selectedPlan && /* @__PURE__ */ jsxs5(Flex, { $justifyContent: "space-between", children: [
|
10583
|
+
/* @__PURE__ */ jsx10(Box, { $opacity: "0.625", children: /* @__PURE__ */ jsxs5(
|
10584
|
+
Text,
|
10585
|
+
{
|
10586
|
+
$font: theme.typography.text.fontFamily,
|
10587
|
+
$size: theme.typography.text.fontSize,
|
10588
|
+
$weight: theme.typography.text.fontWeight,
|
10589
|
+
$color: theme.typography.text.color,
|
10590
|
+
children: [
|
10591
|
+
planPeriod === "month" ? "Monthly" : "Yearly",
|
10592
|
+
" total:",
|
10593
|
+
" "
|
10594
|
+
]
|
10595
|
+
}
|
10596
|
+
) }),
|
10597
|
+
/* @__PURE__ */ jsx10(Box, { children: /* @__PURE__ */ jsxs5(
|
10598
|
+
Text,
|
10599
|
+
{
|
10600
|
+
$font: theme.typography.text.fontFamily,
|
10601
|
+
$size: theme.typography.text.fontSize,
|
10602
|
+
$weight: theme.typography.text.fontWeight,
|
10603
|
+
$color: theme.typography.text.color,
|
10604
|
+
children: [
|
10605
|
+
formatCurrency(
|
10606
|
+
(planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
|
10607
|
+
),
|
10608
|
+
"/",
|
10609
|
+
planPeriod
|
10610
|
+
]
|
10611
|
+
}
|
10612
|
+
) })
|
10613
|
+
] }),
|
10614
|
+
checkoutStage === "plan" ? /* @__PURE__ */ jsx10(
|
10615
|
+
StyledButton,
|
10616
|
+
{
|
10617
|
+
disabled: !selectedPlan,
|
10618
|
+
...selectedPlan && {
|
10619
|
+
onClick: () => setCheckoutStage("checkout")
|
10620
|
+
},
|
10621
|
+
$size: "sm",
|
10622
|
+
children: /* @__PURE__ */ jsxs5(
|
10623
|
+
Flex,
|
10624
|
+
{
|
10625
|
+
$gap: "0.5rem",
|
10626
|
+
$justifyContent: "center",
|
10627
|
+
$alignItems: "center",
|
10628
|
+
$padding: "0 1rem",
|
10629
|
+
children: [
|
10630
|
+
/* @__PURE__ */ jsx10(Text, { $align: "left", children: "Next: Checkout" }),
|
10631
|
+
/* @__PURE__ */ jsx10(Icon2, { name: "arrow-right" })
|
10632
|
+
]
|
10633
|
+
}
|
10634
|
+
)
|
10635
|
+
}
|
10636
|
+
) : /* @__PURE__ */ jsx10(
|
10637
|
+
StyledButton,
|
10638
|
+
{
|
10639
|
+
disabled: !api || !selectedPlan || selectedPlan?.id === currentPlan?.id || !paymentMethodId || isLoading,
|
10640
|
+
onClick: async () => {
|
10641
|
+
const priceId = (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.id;
|
10642
|
+
if (!api || !selectedPlan || !priceId || !paymentMethodId) {
|
10643
|
+
return;
|
10644
|
+
}
|
10645
|
+
try {
|
10646
|
+
setIsLoading(true);
|
10647
|
+
setIsCheckoutComplete(false);
|
10648
|
+
await api.checkout({
|
10649
|
+
changeSubscriptionRequestBody: {
|
10650
|
+
newPlanId: selectedPlan.id,
|
10651
|
+
newPriceId: priceId,
|
10652
|
+
paymentMethodId
|
10653
|
+
}
|
10654
|
+
});
|
10655
|
+
setIsCheckoutComplete(true);
|
10656
|
+
} catch {
|
10657
|
+
setError(
|
10658
|
+
"Error processing payment. Please try a different payment method."
|
10659
|
+
);
|
10660
|
+
} finally {
|
10661
|
+
setIsLoading(false);
|
10662
|
+
}
|
10663
|
+
},
|
10664
|
+
$size: "md",
|
10665
|
+
children: "Pay now"
|
10666
|
+
}
|
10667
|
+
),
|
10668
|
+
/* @__PURE__ */ jsx10(Box, { $opacity: "0.625", children: /* @__PURE__ */ jsx10(
|
10669
|
+
Text,
|
10670
|
+
{
|
10671
|
+
$font: theme.typography.text.fontFamily,
|
10672
|
+
$size: theme.typography.text.fontSize,
|
10673
|
+
$weight: theme.typography.text.fontWeight,
|
10674
|
+
$color: theme.typography.text.color,
|
10675
|
+
children: "Discounts & credits applied at checkout"
|
10676
|
+
}
|
10677
|
+
) }),
|
10678
|
+
error && /* @__PURE__ */ jsx10(Box, { children: /* @__PURE__ */ jsx10(
|
10679
|
+
Text,
|
10680
|
+
{
|
10681
|
+
$font: theme.typography.text.fontFamily,
|
10682
|
+
$size: theme.typography.text.fontSize,
|
10683
|
+
$weight: 500,
|
10684
|
+
$color: "#DB6669",
|
10685
|
+
children: error
|
10686
|
+
}
|
10687
|
+
) })
|
10688
|
+
]
|
10689
|
+
}
|
10690
|
+
)
|
10691
|
+
]
|
10378
10692
|
}
|
10379
10693
|
)
|
10380
10694
|
] })
|
@@ -10382,7 +10696,7 @@ var CheckoutDialog = () => {
|
|
10382
10696
|
};
|
10383
10697
|
|
10384
10698
|
// src/components/elements/plan-manager/PlanManager.tsx
|
10385
|
-
import { jsx as
|
10699
|
+
import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
10386
10700
|
var resolveDesignProps = (props) => {
|
10387
10701
|
return {
|
10388
10702
|
header: {
|
@@ -10406,28 +10720,29 @@ var resolveDesignProps = (props) => {
|
|
10406
10720
|
},
|
10407
10721
|
callToAction: {
|
10408
10722
|
isVisible: props.callToAction?.isVisible ?? true,
|
10409
|
-
buttonSize: props.callToAction?.buttonSize ?? "
|
10723
|
+
buttonSize: props.callToAction?.buttonSize ?? "lg",
|
10410
10724
|
buttonStyle: props.callToAction?.buttonStyle ?? "primary"
|
10411
10725
|
}
|
10412
10726
|
};
|
10413
10727
|
};
|
10414
10728
|
var PlanManager = forwardRef(({ children, className, portal, ...rest }, ref) => {
|
10415
10729
|
const props = resolveDesignProps(rest);
|
10416
|
-
const
|
10417
|
-
const {
|
10730
|
+
const theme = nt();
|
10731
|
+
const { data, layout, stripe, setLayout } = useEmbed();
|
10732
|
+
const { currentPlan, canChangePlan } = useMemo6(() => {
|
10418
10733
|
return {
|
10419
10734
|
currentPlan: data.company?.plan,
|
10420
10735
|
canChangePlan: stripe !== null
|
10421
10736
|
};
|
10422
10737
|
}, [data.company, stripe]);
|
10423
|
-
return /* @__PURE__ */
|
10424
|
-
/* @__PURE__ */
|
10738
|
+
return /* @__PURE__ */ jsxs6("div", { ref, className, children: [
|
10739
|
+
/* @__PURE__ */ jsx11(
|
10425
10740
|
Flex,
|
10426
10741
|
{
|
10427
10742
|
$flexDirection: "column",
|
10428
10743
|
$gap: "0.75rem",
|
10429
10744
|
...canChangePlan && { $margin: "0 0 0.5rem" },
|
10430
|
-
children: props.header.isVisible && currentPlan && /* @__PURE__ */
|
10745
|
+
children: props.header.isVisible && currentPlan && /* @__PURE__ */ jsxs6(
|
10431
10746
|
Flex,
|
10432
10747
|
{
|
10433
10748
|
$justifyContent: "space-between",
|
@@ -10435,36 +10750,36 @@ var PlanManager = forwardRef(({ children, className, portal, ...rest }, ref) =>
|
|
10435
10750
|
$width: "100%",
|
10436
10751
|
...canChangePlan && { $margin: "0 0 1.5rem" },
|
10437
10752
|
children: [
|
10438
|
-
/* @__PURE__ */
|
10439
|
-
/* @__PURE__ */
|
10753
|
+
/* @__PURE__ */ jsxs6("div", { children: [
|
10754
|
+
/* @__PURE__ */ jsx11(Box, { $margin: "0 0 0.75rem", children: /* @__PURE__ */ jsx11(
|
10440
10755
|
Text,
|
10441
10756
|
{
|
10442
|
-
$font:
|
10443
|
-
$size:
|
10444
|
-
$weight:
|
10445
|
-
$color:
|
10757
|
+
$font: theme.typography[props.header.title.fontStyle].fontFamily,
|
10758
|
+
$size: theme.typography[props.header.title.fontStyle].fontSize,
|
10759
|
+
$weight: theme.typography[props.header.title.fontStyle].fontWeight,
|
10760
|
+
$color: theme.typography[props.header.title.fontStyle].color,
|
10446
10761
|
$lineHeight: 1,
|
10447
10762
|
children: currentPlan.name
|
10448
10763
|
}
|
10449
10764
|
) }),
|
10450
|
-
props.header.description.isVisible && currentPlan.description && /* @__PURE__ */
|
10765
|
+
props.header.description.isVisible && currentPlan.description && /* @__PURE__ */ jsx11(
|
10451
10766
|
Text,
|
10452
10767
|
{
|
10453
|
-
$font:
|
10454
|
-
$size:
|
10455
|
-
$weight:
|
10456
|
-
$color:
|
10768
|
+
$font: theme.typography[props.header.description.fontStyle].fontFamily,
|
10769
|
+
$size: theme.typography[props.header.description.fontStyle].fontSize,
|
10770
|
+
$weight: theme.typography[props.header.description.fontStyle].fontWeight,
|
10771
|
+
$color: theme.typography[props.header.description.fontStyle].color,
|
10457
10772
|
children: currentPlan.description
|
10458
10773
|
}
|
10459
10774
|
)
|
10460
10775
|
] }),
|
10461
|
-
props.header.price.isVisible && typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */
|
10776
|
+
props.header.price.isVisible && typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ jsxs6(
|
10462
10777
|
Text,
|
10463
10778
|
{
|
10464
|
-
$font:
|
10465
|
-
$size:
|
10466
|
-
$weight:
|
10467
|
-
$color:
|
10779
|
+
$font: theme.typography[props.header.price.fontStyle].fontFamily,
|
10780
|
+
$size: theme.typography[props.header.price.fontStyle].fontSize,
|
10781
|
+
$weight: theme.typography[props.header.price.fontStyle].fontWeight,
|
10782
|
+
$color: theme.typography[props.header.price.fontStyle].color,
|
10468
10783
|
children: [
|
10469
10784
|
formatCurrency(currentPlan.planPrice),
|
10470
10785
|
"/",
|
@@ -10477,7 +10792,7 @@ var PlanManager = forwardRef(({ children, className, portal, ...rest }, ref) =>
|
|
10477
10792
|
)
|
10478
10793
|
}
|
10479
10794
|
),
|
10480
|
-
canChangePlan && props.callToAction.isVisible && /* @__PURE__ */
|
10795
|
+
canChangePlan && props.callToAction.isVisible && /* @__PURE__ */ jsx11(
|
10481
10796
|
StyledButton,
|
10482
10797
|
{
|
10483
10798
|
onClick: () => {
|
@@ -10485,24 +10800,16 @@ var PlanManager = forwardRef(({ children, className, portal, ...rest }, ref) =>
|
|
10485
10800
|
},
|
10486
10801
|
$size: props.callToAction.buttonSize,
|
10487
10802
|
$color: props.callToAction.buttonStyle,
|
10488
|
-
children:
|
10489
|
-
Text,
|
10490
|
-
{
|
10491
|
-
$font: settings.theme.typography.text.fontFamily,
|
10492
|
-
$size: settings.theme.typography.text.fontSize,
|
10493
|
-
$weight: settings.theme.typography.text.fontWeight,
|
10494
|
-
children: "Change Plan"
|
10495
|
-
}
|
10496
|
-
)
|
10803
|
+
children: "Change Plan"
|
10497
10804
|
}
|
10498
10805
|
),
|
10499
|
-
canChangePlan && layout === "checkout" && createPortal(/* @__PURE__ */
|
10806
|
+
canChangePlan && layout === "checkout" && createPortal(/* @__PURE__ */ jsx11(CheckoutDialog, {}), portal || document.body)
|
10500
10807
|
] });
|
10501
10808
|
});
|
10502
10809
|
|
10503
10810
|
// src/components/elements/included-features/IncludedFeatures.tsx
|
10504
|
-
import { forwardRef as forwardRef2, useMemo as
|
10505
|
-
import { jsx as
|
10811
|
+
import { forwardRef as forwardRef2, useMemo as useMemo7 } from "react";
|
10812
|
+
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
10506
10813
|
function resolveDesignProps2(props) {
|
10507
10814
|
return {
|
10508
10815
|
header: {
|
@@ -10512,12 +10819,12 @@ function resolveDesignProps2(props) {
|
|
10512
10819
|
},
|
10513
10820
|
icons: {
|
10514
10821
|
isVisible: props.icons?.isVisible ?? true,
|
10515
|
-
fontStyle: props.icons?.fontStyle ?? "
|
10822
|
+
fontStyle: props.icons?.fontStyle ?? "heading5",
|
10516
10823
|
style: props.icons?.style ?? "light"
|
10517
10824
|
},
|
10518
10825
|
entitlement: {
|
10519
10826
|
isVisible: props.entitlement?.isVisible ?? true,
|
10520
|
-
fontStyle: props.entitlement?.fontStyle ?? "
|
10827
|
+
fontStyle: props.entitlement?.fontStyle ?? "text"
|
10521
10828
|
},
|
10522
10829
|
usage: {
|
10523
10830
|
isVisible: props.usage?.isVisible ?? true,
|
@@ -10527,8 +10834,9 @@ function resolveDesignProps2(props) {
|
|
10527
10834
|
}
|
10528
10835
|
var IncludedFeatures = forwardRef2(({ className, ...rest }, ref) => {
|
10529
10836
|
const props = resolveDesignProps2(rest);
|
10530
|
-
const
|
10531
|
-
const
|
10837
|
+
const theme = nt();
|
10838
|
+
const { data } = useEmbed();
|
10839
|
+
const features = useMemo7(() => {
|
10532
10840
|
return (data.featureUsage?.features || []).map(
|
10533
10841
|
({
|
10534
10842
|
access,
|
@@ -10555,14 +10863,17 @@ var IncludedFeatures = forwardRef2(({ className, ...rest }, ref) => {
|
|
10555
10863
|
}
|
10556
10864
|
);
|
10557
10865
|
}, [data.featureUsage]);
|
10558
|
-
|
10559
|
-
|
10866
|
+
const isLightBackground = useMemo7(() => {
|
10867
|
+
return hexToHSL(theme.card.background).l > 50;
|
10868
|
+
}, [theme.card.background]);
|
10869
|
+
return /* @__PURE__ */ jsxs7(Flex, { ref, className, $flexDirection: "column", $gap: "1.5rem", children: [
|
10870
|
+
props.header.isVisible && /* @__PURE__ */ jsx12(Box, { children: /* @__PURE__ */ jsx12(
|
10560
10871
|
Text,
|
10561
10872
|
{
|
10562
|
-
$font:
|
10563
|
-
$size:
|
10564
|
-
$weight:
|
10565
|
-
$color:
|
10873
|
+
$font: theme.typography[props.header.fontStyle].fontFamily,
|
10874
|
+
$size: theme.typography[props.header.fontStyle].fontSize,
|
10875
|
+
$weight: theme.typography[props.header.fontStyle].fontWeight,
|
10876
|
+
$color: theme.typography[props.header.fontStyle].color,
|
10566
10877
|
children: props.header.text
|
10567
10878
|
}
|
10568
10879
|
) }),
|
@@ -10573,7 +10884,7 @@ var IncludedFeatures = forwardRef2(({ className, ...rest }, ref) => {
|
|
10573
10884
|
}
|
10574
10885
|
return [
|
10575
10886
|
...acc,
|
10576
|
-
/* @__PURE__ */
|
10887
|
+
/* @__PURE__ */ jsxs7(
|
10577
10888
|
Flex,
|
10578
10889
|
{
|
10579
10890
|
$flexWrap: "wrap",
|
@@ -10581,49 +10892,51 @@ var IncludedFeatures = forwardRef2(({ className, ...rest }, ref) => {
|
|
10581
10892
|
$alignItems: "center",
|
10582
10893
|
$gap: "1rem",
|
10583
10894
|
children: [
|
10584
|
-
/* @__PURE__ */
|
10585
|
-
props.icons.isVisible && feature?.icon && /* @__PURE__ */
|
10895
|
+
/* @__PURE__ */ jsxs7(Flex, { $gap: "1rem", children: [
|
10896
|
+
props.icons.isVisible && feature?.icon && /* @__PURE__ */ jsx12(
|
10586
10897
|
IconRound,
|
10587
10898
|
{
|
10588
10899
|
name: feature.icon,
|
10589
10900
|
size: "sm",
|
10590
10901
|
colors: [
|
10591
|
-
|
10592
|
-
|
10902
|
+
theme.primary,
|
10903
|
+
isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.25)"
|
10593
10904
|
]
|
10594
10905
|
}
|
10595
10906
|
),
|
10596
|
-
feature?.name && /* @__PURE__ */
|
10907
|
+
feature?.name && /* @__PURE__ */ jsx12(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx12(
|
10597
10908
|
Text,
|
10598
10909
|
{
|
10599
|
-
$font:
|
10600
|
-
$size:
|
10601
|
-
$weight:
|
10602
|
-
$color:
|
10910
|
+
$font: theme.typography[props.icons.fontStyle].fontFamily,
|
10911
|
+
$size: theme.typography[props.icons.fontStyle].fontSize,
|
10912
|
+
$weight: theme.typography[props.icons.fontStyle].fontWeight,
|
10913
|
+
$color: theme.typography[props.icons.fontStyle].color,
|
10603
10914
|
children: feature.name
|
10604
10915
|
}
|
10605
10916
|
) })
|
10606
10917
|
] }),
|
10607
|
-
allocationType === "numeric" && feature?.name && /* @__PURE__ */
|
10608
|
-
props.entitlement.isVisible && /* @__PURE__ */
|
10918
|
+
allocationType === "numeric" && feature?.name && /* @__PURE__ */ jsxs7(Box, { $textAlign: "right", children: [
|
10919
|
+
props.entitlement.isVisible && /* @__PURE__ */ jsx12(
|
10609
10920
|
Text,
|
10610
10921
|
{
|
10611
10922
|
as: Box,
|
10612
|
-
$font:
|
10613
|
-
$size:
|
10614
|
-
$weight:
|
10615
|
-
$
|
10923
|
+
$font: theme.typography[props.entitlement.fontStyle].fontFamily,
|
10924
|
+
$size: theme.typography[props.entitlement.fontStyle].fontSize,
|
10925
|
+
$weight: theme.typography[props.entitlement.fontStyle].fontWeight,
|
10926
|
+
$lineHeight: 1.5,
|
10927
|
+
$color: theme.typography[props.entitlement.fontStyle].color,
|
10616
10928
|
children: typeof allocation === "number" ? `${allocation} ${feature.name}` : `Unlimited ${feature.name}`
|
10617
10929
|
}
|
10618
10930
|
),
|
10619
|
-
props.usage.isVisible && /* @__PURE__ */
|
10931
|
+
props.usage.isVisible && /* @__PURE__ */ jsx12(
|
10620
10932
|
Text,
|
10621
10933
|
{
|
10622
10934
|
as: Box,
|
10623
|
-
$font:
|
10624
|
-
$size:
|
10625
|
-
$weight:
|
10626
|
-
$
|
10935
|
+
$font: theme.typography[props.usage.fontStyle].fontFamily,
|
10936
|
+
$size: theme.typography[props.usage.fontStyle].fontSize,
|
10937
|
+
$weight: theme.typography[props.usage.fontStyle].fontWeight,
|
10938
|
+
$lineHeight: 1.5,
|
10939
|
+
$color: theme.typography[props.usage.fontStyle].color,
|
10627
10940
|
children: typeof allocation === "number" ? `${usage} of ${allocation} used` : `${usage} used`
|
10628
10941
|
}
|
10629
10942
|
)
|
@@ -10640,8 +10953,8 @@ var IncludedFeatures = forwardRef2(({ className, ...rest }, ref) => {
|
|
10640
10953
|
});
|
10641
10954
|
|
10642
10955
|
// src/components/elements/metered-features/MeteredFeatures.tsx
|
10643
|
-
import { forwardRef as forwardRef3, useMemo as
|
10644
|
-
import { jsx as
|
10956
|
+
import { forwardRef as forwardRef3, useMemo as useMemo8 } from "react";
|
10957
|
+
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
10645
10958
|
function resolveDesignProps3(props) {
|
10646
10959
|
return {
|
10647
10960
|
isVisible: props.isVisible ?? true,
|
@@ -10672,8 +10985,9 @@ function resolveDesignProps3(props) {
|
|
10672
10985
|
}
|
10673
10986
|
var MeteredFeatures = forwardRef3(({ className, ...rest }, ref) => {
|
10674
10987
|
const props = resolveDesignProps3(rest);
|
10675
|
-
const
|
10676
|
-
const
|
10988
|
+
const theme = nt();
|
10989
|
+
const { data } = useEmbed();
|
10990
|
+
const features = useMemo8(() => {
|
10677
10991
|
return (data.featureUsage?.features || []).map(
|
10678
10992
|
({
|
10679
10993
|
access,
|
@@ -10700,67 +11014,67 @@ var MeteredFeatures = forwardRef3(({ className, ...rest }, ref) => {
|
|
10700
11014
|
}
|
10701
11015
|
);
|
10702
11016
|
}, [data.featureUsage]);
|
10703
|
-
return /* @__PURE__ */
|
11017
|
+
return /* @__PURE__ */ jsx13(Flex, { ref, className, $flexDirection: "column", $gap: "1.5rem", children: features.reduce(
|
10704
11018
|
(acc, { allocation, allocationType, feature, usage }, index) => {
|
10705
11019
|
if (!props.isVisible || allocationType !== "numeric" || typeof allocation !== "number") {
|
10706
11020
|
return acc;
|
10707
11021
|
}
|
10708
11022
|
return [
|
10709
11023
|
...acc,
|
10710
|
-
/* @__PURE__ */
|
10711
|
-
props.icon.isVisible && feature?.icon && /* @__PURE__ */
|
10712
|
-
/* @__PURE__ */
|
10713
|
-
/* @__PURE__ */
|
10714
|
-
feature?.name && /* @__PURE__ */
|
10715
|
-
/* @__PURE__ */
|
11024
|
+
/* @__PURE__ */ jsxs8(Flex, { $gap: "1.5rem", children: [
|
11025
|
+
props.icon.isVisible && feature?.icon && /* @__PURE__ */ jsx13(Box, { $flexShrink: "0", children: /* @__PURE__ */ jsx13(IconRound, { name: feature.icon, size: "sm" }) }),
|
11026
|
+
/* @__PURE__ */ jsxs8(Box, { $flexGrow: "1", children: [
|
11027
|
+
/* @__PURE__ */ jsxs8(Flex, { children: [
|
11028
|
+
feature?.name && /* @__PURE__ */ jsxs8(Box, { $flexGrow: "1", children: [
|
11029
|
+
/* @__PURE__ */ jsx13(
|
10716
11030
|
Text,
|
10717
11031
|
{
|
10718
11032
|
as: Box,
|
10719
|
-
$font:
|
10720
|
-
$size:
|
10721
|
-
$weight:
|
10722
|
-
$color:
|
11033
|
+
$font: theme.typography[props.header.fontStyle].fontFamily,
|
11034
|
+
$size: theme.typography[props.header.fontStyle].fontSize,
|
11035
|
+
$weight: theme.typography[props.header.fontStyle].fontWeight,
|
11036
|
+
$color: theme.typography[props.header.fontStyle].color,
|
10723
11037
|
children: feature.name
|
10724
11038
|
}
|
10725
11039
|
),
|
10726
|
-
props.description.isVisible && /* @__PURE__ */
|
11040
|
+
props.description.isVisible && /* @__PURE__ */ jsx13(
|
10727
11041
|
Text,
|
10728
11042
|
{
|
10729
11043
|
as: Box,
|
10730
|
-
$font:
|
10731
|
-
$size:
|
10732
|
-
$weight:
|
10733
|
-
$color:
|
11044
|
+
$font: theme.typography[props.description.fontStyle].fontFamily,
|
11045
|
+
$size: theme.typography[props.description.fontStyle].fontSize,
|
11046
|
+
$weight: theme.typography[props.description.fontStyle].fontWeight,
|
11047
|
+
$color: theme.typography[props.description.fontStyle].color,
|
10734
11048
|
children: feature.description
|
10735
11049
|
}
|
10736
11050
|
)
|
10737
11051
|
] }),
|
10738
|
-
allocationType === "numeric" && feature?.name && /* @__PURE__ */
|
10739
|
-
props.allocation.isVisible && /* @__PURE__ */
|
11052
|
+
allocationType === "numeric" && feature?.name && /* @__PURE__ */ jsxs8(Box, { $textAlign: "right", children: [
|
11053
|
+
props.allocation.isVisible && /* @__PURE__ */ jsx13(
|
10740
11054
|
Text,
|
10741
11055
|
{
|
10742
11056
|
as: Box,
|
10743
|
-
$font:
|
10744
|
-
$size:
|
10745
|
-
$weight:
|
10746
|
-
$color:
|
11057
|
+
$font: theme.typography[props.allocation.fontStyle].fontFamily,
|
11058
|
+
$size: theme.typography[props.allocation.fontStyle].fontSize,
|
11059
|
+
$weight: theme.typography[props.allocation.fontStyle].fontWeight,
|
11060
|
+
$color: theme.typography[props.allocation.fontStyle].color,
|
10747
11061
|
children: typeof allocation === "number" ? `${allocation} ${feature.name}` : `Unlimited ${feature.name}`
|
10748
11062
|
}
|
10749
11063
|
),
|
10750
|
-
props.usage.isVisible && /* @__PURE__ */
|
11064
|
+
props.usage.isVisible && /* @__PURE__ */ jsx13(
|
10751
11065
|
Text,
|
10752
11066
|
{
|
10753
11067
|
as: Box,
|
10754
|
-
$font:
|
10755
|
-
$size:
|
10756
|
-
$weight:
|
10757
|
-
$color:
|
11068
|
+
$font: theme.typography[props.usage.fontStyle].fontFamily,
|
11069
|
+
$size: theme.typography[props.usage.fontStyle].fontSize,
|
11070
|
+
$weight: theme.typography[props.usage.fontStyle].fontWeight,
|
11071
|
+
$color: theme.typography[props.usage.fontStyle].color,
|
10758
11072
|
children: typeof allocation === "number" ? `${usage} of ${allocation} used` : `${usage} used`
|
10759
11073
|
}
|
10760
11074
|
)
|
10761
11075
|
] })
|
10762
11076
|
] }),
|
10763
|
-
typeof usage === "number" && typeof allocation === "number" && /* @__PURE__ */
|
11077
|
+
typeof usage === "number" && typeof allocation === "number" && /* @__PURE__ */ jsx13(Box, { children: /* @__PURE__ */ jsx13(
|
10764
11078
|
ProgressBar,
|
10765
11079
|
{
|
10766
11080
|
progress: usage / allocation * 100,
|
@@ -10778,8 +11092,8 @@ var MeteredFeatures = forwardRef3(({ className, ...rest }, ref) => {
|
|
10778
11092
|
});
|
10779
11093
|
|
10780
11094
|
// src/components/elements/upcoming-bill/UpcomingBill.tsx
|
10781
|
-
import { forwardRef as forwardRef4, useMemo as
|
10782
|
-
import { jsx as
|
11095
|
+
import { forwardRef as forwardRef4, useMemo as useMemo9 } from "react";
|
11096
|
+
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
10783
11097
|
function resolveDesignProps4(props) {
|
10784
11098
|
return {
|
10785
11099
|
header: {
|
@@ -10800,8 +11114,9 @@ function resolveDesignProps4(props) {
|
|
10800
11114
|
}
|
10801
11115
|
var UpcomingBill = forwardRef4(({ className, ...rest }, ref) => {
|
10802
11116
|
const props = resolveDesignProps4(rest);
|
10803
|
-
const
|
10804
|
-
const {
|
11117
|
+
const theme = nt();
|
11118
|
+
const { data, stripe } = useEmbed();
|
11119
|
+
const { upcomingInvoice } = useMemo9(() => {
|
10805
11120
|
return {
|
10806
11121
|
upcomingInvoice: {
|
10807
11122
|
...data.upcomingInvoice?.amountDue && {
|
@@ -10816,23 +11131,23 @@ var UpcomingBill = forwardRef4(({ className, ...rest }, ref) => {
|
|
10816
11131
|
}
|
10817
11132
|
};
|
10818
11133
|
}, [data.subscription, data.upcomingInvoice]);
|
10819
|
-
if (!stripe || !
|
11134
|
+
if (!stripe || !upcomingInvoice.amountDue || !upcomingInvoice.dueDate) {
|
10820
11135
|
return null;
|
10821
11136
|
}
|
10822
|
-
return /* @__PURE__ */
|
10823
|
-
props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */
|
11137
|
+
return /* @__PURE__ */ jsxs9("div", { ref, className, children: [
|
11138
|
+
props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */ jsx14(
|
10824
11139
|
Flex,
|
10825
11140
|
{
|
10826
11141
|
$justifyContent: "space-between",
|
10827
11142
|
$alignItems: "center",
|
10828
11143
|
$margin: "0 0 0.75rem",
|
10829
|
-
children: /* @__PURE__ */
|
11144
|
+
children: /* @__PURE__ */ jsxs9(
|
10830
11145
|
Text,
|
10831
11146
|
{
|
10832
|
-
$font:
|
10833
|
-
$size:
|
10834
|
-
$weight:
|
10835
|
-
$color:
|
11147
|
+
$font: theme.typography[props.header.fontStyle].fontFamily,
|
11148
|
+
$size: theme.typography[props.header.fontStyle].fontSize,
|
11149
|
+
$weight: theme.typography[props.header.fontStyle].fontWeight,
|
11150
|
+
$color: theme.typography[props.header.fontStyle].color,
|
10836
11151
|
children: [
|
10837
11152
|
props.header.prefix,
|
10838
11153
|
" ",
|
@@ -10842,25 +11157,25 @@ var UpcomingBill = forwardRef4(({ className, ...rest }, ref) => {
|
|
10842
11157
|
)
|
10843
11158
|
}
|
10844
11159
|
),
|
10845
|
-
upcomingInvoice.amountDue && /* @__PURE__ */
|
10846
|
-
props.price.isVisible && /* @__PURE__ */
|
11160
|
+
upcomingInvoice.amountDue && /* @__PURE__ */ jsxs9(Flex, { $justifyContent: "space-between", $alignItems: "start", $gap: "1rem", children: [
|
11161
|
+
props.price.isVisible && /* @__PURE__ */ jsx14(Flex, { $alignItems: "end", $flexGrow: "1", children: /* @__PURE__ */ jsx14(
|
10847
11162
|
Text,
|
10848
11163
|
{
|
10849
|
-
$font:
|
10850
|
-
$size:
|
10851
|
-
$weight:
|
10852
|
-
$color:
|
11164
|
+
$font: theme.typography[props.price.fontStyle].fontFamily,
|
11165
|
+
$size: theme.typography[props.price.fontStyle].fontSize,
|
11166
|
+
$weight: theme.typography[props.price.fontStyle].fontWeight,
|
11167
|
+
$color: theme.typography[props.price.fontStyle].color,
|
10853
11168
|
$lineHeight: 1,
|
10854
11169
|
children: formatCurrency(upcomingInvoice.amountDue)
|
10855
11170
|
}
|
10856
11171
|
) }),
|
10857
|
-
/* @__PURE__ */
|
11172
|
+
/* @__PURE__ */ jsx14(Box, { $maxWidth: "10rem", $lineHeight: "1", $textAlign: "right", children: /* @__PURE__ */ jsx14(
|
10858
11173
|
Text,
|
10859
11174
|
{
|
10860
|
-
$font:
|
10861
|
-
$size:
|
10862
|
-
$weight:
|
10863
|
-
$color:
|
11175
|
+
$font: theme.typography[props.contractEndDate.fontStyle].fontFamily,
|
11176
|
+
$size: theme.typography[props.contractEndDate.fontStyle].fontSize,
|
11177
|
+
$weight: theme.typography[props.contractEndDate.fontStyle].fontWeight,
|
11178
|
+
$color: theme.typography[props.contractEndDate.fontStyle].color,
|
10864
11179
|
children: "Estimated monthly bill."
|
10865
11180
|
}
|
10866
11181
|
) })
|
@@ -10869,9 +11184,9 @@ var UpcomingBill = forwardRef4(({ className, ...rest }, ref) => {
|
|
10869
11184
|
});
|
10870
11185
|
|
10871
11186
|
// src/components/elements/payment-method/PaymentMethod.tsx
|
10872
|
-
import { forwardRef as forwardRef5, useMemo as
|
11187
|
+
import { forwardRef as forwardRef5, useMemo as useMemo10 } from "react";
|
10873
11188
|
import { createPortal as createPortal2 } from "react-dom";
|
10874
|
-
import { jsx as
|
11189
|
+
import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
|
10875
11190
|
var resolveDesignProps5 = (props) => {
|
10876
11191
|
return {
|
10877
11192
|
header: {
|
@@ -10885,8 +11200,9 @@ var resolveDesignProps5 = (props) => {
|
|
10885
11200
|
};
|
10886
11201
|
var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref) => {
|
10887
11202
|
const props = resolveDesignProps5(rest);
|
10888
|
-
const
|
10889
|
-
const
|
11203
|
+
const theme = nt();
|
11204
|
+
const { data, stripe, layout } = useEmbed();
|
11205
|
+
const paymentMethod = useMemo10(() => {
|
10890
11206
|
const { cardLast4, cardExpMonth, cardExpYear } = data.subscription?.paymentMethod || {};
|
10891
11207
|
let monthsToExpiration;
|
10892
11208
|
if (typeof cardExpYear === "number" && typeof cardExpMonth === "number") {
|
@@ -10902,31 +11218,34 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
10902
11218
|
monthsToExpiration
|
10903
11219
|
};
|
10904
11220
|
}, [data.subscription?.paymentMethod]);
|
10905
|
-
|
11221
|
+
const isLightBackground = useMemo10(() => {
|
11222
|
+
return hexToHSL(theme.card.background).l > 50;
|
11223
|
+
}, [theme.card.background]);
|
11224
|
+
if (!stripe || !paymentMethod.cardLast4) {
|
10906
11225
|
return null;
|
10907
11226
|
}
|
10908
|
-
return /* @__PURE__ */
|
10909
|
-
props.header.isVisible && /* @__PURE__ */
|
11227
|
+
return /* @__PURE__ */ jsxs10("div", { ref, className, children: [
|
11228
|
+
props.header.isVisible && /* @__PURE__ */ jsxs10(
|
10910
11229
|
Flex,
|
10911
11230
|
{
|
10912
11231
|
$justifyContent: "space-between",
|
10913
11232
|
$alignItems: "center",
|
10914
11233
|
$margin: "0 0 1rem",
|
10915
11234
|
children: [
|
10916
|
-
/* @__PURE__ */
|
11235
|
+
/* @__PURE__ */ jsx15(
|
10917
11236
|
Text,
|
10918
11237
|
{
|
10919
|
-
$font:
|
10920
|
-
$size:
|
10921
|
-
$weight:
|
10922
|
-
$color:
|
11238
|
+
$font: theme.typography[props.header.fontStyle].fontFamily,
|
11239
|
+
$size: theme.typography[props.header.fontStyle].fontSize,
|
11240
|
+
$weight: theme.typography[props.header.fontStyle].fontWeight,
|
11241
|
+
$color: theme.typography[props.header.fontStyle].color,
|
10923
11242
|
children: "Payment Method"
|
10924
11243
|
}
|
10925
11244
|
),
|
10926
|
-
typeof paymentMethod.monthsToExpiration === "number" && Math.abs(paymentMethod.monthsToExpiration) < 4 && /* @__PURE__ */
|
11245
|
+
typeof paymentMethod.monthsToExpiration === "number" && Math.abs(paymentMethod.monthsToExpiration) < 4 && /* @__PURE__ */ jsx15(
|
10927
11246
|
Text,
|
10928
11247
|
{
|
10929
|
-
$font:
|
11248
|
+
$font: theme.typography.text.fontFamily,
|
10930
11249
|
$size: 14,
|
10931
11250
|
$color: "#DB6769",
|
10932
11251
|
children: paymentMethod.monthsToExpiration > 0 ? `Expires in ${paymentMethod.monthsToExpiration} mo` : "Expired"
|
@@ -10935,25 +11254,25 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
10935
11254
|
]
|
10936
11255
|
}
|
10937
11256
|
),
|
10938
|
-
paymentMethod.cardLast4 && /* @__PURE__ */
|
11257
|
+
paymentMethod.cardLast4 && /* @__PURE__ */ jsx15(
|
10939
11258
|
Flex,
|
10940
11259
|
{
|
10941
11260
|
$justifyContent: "space-between",
|
10942
11261
|
$alignItems: "center",
|
10943
11262
|
$margin: "0 0 1rem",
|
10944
|
-
$
|
11263
|
+
$backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.125)",
|
10945
11264
|
$padding: "0.375rem 1rem",
|
10946
11265
|
$borderRadius: "9999px",
|
10947
|
-
children: /* @__PURE__ */
|
11266
|
+
children: /* @__PURE__ */ jsxs10(Text, { $font: theme.typography.text.fontFamily, $size: 14, children: [
|
10948
11267
|
"\u{1F4B3} Card ending in ",
|
10949
11268
|
paymentMethod.cardLast4
|
10950
11269
|
] })
|
10951
11270
|
}
|
10952
11271
|
),
|
10953
11272
|
layout === "payment" && createPortal2(
|
10954
|
-
/* @__PURE__ */
|
10955
|
-
/* @__PURE__ */
|
10956
|
-
/* @__PURE__ */
|
11273
|
+
/* @__PURE__ */ jsxs10(Modal, { size: "md", children: [
|
11274
|
+
/* @__PURE__ */ jsx15(ModalHeader, { children: /* @__PURE__ */ jsx15(Box, { $fontWeight: "600", children: "Edit payment method" }) }),
|
11275
|
+
/* @__PURE__ */ jsxs10(
|
10957
11276
|
Flex,
|
10958
11277
|
{
|
10959
11278
|
$flexDirection: "column",
|
@@ -10961,7 +11280,7 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
10961
11280
|
$height: "100%",
|
10962
11281
|
$gap: "1.5rem",
|
10963
11282
|
children: [
|
10964
|
-
/* @__PURE__ */
|
11283
|
+
/* @__PURE__ */ jsx15(
|
10965
11284
|
Flex,
|
10966
11285
|
{
|
10967
11286
|
$flexDirection: "column",
|
@@ -10970,8 +11289,8 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
10970
11289
|
$borderRadius: "0 0 0.5rem 0.5rem",
|
10971
11290
|
$flex: "1",
|
10972
11291
|
$height: "100%",
|
10973
|
-
children: /* @__PURE__ */
|
10974
|
-
/* @__PURE__ */
|
11292
|
+
children: /* @__PURE__ */ jsxs10(Flex, { $flexDirection: "column", $height: "100%", children: [
|
11293
|
+
/* @__PURE__ */ jsx15(
|
10975
11294
|
Box,
|
10976
11295
|
{
|
10977
11296
|
$fontSize: "18px",
|
@@ -10981,8 +11300,8 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
10981
11300
|
children: "Default"
|
10982
11301
|
}
|
10983
11302
|
),
|
10984
|
-
/* @__PURE__ */
|
10985
|
-
/* @__PURE__ */
|
11303
|
+
/* @__PURE__ */ jsxs10(Flex, { $gap: "1rem", children: [
|
11304
|
+
/* @__PURE__ */ jsx15(
|
10986
11305
|
Flex,
|
10987
11306
|
{
|
10988
11307
|
$alignItems: "center",
|
@@ -10990,65 +11309,48 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
10990
11309
|
$border: "1px solid #E2E5E9",
|
10991
11310
|
$borderRadius: ".5rem",
|
10992
11311
|
$backgroundColor: "#ffffff",
|
10993
|
-
$flexDirection: "row",
|
10994
11312
|
$gap: "1rem",
|
10995
11313
|
$width: "100%",
|
10996
|
-
children: /* @__PURE__ */
|
10997
|
-
Flex,
|
10998
|
-
|
10999
|
-
|
11000
|
-
|
11001
|
-
|
11002
|
-
|
11003
|
-
|
11004
|
-
|
11005
|
-
|
11006
|
-
|
11007
|
-
|
11008
|
-
|
11009
|
-
|
11010
|
-
|
11011
|
-
"
|
11012
|
-
|
11013
|
-
|
11014
|
-
|
11015
|
-
|
11016
|
-
|
11017
|
-
|
11018
|
-
|
11019
|
-
|
11020
|
-
|
11021
|
-
|
11022
|
-
|
11023
|
-
|
11024
|
-
|
11025
|
-
|
11026
|
-
|
11027
|
-
|
11028
|
-
|
11029
|
-
|
11030
|
-
|
11031
|
-
|
11032
|
-
|
11033
|
-
{
|
11034
|
-
d: "M2.788 5.914A7.201 7.201 0 0 0 1 5.237l.028-.125h2.737c.371.013.672.125.77.519l.595 2.836.182.854 1.666-4.21h1.799l-2.674 6.167H4.304L2.788 5.914Zm7.312 5.37H8.399l1.064-6.172h1.7L10.1 11.284Zm6.167-6.021-.232 1.333-.153-.066a3.054 3.054 0 0 0-1.268-.236c-.671 0-.972.269-.98.531 0 .29.365.48.96.762.98.44 1.435.979 1.428 1.681-.014 1.28-1.176 2.108-2.96 2.108-.764-.007-1.5-.158-1.898-.328l.238-1.386.224.099c.553.23.917.328 1.596.328.49 0 1.015-.19 1.022-.604 0-.27-.224-.466-.882-.769-.644-.295-1.505-.788-1.491-1.674C11.878 5.84 13.06 5 14.74 5c.658 0 1.19.138 1.526.263Zm2.26 3.834h1.415c-.07-.308-.392-1.786-.392-1.786l-.12-.531c-.083.23-.23.604-.223.59l-.68 1.727Zm2.1-3.985L22 11.284h-1.575s-.154-.71-.203-.926h-2.184l-.357.926h-1.785l2.527-5.66c.175-.4.483-.512.889-.512h1.316Z",
|
11035
|
-
fill: "#1434CB"
|
11036
|
-
}
|
11037
|
-
)
|
11038
|
-
] })
|
11039
|
-
}
|
11040
|
-
) }),
|
11041
|
-
/* @__PURE__ */ jsx13(Box, { $whiteSpace: "nowrap", children: "Visa **** 4242" })
|
11042
|
-
]
|
11043
|
-
}
|
11044
|
-
),
|
11045
|
-
/* @__PURE__ */ jsx13(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx13(Box, { $fontSize: "12px", $color: "#5D5D5D", children: "Expires: 3/30" }) })
|
11046
|
-
]
|
11047
|
-
}
|
11048
|
-
)
|
11314
|
+
children: /* @__PURE__ */ jsxs10(Flex, { $justifyContent: "space-between", $flex: "1", children: [
|
11315
|
+
/* @__PURE__ */ jsxs10(Flex, { $alignItems: "center", $gap: "1rem", children: [
|
11316
|
+
/* @__PURE__ */ jsx15(Box, { $display: "inline-block", children: /* @__PURE__ */ jsx15(
|
11317
|
+
"svg",
|
11318
|
+
{
|
11319
|
+
viewBox: "0 0 24 16",
|
11320
|
+
fill: "none",
|
11321
|
+
xmlns: "http://www.w3.org/2000/svg",
|
11322
|
+
width: "26px",
|
11323
|
+
height: "auto",
|
11324
|
+
children: /* @__PURE__ */ jsxs10("g", { children: [
|
11325
|
+
/* @__PURE__ */ jsx15(
|
11326
|
+
"rect",
|
11327
|
+
{
|
11328
|
+
stroke: "#DDD",
|
11329
|
+
fill: "#FFF",
|
11330
|
+
x: ".25",
|
11331
|
+
y: ".25",
|
11332
|
+
width: "23",
|
11333
|
+
height: "15.5",
|
11334
|
+
rx: "2"
|
11335
|
+
}
|
11336
|
+
),
|
11337
|
+
/* @__PURE__ */ jsx15(
|
11338
|
+
"path",
|
11339
|
+
{
|
11340
|
+
d: "M2.788 5.914A7.201 7.201 0 0 0 1 5.237l.028-.125h2.737c.371.013.672.125.77.519l.595 2.836.182.854 1.666-4.21h1.799l-2.674 6.167H4.304L2.788 5.914Zm7.312 5.37H8.399l1.064-6.172h1.7L10.1 11.284Zm6.167-6.021-.232 1.333-.153-.066a3.054 3.054 0 0 0-1.268-.236c-.671 0-.972.269-.98.531 0 .29.365.48.96.762.98.44 1.435.979 1.428 1.681-.014 1.28-1.176 2.108-2.96 2.108-.764-.007-1.5-.158-1.898-.328l.238-1.386.224.099c.553.23.917.328 1.596.328.49 0 1.015-.19 1.022-.604 0-.27-.224-.466-.882-.769-.644-.295-1.505-.788-1.491-1.674C11.878 5.84 13.06 5 14.74 5c.658 0 1.19.138 1.526.263Zm2.26 3.834h1.415c-.07-.308-.392-1.786-.392-1.786l-.12-.531c-.083.23-.23.604-.223.59l-.68 1.727Zm2.1-3.985L22 11.284h-1.575s-.154-.71-.203-.926h-2.184l-.357.926h-1.785l2.527-5.66c.175-.4.483-.512.889-.512h1.316Z",
|
11341
|
+
fill: "#1434CB"
|
11342
|
+
}
|
11343
|
+
)
|
11344
|
+
] })
|
11345
|
+
}
|
11346
|
+
) }),
|
11347
|
+
/* @__PURE__ */ jsx15(Box, { $whiteSpace: "nowrap", children: "Visa **** 4242" })
|
11348
|
+
] }),
|
11349
|
+
/* @__PURE__ */ jsx15(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx15(Box, { $fontSize: "12px", $color: "#5D5D5D", children: "Expires: 3/30" }) })
|
11350
|
+
] })
|
11049
11351
|
}
|
11050
11352
|
),
|
11051
|
-
/* @__PURE__ */
|
11353
|
+
/* @__PURE__ */ jsx15(Flex, { children: /* @__PURE__ */ jsx15(
|
11052
11354
|
StyledButton,
|
11053
11355
|
{
|
11054
11356
|
$size: "sm",
|
@@ -11066,7 +11368,7 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
11066
11368
|
] })
|
11067
11369
|
}
|
11068
11370
|
),
|
11069
|
-
/* @__PURE__ */
|
11371
|
+
/* @__PURE__ */ jsx15(
|
11070
11372
|
Flex,
|
11071
11373
|
{
|
11072
11374
|
$flexDirection: "column",
|
@@ -11075,8 +11377,8 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
11075
11377
|
$borderRadius: "0 0 0.5rem 0.5rem",
|
11076
11378
|
$flex: "1",
|
11077
11379
|
$height: "100%",
|
11078
|
-
children: /* @__PURE__ */
|
11079
|
-
/* @__PURE__ */
|
11380
|
+
children: /* @__PURE__ */ jsxs10(Flex, { $flexDirection: "column", $height: "100%", children: [
|
11381
|
+
/* @__PURE__ */ jsx15(
|
11080
11382
|
Box,
|
11081
11383
|
{
|
11082
11384
|
$fontSize: "18px",
|
@@ -11086,8 +11388,8 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
11086
11388
|
children: "Others"
|
11087
11389
|
}
|
11088
11390
|
),
|
11089
|
-
/* @__PURE__ */
|
11090
|
-
/* @__PURE__ */
|
11391
|
+
/* @__PURE__ */ jsxs10(Flex, { $gap: "1rem", children: [
|
11392
|
+
/* @__PURE__ */ jsx15(
|
11091
11393
|
Flex,
|
11092
11394
|
{
|
11093
11395
|
$alignItems: "center",
|
@@ -11095,66 +11397,49 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
11095
11397
|
$border: "1px solid #E2E5E9",
|
11096
11398
|
$borderRadius: ".5rem",
|
11097
11399
|
$backgroundColor: "#ffffff",
|
11098
|
-
$flexDirection: "row",
|
11099
11400
|
$gap: "1rem",
|
11100
11401
|
$width: "100%",
|
11101
|
-
children: /* @__PURE__ */
|
11102
|
-
Flex,
|
11103
|
-
|
11104
|
-
|
11105
|
-
|
11106
|
-
|
11107
|
-
|
11108
|
-
|
11109
|
-
|
11110
|
-
|
11111
|
-
|
11112
|
-
|
11113
|
-
|
11114
|
-
|
11115
|
-
|
11116
|
-
"
|
11117
|
-
|
11118
|
-
|
11119
|
-
|
11120
|
-
|
11121
|
-
|
11122
|
-
|
11123
|
-
|
11124
|
-
|
11125
|
-
|
11126
|
-
|
11127
|
-
|
11128
|
-
|
11129
|
-
|
11130
|
-
|
11131
|
-
|
11132
|
-
|
11133
|
-
|
11134
|
-
|
11135
|
-
|
11136
|
-
|
11137
|
-
|
11138
|
-
{
|
11139
|
-
d: "M2.788 5.914A7.201 7.201 0 0 0 1 5.237l.028-.125h2.737c.371.013.672.125.77.519l.595 2.836.182.854 1.666-4.21h1.799l-2.674 6.167H4.304L2.788 5.914Zm7.312 5.37H8.399l1.064-6.172h1.7L10.1 11.284Zm6.167-6.021-.232 1.333-.153-.066a3.054 3.054 0 0 0-1.268-.236c-.671 0-.972.269-.98.531 0 .29.365.48.96.762.98.44 1.435.979 1.428 1.681-.014 1.28-1.176 2.108-2.96 2.108-.764-.007-1.5-.158-1.898-.328l.238-1.386.224.099c.553.23.917.328 1.596.328.49 0 1.015-.19 1.022-.604 0-.27-.224-.466-.882-.769-.644-.295-1.505-.788-1.491-1.674C11.878 5.84 13.06 5 14.74 5c.658 0 1.19.138 1.526.263Zm2.26 3.834h1.415c-.07-.308-.392-1.786-.392-1.786l-.12-.531c-.083.23-.23.604-.223.59l-.68 1.727Zm2.1-3.985L22 11.284h-1.575s-.154-.71-.203-.926h-2.184l-.357.926h-1.785l2.527-5.66c.175-.4.483-.512.889-.512h1.316Z",
|
11140
|
-
fill: "#1434CB"
|
11141
|
-
}
|
11142
|
-
)
|
11143
|
-
] })
|
11144
|
-
}
|
11145
|
-
) }),
|
11146
|
-
/* @__PURE__ */ jsx13(Box, { $whiteSpace: "nowrap", children: "Visa **** 2929" })
|
11147
|
-
]
|
11148
|
-
}
|
11149
|
-
),
|
11150
|
-
/* @__PURE__ */ jsx13(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx13(Box, { $fontSize: "12px", $color: "#5D5D5D", children: "Expires: 3/30" }) })
|
11151
|
-
]
|
11152
|
-
}
|
11153
|
-
)
|
11402
|
+
children: /* @__PURE__ */ jsxs10(Flex, { $justifyContent: "space-between", $flex: "1", children: [
|
11403
|
+
/* @__PURE__ */ jsxs10(Flex, { $alignItems: "center", $gap: "1rem", children: [
|
11404
|
+
/* @__PURE__ */ jsx15(Box, { $display: "inline-block", children: /* @__PURE__ */ jsx15(
|
11405
|
+
"svg",
|
11406
|
+
{
|
11407
|
+
viewBox: "0 0 24 16",
|
11408
|
+
fill: "none",
|
11409
|
+
xmlns: "http://www.w3.org/2000/svg",
|
11410
|
+
width: "26px",
|
11411
|
+
height: "auto",
|
11412
|
+
children: /* @__PURE__ */ jsxs10("g", { children: [
|
11413
|
+
/* @__PURE__ */ jsx15(
|
11414
|
+
"rect",
|
11415
|
+
{
|
11416
|
+
stroke: "#DDD",
|
11417
|
+
fill: "#FFF",
|
11418
|
+
x: ".25",
|
11419
|
+
y: ".25",
|
11420
|
+
width: "23",
|
11421
|
+
height: "15.5",
|
11422
|
+
rx: "2"
|
11423
|
+
}
|
11424
|
+
),
|
11425
|
+
/* @__PURE__ */ jsx15(
|
11426
|
+
"path",
|
11427
|
+
{
|
11428
|
+
d: "M2.788 5.914A7.201 7.201 0 0 0 1 5.237l.028-.125h2.737c.371.013.672.125.77.519l.595 2.836.182.854 1.666-4.21h1.799l-2.674 6.167H4.304L2.788 5.914Zm7.312 5.37H8.399l1.064-6.172h1.7L10.1 11.284Zm6.167-6.021-.232 1.333-.153-.066a3.054 3.054 0 0 0-1.268-.236c-.671 0-.972.269-.98.531 0 .29.365.48.96.762.98.44 1.435.979 1.428 1.681-.014 1.28-1.176 2.108-2.96 2.108-.764-.007-1.5-.158-1.898-.328l.238-1.386.224.099c.553.23.917.328 1.596.328.49 0 1.015-.19 1.022-.604 0-.27-.224-.466-.882-.769-.644-.295-1.505-.788-1.491-1.674C11.878 5.84 13.06 5 14.74 5c.658 0 1.19.138 1.526.263Zm2.26 3.834h1.415c-.07-.308-.392-1.786-.392-1.786l-.12-.531c-.083.23-.23.604-.223.59l-.68 1.727Zm2.1-3.985L22 11.284h-1.575s-.154-.71-.203-.926h-2.184l-.357.926h-1.785l2.527-5.66c.175-.4.483-.512.889-.512h1.316Z",
|
11429
|
+
fill: "#1434CB"
|
11430
|
+
}
|
11431
|
+
)
|
11432
|
+
] })
|
11433
|
+
}
|
11434
|
+
) }),
|
11435
|
+
/* @__PURE__ */ jsx15(Box, { $whiteSpace: "nowrap", children: "Visa **** 2929" })
|
11436
|
+
] }),
|
11437
|
+
/* @__PURE__ */ jsx15(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx15(Box, { $fontSize: "12px", $color: "#5D5D5D", children: "Expires: 3/30" }) })
|
11438
|
+
] })
|
11154
11439
|
}
|
11155
11440
|
),
|
11156
|
-
/* @__PURE__ */
|
11157
|
-
/* @__PURE__ */
|
11441
|
+
/* @__PURE__ */ jsxs10(Flex, { $gap: "1rem", children: [
|
11442
|
+
/* @__PURE__ */ jsx15(
|
11158
11443
|
StyledButton,
|
11159
11444
|
{
|
11160
11445
|
$size: "sm",
|
@@ -11168,7 +11453,7 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
11168
11453
|
children: "Make Default"
|
11169
11454
|
}
|
11170
11455
|
),
|
11171
|
-
/* @__PURE__ */
|
11456
|
+
/* @__PURE__ */ jsx15(
|
11172
11457
|
StyledButton,
|
11173
11458
|
{
|
11174
11459
|
$size: "sm",
|
@@ -11197,8 +11482,8 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
11197
11482
|
});
|
11198
11483
|
|
11199
11484
|
// src/components/elements/invoices/Invoices.tsx
|
11200
|
-
import { forwardRef as forwardRef6, useMemo as
|
11201
|
-
import { jsx as
|
11485
|
+
import { forwardRef as forwardRef6, useMemo as useMemo11 } from "react";
|
11486
|
+
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
11202
11487
|
function resolveDesignProps6(props) {
|
11203
11488
|
return {
|
11204
11489
|
header: {
|
@@ -11225,8 +11510,8 @@ function resolveDesignProps6(props) {
|
|
11225
11510
|
}
|
11226
11511
|
var Invoices = forwardRef6(({ className, ...rest }, ref) => {
|
11227
11512
|
const props = resolveDesignProps6(rest);
|
11228
|
-
const
|
11229
|
-
const { invoices } =
|
11513
|
+
const theme = nt();
|
11514
|
+
const { invoices } = useMemo11(() => {
|
11230
11515
|
return {
|
11231
11516
|
invoices: [
|
11232
11517
|
{
|
@@ -11240,39 +11525,39 @@ var Invoices = forwardRef6(({ className, ...rest }, ref) => {
|
|
11240
11525
|
]
|
11241
11526
|
};
|
11242
11527
|
}, []);
|
11243
|
-
return /* @__PURE__ */
|
11244
|
-
props.header.isVisible && /* @__PURE__ */
|
11528
|
+
return /* @__PURE__ */ jsx16("div", { ref, className, children: /* @__PURE__ */ jsxs11(Flex, { $flexDirection: "column", $gap: "1rem", children: [
|
11529
|
+
props.header.isVisible && /* @__PURE__ */ jsx16(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ jsx16(
|
11245
11530
|
Text,
|
11246
11531
|
{
|
11247
|
-
$font:
|
11248
|
-
$size:
|
11249
|
-
$weight:
|
11250
|
-
$color:
|
11532
|
+
$font: theme.typography[props.header.fontStyle].fontFamily,
|
11533
|
+
$size: theme.typography[props.header.fontStyle].fontSize,
|
11534
|
+
$weight: theme.typography[props.header.fontStyle].fontWeight,
|
11535
|
+
$color: theme.typography[props.header.fontStyle].color,
|
11251
11536
|
children: "Invoices"
|
11252
11537
|
}
|
11253
11538
|
) }),
|
11254
|
-
/* @__PURE__ */
|
11539
|
+
/* @__PURE__ */ jsx16(Flex, { $flexDirection: "column", $gap: "0.5rem", children: invoices.slice(
|
11255
11540
|
0,
|
11256
11541
|
props.limit.isVisible && props.limit.number || invoices.length
|
11257
11542
|
).map(({ date, amount }, index) => {
|
11258
|
-
return /* @__PURE__ */
|
11259
|
-
props.date.isVisible && /* @__PURE__ */
|
11543
|
+
return /* @__PURE__ */ jsxs11(Flex, { $justifyContent: "space-between", children: [
|
11544
|
+
props.date.isVisible && /* @__PURE__ */ jsx16(
|
11260
11545
|
Text,
|
11261
11546
|
{
|
11262
|
-
$font:
|
11263
|
-
$size:
|
11264
|
-
$weight:
|
11265
|
-
$color:
|
11547
|
+
$font: theme.typography[props.date.fontStyle].fontFamily,
|
11548
|
+
$size: theme.typography[props.date.fontStyle].fontSize,
|
11549
|
+
$weight: theme.typography[props.date.fontStyle].fontWeight,
|
11550
|
+
$color: theme.typography[props.date.fontStyle].color,
|
11266
11551
|
children: toPrettyDate(date)
|
11267
11552
|
}
|
11268
11553
|
),
|
11269
|
-
props.amount.isVisible && /* @__PURE__ */
|
11554
|
+
props.amount.isVisible && /* @__PURE__ */ jsxs11(
|
11270
11555
|
Text,
|
11271
11556
|
{
|
11272
|
-
$font:
|
11273
|
-
$size:
|
11274
|
-
$weight:
|
11275
|
-
$color:
|
11557
|
+
$font: theme.typography[props.amount.fontStyle].fontFamily,
|
11558
|
+
$size: theme.typography[props.amount.fontStyle].fontSize,
|
11559
|
+
$weight: theme.typography[props.amount.fontStyle].fontWeight,
|
11560
|
+
$color: theme.typography[props.amount.fontStyle].color,
|
11276
11561
|
children: [
|
11277
11562
|
"$",
|
11278
11563
|
amount
|
@@ -11281,15 +11566,15 @@ var Invoices = forwardRef6(({ className, ...rest }, ref) => {
|
|
11281
11566
|
)
|
11282
11567
|
] }, index);
|
11283
11568
|
}) }),
|
11284
|
-
props.collapse.isVisible && /* @__PURE__ */
|
11285
|
-
/* @__PURE__ */
|
11286
|
-
/* @__PURE__ */
|
11569
|
+
props.collapse.isVisible && /* @__PURE__ */ jsxs11(Flex, { $alignItems: "center", $gap: "0.5rem", children: [
|
11570
|
+
/* @__PURE__ */ jsx16(Icon2, { name: "chevron-down", style: { color: "#D0D0D0" } }),
|
11571
|
+
/* @__PURE__ */ jsx16(
|
11287
11572
|
Text,
|
11288
11573
|
{
|
11289
|
-
$font:
|
11290
|
-
$size:
|
11291
|
-
$weight:
|
11292
|
-
$color:
|
11574
|
+
$font: theme.typography[props.collapse.fontStyle].fontFamily,
|
11575
|
+
$size: theme.typography[props.collapse.fontStyle].fontSize,
|
11576
|
+
$weight: theme.typography[props.collapse.fontStyle].fontWeight,
|
11577
|
+
$color: theme.typography[props.collapse.fontStyle].color,
|
11293
11578
|
children: "See all"
|
11294
11579
|
}
|
11295
11580
|
)
|
@@ -11298,17 +11583,17 @@ var Invoices = forwardRef6(({ className, ...rest }, ref) => {
|
|
11298
11583
|
});
|
11299
11584
|
|
11300
11585
|
// src/components/embed/ComponentTree.tsx
|
11301
|
-
import { useEffect as useEffect5, useState as
|
11586
|
+
import { useEffect as useEffect5, useState as useState4, Children } from "react";
|
11302
11587
|
|
11303
11588
|
// src/components/embed/renderer.ts
|
11304
11589
|
import { createElement } from "react";
|
11305
11590
|
|
11306
11591
|
// src/components/layout/root/Root.tsx
|
11307
11592
|
import { forwardRef as forwardRef7 } from "react";
|
11308
|
-
import { jsx as
|
11593
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
11309
11594
|
var Root = forwardRef7(
|
11310
11595
|
(props, ref) => {
|
11311
|
-
return /* @__PURE__ */
|
11596
|
+
return /* @__PURE__ */ jsx17("div", { ref, ...props });
|
11312
11597
|
}
|
11313
11598
|
);
|
11314
11599
|
|
@@ -11324,17 +11609,54 @@ var StyledViewport = dt.div`
|
|
11324
11609
|
`;
|
11325
11610
|
|
11326
11611
|
// src/components/layout/viewport/Viewport.tsx
|
11327
|
-
import { jsx as
|
11612
|
+
import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
|
11328
11613
|
var Viewport = forwardRef8(
|
11329
11614
|
({ children, ...props }, ref) => {
|
11330
|
-
const
|
11331
|
-
|
11615
|
+
const theme = nt();
|
11616
|
+
const { layout } = useEmbed();
|
11617
|
+
return /* @__PURE__ */ jsx18(
|
11332
11618
|
StyledViewport,
|
11333
11619
|
{
|
11334
11620
|
ref,
|
11335
|
-
$numberOfColumns:
|
11621
|
+
$numberOfColumns: theme.numberOfColumns,
|
11336
11622
|
...props,
|
11337
|
-
children: layout === "disabled" ? /* @__PURE__ */
|
11623
|
+
children: layout === "disabled" ? /* @__PURE__ */ jsx18(Box, { $width: "100%", children: /* @__PURE__ */ jsxs12(
|
11624
|
+
Flex,
|
11625
|
+
{
|
11626
|
+
$flexDirection: "column",
|
11627
|
+
$padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
|
11628
|
+
$width: "100%",
|
11629
|
+
$height: "auto",
|
11630
|
+
$borderRadius: `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`,
|
11631
|
+
$backgroundColor: theme.card.background,
|
11632
|
+
$alignItems: "center",
|
11633
|
+
$justifyContent: "center",
|
11634
|
+
children: [
|
11635
|
+
/* @__PURE__ */ jsx18(
|
11636
|
+
Box,
|
11637
|
+
{
|
11638
|
+
$marginBottom: "8px",
|
11639
|
+
$fontSize: `${theme.typography.heading1.fontSize / TEXT_BASE_SIZE}rem`,
|
11640
|
+
$fontFamily: theme.typography.heading1.fontFamily,
|
11641
|
+
$fontWeight: theme.typography.heading1.fontWeight,
|
11642
|
+
$color: theme.typography.heading1.color,
|
11643
|
+
children: "Coming soon"
|
11644
|
+
}
|
11645
|
+
),
|
11646
|
+
/* @__PURE__ */ jsx18(
|
11647
|
+
Box,
|
11648
|
+
{
|
11649
|
+
$marginBottom: "8px",
|
11650
|
+
$fontSize: `${theme.typography.text.fontSize / TEXT_BASE_SIZE}rem`,
|
11651
|
+
$fontFamily: theme.typography.text.fontFamily,
|
11652
|
+
$fontWeight: theme.typography.text.fontWeight,
|
11653
|
+
$color: theme.typography.text.color,
|
11654
|
+
children: "The plan manager will be back very soon."
|
11655
|
+
}
|
11656
|
+
)
|
11657
|
+
]
|
11658
|
+
}
|
11659
|
+
) }) : children
|
11338
11660
|
}
|
11339
11661
|
);
|
11340
11662
|
}
|
@@ -11373,7 +11695,7 @@ var StyledCard = dt.div(
|
|
11373
11695
|
|
11374
11696
|
${() => {
|
11375
11697
|
const { l: l2 } = hexToHSL(theme.card.background);
|
11376
|
-
const borderColor = l2 > 50 ?
|
11698
|
+
const borderColor = l2 > 50 ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)";
|
11377
11699
|
const borderRadius = `${$borderRadius / TEXT_BASE_SIZE}rem`;
|
11378
11700
|
const boxShadow = "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A";
|
11379
11701
|
if ($sectionLayout === "merged") {
|
@@ -11405,19 +11727,19 @@ var StyledCard = dt.div(
|
|
11405
11727
|
);
|
11406
11728
|
|
11407
11729
|
// src/components/layout/card/Card.tsx
|
11408
|
-
import { jsx as
|
11730
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
11409
11731
|
var Card = forwardRef9(
|
11410
11732
|
({ children, className }, ref) => {
|
11411
|
-
const
|
11412
|
-
return /* @__PURE__ */
|
11733
|
+
const theme = nt();
|
11734
|
+
return /* @__PURE__ */ jsx19(
|
11413
11735
|
StyledCard,
|
11414
11736
|
{
|
11415
11737
|
ref,
|
11416
11738
|
className,
|
11417
|
-
$sectionLayout:
|
11418
|
-
$borderRadius:
|
11419
|
-
$padding:
|
11420
|
-
$shadow:
|
11739
|
+
$sectionLayout: theme?.sectionLayout,
|
11740
|
+
$borderRadius: theme?.card?.borderRadius,
|
11741
|
+
$padding: theme?.card?.padding,
|
11742
|
+
$shadow: theme?.card?.hasShadow,
|
11421
11743
|
children
|
11422
11744
|
}
|
11423
11745
|
);
|
@@ -11431,10 +11753,10 @@ var StyledColumn = dt.div`
|
|
11431
11753
|
`;
|
11432
11754
|
|
11433
11755
|
// src/components/layout/column/Column.tsx
|
11434
|
-
import { jsx as
|
11756
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
11435
11757
|
var Column = forwardRef10(
|
11436
11758
|
({ children, ...props }, ref) => {
|
11437
|
-
return /* @__PURE__ */
|
11759
|
+
return /* @__PURE__ */ jsx20(StyledColumn, { ref, ...props, children: /* @__PURE__ */ jsx20(Card, { children }) });
|
11438
11760
|
}
|
11439
11761
|
);
|
11440
11762
|
|
@@ -11480,31 +11802,107 @@ function createRenderer(options) {
|
|
11480
11802
|
};
|
11481
11803
|
}
|
11482
11804
|
|
11805
|
+
// src/components/ui/loader/styles.ts
|
11806
|
+
var spin = mt`
|
11807
|
+
0% {
|
11808
|
+
transform: rotate(0deg);
|
11809
|
+
}
|
11810
|
+
100% {
|
11811
|
+
transform: rotate(360deg);
|
11812
|
+
}
|
11813
|
+
`;
|
11814
|
+
var Loader = dt.div`
|
11815
|
+
border: ${({ theme }) => `${4 / TEXT_BASE_SIZE}rem solid hsla(0, 0%, ${hexToHSL(theme.card.background).l > 50 ? 0 : 100}%, 0.1)`};
|
11816
|
+
border-top: ${4 / TEXT_BASE_SIZE}rem solid ${({ theme }) => theme.primary};
|
11817
|
+
border-radius: 50%;
|
11818
|
+
width: ${40 / TEXT_BASE_SIZE}rem;
|
11819
|
+
height: ${40 / TEXT_BASE_SIZE}rem;
|
11820
|
+
animation: ${spin} 1.5s linear infinite;
|
11821
|
+
display: inline-block;
|
11822
|
+
`;
|
11823
|
+
|
11483
11824
|
// src/components/embed/ComponentTree.tsx
|
11484
|
-
import { Fragment as Fragment2, jsx as
|
11825
|
+
import { Fragment as Fragment2, jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
|
11826
|
+
var Loading = () => {
|
11827
|
+
const theme = nt();
|
11828
|
+
return /* @__PURE__ */ jsx21(
|
11829
|
+
Flex,
|
11830
|
+
{
|
11831
|
+
$width: "100%",
|
11832
|
+
$height: "100%",
|
11833
|
+
$alignItems: "center",
|
11834
|
+
$justifyContent: "center",
|
11835
|
+
$padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
|
11836
|
+
children: /* @__PURE__ */ jsx21(Loader, {})
|
11837
|
+
}
|
11838
|
+
);
|
11839
|
+
};
|
11840
|
+
var Error2 = ({ message }) => {
|
11841
|
+
const theme = nt();
|
11842
|
+
return /* @__PURE__ */ jsxs13(
|
11843
|
+
Flex,
|
11844
|
+
{
|
11845
|
+
$flexDirection: "column",
|
11846
|
+
$padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
|
11847
|
+
$width: "100%",
|
11848
|
+
$height: "auto",
|
11849
|
+
$borderRadius: `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`,
|
11850
|
+
$backgroundColor: theme.card.background,
|
11851
|
+
$alignItems: "center",
|
11852
|
+
$justifyContent: "center",
|
11853
|
+
children: [
|
11854
|
+
/* @__PURE__ */ jsx21(
|
11855
|
+
Box,
|
11856
|
+
{
|
11857
|
+
$marginBottom: `${8 / TEXT_BASE_SIZE}rem`,
|
11858
|
+
$fontSize: `${theme.typography.heading1.fontSize / TEXT_BASE_SIZE}rem`,
|
11859
|
+
$fontFamily: theme.typography.heading1.fontFamily,
|
11860
|
+
$fontWeight: theme.typography.heading1.fontWeight,
|
11861
|
+
$color: theme.typography.heading1.color,
|
11862
|
+
children: "404 Error"
|
11863
|
+
}
|
11864
|
+
),
|
11865
|
+
/* @__PURE__ */ jsx21(
|
11866
|
+
Box,
|
11867
|
+
{
|
11868
|
+
$marginBottom: `${8 / TEXT_BASE_SIZE}rem`,
|
11869
|
+
$fontSize: `${theme.typography.text.fontSize / TEXT_BASE_SIZE}rem`,
|
11870
|
+
$fontFamily: theme.typography.text.fontFamily,
|
11871
|
+
$fontWeight: theme.typography.text.fontWeight,
|
11872
|
+
$color: theme.typography.text.color,
|
11873
|
+
children: message
|
11874
|
+
}
|
11875
|
+
)
|
11876
|
+
]
|
11877
|
+
}
|
11878
|
+
);
|
11879
|
+
};
|
11485
11880
|
var ComponentTree = () => {
|
11486
|
-
const [children, setChildren] = useState6("Loading");
|
11487
11881
|
const { error, nodes } = useEmbed();
|
11882
|
+
const [children, setChildren] = useState4(/* @__PURE__ */ jsx21(Loading, {}));
|
11488
11883
|
useEffect5(() => {
|
11489
11884
|
const renderer = createRenderer();
|
11490
11885
|
setChildren(nodes.map(renderer));
|
11491
11886
|
}, [nodes]);
|
11492
11887
|
if (error) {
|
11493
|
-
return /* @__PURE__ */
|
11888
|
+
return /* @__PURE__ */ jsx21(Error2, { message: error.message });
|
11494
11889
|
}
|
11495
|
-
|
11890
|
+
if (Children.count(children) === 0) {
|
11891
|
+
return /* @__PURE__ */ jsx21(Loading, {});
|
11892
|
+
}
|
11893
|
+
return /* @__PURE__ */ jsx21(Fragment2, { children });
|
11496
11894
|
};
|
11497
11895
|
|
11498
11896
|
// src/components/embed/Embed.tsx
|
11499
|
-
import { jsx as
|
11897
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
11500
11898
|
var SchematicEmbed = ({ id, accessToken, apiConfig }) => {
|
11501
11899
|
if (accessToken?.length === 0) {
|
11502
|
-
return /* @__PURE__ */
|
11900
|
+
return /* @__PURE__ */ jsx22("div", { children: "Please provide an access token." });
|
11503
11901
|
}
|
11504
11902
|
if (!accessToken?.startsWith("token_")) {
|
11505
|
-
return /* @__PURE__ */
|
11903
|
+
return /* @__PURE__ */ jsx22("div", { children: 'Invalid access token; your temporary access token will start with "token_".' });
|
11506
11904
|
}
|
11507
|
-
return /* @__PURE__ */
|
11905
|
+
return /* @__PURE__ */ jsx22(EmbedProvider, { id, accessToken, apiConfig, children: /* @__PURE__ */ jsx22(ComponentTree, {}) });
|
11508
11906
|
};
|
11509
11907
|
export {
|
11510
11908
|
Box,
|
@@ -11519,9 +11917,8 @@ export {
|
|
11519
11917
|
IncludedFeatures,
|
11520
11918
|
Invoices,
|
11521
11919
|
MeteredFeatures,
|
11522
|
-
|
11523
|
-
|
11524
|
-
OverlayWrapper,
|
11920
|
+
Modal,
|
11921
|
+
ModalHeader,
|
11525
11922
|
PaymentMethod,
|
11526
11923
|
PlanManager,
|
11527
11924
|
ProgressBar,
|
@@ -11538,7 +11935,8 @@ export {
|
|
11538
11935
|
useSchematic,
|
11539
11936
|
useSchematicContext,
|
11540
11937
|
useSchematicEvents,
|
11541
|
-
useSchematicFlag
|
11938
|
+
useSchematicFlag,
|
11939
|
+
useSchematicIsPending
|
11542
11940
|
};
|
11543
11941
|
/*! Bundled license information:
|
11544
11942
|
|