@schematichq/schematic-react 0.2.0-rc.6 → 0.2.0-rc.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
7
+ var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
8
+ get: (a2, b2) => (typeof require !== "undefined" ? require : a2)[b2]
9
+ }) : x2)(function(x2) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x2 + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
8
14
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
15
  };
10
16
  var __copyProps = (to, from2, except, desc) => {
@@ -843,6 +849,357 @@ var require_classnames = __commonJS({
843
849
  }
844
850
  });
845
851
 
852
+ // node_modules/pluralize/pluralize.js
853
+ var require_pluralize = __commonJS({
854
+ "node_modules/pluralize/pluralize.js"(exports, module) {
855
+ (function(root, pluralize3) {
856
+ if (typeof __require === "function" && typeof exports === "object" && typeof module === "object") {
857
+ module.exports = pluralize3();
858
+ } else if (typeof define === "function" && define.amd) {
859
+ define(function() {
860
+ return pluralize3();
861
+ });
862
+ } else {
863
+ root.pluralize = pluralize3();
864
+ }
865
+ })(exports, function() {
866
+ var pluralRules = [];
867
+ var singularRules = [];
868
+ var uncountables = {};
869
+ var irregularPlurals = {};
870
+ var irregularSingles = {};
871
+ function sanitizeRule(rule) {
872
+ if (typeof rule === "string") {
873
+ return new RegExp("^" + rule + "$", "i");
874
+ }
875
+ return rule;
876
+ }
877
+ function restoreCase(word, token2) {
878
+ if (word === token2) return token2;
879
+ if (word === word.toLowerCase()) return token2.toLowerCase();
880
+ if (word === word.toUpperCase()) return token2.toUpperCase();
881
+ if (word[0] === word[0].toUpperCase()) {
882
+ return token2.charAt(0).toUpperCase() + token2.substr(1).toLowerCase();
883
+ }
884
+ return token2.toLowerCase();
885
+ }
886
+ function interpolate(str, args) {
887
+ return str.replace(/\$(\d{1,2})/g, function(match2, index) {
888
+ return args[index] || "";
889
+ });
890
+ }
891
+ function replace2(word, rule) {
892
+ return word.replace(rule[0], function(match2, index) {
893
+ var result = interpolate(rule[1], arguments);
894
+ if (match2 === "") {
895
+ return restoreCase(word[index - 1], result);
896
+ }
897
+ return restoreCase(match2, result);
898
+ });
899
+ }
900
+ function sanitizeWord(token2, word, rules) {
901
+ if (!token2.length || uncountables.hasOwnProperty(token2)) {
902
+ return word;
903
+ }
904
+ var len = rules.length;
905
+ while (len--) {
906
+ var rule = rules[len];
907
+ if (rule[0].test(word)) return replace2(word, rule);
908
+ }
909
+ return word;
910
+ }
911
+ function replaceWord(replaceMap, keepMap, rules) {
912
+ return function(word) {
913
+ var token2 = word.toLowerCase();
914
+ if (keepMap.hasOwnProperty(token2)) {
915
+ return restoreCase(word, token2);
916
+ }
917
+ if (replaceMap.hasOwnProperty(token2)) {
918
+ return restoreCase(word, replaceMap[token2]);
919
+ }
920
+ return sanitizeWord(token2, word, rules);
921
+ };
922
+ }
923
+ function checkWord(replaceMap, keepMap, rules, bool) {
924
+ return function(word) {
925
+ var token2 = word.toLowerCase();
926
+ if (keepMap.hasOwnProperty(token2)) return true;
927
+ if (replaceMap.hasOwnProperty(token2)) return false;
928
+ return sanitizeWord(token2, token2, rules) === token2;
929
+ };
930
+ }
931
+ function pluralize3(word, count, inclusive) {
932
+ var pluralized = count === 1 ? pluralize3.singular(word) : pluralize3.plural(word);
933
+ return (inclusive ? count + " " : "") + pluralized;
934
+ }
935
+ pluralize3.plural = replaceWord(
936
+ irregularSingles,
937
+ irregularPlurals,
938
+ pluralRules
939
+ );
940
+ pluralize3.isPlural = checkWord(
941
+ irregularSingles,
942
+ irregularPlurals,
943
+ pluralRules
944
+ );
945
+ pluralize3.singular = replaceWord(
946
+ irregularPlurals,
947
+ irregularSingles,
948
+ singularRules
949
+ );
950
+ pluralize3.isSingular = checkWord(
951
+ irregularPlurals,
952
+ irregularSingles,
953
+ singularRules
954
+ );
955
+ pluralize3.addPluralRule = function(rule, replacement) {
956
+ pluralRules.push([sanitizeRule(rule), replacement]);
957
+ };
958
+ pluralize3.addSingularRule = function(rule, replacement) {
959
+ singularRules.push([sanitizeRule(rule), replacement]);
960
+ };
961
+ pluralize3.addUncountableRule = function(word) {
962
+ if (typeof word === "string") {
963
+ uncountables[word.toLowerCase()] = true;
964
+ return;
965
+ }
966
+ pluralize3.addPluralRule(word, "$0");
967
+ pluralize3.addSingularRule(word, "$0");
968
+ };
969
+ pluralize3.addIrregularRule = function(single, plural) {
970
+ plural = plural.toLowerCase();
971
+ single = single.toLowerCase();
972
+ irregularSingles[single] = plural;
973
+ irregularPlurals[plural] = single;
974
+ };
975
+ [
976
+ // Pronouns.
977
+ ["I", "we"],
978
+ ["me", "us"],
979
+ ["he", "they"],
980
+ ["she", "they"],
981
+ ["them", "them"],
982
+ ["myself", "ourselves"],
983
+ ["yourself", "yourselves"],
984
+ ["itself", "themselves"],
985
+ ["herself", "themselves"],
986
+ ["himself", "themselves"],
987
+ ["themself", "themselves"],
988
+ ["is", "are"],
989
+ ["was", "were"],
990
+ ["has", "have"],
991
+ ["this", "these"],
992
+ ["that", "those"],
993
+ // Words ending in with a consonant and `o`.
994
+ ["echo", "echoes"],
995
+ ["dingo", "dingoes"],
996
+ ["volcano", "volcanoes"],
997
+ ["tornado", "tornadoes"],
998
+ ["torpedo", "torpedoes"],
999
+ // Ends with `us`.
1000
+ ["genus", "genera"],
1001
+ ["viscus", "viscera"],
1002
+ // Ends with `ma`.
1003
+ ["stigma", "stigmata"],
1004
+ ["stoma", "stomata"],
1005
+ ["dogma", "dogmata"],
1006
+ ["lemma", "lemmata"],
1007
+ ["schema", "schemata"],
1008
+ ["anathema", "anathemata"],
1009
+ // Other irregular rules.
1010
+ ["ox", "oxen"],
1011
+ ["axe", "axes"],
1012
+ ["die", "dice"],
1013
+ ["yes", "yeses"],
1014
+ ["foot", "feet"],
1015
+ ["eave", "eaves"],
1016
+ ["goose", "geese"],
1017
+ ["tooth", "teeth"],
1018
+ ["quiz", "quizzes"],
1019
+ ["human", "humans"],
1020
+ ["proof", "proofs"],
1021
+ ["carve", "carves"],
1022
+ ["valve", "valves"],
1023
+ ["looey", "looies"],
1024
+ ["thief", "thieves"],
1025
+ ["groove", "grooves"],
1026
+ ["pickaxe", "pickaxes"],
1027
+ ["passerby", "passersby"]
1028
+ ].forEach(function(rule) {
1029
+ return pluralize3.addIrregularRule(rule[0], rule[1]);
1030
+ });
1031
+ [
1032
+ [/s?$/i, "s"],
1033
+ [/[^\u0000-\u007F]$/i, "$0"],
1034
+ [/([^aeiou]ese)$/i, "$1"],
1035
+ [/(ax|test)is$/i, "$1es"],
1036
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
1037
+ [/(e[mn]u)s?$/i, "$1s"],
1038
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
1039
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
1040
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
1041
+ [/(seraph|cherub)(?:im)?$/i, "$1im"],
1042
+ [/(her|at|gr)o$/i, "$1oes"],
1043
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
1044
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
1045
+ [/sis$/i, "ses"],
1046
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
1047
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
1048
+ [/([^ch][ieo][ln])ey$/i, "$1ies"],
1049
+ [/(x|ch|ss|sh|zz)$/i, "$1es"],
1050
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
1051
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
1052
+ [/(pe)(?:rson|ople)$/i, "$1ople"],
1053
+ [/(child)(?:ren)?$/i, "$1ren"],
1054
+ [/eaux$/i, "$0"],
1055
+ [/m[ae]n$/i, "men"],
1056
+ ["thou", "you"]
1057
+ ].forEach(function(rule) {
1058
+ return pluralize3.addPluralRule(rule[0], rule[1]);
1059
+ });
1060
+ [
1061
+ [/s$/i, ""],
1062
+ [/(ss)$/i, "$1"],
1063
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
1064
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
1065
+ [/ies$/i, "y"],
1066
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
1067
+ [/\b(mon|smil)ies$/i, "$1ey"],
1068
+ [/\b((?:tit)?m|l)ice$/i, "$1ouse"],
1069
+ [/(seraph|cherub)im$/i, "$1"],
1070
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
1071
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
1072
+ [/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
1073
+ [/(test)(?:is|es)$/i, "$1is"],
1074
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
1075
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
1076
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
1077
+ [/(alumn|alg|vertebr)ae$/i, "$1a"],
1078
+ [/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
1079
+ [/(matr|append)ices$/i, "$1ix"],
1080
+ [/(pe)(rson|ople)$/i, "$1rson"],
1081
+ [/(child)ren$/i, "$1"],
1082
+ [/(eau)x?$/i, "$1"],
1083
+ [/men$/i, "man"]
1084
+ ].forEach(function(rule) {
1085
+ return pluralize3.addSingularRule(rule[0], rule[1]);
1086
+ });
1087
+ [
1088
+ // Singular words with no plurals.
1089
+ "adulthood",
1090
+ "advice",
1091
+ "agenda",
1092
+ "aid",
1093
+ "aircraft",
1094
+ "alcohol",
1095
+ "ammo",
1096
+ "analytics",
1097
+ "anime",
1098
+ "athletics",
1099
+ "audio",
1100
+ "bison",
1101
+ "blood",
1102
+ "bream",
1103
+ "buffalo",
1104
+ "butter",
1105
+ "carp",
1106
+ "cash",
1107
+ "chassis",
1108
+ "chess",
1109
+ "clothing",
1110
+ "cod",
1111
+ "commerce",
1112
+ "cooperation",
1113
+ "corps",
1114
+ "debris",
1115
+ "diabetes",
1116
+ "digestion",
1117
+ "elk",
1118
+ "energy",
1119
+ "equipment",
1120
+ "excretion",
1121
+ "expertise",
1122
+ "firmware",
1123
+ "flounder",
1124
+ "fun",
1125
+ "gallows",
1126
+ "garbage",
1127
+ "graffiti",
1128
+ "hardware",
1129
+ "headquarters",
1130
+ "health",
1131
+ "herpes",
1132
+ "highjinks",
1133
+ "homework",
1134
+ "housework",
1135
+ "information",
1136
+ "jeans",
1137
+ "justice",
1138
+ "kudos",
1139
+ "labour",
1140
+ "literature",
1141
+ "machinery",
1142
+ "mackerel",
1143
+ "mail",
1144
+ "media",
1145
+ "mews",
1146
+ "moose",
1147
+ "music",
1148
+ "mud",
1149
+ "manga",
1150
+ "news",
1151
+ "only",
1152
+ "personnel",
1153
+ "pike",
1154
+ "plankton",
1155
+ "pliers",
1156
+ "police",
1157
+ "pollution",
1158
+ "premises",
1159
+ "rain",
1160
+ "research",
1161
+ "rice",
1162
+ "salmon",
1163
+ "scissors",
1164
+ "series",
1165
+ "sewage",
1166
+ "shambles",
1167
+ "shrimp",
1168
+ "software",
1169
+ "species",
1170
+ "staff",
1171
+ "swine",
1172
+ "tennis",
1173
+ "traffic",
1174
+ "transportation",
1175
+ "trout",
1176
+ "tuna",
1177
+ "wealth",
1178
+ "welfare",
1179
+ "whiting",
1180
+ "wildebeest",
1181
+ "wildlife",
1182
+ "you",
1183
+ /pok[eé]mon$/i,
1184
+ // Regexes.
1185
+ /[^aeiou]ese$/i,
1186
+ // "chinese", "japanese"
1187
+ /deer$/i,
1188
+ // "deer", "reindeer"
1189
+ /fish$/i,
1190
+ // "fish", "blowfish", "angelfish"
1191
+ /measles$/i,
1192
+ /o[iu]s$/i,
1193
+ // "carnivorous"
1194
+ /pox$/i,
1195
+ // "chickpox", "smallpox"
1196
+ /sheep$/i
1197
+ ].forEach(pluralize3.addUncountableRule);
1198
+ return pluralize3;
1199
+ });
1200
+ }
1201
+ });
1202
+
846
1203
  // src/context/embed.tsx
847
1204
  import { createContext, useCallback, useEffect, useRef, useState } from "react";
848
1205
 
@@ -5020,7 +5377,7 @@ var { Deflate, deflate, deflateRaw, gzip } = deflate_1$1;
5020
5377
  var { Inflate, inflate, inflateRaw, ungzip } = inflate_1$1;
5021
5378
  var inflate_1 = inflate;
5022
5379
 
5023
- // node_modules/tslib/tslib.es6.mjs
5380
+ // node_modules/styled-components/node_modules/tslib/tslib.es6.mjs
5024
5381
  var __assign = function() {
5025
5382
  __assign = Object.assign || function __assign2(t) {
5026
5383
  for (var s2, i2 = 1, n = arguments.length; i2 < n; i2++) {
@@ -6857,6 +7214,7 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
6857
7214
  interval: json["interval"] == null ? void 0 : json["interval"],
6858
7215
  name: json["name"],
6859
7216
  price: json["price"],
7217
+ priceExternalId: json["price_external_id"] == null ? void 0 : json["price_external_id"],
6860
7218
  quantity: json["quantity"],
6861
7219
  subscriptionId: json["subscription_id"],
6862
7220
  updatedAt: new Date(json["updated_at"])
@@ -7288,6 +7646,7 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7288
7646
  ),
7289
7647
  icon: json["icon"],
7290
7648
  id: json["id"],
7649
+ isDefault: json["is_default"],
7291
7650
  monthlyPrice: json["monthly_price"] == null ? void 0 : BillingPriceResponseDataFromJSON(json["monthly_price"]),
7292
7651
  name: json["name"],
7293
7652
  planType: json["plan_type"],
@@ -7316,7 +7675,7 @@ function InvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7316
7675
  customerExternalId: json["customer_external_id"],
7317
7676
  dueDate: json["due_date"] == null ? void 0 : new Date(json["due_date"]),
7318
7677
  environmentId: json["environment_id"],
7319
- externalId: json["external_id"],
7678
+ externalId: json["external_id"] == null ? void 0 : json["external_id"],
7320
7679
  id: json["id"],
7321
7680
  paymentMethodExternalId: json["payment_method_external_id"] == null ? void 0 : json["payment_method_external_id"],
7322
7681
  subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
@@ -7882,7 +8241,7 @@ var defaultTheme = {
7882
8241
  sectionLayout: "merged",
7883
8242
  colorMode: "light",
7884
8243
  primary: "#000000",
7885
- secondary: "#000000",
8244
+ secondary: "#194BFB",
7886
8245
  card: {
7887
8246
  background: "#FFFFFF",
7888
8247
  borderRadius: 10,
@@ -8027,7 +8386,7 @@ var EmbedProvider = ({
8027
8386
  const nodes = [];
8028
8387
  const settings = { ...defaultSettings };
8029
8388
  if (!id || !state.api) {
8030
- throw new Error("Invalid component id or api instance.");
8389
+ return new Error("Invalid component id or api instance.");
8031
8390
  }
8032
8391
  const response = await state.api.hydrateComponent({ componentId: id });
8033
8392
  const { data } = response;
@@ -8149,23 +8508,23 @@ var EmbedProvider = ({
8149
8508
  theme: "stripe",
8150
8509
  variables: {
8151
8510
  // Base
8152
- spacingUnit: ".25rem",
8153
- colorPrimary: "#0570de",
8511
+ fontFamily: '"Public Sans", system-ui, sans-serif',
8512
+ spacingUnit: "0.25rem",
8513
+ borderRadius: "0.5rem",
8514
+ colorText: "#30313D",
8154
8515
  colorBackground: "#FFFFFF",
8155
- colorText: "#30313d",
8156
- colorDanger: "#df1b41",
8157
- fontFamily: "Public Sans, system-ui, sans-serif",
8158
- borderRadius: ".5rem",
8516
+ colorPrimary: "#0570DE",
8517
+ colorDanger: "#DF1B41",
8159
8518
  // Layout
8160
8519
  gridRowSpacing: "1.5rem",
8161
8520
  gridColumnSpacing: "1.5rem"
8162
8521
  },
8163
8522
  rules: {
8164
8523
  ".Label": {
8165
- color: "#020202",
8524
+ fontSize: "1rem",
8166
8525
  fontWeight: "400",
8167
- fontSize: "16px",
8168
- marginBottom: "12px"
8526
+ marginBottom: "0.75rem",
8527
+ color: state.settings.theme.typography.text.color
8169
8528
  }
8170
8529
  }
8171
8530
  },
@@ -8212,7 +8571,7 @@ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
8212
8571
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
8213
8572
  var __getProtoOf2 = Object.getPrototypeOf;
8214
8573
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
8215
- var __commonJS2 = (cb, mod) => function __require() {
8574
+ var __commonJS2 = (cb, mod) => function __require2() {
8216
8575
  return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
8217
8576
  };
8218
8577
  var __copyProps2 = (to, from2, except, desc) => {
@@ -9210,8 +9569,8 @@ var useSchematicIsPending = (opts) => {
9210
9569
  };
9211
9570
 
9212
9571
  // src/components/elements/plan-manager/PlanManager.tsx
9213
- import { forwardRef, useMemo as useMemo6 } from "react";
9214
- import { createPortal } from "react-dom";
9572
+ import { forwardRef as forwardRef2, useMemo as useMemo7 } from "react";
9573
+ import { createPortal as createPortal2 } from "react-dom";
9215
9574
 
9216
9575
  // src/utils/color.ts
9217
9576
  function hexToHSL(color) {
@@ -9591,6 +9950,25 @@ var IconRound = ({
9591
9950
  return /* @__PURE__ */ jsx5(Container, { $size: size, $variant: variant, $colors: colors, ...props, children: /* @__PURE__ */ jsx5(Icon2, { name }) });
9592
9951
  };
9593
9952
 
9953
+ // src/components/ui/loader/styles.ts
9954
+ var spin = mt`
9955
+ 0% {
9956
+ transform: rotate(0deg);
9957
+ }
9958
+ 100% {
9959
+ transform: rotate(360deg);
9960
+ }
9961
+ `;
9962
+ var Loader = dt.div`
9963
+ border: ${4 / TEXT_BASE_SIZE}rem solid hsla(0, 0%, 50%, 0.125);
9964
+ border-top: ${4 / TEXT_BASE_SIZE}rem solid ${({ theme }) => theme.secondary};
9965
+ border-radius: 50%;
9966
+ width: ${56 / TEXT_BASE_SIZE}rem;
9967
+ height: ${56 / TEXT_BASE_SIZE}rem;
9968
+ animation: ${spin} 1.5s linear infinite;
9969
+ display: inline-block;
9970
+ `;
9971
+
9594
9972
  // src/components/ui/modal/Modal.tsx
9595
9973
  import { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo3, useRef as useRef2 } from "react";
9596
9974
  import { jsx as jsx6 } from "react/jsx-runtime";
@@ -9630,7 +10008,7 @@ var Modal = ({ children, size = "auto", onClose }) => {
9630
10008
  $transform: "translate(-50%, -50%)",
9631
10009
  $width: "100%",
9632
10010
  $height: "100%",
9633
- $backgroundColor: isLightBackground ? "hsl(0, 0%, 85%)" : "hsl(0, 0%, 15%)",
10011
+ $backgroundColor: isLightBackground ? "hsla(0, 0%, 85%, 0.8)" : "hsla(0, 0%, 15%, 0.8)",
9634
10012
  $overflow: "hidden",
9635
10013
  children: /* @__PURE__ */ jsx6(
9636
10014
  Flex,
@@ -9681,7 +10059,7 @@ var ModalHeader = ({
9681
10059
  return /* @__PURE__ */ jsxs2(
9682
10060
  Flex,
9683
10061
  {
9684
- $justifyContent: "space-between",
10062
+ $justifyContent: children ? "space-between" : "end",
9685
10063
  $alignItems: "center",
9686
10064
  $flexShrink: "0",
9687
10065
  $gap: "1rem",
@@ -9778,15 +10156,12 @@ var ProgressBar = ({
9778
10156
  };
9779
10157
 
9780
10158
  // src/components/elements/plan-manager/CheckoutDialog.tsx
9781
- import { useEffect as useEffect4, useMemo as useMemo5, useState as useState3 } from "react";
10159
+ import { useMemo as useMemo6, useState as useState3 } from "react";
10160
+ var import_pluralize = __toESM(require_pluralize());
9782
10161
 
9783
- // src/components/elements/plan-manager/PaymentForm.tsx
9784
- import { useState as useState2 } from "react";
9785
- import {
9786
- LinkAuthenticationElement,
9787
- PaymentElement
9788
- } from "@stripe/react-stripe-js";
9789
- import { useStripe, useElements } from "@stripe/react-stripe-js";
10162
+ // src/components/elements/payment-method/PaymentMethod.tsx
10163
+ import { forwardRef, useMemo as useMemo5 } from "react";
10164
+ import { createPortal } from "react-dom";
9790
10165
 
9791
10166
  // src/components/elements/plan-manager/styles.ts
9792
10167
  var StyledButton = dt(Button2)`
@@ -9888,1102 +10263,1324 @@ var StyledButton = dt(Button2)`
9888
10263
  }}
9889
10264
  `;
9890
10265
 
9891
- // src/components/elements/plan-manager/PaymentForm.tsx
10266
+ // src/components/elements/payment-method/PaymentMethod.tsx
9892
10267
  import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
9893
- var PaymentForm = ({ plan, period, onConfirm }) => {
9894
- const stripe = useStripe();
9895
- const elements = useElements();
9896
- const { api, data } = useEmbed();
9897
- const [message, setMessage] = useState2(null);
9898
- const [isLoading, setIsLoading] = useState2(false);
9899
- const [isConfirmed, setIsConfirmed] = useState2(false);
9900
- const handleSubmit = async (event) => {
9901
- event.preventDefault();
9902
- const priceId = period === "month" ? plan.monthlyPrice?.id : plan.yearlyPrice?.id;
9903
- if (!api || !stripe || !elements || !priceId) {
9904
- return;
9905
- }
9906
- setIsLoading(true);
9907
- setIsConfirmed(false);
9908
- setMessage(null);
9909
- try {
9910
- const { setupIntent, error } = await stripe.confirmSetup({
9911
- elements,
9912
- confirmParams: {
9913
- return_url: window.location.href
9914
- },
9915
- redirect: "if_required"
9916
- });
9917
- if (onConfirm && typeof setupIntent?.payment_method === "string") {
9918
- onConfirm(setupIntent.payment_method);
9919
- setIsConfirmed(true);
9920
- } else {
9921
- }
9922
- if (error?.type === "card_error" || error?.type === "validation_error") {
9923
- setMessage(error.message);
9924
- }
9925
- } catch (error) {
9926
- setMessage("A problem occurred while saving your payment method.");
9927
- } finally {
9928
- setIsLoading(false);
10268
+ var resolveDesignProps = (props) => {
10269
+ return {
10270
+ header: {
10271
+ isVisible: props.header?.isVisible ?? true,
10272
+ fontStyle: props.header?.fontStyle ?? "heading4"
10273
+ },
10274
+ functions: {
10275
+ allowEdit: props.functions?.allowEdit ?? true
9929
10276
  }
9930
10277
  };
9931
- return /* @__PURE__ */ jsxs4(
9932
- "form",
9933
- {
9934
- id: "payment-form",
9935
- onSubmit: handleSubmit,
9936
- style: {
9937
- display: "flex",
9938
- flexDirection: "column",
9939
- height: "100%",
9940
- overflowX: "hidden",
9941
- overflowY: "auto"
9942
- },
9943
- children: [
9944
- /* @__PURE__ */ jsx9(Box, { $width: "100%", $marginBottom: "1.5rem", children: /* @__PURE__ */ jsx9(Text, { $size: 18, children: "Add payment method" }) }),
9945
- /* @__PURE__ */ jsx9(
9946
- Flex,
9947
- {
9948
- $flexDirection: "column",
9949
- $gap: "1.5rem",
9950
- $width: "100%",
9951
- $marginBottom: "1.5rem",
9952
- children: /* @__PURE__ */ jsx9(
9953
- LinkAuthenticationElement,
9954
- {
9955
- id: "link-authentication-element"
9956
- }
9957
- )
9958
- }
9959
- ),
9960
- /* @__PURE__ */ jsx9(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ jsx9(PaymentElement, { id: "payment-element" }) }),
9961
- /* @__PURE__ */ jsx9(
9962
- StyledButton,
9963
- {
9964
- id: "submit",
9965
- disabled: isLoading || !stripe || !elements || !data.stripeEmbed?.publishableKey || !data.stripeEmbed?.setupIntentClientSecret || isConfirmed,
9966
- $size: "md",
9967
- $color: "primary",
9968
- children: /* @__PURE__ */ jsx9(Text, { id: "button-text", children: isLoading ? "Loading" : "Save payment method" })
9969
- }
9970
- ),
9971
- message && /* @__PURE__ */ jsx9(Box, { $margin: "1rem 0", children: /* @__PURE__ */ jsx9(Text, { id: "payment-message", $size: 15, $weight: 500, $color: "#DB6669", children: message }) })
9972
- ]
9973
- }
9974
- );
9975
10278
  };
9976
-
9977
- // src/components/elements/plan-manager/CheckoutDialog.tsx
9978
- import { Fragment, jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
9979
- var CheckoutDialog = () => {
9980
- const [checkoutStage, setCheckoutStage] = useState3(
9981
- "plan"
9982
- );
9983
- const [planPeriod, setPlanPeriod] = useState3("month");
9984
- const [selectedPlan, setSelectedPlan] = useState3();
9985
- const [paymentMethodId, setPaymentMethodId] = useState3();
9986
- const [isLoading, setIsLoading] = useState3(false);
9987
- const [isCheckoutComplete, setIsCheckoutComplete] = useState3(false);
9988
- const [error, setError] = useState3();
10279
+ var PaymentMethod = forwardRef(({ children, className, portal, ...rest }, ref) => {
10280
+ const props = resolveDesignProps(rest);
9989
10281
  const theme = nt();
9990
- const { api, data, hydrate, setLayout } = useEmbed();
9991
- const { currentPlan, availablePlans } = useMemo5(() => {
10282
+ const { data, layout } = useEmbed();
10283
+ const paymentMethod = useMemo5(() => {
10284
+ const { paymentMethodType, cardLast4, cardExpMonth, cardExpYear } = data.subscription?.paymentMethod || {};
10285
+ let monthsToExpiration;
10286
+ if (typeof cardExpYear === "number" && typeof cardExpMonth === "number") {
10287
+ const today = /* @__PURE__ */ new Date();
10288
+ const currentYear = today.getFullYear();
10289
+ const currentMonth = today.getMonth();
10290
+ const timeToExpiration = Math.round(
10291
+ +new Date(cardExpYear, cardExpMonth - 1) - +new Date(currentYear, currentMonth)
10292
+ );
10293
+ monthsToExpiration = Math.round(
10294
+ timeToExpiration / (1e3 * 60 * 60 * 24 * 30)
10295
+ );
10296
+ }
9992
10297
  return {
9993
- currentPlan: data.company?.plan,
9994
- availablePlans: data.activePlans
10298
+ paymentMethodType,
10299
+ cardLast4,
10300
+ monthsToExpiration
9995
10301
  };
9996
- }, [data.company, data.activePlans]);
9997
- const savingsPercentage = useMemo5(() => {
9998
- if (selectedPlan) {
9999
- const monthly = (selectedPlan?.monthlyPrice?.price || 0) * 12;
10000
- const yearly = selectedPlan?.yearlyPrice?.price || 0;
10001
- return Math.round((monthly - yearly) / monthly * 1e4) / 100;
10002
- }
10003
- return 0;
10004
- }, [selectedPlan]);
10302
+ }, [data.subscription?.paymentMethod]);
10005
10303
  const isLightBackground = useMemo5(() => {
10006
10304
  return hexToHSL(theme.card.background).l > 50;
10007
10305
  }, [theme.card.background]);
10008
- useEffect4(() => {
10009
- if (isCheckoutComplete && api && data.component?.id) {
10010
- hydrate();
10011
- }
10012
- }, [isCheckoutComplete, api, data.component?.id, hydrate]);
10013
- return /* @__PURE__ */ jsxs5(Modal, { size: isCheckoutComplete ? "auto" : "lg", children: [
10014
- /* @__PURE__ */ jsx10(ModalHeader, { bordered: !isCheckoutComplete, children: /* @__PURE__ */ jsx10(Flex, { $gap: "1rem", children: !isCheckoutComplete && /* @__PURE__ */ jsxs5(Fragment, { children: [
10015
- /* @__PURE__ */ jsxs5(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
10016
- checkoutStage === "plan" ? /* @__PURE__ */ jsx10(
10017
- Box,
10018
- {
10019
- $width: `${20 / TEXT_BASE_SIZE}rem`,
10020
- $height: `${20 / TEXT_BASE_SIZE}rem`,
10021
- $borderWidth: "2px",
10022
- $borderStyle: "solid",
10023
- $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.25)",
10024
- $borderRadius: "9999px"
10025
- }
10026
- ) : /* @__PURE__ */ jsx10(
10027
- IconRound,
10028
- {
10029
- name: "check",
10030
- colors: [
10031
- theme.card.background,
10032
- isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.25)"
10033
- ],
10034
- style: {
10035
- fontSize: `${16 / TEXT_BASE_SIZE}rem`,
10036
- width: `${20 / TEXT_BASE_SIZE}rem`,
10037
- height: `${20 / TEXT_BASE_SIZE}rem`
10306
+ if (!paymentMethod.paymentMethodType) {
10307
+ return null;
10308
+ }
10309
+ return /* @__PURE__ */ jsxs4("div", { ref, className, children: [
10310
+ props.header.isVisible && /* @__PURE__ */ jsxs4(
10311
+ Flex,
10312
+ {
10313
+ $justifyContent: "space-between",
10314
+ $alignItems: "center",
10315
+ $margin: "0 0 1rem",
10316
+ children: [
10317
+ /* @__PURE__ */ jsx9(
10318
+ Text,
10319
+ {
10320
+ $font: theme.typography[props.header.fontStyle].fontFamily,
10321
+ $size: theme.typography[props.header.fontStyle].fontSize,
10322
+ $weight: theme.typography[props.header.fontStyle].fontWeight,
10323
+ $color: theme.typography[props.header.fontStyle].color,
10324
+ children: "Payment Method"
10038
10325
  }
10039
- }
10040
- ),
10041
- /* @__PURE__ */ jsx10(
10042
- Box,
10326
+ ),
10327
+ typeof paymentMethod.monthsToExpiration === "number" && paymentMethod.monthsToExpiration < 4 && /* @__PURE__ */ jsx9(
10328
+ Text,
10329
+ {
10330
+ $font: theme.typography.text.fontFamily,
10331
+ $size: 14,
10332
+ $color: "#DB6769",
10333
+ children: paymentMethod.monthsToExpiration > 0 ? `Expires in ${paymentMethod.monthsToExpiration} mo` : "Expired"
10334
+ }
10335
+ )
10336
+ ]
10337
+ }
10338
+ ),
10339
+ /* @__PURE__ */ jsx9(
10340
+ Flex,
10341
+ {
10342
+ $justifyContent: "space-between",
10343
+ $alignItems: "center",
10344
+ $margin: "0 0 1rem",
10345
+ $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.125)",
10346
+ $padding: "0.375rem 1rem",
10347
+ $borderRadius: "9999px",
10348
+ children: /* @__PURE__ */ jsx9(Text, { $font: theme.typography.text.fontFamily, $size: 14, children: paymentMethod.cardLast4 ? `\u{1F4B3} Card ending in ${paymentMethod.cardLast4}` : "Other existing payment method" })
10349
+ }
10350
+ ),
10351
+ layout === "payment" && createPortal(
10352
+ /* @__PURE__ */ jsxs4(Modal, { size: "md", children: [
10353
+ /* @__PURE__ */ jsx9(ModalHeader, { children: /* @__PURE__ */ jsx9(Box, { $fontWeight: "600", children: "Edit payment method" }) }),
10354
+ /* @__PURE__ */ jsxs4(
10355
+ Flex,
10043
10356
  {
10044
- tabIndex: 0,
10045
- ...checkoutStage !== "plan" && {
10046
- onClick: () => setCheckoutStage("plan"),
10047
- $opacity: "0.6375",
10048
- $cursor: "pointer"
10049
- },
10050
- children: /* @__PURE__ */ jsx10(
10051
- Text,
10052
- {
10053
- $font: theme.typography.text.fontFamily,
10054
- $size: 19,
10055
- $weight: checkoutStage === "plan" ? 600 : 400,
10056
- $color: theme.typography.text.color,
10057
- children: "1. Select plan"
10058
- }
10059
- )
10060
- }
10061
- )
10062
- ] }),
10063
- /* @__PURE__ */ jsx10(
10064
- Icon2,
10065
- {
10066
- name: "chevron-right",
10067
- style: {
10068
- fontSize: 16,
10069
- color: isLightBackground ? "hsla(0, 0%, 0%, 0.175)" : "hsla(0, 0%, 100%, 0.35)"
10070
- }
10071
- }
10072
- ),
10073
- /* @__PURE__ */ jsxs5(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
10074
- /* @__PURE__ */ jsx10(
10075
- Box,
10076
- {
10077
- $width: `${20 / TEXT_BASE_SIZE}rem`,
10078
- $height: `${20 / TEXT_BASE_SIZE}rem`,
10079
- $borderWidth: "2px",
10080
- $borderStyle: "solid",
10081
- $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.25)",
10082
- $borderRadius: "9999px"
10083
- }
10084
- ),
10085
- /* @__PURE__ */ jsx10(
10086
- Box,
10087
- {
10088
- tabIndex: 0,
10089
- ...checkoutStage !== "checkout" && {
10090
- $opacity: "0.6375"
10091
- },
10092
- children: /* @__PURE__ */ jsx10(
10093
- Text,
10094
- {
10095
- $font: theme.typography.text.fontFamily,
10096
- $size: 19,
10097
- $weight: checkoutStage === "plan" ? 600 : 400,
10098
- $color: theme.typography.text.color,
10099
- children: "2. Checkout"
10100
- }
10101
- )
10102
- }
10103
- )
10104
- ] })
10105
- ] }) }) }),
10106
- isCheckoutComplete && /* @__PURE__ */ jsxs5(
10107
- Flex,
10108
- {
10109
- $flexDirection: "column",
10110
- $justifyContent: "center",
10111
- $alignItems: "center",
10112
- $flexGrow: "1",
10113
- $gap: `${32 / TEXT_BASE_SIZE}rem`,
10114
- $padding: `${32 / TEXT_BASE_SIZE}rem ${40 / TEXT_BASE_SIZE}rem`,
10115
- $whiteSpace: "nowrap",
10116
- children: [
10117
- /* @__PURE__ */ jsx10(
10118
- IconRound,
10119
- {
10120
- name: "check",
10121
- size: "3xl",
10122
- colors: [
10123
- theme.card.background,
10124
- isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.125)"
10125
- ]
10126
- }
10127
- ),
10128
- /* @__PURE__ */ jsx10(
10129
- Text,
10130
- {
10131
- as: "h1",
10132
- $font: theme.typography.heading1.fontFamily,
10133
- $size: theme.typography.heading1.fontSize,
10134
- $weight: theme.typography.heading1.fontWeight,
10135
- $color: theme.typography.heading1.color,
10136
- children: "Subscription updated!"
10137
- }
10138
- ),
10139
- /* @__PURE__ */ jsx10(StyledButton, { onClick: () => setLayout("portal"), children: "Close" })
10140
- ]
10141
- }
10142
- ),
10143
- !isCheckoutComplete && /* @__PURE__ */ jsxs5(Flex, { $position: "relative", $height: "calc(100% - 5rem)", children: [
10144
- /* @__PURE__ */ jsxs5(
10145
- Flex,
10146
- {
10147
- $flexDirection: "column",
10148
- $flexGrow: "1",
10149
- $gap: "1rem",
10150
- $padding: "2rem 2.5rem 2rem 2.5rem",
10151
- $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.025)" : "hsla(0, 0%, 100%, 0.025)",
10152
- $flex: "1",
10153
- $overflow: "auto",
10154
- children: [
10155
- checkoutStage === "plan" && /* @__PURE__ */ jsxs5(Fragment, { children: [
10156
- /* @__PURE__ */ jsxs5(Flex, { $flexDirection: "column", $gap: "1rem", $marginBottom: "1rem", children: [
10157
- /* @__PURE__ */ jsx10(
10158
- Text,
10159
- {
10160
- as: "h3",
10161
- id: "select-plan-dialog-label",
10162
- $font: theme.typography.heading3.fontFamily,
10163
- $size: theme.typography.heading3.fontSize,
10164
- $weight: theme.typography.heading3.fontWeight,
10165
- $color: theme.typography.heading3.color,
10166
- $marginBottom: "0.5rem",
10167
- children: "Select plan"
10168
- }
10169
- ),
10170
- /* @__PURE__ */ jsx10(
10171
- Text,
10172
- {
10173
- as: "p",
10174
- id: "select-plan-dialog-description",
10175
- $font: theme.typography.text.fontFamily,
10176
- $size: theme.typography.text.fontSize,
10177
- $weight: theme.typography.text.fontWeight,
10178
- $color: theme.typography.text.color,
10179
- children: "Choose your base plan"
10180
- }
10181
- )
10182
- ] }),
10183
- /* @__PURE__ */ jsx10(Flex, { $flexWrap: "wrap", $gap: "1rem", $flexGrow: "1", children: availablePlans?.map((plan) => {
10184
- return /* @__PURE__ */ jsxs5(
10185
- Flex,
10186
- {
10187
- $flexDirection: "column",
10188
- $width: "100%",
10189
- $minWidth: "280px",
10190
- $maxWidth: `calc(${100 / 3}% - 1rem)`,
10191
- $backgroundColor: theme.card.background,
10192
- $outlineWidth: "2px",
10193
- $outlineStyle: "solid",
10194
- $outlineColor: plan.id === selectedPlan?.id ? theme.primary : "transparent",
10195
- $borderRadius: `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`,
10196
- ...theme.card.hasShadow && {
10197
- $boxShadow: "0px 1px 3px rgba(16, 24, 40, 0.1), 0px 1px 20px rgba(16, 24, 40, 0.06)"
10198
- },
10199
- children: [
10200
- /* @__PURE__ */ jsxs5(
10357
+ $flexDirection: "column",
10358
+ $padding: "2.5rem",
10359
+ $height: "100%",
10360
+ $gap: "1.5rem",
10361
+ children: [
10362
+ /* @__PURE__ */ jsx9(
10363
+ Flex,
10364
+ {
10365
+ $flexDirection: "column",
10366
+ $gap: "1rem",
10367
+ $backgroundColor: "#FBFBFB",
10368
+ $borderRadius: "0 0 0.5rem 0.5rem",
10369
+ $flex: "1",
10370
+ $height: "100%",
10371
+ children: /* @__PURE__ */ jsxs4(Flex, { $flexDirection: "column", $height: "100%", children: [
10372
+ /* @__PURE__ */ jsx9(
10373
+ Box,
10374
+ {
10375
+ $fontSize: "18px",
10376
+ $marginBottom: "1.5rem",
10377
+ $display: "inline-block",
10378
+ $width: "100%",
10379
+ children: "Default"
10380
+ }
10381
+ ),
10382
+ /* @__PURE__ */ jsxs4(Flex, { $gap: "1rem", children: [
10383
+ /* @__PURE__ */ jsx9(
10201
10384
  Flex,
10202
10385
  {
10203
- $flexDirection: "column",
10204
- $position: "relative",
10386
+ $alignItems: "center",
10387
+ $padding: ".5rem 1rem",
10388
+ $border: "1px solid #E2E5E9",
10389
+ $borderRadius: ".5rem",
10390
+ $backgroundColor: "#ffffff",
10205
10391
  $gap: "1rem",
10206
10392
  $width: "100%",
10207
- $height: "auto",
10208
- $padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
10209
- $borderBottomWidth: "1px",
10210
- $borderStyle: "solid",
10211
- $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.175)" : "hsla(0, 0%, 100%, 0.175)",
10212
- children: [
10213
- /* @__PURE__ */ jsx10(Text, { $size: 20, $weight: 600, children: plan.name }),
10214
- /* @__PURE__ */ jsx10(Text, { $size: 14, children: plan.description }),
10215
- /* @__PURE__ */ jsxs5(Text, { children: [
10216
- /* @__PURE__ */ jsx10(Box, { $display: "inline-block", $fontSize: "1.5rem", children: formatCurrency(
10217
- (planPeriod === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0
10393
+ children: /* @__PURE__ */ jsxs4(Flex, { $justifyContent: "space-between", $flex: "1", children: [
10394
+ /* @__PURE__ */ jsxs4(Flex, { $alignItems: "center", $gap: "1rem", children: [
10395
+ /* @__PURE__ */ jsx9(Box, { $display: "inline-block", children: /* @__PURE__ */ jsx9(
10396
+ "svg",
10397
+ {
10398
+ viewBox: "0 0 24 16",
10399
+ fill: "none",
10400
+ xmlns: "http://www.w3.org/2000/svg",
10401
+ width: "26px",
10402
+ height: "auto",
10403
+ children: /* @__PURE__ */ jsxs4("g", { children: [
10404
+ /* @__PURE__ */ jsx9(
10405
+ "rect",
10406
+ {
10407
+ stroke: "#DDD",
10408
+ fill: "#FFF",
10409
+ x: ".25",
10410
+ y: ".25",
10411
+ width: "23",
10412
+ height: "15.5",
10413
+ rx: "2"
10414
+ }
10415
+ ),
10416
+ /* @__PURE__ */ jsx9(
10417
+ "path",
10418
+ {
10419
+ d: "M2.788 5.914A7.201 7.201 0 0 0 1 5.237l.028-.125h2.737c.371.013.672.125.77.519l.595 2.836.182.854 1.666-4.21h1.799l-2.674 6.167H4.304L2.788 5.914Zm7.312 5.37H8.399l1.064-6.172h1.7L10.1 11.284Zm6.167-6.021-.232 1.333-.153-.066a3.054 3.054 0 0 0-1.268-.236c-.671 0-.972.269-.98.531 0 .29.365.48.96.762.98.44 1.435.979 1.428 1.681-.014 1.28-1.176 2.108-2.96 2.108-.764-.007-1.5-.158-1.898-.328l.238-1.386.224.099c.553.23.917.328 1.596.328.49 0 1.015-.19 1.022-.604 0-.27-.224-.466-.882-.769-.644-.295-1.505-.788-1.491-1.674C11.878 5.84 13.06 5 14.74 5c.658 0 1.19.138 1.526.263Zm2.26 3.834h1.415c-.07-.308-.392-1.786-.392-1.786l-.12-.531c-.083.23-.23.604-.223.59l-.68 1.727Zm2.1-3.985L22 11.284h-1.575s-.154-.71-.203-.926h-2.184l-.357.926h-1.785l2.527-5.66c.175-.4.483-.512.889-.512h1.316Z",
10420
+ fill: "#1434CB"
10421
+ }
10422
+ )
10423
+ ] })
10424
+ }
10218
10425
  ) }),
10219
- /* @__PURE__ */ jsxs5(Box, { $display: "inline-block", $fontSize: "0.75rem", children: [
10220
- "/",
10221
- planPeriod
10222
- ] })
10426
+ /* @__PURE__ */ jsx9(Box, { $whiteSpace: "nowrap", children: "Visa **** 4242" })
10223
10427
  ] }),
10224
- (plan.current || plan.id === currentPlan?.id) && /* @__PURE__ */ jsx10(
10225
- Flex,
10226
- {
10227
- $position: "absolute",
10228
- $right: "1rem",
10229
- $top: "1rem",
10230
- $fontSize: "0.625rem",
10231
- $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
10232
- $backgroundColor: theme.primary,
10233
- $borderRadius: "9999px",
10234
- $padding: "0.125rem 0.85rem",
10235
- children: "Current plan"
10236
- }
10237
- )
10238
- ]
10428
+ /* @__PURE__ */ jsx9(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx9(Box, { $fontSize: "12px", $color: "#5D5D5D", children: "Expires: 3/30" }) })
10429
+ ] })
10239
10430
  }
10240
10431
  ),
10241
- /* @__PURE__ */ jsx10(
10242
- Flex,
10432
+ /* @__PURE__ */ jsx9(Flex, { children: /* @__PURE__ */ jsx9(
10433
+ StyledButton,
10243
10434
  {
10244
- $flexDirection: "column",
10245
- $position: "relative",
10246
- $gap: "0.5rem",
10247
- $flex: "1",
10248
- $width: "100%",
10249
- $height: "auto",
10250
- $padding: "1.5rem",
10251
- children: plan.features.map((feature) => {
10252
- return /* @__PURE__ */ jsxs5(
10253
- Flex,
10254
- {
10255
- $flexShrink: "0",
10256
- $gap: "1rem",
10257
- children: [
10258
- /* @__PURE__ */ jsx10(
10259
- IconRound,
10260
- {
10261
- name: feature.icon,
10262
- size: "tn",
10263
- colors: [
10264
- theme.primary,
10265
- isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.0625)"
10266
- ]
10267
- }
10268
- ),
10269
- /* @__PURE__ */ jsx10(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx10(Text, { $size: 12, children: feature.name }) })
10270
- ]
10271
- },
10272
- feature.id
10273
- );
10274
- })
10435
+ $size: "sm",
10436
+ $color: "primary",
10437
+ $variant: "outline",
10438
+ style: {
10439
+ whiteSpace: "nowrap",
10440
+ paddingLeft: "1rem",
10441
+ paddingRight: "1rem"
10442
+ },
10443
+ children: "Edit"
10275
10444
  }
10276
- ),
10277
- /* @__PURE__ */ jsxs5(
10445
+ ) })
10446
+ ] })
10447
+ ] })
10448
+ }
10449
+ ),
10450
+ /* @__PURE__ */ jsx9(
10451
+ Flex,
10452
+ {
10453
+ $flexDirection: "column",
10454
+ $gap: "1rem",
10455
+ $backgroundColor: "#FBFBFB",
10456
+ $borderRadius: "0 0 0.5rem 0.5rem",
10457
+ $flex: "1",
10458
+ $height: "100%",
10459
+ children: /* @__PURE__ */ jsxs4(Flex, { $flexDirection: "column", $height: "100%", children: [
10460
+ /* @__PURE__ */ jsx9(
10461
+ Box,
10462
+ {
10463
+ $fontSize: "18px",
10464
+ $marginBottom: "1.5rem",
10465
+ $display: "inline-block",
10466
+ $width: "100%",
10467
+ children: "Others"
10468
+ }
10469
+ ),
10470
+ /* @__PURE__ */ jsxs4(Flex, { $gap: "1rem", children: [
10471
+ /* @__PURE__ */ jsx9(
10278
10472
  Flex,
10279
10473
  {
10280
- $flexDirection: "column",
10281
- $position: "relative",
10474
+ $alignItems: "center",
10475
+ $padding: ".5rem 1rem",
10476
+ $border: "1px solid #E2E5E9",
10477
+ $borderRadius: ".5rem",
10478
+ $backgroundColor: "#ffffff",
10282
10479
  $gap: "1rem",
10283
10480
  $width: "100%",
10284
- $height: "auto",
10285
- $padding: "1.5rem",
10286
- children: [
10287
- plan.id === selectedPlan?.id && /* @__PURE__ */ jsxs5(
10288
- Flex,
10289
- {
10290
- $justifyContent: "center",
10291
- $alignItems: "center",
10292
- $gap: "0.25rem",
10293
- $fontSize: "0.9375rem",
10294
- $padding: "0.625rem 0",
10295
- children: [
10296
- /* @__PURE__ */ jsx10(
10297
- Icon2,
10298
- {
10299
- name: "check-rounded",
10300
- style: {
10301
- fontSize: 20,
10302
- lineHeight: "1",
10303
- color: theme.primary
10481
+ children: /* @__PURE__ */ jsxs4(Flex, { $justifyContent: "space-between", $flex: "1", children: [
10482
+ /* @__PURE__ */ jsxs4(Flex, { $alignItems: "center", $gap: "1rem", children: [
10483
+ /* @__PURE__ */ jsx9(Box, { $display: "inline-block", children: /* @__PURE__ */ jsx9(
10484
+ "svg",
10485
+ {
10486
+ viewBox: "0 0 24 16",
10487
+ fill: "none",
10488
+ xmlns: "http://www.w3.org/2000/svg",
10489
+ width: "26px",
10490
+ height: "auto",
10491
+ children: /* @__PURE__ */ jsxs4("g", { children: [
10492
+ /* @__PURE__ */ jsx9(
10493
+ "rect",
10494
+ {
10495
+ stroke: "#DDD",
10496
+ fill: "#FFF",
10497
+ x: ".25",
10498
+ y: ".25",
10499
+ width: "23",
10500
+ height: "15.5",
10501
+ rx: "2"
10304
10502
  }
10305
- }
10306
- ),
10307
- /* @__PURE__ */ jsx10(
10308
- Text,
10309
- {
10310
- $lineHeight: "1.4",
10311
- $color: theme.typography.text.color,
10312
- children: "Selected"
10313
- }
10314
- )
10315
- ]
10316
- }
10317
- ),
10318
- !(plan.current || plan.id === currentPlan?.id) && plan.id !== selectedPlan?.id && /* @__PURE__ */ jsx10(
10319
- StyledButton,
10320
- {
10321
- disabled: plan.valid === false,
10322
- ...plan.valid === true && {
10323
- onClick: () => setSelectedPlan(plan)
10324
- },
10325
- $size: "sm",
10326
- $color: "primary",
10327
- $variant: "outline",
10328
- children: "Select"
10329
- }
10330
- )
10331
- ]
10503
+ ),
10504
+ /* @__PURE__ */ jsx9(
10505
+ "path",
10506
+ {
10507
+ d: "M2.788 5.914A7.201 7.201 0 0 0 1 5.237l.028-.125h2.737c.371.013.672.125.77.519l.595 2.836.182.854 1.666-4.21h1.799l-2.674 6.167H4.304L2.788 5.914Zm7.312 5.37H8.399l1.064-6.172h1.7L10.1 11.284Zm6.167-6.021-.232 1.333-.153-.066a3.054 3.054 0 0 0-1.268-.236c-.671 0-.972.269-.98.531 0 .29.365.48.96.762.98.44 1.435.979 1.428 1.681-.014 1.28-1.176 2.108-2.96 2.108-.764-.007-1.5-.158-1.898-.328l.238-1.386.224.099c.553.23.917.328 1.596.328.49 0 1.015-.19 1.022-.604 0-.27-.224-.466-.882-.769-.644-.295-1.505-.788-1.491-1.674C11.878 5.84 13.06 5 14.74 5c.658 0 1.19.138 1.526.263Zm2.26 3.834h1.415c-.07-.308-.392-1.786-.392-1.786l-.12-.531c-.083.23-.23.604-.223.59l-.68 1.727Zm2.1-3.985L22 11.284h-1.575s-.154-.71-.203-.926h-2.184l-.357.926h-1.785l2.527-5.66c.175-.4.483-.512.889-.512h1.316Z",
10508
+ fill: "#1434CB"
10509
+ }
10510
+ )
10511
+ ] })
10512
+ }
10513
+ ) }),
10514
+ /* @__PURE__ */ jsx9(Box, { $whiteSpace: "nowrap", children: "Visa **** 2929" })
10515
+ ] }),
10516
+ /* @__PURE__ */ jsx9(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx9(Box, { $fontSize: "12px", $color: "#5D5D5D", children: "Expires: 3/30" }) })
10517
+ ] })
10332
10518
  }
10333
- )
10334
- ]
10335
- },
10336
- plan.id
10337
- );
10338
- }) })
10339
- ] }),
10340
- selectedPlan && checkoutStage === "checkout" && /* @__PURE__ */ jsx10(
10341
- PaymentForm,
10342
- {
10343
- plan: selectedPlan,
10344
- period: planPeriod,
10345
- onConfirm: (value) => {
10346
- setPaymentMethodId(value);
10347
- }
10348
- }
10349
- )
10350
- ]
10351
- }
10352
- ),
10353
- /* @__PURE__ */ jsxs5(
10354
- Flex,
10355
- {
10356
- $flexDirection: "column",
10357
- $backgroundColor: theme.card.background,
10358
- $borderRadius: "0 0 0.5rem",
10359
- $width: "21.5rem",
10360
- $boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
10361
- children: [
10362
- /* @__PURE__ */ jsxs5(
10363
- Flex,
10364
- {
10365
- $flexDirection: "column",
10366
- $position: "relative",
10367
- $gap: "1rem",
10368
- $width: "100%",
10369
- $height: "auto",
10370
- $padding: "1.5rem",
10371
- $borderBottomWidth: "1px",
10372
- $borderStyle: "solid",
10373
- $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)",
10374
- children: [
10375
- /* @__PURE__ */ jsx10(Flex, { $justifyContent: "space-between", children: /* @__PURE__ */ jsx10(
10376
- Text,
10377
- {
10378
- as: "h3",
10379
- $font: theme.typography.heading3.fontFamily,
10380
- $size: theme.typography.heading3.fontSize,
10381
- $weight: theme.typography.heading3.fontWeight,
10382
- $color: theme.typography.heading3.color,
10383
- children: "Subscription"
10384
- }
10385
- ) }),
10386
- /* @__PURE__ */ jsxs5(
10387
- Flex,
10388
- {
10389
- $borderWidth: "1px",
10390
- $borderStyle: "solid",
10391
- $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)",
10392
- $borderRadius: "2.5rem",
10393
- $cursor: "pointer",
10394
- children: [
10395
- /* @__PURE__ */ jsx10(
10396
- Flex,
10519
+ ),
10520
+ /* @__PURE__ */ jsxs4(Flex, { $gap: "1rem", children: [
10521
+ /* @__PURE__ */ jsx9(
10522
+ StyledButton,
10397
10523
  {
10398
- onClick: () => setPlanPeriod("month"),
10399
- $justifyContent: "center",
10400
- $alignItems: "center",
10401
- $padding: "0.25rem 0.5rem",
10402
- $flex: "1",
10403
- ...planPeriod === "month" && {
10404
- $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.075)" : "hsla(0, 0%, 100%, 0.15)"
10524
+ $size: "sm",
10525
+ $color: "primary",
10526
+ $variant: "outline",
10527
+ style: {
10528
+ whiteSpace: "nowrap",
10529
+ paddingLeft: "1rem",
10530
+ paddingRight: "1rem"
10405
10531
  },
10406
- $borderRadius: "2.5rem",
10407
- children: /* @__PURE__ */ jsx10(
10408
- Text,
10409
- {
10410
- $font: theme.typography.text.fontFamily,
10411
- $size: 14,
10412
- $weight: planPeriod === "month" ? 600 : 400,
10413
- $color: theme.typography.text.color,
10414
- children: "Billed monthly"
10415
- }
10416
- )
10532
+ children: "Make Default"
10417
10533
  }
10418
10534
  ),
10419
- /* @__PURE__ */ jsx10(
10420
- Flex,
10535
+ /* @__PURE__ */ jsx9(
10536
+ StyledButton,
10421
10537
  {
10422
- onClick: () => setPlanPeriod("year"),
10423
- $justifyContent: "center",
10424
- $alignItems: "center",
10425
- $padding: "0.25rem 0.5rem",
10426
- $flex: "1",
10427
- ...planPeriod === "year" && {
10428
- $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.075)" : "hsla(0, 0%, 100%, 0.15)"
10538
+ $size: "sm",
10539
+ $color: "primary",
10540
+ $variant: "outline",
10541
+ style: {
10542
+ whiteSpace: "nowrap",
10543
+ paddingLeft: "1rem",
10544
+ paddingRight: "1rem"
10429
10545
  },
10430
- $borderRadius: "2.5rem",
10431
- children: /* @__PURE__ */ jsx10(
10432
- Text,
10433
- {
10434
- $font: theme.typography.text.fontFamily,
10435
- $size: 14,
10436
- $weight: planPeriod === "year" ? 600 : 400,
10437
- $color: theme.typography.text.color,
10438
- children: "Billed yearly"
10439
- }
10440
- )
10546
+ children: "Edit"
10441
10547
  }
10442
10548
  )
10443
- ]
10444
- }
10445
- ),
10446
- savingsPercentage > 0 && /* @__PURE__ */ jsx10(Box, { children: /* @__PURE__ */ jsx10(
10447
- Text,
10448
- {
10449
- $font: theme.typography.text.fontFamily,
10450
- $size: 11,
10451
- $weight: theme.typography.text.fontWeight,
10452
- $color: theme.primary,
10453
- children: planPeriod === "month" ? `Save up to ${savingsPercentage}% with yearly billing` : `You are saving ${savingsPercentage}% with yearly billing`
10454
- }
10455
- ) })
10456
- ]
10457
- }
10458
- ),
10459
- /* @__PURE__ */ jsxs5(
10460
- Flex,
10461
- {
10462
- $flexDirection: "column",
10463
- $position: "relative",
10464
- $gap: "1rem",
10465
- $width: "100%",
10466
- $height: "auto",
10467
- $padding: "1.5rem",
10468
- $flex: "1",
10469
- $borderBottomWidth: "1px",
10470
- $borderStyle: "solid",
10471
- $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)",
10472
- children: [
10473
- /* @__PURE__ */ jsx10(Box, { $opacity: "0.625", children: /* @__PURE__ */ jsx10(
10474
- Text,
10475
- {
10476
- $font: theme.typography.text.fontFamily,
10477
- $size: 14,
10478
- $weight: theme.typography.text.fontWeight,
10479
- $color: theme.typography.text.color,
10480
- children: "Plan"
10481
- }
10482
- ) }),
10483
- /* @__PURE__ */ jsxs5(Flex, { $flexDirection: "column", $gap: "0.5rem", children: [
10484
- currentPlan && /* @__PURE__ */ jsxs5(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
10485
- /* @__PURE__ */ jsx10(
10486
- Flex,
10487
- {
10488
- ...selectedPlan && {
10489
- $opacity: "0.625",
10490
- $textDecoration: "line-through"
10491
- },
10492
- children: /* @__PURE__ */ jsx10(
10493
- Text,
10494
- {
10495
- $font: theme.typography.heading4.fontFamily,
10496
- $size: theme.typography.heading4.fontSize,
10497
- $weight: theme.typography.heading4.fontWeight,
10498
- $color: theme.typography.heading4.color,
10499
- children: currentPlan.name
10500
- }
10501
- )
10502
- }
10503
- ),
10504
- typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ jsx10(Flex, { children: /* @__PURE__ */ jsxs5(
10505
- Text,
10506
- {
10507
- $font: theme.typography.text.fontFamily,
10508
- $size: theme.typography.text.fontSize,
10509
- $weight: theme.typography.text.fontWeight,
10510
- $color: theme.typography.text.color,
10511
- children: [
10512
- formatCurrency(currentPlan.planPrice),
10513
- "/",
10514
- currentPlan.planPeriod
10515
- ]
10516
- }
10517
- ) })
10518
- ] }),
10519
- selectedPlan && /* @__PURE__ */ jsxs5(Fragment, { children: [
10520
- /* @__PURE__ */ jsx10(
10521
- Box,
10522
- {
10523
- $width: "100%",
10524
- $textAlign: "left",
10525
- $opacity: "50%",
10526
- $marginBottom: "-0.25rem",
10527
- $marginTop: "-0.25rem",
10528
- children: /* @__PURE__ */ jsx10(
10529
- Icon2,
10530
- {
10531
- name: "arrow-down",
10532
- style: {
10533
- display: "inline-block"
10534
- }
10535
- }
10536
- )
10537
- }
10538
- ),
10539
- /* @__PURE__ */ jsxs5(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
10540
- /* @__PURE__ */ jsx10(Flex, { children: /* @__PURE__ */ jsx10(
10541
- Text,
10542
- {
10543
- $font: theme.typography.heading4.fontFamily,
10544
- $size: theme.typography.heading4.fontSize,
10545
- $weight: theme.typography.heading4.fontWeight,
10546
- $color: theme.typography.heading4.color,
10547
- children: selectedPlan.name
10548
- }
10549
- ) }),
10550
- /* @__PURE__ */ jsx10(Flex, { children: /* @__PURE__ */ jsxs5(
10551
- Text,
10552
- {
10553
- $font: theme.typography.text.fontFamily,
10554
- $size: theme.typography.text.fontSize,
10555
- $weight: theme.typography.text.fontWeight,
10556
- $color: theme.typography.text.color,
10557
- children: [
10558
- formatCurrency(
10559
- (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
10560
- ),
10561
- "/",
10562
- planPeriod
10563
- ]
10564
- }
10565
- ) })
10566
10549
  ] })
10567
10550
  ] })
10568
10551
  ] })
10569
- ]
10570
- }
10571
- ),
10572
- /* @__PURE__ */ jsxs5(
10573
- Flex,
10552
+ }
10553
+ )
10554
+ ]
10555
+ }
10556
+ )
10557
+ ] }),
10558
+ portal || document.body
10559
+ )
10560
+ ] });
10561
+ });
10562
+
10563
+ // src/components/elements/plan-manager/PaymentForm.tsx
10564
+ import { useState as useState2 } from "react";
10565
+ import {
10566
+ LinkAuthenticationElement,
10567
+ PaymentElement
10568
+ } from "@stripe/react-stripe-js";
10569
+ import { useStripe, useElements } from "@stripe/react-stripe-js";
10570
+ import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
10571
+ var PaymentForm = ({ plan, period, onConfirm }) => {
10572
+ const stripe = useStripe();
10573
+ const elements = useElements();
10574
+ const { api, data } = useEmbed();
10575
+ const [message, setMessage] = useState2(null);
10576
+ const [isLoading, setIsLoading] = useState2(false);
10577
+ const [isConfirmed, setIsConfirmed] = useState2(false);
10578
+ const handleSubmit = async (event) => {
10579
+ event.preventDefault();
10580
+ const priceId = period === "month" ? plan.monthlyPrice?.id : plan.yearlyPrice?.id;
10581
+ if (!api || !stripe || !elements || !priceId) {
10582
+ return;
10583
+ }
10584
+ setIsLoading(true);
10585
+ setIsConfirmed(false);
10586
+ setMessage(null);
10587
+ try {
10588
+ const { setupIntent, error } = await stripe.confirmSetup({
10589
+ elements,
10590
+ confirmParams: {
10591
+ return_url: window.location.href
10592
+ },
10593
+ redirect: "if_required"
10594
+ });
10595
+ if (onConfirm && typeof setupIntent?.payment_method === "string") {
10596
+ onConfirm(setupIntent.payment_method);
10597
+ setIsConfirmed(true);
10598
+ } else {
10599
+ }
10600
+ if (error?.type === "card_error" || error?.type === "validation_error") {
10601
+ setMessage(error.message);
10602
+ }
10603
+ } catch (error) {
10604
+ setMessage("A problem occurred while saving your payment method.");
10605
+ } finally {
10606
+ setIsLoading(false);
10607
+ }
10608
+ };
10609
+ return /* @__PURE__ */ jsxs5(
10610
+ "form",
10611
+ {
10612
+ id: "payment-form",
10613
+ onSubmit: handleSubmit,
10614
+ style: {
10615
+ display: "flex",
10616
+ flexDirection: "column",
10617
+ overflowX: "hidden",
10618
+ overflowY: "auto"
10619
+ },
10620
+ children: [
10621
+ /* @__PURE__ */ jsx10(Box, { $width: "100%", $marginBottom: "1.5rem", children: /* @__PURE__ */ jsx10(Text, { $size: 18, children: "Add payment method" }) }),
10622
+ /* @__PURE__ */ jsx10(
10623
+ Flex,
10624
+ {
10625
+ $flexDirection: "column",
10626
+ $gap: "1.5rem",
10627
+ $width: "100%",
10628
+ $marginBottom: "1.5rem",
10629
+ children: /* @__PURE__ */ jsx10(
10630
+ LinkAuthenticationElement,
10574
10631
  {
10575
- $flexDirection: "column",
10576
- $position: "relative",
10577
- $gap: "1rem",
10578
- $width: "100%",
10579
- $height: "auto",
10580
- $padding: "1.5rem",
10581
- children: [
10582
- selectedPlan && /* @__PURE__ */ jsxs5(Flex, { $justifyContent: "space-between", children: [
10583
- /* @__PURE__ */ jsx10(Box, { $opacity: "0.625", children: /* @__PURE__ */ jsxs5(
10584
- Text,
10585
- {
10586
- $font: theme.typography.text.fontFamily,
10587
- $size: theme.typography.text.fontSize,
10588
- $weight: theme.typography.text.fontWeight,
10589
- $color: theme.typography.text.color,
10590
- children: [
10591
- planPeriod === "month" ? "Monthly" : "Yearly",
10592
- " total:",
10593
- " "
10594
- ]
10595
- }
10596
- ) }),
10597
- /* @__PURE__ */ jsx10(Box, { children: /* @__PURE__ */ jsxs5(
10598
- Text,
10599
- {
10600
- $font: theme.typography.text.fontFamily,
10601
- $size: theme.typography.text.fontSize,
10602
- $weight: theme.typography.text.fontWeight,
10603
- $color: theme.typography.text.color,
10604
- children: [
10605
- formatCurrency(
10606
- (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
10607
- ),
10608
- "/",
10609
- planPeriod
10610
- ]
10611
- }
10612
- ) })
10613
- ] }),
10614
- checkoutStage === "plan" ? /* @__PURE__ */ jsx10(
10615
- StyledButton,
10616
- {
10617
- disabled: !selectedPlan,
10618
- ...selectedPlan && {
10619
- onClick: () => setCheckoutStage("checkout")
10620
- },
10621
- $size: "sm",
10622
- children: /* @__PURE__ */ jsxs5(
10623
- Flex,
10624
- {
10625
- $gap: "0.5rem",
10626
- $justifyContent: "center",
10627
- $alignItems: "center",
10628
- $padding: "0 1rem",
10629
- children: [
10630
- /* @__PURE__ */ jsx10(Text, { $align: "left", children: "Next: Checkout" }),
10631
- /* @__PURE__ */ jsx10(Icon2, { name: "arrow-right" })
10632
- ]
10633
- }
10634
- )
10635
- }
10636
- ) : /* @__PURE__ */ jsx10(
10637
- StyledButton,
10638
- {
10639
- disabled: !api || !selectedPlan || selectedPlan?.id === currentPlan?.id || !paymentMethodId || isLoading,
10640
- onClick: async () => {
10641
- const priceId = (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.id;
10642
- if (!api || !selectedPlan || !priceId || !paymentMethodId) {
10643
- return;
10644
- }
10645
- try {
10646
- setIsLoading(true);
10647
- setIsCheckoutComplete(false);
10648
- await api.checkout({
10649
- changeSubscriptionRequestBody: {
10650
- newPlanId: selectedPlan.id,
10651
- newPriceId: priceId,
10652
- paymentMethodId
10653
- }
10654
- });
10655
- setIsCheckoutComplete(true);
10656
- } catch {
10657
- setError(
10658
- "Error processing payment. Please try a different payment method."
10659
- );
10660
- } finally {
10661
- setIsLoading(false);
10662
- }
10663
- },
10664
- $size: "md",
10665
- children: "Pay now"
10666
- }
10667
- ),
10668
- /* @__PURE__ */ jsx10(Box, { $opacity: "0.625", children: /* @__PURE__ */ jsx10(
10669
- Text,
10670
- {
10671
- $font: theme.typography.text.fontFamily,
10672
- $size: theme.typography.text.fontSize,
10673
- $weight: theme.typography.text.fontWeight,
10674
- $color: theme.typography.text.color,
10675
- children: "Discounts & credits applied at checkout"
10676
- }
10677
- ) }),
10678
- error && /* @__PURE__ */ jsx10(Box, { children: /* @__PURE__ */ jsx10(
10679
- Text,
10680
- {
10681
- $font: theme.typography.text.fontFamily,
10682
- $size: theme.typography.text.fontSize,
10683
- $weight: 500,
10684
- $color: "#DB6669",
10685
- children: error
10686
- }
10687
- ) })
10688
- ]
10632
+ id: "link-authentication-element"
10689
10633
  }
10690
10634
  )
10691
- ]
10692
- }
10693
- )
10694
- ] })
10695
- ] });
10635
+ }
10636
+ ),
10637
+ /* @__PURE__ */ jsx10(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ jsx10(PaymentElement, { id: "payment-element" }) }),
10638
+ /* @__PURE__ */ jsx10(
10639
+ StyledButton,
10640
+ {
10641
+ id: "submit",
10642
+ disabled: isLoading || !stripe || !elements || !data.stripeEmbed?.publishableKey || !data.stripeEmbed?.setupIntentClientSecret || isConfirmed,
10643
+ $size: "md",
10644
+ $color: "primary",
10645
+ children: /* @__PURE__ */ jsx10(Text, { id: "button-text", children: isLoading ? "Loading" : "Save payment method" })
10646
+ }
10647
+ ),
10648
+ message && /* @__PURE__ */ jsx10(Box, { $margin: "1rem 0", children: /* @__PURE__ */ jsx10(Text, { id: "payment-message", $size: 15, $weight: 500, $color: "#DB6669", children: message }) })
10649
+ ]
10650
+ }
10651
+ );
10696
10652
  };
10697
10653
 
10698
- // src/components/elements/plan-manager/PlanManager.tsx
10699
- import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
10700
- var resolveDesignProps = (props) => {
10701
- return {
10702
- header: {
10703
- isVisible: props.header?.isVisible ?? true,
10704
- title: {
10705
- fontStyle: props.header?.title?.fontStyle ?? "heading1"
10706
- },
10707
- description: {
10708
- isVisible: props.header?.description?.isVisible ?? true,
10709
- fontStyle: props.header?.description?.fontStyle ?? "text"
10710
- },
10711
- price: {
10712
- isVisible: props.header?.price?.isVisible ?? true,
10713
- fontStyle: props.header?.price?.fontStyle ?? "text"
10654
+ // src/components/elements/plan-manager/CheckoutDialog.tsx
10655
+ import { Fragment, jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
10656
+ var FeatureName = ({
10657
+ entitlement
10658
+ }) => {
10659
+ const theme = nt();
10660
+ if (!entitlement.feature?.name) {
10661
+ return null;
10662
+ }
10663
+ if (entitlement.valueType === "numeric" || entitlement.valueType === "trait") {
10664
+ let period;
10665
+ if (entitlement.metricPeriod) {
10666
+ period = {
10667
+ current_day: "day",
10668
+ current_month: "mo",
10669
+ current_year: "yr"
10670
+ }[entitlement.metricPeriod];
10671
+ }
10672
+ return /* @__PURE__ */ jsx11(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsxs6(
10673
+ Text,
10674
+ {
10675
+ $font: theme.typography.text.fontFamily,
10676
+ $size: theme.typography.text.fontSize,
10677
+ $weight: theme.typography.text.fontWeight,
10678
+ $color: theme.typography.text.color,
10679
+ children: [
10680
+ typeof entitlement.valueNumeric === "number" ? (0, import_pluralize.default)(
10681
+ entitlement.feature.name,
10682
+ entitlement.valueNumeric,
10683
+ true
10684
+ ) : `Unlimited ${(0, import_pluralize.default)(entitlement.feature.name)}`,
10685
+ period && `/${period}`
10686
+ ]
10714
10687
  }
10715
- },
10716
- addOns: {
10717
- isVisible: props.addOns?.isVisible ?? true,
10718
- fontStyle: props.addOns?.fontStyle ?? "heading4",
10719
- showLabel: props.addOns?.showLabel ?? true
10720
- },
10721
- callToAction: {
10722
- isVisible: props.callToAction?.isVisible ?? true,
10723
- buttonSize: props.callToAction?.buttonSize ?? "lg",
10724
- buttonStyle: props.callToAction?.buttonStyle ?? "primary"
10688
+ ) });
10689
+ }
10690
+ return /* @__PURE__ */ jsx11(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx11(
10691
+ Text,
10692
+ {
10693
+ $font: theme.typography.text.fontFamily,
10694
+ $size: theme.typography.text.fontSize,
10695
+ $weight: theme.typography.text.fontWeight,
10696
+ $color: theme.typography.text.color,
10697
+ children: entitlement.feature.name
10725
10698
  }
10726
- };
10699
+ ) });
10727
10700
  };
10728
- var PlanManager = forwardRef(({ children, className, portal, ...rest }, ref) => {
10729
- const props = resolveDesignProps(rest);
10701
+ var CheckoutDialog = () => {
10730
10702
  const theme = nt();
10731
- const { data, layout, stripe, setLayout } = useEmbed();
10732
- const { currentPlan, canChangePlan } = useMemo6(() => {
10733
- return {
10734
- currentPlan: data.company?.plan,
10735
- canChangePlan: stripe !== null
10736
- };
10737
- }, [data.company, stripe]);
10738
- return /* @__PURE__ */ jsxs6("div", { ref, className, children: [
10739
- /* @__PURE__ */ jsx11(
10740
- Flex,
10741
- {
10742
- $flexDirection: "column",
10743
- $gap: "0.75rem",
10744
- ...canChangePlan && { $margin: "0 0 0.5rem" },
10745
- children: props.header.isVisible && currentPlan && /* @__PURE__ */ jsxs6(
10746
- Flex,
10703
+ const { api, data, setLayout } = useEmbed();
10704
+ const [checkoutStage, setCheckoutStage] = useState3(
10705
+ "plan"
10706
+ );
10707
+ const [planPeriod, setPlanPeriod] = useState3(
10708
+ () => data.company?.plan?.planPeriod || "month"
10709
+ );
10710
+ const [selectedPlan, setSelectedPlan] = useState3();
10711
+ const [paymentMethodId, setPaymentMethodId] = useState3();
10712
+ const [isLoading, setIsLoading] = useState3(false);
10713
+ const [error, setError] = useState3();
10714
+ const [showPaymentForm, setShowPaymentForm] = useState3(
10715
+ () => typeof data.subscription?.paymentMethod === "undefined"
10716
+ );
10717
+ const { paymentMethod, currentPlan, availablePlans, planPeriodOptions } = useMemo6(() => {
10718
+ const showMonthlyPriceOption = data.activePlans.some(
10719
+ (plan) => typeof plan.yearlyPrice !== "undefined"
10720
+ );
10721
+ const showYearlyPriceOption = data.activePlans.some(
10722
+ (plan) => typeof plan.yearlyPrice !== "undefined"
10723
+ );
10724
+ const planPeriodOptions2 = [];
10725
+ if (showMonthlyPriceOption) {
10726
+ planPeriodOptions2.push("month");
10727
+ }
10728
+ if (showYearlyPriceOption) {
10729
+ planPeriodOptions2.push("year");
10730
+ }
10731
+ return {
10732
+ paymentMethod: data.subscription?.paymentMethod,
10733
+ currentPlan: data.company?.plan,
10734
+ availablePlans: data.activePlans.filter(
10735
+ (plan) => plan.current || plan.yearlyPrice && planPeriod === "year" || plan.monthlyPrice && planPeriod === "month"
10736
+ ),
10737
+ planPeriodOptions: planPeriodOptions2
10738
+ };
10739
+ }, [
10740
+ data.subscription?.paymentMethod,
10741
+ data.company,
10742
+ data.activePlans,
10743
+ planPeriod
10744
+ ]);
10745
+ const savingsPercentage = useMemo6(() => {
10746
+ if (selectedPlan) {
10747
+ const monthly = (selectedPlan?.monthlyPrice?.price || 0) * 12;
10748
+ const yearly = selectedPlan?.yearlyPrice?.price || 0;
10749
+ return Math.round((monthly - yearly) / monthly * 1e4) / 100;
10750
+ }
10751
+ return 0;
10752
+ }, [selectedPlan]);
10753
+ const isLightBackground = useMemo6(() => {
10754
+ return hexToHSL(theme.card.background).l > 50;
10755
+ }, [theme.card.background]);
10756
+ const allowCheckout = api && selectedPlan && selectedPlan?.id !== currentPlan?.id && (paymentMethod && !showPaymentForm || paymentMethodId) && !isLoading;
10757
+ return /* @__PURE__ */ jsxs6(Modal, { size: "lg", children: [
10758
+ /* @__PURE__ */ jsx11(ModalHeader, { bordered: true, children: /* @__PURE__ */ jsxs6(Flex, { $gap: "1rem", children: [
10759
+ /* @__PURE__ */ jsxs6(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
10760
+ checkoutStage === "plan" ? /* @__PURE__ */ jsx11(
10761
+ Box,
10747
10762
  {
10748
- $justifyContent: "space-between",
10749
- $alignItems: "center",
10750
- $width: "100%",
10751
- ...canChangePlan && { $margin: "0 0 1.5rem" },
10752
- children: [
10753
- /* @__PURE__ */ jsxs6("div", { children: [
10754
- /* @__PURE__ */ jsx11(Box, { $margin: "0 0 0.75rem", children: /* @__PURE__ */ jsx11(
10763
+ $width: `${20 / TEXT_BASE_SIZE}rem`,
10764
+ $height: `${20 / TEXT_BASE_SIZE}rem`,
10765
+ $borderWidth: "2px",
10766
+ $borderStyle: "solid",
10767
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.25)",
10768
+ $borderRadius: "9999px"
10769
+ }
10770
+ ) : /* @__PURE__ */ jsx11(
10771
+ IconRound,
10772
+ {
10773
+ name: "check",
10774
+ colors: [
10775
+ theme.card.background,
10776
+ isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.25)"
10777
+ ],
10778
+ style: {
10779
+ fontSize: `${16 / TEXT_BASE_SIZE}rem`,
10780
+ width: `${20 / TEXT_BASE_SIZE}rem`,
10781
+ height: `${20 / TEXT_BASE_SIZE}rem`
10782
+ }
10783
+ }
10784
+ ),
10785
+ /* @__PURE__ */ jsx11(
10786
+ Box,
10787
+ {
10788
+ tabIndex: 0,
10789
+ ...checkoutStage !== "plan" && {
10790
+ onClick: () => setCheckoutStage("plan"),
10791
+ $opacity: "0.6375",
10792
+ $cursor: "pointer"
10793
+ },
10794
+ children: /* @__PURE__ */ jsx11(
10795
+ Text,
10796
+ {
10797
+ $font: theme.typography.text.fontFamily,
10798
+ $size: 19,
10799
+ $weight: checkoutStage === "plan" ? 600 : 400,
10800
+ $color: theme.typography.text.color,
10801
+ children: "1. Select plan"
10802
+ }
10803
+ )
10804
+ }
10805
+ )
10806
+ ] }),
10807
+ /* @__PURE__ */ jsx11(
10808
+ Icon2,
10809
+ {
10810
+ name: "chevron-right",
10811
+ style: {
10812
+ fontSize: 16,
10813
+ color: isLightBackground ? "hsla(0, 0%, 0%, 0.175)" : "hsla(0, 0%, 100%, 0.35)"
10814
+ }
10815
+ }
10816
+ ),
10817
+ /* @__PURE__ */ jsxs6(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
10818
+ /* @__PURE__ */ jsx11(
10819
+ Box,
10820
+ {
10821
+ $width: `${20 / TEXT_BASE_SIZE}rem`,
10822
+ $height: `${20 / TEXT_BASE_SIZE}rem`,
10823
+ $borderWidth: "2px",
10824
+ $borderStyle: "solid",
10825
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.125)" : "hsla(0, 0%, 100%, 0.25)",
10826
+ $borderRadius: "9999px"
10827
+ }
10828
+ ),
10829
+ /* @__PURE__ */ jsx11(
10830
+ Box,
10831
+ {
10832
+ tabIndex: 0,
10833
+ ...checkoutStage !== "checkout" && {
10834
+ $opacity: "0.6375"
10835
+ },
10836
+ children: /* @__PURE__ */ jsx11(
10837
+ Text,
10838
+ {
10839
+ $font: theme.typography.text.fontFamily,
10840
+ $size: 19,
10841
+ $weight: checkoutStage === "plan" ? 600 : 400,
10842
+ $color: theme.typography.text.color,
10843
+ children: "2. Checkout"
10844
+ }
10845
+ )
10846
+ }
10847
+ )
10848
+ ] })
10849
+ ] }) }),
10850
+ /* @__PURE__ */ jsxs6(Flex, { $position: "relative", $height: "calc(100% - 5rem)", children: [
10851
+ /* @__PURE__ */ jsxs6(
10852
+ Flex,
10853
+ {
10854
+ $flexDirection: "column",
10855
+ $flexGrow: "1",
10856
+ $gap: "1rem",
10857
+ $padding: "2rem 2.5rem 2rem 2.5rem",
10858
+ $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.025)" : "hsla(0, 0%, 100%, 0.025)",
10859
+ $flex: "1",
10860
+ $overflow: "auto",
10861
+ children: [
10862
+ checkoutStage === "plan" && /* @__PURE__ */ jsxs6(Fragment, { children: [
10863
+ /* @__PURE__ */ jsxs6(Flex, { $flexDirection: "column", $gap: "1rem", $marginBottom: "1rem", children: [
10864
+ /* @__PURE__ */ jsx11(
10755
10865
  Text,
10756
10866
  {
10757
- $font: theme.typography[props.header.title.fontStyle].fontFamily,
10758
- $size: theme.typography[props.header.title.fontStyle].fontSize,
10759
- $weight: theme.typography[props.header.title.fontStyle].fontWeight,
10760
- $color: theme.typography[props.header.title.fontStyle].color,
10761
- $lineHeight: 1,
10762
- children: currentPlan.name
10867
+ as: "h3",
10868
+ id: "select-plan-dialog-label",
10869
+ $font: theme.typography.heading3.fontFamily,
10870
+ $size: theme.typography.heading3.fontSize,
10871
+ $weight: theme.typography.heading3.fontWeight,
10872
+ $color: theme.typography.heading3.color,
10873
+ $marginBottom: "0.5rem",
10874
+ children: "Select plan"
10763
10875
  }
10764
- ) }),
10765
- props.header.description.isVisible && currentPlan.description && /* @__PURE__ */ jsx11(
10876
+ ),
10877
+ /* @__PURE__ */ jsx11(
10766
10878
  Text,
10767
10879
  {
10768
- $font: theme.typography[props.header.description.fontStyle].fontFamily,
10769
- $size: theme.typography[props.header.description.fontStyle].fontSize,
10770
- $weight: theme.typography[props.header.description.fontStyle].fontWeight,
10771
- $color: theme.typography[props.header.description.fontStyle].color,
10772
- children: currentPlan.description
10880
+ as: "p",
10881
+ id: "select-plan-dialog-description",
10882
+ $font: theme.typography.text.fontFamily,
10883
+ $size: theme.typography.text.fontSize,
10884
+ $weight: theme.typography.text.fontWeight,
10885
+ $color: theme.typography.text.color,
10886
+ children: "Choose your base plan"
10773
10887
  }
10774
10888
  )
10775
10889
  ] }),
10776
- props.header.price.isVisible && typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ jsxs6(
10777
- Text,
10778
- {
10779
- $font: theme.typography[props.header.price.fontStyle].fontFamily,
10780
- $size: theme.typography[props.header.price.fontStyle].fontSize,
10781
- $weight: theme.typography[props.header.price.fontStyle].fontWeight,
10782
- $color: theme.typography[props.header.price.fontStyle].color,
10783
- children: [
10784
- formatCurrency(currentPlan.planPrice),
10785
- "/",
10786
- currentPlan.planPeriod
10787
- ]
10788
- }
10789
- )
10790
- ]
10791
- }
10792
- )
10793
- }
10794
- ),
10795
- canChangePlan && props.callToAction.isVisible && /* @__PURE__ */ jsx11(
10796
- StyledButton,
10797
- {
10798
- onClick: () => {
10799
- setLayout("checkout");
10800
- },
10801
- $size: props.callToAction.buttonSize,
10802
- $color: props.callToAction.buttonStyle,
10803
- children: "Change Plan"
10804
- }
10805
- ),
10806
- canChangePlan && layout === "checkout" && createPortal(/* @__PURE__ */ jsx11(CheckoutDialog, {}), portal || document.body)
10807
- ] });
10808
- });
10809
-
10810
- // src/components/elements/included-features/IncludedFeatures.tsx
10811
- import { forwardRef as forwardRef2, useMemo as useMemo7 } from "react";
10812
- import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
10813
- function resolveDesignProps2(props) {
10814
- return {
10815
- header: {
10816
- isVisible: props.header?.isVisible ?? true,
10817
- fontStyle: props.header?.fontStyle ?? "heading4",
10818
- text: props.header?.text ?? "Included features"
10819
- },
10820
- icons: {
10821
- isVisible: props.icons?.isVisible ?? true,
10822
- fontStyle: props.icons?.fontStyle ?? "heading5",
10823
- style: props.icons?.style ?? "light"
10824
- },
10825
- entitlement: {
10826
- isVisible: props.entitlement?.isVisible ?? true,
10827
- fontStyle: props.entitlement?.fontStyle ?? "text"
10828
- },
10829
- usage: {
10830
- isVisible: props.usage?.isVisible ?? true,
10831
- fontStyle: props.usage?.fontStyle ?? "heading6"
10832
- }
10833
- };
10834
- }
10835
- var IncludedFeatures = forwardRef2(({ className, ...rest }, ref) => {
10836
- const props = resolveDesignProps2(rest);
10837
- const theme = nt();
10838
- const { data } = useEmbed();
10839
- const features = useMemo7(() => {
10840
- return (data.featureUsage?.features || []).map(
10841
- ({
10842
- access,
10843
- allocation,
10844
- allocationType,
10845
- feature,
10846
- period,
10847
- usage = 0,
10848
- ...props2
10849
- }) => {
10850
- return {
10851
- access,
10852
- allocation,
10853
- allocationType,
10854
- feature,
10855
- period,
10856
- /**
10857
- * @TODO: resolve feature price
10858
- */
10859
- price: void 0,
10860
- usage,
10861
- ...props2
10862
- };
10863
- }
10864
- );
10865
- }, [data.featureUsage]);
10866
- const isLightBackground = useMemo7(() => {
10867
- return hexToHSL(theme.card.background).l > 50;
10868
- }, [theme.card.background]);
10869
- return /* @__PURE__ */ jsxs7(Flex, { ref, className, $flexDirection: "column", $gap: "1.5rem", children: [
10870
- props.header.isVisible && /* @__PURE__ */ jsx12(Box, { children: /* @__PURE__ */ jsx12(
10871
- Text,
10872
- {
10873
- $font: theme.typography[props.header.fontStyle].fontFamily,
10874
- $size: theme.typography[props.header.fontStyle].fontSize,
10875
- $weight: theme.typography[props.header.fontStyle].fontWeight,
10876
- $color: theme.typography[props.header.fontStyle].color,
10877
- children: props.header.text
10878
- }
10879
- ) }),
10880
- features.reduce(
10881
- (acc, { allocation, allocationType, feature, usage }, index) => {
10882
- if (!allocationType) {
10883
- return acc;
10884
- }
10885
- return [
10886
- ...acc,
10887
- /* @__PURE__ */ jsxs7(
10888
- Flex,
10889
- {
10890
- $flexWrap: "wrap",
10891
- $justifyContent: "space-between",
10892
- $alignItems: "center",
10893
- $gap: "1rem",
10894
- children: [
10895
- /* @__PURE__ */ jsxs7(Flex, { $gap: "1rem", children: [
10896
- props.icons.isVisible && feature?.icon && /* @__PURE__ */ jsx12(
10897
- IconRound,
10898
- {
10899
- name: feature.icon,
10900
- size: "sm",
10901
- colors: [
10902
- theme.primary,
10903
- isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.25)"
10904
- ]
10905
- }
10906
- ),
10907
- feature?.name && /* @__PURE__ */ jsx12(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx12(
10890
+ /* @__PURE__ */ jsx11(Flex, { $flexWrap: "wrap", $gap: "1rem", $flexGrow: "1", children: availablePlans?.map((plan) => {
10891
+ return /* @__PURE__ */ jsxs6(
10892
+ Flex,
10893
+ {
10894
+ $flexDirection: "column",
10895
+ $width: "100%",
10896
+ $minWidth: "280px",
10897
+ $maxWidth: `calc(${100 / 3}% - 1rem)`,
10898
+ $backgroundColor: theme.card.background,
10899
+ $outlineWidth: "2px",
10900
+ $outlineStyle: "solid",
10901
+ $outlineColor: plan.id === selectedPlan?.id ? theme.primary : "transparent",
10902
+ $borderRadius: `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`,
10903
+ ...theme.card.hasShadow && {
10904
+ $boxShadow: "0px 1px 3px rgba(16, 24, 40, 0.1), 0px 1px 20px rgba(16, 24, 40, 0.06)"
10905
+ },
10906
+ children: [
10907
+ /* @__PURE__ */ jsxs6(
10908
+ Flex,
10909
+ {
10910
+ $flexDirection: "column",
10911
+ $position: "relative",
10912
+ $gap: "1rem",
10913
+ $width: "100%",
10914
+ $height: "auto",
10915
+ $padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
10916
+ $borderBottomWidth: "1px",
10917
+ $borderStyle: "solid",
10918
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.175)" : "hsla(0, 0%, 100%, 0.175)",
10919
+ children: [
10920
+ /* @__PURE__ */ jsx11(Text, { $size: 20, $weight: 600, children: plan.name }),
10921
+ /* @__PURE__ */ jsx11(Text, { $size: 14, children: plan.description }),
10922
+ /* @__PURE__ */ jsxs6(Text, { children: [
10923
+ /* @__PURE__ */ jsx11(Box, { $display: "inline-block", $fontSize: "1.5rem", children: formatCurrency(
10924
+ (planPeriod === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0
10925
+ ) }),
10926
+ /* @__PURE__ */ jsxs6(Box, { $display: "inline-block", $fontSize: "0.75rem", children: [
10927
+ "/",
10928
+ planPeriod
10929
+ ] })
10930
+ ] }),
10931
+ (plan.current || plan.id === currentPlan?.id) && /* @__PURE__ */ jsx11(
10932
+ Flex,
10933
+ {
10934
+ $position: "absolute",
10935
+ $right: "1rem",
10936
+ $top: "1rem",
10937
+ $fontSize: "0.625rem",
10938
+ $color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
10939
+ $backgroundColor: theme.primary,
10940
+ $borderRadius: "9999px",
10941
+ $padding: "0.125rem 0.85rem",
10942
+ children: "Current plan"
10943
+ }
10944
+ )
10945
+ ]
10946
+ }
10947
+ ),
10948
+ /* @__PURE__ */ jsx11(
10949
+ Flex,
10950
+ {
10951
+ $flexDirection: "column",
10952
+ $position: "relative",
10953
+ $gap: "0.5rem",
10954
+ $flex: "1",
10955
+ $width: "100%",
10956
+ $height: "auto",
10957
+ $padding: "1.5rem",
10958
+ children: plan.entitlements.map((entitlement) => {
10959
+ return /* @__PURE__ */ jsx11(
10960
+ Flex,
10961
+ {
10962
+ $flexWrap: "wrap",
10963
+ $justifyContent: "space-between",
10964
+ $alignItems: "center",
10965
+ $gap: "1rem",
10966
+ children: /* @__PURE__ */ jsxs6(Flex, { $gap: "1rem", children: [
10967
+ entitlement.feature?.icon && /* @__PURE__ */ jsx11(
10968
+ IconRound,
10969
+ {
10970
+ name: entitlement.feature.icon,
10971
+ size: "sm",
10972
+ colors: [
10973
+ theme.primary,
10974
+ isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.25)"
10975
+ ]
10976
+ }
10977
+ ),
10978
+ /* @__PURE__ */ jsx11(FeatureName, { entitlement })
10979
+ ] })
10980
+ },
10981
+ entitlement.id
10982
+ );
10983
+ })
10984
+ }
10985
+ ),
10986
+ /* @__PURE__ */ jsxs6(
10987
+ Flex,
10988
+ {
10989
+ $flexDirection: "column",
10990
+ $position: "relative",
10991
+ $gap: "1rem",
10992
+ $width: "100%",
10993
+ $height: "auto",
10994
+ $padding: "1.5rem",
10995
+ children: [
10996
+ plan.id === selectedPlan?.id && /* @__PURE__ */ jsxs6(
10997
+ Flex,
10998
+ {
10999
+ $justifyContent: "center",
11000
+ $alignItems: "center",
11001
+ $gap: "0.25rem",
11002
+ $fontSize: "0.9375rem",
11003
+ $padding: "0.625rem 0",
11004
+ children: [
11005
+ /* @__PURE__ */ jsx11(
11006
+ Icon2,
11007
+ {
11008
+ name: "check-rounded",
11009
+ style: {
11010
+ fontSize: 20,
11011
+ lineHeight: "1",
11012
+ color: theme.primary
11013
+ }
11014
+ }
11015
+ ),
11016
+ /* @__PURE__ */ jsx11(
11017
+ Text,
11018
+ {
11019
+ $lineHeight: "1.4",
11020
+ $color: theme.typography.text.color,
11021
+ children: "Selected"
11022
+ }
11023
+ )
11024
+ ]
11025
+ }
11026
+ ),
11027
+ !(plan.current || plan.id === currentPlan?.id) && plan.id !== selectedPlan?.id && /* @__PURE__ */ jsx11(
11028
+ StyledButton,
11029
+ {
11030
+ disabled: plan.valid === false,
11031
+ ...plan.valid === true && {
11032
+ onClick: () => setSelectedPlan(plan)
11033
+ },
11034
+ $size: "sm",
11035
+ $color: "primary",
11036
+ $variant: "outline",
11037
+ children: "Select"
11038
+ }
11039
+ )
11040
+ ]
11041
+ }
11042
+ )
11043
+ ]
11044
+ },
11045
+ plan.id
11046
+ );
11047
+ }) })
11048
+ ] }),
11049
+ selectedPlan && checkoutStage === "checkout" && /* @__PURE__ */ jsx11(Fragment, { children: showPaymentForm ? /* @__PURE__ */ jsxs6(Fragment, { children: [
11050
+ /* @__PURE__ */ jsx11(
11051
+ PaymentForm,
11052
+ {
11053
+ plan: selectedPlan,
11054
+ period: planPeriod,
11055
+ onConfirm: (value) => {
11056
+ setPaymentMethodId(value);
11057
+ }
11058
+ }
11059
+ ),
11060
+ typeof data.subscription?.paymentMethod !== "undefined" && /* @__PURE__ */ jsx11(
11061
+ Box,
11062
+ {
11063
+ tabIndex: 0,
11064
+ onClick: () => setShowPaymentForm(false),
11065
+ $cursor: "pointer",
11066
+ children: /* @__PURE__ */ jsx11(
10908
11067
  Text,
10909
11068
  {
10910
- $font: theme.typography[props.icons.fontStyle].fontFamily,
10911
- $size: theme.typography[props.icons.fontStyle].fontSize,
10912
- $weight: theme.typography[props.icons.fontStyle].fontWeight,
10913
- $color: theme.typography[props.icons.fontStyle].color,
10914
- children: feature.name
11069
+ $font: theme.typography.link.fontFamily,
11070
+ $size: theme.typography.link.fontSize,
11071
+ $weight: theme.typography.link.fontWeight,
11072
+ $color: theme.typography.link.color,
11073
+ children: "Use existing payment method"
10915
11074
  }
10916
- ) })
10917
- ] }),
10918
- allocationType === "numeric" && feature?.name && /* @__PURE__ */ jsxs7(Box, { $textAlign: "right", children: [
10919
- props.entitlement.isVisible && /* @__PURE__ */ jsx12(
11075
+ )
11076
+ }
11077
+ )
11078
+ ] }) : /* @__PURE__ */ jsxs6(Fragment, { children: [
11079
+ /* @__PURE__ */ jsx11(PaymentMethod, {}),
11080
+ /* @__PURE__ */ jsx11(
11081
+ Box,
11082
+ {
11083
+ tabIndex: 0,
11084
+ onClick: () => setShowPaymentForm(true),
11085
+ $cursor: "pointer",
11086
+ children: /* @__PURE__ */ jsx11(
10920
11087
  Text,
10921
11088
  {
10922
- as: Box,
10923
- $font: theme.typography[props.entitlement.fontStyle].fontFamily,
10924
- $size: theme.typography[props.entitlement.fontStyle].fontSize,
10925
- $weight: theme.typography[props.entitlement.fontStyle].fontWeight,
10926
- $lineHeight: 1.5,
10927
- $color: theme.typography[props.entitlement.fontStyle].color,
10928
- children: typeof allocation === "number" ? `${allocation} ${feature.name}` : `Unlimited ${feature.name}`
11089
+ $font: theme.typography.link.fontFamily,
11090
+ $size: theme.typography.link.fontSize,
11091
+ $weight: theme.typography.link.fontWeight,
11092
+ $color: theme.typography.link.color,
11093
+ children: "Change payment method"
10929
11094
  }
10930
- ),
10931
- props.usage.isVisible && /* @__PURE__ */ jsx12(
11095
+ )
11096
+ }
11097
+ )
11098
+ ] }) })
11099
+ ]
11100
+ }
11101
+ ),
11102
+ /* @__PURE__ */ jsxs6(
11103
+ Flex,
11104
+ {
11105
+ $flexDirection: "column",
11106
+ $backgroundColor: theme.card.background,
11107
+ $borderRadius: "0 0 0.5rem",
11108
+ $width: "21.5rem",
11109
+ $boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
11110
+ children: [
11111
+ /* @__PURE__ */ jsxs6(
11112
+ Flex,
11113
+ {
11114
+ $flexDirection: "column",
11115
+ $position: "relative",
11116
+ $gap: "1rem",
11117
+ $width: "100%",
11118
+ $height: "auto",
11119
+ $padding: "1.5rem",
11120
+ $borderBottomWidth: "1px",
11121
+ $borderStyle: "solid",
11122
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)",
11123
+ children: [
11124
+ /* @__PURE__ */ jsx11(Flex, { $justifyContent: "space-between", children: /* @__PURE__ */ jsx11(
10932
11125
  Text,
10933
11126
  {
10934
- as: Box,
10935
- $font: theme.typography[props.usage.fontStyle].fontFamily,
10936
- $size: theme.typography[props.usage.fontStyle].fontSize,
10937
- $weight: theme.typography[props.usage.fontStyle].fontWeight,
10938
- $lineHeight: 1.5,
10939
- $color: theme.typography[props.usage.fontStyle].color,
10940
- children: typeof allocation === "number" ? `${usage} of ${allocation} used` : `${usage} used`
11127
+ as: "h3",
11128
+ $font: theme.typography.heading3.fontFamily,
11129
+ $size: theme.typography.heading3.fontSize,
11130
+ $weight: theme.typography.heading3.fontWeight,
11131
+ $color: theme.typography.heading3.color,
11132
+ children: "Subscription"
10941
11133
  }
10942
- )
10943
- ] })
10944
- ]
10945
- },
10946
- index
10947
- )
10948
- ];
10949
- },
10950
- []
10951
- )
10952
- ] });
10953
- });
10954
-
10955
- // src/components/elements/metered-features/MeteredFeatures.tsx
10956
- import { forwardRef as forwardRef3, useMemo as useMemo8 } from "react";
10957
- import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
10958
- function resolveDesignProps3(props) {
10959
- return {
10960
- isVisible: props.isVisible ?? true,
10961
- header: {
10962
- fontStyle: props.header?.fontStyle ?? "heading2"
10963
- },
10964
- description: {
10965
- isVisible: props.description?.isVisible ?? true,
10966
- fontStyle: props.description?.fontStyle ?? "text"
10967
- },
10968
- icon: {
10969
- isVisible: props.icon?.isVisible ?? true
10970
- },
10971
- allocation: {
10972
- isVisible: props.allocation?.isVisible ?? true,
10973
- fontStyle: props.allocation?.fontStyle ?? "heading4"
10974
- },
10975
- usage: {
10976
- isVisible: props.usage?.isVisible ?? true,
10977
- fontStyle: props.usage?.fontStyle ?? "heading5"
10978
- },
10979
- callToAction: {
10980
- isVisible: props.callToAction?.isVisible ?? true,
10981
- buttonSize: props.callToAction?.buttonSize ?? "md",
10982
- buttonStyle: props.callToAction?.buttonStyle ?? "primary"
10983
- }
10984
- };
11134
+ ) }),
11135
+ planPeriodOptions.length > 1 && /* @__PURE__ */ jsxs6(
11136
+ Flex,
11137
+ {
11138
+ $borderWidth: "1px",
11139
+ $borderStyle: "solid",
11140
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)",
11141
+ $borderRadius: "2.5rem",
11142
+ $cursor: "pointer",
11143
+ children: [
11144
+ /* @__PURE__ */ jsx11(
11145
+ Flex,
11146
+ {
11147
+ onClick: () => setPlanPeriod("month"),
11148
+ $justifyContent: "center",
11149
+ $alignItems: "center",
11150
+ $padding: "0.25rem 0.5rem",
11151
+ $flex: "1",
11152
+ ...planPeriod === "month" && {
11153
+ $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.075)" : "hsla(0, 0%, 100%, 0.15)"
11154
+ },
11155
+ $borderRadius: "2.5rem",
11156
+ children: /* @__PURE__ */ jsx11(
11157
+ Text,
11158
+ {
11159
+ $font: theme.typography.text.fontFamily,
11160
+ $size: 14,
11161
+ $weight: planPeriod === "month" ? 600 : 400,
11162
+ $color: theme.typography.text.color,
11163
+ children: "Billed monthly"
11164
+ }
11165
+ )
11166
+ }
11167
+ ),
11168
+ /* @__PURE__ */ jsx11(
11169
+ Flex,
11170
+ {
11171
+ onClick: () => setPlanPeriod("year"),
11172
+ $justifyContent: "center",
11173
+ $alignItems: "center",
11174
+ $padding: "0.25rem 0.5rem",
11175
+ $flex: "1",
11176
+ ...planPeriod === "year" && {
11177
+ $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.075)" : "hsla(0, 0%, 100%, 0.15)"
11178
+ },
11179
+ $borderRadius: "2.5rem",
11180
+ children: /* @__PURE__ */ jsx11(
11181
+ Text,
11182
+ {
11183
+ $font: theme.typography.text.fontFamily,
11184
+ $size: 14,
11185
+ $weight: planPeriod === "year" ? 600 : 400,
11186
+ $color: theme.typography.text.color,
11187
+ children: "Billed yearly"
11188
+ }
11189
+ )
11190
+ }
11191
+ )
11192
+ ]
11193
+ }
11194
+ ),
11195
+ savingsPercentage > 0 && /* @__PURE__ */ jsx11(Box, { children: /* @__PURE__ */ jsx11(
11196
+ Text,
11197
+ {
11198
+ $font: theme.typography.text.fontFamily,
11199
+ $size: 11,
11200
+ $weight: theme.typography.text.fontWeight,
11201
+ $color: theme.primary,
11202
+ children: planPeriod === "month" ? `Save up to ${savingsPercentage}% with yearly billing` : `You are saving ${savingsPercentage}% with yearly billing`
11203
+ }
11204
+ ) })
11205
+ ]
11206
+ }
11207
+ ),
11208
+ /* @__PURE__ */ jsxs6(
11209
+ Flex,
11210
+ {
11211
+ $flexDirection: "column",
11212
+ $position: "relative",
11213
+ $gap: "1rem",
11214
+ $width: "100%",
11215
+ $height: "auto",
11216
+ $padding: "1.5rem",
11217
+ $flex: "1",
11218
+ $borderBottomWidth: "1px",
11219
+ $borderStyle: "solid",
11220
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)",
11221
+ children: [
11222
+ /* @__PURE__ */ jsx11(Box, { $opacity: "0.625", children: /* @__PURE__ */ jsx11(
11223
+ Text,
11224
+ {
11225
+ $font: theme.typography.text.fontFamily,
11226
+ $size: 14,
11227
+ $weight: theme.typography.text.fontWeight,
11228
+ $color: theme.typography.text.color,
11229
+ children: "Plan"
11230
+ }
11231
+ ) }),
11232
+ /* @__PURE__ */ jsxs6(Flex, { $flexDirection: "column", $gap: "0.5rem", children: [
11233
+ currentPlan && /* @__PURE__ */ jsxs6(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
11234
+ /* @__PURE__ */ jsx11(
11235
+ Flex,
11236
+ {
11237
+ ...selectedPlan && {
11238
+ $opacity: "0.625",
11239
+ $textDecoration: "line-through"
11240
+ },
11241
+ children: /* @__PURE__ */ jsx11(
11242
+ Text,
11243
+ {
11244
+ $font: theme.typography.heading4.fontFamily,
11245
+ $size: theme.typography.heading4.fontSize,
11246
+ $weight: theme.typography.heading4.fontWeight,
11247
+ $color: theme.typography.heading4.color,
11248
+ children: currentPlan.name
11249
+ }
11250
+ )
11251
+ }
11252
+ ),
11253
+ typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ jsx11(Flex, { children: /* @__PURE__ */ jsxs6(
11254
+ Text,
11255
+ {
11256
+ $font: theme.typography.text.fontFamily,
11257
+ $size: theme.typography.text.fontSize,
11258
+ $weight: theme.typography.text.fontWeight,
11259
+ $color: theme.typography.text.color,
11260
+ children: [
11261
+ formatCurrency(currentPlan.planPrice),
11262
+ "/",
11263
+ currentPlan.planPeriod
11264
+ ]
11265
+ }
11266
+ ) })
11267
+ ] }),
11268
+ selectedPlan && /* @__PURE__ */ jsxs6(Fragment, { children: [
11269
+ /* @__PURE__ */ jsx11(
11270
+ Box,
11271
+ {
11272
+ $width: "100%",
11273
+ $textAlign: "left",
11274
+ $opacity: "50%",
11275
+ $marginBottom: "-0.25rem",
11276
+ $marginTop: "-0.25rem",
11277
+ children: /* @__PURE__ */ jsx11(
11278
+ Icon2,
11279
+ {
11280
+ name: "arrow-down",
11281
+ style: {
11282
+ display: "inline-block"
11283
+ }
11284
+ }
11285
+ )
11286
+ }
11287
+ ),
11288
+ /* @__PURE__ */ jsxs6(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
11289
+ /* @__PURE__ */ jsx11(Flex, { children: /* @__PURE__ */ jsx11(
11290
+ Text,
11291
+ {
11292
+ $font: theme.typography.heading4.fontFamily,
11293
+ $size: theme.typography.heading4.fontSize,
11294
+ $weight: theme.typography.heading4.fontWeight,
11295
+ $color: theme.typography.heading4.color,
11296
+ children: selectedPlan.name
11297
+ }
11298
+ ) }),
11299
+ /* @__PURE__ */ jsx11(Flex, { children: /* @__PURE__ */ jsxs6(
11300
+ Text,
11301
+ {
11302
+ $font: theme.typography.text.fontFamily,
11303
+ $size: theme.typography.text.fontSize,
11304
+ $weight: theme.typography.text.fontWeight,
11305
+ $color: theme.typography.text.color,
11306
+ children: [
11307
+ formatCurrency(
11308
+ (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
11309
+ ),
11310
+ "/",
11311
+ planPeriod
11312
+ ]
11313
+ }
11314
+ ) })
11315
+ ] })
11316
+ ] })
11317
+ ] })
11318
+ ]
11319
+ }
11320
+ ),
11321
+ /* @__PURE__ */ jsxs6(
11322
+ Flex,
11323
+ {
11324
+ $flexDirection: "column",
11325
+ $position: "relative",
11326
+ $gap: "1rem",
11327
+ $width: "100%",
11328
+ $height: "auto",
11329
+ $padding: "1.5rem",
11330
+ children: [
11331
+ selectedPlan && /* @__PURE__ */ jsxs6(Flex, { $justifyContent: "space-between", children: [
11332
+ /* @__PURE__ */ jsx11(Box, { $opacity: "0.625", children: /* @__PURE__ */ jsxs6(
11333
+ Text,
11334
+ {
11335
+ $font: theme.typography.text.fontFamily,
11336
+ $size: theme.typography.text.fontSize,
11337
+ $weight: theme.typography.text.fontWeight,
11338
+ $color: theme.typography.text.color,
11339
+ children: [
11340
+ planPeriod === "month" ? "Monthly" : "Yearly",
11341
+ " total:",
11342
+ " "
11343
+ ]
11344
+ }
11345
+ ) }),
11346
+ /* @__PURE__ */ jsx11(Box, { children: /* @__PURE__ */ jsxs6(
11347
+ Text,
11348
+ {
11349
+ $font: theme.typography.text.fontFamily,
11350
+ $size: theme.typography.text.fontSize,
11351
+ $weight: theme.typography.text.fontWeight,
11352
+ $color: theme.typography.text.color,
11353
+ children: [
11354
+ formatCurrency(
11355
+ (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
11356
+ ),
11357
+ "/",
11358
+ planPeriod
11359
+ ]
11360
+ }
11361
+ ) })
11362
+ ] }),
11363
+ checkoutStage === "plan" ? /* @__PURE__ */ jsx11(
11364
+ StyledButton,
11365
+ {
11366
+ disabled: !selectedPlan,
11367
+ ...selectedPlan && {
11368
+ onClick: () => setCheckoutStage("checkout")
11369
+ },
11370
+ children: /* @__PURE__ */ jsxs6(
11371
+ Flex,
11372
+ {
11373
+ $gap: "0.5rem",
11374
+ $justifyContent: "center",
11375
+ $alignItems: "center",
11376
+ $padding: "0 1rem",
11377
+ children: [
11378
+ /* @__PURE__ */ jsx11(Text, { $align: "left", $lineHeight: 1, children: "Next: Checkout" }),
11379
+ /* @__PURE__ */ jsx11(Icon2, { name: "arrow-right" })
11380
+ ]
11381
+ }
11382
+ )
11383
+ }
11384
+ ) : /* @__PURE__ */ jsx11(
11385
+ StyledButton,
11386
+ {
11387
+ ...allowCheckout ? {
11388
+ onClick: async () => {
11389
+ const priceId = (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.id;
11390
+ if (!priceId) {
11391
+ return;
11392
+ }
11393
+ try {
11394
+ setIsLoading(true);
11395
+ await api.checkout({
11396
+ changeSubscriptionRequestBody: {
11397
+ newPlanId: selectedPlan.id,
11398
+ newPriceId: priceId,
11399
+ ...paymentMethodId && { paymentMethodId }
11400
+ }
11401
+ });
11402
+ setLayout("success");
11403
+ } catch {
11404
+ setError(
11405
+ "Error processing payment. Please try a different payment method."
11406
+ );
11407
+ } finally {
11408
+ setIsLoading(false);
11409
+ }
11410
+ }
11411
+ } : { disabled: true },
11412
+ children: "Pay now"
11413
+ }
11414
+ ),
11415
+ /* @__PURE__ */ jsx11(Box, { $opacity: "0.625", children: /* @__PURE__ */ jsx11(
11416
+ Text,
11417
+ {
11418
+ $font: theme.typography.text.fontFamily,
11419
+ $size: theme.typography.text.fontSize,
11420
+ $weight: theme.typography.text.fontWeight,
11421
+ $color: theme.typography.text.color,
11422
+ children: "Discounts & credits applied at checkout"
11423
+ }
11424
+ ) }),
11425
+ error && /* @__PURE__ */ jsx11(Box, { children: /* @__PURE__ */ jsx11(
11426
+ Text,
11427
+ {
11428
+ $font: theme.typography.text.fontFamily,
11429
+ $size: theme.typography.text.fontSize,
11430
+ $weight: 500,
11431
+ $color: "#DB6669",
11432
+ children: error
11433
+ }
11434
+ ) })
11435
+ ]
11436
+ }
11437
+ )
11438
+ ]
11439
+ }
11440
+ )
11441
+ ] })
11442
+ ] });
11443
+ };
11444
+
11445
+ // src/components/elements/plan-manager/PlanManager.tsx
11446
+ import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
11447
+ var resolveDesignProps2 = (props) => {
11448
+ return {
11449
+ header: {
11450
+ isVisible: props.header?.isVisible ?? true,
11451
+ title: {
11452
+ fontStyle: props.header?.title?.fontStyle ?? "heading1"
11453
+ },
11454
+ description: {
11455
+ isVisible: props.header?.description?.isVisible ?? true,
11456
+ fontStyle: props.header?.description?.fontStyle ?? "text"
11457
+ },
11458
+ price: {
11459
+ isVisible: props.header?.price?.isVisible ?? true,
11460
+ fontStyle: props.header?.price?.fontStyle ?? "text"
11461
+ }
11462
+ },
11463
+ addOns: {
11464
+ isVisible: props.addOns?.isVisible ?? true,
11465
+ fontStyle: props.addOns?.fontStyle ?? "heading4",
11466
+ showLabel: props.addOns?.showLabel ?? true
11467
+ },
11468
+ callToAction: {
11469
+ isVisible: props.callToAction?.isVisible ?? true,
11470
+ buttonSize: props.callToAction?.buttonSize ?? "lg",
11471
+ buttonStyle: props.callToAction?.buttonStyle ?? "primary"
11472
+ }
11473
+ };
11474
+ };
11475
+ var PlanManager = forwardRef2(({ children, className, portal, ...rest }, ref) => {
11476
+ const props = resolveDesignProps2(rest);
11477
+ const theme = nt();
11478
+ const { data, layout, stripe, setLayout } = useEmbed();
11479
+ const { currentPlan, canChangePlan } = useMemo7(() => {
11480
+ return {
11481
+ currentPlan: data.company?.plan,
11482
+ canChangePlan: stripe !== null
11483
+ };
11484
+ }, [data.company, stripe]);
11485
+ return /* @__PURE__ */ jsxs7("div", { ref, className, children: [
11486
+ /* @__PURE__ */ jsx12(
11487
+ Flex,
11488
+ {
11489
+ $flexDirection: "column",
11490
+ $gap: "0.75rem",
11491
+ ...canChangePlan && { $margin: "0 0 0.5rem" },
11492
+ children: props.header.isVisible && currentPlan && /* @__PURE__ */ jsxs7(
11493
+ Flex,
11494
+ {
11495
+ $justifyContent: "space-between",
11496
+ $alignItems: "center",
11497
+ $width: "100%",
11498
+ ...canChangePlan && { $margin: "0 0 1.5rem" },
11499
+ children: [
11500
+ /* @__PURE__ */ jsxs7("div", { children: [
11501
+ /* @__PURE__ */ jsx12(Box, { $margin: "0 0 0.75rem", children: /* @__PURE__ */ jsx12(
11502
+ Text,
11503
+ {
11504
+ $font: theme.typography[props.header.title.fontStyle].fontFamily,
11505
+ $size: theme.typography[props.header.title.fontStyle].fontSize,
11506
+ $weight: theme.typography[props.header.title.fontStyle].fontWeight,
11507
+ $color: theme.typography[props.header.title.fontStyle].color,
11508
+ $lineHeight: 1,
11509
+ children: currentPlan.name
11510
+ }
11511
+ ) }),
11512
+ props.header.description.isVisible && currentPlan.description && /* @__PURE__ */ jsx12(
11513
+ Text,
11514
+ {
11515
+ $font: theme.typography[props.header.description.fontStyle].fontFamily,
11516
+ $size: theme.typography[props.header.description.fontStyle].fontSize,
11517
+ $weight: theme.typography[props.header.description.fontStyle].fontWeight,
11518
+ $color: theme.typography[props.header.description.fontStyle].color,
11519
+ children: currentPlan.description
11520
+ }
11521
+ )
11522
+ ] }),
11523
+ props.header.price.isVisible && typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ jsxs7(
11524
+ Text,
11525
+ {
11526
+ $font: theme.typography[props.header.price.fontStyle].fontFamily,
11527
+ $size: theme.typography[props.header.price.fontStyle].fontSize,
11528
+ $weight: theme.typography[props.header.price.fontStyle].fontWeight,
11529
+ $color: theme.typography[props.header.price.fontStyle].color,
11530
+ children: [
11531
+ formatCurrency(currentPlan.planPrice),
11532
+ "/",
11533
+ currentPlan.planPeriod
11534
+ ]
11535
+ }
11536
+ )
11537
+ ]
11538
+ }
11539
+ )
11540
+ }
11541
+ ),
11542
+ canChangePlan && props.callToAction.isVisible && /* @__PURE__ */ jsx12(
11543
+ StyledButton,
11544
+ {
11545
+ onClick: () => {
11546
+ setLayout("checkout");
11547
+ },
11548
+ $size: props.callToAction.buttonSize,
11549
+ $color: props.callToAction.buttonStyle,
11550
+ children: "Change Plan"
11551
+ }
11552
+ ),
11553
+ canChangePlan && layout === "checkout" && createPortal2(/* @__PURE__ */ jsx12(CheckoutDialog, {}), portal || document.body)
11554
+ ] });
11555
+ });
11556
+
11557
+ // src/components/elements/included-features/IncludedFeatures.tsx
11558
+ import { forwardRef as forwardRef3, useMemo as useMemo8 } from "react";
11559
+ var import_pluralize2 = __toESM(require_pluralize());
11560
+ import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
11561
+ function resolveDesignProps3(props) {
11562
+ return {
11563
+ header: {
11564
+ isVisible: props.header?.isVisible ?? true,
11565
+ fontStyle: props.header?.fontStyle ?? "heading4",
11566
+ text: props.header?.text ?? "Included features"
11567
+ },
11568
+ icons: {
11569
+ isVisible: props.icons?.isVisible ?? true,
11570
+ fontStyle: props.icons?.fontStyle ?? "heading5",
11571
+ style: props.icons?.style ?? "light"
11572
+ },
11573
+ entitlement: {
11574
+ isVisible: props.entitlement?.isVisible ?? true,
11575
+ fontStyle: props.entitlement?.fontStyle ?? "text"
11576
+ },
11577
+ usage: {
11578
+ isVisible: props.usage?.isVisible ?? true,
11579
+ fontStyle: props.usage?.fontStyle ?? "heading6"
11580
+ }
11581
+ };
10985
11582
  }
10986
- var MeteredFeatures = forwardRef3(({ className, ...rest }, ref) => {
11583
+ var IncludedFeatures = forwardRef3(({ className, ...rest }, ref) => {
10987
11584
  const props = resolveDesignProps3(rest);
10988
11585
  const theme = nt();
10989
11586
  const { data } = useEmbed();
@@ -10995,7 +11592,7 @@ var MeteredFeatures = forwardRef3(({ className, ...rest }, ref) => {
10995
11592
  allocationType,
10996
11593
  feature,
10997
11594
  period,
10998
- usage,
11595
+ usage = 0,
10999
11596
  ...props2
11000
11597
  }) => {
11001
11598
  return {
@@ -11014,470 +11611,323 @@ var MeteredFeatures = forwardRef3(({ className, ...rest }, ref) => {
11014
11611
  }
11015
11612
  );
11016
11613
  }, [data.featureUsage]);
11017
- return /* @__PURE__ */ jsx13(Flex, { ref, className, $flexDirection: "column", $gap: "1.5rem", children: features.reduce(
11018
- (acc, { allocation, allocationType, feature, usage }, index) => {
11019
- if (!props.isVisible || allocationType !== "numeric" || typeof allocation !== "number") {
11020
- return acc;
11614
+ const isLightBackground = useMemo8(() => {
11615
+ return hexToHSL(theme.card.background).l > 50;
11616
+ }, [theme.card.background]);
11617
+ return /* @__PURE__ */ jsxs8(Flex, { ref, className, $flexDirection: "column", $gap: "1.5rem", children: [
11618
+ props.header.isVisible && /* @__PURE__ */ jsx13(Box, { children: /* @__PURE__ */ jsx13(
11619
+ Text,
11620
+ {
11621
+ $font: theme.typography[props.header.fontStyle].fontFamily,
11622
+ $size: theme.typography[props.header.fontStyle].fontSize,
11623
+ $weight: theme.typography[props.header.fontStyle].fontWeight,
11624
+ $color: theme.typography[props.header.fontStyle].color,
11625
+ children: props.header.text
11021
11626
  }
11022
- return [
11023
- ...acc,
11024
- /* @__PURE__ */ jsxs8(Flex, { $gap: "1.5rem", children: [
11025
- props.icon.isVisible && feature?.icon && /* @__PURE__ */ jsx13(Box, { $flexShrink: "0", children: /* @__PURE__ */ jsx13(IconRound, { name: feature.icon, size: "sm" }) }),
11026
- /* @__PURE__ */ jsxs8(Box, { $flexGrow: "1", children: [
11027
- /* @__PURE__ */ jsxs8(Flex, { children: [
11028
- feature?.name && /* @__PURE__ */ jsxs8(Box, { $flexGrow: "1", children: [
11029
- /* @__PURE__ */ jsx13(
11030
- Text,
11031
- {
11032
- as: Box,
11033
- $font: theme.typography[props.header.fontStyle].fontFamily,
11034
- $size: theme.typography[props.header.fontStyle].fontSize,
11035
- $weight: theme.typography[props.header.fontStyle].fontWeight,
11036
- $color: theme.typography[props.header.fontStyle].color,
11037
- children: feature.name
11038
- }
11039
- ),
11040
- props.description.isVisible && /* @__PURE__ */ jsx13(
11041
- Text,
11042
- {
11043
- as: Box,
11044
- $font: theme.typography[props.description.fontStyle].fontFamily,
11045
- $size: theme.typography[props.description.fontStyle].fontSize,
11046
- $weight: theme.typography[props.description.fontStyle].fontWeight,
11047
- $color: theme.typography[props.description.fontStyle].color,
11048
- children: feature.description
11049
- }
11050
- )
11051
- ] }),
11052
- allocationType === "numeric" && feature?.name && /* @__PURE__ */ jsxs8(Box, { $textAlign: "right", children: [
11053
- props.allocation.isVisible && /* @__PURE__ */ jsx13(
11054
- Text,
11055
- {
11056
- as: Box,
11057
- $font: theme.typography[props.allocation.fontStyle].fontFamily,
11058
- $size: theme.typography[props.allocation.fontStyle].fontSize,
11059
- $weight: theme.typography[props.allocation.fontStyle].fontWeight,
11060
- $color: theme.typography[props.allocation.fontStyle].color,
11061
- children: typeof allocation === "number" ? `${allocation} ${feature.name}` : `Unlimited ${feature.name}`
11062
- }
11063
- ),
11064
- props.usage.isVisible && /* @__PURE__ */ jsx13(
11065
- Text,
11066
- {
11067
- as: Box,
11068
- $font: theme.typography[props.usage.fontStyle].fontFamily,
11069
- $size: theme.typography[props.usage.fontStyle].fontSize,
11070
- $weight: theme.typography[props.usage.fontStyle].fontWeight,
11071
- $color: theme.typography[props.usage.fontStyle].color,
11072
- children: typeof allocation === "number" ? `${usage} of ${allocation} used` : `${usage} used`
11073
- }
11074
- )
11075
- ] })
11076
- ] }),
11077
- typeof usage === "number" && typeof allocation === "number" && /* @__PURE__ */ jsx13(Box, { children: /* @__PURE__ */ jsx13(
11078
- ProgressBar,
11079
- {
11080
- progress: usage / allocation * 100,
11081
- value: usage,
11082
- total: allocation,
11083
- color: "blue"
11084
- }
11085
- ) })
11086
- ] })
11087
- ] }, index)
11088
- ];
11089
- },
11090
- []
11091
- ) });
11627
+ ) }),
11628
+ features.reduce(
11629
+ (acc, { allocation, allocationType, feature, usage }, index) => {
11630
+ if (!allocationType) {
11631
+ return acc;
11632
+ }
11633
+ return [
11634
+ ...acc,
11635
+ /* @__PURE__ */ jsxs8(
11636
+ Flex,
11637
+ {
11638
+ $flexWrap: "wrap",
11639
+ $justifyContent: "space-between",
11640
+ $alignItems: "center",
11641
+ $gap: "1rem",
11642
+ children: [
11643
+ /* @__PURE__ */ jsxs8(Flex, { $gap: "1rem", children: [
11644
+ props.icons.isVisible && feature?.icon && /* @__PURE__ */ jsx13(
11645
+ IconRound,
11646
+ {
11647
+ name: feature.icon,
11648
+ size: "sm",
11649
+ colors: [
11650
+ theme.primary,
11651
+ isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.25)"
11652
+ ]
11653
+ }
11654
+ ),
11655
+ feature?.name && /* @__PURE__ */ jsx13(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx13(
11656
+ Text,
11657
+ {
11658
+ $font: theme.typography[props.icons.fontStyle].fontFamily,
11659
+ $size: theme.typography[props.icons.fontStyle].fontSize,
11660
+ $weight: theme.typography[props.icons.fontStyle].fontWeight,
11661
+ $color: theme.typography[props.icons.fontStyle].color,
11662
+ children: feature.name
11663
+ }
11664
+ ) })
11665
+ ] }),
11666
+ allocationType === "numeric" && feature?.name && /* @__PURE__ */ jsxs8(Box, { $textAlign: "right", children: [
11667
+ props.entitlement.isVisible && /* @__PURE__ */ jsx13(
11668
+ Text,
11669
+ {
11670
+ as: Box,
11671
+ $font: theme.typography[props.entitlement.fontStyle].fontFamily,
11672
+ $size: theme.typography[props.entitlement.fontStyle].fontSize,
11673
+ $weight: theme.typography[props.entitlement.fontStyle].fontWeight,
11674
+ $lineHeight: 1.5,
11675
+ $color: theme.typography[props.entitlement.fontStyle].color,
11676
+ children: typeof allocation === "number" ? (0, import_pluralize2.default)(feature.name, allocation, true) : `Unlimited ${(0, import_pluralize2.default)(feature.name)}`
11677
+ }
11678
+ ),
11679
+ props.usage.isVisible && /* @__PURE__ */ jsx13(
11680
+ Text,
11681
+ {
11682
+ as: Box,
11683
+ $font: theme.typography[props.usage.fontStyle].fontFamily,
11684
+ $size: theme.typography[props.usage.fontStyle].fontSize,
11685
+ $weight: theme.typography[props.usage.fontStyle].fontWeight,
11686
+ $lineHeight: 1.5,
11687
+ $color: theme.typography[props.usage.fontStyle].color,
11688
+ children: typeof allocation === "number" ? `${usage} of ${allocation} used` : `${usage} used`
11689
+ }
11690
+ )
11691
+ ] })
11692
+ ]
11693
+ },
11694
+ index
11695
+ )
11696
+ ];
11697
+ },
11698
+ []
11699
+ )
11700
+ ] });
11092
11701
  });
11093
11702
 
11094
- // src/components/elements/upcoming-bill/UpcomingBill.tsx
11703
+ // src/components/elements/metered-features/MeteredFeatures.tsx
11095
11704
  import { forwardRef as forwardRef4, useMemo as useMemo9 } from "react";
11096
11705
  import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
11097
11706
  function resolveDesignProps4(props) {
11098
11707
  return {
11708
+ isVisible: props.isVisible ?? true,
11099
11709
  header: {
11100
- isVisible: props.header?.isVisible ?? true,
11101
- fontStyle: props.header?.fontStyle ?? "heading4",
11102
- prefix: props.header?.prefix ?? "Next bill due"
11710
+ fontStyle: props.header?.fontStyle ?? "heading2"
11103
11711
  },
11104
- price: {
11105
- isVisible: props.price?.isVisible ?? true,
11106
- fontStyle: props.price?.fontStyle ?? "heading1"
11712
+ description: {
11713
+ isVisible: props.description?.isVisible ?? true,
11714
+ fontStyle: props.description?.fontStyle ?? "text"
11107
11715
  },
11108
- contractEndDate: {
11109
- isVisible: props.contractEndDate?.isVisible ?? true,
11110
- fontStyle: props.contractEndDate?.fontStyle ?? "heading6",
11111
- prefix: props.contractEndDate?.prefix ?? "Contract ends"
11112
- }
11113
- };
11114
- }
11115
- var UpcomingBill = forwardRef4(({ className, ...rest }, ref) => {
11116
- const props = resolveDesignProps4(rest);
11117
- const theme = nt();
11118
- const { data, stripe } = useEmbed();
11119
- const { upcomingInvoice } = useMemo9(() => {
11120
- return {
11121
- upcomingInvoice: {
11122
- ...data.upcomingInvoice?.amountDue && {
11123
- amountDue: data.upcomingInvoice.amountDue
11124
- },
11125
- ...data.subscription?.interval && {
11126
- interval: data.subscription.interval
11127
- },
11128
- ...data.upcomingInvoice?.dueDate && {
11129
- dueDate: toPrettyDate(new Date(data.upcomingInvoice.dueDate))
11130
- }
11131
- }
11132
- };
11133
- }, [data.subscription, data.upcomingInvoice]);
11134
- if (!stripe || !upcomingInvoice.amountDue || !upcomingInvoice.dueDate) {
11135
- return null;
11136
- }
11137
- return /* @__PURE__ */ jsxs9("div", { ref, className, children: [
11138
- props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */ jsx14(
11139
- Flex,
11140
- {
11141
- $justifyContent: "space-between",
11142
- $alignItems: "center",
11143
- $margin: "0 0 0.75rem",
11144
- children: /* @__PURE__ */ jsxs9(
11145
- Text,
11146
- {
11147
- $font: theme.typography[props.header.fontStyle].fontFamily,
11148
- $size: theme.typography[props.header.fontStyle].fontSize,
11149
- $weight: theme.typography[props.header.fontStyle].fontWeight,
11150
- $color: theme.typography[props.header.fontStyle].color,
11151
- children: [
11152
- props.header.prefix,
11153
- " ",
11154
- upcomingInvoice.dueDate
11155
- ]
11156
- }
11157
- )
11158
- }
11159
- ),
11160
- upcomingInvoice.amountDue && /* @__PURE__ */ jsxs9(Flex, { $justifyContent: "space-between", $alignItems: "start", $gap: "1rem", children: [
11161
- props.price.isVisible && /* @__PURE__ */ jsx14(Flex, { $alignItems: "end", $flexGrow: "1", children: /* @__PURE__ */ jsx14(
11162
- Text,
11163
- {
11164
- $font: theme.typography[props.price.fontStyle].fontFamily,
11165
- $size: theme.typography[props.price.fontStyle].fontSize,
11166
- $weight: theme.typography[props.price.fontStyle].fontWeight,
11167
- $color: theme.typography[props.price.fontStyle].color,
11168
- $lineHeight: 1,
11169
- children: formatCurrency(upcomingInvoice.amountDue)
11170
- }
11171
- ) }),
11172
- /* @__PURE__ */ jsx14(Box, { $maxWidth: "10rem", $lineHeight: "1", $textAlign: "right", children: /* @__PURE__ */ jsx14(
11173
- Text,
11174
- {
11175
- $font: theme.typography[props.contractEndDate.fontStyle].fontFamily,
11176
- $size: theme.typography[props.contractEndDate.fontStyle].fontSize,
11177
- $weight: theme.typography[props.contractEndDate.fontStyle].fontWeight,
11178
- $color: theme.typography[props.contractEndDate.fontStyle].color,
11179
- children: "Estimated monthly bill."
11180
- }
11181
- ) })
11182
- ] })
11183
- ] });
11184
- });
11185
-
11186
- // src/components/elements/payment-method/PaymentMethod.tsx
11187
- import { forwardRef as forwardRef5, useMemo as useMemo10 } from "react";
11188
- import { createPortal as createPortal2 } from "react-dom";
11189
- import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
11190
- var resolveDesignProps5 = (props) => {
11191
- return {
11192
- header: {
11193
- isVisible: props.header?.isVisible ?? true,
11194
- fontStyle: props.header?.fontStyle ?? "heading4"
11716
+ icon: {
11717
+ isVisible: props.icon?.isVisible ?? true
11195
11718
  },
11196
- functions: {
11197
- allowEdit: props.functions?.allowEdit ?? true
11719
+ allocation: {
11720
+ isVisible: props.allocation?.isVisible ?? true,
11721
+ fontStyle: props.allocation?.fontStyle ?? "heading4"
11722
+ },
11723
+ usage: {
11724
+ isVisible: props.usage?.isVisible ?? true,
11725
+ fontStyle: props.usage?.fontStyle ?? "heading5"
11726
+ },
11727
+ callToAction: {
11728
+ isVisible: props.callToAction?.isVisible ?? true,
11729
+ buttonSize: props.callToAction?.buttonSize ?? "md",
11730
+ buttonStyle: props.callToAction?.buttonStyle ?? "primary"
11198
11731
  }
11199
11732
  };
11200
- };
11201
- var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref) => {
11202
- const props = resolveDesignProps5(rest);
11733
+ }
11734
+ var MeteredFeatures = forwardRef4(({ className, ...rest }, ref) => {
11735
+ const props = resolveDesignProps4(rest);
11203
11736
  const theme = nt();
11204
- const { data, stripe, layout } = useEmbed();
11205
- const paymentMethod = useMemo10(() => {
11206
- const { cardLast4, cardExpMonth, cardExpYear } = data.subscription?.paymentMethod || {};
11207
- let monthsToExpiration;
11208
- if (typeof cardExpYear === "number" && typeof cardExpMonth === "number") {
11209
- const timeToExpiration = Math.round(
11210
- +new Date(cardExpYear, cardExpMonth - 1) - +/* @__PURE__ */ new Date()
11211
- );
11212
- monthsToExpiration = Math.round(
11213
- timeToExpiration / (1e3 * 60 * 60 * 24 * 30)
11214
- );
11215
- }
11216
- return {
11217
- cardLast4,
11218
- monthsToExpiration
11219
- };
11220
- }, [data.subscription?.paymentMethod]);
11221
- const isLightBackground = useMemo10(() => {
11222
- return hexToHSL(theme.card.background).l > 50;
11223
- }, [theme.card.background]);
11224
- if (!stripe || !paymentMethod.cardLast4) {
11225
- return null;
11226
- }
11227
- return /* @__PURE__ */ jsxs10("div", { ref, className, children: [
11228
- props.header.isVisible && /* @__PURE__ */ jsxs10(
11229
- Flex,
11230
- {
11231
- $justifyContent: "space-between",
11232
- $alignItems: "center",
11233
- $margin: "0 0 1rem",
11234
- children: [
11235
- /* @__PURE__ */ jsx15(
11236
- Text,
11237
- {
11238
- $font: theme.typography[props.header.fontStyle].fontFamily,
11239
- $size: theme.typography[props.header.fontStyle].fontSize,
11240
- $weight: theme.typography[props.header.fontStyle].fontWeight,
11241
- $color: theme.typography[props.header.fontStyle].color,
11242
- children: "Payment Method"
11243
- }
11244
- ),
11245
- typeof paymentMethod.monthsToExpiration === "number" && Math.abs(paymentMethod.monthsToExpiration) < 4 && /* @__PURE__ */ jsx15(
11246
- Text,
11247
- {
11248
- $font: theme.typography.text.fontFamily,
11249
- $size: 14,
11250
- $color: "#DB6769",
11251
- children: paymentMethod.monthsToExpiration > 0 ? `Expires in ${paymentMethod.monthsToExpiration} mo` : "Expired"
11252
- }
11253
- )
11254
- ]
11255
- }
11256
- ),
11257
- paymentMethod.cardLast4 && /* @__PURE__ */ jsx15(
11258
- Flex,
11259
- {
11260
- $justifyContent: "space-between",
11261
- $alignItems: "center",
11262
- $margin: "0 0 1rem",
11263
- $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.125)",
11264
- $padding: "0.375rem 1rem",
11265
- $borderRadius: "9999px",
11266
- children: /* @__PURE__ */ jsxs10(Text, { $font: theme.typography.text.fontFamily, $size: 14, children: [
11267
- "\u{1F4B3} Card ending in ",
11268
- paymentMethod.cardLast4
11269
- ] })
11737
+ const { data } = useEmbed();
11738
+ const features = useMemo9(() => {
11739
+ return (data.featureUsage?.features || []).map(
11740
+ ({
11741
+ access,
11742
+ allocation,
11743
+ allocationType,
11744
+ feature,
11745
+ period,
11746
+ usage,
11747
+ ...props2
11748
+ }) => {
11749
+ return {
11750
+ access,
11751
+ allocation,
11752
+ allocationType,
11753
+ feature,
11754
+ period,
11755
+ /**
11756
+ * @TODO: resolve feature price
11757
+ */
11758
+ price: void 0,
11759
+ usage,
11760
+ ...props2
11761
+ };
11270
11762
  }
11271
- ),
11272
- layout === "payment" && createPortal2(
11273
- /* @__PURE__ */ jsxs10(Modal, { size: "md", children: [
11274
- /* @__PURE__ */ jsx15(ModalHeader, { children: /* @__PURE__ */ jsx15(Box, { $fontWeight: "600", children: "Edit payment method" }) }),
11275
- /* @__PURE__ */ jsxs10(
11276
- Flex,
11277
- {
11278
- $flexDirection: "column",
11279
- $padding: "2.5rem",
11280
- $height: "100%",
11281
- $gap: "1.5rem",
11282
- children: [
11283
- /* @__PURE__ */ jsx15(
11284
- Flex,
11285
- {
11286
- $flexDirection: "column",
11287
- $gap: "1rem",
11288
- $backgroundColor: "#FBFBFB",
11289
- $borderRadius: "0 0 0.5rem 0.5rem",
11290
- $flex: "1",
11291
- $height: "100%",
11292
- children: /* @__PURE__ */ jsxs10(Flex, { $flexDirection: "column", $height: "100%", children: [
11293
- /* @__PURE__ */ jsx15(
11294
- Box,
11295
- {
11296
- $fontSize: "18px",
11297
- $marginBottom: "1.5rem",
11298
- $display: "inline-block",
11299
- $width: "100%",
11300
- children: "Default"
11301
- }
11302
- ),
11303
- /* @__PURE__ */ jsxs10(Flex, { $gap: "1rem", children: [
11304
- /* @__PURE__ */ jsx15(
11305
- Flex,
11306
- {
11307
- $alignItems: "center",
11308
- $padding: ".5rem 1rem",
11309
- $border: "1px solid #E2E5E9",
11310
- $borderRadius: ".5rem",
11311
- $backgroundColor: "#ffffff",
11312
- $gap: "1rem",
11313
- $width: "100%",
11314
- children: /* @__PURE__ */ jsxs10(Flex, { $justifyContent: "space-between", $flex: "1", children: [
11315
- /* @__PURE__ */ jsxs10(Flex, { $alignItems: "center", $gap: "1rem", children: [
11316
- /* @__PURE__ */ jsx15(Box, { $display: "inline-block", children: /* @__PURE__ */ jsx15(
11317
- "svg",
11318
- {
11319
- viewBox: "0 0 24 16",
11320
- fill: "none",
11321
- xmlns: "http://www.w3.org/2000/svg",
11322
- width: "26px",
11323
- height: "auto",
11324
- children: /* @__PURE__ */ jsxs10("g", { children: [
11325
- /* @__PURE__ */ jsx15(
11326
- "rect",
11327
- {
11328
- stroke: "#DDD",
11329
- fill: "#FFF",
11330
- x: ".25",
11331
- y: ".25",
11332
- width: "23",
11333
- height: "15.5",
11334
- rx: "2"
11335
- }
11336
- ),
11337
- /* @__PURE__ */ jsx15(
11338
- "path",
11339
- {
11340
- d: "M2.788 5.914A7.201 7.201 0 0 0 1 5.237l.028-.125h2.737c.371.013.672.125.77.519l.595 2.836.182.854 1.666-4.21h1.799l-2.674 6.167H4.304L2.788 5.914Zm7.312 5.37H8.399l1.064-6.172h1.7L10.1 11.284Zm6.167-6.021-.232 1.333-.153-.066a3.054 3.054 0 0 0-1.268-.236c-.671 0-.972.269-.98.531 0 .29.365.48.96.762.98.44 1.435.979 1.428 1.681-.014 1.28-1.176 2.108-2.96 2.108-.764-.007-1.5-.158-1.898-.328l.238-1.386.224.099c.553.23.917.328 1.596.328.49 0 1.015-.19 1.022-.604 0-.27-.224-.466-.882-.769-.644-.295-1.505-.788-1.491-1.674C11.878 5.84 13.06 5 14.74 5c.658 0 1.19.138 1.526.263Zm2.26 3.834h1.415c-.07-.308-.392-1.786-.392-1.786l-.12-.531c-.083.23-.23.604-.223.59l-.68 1.727Zm2.1-3.985L22 11.284h-1.575s-.154-.71-.203-.926h-2.184l-.357.926h-1.785l2.527-5.66c.175-.4.483-.512.889-.512h1.316Z",
11341
- fill: "#1434CB"
11342
- }
11343
- )
11344
- ] })
11345
- }
11346
- ) }),
11347
- /* @__PURE__ */ jsx15(Box, { $whiteSpace: "nowrap", children: "Visa **** 4242" })
11348
- ] }),
11349
- /* @__PURE__ */ jsx15(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx15(Box, { $fontSize: "12px", $color: "#5D5D5D", children: "Expires: 3/30" }) })
11350
- ] })
11351
- }
11352
- ),
11353
- /* @__PURE__ */ jsx15(Flex, { children: /* @__PURE__ */ jsx15(
11354
- StyledButton,
11355
- {
11356
- $size: "sm",
11357
- $color: "primary",
11358
- $variant: "outline",
11359
- style: {
11360
- whiteSpace: "nowrap",
11361
- paddingLeft: "1rem",
11362
- paddingRight: "1rem"
11363
- },
11364
- children: "Edit"
11365
- }
11366
- ) })
11367
- ] })
11368
- ] })
11369
- }
11370
- ),
11371
- /* @__PURE__ */ jsx15(
11372
- Flex,
11373
- {
11374
- $flexDirection: "column",
11375
- $gap: "1rem",
11376
- $backgroundColor: "#FBFBFB",
11377
- $borderRadius: "0 0 0.5rem 0.5rem",
11378
- $flex: "1",
11379
- $height: "100%",
11380
- children: /* @__PURE__ */ jsxs10(Flex, { $flexDirection: "column", $height: "100%", children: [
11381
- /* @__PURE__ */ jsx15(
11382
- Box,
11383
- {
11384
- $fontSize: "18px",
11385
- $marginBottom: "1.5rem",
11386
- $display: "inline-block",
11387
- $width: "100%",
11388
- children: "Others"
11389
- }
11390
- ),
11391
- /* @__PURE__ */ jsxs10(Flex, { $gap: "1rem", children: [
11392
- /* @__PURE__ */ jsx15(
11393
- Flex,
11394
- {
11395
- $alignItems: "center",
11396
- $padding: ".5rem 1rem",
11397
- $border: "1px solid #E2E5E9",
11398
- $borderRadius: ".5rem",
11399
- $backgroundColor: "#ffffff",
11400
- $gap: "1rem",
11401
- $width: "100%",
11402
- children: /* @__PURE__ */ jsxs10(Flex, { $justifyContent: "space-between", $flex: "1", children: [
11403
- /* @__PURE__ */ jsxs10(Flex, { $alignItems: "center", $gap: "1rem", children: [
11404
- /* @__PURE__ */ jsx15(Box, { $display: "inline-block", children: /* @__PURE__ */ jsx15(
11405
- "svg",
11406
- {
11407
- viewBox: "0 0 24 16",
11408
- fill: "none",
11409
- xmlns: "http://www.w3.org/2000/svg",
11410
- width: "26px",
11411
- height: "auto",
11412
- children: /* @__PURE__ */ jsxs10("g", { children: [
11413
- /* @__PURE__ */ jsx15(
11414
- "rect",
11415
- {
11416
- stroke: "#DDD",
11417
- fill: "#FFF",
11418
- x: ".25",
11419
- y: ".25",
11420
- width: "23",
11421
- height: "15.5",
11422
- rx: "2"
11423
- }
11424
- ),
11425
- /* @__PURE__ */ jsx15(
11426
- "path",
11427
- {
11428
- d: "M2.788 5.914A7.201 7.201 0 0 0 1 5.237l.028-.125h2.737c.371.013.672.125.77.519l.595 2.836.182.854 1.666-4.21h1.799l-2.674 6.167H4.304L2.788 5.914Zm7.312 5.37H8.399l1.064-6.172h1.7L10.1 11.284Zm6.167-6.021-.232 1.333-.153-.066a3.054 3.054 0 0 0-1.268-.236c-.671 0-.972.269-.98.531 0 .29.365.48.96.762.98.44 1.435.979 1.428 1.681-.014 1.28-1.176 2.108-2.96 2.108-.764-.007-1.5-.158-1.898-.328l.238-1.386.224.099c.553.23.917.328 1.596.328.49 0 1.015-.19 1.022-.604 0-.27-.224-.466-.882-.769-.644-.295-1.505-.788-1.491-1.674C11.878 5.84 13.06 5 14.74 5c.658 0 1.19.138 1.526.263Zm2.26 3.834h1.415c-.07-.308-.392-1.786-.392-1.786l-.12-.531c-.083.23-.23.604-.223.59l-.68 1.727Zm2.1-3.985L22 11.284h-1.575s-.154-.71-.203-.926h-2.184l-.357.926h-1.785l2.527-5.66c.175-.4.483-.512.889-.512h1.316Z",
11429
- fill: "#1434CB"
11430
- }
11431
- )
11432
- ] })
11433
- }
11434
- ) }),
11435
- /* @__PURE__ */ jsx15(Box, { $whiteSpace: "nowrap", children: "Visa **** 2929" })
11436
- ] }),
11437
- /* @__PURE__ */ jsx15(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx15(Box, { $fontSize: "12px", $color: "#5D5D5D", children: "Expires: 3/30" }) })
11438
- ] })
11439
- }
11440
- ),
11441
- /* @__PURE__ */ jsxs10(Flex, { $gap: "1rem", children: [
11442
- /* @__PURE__ */ jsx15(
11443
- StyledButton,
11444
- {
11445
- $size: "sm",
11446
- $color: "primary",
11447
- $variant: "outline",
11448
- style: {
11449
- whiteSpace: "nowrap",
11450
- paddingLeft: "1rem",
11451
- paddingRight: "1rem"
11452
- },
11453
- children: "Make Default"
11454
- }
11455
- ),
11456
- /* @__PURE__ */ jsx15(
11457
- StyledButton,
11458
- {
11459
- $size: "sm",
11460
- $color: "primary",
11461
- $variant: "outline",
11462
- style: {
11463
- whiteSpace: "nowrap",
11464
- paddingLeft: "1rem",
11465
- paddingRight: "1rem"
11466
- },
11467
- children: "Edit"
11468
- }
11469
- )
11470
- ] })
11471
- ] })
11472
- ] })
11473
- }
11474
- )
11763
+ );
11764
+ }, [data.featureUsage]);
11765
+ return /* @__PURE__ */ jsx14(Flex, { ref, className, $flexDirection: "column", $gap: "1.5rem", children: features.reduce(
11766
+ (acc, { allocation, allocationType, feature, usage }, index) => {
11767
+ if (!props.isVisible || allocationType !== "numeric" || typeof allocation !== "number") {
11768
+ return acc;
11769
+ }
11770
+ return [
11771
+ ...acc,
11772
+ /* @__PURE__ */ jsxs9(Flex, { $gap: "1.5rem", children: [
11773
+ props.icon.isVisible && feature?.icon && /* @__PURE__ */ jsx14(Box, { $flexShrink: "0", children: /* @__PURE__ */ jsx14(IconRound, { name: feature.icon, size: "sm" }) }),
11774
+ /* @__PURE__ */ jsxs9(Box, { $flexGrow: "1", children: [
11775
+ /* @__PURE__ */ jsxs9(Flex, { children: [
11776
+ feature?.name && /* @__PURE__ */ jsxs9(Box, { $flexGrow: "1", children: [
11777
+ /* @__PURE__ */ jsx14(
11778
+ Text,
11779
+ {
11780
+ as: Box,
11781
+ $font: theme.typography[props.header.fontStyle].fontFamily,
11782
+ $size: theme.typography[props.header.fontStyle].fontSize,
11783
+ $weight: theme.typography[props.header.fontStyle].fontWeight,
11784
+ $color: theme.typography[props.header.fontStyle].color,
11785
+ children: feature.name
11786
+ }
11787
+ ),
11788
+ props.description.isVisible && /* @__PURE__ */ jsx14(
11789
+ Text,
11790
+ {
11791
+ as: Box,
11792
+ $font: theme.typography[props.description.fontStyle].fontFamily,
11793
+ $size: theme.typography[props.description.fontStyle].fontSize,
11794
+ $weight: theme.typography[props.description.fontStyle].fontWeight,
11795
+ $color: theme.typography[props.description.fontStyle].color,
11796
+ children: feature.description
11797
+ }
11798
+ )
11799
+ ] }),
11800
+ allocationType === "numeric" && feature?.name && /* @__PURE__ */ jsxs9(Box, { $textAlign: "right", children: [
11801
+ props.allocation.isVisible && /* @__PURE__ */ jsx14(
11802
+ Text,
11803
+ {
11804
+ as: Box,
11805
+ $font: theme.typography[props.allocation.fontStyle].fontFamily,
11806
+ $size: theme.typography[props.allocation.fontStyle].fontSize,
11807
+ $weight: theme.typography[props.allocation.fontStyle].fontWeight,
11808
+ $color: theme.typography[props.allocation.fontStyle].color,
11809
+ children: typeof allocation === "number" ? `${allocation} ${feature.name}` : `Unlimited ${feature.name}`
11810
+ }
11811
+ ),
11812
+ props.usage.isVisible && /* @__PURE__ */ jsx14(
11813
+ Text,
11814
+ {
11815
+ as: Box,
11816
+ $font: theme.typography[props.usage.fontStyle].fontFamily,
11817
+ $size: theme.typography[props.usage.fontStyle].fontSize,
11818
+ $weight: theme.typography[props.usage.fontStyle].fontWeight,
11819
+ $color: theme.typography[props.usage.fontStyle].color,
11820
+ children: typeof allocation === "number" ? `${usage} of ${allocation} used` : `${usage} used`
11821
+ }
11822
+ )
11823
+ ] })
11824
+ ] }),
11825
+ typeof usage === "number" && typeof allocation === "number" && /* @__PURE__ */ jsx14(Box, { children: /* @__PURE__ */ jsx14(
11826
+ ProgressBar,
11827
+ {
11828
+ progress: usage / allocation * 100,
11829
+ value: usage,
11830
+ total: allocation,
11831
+ color: "blue"
11832
+ }
11833
+ ) })
11834
+ ] })
11835
+ ] }, index)
11836
+ ];
11837
+ },
11838
+ []
11839
+ ) });
11840
+ });
11841
+
11842
+ // src/components/elements/upcoming-bill/UpcomingBill.tsx
11843
+ import { forwardRef as forwardRef5, useMemo as useMemo10 } from "react";
11844
+ import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
11845
+ function resolveDesignProps5(props) {
11846
+ return {
11847
+ header: {
11848
+ isVisible: props.header?.isVisible ?? true,
11849
+ fontStyle: props.header?.fontStyle ?? "heading4",
11850
+ prefix: props.header?.prefix ?? "Next bill due"
11851
+ },
11852
+ price: {
11853
+ isVisible: props.price?.isVisible ?? true,
11854
+ fontStyle: props.price?.fontStyle ?? "heading1"
11855
+ },
11856
+ contractEndDate: {
11857
+ isVisible: props.contractEndDate?.isVisible ?? true,
11858
+ fontStyle: props.contractEndDate?.fontStyle ?? "heading6",
11859
+ prefix: props.contractEndDate?.prefix ?? "Contract ends"
11860
+ }
11861
+ };
11862
+ }
11863
+ var UpcomingBill = forwardRef5(({ className, ...rest }, ref) => {
11864
+ const props = resolveDesignProps5(rest);
11865
+ const theme = nt();
11866
+ const { data, stripe } = useEmbed();
11867
+ const { upcomingInvoice } = useMemo10(() => {
11868
+ return {
11869
+ upcomingInvoice: {
11870
+ ...data.upcomingInvoice?.amountDue && {
11871
+ amountDue: data.upcomingInvoice.amountDue
11872
+ },
11873
+ ...data.subscription?.interval && {
11874
+ interval: data.subscription.interval
11875
+ },
11876
+ ...data.upcomingInvoice?.dueDate && {
11877
+ dueDate: toPrettyDate(new Date(data.upcomingInvoice.dueDate))
11878
+ }
11879
+ }
11880
+ };
11881
+ }, [data.subscription, data.upcomingInvoice]);
11882
+ if (!stripe || !upcomingInvoice.amountDue || !upcomingInvoice.dueDate) {
11883
+ return null;
11884
+ }
11885
+ return /* @__PURE__ */ jsxs10("div", { ref, className, children: [
11886
+ props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */ jsx15(
11887
+ Flex,
11888
+ {
11889
+ $justifyContent: "space-between",
11890
+ $alignItems: "center",
11891
+ $margin: "0 0 0.75rem",
11892
+ children: /* @__PURE__ */ jsxs10(
11893
+ Text,
11894
+ {
11895
+ $font: theme.typography[props.header.fontStyle].fontFamily,
11896
+ $size: theme.typography[props.header.fontStyle].fontSize,
11897
+ $weight: theme.typography[props.header.fontStyle].fontWeight,
11898
+ $color: theme.typography[props.header.fontStyle].color,
11899
+ children: [
11900
+ props.header.prefix,
11901
+ " ",
11902
+ upcomingInvoice.dueDate
11475
11903
  ]
11476
11904
  }
11477
11905
  )
11478
- ] }),
11479
- portal || document.body
11480
- )
11906
+ }
11907
+ ),
11908
+ upcomingInvoice.amountDue && /* @__PURE__ */ jsxs10(Flex, { $justifyContent: "space-between", $alignItems: "start", $gap: "1rem", children: [
11909
+ props.price.isVisible && /* @__PURE__ */ jsx15(Flex, { $alignItems: "end", $flexGrow: "1", children: /* @__PURE__ */ jsx15(
11910
+ Text,
11911
+ {
11912
+ $font: theme.typography[props.price.fontStyle].fontFamily,
11913
+ $size: theme.typography[props.price.fontStyle].fontSize,
11914
+ $weight: theme.typography[props.price.fontStyle].fontWeight,
11915
+ $color: theme.typography[props.price.fontStyle].color,
11916
+ $lineHeight: 1,
11917
+ children: formatCurrency(upcomingInvoice.amountDue)
11918
+ }
11919
+ ) }),
11920
+ /* @__PURE__ */ jsx15(Box, { $maxWidth: "10rem", $lineHeight: "1", $textAlign: "right", children: /* @__PURE__ */ jsx15(
11921
+ Text,
11922
+ {
11923
+ $font: theme.typography[props.contractEndDate.fontStyle].fontFamily,
11924
+ $size: theme.typography[props.contractEndDate.fontStyle].fontSize,
11925
+ $weight: theme.typography[props.contractEndDate.fontStyle].fontWeight,
11926
+ $color: theme.typography[props.contractEndDate.fontStyle].color,
11927
+ children: "Estimated monthly bill."
11928
+ }
11929
+ ) })
11930
+ ] })
11481
11931
  ] });
11482
11932
  });
11483
11933
 
@@ -11583,7 +12033,7 @@ var Invoices = forwardRef6(({ className, ...rest }, ref) => {
11583
12033
  });
11584
12034
 
11585
12035
  // src/components/embed/ComponentTree.tsx
11586
- import { useEffect as useEffect5, useState as useState4, Children } from "react";
12036
+ import { useEffect as useEffect5, useState as useState5, Children } from "react";
11587
12037
 
11588
12038
  // src/components/embed/renderer.ts
11589
12039
  import { createElement } from "react";
@@ -11592,7 +12042,7 @@ import { createElement } from "react";
11592
12042
  import { forwardRef as forwardRef7 } from "react";
11593
12043
  import { jsx as jsx17 } from "react/jsx-runtime";
11594
12044
  var Root = forwardRef7(
11595
- (props, ref) => {
12045
+ ({ data, settings, ...props }, ref) => {
11596
12046
  return /* @__PURE__ */ jsx17("div", { ref, ...props });
11597
12047
  }
11598
12048
  );
@@ -11606,57 +12056,142 @@ var StyledViewport = dt.div`
11606
12056
  flex-wrap: wrap;
11607
12057
  margin-left: auto;
11608
12058
  margin-right: auto;
12059
+ gap: 1rem;
11609
12060
  `;
11610
12061
 
11611
- // src/components/layout/viewport/Viewport.tsx
12062
+ // src/components/layout/RenderLayout.tsx
12063
+ import { useState as useState4 } from "react";
12064
+ import { useEffect as useEffect4 } from "react";
11612
12065
  import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
12066
+ var DisabledState = () => {
12067
+ const theme = nt();
12068
+ return /* @__PURE__ */ jsx18(Box, { $width: "100%", children: /* @__PURE__ */ jsxs12(
12069
+ Flex,
12070
+ {
12071
+ $flexDirection: "column",
12072
+ $padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
12073
+ $width: "100%",
12074
+ $height: "auto",
12075
+ $borderRadius: `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`,
12076
+ $backgroundColor: theme.card.background,
12077
+ $alignItems: "center",
12078
+ $justifyContent: "center",
12079
+ children: [
12080
+ /* @__PURE__ */ jsx18(
12081
+ Box,
12082
+ {
12083
+ $marginBottom: "8px",
12084
+ $fontSize: `${theme.typography.heading1.fontSize / TEXT_BASE_SIZE}rem`,
12085
+ $fontFamily: theme.typography.heading1.fontFamily,
12086
+ $fontWeight: theme.typography.heading1.fontWeight,
12087
+ $color: theme.typography.heading1.color,
12088
+ children: "Coming soon"
12089
+ }
12090
+ ),
12091
+ /* @__PURE__ */ jsx18(
12092
+ Box,
12093
+ {
12094
+ $marginBottom: "8px",
12095
+ $fontSize: `${theme.typography.text.fontSize / TEXT_BASE_SIZE}rem`,
12096
+ $fontFamily: theme.typography.text.fontFamily,
12097
+ $fontWeight: theme.typography.text.fontWeight,
12098
+ $color: theme.typography.text.color,
12099
+ children: "The plan manager will be back very soon."
12100
+ }
12101
+ )
12102
+ ]
12103
+ }
12104
+ ) });
12105
+ };
12106
+ var SuccessState = () => {
12107
+ const [isOpen, setIsOpen] = useState4(true);
12108
+ const theme = nt();
12109
+ const { hydrate, data, api, setLayout, isPending } = useEmbed();
12110
+ useEffect4(() => {
12111
+ if (api && data.component?.id) {
12112
+ hydrate();
12113
+ setTimeout(() => setIsOpen(false), 2e3);
12114
+ }
12115
+ }, [api, data.component?.id, hydrate]);
12116
+ useEffect4(() => {
12117
+ if (!isPending && !isOpen) {
12118
+ setLayout("portal");
12119
+ }
12120
+ }, [isPending, isOpen, setLayout]);
12121
+ return /* @__PURE__ */ jsxs12(
12122
+ Flex,
12123
+ {
12124
+ $flexDirection: "column",
12125
+ $justifyContent: "center",
12126
+ $alignItems: "center",
12127
+ $gap: `${32 / TEXT_BASE_SIZE}rem`,
12128
+ $width: "min-content",
12129
+ $height: "min-content",
12130
+ $margin: "auto",
12131
+ $padding: `${theme.card.padding / TEXT_BASE_SIZE}rem ${theme.card.padding * 1.5 / TEXT_BASE_SIZE}rem`,
12132
+ $whiteSpace: "nowrap",
12133
+ $backgroundColor: theme.card.background,
12134
+ $borderRadius: "0.5rem",
12135
+ $boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
12136
+ children: [
12137
+ /* @__PURE__ */ jsx18(
12138
+ IconRound,
12139
+ {
12140
+ name: "check",
12141
+ size: "3xl",
12142
+ colors: [theme.card.background, theme.primary]
12143
+ }
12144
+ ),
12145
+ /* @__PURE__ */ jsx18(
12146
+ Text,
12147
+ {
12148
+ as: "h1",
12149
+ $font: theme.typography.heading1.fontFamily,
12150
+ $size: theme.typography.heading1.fontSize,
12151
+ $weight: theme.typography.heading1.fontWeight,
12152
+ $color: theme.typography.heading1.color,
12153
+ children: "Subscription updated!"
12154
+ }
12155
+ ),
12156
+ /* @__PURE__ */ jsx18(
12157
+ Text,
12158
+ {
12159
+ as: "p",
12160
+ $font: theme.typography.text.fontFamily,
12161
+ $size: theme.typography.text.fontSize,
12162
+ $weight: theme.typography.text.fontWeight,
12163
+ $color: theme.typography.text.color,
12164
+ children: "Loading..."
12165
+ }
12166
+ )
12167
+ ]
12168
+ }
12169
+ );
12170
+ };
12171
+ var RenderLayout = ({ children }) => {
12172
+ const { layout } = useEmbed();
12173
+ switch (layout) {
12174
+ case "disabled":
12175
+ return /* @__PURE__ */ jsx18(DisabledState, {});
12176
+ case "success":
12177
+ return /* @__PURE__ */ jsx18(SuccessState, {});
12178
+ default:
12179
+ return children;
12180
+ }
12181
+ };
12182
+
12183
+ // src/components/layout/viewport/Viewport.tsx
12184
+ import { jsx as jsx19 } from "react/jsx-runtime";
11613
12185
  var Viewport = forwardRef8(
11614
12186
  ({ children, ...props }, ref) => {
11615
12187
  const theme = nt();
11616
- const { layout } = useEmbed();
11617
- return /* @__PURE__ */ jsx18(
12188
+ return /* @__PURE__ */ jsx19(
11618
12189
  StyledViewport,
11619
12190
  {
11620
12191
  ref,
11621
12192
  $numberOfColumns: theme.numberOfColumns,
11622
12193
  ...props,
11623
- children: layout === "disabled" ? /* @__PURE__ */ jsx18(Box, { $width: "100%", children: /* @__PURE__ */ jsxs12(
11624
- Flex,
11625
- {
11626
- $flexDirection: "column",
11627
- $padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
11628
- $width: "100%",
11629
- $height: "auto",
11630
- $borderRadius: `${theme.card.borderRadius / TEXT_BASE_SIZE}rem`,
11631
- $backgroundColor: theme.card.background,
11632
- $alignItems: "center",
11633
- $justifyContent: "center",
11634
- children: [
11635
- /* @__PURE__ */ jsx18(
11636
- Box,
11637
- {
11638
- $marginBottom: "8px",
11639
- $fontSize: `${theme.typography.heading1.fontSize / TEXT_BASE_SIZE}rem`,
11640
- $fontFamily: theme.typography.heading1.fontFamily,
11641
- $fontWeight: theme.typography.heading1.fontWeight,
11642
- $color: theme.typography.heading1.color,
11643
- children: "Coming soon"
11644
- }
11645
- ),
11646
- /* @__PURE__ */ jsx18(
11647
- Box,
11648
- {
11649
- $marginBottom: "8px",
11650
- $fontSize: `${theme.typography.text.fontSize / TEXT_BASE_SIZE}rem`,
11651
- $fontFamily: theme.typography.text.fontFamily,
11652
- $fontWeight: theme.typography.text.fontWeight,
11653
- $color: theme.typography.text.color,
11654
- children: "The plan manager will be back very soon."
11655
- }
11656
- )
11657
- ]
11658
- }
11659
- ) }) : children
12194
+ children: /* @__PURE__ */ jsx19(RenderLayout, { children })
11660
12195
  }
11661
12196
  );
11662
12197
  }
@@ -11727,11 +12262,11 @@ var StyledCard = dt.div(
11727
12262
  );
11728
12263
 
11729
12264
  // src/components/layout/card/Card.tsx
11730
- import { jsx as jsx19 } from "react/jsx-runtime";
12265
+ import { jsx as jsx20 } from "react/jsx-runtime";
11731
12266
  var Card = forwardRef9(
11732
12267
  ({ children, className }, ref) => {
11733
12268
  const theme = nt();
11734
- return /* @__PURE__ */ jsx19(
12269
+ return /* @__PURE__ */ jsx20(
11735
12270
  StyledCard,
11736
12271
  {
11737
12272
  ref,
@@ -11749,14 +12284,13 @@ var Card = forwardRef9(
11749
12284
  // src/components/layout/column/styles.ts
11750
12285
  var StyledColumn = dt.div`
11751
12286
  flex-grow: 1;
11752
- padding: 0.75rem;
11753
12287
  `;
11754
12288
 
11755
12289
  // src/components/layout/column/Column.tsx
11756
- import { jsx as jsx20 } from "react/jsx-runtime";
12290
+ import { jsx as jsx21 } from "react/jsx-runtime";
11757
12291
  var Column = forwardRef10(
11758
- ({ children, ...props }, ref) => {
11759
- return /* @__PURE__ */ jsx20(StyledColumn, { ref, ...props, children: /* @__PURE__ */ jsx20(Card, { children }) });
12292
+ ({ children, basis, ...props }, ref) => {
12293
+ return /* @__PURE__ */ jsx21(StyledColumn, { ref, ...props, children: /* @__PURE__ */ jsx21(Card, { children }) });
11760
12294
  }
11761
12295
  );
11762
12296
 
@@ -11774,7 +12308,7 @@ var components = {
11774
12308
  function createRenderer(options) {
11775
12309
  const { useFallback = false } = options || {};
11776
12310
  return function renderNode(node2, index) {
11777
- const { type, props = {}, custom = {}, children } = node2;
12311
+ const { type, props = {}, children } = node2;
11778
12312
  const name = typeof type !== "string" ? type.resolvedName : type;
11779
12313
  const component = useFallback ? components[name] || "div" : components[name];
11780
12314
  if (!components[name]) {
@@ -11792,40 +12326,20 @@ function createRenderer(options) {
11792
12326
  return createElement(
11793
12327
  component,
11794
12328
  {
12329
+ key: index,
11795
12330
  className,
11796
- ...component !== "div" && { ...resolvedProps },
11797
- ...component !== "div" && Object.keys(custom).length > 0 && { custom },
11798
- key: index
12331
+ ...component !== "div" && { ...resolvedProps }
11799
12332
  },
11800
12333
  resolvedChildren
11801
12334
  );
11802
12335
  };
11803
12336
  }
11804
12337
 
11805
- // src/components/ui/loader/styles.ts
11806
- var spin = mt`
11807
- 0% {
11808
- transform: rotate(0deg);
11809
- }
11810
- 100% {
11811
- transform: rotate(360deg);
11812
- }
11813
- `;
11814
- var Loader = dt.div`
11815
- border: ${({ theme }) => `${4 / TEXT_BASE_SIZE}rem solid hsla(0, 0%, ${hexToHSL(theme.card.background).l > 50 ? 0 : 100}%, 0.1)`};
11816
- border-top: ${4 / TEXT_BASE_SIZE}rem solid ${({ theme }) => theme.primary};
11817
- border-radius: 50%;
11818
- width: ${40 / TEXT_BASE_SIZE}rem;
11819
- height: ${40 / TEXT_BASE_SIZE}rem;
11820
- animation: ${spin} 1.5s linear infinite;
11821
- display: inline-block;
11822
- `;
11823
-
11824
12338
  // src/components/embed/ComponentTree.tsx
11825
- import { Fragment as Fragment2, jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
12339
+ import { Fragment as Fragment2, jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
11826
12340
  var Loading = () => {
11827
12341
  const theme = nt();
11828
- return /* @__PURE__ */ jsx21(
12342
+ return /* @__PURE__ */ jsx22(
11829
12343
  Flex,
11830
12344
  {
11831
12345
  $width: "100%",
@@ -11833,7 +12347,7 @@ var Loading = () => {
11833
12347
  $alignItems: "center",
11834
12348
  $justifyContent: "center",
11835
12349
  $padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
11836
- children: /* @__PURE__ */ jsx21(Loader, {})
12350
+ children: /* @__PURE__ */ jsx22(Loader, {})
11837
12351
  }
11838
12352
  );
11839
12353
  };
@@ -11851,7 +12365,7 @@ var Error2 = ({ message }) => {
11851
12365
  $alignItems: "center",
11852
12366
  $justifyContent: "center",
11853
12367
  children: [
11854
- /* @__PURE__ */ jsx21(
12368
+ /* @__PURE__ */ jsx22(
11855
12369
  Box,
11856
12370
  {
11857
12371
  $marginBottom: `${8 / TEXT_BASE_SIZE}rem`,
@@ -11862,7 +12376,7 @@ var Error2 = ({ message }) => {
11862
12376
  children: "404 Error"
11863
12377
  }
11864
12378
  ),
11865
- /* @__PURE__ */ jsx21(
12379
+ /* @__PURE__ */ jsx22(
11866
12380
  Box,
11867
12381
  {
11868
12382
  $marginBottom: `${8 / TEXT_BASE_SIZE}rem`,
@@ -11879,30 +12393,30 @@ var Error2 = ({ message }) => {
11879
12393
  };
11880
12394
  var ComponentTree = () => {
11881
12395
  const { error, nodes } = useEmbed();
11882
- const [children, setChildren] = useState4(/* @__PURE__ */ jsx21(Loading, {}));
12396
+ const [children, setChildren] = useState5(/* @__PURE__ */ jsx22(Loading, {}));
11883
12397
  useEffect5(() => {
11884
12398
  const renderer = createRenderer();
11885
12399
  setChildren(nodes.map(renderer));
11886
12400
  }, [nodes]);
11887
12401
  if (error) {
11888
- return /* @__PURE__ */ jsx21(Error2, { message: error.message });
12402
+ return /* @__PURE__ */ jsx22(Error2, { message: error.message });
11889
12403
  }
11890
12404
  if (Children.count(children) === 0) {
11891
- return /* @__PURE__ */ jsx21(Loading, {});
12405
+ return /* @__PURE__ */ jsx22(Loading, {});
11892
12406
  }
11893
- return /* @__PURE__ */ jsx21(Fragment2, { children });
12407
+ return /* @__PURE__ */ jsx22(Fragment2, { children });
11894
12408
  };
11895
12409
 
11896
12410
  // src/components/embed/Embed.tsx
11897
- import { jsx as jsx22 } from "react/jsx-runtime";
12411
+ import { jsx as jsx23 } from "react/jsx-runtime";
11898
12412
  var SchematicEmbed = ({ id, accessToken, apiConfig }) => {
11899
12413
  if (accessToken?.length === 0) {
11900
- return /* @__PURE__ */ jsx22("div", { children: "Please provide an access token." });
12414
+ return /* @__PURE__ */ jsx23("div", { children: "Please provide an access token." });
11901
12415
  }
11902
12416
  if (!accessToken?.startsWith("token_")) {
11903
- return /* @__PURE__ */ jsx22("div", { children: 'Invalid access token; your temporary access token will start with "token_".' });
12417
+ return /* @__PURE__ */ jsx23("div", { children: 'Invalid access token; your temporary access token will start with "token_".' });
11904
12418
  }
11905
- return /* @__PURE__ */ jsx22(EmbedProvider, { id, accessToken, apiConfig, children: /* @__PURE__ */ jsx22(ComponentTree, {}) });
12419
+ return /* @__PURE__ */ jsx23(EmbedProvider, { id, accessToken, apiConfig, children: /* @__PURE__ */ jsx23(ComponentTree, {}) });
11906
12420
  };
11907
12421
  export {
11908
12422
  Box,
@@ -11916,6 +12430,7 @@ export {
11916
12430
  IconRound,
11917
12431
  IncludedFeatures,
11918
12432
  Invoices,
12433
+ Loader,
11919
12434
  MeteredFeatures,
11920
12435
  Modal,
11921
12436
  ModalHeader,