@schematichq/schematic-react 0.2.0-rc.5 → 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.
@@ -882,7 +882,8 @@ __export(src_exports, {
882
882
  useSchematic: () => useSchematic,
883
883
  useSchematicContext: () => useSchematicContext,
884
884
  useSchematicEvents: () => useSchematicEvents,
885
- useSchematicFlag: () => useSchematicFlag
885
+ useSchematicFlag: () => useSchematicFlag,
886
+ useSchematicIsPending: () => useSchematicIsPending
886
887
  });
887
888
  module.exports = __toCommonJS(src_exports);
888
889
 
@@ -6461,7 +6462,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
6461
6462
  }
6462
6463
  stripe._registerWrapper({
6463
6464
  name: "stripe-js",
6464
- version: "4.3.0",
6465
+ version: "4.4.0",
6465
6466
  startTime
6466
6467
  });
6467
6468
  };
@@ -7387,7 +7388,6 @@ function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7387
7388
  environmentId: json["environment_id"],
7388
7389
  externalId: json["external_id"],
7389
7390
  id: json["id"],
7390
- invoiceExternalId: json["invoice_external_id"] == null ? void 0 : json["invoice_external_id"],
7391
7391
  paymentMethodType: json["payment_method_type"],
7392
7392
  subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7393
7393
  updatedAt: new Date(json["updated_at"])
@@ -8012,33 +8012,6 @@ function parseEditorState(data) {
8012
8012
  });
8013
8013
  return arr;
8014
8014
  }
8015
- async function fetchComponent(id, api) {
8016
- const nodes = [];
8017
- const settings = { ...defaultSettings };
8018
- const response = await api.hydrateComponent({ componentId: id });
8019
- const { data } = response;
8020
- if (data.component?.ast) {
8021
- const compressed = data.component.ast;
8022
- const json = inflate_1(Uint8Array.from(Object.values(compressed)), {
8023
- to: "string"
8024
- });
8025
- const ast = getEditorState(json);
8026
- if (ast) {
8027
- (0, import_lodash.default)(settings, ast.ROOT.props.settings);
8028
- nodes.push(...parseEditorState(ast));
8029
- }
8030
- }
8031
- let stripe = null;
8032
- if (data.stripeEmbed?.publishableKey) {
8033
- stripe = loadStripe(data.stripeEmbed.publishableKey);
8034
- }
8035
- return {
8036
- data,
8037
- nodes,
8038
- settings,
8039
- stripe
8040
- };
8041
- }
8042
8015
  var EmbedContext = (0, import_react2.createContext)({
8043
8016
  api: null,
8044
8017
  data: {
@@ -8049,6 +8022,9 @@ var EmbedContext = (0, import_react2.createContext)({
8049
8022
  stripe: null,
8050
8023
  layout: "portal",
8051
8024
  error: void 0,
8025
+ isPending: false,
8026
+ hydrate: () => {
8027
+ },
8052
8028
  setData: () => {
8053
8029
  },
8054
8030
  updateSettings: () => {
@@ -8075,7 +8051,10 @@ var EmbedProvider = ({
8075
8051
  settings: { ...defaultSettings },
8076
8052
  stripe: null,
8077
8053
  layout: "portal",
8054
+ isPending: false,
8078
8055
  error: void 0,
8056
+ hydrate: () => {
8057
+ },
8079
8058
  setData: () => {
8080
8059
  },
8081
8060
  updateSettings: () => {
@@ -8086,45 +8065,47 @@ var EmbedProvider = ({
8086
8065
  }
8087
8066
  };
8088
8067
  });
8089
- (0, import_react2.useEffect)(() => {
8090
- const element = document.getElementById("schematic-fonts");
8091
- if (element) {
8092
- return void (styleRef.current = element);
8093
- }
8094
- const style = document.createElement("link");
8095
- style.id = "schematic-fonts";
8096
- style.rel = "stylesheet";
8097
- document.head.appendChild(style);
8098
- styleRef.current = style;
8099
- }, []);
8100
- (0, import_react2.useEffect)(() => {
8101
- if (!accessToken) {
8102
- return;
8103
- }
8104
- const config = new Configuration({ ...apiConfig, apiKey: accessToken });
8105
- const api = new CheckoutApi(config);
8106
- setState((prev2) => ({ ...prev2, api }));
8107
- }, [accessToken, apiConfig]);
8108
- (0, import_react2.useEffect)(() => {
8109
- if (!id || !state.api) {
8110
- return;
8111
- }
8112
- fetchComponent(id, state.api).then(async (resolvedData) => {
8113
- setState((prev2) => ({ ...prev2, ...resolvedData }));
8114
- }).catch((error) => setState((prev2) => ({ ...prev2, error })));
8115
- }, [id, state.api]);
8116
- (0, import_react2.useEffect)(() => {
8117
- const fontSet = /* @__PURE__ */ new Set([]);
8118
- Object.values(state.settings.theme.typography).forEach(({ fontFamily }) => {
8119
- fontSet.add(fontFamily);
8120
- });
8121
- if (fontSet.size > 0) {
8122
- const src = `https://fonts.googleapis.com/css2?${[...fontSet].map((fontFamily) => `family=${fontFamily}&display=swap`).join("&")}`;
8123
- if (styleRef.current) {
8124
- styleRef.current.href = src;
8068
+ const hydrate = (0, import_react2.useCallback)(async () => {
8069
+ setState((prev2) => ({ ...prev2, isPending: true, error: void 0 }));
8070
+ try {
8071
+ const nodes = [];
8072
+ const settings = { ...defaultSettings };
8073
+ if (!id || !state.api) {
8074
+ throw new Error("Invalid component id or api instance.");
8075
+ }
8076
+ const response = await state.api.hydrateComponent({ componentId: id });
8077
+ const { data } = response;
8078
+ if (data.component?.ast) {
8079
+ const compressed = data.component.ast;
8080
+ const json = inflate_1(Uint8Array.from(Object.values(compressed)), {
8081
+ to: "string"
8082
+ });
8083
+ const ast = getEditorState(json);
8084
+ if (ast) {
8085
+ (0, import_lodash.default)(settings, ast.ROOT.props.settings);
8086
+ nodes.push(...parseEditorState(ast));
8087
+ }
8088
+ }
8089
+ let stripe = null;
8090
+ if (data.stripeEmbed?.publishableKey) {
8091
+ stripe = loadStripe(data.stripeEmbed.publishableKey);
8125
8092
  }
8093
+ setState((prev2) => ({
8094
+ ...prev2,
8095
+ data,
8096
+ nodes,
8097
+ settings,
8098
+ stripe,
8099
+ isPending: false
8100
+ }));
8101
+ } catch (error) {
8102
+ setState((prev2) => ({
8103
+ ...prev2,
8104
+ isPending: false,
8105
+ error: error instanceof Error ? error : new Error("An unknown error occurred.")
8106
+ }));
8126
8107
  }
8127
- }, [state.settings.theme.typography]);
8108
+ }, [id, state.api]);
8128
8109
  const setData = (0, import_react2.useCallback)(
8129
8110
  (data) => {
8130
8111
  setState((prev2) => {
@@ -8167,6 +8148,40 @@ var EmbedProvider = ({
8167
8148
  },
8168
8149
  [setState]
8169
8150
  );
8151
+ (0, import_react2.useEffect)(() => {
8152
+ const element = document.getElementById("schematic-fonts");
8153
+ if (element) {
8154
+ return void (styleRef.current = element);
8155
+ }
8156
+ const style = document.createElement("link");
8157
+ style.id = "schematic-fonts";
8158
+ style.rel = "stylesheet";
8159
+ document.head.appendChild(style);
8160
+ styleRef.current = style;
8161
+ }, []);
8162
+ (0, import_react2.useEffect)(() => {
8163
+ if (!accessToken) {
8164
+ return;
8165
+ }
8166
+ const config = new Configuration({ ...apiConfig, apiKey: accessToken });
8167
+ const api = new CheckoutApi(config);
8168
+ setState((prev2) => ({ ...prev2, api }));
8169
+ }, [accessToken, apiConfig]);
8170
+ (0, import_react2.useEffect)(() => {
8171
+ hydrate();
8172
+ }, [hydrate]);
8173
+ (0, import_react2.useEffect)(() => {
8174
+ const fontSet = /* @__PURE__ */ new Set([]);
8175
+ Object.values(state.settings.theme.typography).forEach(({ fontFamily }) => {
8176
+ fontSet.add(fontFamily);
8177
+ });
8178
+ if (fontSet.size > 0) {
8179
+ const src = `https://fonts.googleapis.com/css2?${[...fontSet].map((fontFamily) => `family=${fontFamily}&display=swap`).join("&")}`;
8180
+ if (styleRef.current) {
8181
+ styleRef.current.href = src;
8182
+ }
8183
+ }
8184
+ }, [state.settings.theme.typography]);
8170
8185
  const renderChildren = () => {
8171
8186
  if (state.stripe) {
8172
8187
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -8219,6 +8234,8 @@ var EmbedProvider = ({
8219
8234
  stripe: state.stripe,
8220
8235
  layout: state.layout,
8221
8236
  error: state.error,
8237
+ isPending: state.isPending,
8238
+ hydrate,
8222
8239
  setData,
8223
8240
  updateSettings,
8224
8241
  setStripe,
@@ -8799,19 +8816,36 @@ function v4(options, buf, offset) {
8799
8816
  }
8800
8817
  var v4_default = v4;
8801
8818
  var import_polyfill = __toESM2(require_browser_polyfill());
8819
+ function contextString(context) {
8820
+ const sortedContext = Object.keys(context).reduce((acc, key) => {
8821
+ const sortedKeys = Object.keys(
8822
+ context[key] || {}
8823
+ ).sort();
8824
+ const sortedObj = sortedKeys.reduce((obj, sortedKey) => {
8825
+ obj[sortedKey] = context[key][sortedKey];
8826
+ return obj;
8827
+ }, {});
8828
+ acc[key] = sortedObj;
8829
+ return acc;
8830
+ }, {});
8831
+ return JSON.stringify(sortedContext);
8832
+ }
8802
8833
  var anonymousIdKey = "schematicId";
8803
8834
  var Schematic = class {
8804
8835
  apiKey;
8805
8836
  apiUrl = "https://api.schematichq.com";
8806
- webSocketUrl = "wss://api.schematichq.com";
8807
- eventUrl = "https://c.schematichq.com";
8808
8837
  conn = null;
8809
8838
  context = {};
8810
8839
  eventQueue;
8840
+ eventUrl = "https://c.schematichq.com";
8841
+ flagListener;
8842
+ flagValueListeners = {};
8843
+ isPending = true;
8844
+ isPendingListeners = /* @__PURE__ */ new Set();
8811
8845
  storage;
8812
8846
  useWebSocket = false;
8813
8847
  values = {};
8814
- flagListener;
8848
+ webSocketUrl = "wss://api.schematichq.com";
8815
8849
  constructor(apiKey, options) {
8816
8850
  this.apiKey = apiKey;
8817
8851
  this.eventQueue = [];
@@ -8831,12 +8865,14 @@ var Schematic = class {
8831
8865
  if (options?.webSocketUrl !== void 0) {
8832
8866
  this.webSocketUrl = options.webSocketUrl;
8833
8867
  }
8834
- if (window?.addEventListener) {
8868
+ if (typeof window !== "undefined" && window?.addEventListener) {
8835
8869
  window.addEventListener("beforeunload", () => {
8836
8870
  this.flushEventQueue();
8837
8871
  });
8838
8872
  }
8839
8873
  }
8874
+ // Get value for a single flag
8875
+ // If in websocket mode, return the local value, otherwise make an API call
8840
8876
  async checkFlag(options) {
8841
8877
  const { fallback = false, key } = options;
8842
8878
  const context = options.context || this.context;
@@ -8864,7 +8900,7 @@ var Schematic = class {
8864
8900
  return fallback;
8865
8901
  });
8866
8902
  }
8867
- // Make a REST API call to fetch all flag values for a given context
8903
+ // Make an API call to fetch all flag values for a given context (use if not in websocket mode)
8868
8904
  checkFlags = async (context) => {
8869
8905
  context = context || this.context;
8870
8906
  const requestUrl = `${this.apiUrl}/flags/check`;
@@ -8894,18 +8930,6 @@ var Schematic = class {
8894
8930
  return false;
8895
8931
  });
8896
8932
  };
8897
- cleanup = async () => {
8898
- if (this.conn) {
8899
- try {
8900
- const socket = await this.conn;
8901
- socket.close();
8902
- } catch (error) {
8903
- console.error("Error during cleanup:", error);
8904
- } finally {
8905
- this.conn = null;
8906
- }
8907
- }
8908
- };
8909
8933
  // Send an identify event
8910
8934
  identify = (body) => {
8911
8935
  this.setContext({
@@ -8923,12 +8947,16 @@ var Schematic = class {
8923
8947
  this.context = context;
8924
8948
  return Promise.resolve();
8925
8949
  }
8926
- if (!this.conn) {
8927
- this.conn = this.wsConnect();
8950
+ try {
8951
+ this.setIsPending(true);
8952
+ if (!this.conn) {
8953
+ this.conn = this.wsConnect();
8954
+ }
8955
+ const socket = await this.conn;
8956
+ await this.wsSendMessage(socket, context);
8957
+ } catch (error) {
8958
+ console.error("Error setting Schematic context:", error);
8928
8959
  }
8929
- return this.conn.then((socket) => {
8930
- return this.wsSendMessage(socket, context);
8931
- });
8932
8960
  };
8933
8961
  // Send track event
8934
8962
  track = (body) => {
@@ -8940,6 +8968,9 @@ var Schematic = class {
8940
8968
  user: user ?? this.context.user
8941
8969
  });
8942
8970
  };
8971
+ /**
8972
+ * Event processing
8973
+ */
8943
8974
  flushEventQueue = () => {
8944
8975
  while (this.eventQueue.length > 0) {
8945
8976
  const event = this.eventQueue.shift();
@@ -8995,6 +9026,22 @@ var Schematic = class {
8995
9026
  this.eventQueue.push(event);
8996
9027
  return Promise.resolve();
8997
9028
  };
9029
+ /**
9030
+ * Websocket management
9031
+ */
9032
+ cleanup = async () => {
9033
+ if (this.conn) {
9034
+ try {
9035
+ const socket = await this.conn;
9036
+ socket.close();
9037
+ } catch (error) {
9038
+ console.error("Error during cleanup:", error);
9039
+ } finally {
9040
+ this.conn = null;
9041
+ }
9042
+ }
9043
+ };
9044
+ // Open a websocket connection
8998
9045
  wsConnect = () => {
8999
9046
  return new Promise((resolve, reject) => {
9000
9047
  const wsUrl = `${this.webSocketUrl}/flags/bootstrap`;
@@ -9010,6 +9057,8 @@ var Schematic = class {
9010
9057
  };
9011
9058
  });
9012
9059
  };
9060
+ // Send a message on the websocket indicating interest in a particular evaluation context
9061
+ // and wait for the initial set of flag values to be returned
9013
9062
  wsSendMessage = (socket, context) => {
9014
9063
  return new Promise((resolve, reject) => {
9015
9064
  if (contextString(context) == contextString(this.context)) {
@@ -9027,16 +9076,17 @@ var Schematic = class {
9027
9076
  (message.flags ?? []).forEach(
9028
9077
  (flag) => {
9029
9078
  this.values[contextString(context)][flag.flag] = flag.value;
9079
+ this.notifyFlagValueListeners(flag.flag);
9030
9080
  }
9031
9081
  );
9032
9082
  if (this.flagListener) {
9033
- this.flagListener(this.values[contextString(context)]);
9083
+ this.flagListener(this.getFlagValues());
9034
9084
  }
9085
+ this.setIsPending(false);
9035
9086
  if (!resolved) {
9036
9087
  resolved = true;
9037
9088
  resolve();
9038
9089
  }
9039
- socket.removeEventListener("message", messageHandler);
9040
9090
  };
9041
9091
  socket.addEventListener("message", messageHandler);
9042
9092
  socket.send(
@@ -9055,72 +9105,93 @@ var Schematic = class {
9055
9105
  }
9056
9106
  });
9057
9107
  };
9108
+ /**
9109
+ * State management
9110
+ */
9111
+ // isPending state
9112
+ getIsPending = () => {
9113
+ return this.isPending;
9114
+ };
9115
+ addIsPendingListener = (listener) => {
9116
+ this.isPendingListeners.add(listener);
9117
+ return () => {
9118
+ this.isPendingListeners.delete(listener);
9119
+ };
9120
+ };
9121
+ setIsPending = (isPending) => {
9122
+ this.isPending = isPending;
9123
+ this.isPendingListeners.forEach((listener) => listener());
9124
+ };
9125
+ // flagValues state
9126
+ getFlagValue = (flagKey) => {
9127
+ const values = this.getFlagValues();
9128
+ return values[flagKey];
9129
+ };
9130
+ getFlagValues = () => {
9131
+ const contextStr = contextString(this.context);
9132
+ return this.values[contextStr] ?? {};
9133
+ };
9134
+ addFlagValueListener = (flagKey, listener) => {
9135
+ if (!(flagKey in this.flagValueListeners)) {
9136
+ this.flagValueListeners[flagKey] = /* @__PURE__ */ new Set();
9137
+ }
9138
+ this.flagValueListeners[flagKey].add(listener);
9139
+ return () => {
9140
+ this.flagValueListeners[flagKey].delete(listener);
9141
+ };
9142
+ };
9143
+ notifyFlagValueListeners = (flagKey) => {
9144
+ const listeners = this.flagValueListeners?.[flagKey] ?? [];
9145
+ listeners.forEach((listener) => listener());
9146
+ };
9058
9147
  };
9059
- function contextString(context) {
9060
- const sortedContext = Object.keys(context).reduce((acc, key) => {
9061
- const sortedKeys = Object.keys(
9062
- context[key] || {}
9063
- ).sort();
9064
- const sortedObj = sortedKeys.reduce((obj, sortedKey) => {
9065
- obj[sortedKey] = context[key][sortedKey];
9066
- return obj;
9067
- }, {});
9068
- acc[key] = sortedObj;
9069
- return acc;
9070
- }, {});
9071
- return JSON.stringify(sortedContext);
9072
- }
9073
9148
 
9074
9149
  // src/context/schematic.tsx
9075
- var import_react3 = require("react");
9150
+ var import_react3 = __toESM(require("react"));
9076
9151
  var import_jsx_runtime2 = require("react/jsx-runtime");
9077
- var SchematicContext = (0, import_react3.createContext)({
9078
- flagValues: {}
9079
- });
9152
+ var SchematicContext = (0, import_react3.createContext)(
9153
+ null
9154
+ );
9080
9155
  var SchematicProvider = ({
9081
9156
  children,
9082
9157
  client: providedClient,
9083
9158
  publishableKey,
9084
9159
  ...clientOpts
9085
9160
  }) => {
9086
- const [client, setClient] = (0, import_react3.useState)();
9087
- const [flagValues, setFlagValues] = (0, import_react3.useState)({});
9088
- const memoizedClientOpts = (0, import_react3.useMemo)(
9089
- () => clientOpts,
9090
- /* eslint-disable-next-line react-hooks/exhaustive-deps */
9091
- [JSON.stringify(clientOpts)]
9092
- );
9093
- const { useWebSocket = true } = clientOpts;
9094
- (0, import_react3.useEffect)(() => {
9095
- let cleanupFunction;
9161
+ const client = (0, import_react3.useMemo)(() => {
9162
+ const { useWebSocket = true } = clientOpts;
9096
9163
  if (providedClient) {
9097
- setClient(providedClient);
9098
- cleanupFunction = () => {
9099
- providedClient.cleanup().catch((error) => {
9100
- console.error("Error during cleanup:", error);
9101
- });
9102
- };
9103
- } else {
9104
- const newClient = new Schematic(publishableKey, {
9105
- ...memoizedClientOpts,
9106
- flagListener: setFlagValues,
9107
- useWebSocket
9108
- });
9109
- setClient(newClient);
9110
- cleanupFunction = () => {
9111
- newClient.cleanup().catch((error) => {
9164
+ return providedClient;
9165
+ }
9166
+ return new Schematic(publishableKey, {
9167
+ useWebSocket,
9168
+ ...clientOpts
9169
+ });
9170
+ }, [providedClient, publishableKey, clientOpts]);
9171
+ (0, import_react3.useEffect)(() => {
9172
+ return () => {
9173
+ if (!providedClient) {
9174
+ client.cleanup().catch((error) => {
9112
9175
  console.error("Error during cleanup:", error);
9113
9176
  });
9114
- };
9115
- }
9116
- return cleanupFunction;
9117
- }, [memoizedClientOpts, providedClient, publishableKey, useWebSocket]);
9118
- const contextValue = {
9119
- client,
9120
- flagValues
9121
- };
9177
+ }
9178
+ };
9179
+ }, [client, providedClient]);
9180
+ const contextValue = (0, import_react3.useMemo)(
9181
+ () => ({
9182
+ client
9183
+ }),
9184
+ [client]
9185
+ );
9122
9186
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SchematicContext.Provider, { value: contextValue, children });
9123
9187
  };
9188
+ var useSchematic = () => {
9189
+ const context = import_react3.default.useContext(SchematicContext);
9190
+ if (context === null) {
9191
+ throw new Error("useSchematic must be used within a SchematicProvider");
9192
+ }
9193
+ return context;
9194
+ };
9124
9195
 
9125
9196
  // src/hooks/embed.ts
9126
9197
  var import_react4 = require("react");
@@ -9128,41 +9199,58 @@ var useEmbed = () => (0, import_react4.useContext)(EmbedContext);
9128
9199
 
9129
9200
  // src/hooks/schematic.ts
9130
9201
  var import_react5 = require("react");
9131
- var useSchematic = () => (0, import_react5.useContext)(SchematicContext);
9132
9202
  var useSchematicClient = (opts) => {
9133
9203
  const schematic = useSchematic();
9134
9204
  const { client } = opts ?? {};
9135
- if (client) {
9136
- return client;
9137
- }
9138
- return schematic.client;
9205
+ return (0, import_react5.useMemo)(() => {
9206
+ if (client) {
9207
+ return client;
9208
+ }
9209
+ return schematic.client;
9210
+ }, [client, schematic.client]);
9139
9211
  };
9140
9212
  var useSchematicContext = (opts) => {
9141
9213
  const client = useSchematicClient(opts);
9142
- const { setContext } = client ?? {};
9143
- return { setContext };
9214
+ return (0, import_react5.useMemo)(
9215
+ () => ({
9216
+ setContext: client.setContext.bind(client)
9217
+ }),
9218
+ [client]
9219
+ );
9144
9220
  };
9145
9221
  var useSchematicEvents = (opts) => {
9146
9222
  const client = useSchematicClient(opts);
9147
- const { track, identify } = client ?? {};
9148
- return { track, identify };
9223
+ const track = (0, import_react5.useCallback)(
9224
+ (...args) => client.track(...args),
9225
+ [client]
9226
+ );
9227
+ const identify = (0, import_react5.useCallback)(
9228
+ (...args) => client.identify(...args),
9229
+ [client]
9230
+ );
9231
+ return (0, import_react5.useMemo)(() => ({ track, identify }), [track, identify]);
9149
9232
  };
9150
9233
  var useSchematicFlag = (key, opts) => {
9151
- const { flagValues } = useSchematic();
9152
- const { client } = opts ?? {};
9153
- const { fallback = false } = opts ?? {};
9154
- const [value, setValue] = (0, import_react5.useState)(fallback);
9155
- const flagValue = flagValues[key];
9156
- (0, import_react5.useEffect)(() => {
9157
- if (typeof flagValue !== "undefined") {
9158
- setValue(flagValue);
9159
- } else if (client) {
9160
- client.checkFlag({ key, fallback }).then(setValue);
9161
- } else {
9162
- setValue(fallback);
9163
- }
9164
- }, [key, fallback, flagValue, client]);
9165
- return value;
9234
+ const client = useSchematicClient(opts);
9235
+ const fallback = opts?.fallback ?? false;
9236
+ const subscribe = (0, import_react5.useCallback)(
9237
+ (callback) => client.addFlagValueListener(key, callback),
9238
+ [client, key]
9239
+ );
9240
+ const getSnapshot = (0, import_react5.useCallback)(() => {
9241
+ const value = client.getFlagValue(key);
9242
+ return typeof value === "undefined" ? fallback : value;
9243
+ }, [client, key, fallback]);
9244
+ return (0, import_react5.useSyncExternalStore)(subscribe, getSnapshot);
9245
+ };
9246
+ var useSchematicIsPending = (opts) => {
9247
+ const client = useSchematicClient(opts);
9248
+ const subscribe = (0, import_react5.useCallback)(
9249
+ (callback) => client.addIsPendingListener(callback),
9250
+ [client]
9251
+ );
9252
+ const getSnapshot = (0, import_react5.useCallback)(() => client.getIsPending(), [client]);
9253
+ return (0, import_react5.useSyncExternalStore)(subscribe, getSnapshot);
9166
9254
  };
9167
9255
 
9168
9256
  // src/components/elements/plan-manager/PlanManager.tsx
@@ -9248,7 +9336,7 @@ function hslToHex({ h, s: s2, l: l2 }) {
9248
9336
  }
9249
9337
  function adjustLightness(color, amount) {
9250
9338
  const { h, s: s2, l: l2 } = hexToHSL(color);
9251
- return hslToHex({ h, s: s2, l: Math.max(Math.min(l2 + amount, 100), 0) });
9339
+ return hslToHex({ h, s: s2, l: Math.max(Math.min(l2 + amount * 100, 100), 0) });
9252
9340
  }
9253
9341
  function lighten(color, amount) {
9254
9342
  return adjustLightness(color, amount);
@@ -9478,6 +9566,7 @@ var Container = dt.div`
9478
9566
  align-items: center;
9479
9567
  flex-shrink: 0;
9480
9568
  border-radius: 9999px;
9569
+
9481
9570
  ${({ $size }) => {
9482
9571
  const base = 24;
9483
9572
  let scale = 1;
@@ -9495,6 +9584,15 @@ var Container = dt.div`
9495
9584
  case "lg":
9496
9585
  scale *= 1.75;
9497
9586
  break;
9587
+ case "xl":
9588
+ scale *= 2;
9589
+ break;
9590
+ case "2xl":
9591
+ scale *= 2.5;
9592
+ break;
9593
+ case "3xl":
9594
+ scale *= 3;
9595
+ break;
9498
9596
  }
9499
9597
  return lt`
9500
9598
  font-size: ${base * scale / TEXT_BASE_SIZE}rem;
@@ -9503,12 +9601,19 @@ var Container = dt.div`
9503
9601
  height: ${(base + 8) * scale / TEXT_BASE_SIZE}rem;
9504
9602
  `;
9505
9603
  }}
9604
+
9506
9605
  ${({ $variant, $colors }) => $variant === "outline" ? lt`
9507
- color: ${$colors[0]};
9508
9606
  background-color: transparent;
9607
+
9608
+ ${Icon} {
9609
+ color: ${$colors[0]};
9610
+ }
9509
9611
  ` : lt`
9510
- color: ${$colors[0]};
9511
9612
  background-color: ${$colors[1]};
9613
+
9614
+ ${Icon} {
9615
+ color: ${$colors[0]};
9616
+ }
9512
9617
  `}
9513
9618
  `;
9514
9619
 
@@ -9533,10 +9638,13 @@ var IconRound = ({
9533
9638
  // src/components/ui/modal/Modal.tsx
9534
9639
  var import_react6 = require("react");
9535
9640
  var import_jsx_runtime6 = require("react/jsx-runtime");
9536
- var Modal = ({ children, onClose }) => {
9641
+ var Modal = ({ children, size = "auto", onClose }) => {
9537
9642
  const theme = nt();
9538
9643
  const { setLayout } = useEmbed();
9539
9644
  const ref = (0, import_react6.useRef)(null);
9645
+ const isLightBackground = (0, import_react6.useMemo)(() => {
9646
+ return hexToHSL(theme.card.background).l > 50;
9647
+ }, [theme.card.background]);
9540
9648
  const handleClose = (0, import_react6.useCallback)(() => {
9541
9649
  setLayout("portal");
9542
9650
  onClose?.();
@@ -9566,7 +9674,7 @@ var Modal = ({ children, onClose }) => {
9566
9674
  $transform: "translate(-50%, -50%)",
9567
9675
  $width: "100%",
9568
9676
  $height: "100%",
9569
- $backgroundColor: hexToHSL(theme.card.background).l > 50 ? darken(theme.card.background, 15) : lighten(theme.card.background, 15),
9677
+ $backgroundColor: isLightBackground ? "hsl(0, 0%, 85%)" : "hsl(0, 0%, 15%)",
9570
9678
  $overflow: "hidden",
9571
9679
  children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9572
9680
  Flex,
@@ -9577,9 +9685,13 @@ var Modal = ({ children, onClose }) => {
9577
9685
  $transform: "translate(-50%, -50%)",
9578
9686
  $flexDirection: "column",
9579
9687
  $overflow: "hidden",
9580
- $width: "calc(100% - 5rem)",
9581
- $height: "calc(100% - 5rem)",
9582
- $backgroundColor: hexToHSL(theme.card.background).l > 50 ? darken(theme.card.background, 2.5) : lighten(theme.card.background, 2.5),
9688
+ ...size === "auto" ? { $width: "min-content", $height: "min-content" } : {
9689
+ $width: "100%",
9690
+ $height: "100%",
9691
+ $maxWidth: "1366px",
9692
+ $maxHeight: "768px"
9693
+ },
9694
+ $backgroundColor: theme.card.background,
9583
9695
  $borderRadius: "0.5rem",
9584
9696
  $boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
9585
9697
  id: "select-plan-dialog",
@@ -9596,9 +9708,16 @@ var Modal = ({ children, onClose }) => {
9596
9708
  // src/components/ui/modal/ModalHeader.tsx
9597
9709
  var import_react7 = require("react");
9598
9710
  var import_jsx_runtime7 = require("react/jsx-runtime");
9599
- var ModalHeader = ({ children, onClose }) => {
9711
+ var ModalHeader = ({
9712
+ children,
9713
+ bordered = false,
9714
+ onClose
9715
+ }) => {
9600
9716
  const theme = nt();
9601
9717
  const { setLayout } = useEmbed();
9718
+ const isLightBackground = (0, import_react7.useMemo)(() => {
9719
+ return hexToHSL(theme.card.background).l > 50;
9720
+ }, [theme.card.background]);
9602
9721
  const handleClose = (0, import_react7.useCallback)(() => {
9603
9722
  setLayout("portal");
9604
9723
  onClose?.();
@@ -9608,13 +9727,15 @@ var ModalHeader = ({ children, onClose }) => {
9608
9727
  {
9609
9728
  $justifyContent: "space-between",
9610
9729
  $alignItems: "center",
9730
+ $flexShrink: "0",
9611
9731
  $gap: "1rem",
9612
- $height: "3.75rem",
9613
- $padding: "0 0.625rem 0 2.5rem",
9614
- $backgroundColor: theme.card.background,
9615
- $borderBottomWidth: "1px",
9616
- $borderBottomStyle: "solid",
9617
- $borderBottomColor: hexToHSL(theme.card.background).l > 50 ? darken(theme.card.background, 15) : lighten(theme.card.background, 15),
9732
+ $height: "5rem",
9733
+ $padding: "0 1.5rem 0 3rem",
9734
+ ...bordered && {
9735
+ $borderBottomWidth: "1px",
9736
+ $borderBottomStyle: "solid",
9737
+ $borderBottomColor: isLightBackground ? "hsla(0, 0%, 0%, 0.15)" : "hsla(0, 0%, 100%, 0.15)"
9738
+ },
9618
9739
  children: [
9619
9740
  children,
9620
9741
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box, { $cursor: "pointer", onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
@@ -9623,7 +9744,7 @@ var ModalHeader = ({ children, onClose }) => {
9623
9744
  name: "close",
9624
9745
  style: {
9625
9746
  fontSize: 36,
9626
- color: hexToHSL(theme.card.background).l > 50 ? darken(theme.card.background, 27.5) : lighten(theme.card.background, 27.5)
9747
+ color: isLightBackground ? "hsla(0, 0%, 0%, 0.275)" : "hsla(0, 0%, 100%, 0.275)"
9627
9748
  }
9628
9749
  }
9629
9750
  ) })
@@ -9675,14 +9796,14 @@ var ProgressBar = ({
9675
9796
  $overflow: "hidden",
9676
9797
  $width: "100%",
9677
9798
  $height: `${8 / TEXT_BASE_SIZE}rem`,
9678
- $background: "#F2F4F7",
9799
+ $backgroundColor: "#F2F4F7",
9679
9800
  $borderRadius: "9999px",
9680
9801
  children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
9681
9802
  Box,
9682
9803
  {
9683
9804
  $width: `${Math.min(progress, 100)}%`,
9684
9805
  $height: "100%",
9685
- $background: barColorMap[color],
9806
+ $backgroundColor: barColorMap[color],
9686
9807
  $borderRadius: "9999px"
9687
9808
  }
9688
9809
  )
@@ -9742,7 +9863,7 @@ var StyledButton = dt(Button2)`
9742
9863
  if (disabled) {
9743
9864
  const { l: l2 } = hexToHSL(theme.card.background);
9744
9865
  color = hslToHex({ h: 0, s: 0, l: l2 });
9745
- color = l2 > 50 ? darken(color, 7.5) : lighten(color, 7.5);
9866
+ color = l2 > 50 ? darken(color, 0.075) : lighten(color, 0.15);
9746
9867
  }
9747
9868
  return $variant === "filled" ? lt`
9748
9869
  background-color: ${color};
@@ -9765,8 +9886,8 @@ var StyledButton = dt(Button2)`
9765
9886
  &:not(:disabled):hover {
9766
9887
  ${({ $color = "primary", theme, $variant = "filled" }) => {
9767
9888
  const specified = theme[$color];
9768
- const lightened = lighten(specified, 15);
9769
- const color = specified === lightened ? darken(specified, 15) : lightened;
9889
+ const lightened = lighten(specified, 0.15);
9890
+ const color = specified === lightened ? darken(specified, 0.15) : lightened;
9770
9891
  const { l: l2 } = hexToHSL(theme[$color]);
9771
9892
  const textColor = l2 > 50 ? "#000000" : "#FFFFFF";
9772
9893
  return $variant === "filled" ? lt`
@@ -9788,21 +9909,21 @@ var StyledButton = dt(Button2)`
9788
9909
  switch ($size) {
9789
9910
  case "sm":
9790
9911
  return lt`
9791
- font-size: ${15 / 16}rem;
9792
- padding: ${12 / 16}rem 0;
9793
- border-radius: ${6 / 16}rem;
9912
+ font-size: ${15 / TEXT_BASE_SIZE}rem;
9913
+ padding: ${12 / TEXT_BASE_SIZE}rem 0;
9914
+ border-radius: ${6 / TEXT_BASE_SIZE}rem;
9794
9915
  `;
9795
9916
  case "md":
9796
9917
  return lt`
9797
- font-size: ${17 / 16}rem;
9798
- padding: ${16 / 16}rem 0;
9799
- border-radius: ${8 / 16}rem;
9918
+ font-size: ${17 / TEXT_BASE_SIZE}rem;
9919
+ padding: ${16 / TEXT_BASE_SIZE}rem 0;
9920
+ border-radius: ${8 / TEXT_BASE_SIZE}rem;
9800
9921
  `;
9801
9922
  case "lg":
9802
9923
  return lt`
9803
- font-size: ${19 / 16}rem;
9804
- padding: ${20 / 16}rem 0;
9805
- border-radius: ${10 / 16}rem;
9924
+ font-size: ${19 / TEXT_BASE_SIZE}rem;
9925
+ padding: ${20 / TEXT_BASE_SIZE}rem 0;
9926
+ border-radius: ${10 / TEXT_BASE_SIZE}rem;
9806
9927
  `;
9807
9928
  }
9808
9929
  }}
@@ -9825,6 +9946,7 @@ var PaymentForm = ({ plan, period, onConfirm }) => {
9825
9946
  }
9826
9947
  setIsLoading(true);
9827
9948
  setIsConfirmed(false);
9949
+ setMessage(null);
9828
9950
  try {
9829
9951
  const { setupIntent, error } = await stripe.confirmSetup({
9830
9952
  elements,
@@ -9841,13 +9963,9 @@ var PaymentForm = ({ plan, period, onConfirm }) => {
9841
9963
  if (error?.type === "card_error" || error?.type === "validation_error") {
9842
9964
  setMessage(error.message);
9843
9965
  }
9844
- setIsLoading(false);
9845
9966
  } catch (error) {
9846
- if (error instanceof Error) {
9847
- setMessage(error.message);
9848
- } else {
9849
- setMessage("An unexpected error occured.");
9850
- }
9967
+ setMessage("A problem occurred while saving your payment method.");
9968
+ } finally {
9851
9969
  setIsLoading(false);
9852
9970
  }
9853
9971
  };
@@ -9870,8 +9988,8 @@ var PaymentForm = ({ plan, period, onConfirm }) => {
9870
9988
  {
9871
9989
  $flexDirection: "column",
9872
9990
  $gap: "1.5rem",
9873
- $marginBottom: "1.5rem",
9874
9991
  $width: "100%",
9992
+ $marginBottom: "1.5rem",
9875
9993
  children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
9876
9994
  import_react_stripe_js2.LinkAuthenticationElement,
9877
9995
  {
@@ -9880,20 +9998,18 @@ var PaymentForm = ({ plan, period, onConfirm }) => {
9880
9998
  )
9881
9999
  }
9882
10000
  ),
9883
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Flex, { $flexDirection: "column", $width: "100%", $flex: "1", $height: "100%", children: [
9884
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_stripe_js2.PaymentElement, { id: "payment-element" }),
9885
- message && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { id: "payment-message", children: message })
9886
- ] }),
9887
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
10001
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_stripe_js2.PaymentElement, { id: "payment-element" }) }),
10002
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
9888
10003
  StyledButton,
9889
10004
  {
9890
10005
  id: "submit",
9891
10006
  disabled: isLoading || !stripe || !elements || !data.stripeEmbed?.publishableKey || !data.stripeEmbed?.setupIntentClientSecret || isConfirmed,
9892
10007
  $size: "md",
9893
10008
  $color: "primary",
9894
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { id: "button-text", children: !isLoading ? "Loading" : "Save payment method" })
10009
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { id: "button-text", children: isLoading ? "Loading" : "Save payment method" })
9895
10010
  }
9896
- ) })
10011
+ ),
10012
+ message && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { $margin: "1rem 0", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { id: "payment-message", $size: 15, $weight: 500, $color: "#DB6669", children: message }) })
9897
10013
  ]
9898
10014
  }
9899
10015
  );
@@ -9910,8 +10026,9 @@ var CheckoutDialog = () => {
9910
10026
  const [paymentMethodId, setPaymentMethodId] = (0, import_react9.useState)();
9911
10027
  const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
9912
10028
  const [isCheckoutComplete, setIsCheckoutComplete] = (0, import_react9.useState)(false);
10029
+ const [error, setError] = (0, import_react9.useState)();
9913
10030
  const theme = nt();
9914
- const { api, data, settings } = useEmbed();
10031
+ const { api, data, hydrate, setLayout } = useEmbed();
9915
10032
  const { currentPlan, availablePlans } = (0, import_react9.useMemo)(() => {
9916
10033
  return {
9917
10034
  currentPlan: data.company?.plan,
@@ -9926,29 +10043,39 @@ var CheckoutDialog = () => {
9926
10043
  }
9927
10044
  return 0;
9928
10045
  }, [selectedPlan]);
9929
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Modal, { children: [
9930
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ModalHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Flex, { $gap: "1rem", children: !isCheckoutComplete && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
10046
+ const isLightBackground = (0, import_react9.useMemo)(() => {
10047
+ return hexToHSL(theme.card.background).l > 50;
10048
+ }, [theme.card.background]);
10049
+ (0, import_react9.useEffect)(() => {
10050
+ if (isCheckoutComplete && api && data.component?.id) {
10051
+ hydrate();
10052
+ }
10053
+ }, [isCheckoutComplete, api, data.component?.id, hydrate]);
10054
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Modal, { size: isCheckoutComplete ? "auto" : "lg", children: [
10055
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ModalHeader, { bordered: !isCheckoutComplete, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Flex, { $gap: "1rem", children: !isCheckoutComplete && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
9931
10056
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
9932
10057
  checkoutStage === "plan" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
9933
10058
  Box,
9934
10059
  {
9935
- $width: "0.9375rem",
9936
- $height: "0.9375rem",
10060
+ $width: `${20 / TEXT_BASE_SIZE}rem`,
10061
+ $height: `${20 / TEXT_BASE_SIZE}rem`,
9937
10062
  $borderWidth: "2px",
9938
10063
  $borderStyle: "solid",
9939
- $borderColor: hexToHSL(theme.card.background).l > 50 ? darken(theme.card.background, 12.5) : lighten(theme.card.background, 12.5),
10064
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.25)",
9940
10065
  $borderRadius: "9999px"
9941
10066
  }
9942
10067
  ) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
9943
10068
  IconRound,
9944
10069
  {
9945
10070
  name: "check",
10071
+ colors: [
10072
+ theme.card.background,
10073
+ isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.25)"
10074
+ ],
9946
10075
  style: {
9947
- color: theme.card.background,
9948
- backgroundColor: hexToHSL(theme.card.background).l > 50 ? darken(theme.card.background, 12.5) : lighten(theme.card.background, 12.5),
9949
- fontSize: 16,
9950
- width: "1rem",
9951
- height: "1rem"
10076
+ fontSize: `${16 / TEXT_BASE_SIZE}rem`,
10077
+ width: `${20 / TEXT_BASE_SIZE}rem`,
10078
+ height: `${20 / TEXT_BASE_SIZE}rem`
9952
10079
  }
9953
10080
  }
9954
10081
  ),
@@ -9956,39 +10083,43 @@ var CheckoutDialog = () => {
9956
10083
  Box,
9957
10084
  {
9958
10085
  tabIndex: 0,
9959
- ...checkoutStage === "plan" ? {
9960
- style: {
9961
- fontWeight: "700"
9962
- }
9963
- } : {
9964
- style: {
9965
- cursor: "pointer"
9966
- },
9967
- onClick: () => setCheckoutStage("plan")
10086
+ ...checkoutStage !== "plan" && {
10087
+ onClick: () => setCheckoutStage("plan"),
10088
+ $opacity: "0.6375",
10089
+ $cursor: "pointer"
9968
10090
  },
9969
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { children: "1. Select plan" })
9970
- }
9971
- ),
9972
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
9973
- Icon2,
9974
- {
9975
- name: "chevron-right",
9976
- style: {
9977
- fontSize: 16,
9978
- color: hexToHSL(theme.card.background).l > 50 ? darken(theme.card.background, 17.5) : lighten(theme.card.background, 17.5)
9979
- }
10091
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10092
+ Text,
10093
+ {
10094
+ $font: theme.typography.text.fontFamily,
10095
+ $size: 19,
10096
+ $weight: checkoutStage === "plan" ? 600 : 400,
10097
+ $color: theme.typography.text.color,
10098
+ children: "1. Select plan"
10099
+ }
10100
+ )
9980
10101
  }
9981
10102
  )
9982
10103
  ] }),
10104
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10105
+ Icon2,
10106
+ {
10107
+ name: "chevron-right",
10108
+ style: {
10109
+ fontSize: 16,
10110
+ color: isLightBackground ? "hsla(0, 0%, 0%, 0.175)" : "hsla(0, 0%, 100%, 0.35)"
10111
+ }
10112
+ }
10113
+ ),
9983
10114
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
9984
10115
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
9985
10116
  Box,
9986
10117
  {
9987
- $width: "0.9375rem",
9988
- $height: "0.9375rem",
10118
+ $width: `${20 / TEXT_BASE_SIZE}rem`,
10119
+ $height: `${20 / TEXT_BASE_SIZE}rem`,
9989
10120
  $borderWidth: "2px",
9990
10121
  $borderStyle: "solid",
9991
- $borderColor: hexToHSL(theme.card.background).l > 50 ? darken(theme.card.background, 12.5) : lighten(theme.card.background, 12.5),
10122
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.25)",
9992
10123
  $borderRadius: "9999px"
9993
10124
  }
9994
10125
  ),
@@ -9996,41 +10127,70 @@ var CheckoutDialog = () => {
9996
10127
  Box,
9997
10128
  {
9998
10129
  tabIndex: 0,
9999
- ...checkoutStage === "checkout" && {
10000
- style: {
10001
- fontWeight: "700"
10002
- }
10130
+ ...checkoutStage !== "checkout" && {
10131
+ $opacity: "0.6375"
10003
10132
  },
10004
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { children: "2. Checkout" })
10133
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10134
+ Text,
10135
+ {
10136
+ $font: theme.typography.text.fontFamily,
10137
+ $size: 19,
10138
+ $weight: checkoutStage === "plan" ? 600 : 400,
10139
+ $color: theme.typography.text.color,
10140
+ children: "2. Checkout"
10141
+ }
10142
+ )
10005
10143
  }
10006
10144
  )
10007
10145
  ] })
10008
10146
  ] }) }) }),
10009
- isCheckoutComplete && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Flex, { $justifyContent: "center", $alignItems: "center", $flexGrow: "1", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10010
- Text,
10147
+ isCheckoutComplete && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
10148
+ Flex,
10011
10149
  {
10012
- as: "h1",
10013
- $font: theme.typography.heading1.fontFamily,
10014
- $size: theme.typography.heading1.fontSize,
10015
- $weight: theme.typography.heading1.fontWeight,
10016
- $color: theme.typography.heading1.color,
10017
- children: "Subscription updated!"
10150
+ $flexDirection: "column",
10151
+ $justifyContent: "center",
10152
+ $alignItems: "center",
10153
+ $flexGrow: "1",
10154
+ $gap: `${32 / TEXT_BASE_SIZE}rem`,
10155
+ $padding: `${32 / TEXT_BASE_SIZE}rem ${40 / TEXT_BASE_SIZE}rem`,
10156
+ $whiteSpace: "nowrap",
10157
+ children: [
10158
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10159
+ IconRound,
10160
+ {
10161
+ name: "check",
10162
+ size: "3xl",
10163
+ colors: [
10164
+ theme.card.background,
10165
+ isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.125)"
10166
+ ]
10167
+ }
10168
+ ),
10169
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10170
+ Text,
10171
+ {
10172
+ as: "h1",
10173
+ $font: theme.typography.heading1.fontFamily,
10174
+ $size: theme.typography.heading1.fontSize,
10175
+ $weight: theme.typography.heading1.fontWeight,
10176
+ $color: theme.typography.heading1.color,
10177
+ children: "Subscription updated!"
10178
+ }
10179
+ ),
10180
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(StyledButton, { onClick: () => setLayout("portal"), children: "Close" })
10181
+ ]
10018
10182
  }
10019
- ) }),
10020
- !isCheckoutComplete && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Flex, { $position: "relative", $flexGrow: "1", children: [
10183
+ ),
10184
+ !isCheckoutComplete && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Flex, { $position: "relative", $height: "calc(100% - 5rem)", children: [
10021
10185
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
10022
10186
  Flex,
10023
10187
  {
10024
- $position: "absolute",
10025
- $top: "0",
10026
- $left: "0",
10027
10188
  $flexDirection: "column",
10189
+ $flexGrow: "1",
10028
10190
  $gap: "1rem",
10029
10191
  $padding: "2rem 2.5rem 2rem 2.5rem",
10030
- $backgroundColor: darken(settings.theme.card.background, 2.5),
10192
+ $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.025)" : "hsla(0, 0%, 100%, 0.025)",
10031
10193
  $flex: "1",
10032
- $width: "72.5%",
10033
- $height: "100%",
10034
10194
  $overflow: "auto",
10035
10195
  children: [
10036
10196
  checkoutStage === "plan" && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
@@ -10038,9 +10198,12 @@ var CheckoutDialog = () => {
10038
10198
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10039
10199
  Text,
10040
10200
  {
10041
- as: "h1",
10201
+ as: "h3",
10042
10202
  id: "select-plan-dialog-label",
10043
- $size: 18,
10203
+ $font: theme.typography.heading3.fontFamily,
10204
+ $size: theme.typography.heading3.fontSize,
10205
+ $weight: theme.typography.heading3.fontWeight,
10206
+ $color: theme.typography.heading3.color,
10044
10207
  $marginBottom: "0.5rem",
10045
10208
  children: "Select plan"
10046
10209
  }
@@ -10050,25 +10213,28 @@ var CheckoutDialog = () => {
10050
10213
  {
10051
10214
  as: "p",
10052
10215
  id: "select-plan-dialog-description",
10053
- $size: 14,
10054
- $weight: 400,
10216
+ $font: theme.typography.text.fontFamily,
10217
+ $size: theme.typography.text.fontSize,
10218
+ $weight: theme.typography.text.fontWeight,
10219
+ $color: theme.typography.text.color,
10055
10220
  children: "Choose your base plan"
10056
10221
  }
10057
10222
  )
10058
10223
  ] }),
10059
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Flex, { $gap: "1rem", $flexGrow: "1", children: availablePlans?.map((plan) => {
10224
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Flex, { $flexWrap: "wrap", $gap: "1rem", $flexGrow: "1", children: availablePlans?.map((plan) => {
10060
10225
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
10061
10226
  Flex,
10062
10227
  {
10063
- $height: "100%",
10064
10228
  $flexDirection: "column",
10065
- $backgroundColor: settings.theme.card.background,
10066
- $flex: "1",
10229
+ $width: "100%",
10230
+ $minWidth: "280px",
10231
+ $maxWidth: `calc(${100 / 3}% - 1rem)`,
10232
+ $backgroundColor: theme.card.background,
10067
10233
  $outlineWidth: "2px",
10068
10234
  $outlineStyle: "solid",
10069
10235
  $outlineColor: plan.id === selectedPlan?.id ? theme.primary : "transparent",
10070
- $borderRadius: `${settings.theme.card.borderRadius / 16}rem`,
10071
- ...settings.theme.card.hasShadow && {
10236
+ $borderRadius: `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`,
10237
+ ...theme.card.hasShadow && {
10072
10238
  $boxShadow: "0px 1px 3px rgba(16, 24, 40, 0.1), 0px 1px 20px rgba(16, 24, 40, 0.06)"
10073
10239
  },
10074
10240
  children: [
@@ -10080,10 +10246,10 @@ var CheckoutDialog = () => {
10080
10246
  $gap: "1rem",
10081
10247
  $width: "100%",
10082
10248
  $height: "auto",
10083
- $padding: `${settings.theme.card.padding / 16}rem`,
10249
+ $padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
10084
10250
  $borderBottomWidth: "1px",
10085
10251
  $borderStyle: "solid",
10086
- $borderColor: hexToHSL(theme.card.background).l > 50 ? darken(theme.card.background, 17.5) : lighten(theme.card.background, 17.5),
10252
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.175)" : "hsla(0, 0%, 100%, 0.175)",
10087
10253
  children: [
10088
10254
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { $size: 20, $weight: 600, children: plan.name }),
10089
10255
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { $size: 14, children: plan.description }),
@@ -10136,8 +10302,8 @@ var CheckoutDialog = () => {
10136
10302
  name: feature.icon,
10137
10303
  size: "tn",
10138
10304
  colors: [
10139
- settings.theme.primary,
10140
- `${hexToHSL(settings.theme.card.background).l > 50 ? darken(settings.theme.card.background, 10) : lighten(settings.theme.card.background, 20)}`
10305
+ theme.primary,
10306
+ isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.0625)"
10141
10307
  ]
10142
10308
  }
10143
10309
  ),
@@ -10182,10 +10348,8 @@ var CheckoutDialog = () => {
10182
10348
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10183
10349
  Text,
10184
10350
  {
10185
- style: {
10186
- color: hexToHSL(theme.card.background).l > 50 ? "#000000" : "#FFFFFF",
10187
- lineHeight: "1.4"
10188
- },
10351
+ $lineHeight: "1.4",
10352
+ $color: theme.typography.text.color,
10189
10353
  children: "Selected"
10190
10354
  }
10191
10355
  )
@@ -10196,12 +10360,12 @@ var CheckoutDialog = () => {
10196
10360
  StyledButton,
10197
10361
  {
10198
10362
  disabled: plan.valid === false,
10363
+ ...plan.valid === true && {
10364
+ onClick: () => setSelectedPlan(plan)
10365
+ },
10199
10366
  $size: "sm",
10200
10367
  $color: "primary",
10201
10368
  $variant: "outline",
10202
- onClick: () => {
10203
- setSelectedPlan(plan);
10204
- },
10205
10369
  children: "Select"
10206
10370
  }
10207
10371
  )
@@ -10230,14 +10394,10 @@ var CheckoutDialog = () => {
10230
10394
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
10231
10395
  Flex,
10232
10396
  {
10233
- $position: "absolute",
10234
- $top: "0",
10235
- $right: "0",
10236
10397
  $flexDirection: "column",
10237
- $background: settings.theme.card.background,
10398
+ $backgroundColor: theme.card.background,
10238
10399
  $borderRadius: "0 0 0.5rem",
10239
- $width: "27.5%",
10240
- $height: "100%",
10400
+ $width: "21.5rem",
10241
10401
  $boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
10242
10402
  children: [
10243
10403
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
@@ -10249,13 +10409,27 @@ var CheckoutDialog = () => {
10249
10409
  $width: "100%",
10250
10410
  $height: "auto",
10251
10411
  $padding: "1.5rem",
10252
- $borderBottom: "1px solid #DEDEDE",
10412
+ $borderBottomWidth: "1px",
10413
+ $borderStyle: "solid",
10414
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)",
10253
10415
  children: [
10254
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Flex, { $justifyContent: "space-between", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { $size: 20, $weight: 600, children: "Subscription" }) }),
10416
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Flex, { $justifyContent: "space-between", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10417
+ Text,
10418
+ {
10419
+ as: "h3",
10420
+ $font: theme.typography.heading3.fontFamily,
10421
+ $size: theme.typography.heading3.fontSize,
10422
+ $weight: theme.typography.heading3.fontWeight,
10423
+ $color: theme.typography.heading3.color,
10424
+ children: "Subscription"
10425
+ }
10426
+ ) }),
10255
10427
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
10256
10428
  Flex,
10257
10429
  {
10258
- $border: "1px solid #D9D9D9",
10430
+ $borderWidth: "1px",
10431
+ $borderStyle: "solid",
10432
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)",
10259
10433
  $borderRadius: "2.5rem",
10260
10434
  $cursor: "pointer",
10261
10435
  children: [
@@ -10267,9 +10441,20 @@ var CheckoutDialog = () => {
10267
10441
  $alignItems: "center",
10268
10442
  $padding: "0.25rem 0.5rem",
10269
10443
  $flex: "1",
10270
- $backgroundColor: planPeriod === "month" ? darken(settings.theme.card.background, 8) : lighten(settings.theme.card.background, 2),
10444
+ ...planPeriod === "month" && {
10445
+ $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.075)" : "hsla(0, 0%, 100%, 0.15)"
10446
+ },
10271
10447
  $borderRadius: "2.5rem",
10272
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { $size: 12, $weight: planPeriod === "month" ? 600 : 400, children: "Billed monthly" })
10448
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10449
+ Text,
10450
+ {
10451
+ $font: theme.typography.text.fontFamily,
10452
+ $size: 14,
10453
+ $weight: planPeriod === "month" ? 600 : 400,
10454
+ $color: theme.typography.text.color,
10455
+ children: "Billed monthly"
10456
+ }
10457
+ )
10273
10458
  }
10274
10459
  ),
10275
10460
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -10280,15 +10465,35 @@ var CheckoutDialog = () => {
10280
10465
  $alignItems: "center",
10281
10466
  $padding: "0.25rem 0.5rem",
10282
10467
  $flex: "1",
10283
- $backgroundColor: planPeriod === "year" ? darken(settings.theme.card.background, 8) : lighten(settings.theme.card.background, 2),
10468
+ ...planPeriod === "year" && {
10469
+ $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.075)" : "hsla(0, 0%, 100%, 0.15)"
10470
+ },
10284
10471
  $borderRadius: "2.5rem",
10285
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { $size: 12, $weight: planPeriod === "year" ? 600 : 400, children: "Billed yearly" })
10472
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10473
+ Text,
10474
+ {
10475
+ $font: theme.typography.text.fontFamily,
10476
+ $size: 14,
10477
+ $weight: planPeriod === "year" ? 600 : 400,
10478
+ $color: theme.typography.text.color,
10479
+ children: "Billed yearly"
10480
+ }
10481
+ )
10286
10482
  }
10287
10483
  )
10288
10484
  ]
10289
10485
  }
10290
10486
  ),
10291
- savingsPercentage > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { $size: 11, $color: "#194BFB", children: planPeriod === "month" ? `Save up to ${savingsPercentage}% with yearly billing` : `You are saving ${savingsPercentage}% with yearly billing` }) })
10487
+ savingsPercentage > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10488
+ Text,
10489
+ {
10490
+ $font: theme.typography.text.fontFamily,
10491
+ $size: 11,
10492
+ $weight: theme.typography.text.fontWeight,
10493
+ $color: theme.primary,
10494
+ children: planPeriod === "month" ? `Save up to ${savingsPercentage}% with yearly billing` : `You are saving ${savingsPercentage}% with yearly billing`
10495
+ }
10496
+ ) })
10292
10497
  ]
10293
10498
  }
10294
10499
  ),
@@ -10302,85 +10507,106 @@ var CheckoutDialog = () => {
10302
10507
  $height: "auto",
10303
10508
  $padding: "1.5rem",
10304
10509
  $flex: "1",
10305
- $borderBottom: "1px solid #DEDEDE",
10510
+ $borderBottomWidth: "1px",
10511
+ $borderStyle: "solid",
10512
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)",
10306
10513
  children: [
10307
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { $size: 14, $color: "#5D5D5D", children: "Plan" }) }),
10308
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
10309
- Flex,
10514
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box, { $opacity: "0.625", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10515
+ Text,
10310
10516
  {
10311
- $flexDirection: "column",
10312
- $fontSize: "0.875rem",
10313
- $color: "#5D5D5D",
10314
- $gap: "0.5rem",
10315
- children: [
10316
- currentPlan && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
10317
- Flex,
10318
- {
10319
- $alignItems: "center",
10320
- $justifyContent: "space-between",
10321
- $fontSize: "0.875rem",
10322
- $color: "#5D5D5D",
10323
- children: [
10324
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Flex, { $fontSize: "0.875rem", $color: "#5D5D5D", children: currentPlan.name }),
10325
- typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Flex, { $fontSize: "0.75rem", $color: "#000000", children: [
10326
- formatCurrency(currentPlan.planPrice),
10327
- "/",
10328
- currentPlan.planPeriod
10329
- ] })
10330
- ]
10331
- }
10332
- ),
10333
- selectedPlan && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
10334
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10335
- Box,
10517
+ $font: theme.typography.text.fontFamily,
10518
+ $size: 14,
10519
+ $weight: theme.typography.text.fontWeight,
10520
+ $color: theme.typography.text.color,
10521
+ children: "Plan"
10522
+ }
10523
+ ) }),
10524
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Flex, { $flexDirection: "column", $gap: "0.5rem", children: [
10525
+ currentPlan && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
10526
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10527
+ Flex,
10528
+ {
10529
+ ...selectedPlan && {
10530
+ $opacity: "0.625",
10531
+ $textDecoration: "line-through"
10532
+ },
10533
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10534
+ Text,
10336
10535
  {
10337
- $width: "100%",
10338
- $textAlign: "left",
10339
- $opacity: "50%",
10340
- $marginBottom: "-0.25rem",
10341
- $marginTop: "-0.25rem",
10342
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10343
- Icon2,
10344
- {
10345
- name: "arrow-down",
10346
- style: {
10347
- display: "inline-block"
10348
- }
10349
- }
10350
- )
10536
+ $font: theme.typography.heading4.fontFamily,
10537
+ $size: theme.typography.heading4.fontSize,
10538
+ $weight: theme.typography.heading4.fontWeight,
10539
+ $color: theme.typography.heading4.color,
10540
+ children: currentPlan.name
10351
10541
  }
10352
- ),
10353
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
10354
- Flex,
10542
+ )
10543
+ }
10544
+ ),
10545
+ typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Flex, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
10546
+ Text,
10547
+ {
10548
+ $font: theme.typography.text.fontFamily,
10549
+ $size: theme.typography.text.fontSize,
10550
+ $weight: theme.typography.text.fontWeight,
10551
+ $color: theme.typography.text.color,
10552
+ children: [
10553
+ formatCurrency(currentPlan.planPrice),
10554
+ "/",
10555
+ currentPlan.planPeriod
10556
+ ]
10557
+ }
10558
+ ) })
10559
+ ] }),
10560
+ selectedPlan && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
10561
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10562
+ Box,
10563
+ {
10564
+ $width: "100%",
10565
+ $textAlign: "left",
10566
+ $opacity: "50%",
10567
+ $marginBottom: "-0.25rem",
10568
+ $marginTop: "-0.25rem",
10569
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10570
+ Icon2,
10355
10571
  {
10356
- $alignItems: "center",
10357
- $justifyContent: "space-between",
10358
- $fontSize: "0.875rem",
10359
- $color: "#5D5D5D",
10360
- children: [
10361
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10362
- Flex,
10363
- {
10364
- $fontSize: "0.875rem",
10365
- $color: "#000000",
10366
- $fontWeight: "600",
10367
- children: selectedPlan.name
10368
- }
10369
- ),
10370
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Flex, { $fontSize: "0.75rem", $color: "#000000", children: [
10371
- formatCurrency(
10372
- (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
10373
- ),
10374
- "/",
10375
- planPeriod
10376
- ] })
10377
- ]
10572
+ name: "arrow-down",
10573
+ style: {
10574
+ display: "inline-block"
10575
+ }
10378
10576
  }
10379
10577
  )
10380
- ] })
10381
- ]
10382
- }
10383
- )
10578
+ }
10579
+ ),
10580
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
10581
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Flex, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10582
+ Text,
10583
+ {
10584
+ $font: theme.typography.heading4.fontFamily,
10585
+ $size: theme.typography.heading4.fontSize,
10586
+ $weight: theme.typography.heading4.fontWeight,
10587
+ $color: theme.typography.heading4.color,
10588
+ children: selectedPlan.name
10589
+ }
10590
+ ) }),
10591
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Flex, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
10592
+ Text,
10593
+ {
10594
+ $font: theme.typography.text.fontFamily,
10595
+ $size: theme.typography.text.fontSize,
10596
+ $weight: theme.typography.text.fontWeight,
10597
+ $color: theme.typography.text.color,
10598
+ children: [
10599
+ formatCurrency(
10600
+ (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
10601
+ ),
10602
+ "/",
10603
+ planPeriod
10604
+ ]
10605
+ }
10606
+ ) })
10607
+ ] })
10608
+ ] })
10609
+ ] })
10384
10610
  ]
10385
10611
  }
10386
10612
  ),
@@ -10389,47 +10615,57 @@ var CheckoutDialog = () => {
10389
10615
  {
10390
10616
  $flexDirection: "column",
10391
10617
  $position: "relative",
10392
- $gap: "0.75rem",
10618
+ $gap: "1rem",
10393
10619
  $width: "100%",
10394
10620
  $height: "auto",
10395
10621
  $padding: "1.5rem",
10396
10622
  children: [
10397
- selectedPlan && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
10398
- Flex,
10399
- {
10400
- $fontSize: "0.75rem",
10401
- $color: "#5D5D5D",
10402
- $justifyContent: "space-between",
10403
- children: [
10404
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Box, { $fontSize: "0.75rem", $color: "#5D5D5D", children: [
10623
+ selectedPlan && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Flex, { $justifyContent: "space-between", children: [
10624
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box, { $opacity: "0.625", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
10625
+ Text,
10626
+ {
10627
+ $font: theme.typography.text.fontFamily,
10628
+ $size: theme.typography.text.fontSize,
10629
+ $weight: theme.typography.text.fontWeight,
10630
+ $color: theme.typography.text.color,
10631
+ children: [
10405
10632
  planPeriod === "month" ? "Monthly" : "Yearly",
10406
10633
  " total:",
10407
10634
  " "
10408
- ] }),
10409
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Box, { $fontSize: "0.75rem", $color: "#000000", children: [
10635
+ ]
10636
+ }
10637
+ ) }),
10638
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
10639
+ Text,
10640
+ {
10641
+ $font: theme.typography.text.fontFamily,
10642
+ $size: theme.typography.text.fontSize,
10643
+ $weight: theme.typography.text.fontWeight,
10644
+ $color: theme.typography.text.color,
10645
+ children: [
10410
10646
  formatCurrency(
10411
10647
  (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
10412
10648
  ),
10413
10649
  "/",
10414
10650
  planPeriod
10415
- ] })
10416
- ]
10417
- }
10418
- ),
10651
+ ]
10652
+ }
10653
+ ) })
10654
+ ] }),
10419
10655
  checkoutStage === "plan" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10420
10656
  StyledButton,
10421
10657
  {
10422
10658
  disabled: !selectedPlan,
10423
- onClick: () => {
10424
- setCheckoutStage("checkout");
10659
+ ...selectedPlan && {
10660
+ onClick: () => setCheckoutStage("checkout")
10425
10661
  },
10426
10662
  $size: "sm",
10427
10663
  children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
10428
10664
  Flex,
10429
10665
  {
10430
10666
  $gap: "0.5rem",
10431
- $alignItems: "center",
10432
10667
  $justifyContent: "center",
10668
+ $alignItems: "center",
10433
10669
  $padding: "0 1rem",
10434
10670
  children: [
10435
10671
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { $align: "left", children: "Next: Checkout" }),
@@ -10458,10 +10694,11 @@ var CheckoutDialog = () => {
10458
10694
  }
10459
10695
  });
10460
10696
  setIsCheckoutComplete(true);
10461
- } catch (error) {
10462
- console.error(error);
10697
+ } catch {
10698
+ setError(
10699
+ "Error processing payment. Please try a different payment method."
10700
+ );
10463
10701
  } finally {
10464
- setIsCheckoutComplete(true);
10465
10702
  setIsLoading(false);
10466
10703
  }
10467
10704
  },
@@ -10469,7 +10706,26 @@ var CheckoutDialog = () => {
10469
10706
  children: "Pay now"
10470
10707
  }
10471
10708
  ),
10472
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box, { $fontSize: "0.75rem", $color: "#5D5D5D", children: "Discounts & credits applied at checkout" })
10709
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box, { $opacity: "0.625", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10710
+ Text,
10711
+ {
10712
+ $font: theme.typography.text.fontFamily,
10713
+ $size: theme.typography.text.fontSize,
10714
+ $weight: theme.typography.text.fontWeight,
10715
+ $color: theme.typography.text.color,
10716
+ children: "Discounts & credits applied at checkout"
10717
+ }
10718
+ ) }),
10719
+ error && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
10720
+ Text,
10721
+ {
10722
+ $font: theme.typography.text.fontFamily,
10723
+ $size: theme.typography.text.fontSize,
10724
+ $weight: 500,
10725
+ $color: "#DB6669",
10726
+ children: error
10727
+ }
10728
+ ) })
10473
10729
  ]
10474
10730
  }
10475
10731
  )
@@ -10505,14 +10761,15 @@ var resolveDesignProps = (props) => {
10505
10761
  },
10506
10762
  callToAction: {
10507
10763
  isVisible: props.callToAction?.isVisible ?? true,
10508
- buttonSize: props.callToAction?.buttonSize ?? "md",
10764
+ buttonSize: props.callToAction?.buttonSize ?? "lg",
10509
10765
  buttonStyle: props.callToAction?.buttonStyle ?? "primary"
10510
10766
  }
10511
10767
  };
10512
10768
  };
10513
10769
  var PlanManager = (0, import_react10.forwardRef)(({ children, className, portal, ...rest }, ref) => {
10514
10770
  const props = resolveDesignProps(rest);
10515
- const { data, settings, layout, stripe, setLayout } = useEmbed();
10771
+ const theme = nt();
10772
+ const { data, layout, stripe, setLayout } = useEmbed();
10516
10773
  const { currentPlan, canChangePlan } = (0, import_react10.useMemo)(() => {
10517
10774
  return {
10518
10775
  currentPlan: data.company?.plan,
@@ -10538,10 +10795,10 @@ var PlanManager = (0, import_react10.forwardRef)(({ children, className, portal,
10538
10795
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Box, { $margin: "0 0 0.75rem", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
10539
10796
  Text,
10540
10797
  {
10541
- $font: settings.theme.typography[props.header.title.fontStyle].fontFamily,
10542
- $size: settings.theme.typography[props.header.title.fontStyle].fontSize,
10543
- $weight: settings.theme.typography[props.header.title.fontStyle].fontWeight,
10544
- $color: settings.theme.typography[props.header.title.fontStyle].color,
10798
+ $font: theme.typography[props.header.title.fontStyle].fontFamily,
10799
+ $size: theme.typography[props.header.title.fontStyle].fontSize,
10800
+ $weight: theme.typography[props.header.title.fontStyle].fontWeight,
10801
+ $color: theme.typography[props.header.title.fontStyle].color,
10545
10802
  $lineHeight: 1,
10546
10803
  children: currentPlan.name
10547
10804
  }
@@ -10549,10 +10806,10 @@ var PlanManager = (0, import_react10.forwardRef)(({ children, className, portal,
10549
10806
  props.header.description.isVisible && currentPlan.description && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
10550
10807
  Text,
10551
10808
  {
10552
- $font: settings.theme.typography[props.header.description.fontStyle].fontFamily,
10553
- $size: settings.theme.typography[props.header.description.fontStyle].fontSize,
10554
- $weight: settings.theme.typography[props.header.description.fontStyle].fontWeight,
10555
- $color: settings.theme.typography[props.header.description.fontStyle].color,
10809
+ $font: theme.typography[props.header.description.fontStyle].fontFamily,
10810
+ $size: theme.typography[props.header.description.fontStyle].fontSize,
10811
+ $weight: theme.typography[props.header.description.fontStyle].fontWeight,
10812
+ $color: theme.typography[props.header.description.fontStyle].color,
10556
10813
  children: currentPlan.description
10557
10814
  }
10558
10815
  )
@@ -10560,10 +10817,10 @@ var PlanManager = (0, import_react10.forwardRef)(({ children, className, portal,
10560
10817
  props.header.price.isVisible && typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
10561
10818
  Text,
10562
10819
  {
10563
- $font: settings.theme.typography[props.header.price.fontStyle].fontFamily,
10564
- $size: settings.theme.typography[props.header.price.fontStyle].fontSize,
10565
- $weight: settings.theme.typography[props.header.price.fontStyle].fontWeight,
10566
- $color: settings.theme.typography[props.header.price.fontStyle].color,
10820
+ $font: theme.typography[props.header.price.fontStyle].fontFamily,
10821
+ $size: theme.typography[props.header.price.fontStyle].fontSize,
10822
+ $weight: theme.typography[props.header.price.fontStyle].fontWeight,
10823
+ $color: theme.typography[props.header.price.fontStyle].color,
10567
10824
  children: [
10568
10825
  formatCurrency(currentPlan.planPrice),
10569
10826
  "/",
@@ -10584,15 +10841,7 @@ var PlanManager = (0, import_react10.forwardRef)(({ children, className, portal,
10584
10841
  },
10585
10842
  $size: props.callToAction.buttonSize,
10586
10843
  $color: props.callToAction.buttonStyle,
10587
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
10588
- Text,
10589
- {
10590
- $font: settings.theme.typography.text.fontFamily,
10591
- $size: settings.theme.typography.text.fontSize,
10592
- $weight: settings.theme.typography.text.fontWeight,
10593
- children: "Change Plan"
10594
- }
10595
- )
10844
+ children: "Change Plan"
10596
10845
  }
10597
10846
  ),
10598
10847
  canChangePlan && layout === "checkout" && (0, import_react_dom.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckoutDialog, {}), portal || document.body)
@@ -10611,12 +10860,12 @@ function resolveDesignProps2(props) {
10611
10860
  },
10612
10861
  icons: {
10613
10862
  isVisible: props.icons?.isVisible ?? true,
10614
- fontStyle: props.icons?.fontStyle ?? "heading3",
10863
+ fontStyle: props.icons?.fontStyle ?? "heading5",
10615
10864
  style: props.icons?.style ?? "light"
10616
10865
  },
10617
10866
  entitlement: {
10618
10867
  isVisible: props.entitlement?.isVisible ?? true,
10619
- fontStyle: props.entitlement?.fontStyle ?? "heading5"
10868
+ fontStyle: props.entitlement?.fontStyle ?? "text"
10620
10869
  },
10621
10870
  usage: {
10622
10871
  isVisible: props.usage?.isVisible ?? true,
@@ -10626,7 +10875,8 @@ function resolveDesignProps2(props) {
10626
10875
  }
10627
10876
  var IncludedFeatures = (0, import_react11.forwardRef)(({ className, ...rest }, ref) => {
10628
10877
  const props = resolveDesignProps2(rest);
10629
- const { data, settings } = useEmbed();
10878
+ const theme = nt();
10879
+ const { data } = useEmbed();
10630
10880
  const features = (0, import_react11.useMemo)(() => {
10631
10881
  return (data.featureUsage?.features || []).map(
10632
10882
  ({
@@ -10654,14 +10904,17 @@ var IncludedFeatures = (0, import_react11.forwardRef)(({ className, ...rest }, r
10654
10904
  }
10655
10905
  );
10656
10906
  }, [data.featureUsage]);
10907
+ const isLightBackground = (0, import_react11.useMemo)(() => {
10908
+ return hexToHSL(theme.card.background).l > 50;
10909
+ }, [theme.card.background]);
10657
10910
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Flex, { ref, className, $flexDirection: "column", $gap: "1.5rem", children: [
10658
10911
  props.header.isVisible && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10659
10912
  Text,
10660
10913
  {
10661
- $font: settings.theme.typography[props.header.fontStyle].fontFamily,
10662
- $size: settings.theme.typography[props.header.fontStyle].fontSize,
10663
- $weight: settings.theme.typography[props.header.fontStyle].fontWeight,
10664
- $color: settings.theme.typography[props.header.fontStyle].color,
10914
+ $font: theme.typography[props.header.fontStyle].fontFamily,
10915
+ $size: theme.typography[props.header.fontStyle].fontSize,
10916
+ $weight: theme.typography[props.header.fontStyle].fontWeight,
10917
+ $color: theme.typography[props.header.fontStyle].color,
10665
10918
  children: props.header.text
10666
10919
  }
10667
10920
  ) }),
@@ -10687,18 +10940,18 @@ var IncludedFeatures = (0, import_react11.forwardRef)(({ className, ...rest }, r
10687
10940
  name: feature.icon,
10688
10941
  size: "sm",
10689
10942
  colors: [
10690
- settings.theme.primary,
10691
- `${hexToHSL(settings.theme.card.background).l > 50 ? darken(settings.theme.card.background, 10) : lighten(settings.theme.card.background, 20)}`
10943
+ theme.primary,
10944
+ isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.25)"
10692
10945
  ]
10693
10946
  }
10694
10947
  ),
10695
10948
  feature?.name && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Flex, { $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10696
10949
  Text,
10697
10950
  {
10698
- $font: settings.theme.typography[props.icons.fontStyle].fontFamily,
10699
- $size: settings.theme.typography[props.icons.fontStyle].fontSize,
10700
- $weight: settings.theme.typography[props.icons.fontStyle].fontWeight,
10701
- $color: settings.theme.typography[props.icons.fontStyle].color,
10951
+ $font: theme.typography[props.icons.fontStyle].fontFamily,
10952
+ $size: theme.typography[props.icons.fontStyle].fontSize,
10953
+ $weight: theme.typography[props.icons.fontStyle].fontWeight,
10954
+ $color: theme.typography[props.icons.fontStyle].color,
10702
10955
  children: feature.name
10703
10956
  }
10704
10957
  ) })
@@ -10708,10 +10961,11 @@ var IncludedFeatures = (0, import_react11.forwardRef)(({ className, ...rest }, r
10708
10961
  Text,
10709
10962
  {
10710
10963
  as: Box,
10711
- $font: settings.theme.typography[props.entitlement.fontStyle].fontFamily,
10712
- $size: settings.theme.typography[props.entitlement.fontStyle].fontSize,
10713
- $weight: settings.theme.typography[props.entitlement.fontStyle].fontWeight,
10714
- $color: settings.theme.typography[props.entitlement.fontStyle].color,
10964
+ $font: theme.typography[props.entitlement.fontStyle].fontFamily,
10965
+ $size: theme.typography[props.entitlement.fontStyle].fontSize,
10966
+ $weight: theme.typography[props.entitlement.fontStyle].fontWeight,
10967
+ $lineHeight: 1.5,
10968
+ $color: theme.typography[props.entitlement.fontStyle].color,
10715
10969
  children: typeof allocation === "number" ? `${allocation} ${feature.name}` : `Unlimited ${feature.name}`
10716
10970
  }
10717
10971
  ),
@@ -10719,10 +10973,11 @@ var IncludedFeatures = (0, import_react11.forwardRef)(({ className, ...rest }, r
10719
10973
  Text,
10720
10974
  {
10721
10975
  as: Box,
10722
- $font: settings.theme.typography[props.usage.fontStyle].fontFamily,
10723
- $size: settings.theme.typography[props.usage.fontStyle].fontSize,
10724
- $weight: settings.theme.typography[props.usage.fontStyle].fontWeight,
10725
- $color: settings.theme.typography[props.usage.fontStyle].color,
10976
+ $font: theme.typography[props.usage.fontStyle].fontFamily,
10977
+ $size: theme.typography[props.usage.fontStyle].fontSize,
10978
+ $weight: theme.typography[props.usage.fontStyle].fontWeight,
10979
+ $lineHeight: 1.5,
10980
+ $color: theme.typography[props.usage.fontStyle].color,
10726
10981
  children: typeof allocation === "number" ? `${usage} of ${allocation} used` : `${usage} used`
10727
10982
  }
10728
10983
  )
@@ -10771,7 +11026,8 @@ function resolveDesignProps3(props) {
10771
11026
  }
10772
11027
  var MeteredFeatures = (0, import_react12.forwardRef)(({ className, ...rest }, ref) => {
10773
11028
  const props = resolveDesignProps3(rest);
10774
- const { data, settings } = useEmbed();
11029
+ const theme = nt();
11030
+ const { data } = useEmbed();
10775
11031
  const features = (0, import_react12.useMemo)(() => {
10776
11032
  return (data.featureUsage?.features || []).map(
10777
11033
  ({
@@ -10815,10 +11071,10 @@ var MeteredFeatures = (0, import_react12.forwardRef)(({ className, ...rest }, re
10815
11071
  Text,
10816
11072
  {
10817
11073
  as: Box,
10818
- $font: settings.theme.typography[props.header.fontStyle].fontFamily,
10819
- $size: settings.theme.typography[props.header.fontStyle].fontSize,
10820
- $weight: settings.theme.typography[props.header.fontStyle].fontWeight,
10821
- $color: settings.theme.typography[props.header.fontStyle].color,
11074
+ $font: theme.typography[props.header.fontStyle].fontFamily,
11075
+ $size: theme.typography[props.header.fontStyle].fontSize,
11076
+ $weight: theme.typography[props.header.fontStyle].fontWeight,
11077
+ $color: theme.typography[props.header.fontStyle].color,
10822
11078
  children: feature.name
10823
11079
  }
10824
11080
  ),
@@ -10826,10 +11082,10 @@ var MeteredFeatures = (0, import_react12.forwardRef)(({ className, ...rest }, re
10826
11082
  Text,
10827
11083
  {
10828
11084
  as: Box,
10829
- $font: settings.theme.typography[props.description.fontStyle].fontFamily,
10830
- $size: settings.theme.typography[props.description.fontStyle].fontSize,
10831
- $weight: settings.theme.typography[props.description.fontStyle].fontWeight,
10832
- $color: settings.theme.typography[props.description.fontStyle].color,
11085
+ $font: theme.typography[props.description.fontStyle].fontFamily,
11086
+ $size: theme.typography[props.description.fontStyle].fontSize,
11087
+ $weight: theme.typography[props.description.fontStyle].fontWeight,
11088
+ $color: theme.typography[props.description.fontStyle].color,
10833
11089
  children: feature.description
10834
11090
  }
10835
11091
  )
@@ -10839,10 +11095,10 @@ var MeteredFeatures = (0, import_react12.forwardRef)(({ className, ...rest }, re
10839
11095
  Text,
10840
11096
  {
10841
11097
  as: Box,
10842
- $font: settings.theme.typography[props.allocation.fontStyle].fontFamily,
10843
- $size: settings.theme.typography[props.allocation.fontStyle].fontSize,
10844
- $weight: settings.theme.typography[props.allocation.fontStyle].fontWeight,
10845
- $color: settings.theme.typography[props.allocation.fontStyle].color,
11098
+ $font: theme.typography[props.allocation.fontStyle].fontFamily,
11099
+ $size: theme.typography[props.allocation.fontStyle].fontSize,
11100
+ $weight: theme.typography[props.allocation.fontStyle].fontWeight,
11101
+ $color: theme.typography[props.allocation.fontStyle].color,
10846
11102
  children: typeof allocation === "number" ? `${allocation} ${feature.name}` : `Unlimited ${feature.name}`
10847
11103
  }
10848
11104
  ),
@@ -10850,10 +11106,10 @@ var MeteredFeatures = (0, import_react12.forwardRef)(({ className, ...rest }, re
10850
11106
  Text,
10851
11107
  {
10852
11108
  as: Box,
10853
- $font: settings.theme.typography[props.usage.fontStyle].fontFamily,
10854
- $size: settings.theme.typography[props.usage.fontStyle].fontSize,
10855
- $weight: settings.theme.typography[props.usage.fontStyle].fontWeight,
10856
- $color: settings.theme.typography[props.usage.fontStyle].color,
11109
+ $font: theme.typography[props.usage.fontStyle].fontFamily,
11110
+ $size: theme.typography[props.usage.fontStyle].fontSize,
11111
+ $weight: theme.typography[props.usage.fontStyle].fontWeight,
11112
+ $color: theme.typography[props.usage.fontStyle].color,
10857
11113
  children: typeof allocation === "number" ? `${usage} of ${allocation} used` : `${usage} used`
10858
11114
  }
10859
11115
  )
@@ -10899,7 +11155,8 @@ function resolveDesignProps4(props) {
10899
11155
  }
10900
11156
  var UpcomingBill = (0, import_react13.forwardRef)(({ className, ...rest }, ref) => {
10901
11157
  const props = resolveDesignProps4(rest);
10902
- const { data, settings, stripe } = useEmbed();
11158
+ const theme = nt();
11159
+ const { data, stripe } = useEmbed();
10903
11160
  const { upcomingInvoice } = (0, import_react13.useMemo)(() => {
10904
11161
  return {
10905
11162
  upcomingInvoice: {
@@ -10915,7 +11172,7 @@ var UpcomingBill = (0, import_react13.forwardRef)(({ className, ...rest }, ref)
10915
11172
  }
10916
11173
  };
10917
11174
  }, [data.subscription, data.upcomingInvoice]);
10918
- if (!stripe || !data.upcomingInvoice) {
11175
+ if (!stripe || !upcomingInvoice.amountDue || !upcomingInvoice.dueDate) {
10919
11176
  return null;
10920
11177
  }
10921
11178
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { ref, className, children: [
@@ -10928,10 +11185,10 @@ var UpcomingBill = (0, import_react13.forwardRef)(({ className, ...rest }, ref)
10928
11185
  children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
10929
11186
  Text,
10930
11187
  {
10931
- $font: settings.theme.typography[props.header.fontStyle].fontFamily,
10932
- $size: settings.theme.typography[props.header.fontStyle].fontSize,
10933
- $weight: settings.theme.typography[props.header.fontStyle].fontWeight,
10934
- $color: settings.theme.typography[props.header.fontStyle].color,
11188
+ $font: theme.typography[props.header.fontStyle].fontFamily,
11189
+ $size: theme.typography[props.header.fontStyle].fontSize,
11190
+ $weight: theme.typography[props.header.fontStyle].fontWeight,
11191
+ $color: theme.typography[props.header.fontStyle].color,
10935
11192
  children: [
10936
11193
  props.header.prefix,
10937
11194
  " ",
@@ -10945,10 +11202,10 @@ var UpcomingBill = (0, import_react13.forwardRef)(({ className, ...rest }, ref)
10945
11202
  props.price.isVisible && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Flex, { $alignItems: "end", $flexGrow: "1", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
10946
11203
  Text,
10947
11204
  {
10948
- $font: settings.theme.typography[props.price.fontStyle].fontFamily,
10949
- $size: settings.theme.typography[props.price.fontStyle].fontSize,
10950
- $weight: settings.theme.typography[props.price.fontStyle].fontWeight,
10951
- $color: settings.theme.typography[props.price.fontStyle].color,
11205
+ $font: theme.typography[props.price.fontStyle].fontFamily,
11206
+ $size: theme.typography[props.price.fontStyle].fontSize,
11207
+ $weight: theme.typography[props.price.fontStyle].fontWeight,
11208
+ $color: theme.typography[props.price.fontStyle].color,
10952
11209
  $lineHeight: 1,
10953
11210
  children: formatCurrency(upcomingInvoice.amountDue)
10954
11211
  }
@@ -10956,10 +11213,10 @@ var UpcomingBill = (0, import_react13.forwardRef)(({ className, ...rest }, ref)
10956
11213
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Box, { $maxWidth: "10rem", $lineHeight: "1", $textAlign: "right", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
10957
11214
  Text,
10958
11215
  {
10959
- $font: settings.theme.typography[props.contractEndDate.fontStyle].fontFamily,
10960
- $size: settings.theme.typography[props.contractEndDate.fontStyle].fontSize,
10961
- $weight: settings.theme.typography[props.contractEndDate.fontStyle].fontWeight,
10962
- $color: settings.theme.typography[props.contractEndDate.fontStyle].color,
11216
+ $font: theme.typography[props.contractEndDate.fontStyle].fontFamily,
11217
+ $size: theme.typography[props.contractEndDate.fontStyle].fontSize,
11218
+ $weight: theme.typography[props.contractEndDate.fontStyle].fontWeight,
11219
+ $color: theme.typography[props.contractEndDate.fontStyle].color,
10963
11220
  children: "Estimated monthly bill."
10964
11221
  }
10965
11222
  ) })
@@ -10984,7 +11241,8 @@ var resolveDesignProps5 = (props) => {
10984
11241
  };
10985
11242
  var PaymentMethod = (0, import_react14.forwardRef)(({ children, className, portal, ...rest }, ref) => {
10986
11243
  const props = resolveDesignProps5(rest);
10987
- const { data, settings, stripe, layout } = useEmbed();
11244
+ const theme = nt();
11245
+ const { data, stripe, layout } = useEmbed();
10988
11246
  const paymentMethod = (0, import_react14.useMemo)(() => {
10989
11247
  const { cardLast4, cardExpMonth, cardExpYear } = data.subscription?.paymentMethod || {};
10990
11248
  let monthsToExpiration;
@@ -11001,7 +11259,10 @@ var PaymentMethod = (0, import_react14.forwardRef)(({ children, className, porta
11001
11259
  monthsToExpiration
11002
11260
  };
11003
11261
  }, [data.subscription?.paymentMethod]);
11004
- if (!stripe || !data.subscription?.paymentMethod) {
11262
+ const isLightBackground = (0, import_react14.useMemo)(() => {
11263
+ return hexToHSL(theme.card.background).l > 50;
11264
+ }, [theme.card.background]);
11265
+ if (!stripe || !paymentMethod.cardLast4) {
11005
11266
  return null;
11006
11267
  }
11007
11268
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { ref, className, children: [
@@ -11015,17 +11276,17 @@ var PaymentMethod = (0, import_react14.forwardRef)(({ children, className, porta
11015
11276
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
11016
11277
  Text,
11017
11278
  {
11018
- $font: settings.theme.typography[props.header.fontStyle].fontFamily,
11019
- $size: settings.theme.typography[props.header.fontStyle].fontSize,
11020
- $weight: settings.theme.typography[props.header.fontStyle].fontWeight,
11021
- $color: settings.theme.typography[props.header.fontStyle].color,
11279
+ $font: theme.typography[props.header.fontStyle].fontFamily,
11280
+ $size: theme.typography[props.header.fontStyle].fontSize,
11281
+ $weight: theme.typography[props.header.fontStyle].fontWeight,
11282
+ $color: theme.typography[props.header.fontStyle].color,
11022
11283
  children: "Payment Method"
11023
11284
  }
11024
11285
  ),
11025
11286
  typeof paymentMethod.monthsToExpiration === "number" && Math.abs(paymentMethod.monthsToExpiration) < 4 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
11026
11287
  Text,
11027
11288
  {
11028
- $font: settings.theme.typography.text.fontFamily,
11289
+ $font: theme.typography.text.fontFamily,
11029
11290
  $size: 14,
11030
11291
  $color: "#DB6769",
11031
11292
  children: paymentMethod.monthsToExpiration > 0 ? `Expires in ${paymentMethod.monthsToExpiration} mo` : "Expired"
@@ -11040,10 +11301,10 @@ var PaymentMethod = (0, import_react14.forwardRef)(({ children, className, porta
11040
11301
  $justifyContent: "space-between",
11041
11302
  $alignItems: "center",
11042
11303
  $margin: "0 0 1rem",
11043
- $background: `${hexToHSL(settings.theme.card.background).l > 50 ? darken(settings.theme.card.background, 10) : lighten(settings.theme.card.background, 20)}`,
11304
+ $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.125)",
11044
11305
  $padding: "0.375rem 1rem",
11045
11306
  $borderRadius: "9999px",
11046
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Text, { $font: settings.theme.typography.text.fontFamily, $size: 14, children: [
11307
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Text, { $font: theme.typography.text.fontFamily, $size: 14, children: [
11047
11308
  "\u{1F4B3} Card ending in ",
11048
11309
  paymentMethod.cardLast4
11049
11310
  ] })
@@ -11290,7 +11551,7 @@ function resolveDesignProps6(props) {
11290
11551
  }
11291
11552
  var Invoices = (0, import_react15.forwardRef)(({ className, ...rest }, ref) => {
11292
11553
  const props = resolveDesignProps6(rest);
11293
- const { settings } = useEmbed();
11554
+ const theme = nt();
11294
11555
  const { invoices } = (0, import_react15.useMemo)(() => {
11295
11556
  return {
11296
11557
  invoices: [
@@ -11309,10 +11570,10 @@ var Invoices = (0, import_react15.forwardRef)(({ className, ...rest }, ref) => {
11309
11570
  props.header.isVisible && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
11310
11571
  Text,
11311
11572
  {
11312
- $font: settings.theme.typography[props.header.fontStyle].fontFamily,
11313
- $size: settings.theme.typography[props.header.fontStyle].fontSize,
11314
- $weight: settings.theme.typography[props.header.fontStyle].fontWeight,
11315
- $color: settings.theme.typography[props.header.fontStyle].color,
11573
+ $font: theme.typography[props.header.fontStyle].fontFamily,
11574
+ $size: theme.typography[props.header.fontStyle].fontSize,
11575
+ $weight: theme.typography[props.header.fontStyle].fontWeight,
11576
+ $color: theme.typography[props.header.fontStyle].color,
11316
11577
  children: "Invoices"
11317
11578
  }
11318
11579
  ) }),
@@ -11324,20 +11585,20 @@ var Invoices = (0, import_react15.forwardRef)(({ className, ...rest }, ref) => {
11324
11585
  props.date.isVisible && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
11325
11586
  Text,
11326
11587
  {
11327
- $font: settings.theme.typography[props.date.fontStyle].fontFamily,
11328
- $size: settings.theme.typography[props.date.fontStyle].fontSize,
11329
- $weight: settings.theme.typography[props.date.fontStyle].fontWeight,
11330
- $color: settings.theme.typography[props.date.fontStyle].color,
11588
+ $font: theme.typography[props.date.fontStyle].fontFamily,
11589
+ $size: theme.typography[props.date.fontStyle].fontSize,
11590
+ $weight: theme.typography[props.date.fontStyle].fontWeight,
11591
+ $color: theme.typography[props.date.fontStyle].color,
11331
11592
  children: toPrettyDate(date)
11332
11593
  }
11333
11594
  ),
11334
11595
  props.amount.isVisible && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
11335
11596
  Text,
11336
11597
  {
11337
- $font: settings.theme.typography[props.amount.fontStyle].fontFamily,
11338
- $size: settings.theme.typography[props.amount.fontStyle].fontSize,
11339
- $weight: settings.theme.typography[props.amount.fontStyle].fontWeight,
11340
- $color: settings.theme.typography[props.amount.fontStyle].color,
11598
+ $font: theme.typography[props.amount.fontStyle].fontFamily,
11599
+ $size: theme.typography[props.amount.fontStyle].fontSize,
11600
+ $weight: theme.typography[props.amount.fontStyle].fontWeight,
11601
+ $color: theme.typography[props.amount.fontStyle].color,
11341
11602
  children: [
11342
11603
  "$",
11343
11604
  amount
@@ -11351,10 +11612,10 @@ var Invoices = (0, import_react15.forwardRef)(({ className, ...rest }, ref) => {
11351
11612
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
11352
11613
  Text,
11353
11614
  {
11354
- $font: settings.theme.typography[props.collapse.fontStyle].fontFamily,
11355
- $size: settings.theme.typography[props.collapse.fontStyle].fontSize,
11356
- $weight: settings.theme.typography[props.collapse.fontStyle].fontWeight,
11357
- $color: settings.theme.typography[props.collapse.fontStyle].color,
11615
+ $font: theme.typography[props.collapse.fontStyle].fontFamily,
11616
+ $size: theme.typography[props.collapse.fontStyle].fontSize,
11617
+ $weight: theme.typography[props.collapse.fontStyle].fontWeight,
11618
+ $color: theme.typography[props.collapse.fontStyle].color,
11358
11619
  children: "See all"
11359
11620
  }
11360
11621
  )
@@ -11392,22 +11653,23 @@ var StyledViewport = dt.div`
11392
11653
  var import_jsx_runtime18 = require("react/jsx-runtime");
11393
11654
  var Viewport = (0, import_react17.forwardRef)(
11394
11655
  ({ children, ...props }, ref) => {
11395
- const { settings, layout } = useEmbed();
11656
+ const theme = nt();
11657
+ const { layout } = useEmbed();
11396
11658
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
11397
11659
  StyledViewport,
11398
11660
  {
11399
11661
  ref,
11400
- $numberOfColumns: settings.theme.numberOfColumns,
11662
+ $numberOfColumns: theme.numberOfColumns,
11401
11663
  ...props,
11402
11664
  children: layout === "disabled" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Box, { $width: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
11403
11665
  Flex,
11404
11666
  {
11405
11667
  $flexDirection: "column",
11406
- $padding: `${settings.theme.card.padding / 16}rem`,
11668
+ $padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
11407
11669
  $width: "100%",
11408
11670
  $height: "auto",
11409
- $borderRadius: `${settings.theme.card.borderRadius / 16}rem`,
11410
- $backgroundColor: settings.theme.card.background,
11671
+ $borderRadius: `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`,
11672
+ $backgroundColor: theme.card.background,
11411
11673
  $alignItems: "center",
11412
11674
  $justifyContent: "center",
11413
11675
  children: [
@@ -11415,10 +11677,10 @@ var Viewport = (0, import_react17.forwardRef)(
11415
11677
  Box,
11416
11678
  {
11417
11679
  $marginBottom: "8px",
11418
- $fontSize: `${settings.theme.typography.heading1.fontSize / 16}rem`,
11419
- $fontFamily: settings.theme.typography.heading1.fontFamily,
11420
- $fontWeight: settings.theme.typography.heading1.fontWeight,
11421
- $color: settings.theme.typography.heading1.color,
11680
+ $fontSize: `${theme.typography.heading1.fontSize / TEXT_BASE_SIZE}rem`,
11681
+ $fontFamily: theme.typography.heading1.fontFamily,
11682
+ $fontWeight: theme.typography.heading1.fontWeight,
11683
+ $color: theme.typography.heading1.color,
11422
11684
  children: "Coming soon"
11423
11685
  }
11424
11686
  ),
@@ -11426,10 +11688,10 @@ var Viewport = (0, import_react17.forwardRef)(
11426
11688
  Box,
11427
11689
  {
11428
11690
  $marginBottom: "8px",
11429
- $fontSize: `${settings.theme.typography.text.fontSize / 16}rem`,
11430
- $fontFamily: settings.theme.typography.text.fontFamily,
11431
- $fontWeight: settings.theme.typography.text.fontWeight,
11432
- $color: settings.theme.typography.text.color,
11691
+ $fontSize: `${theme.typography.text.fontSize / TEXT_BASE_SIZE}rem`,
11692
+ $fontFamily: theme.typography.text.fontFamily,
11693
+ $fontWeight: theme.typography.text.fontWeight,
11694
+ $color: theme.typography.text.color,
11433
11695
  children: "The plan manager will be back very soon."
11434
11696
  }
11435
11697
  )
@@ -11474,7 +11736,7 @@ var StyledCard = dt.div(
11474
11736
 
11475
11737
  ${() => {
11476
11738
  const { l: l2 } = hexToHSL(theme.card.background);
11477
- const borderColor = l2 > 50 ? darken(theme.card.background, 10) : lighten(theme.card.background, 20);
11739
+ const borderColor = l2 > 50 ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)";
11478
11740
  const borderRadius = `${$borderRadius / TEXT_BASE_SIZE}rem`;
11479
11741
  const boxShadow = "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A";
11480
11742
  if ($sectionLayout === "merged") {
@@ -11509,16 +11771,16 @@ var StyledCard = dt.div(
11509
11771
  var import_jsx_runtime19 = require("react/jsx-runtime");
11510
11772
  var Card = (0, import_react18.forwardRef)(
11511
11773
  ({ children, className }, ref) => {
11512
- const { settings } = useEmbed();
11774
+ const theme = nt();
11513
11775
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
11514
11776
  StyledCard,
11515
11777
  {
11516
11778
  ref,
11517
11779
  className,
11518
- $sectionLayout: settings.theme?.sectionLayout,
11519
- $borderRadius: settings.theme?.card?.borderRadius,
11520
- $padding: settings.theme?.card?.padding,
11521
- $shadow: settings.theme?.card?.hasShadow,
11780
+ $sectionLayout: theme?.sectionLayout,
11781
+ $borderRadius: theme?.card?.borderRadius,
11782
+ $padding: theme?.card?.padding,
11783
+ $shadow: theme?.card?.hasShadow,
11522
11784
  children
11523
11785
  }
11524
11786
  );
@@ -11590,78 +11852,84 @@ var spin = mt`
11590
11852
  transform: rotate(360deg);
11591
11853
  }
11592
11854
  `;
11593
- var Loader = dt.div(() => {
11594
- const { settings } = useEmbed();
11595
- return lt`
11596
- border: 4px solid rgba(0, 0, 0, 0.1);
11597
- border-top: 4px solid ${settings.theme.primary};
11598
- border-radius: 50%;
11599
- width: 40px;
11600
- height: 40px;
11601
- animation: ${spin} 1.5s linear infinite;
11602
- display: inline-block;
11603
- `;
11604
- });
11855
+ var Loader = dt.div`
11856
+ border: ${({ theme }) => `${4 / TEXT_BASE_SIZE}rem solid hsla(0, 0%, ${hexToHSL(theme.card.background).l > 50 ? 0 : 100}%, 0.1)`};
11857
+ border-top: ${4 / TEXT_BASE_SIZE}rem solid ${({ theme }) => theme.primary};
11858
+ border-radius: 50%;
11859
+ width: ${40 / TEXT_BASE_SIZE}rem;
11860
+ height: ${40 / TEXT_BASE_SIZE}rem;
11861
+ animation: ${spin} 1.5s linear infinite;
11862
+ display: inline-block;
11863
+ `;
11605
11864
 
11606
11865
  // src/components/embed/ComponentTree.tsx
11607
11866
  var import_jsx_runtime21 = require("react/jsx-runtime");
11608
- var ComponentTree = () => {
11609
- const { error, nodes, settings } = useEmbed();
11610
- const [children, setChildren] = (0, import_react21.useState)(
11611
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
11612
- Flex,
11613
- {
11614
- $width: "100%",
11615
- $height: "100%",
11616
- $alignItems: "center",
11617
- $justifyContent: "center",
11618
- $padding: `${settings.theme.card.padding / 16}rem`,
11619
- children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader, {})
11620
- }
11621
- )
11867
+ var Loading = () => {
11868
+ const theme = nt();
11869
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
11870
+ Flex,
11871
+ {
11872
+ $width: "100%",
11873
+ $height: "100%",
11874
+ $alignItems: "center",
11875
+ $justifyContent: "center",
11876
+ $padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
11877
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader, {})
11878
+ }
11622
11879
  );
11880
+ };
11881
+ var Error2 = ({ message }) => {
11882
+ const theme = nt();
11883
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
11884
+ Flex,
11885
+ {
11886
+ $flexDirection: "column",
11887
+ $padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
11888
+ $width: "100%",
11889
+ $height: "auto",
11890
+ $borderRadius: `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`,
11891
+ $backgroundColor: theme.card.background,
11892
+ $alignItems: "center",
11893
+ $justifyContent: "center",
11894
+ children: [
11895
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
11896
+ Box,
11897
+ {
11898
+ $marginBottom: `${8 / TEXT_BASE_SIZE}rem`,
11899
+ $fontSize: `${theme.typography.heading1.fontSize / TEXT_BASE_SIZE}rem`,
11900
+ $fontFamily: theme.typography.heading1.fontFamily,
11901
+ $fontWeight: theme.typography.heading1.fontWeight,
11902
+ $color: theme.typography.heading1.color,
11903
+ children: "404 Error"
11904
+ }
11905
+ ),
11906
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
11907
+ Box,
11908
+ {
11909
+ $marginBottom: `${8 / TEXT_BASE_SIZE}rem`,
11910
+ $fontSize: `${theme.typography.text.fontSize / TEXT_BASE_SIZE}rem`,
11911
+ $fontFamily: theme.typography.text.fontFamily,
11912
+ $fontWeight: theme.typography.text.fontWeight,
11913
+ $color: theme.typography.text.color,
11914
+ children: message
11915
+ }
11916
+ )
11917
+ ]
11918
+ }
11919
+ );
11920
+ };
11921
+ var ComponentTree = () => {
11922
+ const { error, nodes } = useEmbed();
11923
+ const [children, setChildren] = (0, import_react21.useState)(/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loading, {}));
11623
11924
  (0, import_react21.useEffect)(() => {
11624
11925
  const renderer = createRenderer();
11625
11926
  setChildren(nodes.map(renderer));
11626
11927
  }, [nodes]);
11627
11928
  if (error) {
11628
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
11629
- Flex,
11630
- {
11631
- $flexDirection: "column",
11632
- $padding: `${settings.theme.card.padding / 16}rem`,
11633
- $width: "100%",
11634
- $height: "auto",
11635
- $borderRadius: `${settings.theme.card.borderRadius / 16}rem`,
11636
- $backgroundColor: settings.theme.card.background,
11637
- $alignItems: "center",
11638
- $justifyContent: "center",
11639
- children: [
11640
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
11641
- Box,
11642
- {
11643
- $marginBottom: "8px",
11644
- $fontSize: `${settings.theme.typography.heading1.fontSize / 16}rem`,
11645
- $fontFamily: settings.theme.typography.heading1.fontFamily,
11646
- $fontWeight: settings.theme.typography.heading1.fontWeight,
11647
- $color: settings.theme.typography.heading1.color,
11648
- children: "404 Error"
11649
- }
11650
- ),
11651
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
11652
- Box,
11653
- {
11654
- $marginBottom: "8px",
11655
- $fontSize: `${settings.theme.typography.text.fontSize / 16}rem`,
11656
- $fontFamily: settings.theme.typography.text.fontFamily,
11657
- $fontWeight: settings.theme.typography.text.fontWeight,
11658
- $color: settings.theme.typography.text.color,
11659
- children: error.message
11660
- }
11661
- )
11662
- ]
11663
- }
11664
- );
11929
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Error2, { message: error.message });
11930
+ }
11931
+ if (import_react21.Children.count(children) === 0) {
11932
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loading, {});
11665
11933
  }
11666
11934
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children });
11667
11935
  };