@schematichq/schematic-components 0.7.14 → 0.7.16

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.
@@ -6028,16 +6028,17 @@ __export(index_exports, {
6028
6028
  useEmbed: () => useEmbed,
6029
6029
  useIsLightBackground: () => useIsLightBackground,
6030
6030
  usePrevious: () => usePrevious2,
6031
+ useRequest: () => useRequest,
6031
6032
  useTrialEnd: () => useTrialEnd,
6032
6033
  useWrapChildren: () => useWrapChildren
6033
6034
  });
6034
6035
  module.exports = __toCommonJS(index_exports);
6035
6036
 
6036
6037
  // src/components/elements/button/Button.tsx
6037
- var import_react31 = require("react");
6038
+ var import_react33 = require("react");
6038
6039
 
6039
6040
  // src/components/layout/card/Card.tsx
6040
- var import_react19 = require("react");
6041
+ var import_react21 = require("react");
6041
6042
 
6042
6043
  // node_modules/styled-components/node_modules/tslib/tslib.es6.mjs
6043
6044
  var __assign = function() {
@@ -7854,8 +7855,7 @@ var looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
7854
7855
  }
7855
7856
  return matched;
7856
7857
  };
7857
- var deepFind = function(obj, path) {
7858
- let keySeparator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
7858
+ var deepFind = (obj, path, keySeparator = ".") => {
7859
7859
  if (!obj) return void 0;
7860
7860
  if (obj[path]) {
7861
7861
  if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
@@ -7904,39 +7904,25 @@ var consoleLogger = {
7904
7904
  }
7905
7905
  };
7906
7906
  var Logger = class _Logger {
7907
- constructor(concreteLogger) {
7908
- let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
7907
+ constructor(concreteLogger, options2 = {}) {
7909
7908
  this.init(concreteLogger, options2);
7910
7909
  }
7911
- init(concreteLogger) {
7912
- let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
7910
+ init(concreteLogger, options2 = {}) {
7913
7911
  this.prefix = options2.prefix || "i18next:";
7914
7912
  this.logger = concreteLogger || consoleLogger;
7915
7913
  this.options = options2;
7916
7914
  this.debug = options2.debug;
7917
7915
  }
7918
- log() {
7919
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
7920
- args[_key] = arguments[_key];
7921
- }
7916
+ log(...args) {
7922
7917
  return this.forward(args, "log", "", true);
7923
7918
  }
7924
- warn() {
7925
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
7926
- args[_key2] = arguments[_key2];
7927
- }
7919
+ warn(...args) {
7928
7920
  return this.forward(args, "warn", "", true);
7929
7921
  }
7930
- error() {
7931
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
7932
- args[_key3] = arguments[_key3];
7933
- }
7922
+ error(...args) {
7934
7923
  return this.forward(args, "error", "");
7935
7924
  }
7936
- deprecate() {
7937
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
7938
- args[_key4] = arguments[_key4];
7939
- }
7925
+ deprecate(...args) {
7940
7926
  return this.forward(args, "warn", "WARNING DEPRECATED: ", true);
7941
7927
  }
7942
7928
  forward(args, lvl, prefix2, debugOnly) {
@@ -7979,14 +7965,10 @@ var EventEmitter = class {
7979
7965
  }
7980
7966
  this.observers[event].delete(listener);
7981
7967
  }
7982
- emit(event) {
7983
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
7984
- args[_key - 1] = arguments[_key];
7985
- }
7968
+ emit(event, ...args) {
7986
7969
  if (this.observers[event]) {
7987
7970
  const cloned = Array.from(this.observers[event].entries());
7988
- cloned.forEach((_ref) => {
7989
- let [observer, numTimesAdded] = _ref;
7971
+ cloned.forEach(([observer, numTimesAdded]) => {
7990
7972
  for (let i2 = 0; i2 < numTimesAdded; i2++) {
7991
7973
  observer(...args);
7992
7974
  }
@@ -7994,8 +7976,7 @@ var EventEmitter = class {
7994
7976
  }
7995
7977
  if (this.observers["*"]) {
7996
7978
  const cloned = Array.from(this.observers["*"].entries());
7997
- cloned.forEach((_ref2) => {
7998
- let [observer, numTimesAdded] = _ref2;
7979
+ cloned.forEach(([observer, numTimesAdded]) => {
7999
7980
  for (let i2 = 0; i2 < numTimesAdded; i2++) {
8000
7981
  observer.apply(observer, [event, ...args]);
8001
7982
  }
@@ -8004,11 +7985,10 @@ var EventEmitter = class {
8004
7985
  }
8005
7986
  };
8006
7987
  var ResourceStore = class extends EventEmitter {
8007
- constructor(data) {
8008
- let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
8009
- ns: ["translation"],
8010
- defaultNS: "translation"
8011
- };
7988
+ constructor(data, options2 = {
7989
+ ns: ["translation"],
7990
+ defaultNS: "translation"
7991
+ }) {
8012
7992
  super();
8013
7993
  this.data = data || {};
8014
7994
  this.options = options2;
@@ -8030,8 +8010,7 @@ var ResourceStore = class extends EventEmitter {
8030
8010
  this.options.ns.splice(index, 1);
8031
8011
  }
8032
8012
  }
8033
- getResource(lng, ns, key) {
8034
- let options2 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
8013
+ getResource(lng, ns, key, options2 = {}) {
8035
8014
  const keySeparator = options2.keySeparator !== void 0 ? options2.keySeparator : this.options.keySeparator;
8036
8015
  const ignoreJSONStructure = options2.ignoreJSONStructure !== void 0 ? options2.ignoreJSONStructure : this.options.ignoreJSONStructure;
8037
8016
  let path;
@@ -8058,10 +8037,9 @@ var ResourceStore = class extends EventEmitter {
8058
8037
  if (result || !ignoreJSONStructure || !isString(key)) return result;
8059
8038
  return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
8060
8039
  }
8061
- addResource(lng, ns, key, value) {
8062
- let options2 = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
8063
- silent: false
8064
- };
8040
+ addResource(lng, ns, key, value, options2 = {
8041
+ silent: false
8042
+ }) {
8065
8043
  const keySeparator = options2.keySeparator !== void 0 ? options2.keySeparator : this.options.keySeparator;
8066
8044
  let path = [lng, ns];
8067
8045
  if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
@@ -8074,10 +8052,9 @@ var ResourceStore = class extends EventEmitter {
8074
8052
  setPath(this.data, path, value);
8075
8053
  if (!options2.silent) this.emit("added", lng, ns, key, value);
8076
8054
  }
8077
- addResources(lng, ns, resources) {
8078
- let options2 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {
8079
- silent: false
8080
- };
8055
+ addResources(lng, ns, resources, options2 = {
8056
+ silent: false
8057
+ }) {
8081
8058
  for (const m2 in resources) {
8082
8059
  if (isString(resources[m2]) || Array.isArray(resources[m2])) this.addResource(lng, ns, m2, resources[m2], {
8083
8060
  silent: true
@@ -8085,11 +8062,10 @@ var ResourceStore = class extends EventEmitter {
8085
8062
  }
8086
8063
  if (!options2.silent) this.emit("added", lng, ns, resources);
8087
8064
  }
8088
- addResourceBundle(lng, ns, resources, deep, overwrite) {
8089
- let options2 = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {
8090
- silent: false,
8091
- skipCopy: false
8092
- };
8065
+ addResourceBundle(lng, ns, resources, deep, overwrite, options2 = {
8066
+ silent: false,
8067
+ skipCopy: false
8068
+ }) {
8093
8069
  let path = [lng, ns];
8094
8070
  if (lng.indexOf(".") > -1) {
8095
8071
  path = lng.split(".");
@@ -8152,8 +8128,7 @@ var postProcessor = {
8152
8128
  var checkedLoadedFor = {};
8153
8129
  var shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" && typeof res !== "number";
8154
8130
  var Translator = class _Translator extends EventEmitter {
8155
- constructor(services) {
8156
- let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8131
+ constructor(services, options2 = {}) {
8157
8132
  super();
8158
8133
  copy2(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], services, this);
8159
8134
  this.options = options2;
@@ -8165,10 +8140,9 @@ var Translator = class _Translator extends EventEmitter {
8165
8140
  changeLanguage(lng) {
8166
8141
  if (lng) this.language = lng;
8167
8142
  }
8168
- exists(key) {
8169
- let o2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
8170
- interpolation: {}
8171
- };
8143
+ exists(key, o2 = {
8144
+ interpolation: {}
8145
+ }) {
8172
8146
  const opt = {
8173
8147
  ...o2
8174
8148
  };
@@ -8220,11 +8194,12 @@ var Translator = class _Translator extends EventEmitter {
8220
8194
  namespaces
8221
8195
  } = this.extractFromKey(keys[keys.length - 1], opt);
8222
8196
  const namespace = namespaces[namespaces.length - 1];
8197
+ let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
8198
+ if (nsSeparator === void 0) nsSeparator = ":";
8223
8199
  const lng = opt.lng || this.language;
8224
8200
  const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
8225
8201
  if (lng?.toLowerCase() === "cimode") {
8226
8202
  if (appendNamespaceToCIMode) {
8227
- const nsSeparator = opt.nsSeparator || this.options.nsSeparator;
8228
8203
  if (returnDetails) {
8229
8204
  return {
8230
8205
  res: `${namespace}${nsSeparator}${key}`,
@@ -8379,9 +8354,11 @@ var Translator = class _Translator extends EventEmitter {
8379
8354
  }
8380
8355
  }
8381
8356
  res = this.extendTranslation(res, keys, opt, resolved, lastKey);
8382
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
8357
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) {
8358
+ res = `${namespace}${nsSeparator}${key}`;
8359
+ }
8383
8360
  if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
8384
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : void 0, opt);
8361
+ res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : void 0, opt);
8385
8362
  }
8386
8363
  }
8387
8364
  if (returnDetails) {
@@ -8392,7 +8369,6 @@ var Translator = class _Translator extends EventEmitter {
8392
8369
  return res;
8393
8370
  }
8394
8371
  extendTranslation(res, key, opt, resolved, lastKey) {
8395
- var _this = this;
8396
8372
  if (this.i18nFormat?.parse) {
8397
8373
  res = this.i18nFormat.parse(res, {
8398
8374
  ...this.options.interpolation.defaultVariables,
@@ -8428,15 +8404,12 @@ var Translator = class _Translator extends EventEmitter {
8428
8404
  if (nestBef < nestAft) opt.nest = false;
8429
8405
  }
8430
8406
  if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
8431
- if (opt.nest !== false) res = this.interpolator.nest(res, function() {
8432
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8433
- args[_key] = arguments[_key];
8434
- }
8407
+ if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
8435
8408
  if (lastKey?.[0] === args[0] && !opt.context) {
8436
- _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
8409
+ this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
8437
8410
  return null;
8438
8411
  }
8439
- return _this.translate(...args, key);
8412
+ return this.translate(...args, key);
8440
8413
  }, opt);
8441
8414
  if (opt.interpolation) this.interpolator.reset();
8442
8415
  }
@@ -8453,8 +8426,7 @@ var Translator = class _Translator extends EventEmitter {
8453
8426
  }
8454
8427
  return res;
8455
8428
  }
8456
- resolve(keys) {
8457
- let opt = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8429
+ resolve(keys, opt = {}) {
8458
8430
  let found;
8459
8431
  let usedKey;
8460
8432
  let exactUsedKey;
@@ -8534,13 +8506,11 @@ var Translator = class _Translator extends EventEmitter {
8534
8506
  isValidLookup(res) {
8535
8507
  return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
8536
8508
  }
8537
- getResource(code, ns, key) {
8538
- let options2 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
8509
+ getResource(code, ns, key, options2 = {}) {
8539
8510
  if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options2);
8540
8511
  return this.resourceStore.getResource(code, ns, key, options2);
8541
8512
  }
8542
- getUsedParamsDetails() {
8543
- let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8513
+ getUsedParamsDetails(options2 = {}) {
8544
8514
  const optionsKeys = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"];
8545
8515
  const useOptionsReplaceForData = options2.replace && !isString(options2.replace);
8546
8516
  let data = useOptionsReplaceForData ? options2.replace : options2;
@@ -8696,8 +8666,7 @@ var dummyRule = {
8696
8666
  })
8697
8667
  };
8698
8668
  var PluralResolver = class {
8699
- constructor(languageUtils) {
8700
- let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8669
+ constructor(languageUtils, options2 = {}) {
8701
8670
  this.languageUtils = languageUtils;
8702
8671
  this.options = options2;
8703
8672
  this.logger = baseLogger.create("pluralResolver");
@@ -8709,8 +8678,7 @@ var PluralResolver = class {
8709
8678
  clearCache() {
8710
8679
  this.pluralRulesCache = {};
8711
8680
  }
8712
- getRule(code) {
8713
- let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8681
+ getRule(code, options2 = {}) {
8714
8682
  const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
8715
8683
  const type = options2.ordinal ? "ordinal" : "cardinal";
8716
8684
  const cacheKey = JSON.stringify({
@@ -8737,25 +8705,21 @@ var PluralResolver = class {
8737
8705
  this.pluralRulesCache[cacheKey] = rule;
8738
8706
  return rule;
8739
8707
  }
8740
- needsPlural(code) {
8741
- let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8708
+ needsPlural(code, options2 = {}) {
8742
8709
  let rule = this.getRule(code, options2);
8743
8710
  if (!rule) rule = this.getRule("dev", options2);
8744
8711
  return rule?.resolvedOptions().pluralCategories.length > 1;
8745
8712
  }
8746
- getPluralFormsOfKey(code, key) {
8747
- let options2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
8713
+ getPluralFormsOfKey(code, key, options2 = {}) {
8748
8714
  return this.getSuffixes(code, options2).map((suffix) => `${key}${suffix}`);
8749
8715
  }
8750
- getSuffixes(code) {
8751
- let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8716
+ getSuffixes(code, options2 = {}) {
8752
8717
  let rule = this.getRule(code, options2);
8753
8718
  if (!rule) rule = this.getRule("dev", options2);
8754
8719
  if (!rule) return [];
8755
8720
  return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options2.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
8756
8721
  }
8757
- getSuffix(code, count) {
8758
- let options2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
8722
+ getSuffix(code, count, options2 = {}) {
8759
8723
  const rule = this.getRule(code, options2);
8760
8724
  if (rule) {
8761
8725
  return `${this.options.prepend}${options2.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
@@ -8764,9 +8728,7 @@ var PluralResolver = class {
8764
8728
  return this.getSuffix("dev", count, options2);
8765
8729
  }
8766
8730
  };
8767
- var deepFindWithDefaults = function(data, defaultData, key) {
8768
- let keySeparator = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".";
8769
- let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : true;
8731
+ var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJSONStructure = true) => {
8770
8732
  let path = getPathWithDefaults(data, defaultData, key);
8771
8733
  if (!path && ignoreJSONStructure && isString(key)) {
8772
8734
  path = deepFind(data, key, keySeparator);
@@ -8776,15 +8738,13 @@ var deepFindWithDefaults = function(data, defaultData, key) {
8776
8738
  };
8777
8739
  var regexSafe = (val) => val.replace(/\$/g, "$$$$");
8778
8740
  var Interpolator = class {
8779
- constructor() {
8780
- let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8741
+ constructor(options2 = {}) {
8781
8742
  this.logger = baseLogger.create("interpolator");
8782
8743
  this.options = options2;
8783
8744
  this.format = options2?.interpolation?.format || ((value) => value);
8784
8745
  this.init(options2);
8785
8746
  }
8786
- init() {
8787
- let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8747
+ init(options2 = {}) {
8788
8748
  if (!options2.interpolation) options2.interpolation = {
8789
8749
  escapeValue: true
8790
8750
  };
@@ -8907,8 +8867,7 @@ var Interpolator = class {
8907
8867
  });
8908
8868
  return str;
8909
8869
  }
8910
- nest(str, fc) {
8911
- let options2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
8870
+ nest(str, fc, options2 = {}) {
8912
8871
  let match2;
8913
8872
  let value;
8914
8873
  let clonedOptions;
@@ -9004,68 +8963,68 @@ var parseFormatStr = (formatStr) => {
9004
8963
  };
9005
8964
  var createCachedFormatter = (fn) => {
9006
8965
  const cache = {};
9007
- return (val, lng, options2) => {
9008
- let optForCache = options2;
9009
- if (options2 && options2.interpolationkey && options2.formatParams && options2.formatParams[options2.interpolationkey] && options2[options2.interpolationkey]) {
8966
+ return (v2, l2, o2) => {
8967
+ let optForCache = o2;
8968
+ if (o2 && o2.interpolationkey && o2.formatParams && o2.formatParams[o2.interpolationkey] && o2[o2.interpolationkey]) {
9010
8969
  optForCache = {
9011
8970
  ...optForCache,
9012
- [options2.interpolationkey]: void 0
8971
+ [o2.interpolationkey]: void 0
9013
8972
  };
9014
8973
  }
9015
- const key = lng + JSON.stringify(optForCache);
9016
- let formatter = cache[key];
9017
- if (!formatter) {
9018
- formatter = fn(getCleanedCode(lng), options2);
9019
- cache[key] = formatter;
8974
+ const key = l2 + JSON.stringify(optForCache);
8975
+ let frm = cache[key];
8976
+ if (!frm) {
8977
+ frm = fn(getCleanedCode(l2), o2);
8978
+ cache[key] = frm;
9020
8979
  }
9021
- return formatter(val);
8980
+ return frm(v2);
9022
8981
  };
9023
8982
  };
8983
+ var createNonCachedFormatter = (fn) => (v2, l2, o2) => fn(getCleanedCode(l2), o2)(v2);
9024
8984
  var Formatter = class {
9025
- constructor() {
9026
- let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8985
+ constructor(options2 = {}) {
9027
8986
  this.logger = baseLogger.create("formatter");
9028
8987
  this.options = options2;
8988
+ this.init(options2);
8989
+ }
8990
+ init(services, options2 = {
8991
+ interpolation: {}
8992
+ }) {
8993
+ this.formatSeparator = options2.interpolation.formatSeparator || ",";
8994
+ const cf = options2.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
9029
8995
  this.formats = {
9030
- number: createCachedFormatter((lng, opt) => {
8996
+ number: cf((lng, opt) => {
9031
8997
  const formatter = new Intl.NumberFormat(lng, {
9032
8998
  ...opt
9033
8999
  });
9034
9000
  return (val) => formatter.format(val);
9035
9001
  }),
9036
- currency: createCachedFormatter((lng, opt) => {
9002
+ currency: cf((lng, opt) => {
9037
9003
  const formatter = new Intl.NumberFormat(lng, {
9038
9004
  ...opt,
9039
9005
  style: "currency"
9040
9006
  });
9041
9007
  return (val) => formatter.format(val);
9042
9008
  }),
9043
- datetime: createCachedFormatter((lng, opt) => {
9009
+ datetime: cf((lng, opt) => {
9044
9010
  const formatter = new Intl.DateTimeFormat(lng, {
9045
9011
  ...opt
9046
9012
  });
9047
9013
  return (val) => formatter.format(val);
9048
9014
  }),
9049
- relativetime: createCachedFormatter((lng, opt) => {
9015
+ relativetime: cf((lng, opt) => {
9050
9016
  const formatter = new Intl.RelativeTimeFormat(lng, {
9051
9017
  ...opt
9052
9018
  });
9053
9019
  return (val) => formatter.format(val, opt.range || "day");
9054
9020
  }),
9055
- list: createCachedFormatter((lng, opt) => {
9021
+ list: cf((lng, opt) => {
9056
9022
  const formatter = new Intl.ListFormat(lng, {
9057
9023
  ...opt
9058
9024
  });
9059
9025
  return (val) => formatter.format(val);
9060
9026
  })
9061
9027
  };
9062
- this.init(options2);
9063
- }
9064
- init(services) {
9065
- let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
9066
- interpolation: {}
9067
- };
9068
- this.formatSeparator = options2.interpolation.formatSeparator || ",";
9069
9028
  }
9070
9029
  add(name, fc) {
9071
9030
  this.formats[name.toLowerCase().trim()] = fc;
@@ -9073,8 +9032,7 @@ var Formatter = class {
9073
9032
  addCached(name, fc) {
9074
9033
  this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
9075
9034
  }
9076
- format(value, format, lng) {
9077
- let options2 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
9035
+ format(value, format, lng, options2 = {}) {
9078
9036
  const formats = format.split(this.formatSeparator);
9079
9037
  if (formats.length > 1 && formats[0].indexOf("(") > 1 && formats[0].indexOf(")") < 0 && formats.find((f2) => f2.indexOf(")") > -1)) {
9080
9038
  const lastIndex = formats.findIndex((f2) => f2.indexOf(")") > -1);
@@ -9114,8 +9072,7 @@ var removePending = (q2, name) => {
9114
9072
  }
9115
9073
  };
9116
9074
  var Connector = class extends EventEmitter {
9117
- constructor(backend, store, services) {
9118
- let options2 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
9075
+ constructor(backend, store, services, options2 = {}) {
9119
9076
  super();
9120
9077
  this.backend = backend;
9121
9078
  this.store = store;
@@ -9210,10 +9167,7 @@ var Connector = class extends EventEmitter {
9210
9167
  this.emit("loaded", loaded);
9211
9168
  this.queue = this.queue.filter((q2) => !q2.done);
9212
9169
  }
9213
- read(lng, ns, fcName) {
9214
- let tried = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
9215
- let wait = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : this.retryTimeout;
9216
- let callback = arguments.length > 5 ? arguments[5] : void 0;
9170
+ read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
9217
9171
  if (!lng.length) return callback(null, {});
9218
9172
  if (this.readingCalls >= this.maxParallelReads) {
9219
9173
  this.waitingReads.push({
@@ -9257,9 +9211,7 @@ var Connector = class extends EventEmitter {
9257
9211
  }
9258
9212
  return fc(lng, ns, resolver);
9259
9213
  }
9260
- prepareLoading(languages, namespaces) {
9261
- let options2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
9262
- let callback = arguments.length > 3 ? arguments[3] : void 0;
9214
+ prepareLoading(languages, namespaces, options2 = {}, callback) {
9263
9215
  if (!this.backend) {
9264
9216
  this.logger.warn("No backend was added via i18next.use. Will not load resources.");
9265
9217
  return callback && callback();
@@ -9283,8 +9235,7 @@ var Connector = class extends EventEmitter {
9283
9235
  reload: true
9284
9236
  }, callback);
9285
9237
  }
9286
- loadOne(name) {
9287
- let prefix2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
9238
+ loadOne(name, prefix2 = "") {
9288
9239
  const s2 = name.split("|");
9289
9240
  const lng = s2[0];
9290
9241
  const ns = s2[1];
@@ -9294,10 +9245,8 @@ var Connector = class extends EventEmitter {
9294
9245
  this.loaded(name, err2, data);
9295
9246
  });
9296
9247
  }
9297
- saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
9298
- let options2 = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {};
9299
- let clb = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : () => {
9300
- };
9248
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate, options2 = {}, clb = () => {
9249
+ }) {
9301
9250
  if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
9302
9251
  this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
9303
9252
  return;
@@ -9391,7 +9340,8 @@ var get = () => ({
9391
9340
  nestingOptionsSeparator: ",",
9392
9341
  maxReplaces: 1e3,
9393
9342
  skipOnVariables: true
9394
- }
9343
+ },
9344
+ cacheInBuiltFormats: true
9395
9345
  });
9396
9346
  var transformOptions = (options2) => {
9397
9347
  if (isString(options2.ns)) options2.ns = [options2.ns];
@@ -9414,9 +9364,7 @@ var bindMemberFunctions = (inst) => {
9414
9364
  });
9415
9365
  };
9416
9366
  var I18n = class _I18n extends EventEmitter {
9417
- constructor() {
9418
- let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
9419
- let callback = arguments.length > 1 ? arguments[1] : void 0;
9367
+ constructor(options2 = {}, callback) {
9420
9368
  super();
9421
9369
  this.options = transformOptions(options2);
9422
9370
  this.services = {};
@@ -9435,10 +9383,7 @@ var I18n = class _I18n extends EventEmitter {
9435
9383
  }, 0);
9436
9384
  }
9437
9385
  }
9438
- init() {
9439
- var _this = this;
9440
- let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
9441
- let callback = arguments.length > 1 ? arguments[1] : void 0;
9386
+ init(options2 = {}, callback) {
9442
9387
  this.isInitializing = true;
9443
9388
  if (typeof options2 === "function") {
9444
9389
  callback = options2;
@@ -9504,11 +9449,8 @@ var I18n = class _I18n extends EventEmitter {
9504
9449
  hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
9505
9450
  };
9506
9451
  s2.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s2.resourceStore, s2, this.options);
9507
- s2.backendConnector.on("*", function(event) {
9508
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
9509
- args[_key - 1] = arguments[_key];
9510
- }
9511
- _this.emit(event, ...args);
9452
+ s2.backendConnector.on("*", (event, ...args) => {
9453
+ this.emit(event, ...args);
9512
9454
  });
9513
9455
  if (this.modules.languageDetector) {
9514
9456
  s2.languageDetector = createClassOnDemand(this.modules.languageDetector);
@@ -9519,11 +9461,8 @@ var I18n = class _I18n extends EventEmitter {
9519
9461
  if (s2.i18nFormat.init) s2.i18nFormat.init(this);
9520
9462
  }
9521
9463
  this.translator = new Translator(this.services, this.options);
9522
- this.translator.on("*", function(event) {
9523
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
9524
- args[_key2 - 1] = arguments[_key2];
9525
- }
9526
- _this.emit(event, ...args);
9464
+ this.translator.on("*", (event, ...args) => {
9465
+ this.emit(event, ...args);
9527
9466
  });
9528
9467
  this.modules.external.forEach((m2) => {
9529
9468
  if (m2.init) m2.init(this);
@@ -9540,15 +9479,13 @@ var I18n = class _I18n extends EventEmitter {
9540
9479
  }
9541
9480
  const storeApi = ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"];
9542
9481
  storeApi.forEach((fcName) => {
9543
- this[fcName] = function() {
9544
- return _this.store[fcName](...arguments);
9545
- };
9482
+ this[fcName] = (...args) => this.store[fcName](...args);
9546
9483
  });
9547
9484
  const storeApiChained = ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"];
9548
9485
  storeApiChained.forEach((fcName) => {
9549
- this[fcName] = function() {
9550
- _this.store[fcName](...arguments);
9551
- return _this;
9486
+ this[fcName] = (...args) => {
9487
+ this.store[fcName](...args);
9488
+ return this;
9552
9489
  };
9553
9490
  });
9554
9491
  const deferred = defer();
@@ -9572,8 +9509,7 @@ var I18n = class _I18n extends EventEmitter {
9572
9509
  }
9573
9510
  return deferred;
9574
9511
  }
9575
- loadResources(language) {
9576
- let callback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
9512
+ loadResources(language, callback = noop) {
9577
9513
  let usedCallback = callback;
9578
9514
  const usedLng = isString(language) ? language : this.language;
9579
9515
  if (typeof language === "function") usedCallback = language;
@@ -9666,7 +9602,6 @@ var I18n = class _I18n extends EventEmitter {
9666
9602
  }
9667
9603
  }
9668
9604
  changeLanguage(lng, callback) {
9669
- var _this2 = this;
9670
9605
  this.isLanguageChangingTo = lng;
9671
9606
  const deferred = defer();
9672
9607
  this.emit("languageChanging", lng);
@@ -9688,12 +9623,8 @@ var I18n = class _I18n extends EventEmitter {
9688
9623
  } else {
9689
9624
  this.isLanguageChangingTo = void 0;
9690
9625
  }
9691
- deferred.resolve(function() {
9692
- return _this2.t(...arguments);
9693
- });
9694
- if (callback) callback(err2, function() {
9695
- return _this2.t(...arguments);
9696
- });
9626
+ deferred.resolve((...args) => this.t(...args));
9627
+ if (callback) callback(err2, (...args) => this.t(...args));
9697
9628
  };
9698
9629
  const setLng = (lngs) => {
9699
9630
  if (!lng && !lngs && this.services.languageDetector) lngs = [];
@@ -9724,14 +9655,10 @@ var I18n = class _I18n extends EventEmitter {
9724
9655
  return deferred;
9725
9656
  }
9726
9657
  getFixedT(lng, ns, keyPrefix) {
9727
- var _this3 = this;
9728
- const fixedT = function(key, opts) {
9658
+ const fixedT = (key, opts, ...rest) => {
9729
9659
  let o2;
9730
9660
  if (typeof opts !== "object") {
9731
- for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
9732
- rest[_key3 - 2] = arguments[_key3];
9733
- }
9734
- o2 = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
9661
+ o2 = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
9735
9662
  } else {
9736
9663
  o2 = {
9737
9664
  ...opts
@@ -9741,14 +9668,14 @@ var I18n = class _I18n extends EventEmitter {
9741
9668
  o2.lngs = o2.lngs || fixedT.lngs;
9742
9669
  o2.ns = o2.ns || fixedT.ns;
9743
9670
  if (o2.keyPrefix !== "") o2.keyPrefix = o2.keyPrefix || keyPrefix || fixedT.keyPrefix;
9744
- const keySeparator = _this3.options.keySeparator || ".";
9671
+ const keySeparator = this.options.keySeparator || ".";
9745
9672
  let resultKey;
9746
9673
  if (o2.keyPrefix && Array.isArray(key)) {
9747
9674
  resultKey = key.map((k2) => `${o2.keyPrefix}${keySeparator}${k2}`);
9748
9675
  } else {
9749
9676
  resultKey = o2.keyPrefix ? `${o2.keyPrefix}${keySeparator}${key}` : key;
9750
9677
  }
9751
- return _this3.t(resultKey, o2);
9678
+ return this.t(resultKey, o2);
9752
9679
  };
9753
9680
  if (isString(lng)) {
9754
9681
  fixedT.lng = lng;
@@ -9759,23 +9686,16 @@ var I18n = class _I18n extends EventEmitter {
9759
9686
  fixedT.keyPrefix = keyPrefix;
9760
9687
  return fixedT;
9761
9688
  }
9762
- t() {
9763
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
9764
- args[_key4] = arguments[_key4];
9765
- }
9689
+ t(...args) {
9766
9690
  return this.translator?.translate(...args);
9767
9691
  }
9768
- exists() {
9769
- for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
9770
- args[_key5] = arguments[_key5];
9771
- }
9692
+ exists(...args) {
9772
9693
  return this.translator?.exists(...args);
9773
9694
  }
9774
9695
  setDefaultNamespace(ns) {
9775
9696
  this.options.defaultNS = ns;
9776
9697
  }
9777
- hasLoadedNamespace(ns) {
9778
- let options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
9698
+ hasLoadedNamespace(ns, options2 = {}) {
9779
9699
  if (!this.isInitialized) {
9780
9700
  this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
9781
9701
  return false;
@@ -9840,14 +9760,10 @@ var I18n = class _I18n extends EventEmitter {
9840
9760
  const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
9841
9761
  return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
9842
9762
  }
9843
- static createInstance() {
9844
- let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
9845
- let callback = arguments.length > 1 ? arguments[1] : void 0;
9763
+ static createInstance(options2 = {}, callback) {
9846
9764
  return new _I18n(options2, callback);
9847
9765
  }
9848
- cloneInstance() {
9849
- let options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
9850
- let callback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
9766
+ cloneInstance(options2 = {}, callback = noop) {
9851
9767
  const forkResourceStore = options2.forkResourceStore;
9852
9768
  if (forkResourceStore) delete options2.forkResourceStore;
9853
9769
  const mergedOptions = {
@@ -9888,10 +9804,7 @@ var I18n = class _I18n extends EventEmitter {
9888
9804
  clone.services.resourceStore = clone.store;
9889
9805
  }
9890
9806
  clone.translator = new Translator(clone.services, mergedOptions);
9891
- clone.translator.on("*", function(event) {
9892
- for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
9893
- args[_key6 - 1] = arguments[_key6];
9894
- }
9807
+ clone.translator.on("*", (event, ...args) => {
9895
9808
  clone.emit(event, ...args);
9896
9809
  });
9897
9810
  clone.init(mergedOptions, callback);
@@ -15554,6 +15467,7 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
15554
15467
  chargeType: json["charge_type"],
15555
15468
  companyCanTrial: json["company_can_trial"],
15556
15469
  companyCount: json["company_count"],
15470
+ controlledBy: json["controlled_by"],
15557
15471
  createdAt: new Date(json["created_at"]),
15558
15472
  current: json["current"],
15559
15473
  custom: json["custom"],
@@ -15639,6 +15553,7 @@ function PlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
15639
15553
  billingProduct: json["billing_product"] == null ? void 0 : BillingProductDetailResponseDataFromJSON(json["billing_product"]),
15640
15554
  chargeType: json["charge_type"],
15641
15555
  companyCount: json["company_count"],
15556
+ controlledBy: json["controlled_by"],
15642
15557
  createdAt: new Date(json["created_at"]),
15643
15558
  description: json["description"],
15644
15559
  features: json["features"].map(
@@ -15785,31 +15700,45 @@ function ComponentHydrateResponseDataFromJSONTyped(json, ignoreDiscriminator) {
15785
15700
  };
15786
15701
  }
15787
15702
 
15788
- // src/api/checkoutexternal/models/DeletePaymentMethodResponse.ts
15789
- function DeletePaymentMethodResponseFromJSON(json) {
15790
- return DeletePaymentMethodResponseFromJSONTyped(json, false);
15703
+ // src/api/checkoutexternal/models/SetupIntentResponseData.ts
15704
+ function SetupIntentResponseDataFromJSON(json) {
15705
+ return SetupIntentResponseDataFromJSONTyped(json, false);
15791
15706
  }
15792
- function DeletePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
15707
+ function SetupIntentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
15793
15708
  if (json == null) {
15794
15709
  return json;
15795
15710
  }
15796
15711
  return {
15797
- data: DeleteResponseFromJSON(json["data"]),
15712
+ publishableKey: json["publishable_key"],
15713
+ setupIntentClientSecret: json["setup_intent_client_secret"] == null ? void 0 : json["setup_intent_client_secret"]
15714
+ };
15715
+ }
15716
+
15717
+ // src/api/checkoutexternal/models/CreateSetupIntentResponse.ts
15718
+ function CreateSetupIntentResponseFromJSON(json) {
15719
+ return CreateSetupIntentResponseFromJSONTyped(json, false);
15720
+ }
15721
+ function CreateSetupIntentResponseFromJSONTyped(json, ignoreDiscriminator) {
15722
+ if (json == null) {
15723
+ return json;
15724
+ }
15725
+ return {
15726
+ data: SetupIntentResponseDataFromJSON(json["data"]),
15798
15727
  params: json["params"]
15799
15728
  };
15800
15729
  }
15801
15730
 
15802
- // src/api/checkoutexternal/models/SetupIntentResponseData.ts
15803
- function SetupIntentResponseDataFromJSON(json) {
15804
- return SetupIntentResponseDataFromJSONTyped(json, false);
15731
+ // src/api/checkoutexternal/models/DeletePaymentMethodResponse.ts
15732
+ function DeletePaymentMethodResponseFromJSON(json) {
15733
+ return DeletePaymentMethodResponseFromJSONTyped(json, false);
15805
15734
  }
15806
- function SetupIntentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
15735
+ function DeletePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
15807
15736
  if (json == null) {
15808
15737
  return json;
15809
15738
  }
15810
15739
  return {
15811
- publishableKey: json["publishable_key"],
15812
- setupIntentClientSecret: json["setup_intent_client_secret"] == null ? void 0 : json["setup_intent_client_secret"]
15740
+ data: DeleteResponseFromJSON(json["data"]),
15741
+ params: json["params"]
15813
15742
  };
15814
15743
  }
15815
15744
 
@@ -16059,6 +15988,38 @@ var CheckoutexternalApi = class extends BaseAPI {
16059
15988
  const response = await this.checkoutUnsubscribeRaw(initOverrides);
16060
15989
  return await response.value();
16061
15990
  }
15991
+ /**
15992
+ * Create setup intent
15993
+ */
15994
+ async createSetupIntentRaw(initOverrides) {
15995
+ const queryParameters = {};
15996
+ const headerParameters = {};
15997
+ if (this.configuration && this.configuration.apiKey) {
15998
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
15999
+ "X-Schematic-Api-Key"
16000
+ );
16001
+ }
16002
+ const response = await this.request(
16003
+ {
16004
+ path: `/components/setup-intent`,
16005
+ method: "POST",
16006
+ headers: headerParameters,
16007
+ query: queryParameters
16008
+ },
16009
+ initOverrides
16010
+ );
16011
+ return new JSONApiResponse(
16012
+ response,
16013
+ (jsonValue) => CreateSetupIntentResponseFromJSON(jsonValue)
16014
+ );
16015
+ }
16016
+ /**
16017
+ * Create setup intent
16018
+ */
16019
+ async createSetupIntent(initOverrides) {
16020
+ const response = await this.createSetupIntentRaw(initOverrides);
16021
+ return await response.value();
16022
+ }
16062
16023
  /**
16063
16024
  * Delete payment method
16064
16025
  */
@@ -16381,6 +16342,7 @@ var en_default = {
16381
16342
  "After the trial, cancel no default": "After the trial, you will be lose access to {{planName}} plan and your subscription will be cancelled.",
16382
16343
  "After the trial, cancel": "After the trial, you will be downgraded to the {{defaultPlanName}} plan and your subscription will be cancelled.",
16383
16344
  "After the trial, subscribe": "After the trial, subscription starts and you will be billed.",
16345
+ "Amount off": "{{amount}} off",
16384
16346
  Billed: "Billed {{period}}",
16385
16347
  "billing period": "billing period",
16386
16348
  "Cancel subscription": "Cancel subscription",
@@ -16422,8 +16384,10 @@ var en_default = {
16422
16384
  "Manage plan": "Manage plan",
16423
16385
  Monthly: "Monthly",
16424
16386
  Next: "Next",
16387
+ "No invoices created yet": "No invoices created yet",
16425
16388
  "No limit": "No limit",
16426
16389
  "No payment method added yet": "No payment method added yet",
16390
+ "No upcoming invoice": "No upcoming invoice",
16427
16391
  "Not ready to cancel?": "Not ready to cancel?",
16428
16392
  "On demand": "On demand",
16429
16393
  "One time ": "One time",
@@ -16460,11 +16424,13 @@ var en_default = {
16460
16424
  "Subscription canceled": "Subscription canceled",
16461
16425
  Subscription: "Subscription",
16462
16426
  "Talk to support": "Talk to support",
16427
+ "There was a problem retrieving your upcoming invoice.": "There was a problem retrieving your upcoming invoice.",
16463
16428
  Total: "Total",
16464
16429
  "Trial ends in": "Trial ends in {{days}} days",
16465
16430
  "Trial in progress": "Trial in progress",
16466
16431
  "Trial selected": "Trial selected",
16467
16432
  Trial: "Trial",
16433
+ "Try again": "Try again",
16468
16434
  Unlimited: "Unlimited {{item}}",
16469
16435
  "Unsubscribe failed": "Unsubscribe failed",
16470
16436
  Unsubscribe: "Unsubscribe",
@@ -17158,7 +17124,7 @@ var EmbedProvider = ({
17158
17124
  (0, import_react11.useEffect)(() => {
17159
17125
  if (accessToken) {
17160
17126
  const { headers = {} } = apiConfig ?? {};
17161
- headers["X-Schematic-Components-Version"] = "0.7.14";
17127
+ headers["X-Schematic-Components-Version"] = "0.7.16";
17162
17128
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
17163
17129
  const config = new Configuration({
17164
17130
  ...apiConfig,
@@ -17238,6 +17204,36 @@ function usePrevious2(value) {
17238
17204
  return ref.current;
17239
17205
  }
17240
17206
 
17207
+ // src/hooks/useRequest.ts
17208
+ var import_react15 = require("react");
17209
+ function useRequest(fn) {
17210
+ const [isLoading, setIsLoading] = (0, import_react15.useState)(false);
17211
+ const [error, setError] = (0, import_react15.useState)(null);
17212
+ const [data, setData] = (0, import_react15.useState)(void 0);
17213
+ const request = (0, import_react15.useCallback)(async () => {
17214
+ try {
17215
+ setError(null);
17216
+ setIsLoading(true);
17217
+ const response = await fn();
17218
+ if (!response) {
17219
+ return;
17220
+ }
17221
+ setData(response.data);
17222
+ } catch (e2) {
17223
+ if (e2 instanceof Error) {
17224
+ setError(e2);
17225
+ }
17226
+ } finally {
17227
+ setIsLoading(false);
17228
+ }
17229
+ }, [fn]);
17230
+ const value = (0, import_react15.useMemo)(() => {
17231
+ const state = { isLoading, error, data };
17232
+ return [state, request];
17233
+ }, [isLoading, error, data, request]);
17234
+ return value;
17235
+ }
17236
+
17241
17237
  // src/hooks/useTrialEnd.ts
17242
17238
  function useTrialEnd() {
17243
17239
  const { data } = useEmbed();
@@ -17253,12 +17249,12 @@ function useTrialEnd() {
17253
17249
  }
17254
17250
 
17255
17251
  // src/hooks/useWrapChildren.ts
17256
- var import_react15 = require("react");
17252
+ var import_react16 = require("react");
17257
17253
  function useWrapChildren(elements) {
17258
- const [shouldWrap, setShouldWrap] = (0, import_react15.useState)(
17254
+ const [shouldWrap, setShouldWrap] = (0, import_react16.useState)(
17259
17255
  () => new Array(elements.length).fill(false)
17260
17256
  );
17261
- (0, import_react15.useLayoutEffect)(() => {
17257
+ (0, import_react16.useLayoutEffect)(() => {
17262
17258
  const rowShouldWrap = (parent) => [...parent.children].some(
17263
17259
  (el) => el instanceof HTMLElement && el.previousElementSibling instanceof HTMLElement && el.offsetLeft <= el.previousElementSibling.offsetLeft
17264
17260
  );
@@ -17285,7 +17281,7 @@ var Box = dt.div((props) => {
17285
17281
  function reducer(acc, [key, value]) {
17286
17282
  if (key.startsWith("$") && !["$viewport"].includes(key)) {
17287
17283
  acc.push(
17288
- // keys will always be CSS properties
17284
+ // keys should always be CSS properties
17289
17285
  attr(camelToHyphen(key.slice(1)), value)
17290
17286
  );
17291
17287
  }
@@ -17295,11 +17291,11 @@ var Box = dt.div((props) => {
17295
17291
  for (const [key, value] of Object.entries(props.$viewport || {})) {
17296
17292
  styles.push(lt`
17297
17293
  ${{
17298
- sm: "@media (min-width: 640px)",
17299
- md: "@media (min-width: 768px)",
17300
- lg: "@media (min-width: 1024px)",
17301
- xl: "@media (min-width: 1280px)",
17302
- "2xl": "@media (min-width: 1536px)"
17294
+ sm: "@container (min-width: 640px)",
17295
+ md: "@container (min-width: 768px)",
17296
+ lg: "@container (min-width: 1024px)",
17297
+ xl: "@container (min-width: 1280px)",
17298
+ "2xl": "@container (min-width: 1536px)"
17303
17299
  }[key] || key} {
17304
17300
  ${Object.entries(value || {}).reduce(reducer, [])}
17305
17301
  }
@@ -17452,7 +17448,7 @@ var Button = dt.button(
17452
17448
  $isLoading = false,
17453
17449
  $alignment = "center",
17454
17450
  $selfAlignment = "center",
17455
- $fullWidth = true,
17451
+ $fullWidth = false,
17456
17452
  disabled,
17457
17453
  theme
17458
17454
  }) => {
@@ -17495,7 +17491,7 @@ var Button = dt.button(
17495
17491
  return lt`
17496
17492
  color: ${textColor};
17497
17493
 
17498
- ${Icon} {
17494
+ ${Text}, ${Icon} {
17499
17495
  color: ${textColor};
17500
17496
  }
17501
17497
  `;
@@ -17514,7 +17510,7 @@ var Button = dt.button(
17514
17510
  border-color: ${color};
17515
17511
  color: ${color};
17516
17512
 
17517
- ${Icon} {
17513
+ ${Text}, ${Icon} {
17518
17514
  color: ${color};
17519
17515
  }
17520
17516
  `;
@@ -17525,7 +17521,7 @@ var Button = dt.button(
17525
17521
  border-color: ${l2 > 50 ? darken(theme.card.background, 0.2) : lighten(theme.card.background, 0.2)};
17526
17522
  color: ${color};
17527
17523
 
17528
- ${Icon} {
17524
+ ${Text}, ${Icon} {
17529
17525
  color: ${color};
17530
17526
  }
17531
17527
  `;
@@ -17540,7 +17536,7 @@ var Button = dt.button(
17540
17536
  text-decoration: underline;
17541
17537
  }
17542
17538
 
17543
- ${Icon} {
17539
+ ${Text}, ${Icon} {
17544
17540
  color: ${color};
17545
17541
  }
17546
17542
  `;
@@ -17581,7 +17577,7 @@ var Button = dt.button(
17581
17577
  border-color: ${color};
17582
17578
  color: ${textColor};
17583
17579
 
17584
- ${Icon} {
17580
+ ${Text}, ${Icon} {
17585
17581
  color: ${textColor};
17586
17582
  }
17587
17583
  `;
@@ -17913,7 +17909,7 @@ var Input = dt.input(({ theme, $size = "md", $variant = "filled" }) => {
17913
17909
  });
17914
17910
 
17915
17911
  // src/components/ui/modal/Modal.tsx
17916
- var import_react16 = require("react");
17912
+ var import_react17 = require("react");
17917
17913
 
17918
17914
  // src/components/ui/modal/styles.ts
17919
17915
  var Modal = dt(Box).attrs({
@@ -17952,15 +17948,15 @@ var Modal = dt(Box).attrs({
17952
17948
 
17953
17949
  // src/components/ui/modal/Modal.tsx
17954
17950
  var import_jsx_runtime4 = require("react/jsx-runtime");
17955
- var Modal2 = (0, import_react16.forwardRef)(
17951
+ var Modal2 = (0, import_react17.forwardRef)(
17956
17952
  ({ children, contentRef, size = "auto", top = 0, onClose, ...rest }, ref) => {
17957
17953
  const { setLayout } = useEmbed();
17958
17954
  const isLightBackground = useIsLightBackground();
17959
- const handleClose = (0, import_react16.useCallback)(() => {
17955
+ const handleClose = (0, import_react17.useCallback)(() => {
17960
17956
  setLayout("portal");
17961
17957
  onClose?.();
17962
17958
  }, [setLayout, onClose]);
17963
- (0, import_react16.useLayoutEffect)(() => {
17959
+ (0, import_react17.useLayoutEffect)(() => {
17964
17960
  contentRef?.current?.focus({ preventScroll: true });
17965
17961
  }, [contentRef]);
17966
17962
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
@@ -18000,7 +17996,7 @@ var Modal2 = (0, import_react16.forwardRef)(
18000
17996
  Modal2.displayName = "Modal";
18001
17997
 
18002
17998
  // src/components/ui/modal/ModalHeader.tsx
18003
- var import_react17 = require("react");
17999
+ var import_react18 = require("react");
18004
18000
  var import_jsx_runtime5 = require("react/jsx-runtime");
18005
18001
  var ModalHeader = ({
18006
18002
  children,
@@ -18010,7 +18006,7 @@ var ModalHeader = ({
18010
18006
  const theme = nt();
18011
18007
  const { setLayout } = useEmbed();
18012
18008
  const isLightBackground = useIsLightBackground();
18013
- const handleClose = (0, import_react17.useCallback)(() => {
18009
+ const handleClose = (0, import_react18.useCallback)(() => {
18014
18010
  setLayout("portal");
18015
18011
  onClose?.();
18016
18012
  }, [setLayout, onClose]);
@@ -18058,6 +18054,7 @@ var ModalHeader = ({
18058
18054
  };
18059
18055
 
18060
18056
  // src/components/ui/progress-bar/ProgressBar.tsx
18057
+ var import_react19 = require("react");
18061
18058
  var import_jsx_runtime6 = require("react/jsx-runtime");
18062
18059
  var progressColorMap = [
18063
18060
  "blue",
@@ -18067,68 +18064,72 @@ var progressColorMap = [
18067
18064
  "red",
18068
18065
  "red"
18069
18066
  ];
18070
- var ProgressBar = ({
18071
- progress,
18072
- value,
18073
- total = 0,
18074
- color = "gray",
18075
- bgColor = "#F2F4F7",
18076
- ...props
18077
- }) => {
18078
- const theme = nt();
18079
- const barColorMap = {
18080
- gray: "#9CA3AF",
18081
- blue: "#2563EB",
18082
- yellow: "#FFAA06",
18083
- orange: "#DB6769",
18084
- red: "#EF4444"
18085
- };
18086
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
18087
- Flex,
18088
- {
18089
- $position: "relative",
18090
- $alignItems: "center",
18091
- $gap: "1rem",
18092
- $width: "100%",
18093
- ...props,
18094
- children: [
18095
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
18096
- Box,
18097
- {
18098
- $overflow: "hidden",
18099
- $width: "100%",
18100
- $minWidth: "6rem",
18101
- $height: `${8 / TEXT_BASE_SIZE}rem`,
18102
- $backgroundColor: bgColor,
18103
- $borderRadius: "9999px",
18104
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
18105
- Box,
18106
- {
18107
- $width: `${Math.min(progress, 100)}%`,
18108
- $height: "100%",
18109
- $backgroundColor: barColorMap[color]
18110
- }
18111
- )
18112
- }
18113
- ),
18114
- total && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
18115
- Text,
18116
- {
18117
- $font: theme.typography.text.fontFamily,
18118
- $size: 14,
18119
- $weight: 500,
18120
- $color: theme.typography.text.color,
18121
- children: [
18122
- formatNumber(value),
18123
- "/",
18124
- formatNumber(total)
18125
- ]
18126
- }
18127
- )
18128
- ]
18129
- }
18130
- );
18131
- };
18067
+ var ProgressBar = (0, import_react19.forwardRef)(
18068
+ ({
18069
+ progress,
18070
+ value,
18071
+ total = 0,
18072
+ color = "gray",
18073
+ bgColor = "#F2F4F7",
18074
+ ...props
18075
+ }, ref) => {
18076
+ const theme = nt();
18077
+ const barColorMap = {
18078
+ gray: "#9CA3AF",
18079
+ blue: "#2563EB",
18080
+ yellow: "#FFAA06",
18081
+ orange: "#DB6769",
18082
+ red: "#EF4444"
18083
+ };
18084
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
18085
+ Flex,
18086
+ {
18087
+ ref,
18088
+ $position: "relative",
18089
+ $alignItems: "center",
18090
+ $gap: "1rem",
18091
+ $width: "100%",
18092
+ ...props,
18093
+ children: [
18094
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
18095
+ Box,
18096
+ {
18097
+ $overflow: "hidden",
18098
+ $width: "100%",
18099
+ $minWidth: "6rem",
18100
+ $height: `${8 / TEXT_BASE_SIZE}rem`,
18101
+ $backgroundColor: bgColor,
18102
+ $borderRadius: "9999px",
18103
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
18104
+ Box,
18105
+ {
18106
+ $width: `${Math.min(progress, 100)}%`,
18107
+ $height: "100%",
18108
+ $backgroundColor: barColorMap[color]
18109
+ }
18110
+ )
18111
+ }
18112
+ ),
18113
+ total && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
18114
+ Text,
18115
+ {
18116
+ $font: theme.typography.text.fontFamily,
18117
+ $size: 14,
18118
+ $weight: 500,
18119
+ $color: theme.typography.text.color,
18120
+ children: [
18121
+ formatNumber(value),
18122
+ "/",
18123
+ formatNumber(total)
18124
+ ]
18125
+ }
18126
+ )
18127
+ ]
18128
+ }
18129
+ );
18130
+ }
18131
+ );
18132
+ ProgressBar.displayName = "ProgressBar";
18132
18133
 
18133
18134
  // src/components/ui/text/styles.ts
18134
18135
  var TextPropNames = /* @__PURE__ */ ((TextPropNames2) => {
@@ -18195,12 +18196,13 @@ var Text = dt.span.withConfig({
18195
18196
 
18196
18197
  // src/components/ui/tooltip/Tooltip.tsx
18197
18198
  var import_lodash2 = __toESM(require_lodash());
18198
- var import_react18 = require("react");
18199
+ var import_react20 = require("react");
18199
18200
  var import_react_dom = require("react-dom");
18200
18201
 
18201
18202
  // src/components/ui/tooltip/styles.ts
18202
18203
  var Trigger = dt.div`
18203
18204
  width: 100%;
18205
+ flex-grow: 1;
18204
18206
  `;
18205
18207
  var coords = (position2) => {
18206
18208
  let x2 = 0;
@@ -18332,13 +18334,13 @@ var Tooltip = ({
18332
18334
  trigger,
18333
18335
  content,
18334
18336
  position: position2 = "top",
18335
- zIndex = 1,
18337
+ zIndex = 9999999,
18336
18338
  ...rest
18337
18339
  }) => {
18338
- const ref = (0, import_react18.useRef)(null);
18339
- const [show, setShow] = (0, import_react18.useState)(false);
18340
- const [coords2, setCoords] = (0, import_react18.useState)({ x: 0, y: 0 });
18341
- const updateCoords = (0, import_react18.useCallback)(() => {
18340
+ const ref = (0, import_react20.useRef)(null);
18341
+ const [show, setShow] = (0, import_react20.useState)(false);
18342
+ const [coords2, setCoords] = (0, import_react20.useState)({ x: 0, y: 0 });
18343
+ const updateCoords = (0, import_react20.useCallback)(() => {
18342
18344
  if (ref.current) {
18343
18345
  const { top: offsetTop, left: offsetLeft } = document.body.getBoundingClientRect();
18344
18346
  const rect = ref.current.getBoundingClientRect();
@@ -18356,14 +18358,14 @@ var Tooltip = ({
18356
18358
  });
18357
18359
  }
18358
18360
  }, [position2]);
18359
- (0, import_react18.useLayoutEffect)(() => {
18361
+ (0, import_react20.useLayoutEffect)(() => {
18360
18362
  const handleResize = (0, import_lodash2.debounce)(updateCoords, DEBOUNCE_TIMEOUT);
18361
18363
  window.addEventListener("resize", handleResize);
18362
18364
  return () => {
18363
18365
  window.removeEventListener("resize", handleResize);
18364
18366
  };
18365
18367
  }, [updateCoords]);
18366
- (0, import_react18.useLayoutEffect)(() => {
18368
+ (0, import_react20.useLayoutEffect)(() => {
18367
18369
  updateCoords();
18368
18370
  }, [updateCoords, show]);
18369
18371
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
@@ -18425,7 +18427,7 @@ var StyledCard = dt.div(({ theme }) => {
18425
18427
 
18426
18428
  // src/components/layout/card/Card.tsx
18427
18429
  var import_jsx_runtime8 = require("react/jsx-runtime");
18428
- var Card = (0, import_react19.forwardRef)(
18430
+ var Card = (0, import_react21.forwardRef)(
18429
18431
  ({ children, className }, ref) => {
18430
18432
  const { isPending } = useEmbed();
18431
18433
  const theme = nt();
@@ -18454,7 +18456,7 @@ var Card = (0, import_react19.forwardRef)(
18454
18456
  Card.displayName = "Card";
18455
18457
 
18456
18458
  // src/components/layout/column/Column.tsx
18457
- var import_react20 = require("react");
18459
+ var import_react22 = require("react");
18458
18460
 
18459
18461
  // src/components/layout/column/styles.ts
18460
18462
  var StyledColumn = dt.div`
@@ -18463,15 +18465,15 @@ var StyledColumn = dt.div`
18463
18465
 
18464
18466
  // src/components/layout/column/Column.tsx
18465
18467
  var import_jsx_runtime9 = require("react/jsx-runtime");
18466
- var Column = (0, import_react20.forwardRef)(
18468
+ var Column = (0, import_react22.forwardRef)(
18467
18469
  ({ children, basis, ...props }, ref) => {
18468
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyledColumn, { ref, ...props, children: import_react20.Children.count(children) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Card, { children }) : children });
18470
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyledColumn, { ref, ...props, children: import_react22.Children.count(children) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Card, { children }) : children });
18469
18471
  }
18470
18472
  );
18471
18473
  Column.displayName = "Column";
18472
18474
 
18473
18475
  // src/components/layout/root/Root.tsx
18474
- var import_react21 = require("react");
18476
+ var import_react23 = require("react");
18475
18477
 
18476
18478
  // src/components/layout/root/styles.ts
18477
18479
  var Container2 = dt.div`
@@ -18482,6 +18484,8 @@ var Container2 = dt.div`
18482
18484
  line-height: 1.35;
18483
18485
  width: 100%;
18484
18486
  height: 100%;
18487
+ container-type: inline-size;
18488
+ interpolate-size: allow-keywords;
18485
18489
 
18486
18490
  *,
18487
18491
  *::before,
@@ -18506,7 +18510,7 @@ var Container2 = dt.div`
18506
18510
 
18507
18511
  // src/components/layout/root/Root.tsx
18508
18512
  var import_jsx_runtime10 = require("react/jsx-runtime");
18509
- var Root = (0, import_react21.forwardRef)(
18513
+ var Root = (0, import_react23.forwardRef)(
18510
18514
  ({ data, settings, ...props }, ref) => {
18511
18515
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Container2, { ref, ...props });
18512
18516
  }
@@ -18515,17 +18519,17 @@ Root.displayName = "Root";
18515
18519
 
18516
18520
  // src/components/layout/viewport/Viewport.tsx
18517
18521
  var import_lodash3 = __toESM(require_lodash());
18518
- var import_react30 = require("react");
18522
+ var import_react32 = require("react");
18519
18523
  var import_react_dom2 = require("react-dom");
18520
18524
 
18521
18525
  // src/components/shared/checkout-dialog/CheckoutDialog.tsx
18522
- var import_react26 = require("react");
18526
+ var import_react28 = require("react");
18523
18527
 
18524
18528
  // src/components/shared/sidebar/Sidebar.tsx
18525
- var import_react23 = require("react");
18529
+ var import_react25 = require("react");
18526
18530
 
18527
18531
  // src/components/shared/sidebar/Proration.tsx
18528
- var import_react22 = require("react");
18532
+ var import_react24 = require("react");
18529
18533
  var import_jsx_runtime11 = require("react/jsx-runtime");
18530
18534
  var Proration = ({
18531
18535
  currency,
@@ -18534,7 +18538,7 @@ var Proration = ({
18534
18538
  }) => {
18535
18539
  const { t: t2 } = useTranslation();
18536
18540
  const theme = nt();
18537
- const [open, setOpen] = (0, import_react22.useState)(false);
18541
+ const [open, setOpen] = (0, import_react24.useState)(false);
18538
18542
  const toggle = (e2) => {
18539
18543
  e2.preventDefault();
18540
18544
  e2.stopPropagation();
@@ -18590,21 +18594,29 @@ var Proration = ({
18590
18594
  children: t2("Total")
18591
18595
  }
18592
18596
  ),
18593
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Button, { onClick: toggle, $variant: "text", children: [
18594
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon2, { name: open ? "chevron-up" : "chevron-down" }),
18595
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
18596
- Text,
18597
- {
18598
- $font: theme.typography.link.fontFamily,
18599
- $size: theme.typography.link.fontSize,
18600
- $weight: theme.typography.link.fontWeight,
18601
- $color: theme.typography.link.color,
18602
- $leading: 1,
18603
- style: { cursor: "pointer" },
18604
- children: open ? t2("Hide details") : t2("Show details")
18605
- }
18606
- )
18607
- ] })
18597
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
18598
+ Button,
18599
+ {
18600
+ onClick: toggle,
18601
+ style: { height: "auto", padding: 0 },
18602
+ $variant: "text",
18603
+ children: [
18604
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon2, { name: open ? "chevron-up" : "chevron-down" }),
18605
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
18606
+ Text,
18607
+ {
18608
+ $font: theme.typography.link.fontFamily,
18609
+ $size: theme.typography.link.fontSize,
18610
+ $weight: theme.typography.link.fontWeight,
18611
+ $color: theme.typography.link.color,
18612
+ $leading: 1,
18613
+ style: { cursor: "pointer" },
18614
+ children: open ? t2("Hide details") : t2("Show details")
18615
+ }
18616
+ )
18617
+ ]
18618
+ }
18619
+ )
18608
18620
  ] }),
18609
18621
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Flex, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
18610
18622
  Text,
@@ -18648,6 +18660,7 @@ var StageButton = ({
18648
18660
  disabled: isLoading || !hasUnstagedChanges || !canUpdateSubscription,
18649
18661
  onClick: checkout,
18650
18662
  $isLoading: isLoading,
18663
+ $fullWidth: true,
18651
18664
  children: t2("Subscribe and close")
18652
18665
  }
18653
18666
  );
@@ -18663,6 +18676,7 @@ var StageButton = ({
18663
18676
  setCheckoutStage?.("checkout");
18664
18677
  },
18665
18678
  $isLoading: isLoading,
18679
+ $fullWidth: true,
18666
18680
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
18667
18681
  Flex,
18668
18682
  {
@@ -18697,6 +18711,7 @@ var StageButton = ({
18697
18711
  );
18698
18712
  },
18699
18713
  $isLoading: isLoading,
18714
+ $fullWidth: true,
18700
18715
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Flex, { $gap: "0.5rem", $justifyContent: "center", $alignItems: "center", children: [
18701
18716
  t2("Next"),
18702
18717
  ":",
@@ -18720,6 +18735,7 @@ var StageButton = ({
18720
18735
  setCheckoutStage?.(hasAddOns ? "addons" : "checkout");
18721
18736
  },
18722
18737
  $isLoading: isLoading,
18738
+ $fullWidth: true,
18723
18739
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
18724
18740
  Flex,
18725
18741
  {
@@ -18751,6 +18767,7 @@ var StageButton = ({
18751
18767
  setCheckoutStage?.("checkout");
18752
18768
  },
18753
18769
  $isLoading: isLoading,
18770
+ $fullWidth: true,
18754
18771
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
18755
18772
  Flex,
18756
18773
  {
@@ -18780,6 +18797,7 @@ var StageButton = ({
18780
18797
  disabled: isLoading || !hasUnstagedChanges || !canCheckout,
18781
18798
  onClick: checkout,
18782
18799
  $isLoading: isLoading,
18800
+ $fullWidth: true,
18783
18801
  children: willTrial ? t2("Start trial") : t2("Pay now")
18784
18802
  }
18785
18803
  );
@@ -18815,7 +18833,7 @@ var Sidebar = ({
18815
18833
  const isLightBackground = useIsLightBackground();
18816
18834
  const currentPlan = data.company?.plan;
18817
18835
  const currentAddOns = data.company?.addOns || [];
18818
- const currentUsageBasedEntitlements = (0, import_react23.useMemo)(() => {
18836
+ const currentUsageBasedEntitlements = (0, import_react25.useMemo)(() => {
18819
18837
  return (data.featureUsage?.features || []).reduce(
18820
18838
  (acc, entitlement) => {
18821
18839
  if (entitlement.priceBehavior && (planPeriod === "month" && entitlement.monthlyUsageBasedPrice || planPeriod === "year" && entitlement.yearlyUsageBasedPrice)) {
@@ -18833,7 +18851,7 @@ var Sidebar = ({
18833
18851
  []
18834
18852
  );
18835
18853
  }, [data.featureUsage?.features, planPeriod]);
18836
- const { payAsYouGoEntitlements, payInAdvanceEntitlements } = (0, import_react23.useMemo)(() => {
18854
+ const { payAsYouGoEntitlements, payInAdvanceEntitlements } = (0, import_react25.useMemo)(() => {
18837
18855
  const payAsYouGoEntitlements2 = [];
18838
18856
  const payInAdvanceEntitlements2 = usageBasedEntitlements.filter(
18839
18857
  (entitlement) => {
@@ -18845,7 +18863,7 @@ var Sidebar = ({
18845
18863
  );
18846
18864
  return { payAsYouGoEntitlements: payAsYouGoEntitlements2, payInAdvanceEntitlements: payInAdvanceEntitlements2 };
18847
18865
  }, [usageBasedEntitlements]);
18848
- const subscriptionPrice = (0, import_react23.useMemo)(() => {
18866
+ const subscriptionPrice = (0, import_react25.useMemo)(() => {
18849
18867
  let planPrice;
18850
18868
  let currency;
18851
18869
  if (selectedPlan) {
@@ -18879,7 +18897,7 @@ var Sidebar = ({
18879
18897
  total += payInAdvanceCost;
18880
18898
  return formatCurrency(total, currency);
18881
18899
  }, [selectedPlan, currentPlan, planPeriod, addOns, payInAdvanceEntitlements]);
18882
- const { amountOff, dueNow, newCharges, percentOff, periodStart, proration } = (0, import_react23.useMemo)(() => {
18900
+ const { amountOff, dueNow, newCharges, percentOff, periodStart, proration } = (0, import_react25.useMemo)(() => {
18883
18901
  return {
18884
18902
  amountOff: charges?.amountOff ?? 0,
18885
18903
  dueNow: charges?.dueNow ?? 0,
@@ -18896,7 +18914,7 @@ var Sidebar = ({
18896
18914
  });
18897
18915
  window.dispatchEvent(event);
18898
18916
  };
18899
- const checkout = (0, import_react23.useCallback)(async () => {
18917
+ const checkout = (0, import_react25.useCallback)(async () => {
18900
18918
  const priceId = (planPeriod === "year" ? selectedPlan?.yearlyPrice : selectedPlan?.monthlyPrice)?.id;
18901
18919
  if (!api || !selectedPlan || !priceId) {
18902
18920
  return;
@@ -18963,7 +18981,7 @@ var Sidebar = ({
18963
18981
  payInAdvanceEntitlements,
18964
18982
  promoCode
18965
18983
  ]);
18966
- const unsubscribe = (0, import_react23.useCallback)(async () => {
18984
+ const unsubscribe = (0, import_react25.useCallback)(async () => {
18967
18985
  if (!api) {
18968
18986
  return;
18969
18987
  }
@@ -18987,7 +19005,7 @@ var Sidebar = ({
18987
19005
  addedUsageBasedEntitlements,
18988
19006
  removedUsageBasedEntitlements,
18989
19007
  willUsageBasedEntitlementsChange
18990
- } = (0, import_react23.useMemo)(() => {
19008
+ } = (0, import_react25.useMemo)(() => {
18991
19009
  const changedUsageBasedEntitlements2 = [];
18992
19010
  const addedUsageBasedEntitlements2 = selectedPlan ? usageBasedEntitlements.reduce(
18993
19011
  (acc, selected) => {
@@ -19051,7 +19069,7 @@ var Sidebar = ({
19051
19069
  const hasUnstagedChanges = willPeriodChange || willPlanChange || willAddOnsChange || willPayInAdvanceEntitlementsChange;
19052
19070
  const canUpdateSubscription = mode === "edit" || api !== null && !isLoading;
19053
19071
  const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
19054
- const isTrialable = selectedPlan?.companyCanTrial === true;
19072
+ const isTrialable = selectedPlan?.companyCanTrial === true && selectedPlan?.isTrialable === true;
19055
19073
  const today = /* @__PURE__ */ new Date();
19056
19074
  const trialEndsOn = new Date(today);
19057
19075
  if (isTrialable && selectedPlan.trialDays) {
@@ -19945,7 +19963,7 @@ var Sidebar = ({
19945
19963
  willTrial
19946
19964
  }
19947
19965
  ),
19948
- layout === "unsubscribe" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { onClick: unsubscribe, $isLoading: isLoading, children: t2("Cancel subscription") }),
19966
+ layout === "unsubscribe" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { onClick: unsubscribe, $isLoading: isLoading, $fullWidth: true, children: t2("Cancel subscription") }),
19949
19967
  !isLoading && error && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
19950
19968
  Text,
19951
19969
  {
@@ -20082,6 +20100,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
20082
20100
  $size: "sm",
20083
20101
  $color: "primary",
20084
20102
  $variant: "outline",
20103
+ $fullWidth: true,
20085
20104
  children: t2("Choose add-on")
20086
20105
  }
20087
20106
  ) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
@@ -20093,6 +20112,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
20093
20112
  $size: "sm",
20094
20113
  $color: addOn.current ? "danger" : "primary",
20095
20114
  $variant: addOn.current ? "ghost" : "text",
20115
+ $fullWidth: true,
20096
20116
  children: addOn.current ? t2("Remove add-on") : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
20097
20117
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
20098
20118
  Icon2,
@@ -20118,7 +20138,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
20118
20138
  };
20119
20139
 
20120
20140
  // src/components/shared/checkout-dialog/Checkout.tsx
20121
- var import_react24 = require("react");
20141
+ var import_react26 = require("react");
20122
20142
  var import_jsx_runtime15 = require("react/jsx-runtime");
20123
20143
  var Checkout = ({
20124
20144
  requiresPayment,
@@ -20128,7 +20148,7 @@ var Checkout = ({
20128
20148
  const { t: t2 } = useTranslation();
20129
20149
  const theme = nt();
20130
20150
  const isLightBackground = useIsLightBackground();
20131
- const [discount, setDiscount] = (0, import_react24.useState)("");
20151
+ const [discount, setDiscount] = (0, import_react26.useState)("");
20132
20152
  if (!requiresPayment) {
20133
20153
  return null;
20134
20154
  }
@@ -20296,7 +20316,7 @@ var Navigation = ({
20296
20316
  };
20297
20317
 
20298
20318
  // src/components/shared/checkout-dialog/Plan.tsx
20299
- var import_react25 = require("react");
20319
+ var import_react27 = require("react");
20300
20320
 
20301
20321
  // src/components/elements/pricing-table/styles.ts
20302
20322
  var ButtonLink = dt.a`
@@ -20312,7 +20332,7 @@ var import_jsx_runtime17 = require("react/jsx-runtime");
20312
20332
  var Selected = ({ isCurrent = false, isTrial = false }) => {
20313
20333
  const { t: t2 } = useTranslation();
20314
20334
  const theme = nt();
20315
- const text = (0, import_react25.useMemo)(() => {
20335
+ const text = (0, import_react27.useMemo)(() => {
20316
20336
  if (isCurrent) {
20317
20337
  return isTrial ? t2("Trial in progress") : t2("Current plan");
20318
20338
  }
@@ -20362,15 +20382,9 @@ var PlanButtonGroup = ({
20362
20382
  const { t: t2 } = useTranslation();
20363
20383
  const { data } = useEmbed();
20364
20384
  const isCurrent = plan.id === data.company?.plan?.id;
20365
- if (plan.companyCanTrial) {
20385
+ if (plan.companyCanTrial && plan.isTrialable) {
20366
20386
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Flex, { $flexDirection: "column", $gap: "1.5rem", children: [
20367
- data.subscription?.status !== "trialing" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: isSelected && willTrial ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20368
- Selected,
20369
- {
20370
- isCurrent,
20371
- isTrial: plan.companyCanTrial && willTrial
20372
- }
20373
- ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20387
+ data.subscription?.status !== "trialing" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: isSelected && willTrial ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Selected, { isCurrent, isTrial: willTrial }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20374
20388
  Button,
20375
20389
  {
20376
20390
  type: "button",
@@ -20386,6 +20400,7 @@ var PlanButtonGroup = ({
20386
20400
  $size: "sm",
20387
20401
  $color: "primary",
20388
20402
  $variant: "filled",
20403
+ $fullWidth: true,
20389
20404
  children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20390
20405
  ButtonLink,
20391
20406
  {
@@ -20396,8 +20411,8 @@ var PlanButtonGroup = ({
20396
20411
  ) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20397
20412
  Tooltip,
20398
20413
  {
20399
- trigger: t2("Over usage limit"),
20400
- content: t2("Current usage exceeds the limit of this plan.")
20414
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { children: t2("Over usage limit") }),
20415
+ content: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { children: t2("Current usage exceeds the limit of this plan.") })
20401
20416
  }
20402
20417
  ) : t2("Start X day trial", { days: plan.trialDays })
20403
20418
  }
@@ -20413,11 +20428,12 @@ var PlanButtonGroup = ({
20413
20428
  $size: "sm",
20414
20429
  $color: "primary",
20415
20430
  $variant: data.subscription?.status === "trialing" ? "filled" : "text",
20431
+ $fullWidth: true,
20416
20432
  children: !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20417
20433
  Tooltip,
20418
20434
  {
20419
- trigger: t2("Over usage limit"),
20420
- content: t2("Current usage exceeds the limit of this plan.")
20435
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { children: t2("Over usage limit") }),
20436
+ content: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { children: t2("Current usage exceeds the limit of this plan.") })
20421
20437
  }
20422
20438
  ) : t2("Choose plan")
20423
20439
  }
@@ -20437,6 +20453,7 @@ var PlanButtonGroup = ({
20437
20453
  $size: "sm",
20438
20454
  $color: "primary",
20439
20455
  $variant: "filled",
20456
+ $fullWidth: true,
20440
20457
  children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20441
20458
  ButtonLink,
20442
20459
  {
@@ -20447,8 +20464,8 @@ var PlanButtonGroup = ({
20447
20464
  ) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20448
20465
  Tooltip,
20449
20466
  {
20450
- trigger: t2("Over usage limit"),
20451
- content: t2("Current usage exceeds the limit of this plan.")
20467
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { children: t2("Over usage limit") }),
20468
+ content: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { children: t2("Current usage exceeds the limit of this plan.") })
20452
20469
  }
20453
20470
  ) : t2("Choose plan")
20454
20471
  }
@@ -20466,7 +20483,7 @@ var Plan = ({
20466
20483
  const theme = nt();
20467
20484
  const { data } = useEmbed();
20468
20485
  const isLightBackground = useIsLightBackground();
20469
- const [entitlementCounts, setEntitlementCounts] = (0, import_react25.useState)(
20486
+ const [entitlementCounts, setEntitlementCounts] = (0, import_react27.useState)(
20470
20487
  () => plans.reduce(
20471
20488
  (acc, plan) => {
20472
20489
  acc[plan.id] = {
@@ -21027,16 +21044,16 @@ var CheckoutDialog = ({ top = 0 }) => {
21027
21044
  const { t: t2 } = useTranslation();
21028
21045
  const theme = nt();
21029
21046
  const { api, data, selected } = useEmbed();
21030
- const modalRef = (0, import_react26.useRef)(null);
21031
- const contentRef = (0, import_react26.useRef)(null);
21032
- const checkoutRef = (0, import_react26.useRef)(null);
21033
- const [charges, setCharges] = (0, import_react26.useState)();
21034
- const [paymentMethodId, setPaymentMethodId] = (0, import_react26.useState)(
21047
+ const modalRef = (0, import_react28.useRef)(null);
21048
+ const contentRef = (0, import_react28.useRef)(null);
21049
+ const checkoutRef = (0, import_react28.useRef)(null);
21050
+ const [charges, setCharges] = (0, import_react28.useState)();
21051
+ const [paymentMethodId, setPaymentMethodId] = (0, import_react28.useState)(
21035
21052
  (data.subscription?.paymentMethod || data.company?.defaultPaymentMethod)?.externalId
21036
21053
  );
21037
- const [isLoading, setIsLoading] = (0, import_react26.useState)(false);
21038
- const [error, setError] = (0, import_react26.useState)();
21039
- const [planPeriod, setPlanPeriod] = (0, import_react26.useState)(
21054
+ const [isLoading, setIsLoading] = (0, import_react28.useState)(false);
21055
+ const [error, setError] = (0, import_react28.useState)();
21056
+ const [planPeriod, setPlanPeriod] = (0, import_react28.useState)(
21040
21057
  selected.period || data.company?.plan?.planPeriod || "month"
21041
21058
  );
21042
21059
  const {
@@ -21044,15 +21061,13 @@ var CheckoutDialog = ({ top = 0 }) => {
21044
21061
  addOns: availableAddOns,
21045
21062
  periods: availablePeriods
21046
21063
  } = useAvailablePlans(planPeriod);
21047
- const [selectedPlan, setSelectedPlan] = (0, import_react26.useState)(
21064
+ const [selectedPlan, setSelectedPlan] = (0, import_react28.useState)(
21048
21065
  () => availablePlans.find(
21049
21066
  (plan) => selected.planId ? plan.id === selected.planId : plan.current
21050
21067
  )
21051
21068
  );
21052
- const [willTrial, setWillTrial] = (0, import_react26.useState)(
21053
- data.subscription?.status !== "trialing" && !data.trialPaymentMethodRequired
21054
- );
21055
- const [addOns, setAddOns] = (0, import_react26.useState)(
21069
+ const [willTrial, setWillTrial] = (0, import_react28.useState)(false);
21070
+ const [addOns, setAddOns] = (0, import_react28.useState)(
21056
21071
  () => availableAddOns.map((addOn) => ({
21057
21072
  ...addOn,
21058
21073
  isSelected: typeof selected.addOnId !== "undefined" ? addOn.id === selected.addOnId : (data.company?.addOns || []).some(
@@ -21061,10 +21076,10 @@ var CheckoutDialog = ({ top = 0 }) => {
21061
21076
  }))
21062
21077
  );
21063
21078
  const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected);
21064
- const currentEntitlements = (0, import_react26.useMemo)(() => {
21079
+ const currentEntitlements = (0, import_react28.useMemo)(() => {
21065
21080
  return data.featureUsage?.features || [];
21066
21081
  }, [data.featureUsage?.features]);
21067
- const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react26.useState)(
21082
+ const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react28.useState)(
21068
21083
  () => (selectedPlan?.entitlements || []).reduce(
21069
21084
  createActiveUsageBasedEntitlementsReducer(
21070
21085
  currentEntitlements,
@@ -21073,7 +21088,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21073
21088
  []
21074
21089
  )
21075
21090
  );
21076
- const payInAdvanceEntitlements = (0, import_react26.useMemo)(
21091
+ const payInAdvanceEntitlements = (0, import_react28.useMemo)(
21077
21092
  () => usageBasedEntitlements.filter(
21078
21093
  (entitlement) => entitlement.priceBehavior === "pay_in_advance"
21079
21094
  ),
@@ -21082,12 +21097,12 @@ var CheckoutDialog = ({ top = 0 }) => {
21082
21097
  const hasActivePayInAdvanceEntitlements = payInAdvanceEntitlements.some(
21083
21098
  ({ quantity }) => quantity > 0
21084
21099
  );
21085
- const [promoCode, setPromoCode] = (0, import_react26.useState)();
21100
+ const [promoCode, setPromoCode] = (0, import_react28.useState)();
21086
21101
  const isTrialable = selectedPlan?.isTrialable === true && selectedPlan?.companyCanTrial === true;
21087
21102
  const isTrialableAndFree = isTrialable && data.trialPaymentMethodRequired !== true;
21088
21103
  const planRequiresPayment = !isTrialableAndFree || !isTrialable && selectedPlan?.isFree !== true;
21089
21104
  const requiresPayment = planRequiresPayment || hasActiveAddOns || hasActivePayInAdvanceEntitlements;
21090
- const checkoutStages = (0, import_react26.useMemo)(() => {
21105
+ const checkoutStages = (0, import_react28.useMemo)(() => {
21091
21106
  const stages = [
21092
21107
  {
21093
21108
  id: "plan",
@@ -21128,7 +21143,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21128
21143
  availableAddOns,
21129
21144
  requiresPayment
21130
21145
  ]);
21131
- const [checkoutStage, setCheckoutStage] = (0, import_react26.useState)(() => {
21146
+ const [checkoutStage, setCheckoutStage] = (0, import_react28.useState)(() => {
21132
21147
  if (selected.addOnId) {
21133
21148
  return "addons";
21134
21149
  }
@@ -21141,7 +21156,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21141
21156
  return "plan";
21142
21157
  });
21143
21158
  const isLightBackground = useIsLightBackground();
21144
- const previewCheckout = (0, import_react26.useCallback)(
21159
+ const previewCheckout = (0, import_react28.useCallback)(
21145
21160
  async (updates) => {
21146
21161
  const period = updates.period || planPeriod;
21147
21162
  const plan = updates.plan || selectedPlan;
@@ -21215,7 +21230,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21215
21230
  promoCode
21216
21231
  ]
21217
21232
  );
21218
- const selectPlan = (0, import_react26.useCallback)(
21233
+ const selectPlan = (0, import_react28.useCallback)(
21219
21234
  (updates) => {
21220
21235
  const plan = updates.plan || selectedPlan;
21221
21236
  if (!plan) {
@@ -21248,7 +21263,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21248
21263
  previewCheckout
21249
21264
  ]
21250
21265
  );
21251
- const changePlanPeriod = (0, import_react26.useCallback)(
21266
+ const changePlanPeriod = (0, import_react28.useCallback)(
21252
21267
  (period) => {
21253
21268
  setPlanPeriod(period);
21254
21269
  previewCheckout({ period });
@@ -21265,7 +21280,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21265
21280
  return updated;
21266
21281
  });
21267
21282
  };
21268
- const updateUsageBasedEntitlementQuantity = (0, import_react26.useCallback)(
21283
+ const updateUsageBasedEntitlementQuantity = (0, import_react28.useCallback)(
21269
21284
  (id, updatedQuantity) => {
21270
21285
  setUsageBasedEntitlements((prev2) => {
21271
21286
  const updated = prev2.map(
@@ -21288,7 +21303,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21288
21303
  setPromoCode(code);
21289
21304
  previewCheckout({ promoCode: code });
21290
21305
  };
21291
- (0, import_react26.useEffect)(() => {
21306
+ (0, import_react28.useEffect)(() => {
21292
21307
  if (charges) {
21293
21308
  checkoutRef.current?.scrollIntoView({
21294
21309
  behavior: "smooth",
@@ -21296,7 +21311,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21296
21311
  });
21297
21312
  }
21298
21313
  }, [charges]);
21299
- (0, import_react26.useLayoutEffect)(() => {
21314
+ (0, import_react28.useLayoutEffect)(() => {
21300
21315
  if (contentRef.current) {
21301
21316
  contentRef.current.scrollTo({
21302
21317
  top: 0,
@@ -21531,7 +21546,7 @@ var PaymentDialog = ({ top = 0 }) => {
21531
21546
 
21532
21547
  // src/components/shared/payment-form/PaymentForm.tsx
21533
21548
  var import_react_stripe_js = require("@stripe/react-stripe-js");
21534
- var import_react27 = require("react");
21549
+ var import_react29 = require("react");
21535
21550
  var import_jsx_runtime21 = require("react/jsx-runtime");
21536
21551
  var PaymentForm = ({ onConfirm }) => {
21537
21552
  const { t: t2 } = useTranslation();
@@ -21539,10 +21554,10 @@ var PaymentForm = ({ onConfirm }) => {
21539
21554
  const stripe = (0, import_react_stripe_js.useStripe)();
21540
21555
  const elements = (0, import_react_stripe_js.useElements)();
21541
21556
  const { api } = useEmbed();
21542
- const [message, setMessage] = (0, import_react27.useState)(null);
21543
- const [isLoading, setIsLoading] = (0, import_react27.useState)(false);
21544
- const [isConfirmed, setIsConfirmed] = (0, import_react27.useState)(false);
21545
- const [isComplete, setIsComplete] = (0, import_react27.useState)(false);
21557
+ const [message, setMessage] = (0, import_react29.useState)(null);
21558
+ const [isLoading, setIsLoading] = (0, import_react29.useState)(false);
21559
+ const [isConfirmed, setIsConfirmed] = (0, import_react29.useState)(false);
21560
+ const [isComplete, setIsComplete] = (0, import_react29.useState)(false);
21546
21561
  const handleSubmit = async (event) => {
21547
21562
  event.preventDefault();
21548
21563
  if (!api || !stripe || !elements) {
@@ -21602,6 +21617,7 @@ var PaymentForm = ({ onConfirm }) => {
21602
21617
  style: { flexShrink: 0 },
21603
21618
  $color: "primary",
21604
21619
  $isLoading: isLoading,
21620
+ $fullWidth: true,
21605
21621
  children: isLoading ? t2("Loading") : t2("Save payment method")
21606
21622
  }
21607
21623
  ),
@@ -21622,7 +21638,7 @@ var PaymentForm = ({ onConfirm }) => {
21622
21638
  };
21623
21639
 
21624
21640
  // src/components/shared/period-toggle/PeriodToggle.tsx
21625
- var import_react28 = require("react");
21641
+ var import_react30 = require("react");
21626
21642
  var import_jsx_runtime22 = require("react/jsx-runtime");
21627
21643
  var PeriodToggle = ({
21628
21644
  options: options2,
@@ -21634,8 +21650,8 @@ var PeriodToggle = ({
21634
21650
  const { t: t2 } = useTranslation();
21635
21651
  const theme = nt();
21636
21652
  const isLightBackground = useIsLightBackground();
21637
- const [tooltipZIndex, setTooltipZIndex] = (0, import_react28.useState)(1);
21638
- const savingsPercentage = (0, import_react28.useMemo)(() => {
21653
+ const [tooltipZIndex, setTooltipZIndex] = (0, import_react30.useState)(1);
21654
+ const savingsPercentage = (0, import_react30.useMemo)(() => {
21639
21655
  if (selectedPlan) {
21640
21656
  const monthlyBillingPrice = getBillingPrice(selectedPlan?.monthlyPrice);
21641
21657
  const yearlyBillingPrice = getBillingPrice(selectedPlan?.yearlyPrice);
@@ -21645,7 +21661,7 @@ var PeriodToggle = ({
21645
21661
  }
21646
21662
  return 0;
21647
21663
  }, [selectedPlan]);
21648
- (0, import_react28.useLayoutEffect)(() => {
21664
+ (0, import_react30.useLayoutEffect)(() => {
21649
21665
  const element = layerRef?.current;
21650
21666
  if (element) {
21651
21667
  const style = getComputedStyle(element);
@@ -21735,21 +21751,21 @@ var PeriodToggle = ({
21735
21751
  };
21736
21752
 
21737
21753
  // src/components/shared/unsubscribe-dialog/UnsubscribeDialog.tsx
21738
- var import_react29 = require("react");
21754
+ var import_react31 = require("react");
21739
21755
  var import_jsx_runtime23 = require("react/jsx-runtime");
21740
21756
  var UnsubscribeDialog = ({ top = 0 }) => {
21741
21757
  const { t: t2 } = useTranslation();
21742
21758
  const theme = nt();
21743
21759
  const { data, setLayout, setSelected } = useEmbed();
21744
- const contentRef = (0, import_react29.useRef)(null);
21745
- const [error, setError] = (0, import_react29.useState)();
21746
- const [isLoading, setIsLoading] = (0, import_react29.useState)(false);
21747
- const planPeriod = (0, import_react29.useMemo)(
21760
+ const contentRef = (0, import_react31.useRef)(null);
21761
+ const [error, setError] = (0, import_react31.useState)();
21762
+ const [isLoading, setIsLoading] = (0, import_react31.useState)(false);
21763
+ const planPeriod = (0, import_react31.useMemo)(
21748
21764
  () => data.company?.plan?.planPeriod ?? "month",
21749
21765
  [data.company?.plan?.planPeriod]
21750
21766
  );
21751
21767
  const { plans: availablePlans, addOns: availableAddOns } = useAvailablePlans(planPeriod);
21752
- const selectedPlan = (0, import_react29.useMemo)(
21768
+ const selectedPlan = (0, import_react31.useMemo)(
21753
21769
  () => availablePlans.find(
21754
21770
  (plan) => plan.id === data.company?.plan?.id && data.company?.plan.planPeriod === planPeriod
21755
21771
  ),
@@ -21760,7 +21776,7 @@ var UnsubscribeDialog = ({ top = 0 }) => {
21760
21776
  createActiveUsageBasedEntitlementsReducer(currentEntitlements, planPeriod),
21761
21777
  []
21762
21778
  );
21763
- const addOns = (0, import_react29.useMemo)(
21779
+ const addOns = (0, import_react31.useMemo)(
21764
21780
  () => availableAddOns.map((available) => ({
21765
21781
  ...available,
21766
21782
  isSelected: data.company?.addOns.some((current) => available.id === current.id) ?? false
@@ -21771,7 +21787,7 @@ var UnsubscribeDialog = ({ top = 0 }) => {
21771
21787
  data.subscription?.cancelAt || data.upcomingInvoice?.dueDate || Date.now()
21772
21788
  );
21773
21789
  const isLightBackground = useIsLightBackground();
21774
- const handleClose = (0, import_react29.useCallback)(() => {
21790
+ const handleClose = (0, import_react31.useCallback)(() => {
21775
21791
  setLayout("portal");
21776
21792
  }, [setLayout]);
21777
21793
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
@@ -21884,7 +21900,6 @@ var UnsubscribeDialog = ({ top = 0 }) => {
21884
21900
  $size: "sm",
21885
21901
  $color: "secondary",
21886
21902
  $variant: "ghost",
21887
- $fullWidth: false,
21888
21903
  children: t2("Manage plan")
21889
21904
  }
21890
21905
  )
@@ -22084,28 +22099,27 @@ var StyledViewport = dt.div.withConfig({
22084
22099
  shouldForwardProp: (prop) => !["$numberOfColumns", "numberOfColumns"].includes(prop)
22085
22100
  })`
22086
22101
  display: grid;
22087
- grid-template-columns: repeat(1, minmax(300px, 1fr));
22088
22102
  margin-left: auto;
22089
22103
  margin-right: auto;
22090
22104
  gap: 1rem;
22091
22105
 
22092
- @media (min-width: 768px) {
22093
- grid-template-columns: ${({ theme }) => lt`repeat(${theme.numberOfColumns}, minmax(300px, 1fr))`};
22106
+ @container (max-width: 767px) {
22107
+ grid-template-columns: repeat(1, minmax(300px, 1fr));
22094
22108
  }
22095
22109
 
22096
- @container (max-width: 768px) {
22097
- grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
22110
+ @container (min-width: 768px) {
22111
+ grid-template-columns: ${({ theme }) => lt`repeat(${theme.numberOfColumns}, minmax(300px, 1fr))`};
22098
22112
  }
22099
22113
  `;
22100
22114
 
22101
22115
  // src/components/layout/viewport/Viewport.tsx
22102
22116
  var import_jsx_runtime26 = require("react/jsx-runtime");
22103
- var Viewport = (0, import_react30.forwardRef)(
22117
+ var Viewport = (0, import_react32.forwardRef)(
22104
22118
  ({ children, portal, ...props }, ref) => {
22105
22119
  const { data, layout, settings } = useEmbed();
22106
- const [top, setTop] = (0, import_react30.useState)(0);
22120
+ const [top, setTop] = (0, import_react32.useState)(0);
22107
22121
  const canCheckout = data.capabilities?.checkout ?? true;
22108
- (0, import_react30.useLayoutEffect)(() => {
22122
+ (0, import_react32.useLayoutEffect)(() => {
22109
22123
  const parent = portal || document.body;
22110
22124
  const setModalY = (0, import_lodash3.debounce)(() => {
22111
22125
  const value = Math.abs(
@@ -22152,7 +22166,7 @@ var resolveDesignProps = (props) => {
22152
22166
  }
22153
22167
  };
22154
22168
  };
22155
- var ButtonElement = (0, import_react31.forwardRef)(({ children, className, ...rest }, ref) => {
22169
+ var ButtonElement = (0, import_react33.forwardRef)(({ children, className, ...rest }, ref) => {
22156
22170
  const props = resolveDesignProps(rest);
22157
22171
  const buttonStyles = {
22158
22172
  primary: {
@@ -22197,10 +22211,10 @@ var ButtonElement = (0, import_react31.forwardRef)(({ children, className, ...re
22197
22211
  ButtonElement.displayName = "Button";
22198
22212
 
22199
22213
  // src/components/elements/included-features/IncludedFeatures.tsx
22200
- var import_react33 = require("react");
22214
+ var import_react35 = require("react");
22201
22215
 
22202
22216
  // src/components/elements/included-features/Details.tsx
22203
- var import_react32 = require("react");
22217
+ var import_react34 = require("react");
22204
22218
  var import_jsx_runtime28 = require("react/jsx-runtime");
22205
22219
  var Details = ({
22206
22220
  shouldWrapChildren,
@@ -22225,7 +22239,7 @@ var Details = ({
22225
22239
  priceTier,
22226
22240
  currency,
22227
22241
  packageSize = 1
22228
- } = (0, import_react32.useMemo)(() => {
22242
+ } = (0, import_react34.useMemo)(() => {
22229
22243
  const {
22230
22244
  price: entitlementPrice,
22231
22245
  priceDecimal: entitlementPriceDecimal,
@@ -22247,7 +22261,7 @@ var Details = ({
22247
22261
  monthlyUsageBasedPrice,
22248
22262
  yearlyUsageBasedPrice
22249
22263
  ]);
22250
- const text = (0, import_react32.useMemo)(() => {
22264
+ const text = (0, import_react34.useMemo)(() => {
22251
22265
  if (!feature) {
22252
22266
  return;
22253
22267
  }
@@ -22298,7 +22312,7 @@ var Details = ({
22298
22312
  packageSize,
22299
22313
  softLimit
22300
22314
  ]);
22301
- const usageText = (0, import_react32.useMemo)(() => {
22315
+ const usageText = (0, import_react34.useMemo)(() => {
22302
22316
  if (!feature) {
22303
22317
  return;
22304
22318
  }
@@ -22306,7 +22320,7 @@ var Details = ({
22306
22320
  let index = 0;
22307
22321
  if (priceBehavior === "pay_in_advance" && typeof data.company?.plan?.planPeriod === "string" && typeof price === "number") {
22308
22322
  acc.push(
22309
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22323
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react34.Fragment, { children: [
22310
22324
  formatCurrency(price, currency),
22311
22325
  "/",
22312
22326
  packageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
@@ -22321,7 +22335,7 @@ var Details = ({
22321
22335
  index += 1;
22322
22336
  } else if ((priceBehavior === "pay_as_you_go" || priceBehavior === "overage") && typeof usage === "number") {
22323
22337
  acc.push(
22324
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22338
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react34.Fragment, { children: [
22325
22339
  usage,
22326
22340
  " ",
22327
22341
  getFeatureName(feature, usage),
@@ -22334,7 +22348,7 @@ var Details = ({
22334
22348
  if (acc) {
22335
22349
  if (priceBehavior === "pay_in_advance" && typeof price === "number" && typeof allocation === "number") {
22336
22350
  acc.push(
22337
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22351
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react34.Fragment, { children: [
22338
22352
  " ",
22339
22353
  "\u2022 ",
22340
22354
  formatCurrency(price * allocation, currency)
@@ -22343,7 +22357,7 @@ var Details = ({
22343
22357
  index += 1;
22344
22358
  } else if (priceBehavior === "pay_as_you_go" && typeof price === "number" && typeof usage === "number") {
22345
22359
  acc.push(
22346
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22360
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react34.Fragment, { children: [
22347
22361
  " ",
22348
22362
  "\u2022 ",
22349
22363
  formatCurrency(price * usage, currency)
@@ -22364,7 +22378,7 @@ var Details = ({
22364
22378
  const period = feature.featureType === "trait" && typeof data.company?.plan?.planPeriod === "string" ? `/${shortenPeriod(data.company.plan.planPeriod)}` : "";
22365
22379
  if (cost > 0) {
22366
22380
  acc.push(
22367
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22381
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react34.Fragment, { children: [
22368
22382
  " ",
22369
22383
  "\u2022 ",
22370
22384
  formatCurrency(cost),
@@ -22466,16 +22480,16 @@ function resolveDesignProps2(props) {
22466
22480
  visibleFeatures: props.visibleFeatures
22467
22481
  };
22468
22482
  }
22469
- var IncludedFeatures = (0, import_react33.forwardRef)(({ className, ...rest }, ref) => {
22483
+ var IncludedFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, ref) => {
22470
22484
  const props = resolveDesignProps2(rest);
22471
22485
  const { t: t2 } = useTranslation();
22472
22486
  const theme = nt();
22473
22487
  const { data } = useEmbed();
22474
- const elements = (0, import_react33.useRef)([]);
22488
+ const elements = (0, import_react35.useRef)([]);
22475
22489
  const shouldWrapChildren = useWrapChildren(elements.current);
22476
22490
  const isLightBackground = useIsLightBackground();
22477
- const [showCount, setShowCount] = (0, import_react33.useState)(VISIBLE_ENTITLEMENT_COUNT);
22478
- const featureUsage = (0, import_react33.useMemo)(() => {
22491
+ const [showCount, setShowCount] = (0, import_react35.useState)(VISIBLE_ENTITLEMENT_COUNT);
22492
+ const featureUsage = (0, import_react35.useMemo)(() => {
22479
22493
  const orderedFeatureUsage = props.visibleFeatures?.reduce(
22480
22494
  (acc, id) => {
22481
22495
  const mappedFeatureUsage = data.featureUsage?.features.find(
@@ -22633,7 +22647,7 @@ var IncludedFeatures = (0, import_react33.forwardRef)(({ className, ...rest }, r
22633
22647
  IncludedFeatures.displayName = "IncludedFeatures";
22634
22648
 
22635
22649
  // src/components/elements/invoices/Invoices.tsx
22636
- var import_react34 = require("react");
22650
+ var import_react36 = require("react");
22637
22651
  var import_jsx_runtime30 = require("react/jsx-runtime");
22638
22652
  function resolveDesignProps3(props) {
22639
22653
  return {
@@ -22685,29 +22699,26 @@ var InvoiceDate = ({ date, fontStyle, url }) => {
22685
22699
  }
22686
22700
  return dateText;
22687
22701
  };
22688
- var Invoices = (0, import_react34.forwardRef)(({ className, data, ...rest }, ref) => {
22702
+ var Invoices = (0, import_react36.forwardRef)(({ className, data, ...rest }, ref) => {
22689
22703
  const props = resolveDesignProps3(rest);
22690
22704
  const { t: t2 } = useTranslation();
22691
22705
  const theme = nt();
22692
22706
  const { api } = useEmbed();
22693
- const [invoices, setInvoices] = (0, import_react34.useState)(() => formatInvoices(data));
22694
- const [listSize, setListSize] = (0, import_react34.useState)(props.limit.number);
22707
+ const [invoices, setInvoices] = (0, import_react36.useState)(() => formatInvoices(data));
22708
+ const [listSize, setListSize] = (0, import_react36.useState)(props.limit.number);
22695
22709
  const toggleListSize = () => {
22696
22710
  setListSize(
22697
22711
  (prev2) => prev2 !== props.limit.number ? props.limit.number : MAX_VISIBLE_INVOICE_COUNT
22698
22712
  );
22699
22713
  };
22700
- (0, import_react34.useEffect)(() => {
22714
+ (0, import_react36.useEffect)(() => {
22701
22715
  api?.listInvoices().then((response) => {
22702
22716
  setInvoices(formatInvoices(response.data));
22703
22717
  });
22704
22718
  }, [api]);
22705
- (0, import_react34.useEffect)(() => {
22719
+ (0, import_react36.useEffect)(() => {
22706
22720
  setInvoices(formatInvoices(data));
22707
22721
  }, [data]);
22708
- if (invoices.length === 0) {
22709
- return null;
22710
- }
22711
22722
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Element, { ref, className, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Flex, { $flexDirection: "column", $gap: "1rem", children: [
22712
22723
  props.header.isVisible && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
22713
22724
  Text,
@@ -22719,54 +22730,56 @@ var Invoices = (0, import_react34.forwardRef)(({ className, data, ...rest }, ref
22719
22730
  children: t2("Invoices")
22720
22731
  }
22721
22732
  ) }),
22722
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Flex, { $flexDirection: "column", $gap: "0.5rem", children: invoices.slice(0, listSize).map(({ date, amount, url }, index) => {
22723
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Flex, { $justifyContent: "space-between", children: [
22724
- props.date.isVisible && date && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
22725
- InvoiceDate,
22733
+ invoices.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
22734
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Flex, { $flexDirection: "column", $gap: "0.5rem", children: invoices.slice(0, listSize).map(({ date, amount, url }, index) => {
22735
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Flex, { $justifyContent: "space-between", children: [
22736
+ props.date.isVisible && date && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
22737
+ InvoiceDate,
22738
+ {
22739
+ date,
22740
+ fontStyle: props.date.fontStyle,
22741
+ url
22742
+ }
22743
+ ),
22744
+ props.amount.isVisible && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
22745
+ Text,
22746
+ {
22747
+ $font: theme.typography[props.amount.fontStyle].fontFamily,
22748
+ $size: theme.typography[props.amount.fontStyle].fontSize,
22749
+ $weight: theme.typography[props.amount.fontStyle].fontWeight,
22750
+ $color: theme.typography[props.amount.fontStyle].color,
22751
+ children: amount
22752
+ }
22753
+ )
22754
+ ] }, index);
22755
+ }) }),
22756
+ props.collapse.isVisible && invoices.length > props.limit.number && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Flex, { $alignItems: "center", $gap: "0.5rem", children: [
22757
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
22758
+ Icon2,
22726
22759
  {
22727
- date,
22728
- fontStyle: props.date.fontStyle,
22729
- url
22760
+ name: `chevron-${listSize === props.limit.number ? "down" : "up"}`,
22761
+ style: { color: "#D0D0D0" }
22730
22762
  }
22731
22763
  ),
22732
- props.amount.isVisible && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
22764
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
22733
22765
  Text,
22734
22766
  {
22735
- $font: theme.typography[props.amount.fontStyle].fontFamily,
22736
- $size: theme.typography[props.amount.fontStyle].fontSize,
22737
- $weight: theme.typography[props.amount.fontStyle].fontWeight,
22738
- $color: theme.typography[props.amount.fontStyle].color,
22739
- children: amount
22767
+ onClick: toggleListSize,
22768
+ $font: theme.typography[props.collapse.fontStyle].fontFamily,
22769
+ $size: theme.typography[props.collapse.fontStyle].fontSize,
22770
+ $weight: theme.typography[props.collapse.fontStyle].fontWeight,
22771
+ $color: theme.typography[props.collapse.fontStyle].color,
22772
+ children: listSize === props.limit.number ? t2("See more") : t2("See less")
22740
22773
  }
22741
22774
  )
22742
- ] }, index);
22743
- }) }),
22744
- props.collapse.isVisible && invoices.length > props.limit.number && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Flex, { $alignItems: "center", $gap: "0.5rem", children: [
22745
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
22746
- Icon2,
22747
- {
22748
- name: `chevron-${listSize === props.limit.number ? "down" : "up"}`,
22749
- style: { color: "#D0D0D0" }
22750
- }
22751
- ),
22752
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
22753
- Text,
22754
- {
22755
- onClick: toggleListSize,
22756
- $font: theme.typography[props.collapse.fontStyle].fontFamily,
22757
- $size: theme.typography[props.collapse.fontStyle].fontSize,
22758
- $weight: theme.typography[props.collapse.fontStyle].fontWeight,
22759
- $color: theme.typography[props.collapse.fontStyle].color,
22760
- children: listSize === props.limit.number ? t2("See more") : t2("See less")
22761
- }
22762
- )
22763
- ] })
22775
+ ] })
22776
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Text, { display: "heading2", children: t2("No invoices created yet") })
22764
22777
  ] }) });
22765
22778
  });
22766
22779
  Invoices.displayName = "Invoices";
22767
22780
 
22768
22781
  // src/components/elements/metered-features/MeteredFeatures.tsx
22769
- var import_react35 = require("react");
22782
+ var import_react37 = require("react");
22770
22783
 
22771
22784
  // src/components/elements/metered-features/styles.ts
22772
22785
  var Container3 = dt.div`
@@ -22774,11 +22787,10 @@ var Container3 = dt.div`
22774
22787
  flex-direction: column;
22775
22788
 
22776
22789
  &:last-child {
22777
- overflow: hidden;
22778
-
22779
22790
  ${({ theme }) => {
22780
22791
  const borderRadius = `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`;
22781
22792
  return theme.sectionLayout === "merged" && lt`
22793
+ overflow: hidden;
22782
22794
  border-bottom-left-radius: ${borderRadius};
22783
22795
  border-bottom-right-radius: ${borderRadius};
22784
22796
  `;
@@ -22813,15 +22825,15 @@ function resolveDesignProps4(props) {
22813
22825
  visibleFeatures: props.visibleFeatures
22814
22826
  };
22815
22827
  }
22816
- var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, ref) => {
22828
+ var MeteredFeatures = (0, import_react37.forwardRef)(({ className, ...rest }, ref) => {
22817
22829
  const props = resolveDesignProps4(rest);
22818
- const elements = (0, import_react35.useRef)([]);
22830
+ const elements = (0, import_react37.useRef)([]);
22819
22831
  const shouldWrapChildren = useWrapChildren(elements.current);
22820
22832
  const { t: t2 } = useTranslation();
22821
22833
  const theme = nt();
22822
22834
  const { data, setLayout, setSelected } = useEmbed();
22823
22835
  const isLightBackground = useIsLightBackground();
22824
- const featureUsage = (0, import_react35.useMemo)(() => {
22836
+ const featureUsage = (0, import_react37.useMemo)(() => {
22825
22837
  const orderedFeatureUsage = props.visibleFeatures?.reduce(
22826
22838
  (acc, id) => {
22827
22839
  const mappedFeatureUsage = data.featureUsage?.features.find(
@@ -23007,7 +23019,7 @@ var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, re
23007
23019
  }
23008
23020
  ),
23009
23021
  props.isVisible && typeof usage === "number" && priceBehavior !== "pay_as_you_go" && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Flex, { $flexWrap: "wrap", $justifyContent: "end", $gap: "2rem", children: [
23010
- typeof allocation === "number" ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
23022
+ typeof allocation === "number" && progressBar ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
23011
23023
  Tooltip,
23012
23024
  {
23013
23025
  trigger: progressBar,
@@ -23035,7 +23047,6 @@ var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, re
23035
23047
  setSelected({ usage: true });
23036
23048
  setLayout("checkout");
23037
23049
  },
23038
- $fullWidth: false,
23039
23050
  style: { whiteSpace: "nowrap" },
23040
23051
  children: t2("Add More")
23041
23052
  }
@@ -23118,10 +23129,10 @@ var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, re
23118
23129
  MeteredFeatures.displayName = "MeteredFeatures";
23119
23130
 
23120
23131
  // src/components/elements/payment-method/PaymentMethod.tsx
23121
- var import_react37 = require("react");
23132
+ var import_react39 = require("react");
23122
23133
 
23123
23134
  // src/components/elements/payment-method/PaymentMethodElement.tsx
23124
- var import_react36 = require("react");
23135
+ var import_react38 = require("react");
23125
23136
  var import_jsx_runtime32 = require("react/jsx-runtime");
23126
23137
  var PaymentElement2 = ({
23127
23138
  iconName,
@@ -23296,7 +23307,7 @@ var PaymentListElement = ({
23296
23307
  const isLightBackground = useIsLightBackground();
23297
23308
  const { iconName, iconTitle, label, paymentLast4 } = getPaymentMethodData(paymentMethod);
23298
23309
  const iconStyles = getIconStyles({ size: "lg", theme });
23299
- const expirationDate = (0, import_react36.useMemo)(() => {
23310
+ const expirationDate = (0, import_react38.useMemo)(() => {
23300
23311
  const { cardExpMonth, cardExpYear } = paymentMethod;
23301
23312
  if (!cardExpMonth && !cardExpYear) {
23302
23313
  return "";
@@ -23408,13 +23419,13 @@ var resolveDesignProps5 = (props) => {
23408
23419
  }
23409
23420
  };
23410
23421
  };
23411
- var PaymentMethod = (0, import_react37.forwardRef)(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
23422
+ var PaymentMethod = (0, import_react39.forwardRef)(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
23412
23423
  const props = resolveDesignProps5(rest);
23413
23424
  const { data, setLayout } = useEmbed();
23414
- const paymentMethod = (0, import_react37.useMemo)(() => {
23425
+ const paymentMethod = (0, import_react39.useMemo)(() => {
23415
23426
  return data.subscription?.paymentMethod || data.company?.defaultPaymentMethod;
23416
23427
  }, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
23417
- const monthsToExpiration = (0, import_react37.useMemo)(() => {
23428
+ const monthsToExpiration = (0, import_react39.useMemo)(() => {
23418
23429
  let expiration;
23419
23430
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
23420
23431
  const today = /* @__PURE__ */ new Date();
@@ -23595,7 +23606,7 @@ var loadStripe = function loadStripe2() {
23595
23606
  };
23596
23607
 
23597
23608
  // src/components/elements/payment-method/PaymentMethodDetails.tsx
23598
- var import_react38 = require("react");
23609
+ var import_react40 = require("react");
23599
23610
  var import_jsx_runtime34 = require("react/jsx-runtime");
23600
23611
  var resolveDesignProps6 = () => {
23601
23612
  return {
@@ -23617,14 +23628,14 @@ var PaymentMethodDetails = ({
23617
23628
  const theme = nt();
23618
23629
  const { api, data, setData } = useEmbed();
23619
23630
  const isLightBackground = useIsLightBackground();
23620
- const [isLoading, setIsLoading] = (0, import_react38.useState)(false);
23621
- const [error, setError] = (0, import_react38.useState)();
23622
- const [showPaymentForm, setShowPaymentForm] = (0, import_react38.useState)(false);
23623
- const [stripe, setStripe] = (0, import_react38.useState)(null);
23624
- const [setupIntent, setSetupIntent] = (0, import_react38.useState)();
23625
- const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react38.useState)(false);
23626
- const [paymentMethod, setPaymentMethod] = (0, import_react38.useState)(data.subscription?.paymentMethod || data.company?.defaultPaymentMethod);
23627
- const monthsToExpiration = (0, import_react38.useMemo)(() => {
23631
+ const [isLoading, setIsLoading] = (0, import_react40.useState)(false);
23632
+ const [error, setError] = (0, import_react40.useState)();
23633
+ const [showPaymentForm, setShowPaymentForm] = (0, import_react40.useState)(false);
23634
+ const [stripe, setStripe] = (0, import_react40.useState)(null);
23635
+ const [setupIntent, setSetupIntent] = (0, import_react40.useState)();
23636
+ const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react40.useState)(false);
23637
+ const [paymentMethod, setPaymentMethod] = (0, import_react40.useState)(data.subscription?.paymentMethod || data.company?.defaultPaymentMethod);
23638
+ const monthsToExpiration = (0, import_react40.useMemo)(() => {
23628
23639
  let expiration;
23629
23640
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
23630
23641
  const today = /* @__PURE__ */ new Date();
@@ -23637,7 +23648,7 @@ var PaymentMethodDetails = ({
23637
23648
  }
23638
23649
  return expiration;
23639
23650
  }, [paymentMethod?.cardExpYear, paymentMethod?.cardExpMonth]);
23640
- const createSetupIntent = (0, import_react38.useCallback)(async () => {
23651
+ const createSetupIntent = (0, import_react40.useCallback)(async () => {
23641
23652
  if (!api || !data.component?.id) {
23642
23653
  return;
23643
23654
  }
@@ -23656,7 +23667,7 @@ var PaymentMethodDetails = ({
23656
23667
  setIsLoading(false);
23657
23668
  }
23658
23669
  }, [t2, api, data.component?.id]);
23659
- const updatePaymentMethod = (0, import_react38.useCallback)(
23670
+ const updatePaymentMethod = (0, import_react40.useCallback)(
23660
23671
  async (externalId) => {
23661
23672
  if (!api || !externalId) {
23662
23673
  return;
@@ -23705,7 +23716,7 @@ var PaymentMethodDetails = ({
23705
23716
  },
23706
23717
  [api, data, setData, setPaymentMethodId, t2]
23707
23718
  );
23708
- const deletePaymentMethod = (0, import_react38.useCallback)(
23719
+ const deletePaymentMethod = (0, import_react40.useCallback)(
23709
23720
  async (id) => {
23710
23721
  if (!api || !id) {
23711
23722
  return;
@@ -23732,12 +23743,12 @@ var PaymentMethodDetails = ({
23732
23743
  },
23733
23744
  [api, data, setData, t2]
23734
23745
  );
23735
- (0, import_react38.useEffect)(() => {
23746
+ (0, import_react40.useEffect)(() => {
23736
23747
  if (!stripe && setupIntent?.publishableKey) {
23737
23748
  setStripe(loadStripe(setupIntent.publishableKey));
23738
23749
  }
23739
23750
  }, [stripe, setupIntent?.publishableKey]);
23740
- (0, import_react38.useEffect)(() => {
23751
+ (0, import_react40.useEffect)(() => {
23741
23752
  if (!setupIntent && (!paymentMethod || showPaymentForm)) {
23742
23753
  createSetupIntent();
23743
23754
  }
@@ -23874,7 +23885,7 @@ var PaymentMethodDetails = ({
23874
23885
  },
23875
23886
  paymentMethod2.id
23876
23887
  )) }),
23877
- (!setupIntent || !paymentMethod || showDifferentPaymentMethods) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Button, { onClick: createSetupIntent, $size: "lg", children: t2("Add new payment method") })
23888
+ (!setupIntent || !paymentMethod || showDifferentPaymentMethods) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Button, { onClick: createSetupIntent, $size: "lg", $fullWidth: true, children: t2("Add new payment method") })
23878
23889
  ] })
23879
23890
  ] }),
23880
23891
  !isLoading && error && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
@@ -23894,7 +23905,7 @@ var PaymentMethodDetails = ({
23894
23905
  };
23895
23906
 
23896
23907
  // src/components/elements/plan-manager/PlanManager.tsx
23897
- var import_react39 = require("react");
23908
+ var import_react41 = require("react");
23898
23909
  var import_jsx_runtime35 = require("react/jsx-runtime");
23899
23910
  var resolveDesignProps7 = (props) => {
23900
23911
  return {
@@ -23924,7 +23935,7 @@ var resolveDesignProps7 = (props) => {
23924
23935
  }
23925
23936
  };
23926
23937
  };
23927
- var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal, ...rest }, ref) => {
23938
+ var PlanManager = (0, import_react41.forwardRef)(({ children, className, portal, ...rest }, ref) => {
23928
23939
  const props = resolveDesignProps7(rest);
23929
23940
  const theme = nt();
23930
23941
  const { t: t2 } = useTranslation();
@@ -23950,7 +23961,7 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
23950
23961
  []
23951
23962
  );
23952
23963
  const billingSubscription = data.company?.billingSubscription;
23953
- const trialEndDays = (0, import_react39.useMemo)(() => {
23964
+ const trialEndDays = (0, import_react41.useMemo)(() => {
23954
23965
  const trialEnd = billingSubscription?.trialEnd;
23955
23966
  const trialEndDate = trialEnd ? new Date(trialEnd * 1e3) : /* @__PURE__ */ new Date();
23956
23967
  const todayDate = /* @__PURE__ */ new Date();
@@ -24222,6 +24233,7 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
24222
24233
  },
24223
24234
  $size: props.callToAction.buttonSize,
24224
24235
  $color: props.callToAction.buttonStyle,
24236
+ $fullWidth: true,
24225
24237
  children: t2("Change plan")
24226
24238
  }
24227
24239
  )
@@ -24233,7 +24245,7 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
24233
24245
  PlanManager.displayName = "PlanManager";
24234
24246
 
24235
24247
  // src/components/elements/pricing-table/PricingTable.tsx
24236
- var import_react40 = require("react");
24248
+ var import_react42 = require("react");
24237
24249
  var import_jsx_runtime36 = require("react/jsx-runtime");
24238
24250
  var resolveDesignProps8 = (props) => {
24239
24251
  return {
@@ -24274,18 +24286,18 @@ var resolveDesignProps8 = (props) => {
24274
24286
  }
24275
24287
  };
24276
24288
  };
24277
- var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...rest }, ref) => {
24289
+ var PricingTable = (0, import_react42.forwardRef)(({ children, className, ...rest }, ref) => {
24278
24290
  const props = resolveDesignProps8(rest);
24279
24291
  const { t: t2 } = useTranslation();
24280
24292
  const theme = nt();
24281
24293
  const { data, setLayout, setSelected } = useEmbed();
24282
24294
  const trialEndDays = useTrialEnd();
24283
- const [selectedPeriod, setSelectedPeriod] = (0, import_react40.useState)(
24295
+ const [selectedPeriod, setSelectedPeriod] = (0, import_react42.useState)(
24284
24296
  () => data.company?.plan?.planPeriod || "month"
24285
24297
  );
24286
24298
  const { plans, addOns, periods } = useAvailablePlans(selectedPeriod);
24287
24299
  const isLightBackground = useIsLightBackground();
24288
- const [entitlementCounts, setEntitlementCounts] = (0, import_react40.useState)(
24300
+ const [entitlementCounts, setEntitlementCounts] = (0, import_react42.useState)(
24289
24301
  () => plans.reduce(
24290
24302
  (acc, plan) => {
24291
24303
  acc[plan.id] = {
@@ -24739,6 +24751,7 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
24739
24751
  $color: props.downgrade.buttonStyle,
24740
24752
  $variant: "outline"
24741
24753
  },
24754
+ $fullWidth: true,
24742
24755
  children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
24743
24756
  ButtonLink,
24744
24757
  {
@@ -24749,12 +24762,12 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
24749
24762
  ) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
24750
24763
  Tooltip,
24751
24764
  {
24752
- trigger: t2("Over usage limit"),
24753
- content: t2(
24765
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Text, { children: t2("Over usage limit") }),
24766
+ content: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Text, { children: t2(
24754
24767
  "Current usage exceeds the limit of this plan."
24755
- )
24768
+ ) })
24756
24769
  }
24757
- ) : plan.companyCanTrial ? t2("Start X day trial", { days: plan.trialDays }) : t2("Choose plan")
24770
+ ) : plan.companyCanTrial && plan.isTrialable ? t2("Start X day trial", { days: plan.trialDays }) : t2("Choose plan")
24758
24771
  }
24759
24772
  )
24760
24773
  ]
@@ -24976,6 +24989,7 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
24976
24989
  $size: props.upgrade.buttonSize,
24977
24990
  $color: isActiveAddOn ? "danger" : props.upgrade.buttonStyle,
24978
24991
  $variant: isActiveAddOn ? "ghost" : addOn.current ? "outline" : "filled",
24992
+ $fullWidth: true,
24979
24993
  children: isActiveAddOn ? t2("Remove add-on") : addOn.current ? t2("Change add-on") : t2("Choose add-on")
24980
24994
  }
24981
24995
  )
@@ -24997,7 +25011,7 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
24997
25011
  PricingTable.displayName = "PricingTable";
24998
25012
 
24999
25013
  // src/components/elements/text/Text.tsx
25000
- var import_react41 = require("react");
25014
+ var import_react43 = require("react");
25001
25015
  var import_jsx_runtime37 = require("react/jsx-runtime");
25002
25016
  var resolveDesignProps9 = (props) => {
25003
25017
  return {
@@ -25008,7 +25022,7 @@ var resolveDesignProps9 = (props) => {
25008
25022
  }
25009
25023
  };
25010
25024
  };
25011
- var TextElement = (0, import_react41.forwardRef)(({ children, className, ...rest }, ref) => {
25025
+ var TextElement = (0, import_react43.forwardRef)(({ children, className, ...rest }, ref) => {
25012
25026
  const props = resolveDesignProps9(rest);
25013
25027
  const theme = nt();
25014
25028
  return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Element, { as: Flex, ref, className, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
@@ -25027,7 +25041,7 @@ var TextElement = (0, import_react41.forwardRef)(({ children, className, ...rest
25027
25041
  TextElement.displayName = "Text";
25028
25042
 
25029
25043
  // src/components/elements/unsubscribe-button/UnsubscribeButton.tsx
25030
- var import_react42 = require("react");
25044
+ var import_react44 = require("react");
25031
25045
  var import_jsx_runtime38 = require("react/jsx-runtime");
25032
25046
  var resolveDesignProps10 = (props) => {
25033
25047
  return {
@@ -25040,7 +25054,7 @@ var resolveDesignProps10 = (props) => {
25040
25054
  }
25041
25055
  };
25042
25056
  };
25043
- var UnsubscribeButton = (0, import_react42.forwardRef)(({ children, className, ...rest }, ref) => {
25057
+ var UnsubscribeButton = (0, import_react44.forwardRef)(({ children, className, ...rest }, ref) => {
25044
25058
  const props = resolveDesignProps10(rest);
25045
25059
  const { t: t2 } = useTranslation();
25046
25060
  const { data, setLayout } = useEmbed();
@@ -25088,7 +25102,21 @@ var UnsubscribeButton = (0, import_react42.forwardRef)(({ children, className, .
25088
25102
  UnsubscribeButton.displayName = "UnsubscribeButton";
25089
25103
 
25090
25104
  // src/components/elements/upcoming-bill/UpcomingBill.tsx
25091
- var import_react43 = require("react");
25105
+ var import_react45 = require("react");
25106
+
25107
+ // src/components/elements/upcoming-bill/styles.ts
25108
+ var Container4 = dt.div`
25109
+ height: auto;
25110
+ opacity: 1;
25111
+ transition: 0.1s;
25112
+
25113
+ @starting-style {
25114
+ height: 0;
25115
+ opacity: 0;
25116
+ }
25117
+ `;
25118
+
25119
+ // src/components/elements/upcoming-bill/UpcomingBill.tsx
25092
25120
  var import_jsx_runtime39 = require("react/jsx-runtime");
25093
25121
  function resolveDesignProps11(props) {
25094
25122
  return {
@@ -25108,145 +25136,179 @@ function resolveDesignProps11(props) {
25108
25136
  }
25109
25137
  };
25110
25138
  }
25111
- var UpcomingBill = (0, import_react43.forwardRef)(({ className, ...rest }, ref) => {
25139
+ var UpcomingBill = (0, import_react45.forwardRef)(({ className, ...rest }, ref) => {
25112
25140
  const props = resolveDesignProps11(rest);
25113
25141
  const { t: t2 } = useTranslation();
25114
25142
  const theme = nt();
25115
- const { data } = useEmbed();
25143
+ const { api, data } = useEmbed();
25116
25144
  const isLightBackground = useIsLightBackground();
25117
- const { upcomingInvoice, discounts } = (0, import_react43.useMemo)(() => {
25118
- const discounts2 = (data.subscription?.discounts || []).map((discount) => ({
25119
- amountOff: discount.amountOff,
25145
+ const [isLoading, setIsLoading] = (0, import_react45.useState)(false);
25146
+ const [error, setError] = (0, import_react45.useState)();
25147
+ const [upcomingInvoice, setUpcomingInvoice] = (0, import_react45.useState)();
25148
+ const discounts = (0, import_react45.useMemo)(() => {
25149
+ return (data.subscription?.discounts || []).map((discount) => ({
25120
25150
  couponId: discount.couponId,
25121
- customerFacingCode: discount.customerFacingCode,
25122
- isActive: discount.isActive,
25123
- percentOff: discount.percentOff
25151
+ customerFacingCode: discount.customerFacingCode || void 0,
25152
+ currency: discount.currency || void 0,
25153
+ amountOff: discount.amountOff ?? void 0,
25154
+ percentOff: discount.percentOff ?? void 0,
25155
+ isActive: discount.isActive
25124
25156
  }));
25125
- return {
25126
- discounts: discounts2,
25127
- upcomingInvoice: {
25128
- ...typeof data.upcomingInvoice?.amountDue === "number" && {
25129
- amountDue: data.upcomingInvoice.amountDue
25130
- },
25131
- ...data.subscription?.interval && {
25132
- interval: data.subscription.interval
25133
- },
25134
- ...data.upcomingInvoice?.dueDate && {
25135
- dueDate: toPrettyDate(new Date(data.upcomingInvoice.dueDate))
25136
- },
25137
- currency: data.upcomingInvoice?.currency
25157
+ }, [data.subscription]);
25158
+ const loadInvoice = (0, import_react45.useCallback)(async () => {
25159
+ if (!api || !data.component?.id) {
25160
+ return;
25161
+ }
25162
+ try {
25163
+ setError(void 0);
25164
+ setIsLoading(true);
25165
+ const response = await api.hydrateUpcomingInvoice({
25166
+ componentId: data.component.id
25167
+ });
25168
+ setUpcomingInvoice(response.data);
25169
+ } catch (e2) {
25170
+ if (e2 instanceof Error) {
25171
+ setError(e2);
25138
25172
  }
25139
- };
25140
- }, [data.subscription, data.upcomingInvoice]);
25141
- if (typeof upcomingInvoice.amountDue !== "number" || !upcomingInvoice.dueDate) {
25142
- return null;
25143
- }
25144
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
25145
- Element,
25146
- {
25147
- as: Flex,
25148
- ref,
25149
- className,
25150
- $flexDirection: "column",
25151
- $gap: "1rem",
25152
- children: [
25153
- props.header.isVisible && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
25154
- Text,
25155
- {
25156
- $font: theme.typography[props.header.fontStyle].fontFamily,
25157
- $size: theme.typography[props.header.fontStyle].fontSize,
25158
- $weight: theme.typography[props.header.fontStyle].fontWeight,
25159
- $color: theme.typography[props.header.fontStyle].color,
25160
- children: [
25161
- props.header.prefix,
25162
- " ",
25163
- upcomingInvoice.dueDate
25164
- ]
25165
- }
25166
- ) }),
25167
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Flex, { $justifyContent: "space-between", $alignItems: "start", $gap: "1rem", children: [
25168
- props.price.isVisible && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Flex, { $alignItems: "end", $flexGrow: "1", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25169
- Text,
25170
- {
25171
- $font: theme.typography[props.price.fontStyle].fontFamily,
25172
- $size: theme.typography[props.price.fontStyle].fontSize,
25173
- $weight: theme.typography[props.price.fontStyle].fontWeight,
25174
- $color: theme.typography[props.price.fontStyle].color,
25175
- $leading: 1,
25176
- children: formatCurrency(
25177
- upcomingInvoice.amountDue,
25178
- upcomingInvoice.currency
25179
- )
25180
- }
25181
- ) }),
25182
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { $lineHeight: 1.15, $maxWidth: "10rem", $textAlign: "right", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25183
- Text,
25184
- {
25185
- $font: theme.typography[props.contractEndDate.fontStyle].fontFamily,
25186
- $size: theme.typography[props.contractEndDate.fontStyle].fontSize,
25187
- $weight: theme.typography[props.contractEndDate.fontStyle].fontWeight,
25188
- $color: theme.typography[props.contractEndDate.fontStyle].color,
25189
- $leading: 1,
25190
- children: t2("Estimated bill.")
25191
- }
25192
- ) })
25193
- ] }),
25194
- discounts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
25195
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25196
- Text,
25173
+ } finally {
25174
+ setIsLoading(false);
25175
+ }
25176
+ }, [api, data.component?.id]);
25177
+ (0, import_react45.useEffect)(() => {
25178
+ loadInvoice();
25179
+ }, [loadInvoice]);
25180
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Element, { ref, className, children: [
25181
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Flex, { as: Container4, $justifyContent: "center", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { $color: theme.primary, $isLoading: isLoading }) }),
25182
+ error ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
25183
+ Flex,
25184
+ {
25185
+ as: Container4,
25186
+ $flexDirection: "column",
25187
+ $justifyContent: "center",
25188
+ $alignItems: "center",
25189
+ $gap: "1rem",
25190
+ children: [
25191
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { $weight: 500, $color: "#DB6669", children: t2("There was a problem retrieving your upcoming invoice.") }),
25192
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25193
+ Button,
25197
25194
  {
25198
- $font: theme.typography.text.fontFamily,
25199
- $size: theme.typography.text.fontSize,
25200
- $weight: 600,
25201
- $color: theme.typography.text.color,
25202
- children: t2("Discount")
25195
+ onClick: () => loadInvoice(),
25196
+ $size: "sm",
25197
+ $variant: "ghost",
25198
+ $fullWidth: false,
25199
+ children: t2("Try again")
25203
25200
  }
25204
- ) }),
25205
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { children: discounts.map((discount) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Flex, { $alignItems: "center", $gap: "0.5rem", children: [
25201
+ )
25202
+ ]
25203
+ }
25204
+ ) : !isLoading && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Container4, { children: upcomingInvoice ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Flex, { $flexDirection: "column", $gap: "1rem", children: [
25205
+ props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Text, { display: props.header.fontStyle, children: [
25206
+ props.header.prefix,
25207
+ " ",
25208
+ toPrettyDate(upcomingInvoice.dueDate)
25209
+ ] }),
25210
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
25211
+ Flex,
25212
+ {
25213
+ $justifyContent: "space-between",
25214
+ $alignItems: "start",
25215
+ $gap: "1rem",
25216
+ children: [
25217
+ props.price.isVisible && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { display: props.price.fontStyle, $leading: 1, children: formatCurrency(
25218
+ upcomingInvoice.amountDue,
25219
+ upcomingInvoice.currency
25220
+ ) }),
25221
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { $maxWidth: "10rem", $textAlign: "right", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { display: props.contractEndDate.fontStyle, children: t2("Estimated bill.") }) })
25222
+ ]
25223
+ }
25224
+ ),
25225
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
25226
+ Flex,
25227
+ {
25228
+ $justifyContent: "space-between",
25229
+ $alignItems: "center",
25230
+ $gap: "1rem",
25231
+ children: [
25232
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { $weight: 600, children: t2("Remaining balance") }),
25233
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { children: formatCurrency(5e3, upcomingInvoice.currency) })
25234
+ ]
25235
+ }
25236
+ ),
25237
+ discounts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
25238
+ Flex,
25239
+ {
25240
+ $justifyContent: "space-between",
25241
+ $alignItems: "start",
25242
+ $gap: "1rem",
25243
+ children: [
25244
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { $weight: 600, children: t2("Discount") }),
25206
25245
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25207
25246
  Flex,
25208
25247
  {
25209
- $alignItems: "center",
25210
- $padding: "0.1875rem 0.375rem",
25211
- $borderWidth: "1px",
25212
- $borderStyle: "solid",
25213
- $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.15)" : "hsla(0, 0%, 100%, 0.15)",
25214
- $borderRadius: "0.3125rem",
25215
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25216
- Text,
25217
- {
25218
- $font: theme.typography.text.fontFamily,
25219
- $size: 0.75 * theme.typography.text.fontSize,
25220
- $weight: theme.typography.text.fontWeight,
25221
- $color: theme.typography.text.color,
25222
- children: discount.customerFacingCode
25223
- }
25248
+ $flexDirection: "column",
25249
+ $alignItems: "end",
25250
+ $gap: "0.5rem",
25251
+ children: discounts.reduce(
25252
+ (acc, discount) => {
25253
+ if (typeof discount.customerFacingCode === "string" && (typeof discount.percentOff === "number" || typeof discount.amountOff === "number")) {
25254
+ acc.push(
25255
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
25256
+ Flex,
25257
+ {
25258
+ $alignItems: "center",
25259
+ $gap: "0.5rem",
25260
+ children: [
25261
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25262
+ Flex,
25263
+ {
25264
+ $alignItems: "center",
25265
+ $padding: "0.1875rem 0.375rem",
25266
+ $borderWidth: "1px",
25267
+ $borderStyle: "solid",
25268
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.15)" : "hsla(0, 0%, 100%, 0.15)",
25269
+ $borderRadius: "0.3125rem",
25270
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25271
+ Text,
25272
+ {
25273
+ $size: 0.75 * theme.typography.text.fontSize,
25274
+ children: discount.customerFacingCode
25275
+ }
25276
+ )
25277
+ }
25278
+ ),
25279
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { children: typeof discount.percentOff === "number" ? t2("Percent off", {
25280
+ percent: discount.percentOff
25281
+ }) : t2("Amount off", {
25282
+ amount: formatCurrency(
25283
+ discount.amountOff,
25284
+ discount?.currency
25285
+ )
25286
+ }) }) })
25287
+ ]
25288
+ },
25289
+ discount.couponId
25290
+ )
25291
+ );
25292
+ }
25293
+ return acc;
25294
+ },
25295
+ []
25224
25296
  )
25225
25297
  }
25226
- ),
25227
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25228
- Text,
25229
- {
25230
- $font: theme.typography.text.fontFamily,
25231
- $size: theme.typography.text.fontSize,
25232
- $weight: theme.typography.text.fontWeight,
25233
- $color: theme.typography.text.color,
25234
- children: t2("Percent off", { percent: discount.percentOff })
25235
- }
25236
- ) })
25237
- ] }, discount.couponId)) })
25238
- ] })
25239
- ]
25240
- }
25241
- );
25298
+ )
25299
+ ]
25300
+ }
25301
+ )
25302
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { display: "heading2", children: t2("No upcoming invoice") }) })
25303
+ ] });
25242
25304
  });
25243
25305
  UpcomingBill.displayName = "UpcomingBill";
25244
25306
 
25245
25307
  // src/components/embed/ComponentTree.tsx
25246
- var import_react45 = require("react");
25308
+ var import_react47 = require("react");
25247
25309
 
25248
25310
  // src/components/embed/renderer.ts
25249
- var import_react44 = require("react");
25311
+ var import_react46 = require("react");
25250
25312
  var components = {
25251
25313
  Root,
25252
25314
  Viewport,
@@ -25281,7 +25343,7 @@ function createRenderer(options2) {
25281
25343
  const { className, ...rest } = props;
25282
25344
  const resolvedProps = component === "div" ? rest : props;
25283
25345
  const resolvedChildren = children.map(renderNode);
25284
- return (0, import_react44.createElement)(
25346
+ return (0, import_react46.createElement)(
25285
25347
  component,
25286
25348
  {
25287
25349
  key: index,
@@ -25350,8 +25412,8 @@ var Error2 = ({ message }) => {
25350
25412
  };
25351
25413
  var ComponentTree = () => {
25352
25414
  const { error, nodes, isPending } = useEmbed();
25353
- const [children, setChildren] = (0, import_react45.useState)(/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Loading, {}));
25354
- (0, import_react45.useEffect)(() => {
25415
+ const [children, setChildren] = (0, import_react47.useState)(/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Loading, {}));
25416
+ (0, import_react47.useEffect)(() => {
25355
25417
  const renderer = createRenderer();
25356
25418
  setChildren(nodes.map(renderer));
25357
25419
  }, [nodes]);