@feathery/react 2.23.3 → 2.23.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/cjs/Form/index.d.ts.map +1 -1
  2. package/cjs/auth/internal/utils.d.ts.map +1 -1
  3. package/cjs/elements/fields/PhoneField/CountryDropdown.d.ts.map +1 -1
  4. package/cjs/elements/fields/PhoneField/index.d.ts.map +1 -1
  5. package/cjs/elements/fields/PhoneField/tests/test-utils.d.ts.map +1 -1
  6. package/cjs/{fthry_FormControl.BgJi7H3j.js → fthry_FormControl.CscXHID3.js} +1 -1
  7. package/cjs/{fthry_InlineTooltip.C0fcrMAl.js → fthry_InlineTooltip.ZpgEmPO3.js} +2 -2
  8. package/cjs/{fthry_Overlay.DVxwKvvt.js → fthry_Overlay.BTS_EcV3.js} +1 -1
  9. package/cjs/{fthry_PaymentMethodField.B_GDmxLy.js → fthry_PaymentMethodField.D902pJlo.js} +4 -4
  10. package/cjs/{fthry_Placeholder.Djw0_HfW.js → fthry_Placeholder.Ctq06SYu.js} +1 -1
  11. package/cjs/{fthry_ShowEyeIcon.BzYc1Yga.js → fthry_ShowEyeIcon.q9BhUK2g.js} +1 -1
  12. package/cjs/{fthry_index.ByVaPSCt.js → fthry_index.-Y9ZJS34.js} +6 -6
  13. package/cjs/{fthry_index.BPf3q0bZ.js → fthry_index.9PFsbc4I.js} +1 -1
  14. package/cjs/{fthry_index.BrrNGZQn.js → fthry_index.B4YVBeqY.js} +3 -3
  15. package/cjs/{fthry_index.Cs1MGCSE.js → fthry_index.BS6b2BTF.js} +6 -6
  16. package/cjs/{fthry_index.B0KReyAP.js → fthry_index.BYTU7WTg.js} +4 -4
  17. package/cjs/{fthry_index.CRDDUT1I.js → fthry_index.B_UehadW.js} +1 -1
  18. package/cjs/{fthry_index.ly3gOUU_.js → fthry_index.Bh5jAAhx.js} +6 -6
  19. package/cjs/{fthry_index.2nJBzqdc.js → fthry_index.Bl2kuNOo.js} +14 -16
  20. package/cjs/{fthry_index.Feu6uyn6.js → fthry_index.BmT77CVY.js} +2 -2
  21. package/cjs/{fthry_index.Bn7LKMrK.js → fthry_index.Bsklltx4.js} +1 -1
  22. package/cjs/{fthry_index.C_qw3SH5.js → fthry_index.BuQ1HIIN.js} +8 -8
  23. package/cjs/{fthry_index.CLTU9AAQ.js → fthry_index.C6-dnyHD.js} +1 -1
  24. package/cjs/{fthry_index.yAmVGVxf.js → fthry_index.CSwhuTPY.js} +1 -1
  25. package/cjs/{fthry_index.CBucgTSF.js → fthry_index.CTqVrxjv.js} +1 -1
  26. package/cjs/{fthry_index.mj0_Tc2V.js → fthry_index.CWofoHQs.js} +4 -4
  27. package/cjs/{fthry_index.Bo0inH5r.js → fthry_index.CbASwLjr.js} +1 -1
  28. package/cjs/{fthry_index.DH3KDEwG.js → fthry_index.D36o5hns.js} +5 -5
  29. package/cjs/{fthry_index.D5CGTQKa.js → fthry_index.DGctX9WE.js} +5 -5
  30. package/cjs/fthry_index.DKgFa6Cd.js +7245 -0
  31. package/cjs/{fthry_index.DVrmPZ9A.js → fthry_index.Jp2CJ4is.js} +2 -2
  32. package/cjs/{fthry_index.DYqW71E8.js → fthry_index.Nrwqiq0j.js} +5 -5
  33. package/cjs/{fthry_index.Dje6TQOt.js → fthry_index._iQAHcD9.js} +1307 -1273
  34. package/cjs/{fthry_index.DT82qJhW.js → fthry_index.dGUMsRB1.js} +4 -4
  35. package/cjs/{fthry_index.h9jJa8zh.js → fthry_index.jot4NArP.js} +3 -3
  36. package/cjs/{fthry_index.DQZt7KIS.js → fthry_index.lGGMSnRj.js} +1 -1
  37. package/cjs/{fthry_index.xFsG3Jma.js → fthry_index.mEUshDAA.js} +1 -1
  38. package/cjs/{fthry_input.C7oRNtWz.js → fthry_input.3JtjJgPY.js} +1 -1
  39. package/cjs/{fthry_script.NtkfplNS.js → fthry_script.DOCG8gyM.js} +1 -1
  40. package/cjs/{fthry_styles.CJtigNS-.js → fthry_styles.CVqE6wer.js} +1 -1
  41. package/cjs/{fthry_useElementSize.B3LEGWLi.js → fthry_useElementSize.B5-XFuix.js} +1 -1
  42. package/cjs/{fthry_useSalesforceSync.CUVT8Mvb.js → fthry_useSalesforceSync.D9f_IkFv.js} +1 -1
  43. package/cjs/{fthry_webfontloader.Dgu1OvOA.js → fthry_webfontloader.5X-HEWHN.js} +1 -1
  44. package/cjs/index.js +1 -1
  45. package/cjs/utils/validation.d.ts +4 -3
  46. package/cjs/utils/validation.d.ts.map +1 -1
  47. package/dist/Form/index.d.ts.map +1 -1
  48. package/dist/auth/internal/utils.d.ts.map +1 -1
  49. package/dist/elements/fields/PhoneField/CountryDropdown.d.ts.map +1 -1
  50. package/dist/elements/fields/PhoneField/index.d.ts.map +1 -1
  51. package/dist/elements/fields/PhoneField/tests/test-utils.d.ts.map +1 -1
  52. package/dist/{fthry_FormControl.DZ-yelpB.js → fthry_FormControl.Bt83gTi3.js} +1 -1
  53. package/dist/{fthry_InlineTooltip.C-94aZft.js → fthry_InlineTooltip.BADFGh_F.js} +2 -2
  54. package/dist/{fthry_Overlay.D60Mo5sc.js → fthry_Overlay.CsBPXuR_.js} +1 -1
  55. package/dist/{fthry_PaymentMethodField.DOD4xxBf.js → fthry_PaymentMethodField.CVKE3t_i.js} +4 -4
  56. package/dist/{fthry_Placeholder.Q6LOYgfy.js → fthry_Placeholder.9MqCxqHS.js} +1 -1
  57. package/dist/{fthry_ShowEyeIcon.DudVwlqL.js → fthry_ShowEyeIcon.CxXoA4_B.js} +1 -1
  58. package/dist/{fthry_index.BIezS_Js.js → fthry_index.5oEnjTzQ.js} +3 -3
  59. package/dist/{fthry_index.D_445pef.js → fthry_index.7TulZeVg.js} +6 -6
  60. package/dist/{fthry_index.BbQn1vco.js → fthry_index.AdQD-dII.js} +1 -1
  61. package/dist/{fthry_index.LLvosXZC.js → fthry_index.B0_n9jqc.js} +4 -4
  62. package/dist/{fthry_index.hD4VI9ak.js → fthry_index.BIkyi9OD.js} +4 -4
  63. package/dist/{fthry_index.DhrE0rpb.js → fthry_index.BPmvHG0R.js} +1 -1
  64. package/dist/{fthry_index.CA8KDA0W.js → fthry_index.BQTGcd6O.js} +8 -8
  65. package/dist/{fthry_index.BykB3HX8.js → fthry_index.BbSZxIR5.js} +2 -2
  66. package/dist/{fthry_index.DITsZWwh.js → fthry_index.Beh4LhUb.js} +4 -4
  67. package/dist/{fthry_index.C1kvOEHl.js → fthry_index.C0FNSGu0.js} +5 -5
  68. package/dist/{fthry_index.Ce0LfPTs.js → fthry_index.C4cVkdmR.js} +5 -5
  69. package/dist/{fthry_index.7fQDnsUX.js → fthry_index.CefyT_Xy.js} +3 -3
  70. package/dist/{fthry_index.BJXPVhqn.js → fthry_index.CnNPiyfF.js} +6 -6
  71. package/dist/{fthry_index.BbESsk-g.js → fthry_index.CsQzji9M.js} +1 -1
  72. package/dist/{fthry_index.BJAdYqCo.js → fthry_index.Cy8OGyJ9.js} +14 -16
  73. package/dist/{fthry_index.LL5LHx6u.js → fthry_index.CyjNCuWE.js} +1 -1
  74. package/dist/{fthry_index.BdHFQJ4O.js → fthry_index.D4ENNIPP.js} +1 -1
  75. package/dist/{fthry_index.saXzLiO5.js → fthry_index.D86GTeP3.js} +6 -6
  76. package/dist/{fthry_index.SaBEl6_L.js → fthry_index.Degy27gw.js} +1 -1
  77. package/dist/{fthry_index.DjoYiCbm.js → fthry_index.DoxZOyru.js} +2 -2
  78. package/dist/{fthry_index.BHl66fdc.js → fthry_index.DpU0lL2P.js} +1 -1
  79. package/dist/{fthry_index.C_ReA4YV.js → fthry_index.Dte366nP.js} +1 -1
  80. package/dist/{fthry_index.hnaQSM0L.js → fthry_index.EFk2iysz.js} +1308 -1274
  81. package/dist/{fthry_index.DqN9FbBz.js → fthry_index.FjbxGNs2.js} +5 -5
  82. package/dist/fthry_index.FxHyaooV.js +7193 -0
  83. package/dist/{fthry_index.E97uBUJr.js → fthry_index.qQius3J9.js} +1 -1
  84. package/dist/{fthry_input.DYl95BsH.js → fthry_input.BMNwRyD_.js} +1 -1
  85. package/dist/{fthry_script.BzxDIntC.js → fthry_script.0KhNn8f9.js} +1 -1
  86. package/dist/{fthry_styles.r3froItr.js → fthry_styles.DtCYeZPi.js} +1 -1
  87. package/dist/{fthry_useElementSize.D0Sv0zhM.js → fthry_useElementSize.fW6iiT11.js} +1 -1
  88. package/dist/{fthry_useSalesforceSync.ijGABR2r.js → fthry_useSalesforceSync.BIkirclp.js} +1 -1
  89. package/dist/{fthry_webfontloader.CI8nQbb6.js → fthry_webfontloader.Dyilj6id.js} +1 -1
  90. package/dist/index.js +1 -1
  91. package/dist/utils/validation.d.ts +4 -3
  92. package/dist/utils/validation.d.ts.map +1 -1
  93. package/package.json +2 -1
  94. package/umd/{PhoneField.f52b5de44614b445feeb.js → PhoneField.42eae8ec161c28522777.js} +1 -1
  95. package/umd/index.js +1 -1
  96. package/umd/libphonenumber.d53d0d1347fa5545ff45.js +1 -0
@@ -17570,373 +17570,726 @@ var isBase64Image = function (string) {
17570
17570
  return BASE64_REGEX.test(string);
17571
17571
  };
17572
17572
 
17573
- var plaidPromise = null;
17574
- function installPlaid(isPlaidActive) {
17575
- if (plaidPromise)
17576
- return plaidPromise;
17577
- else if (!isPlaidActive)
17578
- return Promise.resolve();
17579
- else {
17580
- plaidPromise = dynamicImport('https://cdn.plaid.com/link/v2/stable/link-initialize.js');
17581
- return plaidPromise;
17582
- }
17583
- }
17584
- function openPlaidLink(client, onSuccess, onExit, updateFieldValues, action, handleError) {
17585
- return __awaiter$2(this, void 0, void 0, function () {
17586
- var kwargs, res, handler;
17587
- var _this = this;
17588
- return __generator(this, function (_a) {
17589
- switch (_a.label) {
17590
- case 0: return [4 /*yield*/, plaidPromise];
17591
- case 1:
17592
- _a.sent();
17593
- if (action.plaid_action === 'identity') {
17594
- kwargs = {
17595
- identity_template_id: action.template_id,
17596
- email_field: action.email_field
17597
- };
17598
- }
17599
- else {
17600
- kwargs = { liabilities: action.include_liabilities ? 'true' : 'false' };
17601
- }
17602
- return [4 /*yield*/, client.fetchPlaidLinkToken(kwargs)];
17603
- case 2:
17604
- res = _a.sent();
17605
- if (res.err) {
17606
- handleError(res.err);
17607
- return [2 /*return*/];
17608
- }
17609
- handler = global.Plaid.create({
17610
- token: res.token,
17611
- onExit: onExit,
17612
- onSuccess: function (publicToken, metadata) { return __awaiter$2(_this, void 0, void 0, function () {
17613
- var res_1, statusKey, newValues, res_2, fieldVals;
17614
- var _a;
17615
- var _b;
17616
- return __generator(this, function (_c) {
17617
- switch (_c.label) {
17618
- case 0:
17619
- _c.trys.push([0, 8, 9, 10]);
17620
- if (!(action.plaid_action === 'identity')) return [3 /*break*/, 4];
17621
- return [4 /*yield*/, client.fetchPlaidVerificationStatus(metadata.link_session_id)];
17622
- case 1:
17623
- res_1 = _c.sent();
17624
- statusKey = action.plaid_identity_field_key;
17625
- if (statusKey) {
17626
- newValues = (_a = {}, _a[statusKey] = res_1.status, _a);
17627
- updateFieldValues(newValues);
17628
- client.submitCustom(newValues, { shouldFlush: true });
17629
- }
17630
- if (!(res_1.status !== 'success')) return [3 /*break*/, 3];
17631
- handleError('Identity verification was not successful');
17632
- return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
17633
- case 2:
17634
- _c.sent();
17635
- return [2 /*return*/];
17636
- case 3: return [3 /*break*/, 6];
17637
- case 4:
17638
- if (!publicToken) return [3 /*break*/, 6];
17639
- res_2 = client.submitPlaidUserData(publicToken);
17640
- if (!((_b = action.wait_for_completion) !== null && _b !== void 0 ? _b : true)) return [3 /*break*/, 6];
17641
- return [4 /*yield*/, res_2];
17642
- case 5:
17643
- fieldVals = _c.sent();
17644
- updateFieldValues(fieldVals);
17645
- _c.label = 6;
17646
- case 6: return [4 /*yield*/, onSuccess()];
17647
- case 7:
17648
- _c.sent();
17649
- return [3 /*break*/, 10];
17650
- case 8:
17651
- _c.sent();
17652
- handleError();
17653
- return [3 /*break*/, 10];
17654
- case 9:
17655
- handler.exit();
17656
- handler.destroy();
17657
- return [7 /*endfinally*/];
17658
- case 10: return [2 /*return*/];
17659
- }
17660
- });
17661
- }); }
17662
- });
17663
- handler.open();
17664
- return [2 /*return*/];
17665
- }
17666
- });
17667
- });
17668
- }
17573
+ var isUrl_1;
17574
+ var hasRequiredIsUrl;
17669
17575
 
17670
- var RouterContext = createContext({
17671
- location: {
17672
- pathname: ''
17673
- },
17674
- navigate: function () { }
17675
- });
17676
- function RouterProvider(_a) {
17677
- var children = _a.children, _b = _a.initialPath, initialPath = _b === void 0 ? featheryWindow().location.pathname : _b;
17678
- var _c = __read(useState({ pathname: initialPath }), 2), location = _c[0], setLocation = _c[1];
17679
- var navigate = useCallback(function (to, options) {
17680
- if (options === void 0) { options = {}; }
17681
- var historyMethod = options.replace ? 'replaceState' : 'pushState';
17682
- featheryWindow().history[historyMethod](null, '', to);
17683
- setLocation({ pathname: to });
17684
- }, []);
17685
- // listen to browser back/forward navigation
17686
- useEffect(function () {
17687
- var window = featheryWindow();
17688
- var handlePopState = function () {
17689
- setLocation({ pathname: window.location.pathname });
17690
- };
17691
- window.addEventListener('popstate', handlePopState);
17692
- return function () { return window.removeEventListener('popstate', handlePopState); };
17693
- }, []);
17694
- var routerData = useMemo(function () { return ({
17695
- location: location,
17696
- navigate: navigate
17697
- }); }, [location, navigate]);
17698
- return (jsx$1(RouterContext.Provider, __assign({ value: routerData }, { children: children })));
17699
- }
17700
- function useLocation() {
17701
- var context = useContext(RouterContext);
17702
- if (!context)
17703
- throw new Error('useLocation must be used within RouterProvider');
17704
- return context.location;
17705
- }
17706
- function useNavigate() {
17707
- var context = useContext(RouterContext);
17708
- if (!context)
17709
- throw new Error('useNavigate must be used within RouterProvider');
17710
- return context.navigate;
17576
+ function requireIsUrl () {
17577
+ if (hasRequiredIsUrl) return isUrl_1;
17578
+ hasRequiredIsUrl = 1;
17579
+ /**
17580
+ * Expose `isUrl`.
17581
+ */
17582
+
17583
+ isUrl_1 = isUrl;
17584
+
17585
+ /**
17586
+ * RegExps.
17587
+ * A URL must match #1 and then at least one of #2/#3.
17588
+ * Use two levels of REs to avoid REDOS.
17589
+ */
17590
+
17591
+ var protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
17592
+
17593
+ var localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/;
17594
+ var nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/;
17595
+
17596
+ /**
17597
+ * Loosely validate a URL `string`.
17598
+ *
17599
+ * @param {String} string
17600
+ * @return {Boolean}
17601
+ */
17602
+
17603
+ function isUrl(string){
17604
+ if (typeof string !== 'string') {
17605
+ return false;
17606
+ }
17607
+
17608
+ var match = string.match(protocolAndDomainRE);
17609
+ if (!match) {
17610
+ return false;
17611
+ }
17612
+
17613
+ var everythingAfterProtocol = match[1];
17614
+ if (!everythingAfterProtocol) {
17615
+ return false;
17616
+ }
17617
+
17618
+ if (localhostDomainRE.test(everythingAfterProtocol) ||
17619
+ nonLocalhostDomainRE.test(everythingAfterProtocol)) {
17620
+ return true;
17621
+ }
17622
+
17623
+ return false;
17624
+ }
17625
+ return isUrl_1;
17711
17626
  }
17712
17627
 
17713
- var MIN_AXIS_SIZE = 15;
17714
- var FIT = 'fit';
17715
- var FILL = 'fill';
17716
- var isFill = function (v) { return v === FILL; };
17717
- var isFit = function (v) { return v === FIT; };
17718
- var isPx = function (v) {
17719
- return typeof v === 'string' && v.indexOf('px') >= 0 && v.indexOf('calc') < 0;
17720
- };
17721
- var getPxValue = function (size) {
17722
- return isPx(size) ? Number.parseFloat(size) : MIN_AXIS_SIZE;
17723
- };
17724
- var formatDimensionValue = function (value, type) {
17725
- // fit-content is needed to allow elements to push beyond the parent container's explicit height.
17726
- switch (value) {
17727
- case FILL:
17728
- return type === 'width' ? '100%' : 'auto';
17729
- case FIT:
17730
- return 'fit-content';
17731
- default:
17732
- return parseInt(value);
17733
- }
17734
- };
17735
- var calculateDimensionsHelper = function (root, p) {
17736
- if (p === void 0) { p = ''; }
17737
- var width = root["".concat(p, "width")] || root.width;
17738
- var height = root["".concat(p, "height")] || root.height;
17739
- var dimensions = {
17740
- maxWidth: formatDimensionValue(width, 'width'),
17741
- height: formatDimensionValue(height, 'height')
17742
- };
17743
- // to allow responsiveness, min width shouldn't be set for fixed widths
17744
- dimensions.minWidth = isNum(width) ? undefined : dimensions.maxWidth;
17745
- // min and max height must be 100% to prevent fit-content from collapsing, which would break fill's non-collapsing intent
17746
- dimensions.minHeight = isFill(height) ? '100%' : dimensions.height;
17747
- return dimensions;
17748
- };
17628
+ var isUrlExports = requireIsUrl();
17629
+ var isUrl = /*@__PURE__*/getDefaultExportFromCjs(isUrlExports);
17630
+
17631
+ var LETTER_MATCH = /[a-zA-Z]/;
17632
+ var UPPERCASE_LETTER_MATCH = /[A-Z]/;
17633
+ var LOWERCASE_LETTER_MATCH = /[a-z]/;
17634
+ var NUMBER_MATCH = /\d/;
17635
+ // eslint-disable-next-line no-useless-escape
17636
+ var SYMBOL_MATCH = /[#$\.%&'()\+,-/:;<=>!?@\\\[\]\^_`{|}~\*]/;
17637
+ var DOMAIN_ALLOWED_CHARACTERS = /^[a-zA-Z0-9.\\-]+$/;
17749
17638
  /**
17750
- * Calculates the dimensions of the provided step.
17751
- * Note: The provided step should be fully-hydrated (i.e. rows injected, etc.) to calculate dimensions accurately.
17639
+ * Validate elements on a form
17752
17640
  */
17753
- function calculateStepCSS(step) {
17754
- if (!step)
17755
- return {};
17756
- var root = step.subgrids.find(function (grid) { return grid.position.length === 0; });
17757
- var desktop = calculateDimensionsHelper(root);
17758
- var mobile = calculateDimensionsHelper(root, 'mobile_');
17759
- var stepCSS = __assign({ backgroundSize: 'cover', width: '100%' }, desktop);
17760
- // width will be controlled by maxWidth in the case it is fixed below 478px
17761
- stepCSS["@media (max-width: 478px)"] = __assign({ width: '100%' }, mobile);
17762
- return stepCSS;
17763
- }
17764
- function calculateGlobalCSS(globalStyles) {
17765
- var styles = new ResponsiveStyles({ styles: globalStyles }, ['form'], false, DEFAULT_MOBILE_BREAKPOINT);
17766
- if (globalStyles) {
17767
- styles.applyFontStyles('form');
17768
- }
17769
- return styles;
17770
- }
17771
-
17772
- function changeStep(newKey, oldKey, steps, setStepKey, navigate, client, trackHashes) {
17773
- var sameKey = oldKey === newKey;
17774
- if (!sameKey && newKey) {
17775
- if (newKey in steps) {
17776
- client.registerEvent({
17777
- step_key: oldKey,
17778
- next_step_key: newKey,
17779
- event: 'complete'
17780
- });
17781
- if (trackHashes)
17782
- navigate(location.pathname + location.search + "#".concat(newKey), {
17783
- replace: true
17784
- });
17785
- setStepKey(newKey);
17786
- return true;
17641
+ function validateElements(_a) {
17642
+ var step = _a.step, visiblePositions = _a.visiblePositions, triggerErrors = _a.triggerErrors, errorType = _a.errorType, formRef = _a.formRef, _b = _a.errorCallback, errorCallback = _b === void 0 ? function () { } : _b, setInlineErrors = _a.setInlineErrors, trigger = _a.trigger;
17643
+ var invalid = false;
17644
+ var inlineErrors = {};
17645
+ var errors = getVisibleElements(step, visiblePositions, ['servar_fields', 'buttons'], true).reduce(function (errors, _a) {
17646
+ var _b;
17647
+ var element = _a.element, repeat = _a.repeat, last = _a.last, elementType = _a.type;
17648
+ var key, type;
17649
+ if (elementType === 'servar_fields') {
17650
+ if (element.servar.repeat_trigger === 'set_value' && last && repeat) {
17651
+ // Skip validation on last repeat since it might be default value
17652
+ return errors;
17653
+ }
17654
+ type = element.servar.type;
17655
+ key = element.servar.key;
17656
+ }
17657
+ else {
17658
+ // if not a servar, then a button
17659
+ type = 'button';
17660
+ key = element.id;
17787
17661
  }
17662
+ var message = validateElement(element, repeat);
17663
+ // We want to clear button errors when the button is not "relevant" to what the user is doing.
17664
+ // If the element is a button and was NOT the trigger or no trigger,
17665
+ // then we don't show the error.
17666
+ if (type === 'button' && ((trigger && key !== trigger.id) || !trigger))
17667
+ message = '';
17668
+ if (!(key in errors))
17669
+ errors[key] = message;
17670
+ else if (Array.isArray(errors[key]))
17671
+ errors[key].push(message);
17788
17672
  else
17789
- console.warn("".concat(newKey, " is not a valid step to navigate to"));
17790
- }
17791
- return false;
17792
- }
17793
- function getNewStepUrl(stepKey) {
17794
- return location.pathname + location.search + "#".concat(stepKey);
17795
- }
17796
- function getPrevStepKey(curStep, stepMap) {
17797
- var newStepKey = stepMap[curStep.key];
17798
- if (!newStepKey) {
17799
- var prevCondition = curStep.previous_conditions[0];
17800
- if (prevCondition)
17801
- newStepKey = prevCondition.previous_step_key;
17673
+ errors[key] = [errors[key], message];
17674
+ if (message && !invalid)
17675
+ invalid = true;
17676
+ if (type === 'matrix' && message) {
17677
+ // Get question index where error is
17678
+ var fieldValue = fieldValues[key];
17679
+ // handle repeated matrix fields
17680
+ if (repeat != null && Array.isArray(fieldValue))
17681
+ fieldValue = (_b = fieldValue[repeat]) !== null && _b !== void 0 ? _b : {};
17682
+ var questions = element.servar.metadata.questions;
17683
+ var questionIds = questions.map(function (q) { return q.id; });
17684
+ for (var i = 0; i < questionIds.length; i++) {
17685
+ var value = fieldValue[questionIds[i]];
17686
+ if (value === undefined ||
17687
+ (Array.isArray(value) && value.length === 0)) {
17688
+ key = "".concat(key, "-").concat(i);
17689
+ break;
17690
+ }
17691
+ }
17692
+ }
17693
+ if (triggerErrors) {
17694
+ setFormElementError({
17695
+ formRef: formRef,
17696
+ errorCallback: errorCallback,
17697
+ fieldKey: key,
17698
+ message: message,
17699
+ errorType: errorType,
17700
+ servarType: type,
17701
+ inlineErrors: inlineErrors,
17702
+ index: repeat
17703
+ });
17704
+ }
17705
+ return errors;
17706
+ }, {});
17707
+ if (triggerErrors) {
17708
+ setFormElementError({
17709
+ formRef: formRef,
17710
+ errorType: errorType,
17711
+ inlineErrors: inlineErrors,
17712
+ setInlineErrors: setInlineErrors,
17713
+ triggerErrors: true
17714
+ });
17802
17715
  }
17803
- return newStepKey;
17716
+ return { errors: errors, inlineErrors: inlineErrors, invalid: invalid };
17804
17717
  }
17805
- var nextStepKey = function (nextConditions, metadata) {
17806
- var newKey = null;
17807
- nextConditions
17808
- .filter(function (cond) {
17809
- return cond.element_type === metadata.elementType &&
17810
- metadata.elementIDs.includes(cond.element_id) &&
17811
- cond.metadata.start === metadata.start &&
17812
- cond.metadata.end === metadata.end;
17813
- })
17814
- .sort(function (cond1, cond2) {
17815
- return cond1.rules.length < cond2.rules.length ? 1 : -1;
17816
- })
17817
- .forEach(function (cond) {
17818
- if (newKey)
17819
- return;
17820
- var rulesMet = true;
17821
- cond.rules.forEach(function (rule) {
17822
- rulesMet && (rulesMet = evalComparisonRule(rule));
17823
- });
17824
- if (rulesMet)
17825
- newKey = cond.next_step_key;
17826
- });
17827
- return newKey;
17828
- };
17829
- // No origin is possible if there are no steps, e.g. form is disabled
17830
- var NO_ORIGIN_DEFAULT = { key: '' };
17831
- var getOrigin = function (steps) {
17832
- var _a;
17833
- return (_a = Object.values(steps).find(function (step) { return step.origin; })) !== null && _a !== void 0 ? _a : NO_ORIGIN_DEFAULT;
17834
- };
17835
17718
  /**
17836
- *
17837
- * @returns Url hash without the #, or '' if decodeURI fails
17719
+ * Performs all default/standard and custom validations on a field/element
17720
+ * and returns any validation message.
17838
17721
  */
17839
- function getUrlHash() {
17840
- try {
17841
- return decodeURI(location.hash.substr(1));
17842
- }
17843
- catch (e) {
17844
- console.warn(e);
17845
- return '';
17846
- }
17847
- }
17848
- function setUrlStepHash(navigate, steps, stepName) {
17849
- // No hash necessary if form only has one step
17850
- if (Object.keys(steps).length > 1) {
17851
- navigate(location.pathname + location.search + "#".concat(stepName), {
17852
- replace: true
17722
+ function validateElement(element, repeat) {
17723
+ var servar = element.servar, validations = element.validations;
17724
+ // First priority is custom validations for servar fields
17725
+ if (validations) {
17726
+ var firstMatchingValidation = validations.find(function (validation) {
17727
+ return validation.rules.every(function (rule) { return evalComparisonRule(rule, repeat); });
17853
17728
  });
17729
+ if (firstMatchingValidation)
17730
+ return firstMatchingValidation.message;
17854
17731
  }
17855
- }
17856
- function getInitialStep(_a) {
17857
- var initialStepId = _a.initialStepId, steps = _a.steps, sessionCurrentStep = _a.sessionCurrentStep, formId = _a.formId;
17858
- return ((formId && getSavedStepKey(formId)) || // saved step from remounting
17859
- initialStepId ||
17860
- sessionCurrentStep ||
17861
- getOrigin(steps).key);
17862
- }
17863
- // Store current step keys for each form during remount
17864
- var savedStepKeys = {};
17865
- function getSavedStepKey(formId) {
17866
- var savedKey = savedStepKeys[formId];
17867
- if (savedKey) {
17868
- delete savedStepKeys[formId];
17869
- return savedKey;
17732
+ // Now apply any standard validations
17733
+ if (servar) {
17734
+ var fieldVal = fieldValues[servar.key];
17735
+ if (servar.repeated)
17736
+ fieldVal = fieldVal[repeat];
17737
+ var errorMsg = getStandardFieldError(fieldVal, servar, repeat);
17738
+ if (errorMsg)
17739
+ return errorMsg;
17870
17740
  }
17871
- return undefined;
17872
- }
17873
- function setSavedStepKey(formId, stepKey) {
17874
- savedStepKeys[formId] = stepKey;
17741
+ return '';
17875
17742
  }
17876
- function isStepTerminal(step) {
17877
- // If step is navigable to another step, it's not terminal
17878
- if (step.next_conditions.length > 0)
17879
- return false;
17880
- if (step.servar_fields.some(function (field) { return field.servar.required; }) &&
17881
- step.buttons.some(function (b) { return b.properties.submit; })) {
17882
- // Not terminal if there is a required field on the step that can be saved
17883
- return false;
17884
- }
17885
- var onlyExits = ['buttons', 'texts', 'subgrids'].every(function (key) {
17886
- return step[key].every(function (b) {
17887
- var _a;
17888
- return ((_a = b.properties.actions) !== null && _a !== void 0 ? _a : []).every(function (action) { return action.type === ACTION_URL; });
17889
- });
17890
- });
17891
- if (onlyExits && step.servar_fields.length === 0)
17892
- return true;
17893
- var hasNext = step.buttons.some(function (b) {
17894
- var _a;
17895
- return ((_a = b.properties.actions) !== null && _a !== void 0 ? _a : []).some(function (action) {
17896
- return action.type === ACTION_NEXT ||
17897
- (action.type === ACTION_URL && !action.open_tab);
17898
- });
17743
+ //
17744
+ // Standard Validations
17745
+ //
17746
+ var emailPatternStr = "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]{2,63})+$";
17747
+ var emailPattern = new RegExp(emailPatternStr);
17748
+ var phoneLib = null;
17749
+ var phoneLibPromise = Promise.resolve();
17750
+ var loadPhoneValidator = function () {
17751
+ phoneLibPromise = import(
17752
+ /* webpackChunkName: "libphonenumber" */ './fthry_index.FxHyaooV.js').then(function (mod) {
17753
+ phoneLib = mod;
17754
+ return mod;
17899
17755
  });
17900
- return !hasNext;
17901
- }
17902
- function _recurseQueue(depthMap, steps, hasProgressBar, queue, altQueue) {
17903
- var _loop_1 = function () {
17904
- var _a = __read(queue.shift(), 2), step = _a[0], depth = _a[1];
17905
- if (step.key in depthMap)
17906
- return "continue";
17907
- // Optionally filter only for steps with progress bar
17908
- var missingBar = hasProgressBar && step.progress_bars.length === 0;
17909
- depthMap[step.key] = missingBar ? 0 : depth;
17910
- var incr = missingBar ? 0 : 1;
17911
- step.next_conditions.forEach(function (condition) {
17912
- queue.push([steps[condition.next_step_key], depth + incr]);
17913
- });
17914
- // For calculating progress bar depth, deprioritize previous condition
17915
- // depths relative to next conditions
17916
- var previousQueue = hasProgressBar && altQueue ? altQueue : queue;
17917
- step.previous_conditions.forEach(function (condition) {
17918
- previousQueue.push([steps[condition.previous_step_key], depth + incr]);
17919
- });
17920
- };
17921
- while (queue.length > 0) {
17922
- _loop_1();
17923
- }
17924
- }
17925
- var getStepDepthMap = function (steps, hasProgressBar) {
17926
- if (hasProgressBar === void 0) { hasProgressBar = false; }
17927
- var depthMap = {};
17928
- var stepQueue = [[getOrigin(steps), 0]];
17929
- var reverseQueue = [];
17930
- _recurseQueue(depthMap, steps, hasProgressBar, stepQueue, reverseQueue);
17931
- if (hasProgressBar)
17932
- _recurseQueue(depthMap, steps, hasProgressBar, reverseQueue);
17933
- return depthMap;
17934
17756
  };
17935
- var recurseProgressDepth = function (steps, curKey) {
17936
- var depthMap = getStepDepthMap(steps, true);
17937
- return [depthMap[curKey], Math.max.apply(Math, __spreadArray([], __read(Object.values(depthMap)), false))];
17938
- };
17939
-
17757
+ var validators = {
17758
+ email: function (a) {
17759
+ if (!a)
17760
+ return false;
17761
+ var parts = a.split('@');
17762
+ if (parts.length !== 2)
17763
+ return false;
17764
+ // Email handle cannot end with '.'
17765
+ var part = parts[0];
17766
+ if (part.endsWith('.') || part.startsWith('.'))
17767
+ return false;
17768
+ if (part.includes('..'))
17769
+ return false;
17770
+ return emailPattern.test(a);
17771
+ },
17772
+ phone: function (a) {
17773
+ try {
17774
+ return phoneLib.isValidPhoneNumber("+".concat(a));
17775
+ }
17776
+ catch (e) {
17777
+ // Invalid phone number
17778
+ return false;
17779
+ }
17780
+ },
17781
+ url: function (a) {
17782
+ if (!isUrl(a))
17783
+ return false;
17784
+ try {
17785
+ var urlObj = new URL(a);
17786
+ if (!urlObj)
17787
+ return false;
17788
+ var hostname = urlObj.hostname;
17789
+ if (hostname.length >= 64)
17790
+ return false;
17791
+ if (!DOMAIN_ALLOWED_CHARACTERS.test(hostname))
17792
+ return false;
17793
+ var parts = hostname.split('.');
17794
+ if (parts.some(function (part) { return !part; }))
17795
+ return false;
17796
+ // Last part of domain cannot contain digit
17797
+ if (NUMBER_MATCH.test(parts[parts.length - 1]))
17798
+ return false;
17799
+ // Colon at end of hostname gets filtered out by URL object but
17800
+ // should be invalid
17801
+ if (a[urlObj.origin.length] === ':')
17802
+ return false;
17803
+ // Check for filtered out special characters, e.g.
17804
+ // https://@google.com -> https://google.com
17805
+ if (!a.toLowerCase().includes("/".concat(hostname.toLowerCase())))
17806
+ return false;
17807
+ return parts.length > 1;
17808
+ }
17809
+ catch (e) {
17810
+ return false;
17811
+ }
17812
+ }
17813
+ };
17814
+ function isFieldValueEmpty(value, servar) {
17815
+ var _a;
17816
+ if (ARRAY_FIELD_TYPES.includes(servar.type)) {
17817
+ if (!value || value.length === 0)
17818
+ return true;
17819
+ // For file uploads and button groups, check if array contains only null/falsy values
17820
+ if (['file_upload', 'button_group'].includes(servar.type)) {
17821
+ // In repeatable containers, file upload values are stored as individual Files (not arrays)
17822
+ // because changeValue extracts value[0] for each row. Handle both cases:
17823
+ if (!Array.isArray(value)) {
17824
+ return !value; // Single file or null (from repeatable container)
17825
+ }
17826
+ if (value.every(function (val) { return !val; })) {
17827
+ return true;
17828
+ }
17829
+ }
17830
+ // If 'other' is selected for checkbox group, make sure it has a value
17831
+ return servar.type === 'multiselect' && value.some(function (val) { return !val; });
17832
+ }
17833
+ var noVal;
17834
+ switch (servar.type) {
17835
+ case 'matrix':
17836
+ // Each key in value needs to have an array with at least one value
17837
+ noVal = servar.metadata.questions.some(function (_a) {
17838
+ var id = _a.id;
17839
+ return !value[id] || value[id].length === 0;
17840
+ });
17841
+ break;
17842
+ case 'select':
17843
+ case 'signature':
17844
+ noVal = !value;
17845
+ break;
17846
+ case 'checkbox':
17847
+ // eslint-disable-next-line camelcase
17848
+ noVal = !value && ((_a = servar.metadata) === null || _a === void 0 ? void 0 : _a.must_check);
17849
+ break;
17850
+ case 'payment_method':
17851
+ noVal = !(value === null || value === void 0 ? void 0 : value.complete);
17852
+ break;
17853
+ case 'rating':
17854
+ noVal = !value;
17855
+ break;
17856
+ default:
17857
+ if (typeof value === 'string')
17858
+ value = value.trim();
17859
+ noVal = ['', null, undefined].includes(value);
17860
+ break;
17861
+ }
17862
+ return noVal;
17863
+ }
17864
+ /**
17865
+ * Default validations.
17866
+ * Returns the error message for a field value if it's invalid.
17867
+ * Returns an empty string if it's valid.
17868
+ */
17869
+ function getStandardFieldError(value, servar, repeat) {
17870
+ var defaultErrors = initInfo().defaultErrors;
17871
+ if (isFieldValueEmpty(value, servar)) {
17872
+ // If no value, error if field is required
17873
+ return servar.required ? defaultErrors.required : '';
17874
+ }
17875
+ if (servar.min_length && value.length < servar.min_length) {
17876
+ return defaultErrors.minimum.replace('{length}', servar.min_length);
17877
+ }
17878
+ var defaultErr = defaultErrors[servar.type];
17879
+ // Check if value is badly formatted
17880
+ if (servar.type === 'phone_number' && !validators.phone(value)) {
17881
+ return defaultErr;
17882
+ }
17883
+ else if (servar.type === 'email' && !validators.email(value)) {
17884
+ return defaultErr;
17885
+ }
17886
+ else if (servar.type === 'url' && !validators.url(value)) {
17887
+ // Try appending https since user may have just omitted the protocol
17888
+ var newVal = 'https://' + value;
17889
+ if (validators.url(newVal)) {
17890
+ if (servar.repeated) {
17891
+ // @ts-ignore
17892
+ fieldValues[servar === null || servar === void 0 ? void 0 : servar.key][repeat] = newVal;
17893
+ }
17894
+ else
17895
+ fieldValues[servar.key] = newVal;
17896
+ return '';
17897
+ }
17898
+ return defaultErr;
17899
+ }
17900
+ else if (servar.type === 'ssn' &&
17901
+ value.length !== (servar.metadata.last_four_digits ? 4 : 9)) {
17902
+ return defaultErr;
17903
+ }
17904
+ else if (servar.type === 'pin_input' &&
17905
+ value.length !== servar.max_length) {
17906
+ return defaultErr;
17907
+ }
17908
+ else if (servar.type === 'password') {
17909
+ var meta = servar.metadata;
17910
+ var msg = function (key) { return "Your password must have at least 1 ".concat(key); };
17911
+ if (meta.letter_required && !LETTER_MATCH.test(value))
17912
+ return msg('letter');
17913
+ if (meta.uppercase_letter_required && !UPPERCASE_LETTER_MATCH.test(value))
17914
+ return msg('uppercase letter');
17915
+ if (meta.lowercase_letter_required && !LOWERCASE_LETTER_MATCH.test(value))
17916
+ return msg('lowercase letter');
17917
+ if (meta.number_required && !NUMBER_MATCH.test(value))
17918
+ return msg('number');
17919
+ if (meta.symbol_required && !SYMBOL_MATCH.test(value))
17920
+ return msg('symbol');
17921
+ }
17922
+ // No error
17923
+ return '';
17924
+ }
17925
+
17926
+ var plaidPromise = null;
17927
+ function installPlaid(isPlaidActive) {
17928
+ if (plaidPromise)
17929
+ return plaidPromise;
17930
+ else if (!isPlaidActive)
17931
+ return Promise.resolve();
17932
+ else {
17933
+ plaidPromise = dynamicImport('https://cdn.plaid.com/link/v2/stable/link-initialize.js');
17934
+ return plaidPromise;
17935
+ }
17936
+ }
17937
+ function openPlaidLink(client, onSuccess, onExit, updateFieldValues, action, handleError) {
17938
+ return __awaiter$2(this, void 0, void 0, function () {
17939
+ var kwargs, res, handler;
17940
+ var _this = this;
17941
+ return __generator(this, function (_a) {
17942
+ switch (_a.label) {
17943
+ case 0: return [4 /*yield*/, plaidPromise];
17944
+ case 1:
17945
+ _a.sent();
17946
+ if (action.plaid_action === 'identity') {
17947
+ kwargs = {
17948
+ identity_template_id: action.template_id,
17949
+ email_field: action.email_field
17950
+ };
17951
+ }
17952
+ else {
17953
+ kwargs = { liabilities: action.include_liabilities ? 'true' : 'false' };
17954
+ }
17955
+ return [4 /*yield*/, client.fetchPlaidLinkToken(kwargs)];
17956
+ case 2:
17957
+ res = _a.sent();
17958
+ if (res.err) {
17959
+ handleError(res.err);
17960
+ return [2 /*return*/];
17961
+ }
17962
+ handler = global.Plaid.create({
17963
+ token: res.token,
17964
+ onExit: onExit,
17965
+ onSuccess: function (publicToken, metadata) { return __awaiter$2(_this, void 0, void 0, function () {
17966
+ var res_1, statusKey, newValues, res_2, fieldVals;
17967
+ var _a;
17968
+ var _b;
17969
+ return __generator(this, function (_c) {
17970
+ switch (_c.label) {
17971
+ case 0:
17972
+ _c.trys.push([0, 8, 9, 10]);
17973
+ if (!(action.plaid_action === 'identity')) return [3 /*break*/, 4];
17974
+ return [4 /*yield*/, client.fetchPlaidVerificationStatus(metadata.link_session_id)];
17975
+ case 1:
17976
+ res_1 = _c.sent();
17977
+ statusKey = action.plaid_identity_field_key;
17978
+ if (statusKey) {
17979
+ newValues = (_a = {}, _a[statusKey] = res_1.status, _a);
17980
+ updateFieldValues(newValues);
17981
+ client.submitCustom(newValues, { shouldFlush: true });
17982
+ }
17983
+ if (!(res_1.status !== 'success')) return [3 /*break*/, 3];
17984
+ handleError('Identity verification was not successful');
17985
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
17986
+ case 2:
17987
+ _c.sent();
17988
+ return [2 /*return*/];
17989
+ case 3: return [3 /*break*/, 6];
17990
+ case 4:
17991
+ if (!publicToken) return [3 /*break*/, 6];
17992
+ res_2 = client.submitPlaidUserData(publicToken);
17993
+ if (!((_b = action.wait_for_completion) !== null && _b !== void 0 ? _b : true)) return [3 /*break*/, 6];
17994
+ return [4 /*yield*/, res_2];
17995
+ case 5:
17996
+ fieldVals = _c.sent();
17997
+ updateFieldValues(fieldVals);
17998
+ _c.label = 6;
17999
+ case 6: return [4 /*yield*/, onSuccess()];
18000
+ case 7:
18001
+ _c.sent();
18002
+ return [3 /*break*/, 10];
18003
+ case 8:
18004
+ _c.sent();
18005
+ handleError();
18006
+ return [3 /*break*/, 10];
18007
+ case 9:
18008
+ handler.exit();
18009
+ handler.destroy();
18010
+ return [7 /*endfinally*/];
18011
+ case 10: return [2 /*return*/];
18012
+ }
18013
+ });
18014
+ }); }
18015
+ });
18016
+ handler.open();
18017
+ return [2 /*return*/];
18018
+ }
18019
+ });
18020
+ });
18021
+ }
18022
+
18023
+ var RouterContext = createContext({
18024
+ location: {
18025
+ pathname: ''
18026
+ },
18027
+ navigate: function () { }
18028
+ });
18029
+ function RouterProvider(_a) {
18030
+ var children = _a.children, _b = _a.initialPath, initialPath = _b === void 0 ? featheryWindow().location.pathname : _b;
18031
+ var _c = __read(useState({ pathname: initialPath }), 2), location = _c[0], setLocation = _c[1];
18032
+ var navigate = useCallback(function (to, options) {
18033
+ if (options === void 0) { options = {}; }
18034
+ var historyMethod = options.replace ? 'replaceState' : 'pushState';
18035
+ featheryWindow().history[historyMethod](null, '', to);
18036
+ setLocation({ pathname: to });
18037
+ }, []);
18038
+ // listen to browser back/forward navigation
18039
+ useEffect(function () {
18040
+ var window = featheryWindow();
18041
+ var handlePopState = function () {
18042
+ setLocation({ pathname: window.location.pathname });
18043
+ };
18044
+ window.addEventListener('popstate', handlePopState);
18045
+ return function () { return window.removeEventListener('popstate', handlePopState); };
18046
+ }, []);
18047
+ var routerData = useMemo(function () { return ({
18048
+ location: location,
18049
+ navigate: navigate
18050
+ }); }, [location, navigate]);
18051
+ return (jsx$1(RouterContext.Provider, __assign({ value: routerData }, { children: children })));
18052
+ }
18053
+ function useLocation() {
18054
+ var context = useContext(RouterContext);
18055
+ if (!context)
18056
+ throw new Error('useLocation must be used within RouterProvider');
18057
+ return context.location;
18058
+ }
18059
+ function useNavigate() {
18060
+ var context = useContext(RouterContext);
18061
+ if (!context)
18062
+ throw new Error('useNavigate must be used within RouterProvider');
18063
+ return context.navigate;
18064
+ }
18065
+
18066
+ var MIN_AXIS_SIZE = 15;
18067
+ var FIT = 'fit';
18068
+ var FILL = 'fill';
18069
+ var isFill = function (v) { return v === FILL; };
18070
+ var isFit = function (v) { return v === FIT; };
18071
+ var isPx = function (v) {
18072
+ return typeof v === 'string' && v.indexOf('px') >= 0 && v.indexOf('calc') < 0;
18073
+ };
18074
+ var getPxValue = function (size) {
18075
+ return isPx(size) ? Number.parseFloat(size) : MIN_AXIS_SIZE;
18076
+ };
18077
+ var formatDimensionValue = function (value, type) {
18078
+ // fit-content is needed to allow elements to push beyond the parent container's explicit height.
18079
+ switch (value) {
18080
+ case FILL:
18081
+ return type === 'width' ? '100%' : 'auto';
18082
+ case FIT:
18083
+ return 'fit-content';
18084
+ default:
18085
+ return parseInt(value);
18086
+ }
18087
+ };
18088
+ var calculateDimensionsHelper = function (root, p) {
18089
+ if (p === void 0) { p = ''; }
18090
+ var width = root["".concat(p, "width")] || root.width;
18091
+ var height = root["".concat(p, "height")] || root.height;
18092
+ var dimensions = {
18093
+ maxWidth: formatDimensionValue(width, 'width'),
18094
+ height: formatDimensionValue(height, 'height')
18095
+ };
18096
+ // to allow responsiveness, min width shouldn't be set for fixed widths
18097
+ dimensions.minWidth = isNum(width) ? undefined : dimensions.maxWidth;
18098
+ // min and max height must be 100% to prevent fit-content from collapsing, which would break fill's non-collapsing intent
18099
+ dimensions.minHeight = isFill(height) ? '100%' : dimensions.height;
18100
+ return dimensions;
18101
+ };
18102
+ /**
18103
+ * Calculates the dimensions of the provided step.
18104
+ * Note: The provided step should be fully-hydrated (i.e. rows injected, etc.) to calculate dimensions accurately.
18105
+ */
18106
+ function calculateStepCSS(step) {
18107
+ if (!step)
18108
+ return {};
18109
+ var root = step.subgrids.find(function (grid) { return grid.position.length === 0; });
18110
+ var desktop = calculateDimensionsHelper(root);
18111
+ var mobile = calculateDimensionsHelper(root, 'mobile_');
18112
+ var stepCSS = __assign({ backgroundSize: 'cover', width: '100%' }, desktop);
18113
+ // width will be controlled by maxWidth in the case it is fixed below 478px
18114
+ stepCSS["@media (max-width: 478px)"] = __assign({ width: '100%' }, mobile);
18115
+ return stepCSS;
18116
+ }
18117
+ function calculateGlobalCSS(globalStyles) {
18118
+ var styles = new ResponsiveStyles({ styles: globalStyles }, ['form'], false, DEFAULT_MOBILE_BREAKPOINT);
18119
+ if (globalStyles) {
18120
+ styles.applyFontStyles('form');
18121
+ }
18122
+ return styles;
18123
+ }
18124
+
18125
+ function changeStep(newKey, oldKey, steps, setStepKey, navigate, client, trackHashes) {
18126
+ var sameKey = oldKey === newKey;
18127
+ if (!sameKey && newKey) {
18128
+ if (newKey in steps) {
18129
+ client.registerEvent({
18130
+ step_key: oldKey,
18131
+ next_step_key: newKey,
18132
+ event: 'complete'
18133
+ });
18134
+ if (trackHashes)
18135
+ navigate(location.pathname + location.search + "#".concat(newKey), {
18136
+ replace: true
18137
+ });
18138
+ setStepKey(newKey);
18139
+ return true;
18140
+ }
18141
+ else
18142
+ console.warn("".concat(newKey, " is not a valid step to navigate to"));
18143
+ }
18144
+ return false;
18145
+ }
18146
+ function getNewStepUrl(stepKey) {
18147
+ return location.pathname + location.search + "#".concat(stepKey);
18148
+ }
18149
+ function getPrevStepKey(curStep, stepMap) {
18150
+ var newStepKey = stepMap[curStep.key];
18151
+ if (!newStepKey) {
18152
+ var prevCondition = curStep.previous_conditions[0];
18153
+ if (prevCondition)
18154
+ newStepKey = prevCondition.previous_step_key;
18155
+ }
18156
+ return newStepKey;
18157
+ }
18158
+ var nextStepKey = function (nextConditions, metadata) {
18159
+ var newKey = null;
18160
+ nextConditions
18161
+ .filter(function (cond) {
18162
+ return cond.element_type === metadata.elementType &&
18163
+ metadata.elementIDs.includes(cond.element_id) &&
18164
+ cond.metadata.start === metadata.start &&
18165
+ cond.metadata.end === metadata.end;
18166
+ })
18167
+ .sort(function (cond1, cond2) {
18168
+ return cond1.rules.length < cond2.rules.length ? 1 : -1;
18169
+ })
18170
+ .forEach(function (cond) {
18171
+ if (newKey)
18172
+ return;
18173
+ var rulesMet = true;
18174
+ cond.rules.forEach(function (rule) {
18175
+ rulesMet && (rulesMet = evalComparisonRule(rule));
18176
+ });
18177
+ if (rulesMet)
18178
+ newKey = cond.next_step_key;
18179
+ });
18180
+ return newKey;
18181
+ };
18182
+ // No origin is possible if there are no steps, e.g. form is disabled
18183
+ var NO_ORIGIN_DEFAULT = { key: '' };
18184
+ var getOrigin = function (steps) {
18185
+ var _a;
18186
+ return (_a = Object.values(steps).find(function (step) { return step.origin; })) !== null && _a !== void 0 ? _a : NO_ORIGIN_DEFAULT;
18187
+ };
18188
+ /**
18189
+ *
18190
+ * @returns Url hash without the #, or '' if decodeURI fails
18191
+ */
18192
+ function getUrlHash() {
18193
+ try {
18194
+ return decodeURI(location.hash.substr(1));
18195
+ }
18196
+ catch (e) {
18197
+ console.warn(e);
18198
+ return '';
18199
+ }
18200
+ }
18201
+ function setUrlStepHash(navigate, steps, stepName) {
18202
+ // No hash necessary if form only has one step
18203
+ if (Object.keys(steps).length > 1) {
18204
+ navigate(location.pathname + location.search + "#".concat(stepName), {
18205
+ replace: true
18206
+ });
18207
+ }
18208
+ }
18209
+ function getInitialStep(_a) {
18210
+ var initialStepId = _a.initialStepId, steps = _a.steps, sessionCurrentStep = _a.sessionCurrentStep, formId = _a.formId;
18211
+ return ((formId && getSavedStepKey(formId)) || // saved step from remounting
18212
+ initialStepId ||
18213
+ sessionCurrentStep ||
18214
+ getOrigin(steps).key);
18215
+ }
18216
+ // Store current step keys for each form during remount
18217
+ var savedStepKeys = {};
18218
+ function getSavedStepKey(formId) {
18219
+ var savedKey = savedStepKeys[formId];
18220
+ if (savedKey) {
18221
+ delete savedStepKeys[formId];
18222
+ return savedKey;
18223
+ }
18224
+ return undefined;
18225
+ }
18226
+ function setSavedStepKey(formId, stepKey) {
18227
+ savedStepKeys[formId] = stepKey;
18228
+ }
18229
+ function isStepTerminal(step) {
18230
+ // If step is navigable to another step, it's not terminal
18231
+ if (step.next_conditions.length > 0)
18232
+ return false;
18233
+ if (step.servar_fields.some(function (field) { return field.servar.required; }) &&
18234
+ step.buttons.some(function (b) { return b.properties.submit; })) {
18235
+ // Not terminal if there is a required field on the step that can be saved
18236
+ return false;
18237
+ }
18238
+ var onlyExits = ['buttons', 'texts', 'subgrids'].every(function (key) {
18239
+ return step[key].every(function (b) {
18240
+ var _a;
18241
+ return ((_a = b.properties.actions) !== null && _a !== void 0 ? _a : []).every(function (action) { return action.type === ACTION_URL; });
18242
+ });
18243
+ });
18244
+ if (onlyExits && step.servar_fields.length === 0)
18245
+ return true;
18246
+ var hasNext = step.buttons.some(function (b) {
18247
+ var _a;
18248
+ return ((_a = b.properties.actions) !== null && _a !== void 0 ? _a : []).some(function (action) {
18249
+ return action.type === ACTION_NEXT ||
18250
+ (action.type === ACTION_URL && !action.open_tab);
18251
+ });
18252
+ });
18253
+ return !hasNext;
18254
+ }
18255
+ function _recurseQueue(depthMap, steps, hasProgressBar, queue, altQueue) {
18256
+ var _loop_1 = function () {
18257
+ var _a = __read(queue.shift(), 2), step = _a[0], depth = _a[1];
18258
+ if (step.key in depthMap)
18259
+ return "continue";
18260
+ // Optionally filter only for steps with progress bar
18261
+ var missingBar = hasProgressBar && step.progress_bars.length === 0;
18262
+ depthMap[step.key] = missingBar ? 0 : depth;
18263
+ var incr = missingBar ? 0 : 1;
18264
+ step.next_conditions.forEach(function (condition) {
18265
+ queue.push([steps[condition.next_step_key], depth + incr]);
18266
+ });
18267
+ // For calculating progress bar depth, deprioritize previous condition
18268
+ // depths relative to next conditions
18269
+ var previousQueue = hasProgressBar && altQueue ? altQueue : queue;
18270
+ step.previous_conditions.forEach(function (condition) {
18271
+ previousQueue.push([steps[condition.previous_step_key], depth + incr]);
18272
+ });
18273
+ };
18274
+ while (queue.length > 0) {
18275
+ _loop_1();
18276
+ }
18277
+ }
18278
+ var getStepDepthMap = function (steps, hasProgressBar) {
18279
+ if (hasProgressBar === void 0) { hasProgressBar = false; }
18280
+ var depthMap = {};
18281
+ var stepQueue = [[getOrigin(steps), 0]];
18282
+ var reverseQueue = [];
18283
+ _recurseQueue(depthMap, steps, hasProgressBar, stepQueue, reverseQueue);
18284
+ if (hasProgressBar)
18285
+ _recurseQueue(depthMap, steps, hasProgressBar, reverseQueue);
18286
+ return depthMap;
18287
+ };
18288
+ var recurseProgressDepth = function (steps, curKey) {
18289
+ var depthMap = getStepDepthMap(steps, true);
18290
+ return [depthMap[curKey], Math.max.apply(Math, __spreadArray([], __read(Object.values(depthMap)), false))];
18291
+ };
18292
+
17940
18293
  var pure$1 = {};
17941
18294
 
17942
18295
  var hasRequiredPure$1;
@@ -28604,12 +28957,21 @@ function hasAuthGatedSteps(integrations) {
28604
28957
  function getRedirectUrl() {
28605
28958
  var _a = featheryWindow().location, origin = _a.origin, pathname = _a.pathname, hash = _a.hash, search = _a.search;
28606
28959
  var queryParams = new URLSearchParams(search);
28960
+ // If no _slug param, extract slug from /to/<slug> path
28961
+ if (!queryParams.has('_slug')) {
28962
+ var toMatch = pathname.match(/\/to\/([^/]+)/);
28963
+ if (toMatch) {
28964
+ queryParams.set('_slug', toMatch[1]);
28965
+ }
28966
+ }
28607
28967
  queryParams.forEach(function (value, key) {
28608
28968
  if (!['_slug'].includes(key))
28609
28969
  queryParams.delete(key);
28610
28970
  });
28971
+ // Strip the /to/<slug> segment
28972
+ var cleanPathname = pathname.replace(/\/to\/[^/]+/, '');
28611
28973
  var queryString = queryParams.has('_slug') ? "?".concat(queryParams) : '';
28612
- return "".concat(origin).concat(pathname).concat(queryString).concat(hash);
28974
+ return "".concat(origin).concat(cleanPathname).concat(queryString).concat(hash);
28613
28975
  }
28614
28976
 
28615
28977
  var stytchPromise = null;
@@ -39075,7 +39437,7 @@ function useTrackUserInteraction(formRef, activeStep, stepKey, formName) {
39075
39437
  }, [activeStep, stepKey, formName]);
39076
39438
  }
39077
39439
 
39078
- var AssistantChat = lazy(function () { return import(/* webpackChunkName: "AssistantChat" */ './fthry_index.C_ReA4YV.js'); });
39440
+ var AssistantChat = lazy(function () { return import(/* webpackChunkName: "AssistantChat" */ './fthry_index.Dte366nP.js'); });
39079
39441
  var getSubmissionErrorMessage = function (error) {
39080
39442
  if (error instanceof TypeError && error.message === 'Failed to fetch') {
39081
39443
  return 'Unable to upload files. Please check your connection and try again.';
@@ -39982,7 +40344,28 @@ function Form(_a) {
39982
40344
  var newFieldVals_1 = {};
39983
40345
  activeStep.servar_fields.forEach(function (sf) {
39984
40346
  var key = getPositionKey(sf);
39985
- if (!visiblePositions[key][0]) {
40347
+ var flags = visiblePositions[key];
40348
+ var isRepeated = !!getRepeatedContainer(activeStep, sf);
40349
+ if (isRepeated) {
40350
+ var currentVal = fieldValues[sf.servar.key];
40351
+ if (!Array.isArray(currentVal))
40352
+ return;
40353
+ var defaultVal_1 = getDefaultFieldValue(sf);
40354
+ var defaultJson_1 = JSON.stringify(defaultVal_1);
40355
+ var changed_1 = false;
40356
+ var newArray = currentVal.map(function (val, i) {
40357
+ if (i < flags.length &&
40358
+ !flags[i] &&
40359
+ JSON.stringify(val) !== defaultJson_1) {
40360
+ changed_1 = true;
40361
+ return defaultVal_1;
40362
+ }
40363
+ return val;
40364
+ });
40365
+ if (changed_1)
40366
+ newFieldVals_1[sf.servar.key] = newArray;
40367
+ }
40368
+ else if (!flags[0]) {
39986
40369
  var newVal = getDefaultFormFieldValue(sf);
39987
40370
  if (JSON.stringify(newVal) !== JSON.stringify(getFieldValue$1(sf).value)) {
39988
40371
  newFieldVals_1[sf.servar.key] = newVal;
@@ -43652,944 +44035,595 @@ function requireGa4 () {
43652
44035
  Object.keys(rest).filter(function (key) {
43653
44036
  return key.substr(0, "dimension".length) === "dimension";
43654
44037
  }).forEach(function (key) {
43655
- fieldObject[key] = rest[key];
43656
- });
43657
- Object.keys(rest).filter(function (key) {
43658
- return key.substr(0, "metric".length) === "metric";
43659
- }).forEach(function (key) {
43660
- fieldObject[key] = rest[key];
43661
- });
43662
-
43663
- _this._gaCommand("send", fieldObject);
43664
- }
43665
- });
43666
-
43667
- _defineProperty(this, "send", function (fieldObject) {
43668
- _this._gaCommand("send", fieldObject);
43669
- });
43670
-
43671
- _defineProperty(this, "pageview", function (path, _, title) {
43672
- var pathTrim = path === null || path === void 0 ? void 0 : path.trim();
43673
-
43674
- if (pathTrim === "") {
43675
- console.warn("path cannot be an empty string in .pageview()");
43676
- return;
43677
- }
43678
-
43679
- _this._gaCommand("send", "pageview", pathTrim, {
43680
- title: title
43681
- });
43682
- });
43683
-
43684
- this.reset();
43685
- }
43686
-
43687
- _createClass(GA4, [{
43688
- key: "gtag",
43689
- value: function gtag() {
43690
- this._gtag.apply(this, arguments);
43691
- }
43692
- }, {
43693
- key: "_appendCustomMap",
43694
- value: function _appendCustomMap(options) {
43695
- var legacyDimensionMetric = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
43696
-
43697
- if (!legacyDimensionMetric) {
43698
- return options;
43699
- }
43700
-
43701
- if (!options.custom_map) {
43702
- options.custom_map = {};
43703
- }
43704
-
43705
- for (var i = 1; i <= 200; i++) {
43706
- if (!options.custom_map["dimension".concat(i)]) {
43707
- options.custom_map["dimension".concat(i)] = "dimension".concat(i);
43708
- }
43709
-
43710
- if (!options.custom_map["metric".concat(i)]) {
43711
- options.custom_map["metric".concat(i)] = "metric".concat(i);
43712
- }
43713
- }
43714
-
43715
- return options;
43716
- }
43717
- /**
43718
- * @since v1.0.2
43719
- * @param {string} [path="location.href"]
43720
- * @param {string[]} [_] unsupported
43721
- * @param {string} [title="location.pathname"]
43722
- * @deprecated Use `.send("pageview")` instead
43723
- */
43724
-
43725
- }, {
43726
- key: "outboundLink",
43727
- value:
43728
- /**
43729
- * @since v1.0.6
43730
- * @param {Object} options
43731
- * @param {string} options.label
43732
- * @param {function} hitCallback
43733
- * @deprecated Use `enhanced measurement` feature in Google Analytics.
43734
- */
43735
- function outboundLink(_ref3, hitCallback) {
43736
- var label = _ref3.label;
43737
-
43738
- if (typeof hitCallback !== "function") {
43739
- console.warn("hitCallback function is required");
43740
- return;
43741
- }
43742
-
43743
- if (!label) {
43744
- console.warn("args.label is required in outboundLink()");
43745
- return;
43746
- } // Required Fields
43747
-
43748
-
43749
- var fieldObject = {
43750
- hitType: "event",
43751
- eventCategory: "Outbound",
43752
- eventAction: "Click",
43753
- eventLabel: (0, _format["default"])(label)
43754
- };
43755
- var safetyCallbackCalled = false;
43756
-
43757
- var safetyCallback = function safetyCallback() {
43758
- // This prevents a delayed response from GA
43759
- // causing hitCallback from being fired twice
43760
- safetyCallbackCalled = true;
43761
- hitCallback();
43762
- }; // Using a timeout to ensure the execution of critical application code
43763
- // in the case when the GA server might be down
43764
- // or an ad blocker prevents sending the data
43765
- // register safety net timeout:
43766
-
43767
-
43768
- var t = setTimeout(safetyCallback, 250);
43769
-
43770
- var clearableCallbackForGA = function clearableCallbackForGA() {
43771
- clearTimeout(t);
43772
-
43773
- if (!safetyCallbackCalled) {
43774
- hitCallback();
43775
- }
43776
- };
43777
-
43778
- fieldObject.hitCallback = clearableCallbackForGA;
43779
-
43780
- this._gaCommand("send", fieldObject);
43781
- }
43782
- }]);
43783
-
43784
- return GA4;
43785
- }();
43786
-
43787
- exports$1.GA4 = GA4;
43788
-
43789
- var _default = new GA4();
43790
-
43791
- exports$1["default"] = _default;
43792
- } (ga4));
43793
- return ga4;
43794
- }
43795
-
43796
- var hasRequiredDist;
43797
-
43798
- function requireDist () {
43799
- if (hasRequiredDist) return dist;
43800
- hasRequiredDist = 1;
43801
- (function (exports$1) {
43802
-
43803
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
43804
-
43805
- Object.defineProperty(exports$1, "__esModule", {
43806
- value: true
43807
- });
43808
- exports$1["default"] = exports$1.ReactGAImplementation = void 0;
43809
-
43810
- var _ga = _interopRequireWildcard(requireGa4());
44038
+ fieldObject[key] = rest[key];
44039
+ });
44040
+ Object.keys(rest).filter(function (key) {
44041
+ return key.substr(0, "metric".length) === "metric";
44042
+ }).forEach(function (key) {
44043
+ fieldObject[key] = rest[key];
44044
+ });
43811
44045
 
43812
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
44046
+ _this._gaCommand("send", fieldObject);
44047
+ }
44048
+ });
43813
44049
 
43814
- function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
44050
+ _defineProperty(this, "send", function (fieldObject) {
44051
+ _this._gaCommand("send", fieldObject);
44052
+ });
43815
44053
 
43816
- var ReactGAImplementation = _ga.GA4;
43817
- exports$1.ReactGAImplementation = ReactGAImplementation;
43818
- var _default = _ga["default"];
43819
- exports$1["default"] = _default;
43820
- } (dist));
43821
- return dist;
43822
- }
44054
+ _defineProperty(this, "pageview", function (path, _, title) {
44055
+ var pathTrim = path === null || path === void 0 ? void 0 : path.trim();
43823
44056
 
43824
- var distExports = requireDist();
43825
- var ReactGA = /*@__PURE__*/getDefaultExportFromCjs(distExports);
44057
+ if (pathTrim === "") {
44058
+ console.warn("path cannot be an empty string in .pageview()");
44059
+ return;
44060
+ }
43826
44061
 
43827
- var gaInstalled = false;
43828
- function installGoogleAnalytics(gaConfig) {
43829
- if (gaConfig && !gaInstalled) {
43830
- gaInstalled = true;
43831
- ReactGA.initialize(gaConfig.metadata.api_key);
43832
- }
43833
- return Promise.resolve();
43834
- }
43835
- function trackGAEvent(category, action, label) {
43836
- ReactGA.event({ category: category, action: action, label: label });
43837
- }
44062
+ _this._gaCommand("send", "pageview", pathTrim, {
44063
+ title: title
44064
+ });
44065
+ });
43838
44066
 
43839
- var heapInstalled = false;
43840
- function installHeap(heapConfig) {
43841
- if (heapConfig && !heapInstalled) {
43842
- heapInstalled = true;
43843
- featheryWindow().heap = featheryWindow().heap || [];
43844
- featheryWindow().heap.load = function (e) {
43845
- featheryWindow().heap.appid = e;
43846
- featheryWindow().heap.config = {};
43847
- var r = featheryDoc().createElement('script');
43848
- r.type = 'text/javascript';
43849
- r.async = true;
43850
- r.src = 'https://cdn.heapanalytics.com/js/heap-' + e + '.js';
43851
- var a = featheryDoc().getElementsByTagName('script')[0];
43852
- a.parentNode.insertBefore(r, a);
43853
- for (var n = function (e) {
43854
- return function () {
43855
- featheryWindow().heap.push(
43856
- // eslint-disable-next-line prefer-rest-params
43857
- [e].concat(Array.prototype.slice.call(arguments, 0)));
43858
- };
43859
- }, p = [
43860
- 'addEventProperties',
43861
- 'addUserProperties',
43862
- 'clearEventProperties',
43863
- 'identify',
43864
- 'resetIdentity',
43865
- 'removeEventProperty',
43866
- 'setEventProperties',
43867
- 'track',
43868
- 'unsetEventProperty'
43869
- ], o = 0; o < p.length; o++)
43870
- featheryWindow().heap[p[o]] = n(p[o]);
43871
- };
43872
- featheryWindow().heap.load(heapConfig.metadata.api_key);
43873
- }
43874
- return Promise.resolve();
43875
- }
44067
+ this.reset();
44068
+ }
43876
44069
 
43877
- var intercomInstalled = false;
43878
- function installIntercom(intercomConfig) {
43879
- if (intercomConfig && !intercomInstalled) {
43880
- intercomInstalled = true;
43881
- var workspaceId_1 = intercomConfig.api_key;
43882
- featheryWindow().intercomSettings = {
43883
- api_base: 'https://api-iam.intercom.io',
43884
- app_id: workspaceId_1
43885
- };
43886
- var w = featheryWindow();
43887
- var ic = w.Intercom;
43888
- if (typeof ic === 'function') {
43889
- ic('reattach_activator');
43890
- ic('update', w.intercomSettings);
43891
- }
43892
- else {
43893
- var d_1 = featheryDoc();
43894
- var i_1 = function () {
43895
- // eslint-disable-next-line prefer-rest-params
43896
- i_1.c(arguments);
43897
- };
43898
- i_1.q = [];
43899
- i_1.c = function (args) {
43900
- i_1.q.push(args);
43901
- };
43902
- w.Intercom = i_1;
43903
- var l = function () {
43904
- var s = d_1.createElement('script');
43905
- s.type = 'text/javascript';
43906
- s.async = true;
43907
- s.src = "https://widget.intercom.io/widget/".concat(workspaceId_1);
43908
- var x = d_1.getElementsByTagName('script')[0];
43909
- x.parentNode.insertBefore(s, x);
43910
- };
43911
- if (featheryDoc().readyState === 'complete') {
43912
- l();
43913
- }
43914
- else if (w.attachEvent) {
43915
- w.attachEvent('onload', l);
43916
- }
43917
- else {
43918
- w.addEventListener('load', l, false);
43919
- }
43920
- }
43921
- }
43922
- return Promise.resolve();
43923
- }
44070
+ _createClass(GA4, [{
44071
+ key: "gtag",
44072
+ value: function gtag() {
44073
+ this._gtag.apply(this, arguments);
44074
+ }
44075
+ }, {
44076
+ key: "_appendCustomMap",
44077
+ value: function _appendCustomMap(options) {
44078
+ var legacyDimensionMetric = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
43924
44079
 
43925
- var amplitudeInstalled = false;
43926
- function installAmplitude(amplitudeConfig) {
43927
- return __awaiter$2(this, void 0, void 0, function () {
43928
- var meta, apiKey, cdn, sessionReplayTracking, options;
43929
- return __generator(this, function (_a) {
43930
- switch (_a.label) {
43931
- case 0:
43932
- if (!amplitudeConfig || amplitudeInstalled)
43933
- return [2 /*return*/];
43934
- amplitudeInstalled = true;
43935
- meta = amplitudeConfig.metadata;
43936
- apiKey = meta.api_key;
43937
- cdn = 'cdn';
43938
- if (meta.eu_server)
43939
- cdn = 'cdn.eu';
43940
- return [4 /*yield*/, dynamicImport("https://".concat(cdn, ".amplitude.com/script/").concat(apiKey, ".js"))];
43941
- case 1:
43942
- _a.sent();
43943
- if (!featheryWindow().amplitude) {
43944
- console.warn('Failed to load Amplitude.');
43945
- return [2 /*return*/];
43946
- }
43947
- if (meta.session_replay && featheryWindow().sessionReplay) {
43948
- sessionReplayTracking = featheryWindow().sessionReplay.plugin();
43949
- featheryWindow().amplitude.add(sessionReplayTracking);
43950
- }
43951
- options = {
43952
- fetchRemoteConfig: true,
43953
- autocapture: true
43954
- };
43955
- if (meta.eu_server)
43956
- options.serverZone = 'EU';
43957
- featheryWindow().amplitude.init(apiKey, options);
43958
- if (meta.identify_user)
43959
- featheryWindow().amplitude.setUserId(initInfo().userId);
43960
- return [2 /*return*/];
43961
- }
43962
- });
43963
- });
43964
- }
44080
+ if (!legacyDimensionMetric) {
44081
+ return options;
44082
+ }
43965
44083
 
43966
- var mixpanelInstalled = false;
43967
- function installMixpanel(mixpanelConfig) {
43968
- if (mixpanelConfig && !mixpanelInstalled && !featheryWindow().mixpanel) {
43969
- mixpanelInstalled = true;
43970
- (function (f, b) {
43971
- if (!b.__SV) {
43972
- var i_1, h_1;
43973
- featheryWindow().mixpanel = b;
43974
- b._i = [];
43975
- b.init = function (e, f, c) {
43976
- function g(a, d) {
43977
- var b = d.split('.');
43978
- // eslint-disable-next-line eqeqeq,no-unused-expressions
43979
- b.length == 2 && ((a = a[b[0]]), (d = b[1]));
43980
- a[d] = function () {
43981
- // eslint-disable-next-line prefer-rest-params
43982
- a.push([d].concat(Array.prototype.slice.call(arguments, 0)));
43983
- };
43984
- }
43985
- var a = b;
43986
- typeof c !== 'undefined' ? (a = b[c] = []) : (c = 'mixpanel');
43987
- a.people = a.people || [];
43988
- a.toString = function (a) {
43989
- var d = 'mixpanel';
43990
- c !== 'mixpanel' && (d += '.' + c);
43991
- a || (d += ' (stub)');
43992
- return d;
43993
- };
43994
- a.people.toString = function () {
43995
- return a.toString(1) + '.people (stub)';
43996
- };
43997
- i_1 =
43998
- 'disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove'.split(' ');
43999
- for (h_1 = 0; h_1 < i_1.length; h_1++)
44000
- g(a, i_1[h_1]);
44001
- var j = 'set set_once union unset remove delete'.split(' ');
44002
- a.get_group = function () {
44003
- function b(c) {
44004
- d[c] = function () {
44005
- var call2 = [c].concat(
44006
- // eslint-disable-next-line prefer-rest-params
44007
- Array.prototype.slice.call(arguments, 0));
44008
- a.push([e, call2]);
44009
- };
44010
- }
44011
- var d;
44012
- for (d = {},
44013
- e = ['get_group'].concat(
44014
- // eslint-disable-next-line prefer-rest-params
44015
- Array.prototype.slice.call(arguments, 0)),
44016
- c = 0; c < j.length; c++)
44017
- b(j[c]);
44018
- return d;
44019
- };
44020
- b._i.push([e, f, c]);
44021
- };
44022
- b.__SV = 1.2;
44023
- var e = f.createElement('script');
44024
- e.type = 'text/javascript';
44025
- e.async = true;
44026
- e.src =
44027
- f.location.protocol === 'file:' &&
44028
- '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'.match(/^\/\//)
44029
- ? 'https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'
44030
- : '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js';
44031
- var g = f.getElementsByTagName('script')[0];
44032
- g.parentNode.insertBefore(e, g);
44033
- }
44034
- })(featheryDoc(), featheryWindow().mixpanel || []);
44035
- featheryWindow().mixpanel.init(mixpanelConfig.metadata.api_key);
44036
- }
44037
- return Promise.resolve();
44038
- }
44084
+ if (!options.custom_map) {
44085
+ options.custom_map = {};
44086
+ }
44039
44087
 
44040
- var rudderStackInstalled = false;
44041
- function installRudderStack(rudderStackConfig) {
44042
- return __awaiter$2(this, void 0, void 0, function () {
44043
- var rudderanalytics_1, methods, i, method;
44044
- return __generator(this, function (_a) {
44045
- if (rudderStackConfig && !rudderStackInstalled) {
44046
- rudderStackInstalled = true;
44047
- dynamicImport('https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js');
44048
- rudderanalytics_1 = (featheryWindow().rudderanalytics = []);
44049
- methods = [
44050
- 'load',
44051
- 'page',
44052
- 'track',
44053
- 'identify',
44054
- 'alias',
44055
- 'group',
44056
- 'ready',
44057
- 'reset',
44058
- 'getAnonymousId',
44059
- 'setAnonymousId',
44060
- 'getUserId',
44061
- 'getUserTraits',
44062
- 'getGroupId',
44063
- 'getGroupTraits',
44064
- 'startSession',
44065
- 'endSession',
44066
- 'getSessionId'
44067
- ];
44068
- for (i = 0; i < methods.length; i++) {
44069
- method = methods[i];
44070
- rudderanalytics_1[method] = (function (methodName) {
44071
- return function () {
44072
- rudderanalytics_1.push(
44073
- // eslint-disable-next-line prefer-rest-params
44074
- [methodName].concat(Array.prototype.slice.call(arguments)));
44075
- };
44076
- })(method);
44077
- }
44078
- rudderanalytics_1.load(rudderStackConfig.metadata.write_key, rudderStackConfig.metadata.data_plane_url);
44079
- rudderanalytics_1.identify(initInfo().userId);
44080
- }
44081
- return [2 /*return*/, Promise.resolve()];
44082
- });
44083
- });
44084
- }
44085
- function trackRudderEvent(title, properties, integ) {
44086
- var trackEvents = integ === null || integ === void 0 ? void 0 : integ.metadata.track_events;
44087
- if (!trackEvents || trackEvents.includes(title))
44088
- featheryWindow().rudderanalytics.track(title, properties);
44089
- }
44088
+ for (var i = 1; i <= 200; i++) {
44089
+ if (!options.custom_map["dimension".concat(i)]) {
44090
+ options.custom_map["dimension".concat(i)] = "dimension".concat(i);
44091
+ }
44090
44092
 
44091
- var configMap = {};
44092
- function installTrustedForm(trustedformConfig, formKey) {
44093
- return __awaiter$2(this, void 0, void 0, function () {
44094
- var tf, protocol, certField, pingField, rand, s;
44095
- return __generator(this, function (_a) {
44096
- if (!trustedformConfig)
44097
- return [2 /*return*/];
44098
- configMap[formKey] = trustedformConfig;
44099
- tf = featheryDoc().createElement('script');
44100
- tf.type = 'text/javascript';
44101
- tf.async = true;
44102
- protocol = featheryDoc().location.protocol === 'https:' ? 'https' : 'http';
44103
- certField = trustedformConfig.metadata.certificate_field_key;
44104
- pingField = trustedformConfig.metadata.ping_field_key;
44105
- rand = new Date().getTime() + Math.random();
44106
- tf.src = "".concat(protocol, "://api.trustedform.com/trustedform.js?field=").concat(certField, "&ping_field=").concat(pingField, "&l=").concat(rand);
44107
- s = featheryDoc().getElementsByTagName('script')[0];
44108
- s.parentNode.insertBefore(tf, s);
44109
- return [2 /*return*/];
44110
- });
44111
- });
44112
- }
44113
- function gatherTrustedFormFields(existingFields, formKey) {
44114
- var config = configMap[formKey];
44115
- if (!config)
44116
- return;
44117
- ['certificate_field_key', 'ping_field_key'].forEach(function (attr) {
44118
- var fieldKey = config.metadata[attr];
44119
- if (!(fieldKey in fieldValues)) {
44120
- // Not stored yet
44121
- var el = featheryDoc().getElementsByName(fieldKey)[0];
44122
- if (el) {
44123
- var fieldVal = el.value;
44124
- fieldValues[fieldKey] = fieldVal;
44125
- existingFields[fieldKey] = fieldVal;
44126
- }
44127
- }
44128
- });
44129
- }
44093
+ if (!options.custom_map["metric".concat(i)]) {
44094
+ options.custom_map["metric".concat(i)] = "metric".concat(i);
44095
+ }
44096
+ }
44130
44097
 
44131
- var IMPORTED_URLS = new Set();
44132
- function dynamicImport(dependencies, parallel, force) {
44133
- if (parallel === void 0) { parallel = true; }
44134
- if (force === void 0) { force = false; }
44135
- if (typeof dependencies === 'string')
44136
- dependencies = [dependencies];
44137
- var newDependencies = [];
44138
- dependencies.forEach(function (d) {
44139
- var dup = IMPORTED_URLS.has(d);
44140
- if (dup && force) {
44141
- var base = d;
44142
- var counter = 1;
44143
- while (dup) {
44144
- d = "".concat(base, "?version=").concat(counter);
44145
- dup = IMPORTED_URLS.has(d);
44146
- counter++;
44147
- }
44148
- }
44149
- if (!dup) {
44150
- IMPORTED_URLS.add(d);
44151
- newDependencies.push(d);
44152
- }
44153
- });
44154
- if (newDependencies.length === 0)
44155
- return Promise.resolve();
44156
- if (parallel) {
44157
- return new Promise(function (resolve) {
44158
- global.scriptjsLoadPromise.then(function ($script) {
44159
- $script.default(newDependencies, function (lib) {
44160
- resolve(lib);
44161
- });
44162
- });
44163
- });
44164
- }
44165
- else {
44166
- return new Promise(function (resolve) {
44167
- global.scriptjsLoadPromise.then(function ($script) {
44168
- $script.default.order(newDependencies, resolve);
44169
- });
44170
- });
44171
- }
44172
- }
44173
- function initializeIntegrations(integs, featheryClient) {
44174
- return __awaiter$2(this, void 0, void 0, function () {
44175
- var gtm;
44176
- return __generator(this, function (_a) {
44177
- switch (_a.label) {
44178
- case 0: return [4 /*yield*/, Promise.all([
44179
- installArgyle(!!integs.argyle),
44180
- installPlaid(!!integs.plaid),
44181
- installFirebase(integs.firebase),
44182
- installStytch(integs.stytch),
44183
- installStripe(integs.stripe),
44184
- installSegment(integs.segment),
44185
- installGoogleAnalytics(integs['google-analytics']),
44186
- installHeap(integs.heap),
44187
- installAmplitude(integs.amplitude),
44188
- installMixpanel(integs.mixpanel),
44189
- installIntercom(integs['intercom-embedded']),
44190
- installRudderStack(integs.rudderstack),
44191
- installPersona(integs.persona),
44192
- installAlloy(integs.alloy),
44193
- installTrustedForm(integs.trustedform, featheryClient.formKey)
44194
- ])];
44195
- case 1:
44196
- _a.sent();
44197
- gtm = integs['google-tag-manager'];
44198
- if (gtm)
44199
- initializeTagManager(gtm);
44200
- if (integs.firebase || integs.stytch) {
44201
- authState.authFormKey = featheryClient.formKey;
44202
- return [2 /*return*/, Auth.inferLoginOnLoad(featheryClient)];
44203
- }
44204
- return [2 /*return*/];
44205
- }
44206
- });
44207
- });
44208
- }
44209
- function trackEvent(integrations, title, stepId, formName, fieldData) {
44210
- var metadata = { formName: formName };
44211
- if (stepId)
44212
- metadata.stepId = stepId;
44213
- // Google Tag Manager
44214
- // @ts-expect-error TS(2551): Property 'initialized' does not exist on type '{ d... Remove this comment to see the full error message
44215
- if (TagManager.initialized) {
44216
- var gtmData = __assign({}, metadata);
44217
- if (fieldData === null || fieldData === void 0 ? void 0 : fieldData['google-tag-manager'])
44218
- gtmData = __assign(__assign({}, gtmData), fieldData['google-tag-manager']);
44219
- TagManager.dataLayer({ dataLayer: __assign(__assign({}, gtmData), { event: title }) });
44220
- }
44221
- // RudderStack
44222
- if (rudderStackInstalled) {
44223
- var rudderData = __assign({}, metadata);
44224
- if (title === 'FeatheryFormComplete')
44225
- rudderData.fieldData = fieldValues;
44226
- trackRudderEvent(title, rudderData, integrations === null || integrations === void 0 ? void 0 : integrations.rudderstack);
44227
- }
44228
- // Google Analytics
44229
- if (gaInstalled)
44230
- trackGAEvent(formName, title, stepId);
44231
- // Segment
44232
- var segmentData = __assign({}, metadata);
44233
- if (fieldData === null || fieldData === void 0 ? void 0 : fieldData.segment)
44234
- segmentData.submittedData = fieldData.segment;
44235
- if (featheryWindow().analytics)
44236
- featheryWindow().analytics.track(title, segmentData);
44237
- var amplitudeData = __assign({}, metadata);
44238
- if (fieldData === null || fieldData === void 0 ? void 0 : fieldData.amplitude)
44239
- amplitudeData.submittedData = fieldData.amplitude;
44240
- if (featheryWindow().amplitude)
44241
- featheryWindow().amplitude.track(title, amplitudeData);
44242
- if (featheryWindow().mixpanel)
44243
- featheryWindow().mixpanel.track(title, metadata);
44244
- }
44098
+ return options;
44099
+ }
44100
+ /**
44101
+ * @since v1.0.2
44102
+ * @param {string} [path="location.href"]
44103
+ * @param {string[]} [_] unsupported
44104
+ * @param {string} [title="location.pathname"]
44105
+ * @deprecated Use `.send("pageview")` instead
44106
+ */
44107
+
44108
+ }, {
44109
+ key: "outboundLink",
44110
+ value:
44111
+ /**
44112
+ * @since v1.0.6
44113
+ * @param {Object} options
44114
+ * @param {string} options.label
44115
+ * @param {function} hitCallback
44116
+ * @deprecated Use `enhanced measurement` feature in Google Analytics.
44117
+ */
44118
+ function outboundLink(_ref3, hitCallback) {
44119
+ var label = _ref3.label;
44120
+
44121
+ if (typeof hitCallback !== "function") {
44122
+ console.warn("hitCallback function is required");
44123
+ return;
44124
+ }
44125
+
44126
+ if (!label) {
44127
+ console.warn("args.label is required in outboundLink()");
44128
+ return;
44129
+ } // Required Fields
44130
+
44131
+
44132
+ var fieldObject = {
44133
+ hitType: "event",
44134
+ eventCategory: "Outbound",
44135
+ eventAction: "Click",
44136
+ eventLabel: (0, _format["default"])(label)
44137
+ };
44138
+ var safetyCallbackCalled = false;
44139
+
44140
+ var safetyCallback = function safetyCallback() {
44141
+ // This prevents a delayed response from GA
44142
+ // causing hitCallback from being fired twice
44143
+ safetyCallbackCalled = true;
44144
+ hitCallback();
44145
+ }; // Using a timeout to ensure the execution of critical application code
44146
+ // in the case when the GA server might be down
44147
+ // or an ad blocker prevents sending the data
44148
+ // register safety net timeout:
44245
44149
 
44246
- var isUrl_1;
44247
- var hasRequiredIsUrl;
44248
44150
 
44249
- function requireIsUrl () {
44250
- if (hasRequiredIsUrl) return isUrl_1;
44251
- hasRequiredIsUrl = 1;
44252
- /**
44253
- * Expose `isUrl`.
44254
- */
44151
+ var t = setTimeout(safetyCallback, 250);
44255
44152
 
44256
- isUrl_1 = isUrl;
44153
+ var clearableCallbackForGA = function clearableCallbackForGA() {
44154
+ clearTimeout(t);
44257
44155
 
44258
- /**
44259
- * RegExps.
44260
- * A URL must match #1 and then at least one of #2/#3.
44261
- * Use two levels of REs to avoid REDOS.
44262
- */
44156
+ if (!safetyCallbackCalled) {
44157
+ hitCallback();
44158
+ }
44159
+ };
44263
44160
 
44264
- var protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
44161
+ fieldObject.hitCallback = clearableCallbackForGA;
44265
44162
 
44266
- var localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/;
44267
- var nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/;
44163
+ this._gaCommand("send", fieldObject);
44164
+ }
44165
+ }]);
44268
44166
 
44269
- /**
44270
- * Loosely validate a URL `string`.
44271
- *
44272
- * @param {String} string
44273
- * @return {Boolean}
44274
- */
44167
+ return GA4;
44168
+ }();
44275
44169
 
44276
- function isUrl(string){
44277
- if (typeof string !== 'string') {
44278
- return false;
44279
- }
44170
+ exports$1.GA4 = GA4;
44280
44171
 
44281
- var match = string.match(protocolAndDomainRE);
44282
- if (!match) {
44283
- return false;
44284
- }
44172
+ var _default = new GA4();
44285
44173
 
44286
- var everythingAfterProtocol = match[1];
44287
- if (!everythingAfterProtocol) {
44288
- return false;
44289
- }
44174
+ exports$1["default"] = _default;
44175
+ } (ga4));
44176
+ return ga4;
44177
+ }
44290
44178
 
44291
- if (localhostDomainRE.test(everythingAfterProtocol) ||
44292
- nonLocalhostDomainRE.test(everythingAfterProtocol)) {
44293
- return true;
44294
- }
44179
+ var hasRequiredDist;
44295
44180
 
44296
- return false;
44297
- }
44298
- return isUrl_1;
44181
+ function requireDist () {
44182
+ if (hasRequiredDist) return dist;
44183
+ hasRequiredDist = 1;
44184
+ (function (exports$1) {
44185
+
44186
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
44187
+
44188
+ Object.defineProperty(exports$1, "__esModule", {
44189
+ value: true
44190
+ });
44191
+ exports$1["default"] = exports$1.ReactGAImplementation = void 0;
44192
+
44193
+ var _ga = _interopRequireWildcard(requireGa4());
44194
+
44195
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
44196
+
44197
+ function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
44198
+
44199
+ var ReactGAImplementation = _ga.GA4;
44200
+ exports$1.ReactGAImplementation = ReactGAImplementation;
44201
+ var _default = _ga["default"];
44202
+ exports$1["default"] = _default;
44203
+ } (dist));
44204
+ return dist;
44299
44205
  }
44300
44206
 
44301
- var isUrlExports = requireIsUrl();
44302
- var isUrl = /*@__PURE__*/getDefaultExportFromCjs(isUrlExports);
44207
+ var distExports = requireDist();
44208
+ var ReactGA = /*@__PURE__*/getDefaultExportFromCjs(distExports);
44303
44209
 
44304
- var LETTER_MATCH = /[a-zA-Z]/;
44305
- var UPPERCASE_LETTER_MATCH = /[A-Z]/;
44306
- var LOWERCASE_LETTER_MATCH = /[a-z]/;
44307
- var NUMBER_MATCH = /\d/;
44308
- // eslint-disable-next-line no-useless-escape
44309
- var SYMBOL_MATCH = /[#$\.%&'()\+,-/:;<=>!?@\\\[\]\^_`{|}~\*]/;
44310
- var DOMAIN_ALLOWED_CHARACTERS = /^[a-zA-Z0-9.\\-]+$/;
44311
- /**
44312
- * Validate elements on a form
44313
- */
44314
- function validateElements(_a) {
44315
- var step = _a.step, visiblePositions = _a.visiblePositions, triggerErrors = _a.triggerErrors, errorType = _a.errorType, formRef = _a.formRef, _b = _a.errorCallback, errorCallback = _b === void 0 ? function () { } : _b, setInlineErrors = _a.setInlineErrors, trigger = _a.trigger;
44316
- var invalid = false;
44317
- var inlineErrors = {};
44318
- var errors = getVisibleElements(step, visiblePositions, ['servar_fields', 'buttons'], true).reduce(function (errors, _a) {
44319
- var _b;
44320
- var element = _a.element, repeat = _a.repeat, last = _a.last, elementType = _a.type;
44321
- var key, type;
44322
- if (elementType === 'servar_fields') {
44323
- if (element.servar.repeat_trigger === 'set_value' && last && repeat) {
44324
- // Skip validation on last repeat since it might be default value
44325
- return errors;
44326
- }
44327
- type = element.servar.type;
44328
- key = element.servar.key;
44210
+ var gaInstalled = false;
44211
+ function installGoogleAnalytics(gaConfig) {
44212
+ if (gaConfig && !gaInstalled) {
44213
+ gaInstalled = true;
44214
+ ReactGA.initialize(gaConfig.metadata.api_key);
44215
+ }
44216
+ return Promise.resolve();
44217
+ }
44218
+ function trackGAEvent(category, action, label) {
44219
+ ReactGA.event({ category: category, action: action, label: label });
44220
+ }
44221
+
44222
+ var heapInstalled = false;
44223
+ function installHeap(heapConfig) {
44224
+ if (heapConfig && !heapInstalled) {
44225
+ heapInstalled = true;
44226
+ featheryWindow().heap = featheryWindow().heap || [];
44227
+ featheryWindow().heap.load = function (e) {
44228
+ featheryWindow().heap.appid = e;
44229
+ featheryWindow().heap.config = {};
44230
+ var r = featheryDoc().createElement('script');
44231
+ r.type = 'text/javascript';
44232
+ r.async = true;
44233
+ r.src = 'https://cdn.heapanalytics.com/js/heap-' + e + '.js';
44234
+ var a = featheryDoc().getElementsByTagName('script')[0];
44235
+ a.parentNode.insertBefore(r, a);
44236
+ for (var n = function (e) {
44237
+ return function () {
44238
+ featheryWindow().heap.push(
44239
+ // eslint-disable-next-line prefer-rest-params
44240
+ [e].concat(Array.prototype.slice.call(arguments, 0)));
44241
+ };
44242
+ }, p = [
44243
+ 'addEventProperties',
44244
+ 'addUserProperties',
44245
+ 'clearEventProperties',
44246
+ 'identify',
44247
+ 'resetIdentity',
44248
+ 'removeEventProperty',
44249
+ 'setEventProperties',
44250
+ 'track',
44251
+ 'unsetEventProperty'
44252
+ ], o = 0; o < p.length; o++)
44253
+ featheryWindow().heap[p[o]] = n(p[o]);
44254
+ };
44255
+ featheryWindow().heap.load(heapConfig.metadata.api_key);
44256
+ }
44257
+ return Promise.resolve();
44258
+ }
44259
+
44260
+ var intercomInstalled = false;
44261
+ function installIntercom(intercomConfig) {
44262
+ if (intercomConfig && !intercomInstalled) {
44263
+ intercomInstalled = true;
44264
+ var workspaceId_1 = intercomConfig.api_key;
44265
+ featheryWindow().intercomSettings = {
44266
+ api_base: 'https://api-iam.intercom.io',
44267
+ app_id: workspaceId_1
44268
+ };
44269
+ var w = featheryWindow();
44270
+ var ic = w.Intercom;
44271
+ if (typeof ic === 'function') {
44272
+ ic('reattach_activator');
44273
+ ic('update', w.intercomSettings);
44329
44274
  }
44330
44275
  else {
44331
- // if not a servar, then a button
44332
- type = 'button';
44333
- key = element.id;
44334
- }
44335
- var message = validateElement(element, repeat);
44336
- // We want to clear button errors when the button is not "relevant" to what the user is doing.
44337
- // If the element is a button and was NOT the trigger or no trigger,
44338
- // then we don't show the error.
44339
- if (type === 'button' && ((trigger && key !== trigger.id) || !trigger))
44340
- message = '';
44341
- if (!(key in errors))
44342
- errors[key] = message;
44343
- else if (Array.isArray(errors[key]))
44344
- errors[key].push(message);
44345
- else
44346
- errors[key] = [errors[key], message];
44347
- if (message && !invalid)
44348
- invalid = true;
44349
- if (type === 'matrix' && message) {
44350
- // Get question index where error is
44351
- var fieldValue = fieldValues[key];
44352
- // handle repeated matrix fields
44353
- if (repeat != null && Array.isArray(fieldValue))
44354
- fieldValue = (_b = fieldValue[repeat]) !== null && _b !== void 0 ? _b : {};
44355
- var questions = element.servar.metadata.questions;
44356
- var questionIds = questions.map(function (q) { return q.id; });
44357
- for (var i = 0; i < questionIds.length; i++) {
44358
- var value = fieldValue[questionIds[i]];
44359
- if (value === undefined ||
44360
- (Array.isArray(value) && value.length === 0)) {
44361
- key = "".concat(key, "-").concat(i);
44362
- break;
44363
- }
44276
+ var d_1 = featheryDoc();
44277
+ var i_1 = function () {
44278
+ // eslint-disable-next-line prefer-rest-params
44279
+ i_1.c(arguments);
44280
+ };
44281
+ i_1.q = [];
44282
+ i_1.c = function (args) {
44283
+ i_1.q.push(args);
44284
+ };
44285
+ w.Intercom = i_1;
44286
+ var l = function () {
44287
+ var s = d_1.createElement('script');
44288
+ s.type = 'text/javascript';
44289
+ s.async = true;
44290
+ s.src = "https://widget.intercom.io/widget/".concat(workspaceId_1);
44291
+ var x = d_1.getElementsByTagName('script')[0];
44292
+ x.parentNode.insertBefore(s, x);
44293
+ };
44294
+ if (featheryDoc().readyState === 'complete') {
44295
+ l();
44296
+ }
44297
+ else if (w.attachEvent) {
44298
+ w.attachEvent('onload', l);
44299
+ }
44300
+ else {
44301
+ w.addEventListener('load', l, false);
44364
44302
  }
44365
44303
  }
44366
- if (triggerErrors) {
44367
- setFormElementError({
44368
- formRef: formRef,
44369
- errorCallback: errorCallback,
44370
- fieldKey: key,
44371
- message: message,
44372
- errorType: errorType,
44373
- servarType: type,
44374
- inlineErrors: inlineErrors,
44375
- index: repeat
44376
- });
44377
- }
44378
- return errors;
44379
- }, {});
44380
- if (triggerErrors) {
44381
- setFormElementError({
44382
- formRef: formRef,
44383
- errorType: errorType,
44384
- inlineErrors: inlineErrors,
44385
- setInlineErrors: setInlineErrors,
44386
- triggerErrors: true
44387
- });
44388
44304
  }
44389
- return { errors: errors, inlineErrors: inlineErrors, invalid: invalid };
44390
- }
44391
- /**
44392
- * Performs all default/standard and custom validations on a field/element
44393
- * and returns any validation message.
44394
- */
44395
- function validateElement(element, repeat) {
44396
- var servar = element.servar, validations = element.validations;
44397
- // First priority is custom validations for servar fields
44398
- if (validations) {
44399
- var firstMatchingValidation = validations.find(function (validation) {
44400
- return validation.rules.every(function (rule) { return evalComparisonRule(rule, repeat); });
44305
+ return Promise.resolve();
44306
+ }
44307
+
44308
+ var amplitudeInstalled = false;
44309
+ function installAmplitude(amplitudeConfig) {
44310
+ return __awaiter$2(this, void 0, void 0, function () {
44311
+ var meta, apiKey, cdn, sessionReplayTracking, options;
44312
+ return __generator(this, function (_a) {
44313
+ switch (_a.label) {
44314
+ case 0:
44315
+ if (!amplitudeConfig || amplitudeInstalled)
44316
+ return [2 /*return*/];
44317
+ amplitudeInstalled = true;
44318
+ meta = amplitudeConfig.metadata;
44319
+ apiKey = meta.api_key;
44320
+ cdn = 'cdn';
44321
+ if (meta.eu_server)
44322
+ cdn = 'cdn.eu';
44323
+ return [4 /*yield*/, dynamicImport("https://".concat(cdn, ".amplitude.com/script/").concat(apiKey, ".js"))];
44324
+ case 1:
44325
+ _a.sent();
44326
+ if (!featheryWindow().amplitude) {
44327
+ console.warn('Failed to load Amplitude.');
44328
+ return [2 /*return*/];
44329
+ }
44330
+ if (meta.session_replay && featheryWindow().sessionReplay) {
44331
+ sessionReplayTracking = featheryWindow().sessionReplay.plugin();
44332
+ featheryWindow().amplitude.add(sessionReplayTracking);
44333
+ }
44334
+ options = {
44335
+ fetchRemoteConfig: true,
44336
+ autocapture: true
44337
+ };
44338
+ if (meta.eu_server)
44339
+ options.serverZone = 'EU';
44340
+ featheryWindow().amplitude.init(apiKey, options);
44341
+ if (meta.identify_user)
44342
+ featheryWindow().amplitude.setUserId(initInfo().userId);
44343
+ return [2 /*return*/];
44344
+ }
44401
44345
  });
44402
- if (firstMatchingValidation)
44403
- return firstMatchingValidation.message;
44404
- }
44405
- // Now apply any standard validations
44406
- if (servar) {
44407
- var fieldVal = fieldValues[servar.key];
44408
- if (servar.repeated)
44409
- fieldVal = fieldVal[repeat];
44410
- var errorMsg = getStandardFieldError(fieldVal, servar, repeat);
44411
- if (errorMsg)
44412
- return errorMsg;
44413
- }
44414
- return '';
44415
- }
44416
- //
44417
- // Standard Validations
44418
- //
44419
- var emailPatternStr = "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]{2,63})+$";
44420
- var emailPattern = new RegExp(emailPatternStr);
44421
- var LIB_PHONE_NUMBER_URL = 'https://cdn.jsdelivr.net/npm/libphonenumber-js@1.11.16/bundle/libphonenumber-js.min.js';
44422
- var phoneLibPromise = Promise.resolve();
44423
- var loadPhoneValidator = function () {
44424
- return (phoneLibPromise = dynamicImport(LIB_PHONE_NUMBER_URL));
44425
- };
44426
- var validators = {
44427
- email: function (a) {
44428
- if (!a)
44429
- return false;
44430
- var parts = a.split('@');
44431
- if (parts.length !== 2)
44432
- return false;
44433
- // Email handle cannot end with '.'
44434
- var part = parts[0];
44435
- if (part.endsWith('.') || part.startsWith('.'))
44436
- return false;
44437
- if (part.includes('..'))
44438
- return false;
44439
- return emailPattern.test(a);
44440
- },
44441
- phone: function (a) {
44442
- try {
44443
- return global.libphonenumber.isValidPhoneNumber("+".concat(a));
44444
- }
44445
- catch (e) {
44446
- // Invalid phone number
44447
- return false;
44448
- }
44449
- },
44450
- url: function (a) {
44451
- if (!isUrl(a))
44452
- return false;
44453
- try {
44454
- var urlObj = new URL(a);
44455
- if (!urlObj)
44456
- return false;
44457
- var hostname = urlObj.hostname;
44458
- if (hostname.length >= 64)
44459
- return false;
44460
- if (!DOMAIN_ALLOWED_CHARACTERS.test(hostname))
44461
- return false;
44462
- var parts = hostname.split('.');
44463
- if (parts.some(function (part) { return !part; }))
44464
- return false;
44465
- // Last part of domain cannot contain digit
44466
- if (NUMBER_MATCH.test(parts[parts.length - 1]))
44467
- return false;
44468
- // Colon at end of hostname gets filtered out by URL object but
44469
- // should be invalid
44470
- if (a[urlObj.origin.length] === ':')
44471
- return false;
44472
- // Check for filtered out special characters, e.g.
44473
- // https://@google.com -> https://google.com
44474
- if (!a.toLowerCase().includes("/".concat(hostname.toLowerCase())))
44475
- return false;
44476
- return parts.length > 1;
44477
- }
44478
- catch (e) {
44479
- return false;
44480
- }
44346
+ });
44347
+ }
44348
+
44349
+ var mixpanelInstalled = false;
44350
+ function installMixpanel(mixpanelConfig) {
44351
+ if (mixpanelConfig && !mixpanelInstalled && !featheryWindow().mixpanel) {
44352
+ mixpanelInstalled = true;
44353
+ (function (f, b) {
44354
+ if (!b.__SV) {
44355
+ var i_1, h_1;
44356
+ featheryWindow().mixpanel = b;
44357
+ b._i = [];
44358
+ b.init = function (e, f, c) {
44359
+ function g(a, d) {
44360
+ var b = d.split('.');
44361
+ // eslint-disable-next-line eqeqeq,no-unused-expressions
44362
+ b.length == 2 && ((a = a[b[0]]), (d = b[1]));
44363
+ a[d] = function () {
44364
+ // eslint-disable-next-line prefer-rest-params
44365
+ a.push([d].concat(Array.prototype.slice.call(arguments, 0)));
44366
+ };
44367
+ }
44368
+ var a = b;
44369
+ typeof c !== 'undefined' ? (a = b[c] = []) : (c = 'mixpanel');
44370
+ a.people = a.people || [];
44371
+ a.toString = function (a) {
44372
+ var d = 'mixpanel';
44373
+ c !== 'mixpanel' && (d += '.' + c);
44374
+ a || (d += ' (stub)');
44375
+ return d;
44376
+ };
44377
+ a.people.toString = function () {
44378
+ return a.toString(1) + '.people (stub)';
44379
+ };
44380
+ i_1 =
44381
+ 'disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove'.split(' ');
44382
+ for (h_1 = 0; h_1 < i_1.length; h_1++)
44383
+ g(a, i_1[h_1]);
44384
+ var j = 'set set_once union unset remove delete'.split(' ');
44385
+ a.get_group = function () {
44386
+ function b(c) {
44387
+ d[c] = function () {
44388
+ var call2 = [c].concat(
44389
+ // eslint-disable-next-line prefer-rest-params
44390
+ Array.prototype.slice.call(arguments, 0));
44391
+ a.push([e, call2]);
44392
+ };
44393
+ }
44394
+ var d;
44395
+ for (d = {},
44396
+ e = ['get_group'].concat(
44397
+ // eslint-disable-next-line prefer-rest-params
44398
+ Array.prototype.slice.call(arguments, 0)),
44399
+ c = 0; c < j.length; c++)
44400
+ b(j[c]);
44401
+ return d;
44402
+ };
44403
+ b._i.push([e, f, c]);
44404
+ };
44405
+ b.__SV = 1.2;
44406
+ var e = f.createElement('script');
44407
+ e.type = 'text/javascript';
44408
+ e.async = true;
44409
+ e.src =
44410
+ f.location.protocol === 'file:' &&
44411
+ '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'.match(/^\/\//)
44412
+ ? 'https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'
44413
+ : '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js';
44414
+ var g = f.getElementsByTagName('script')[0];
44415
+ g.parentNode.insertBefore(e, g);
44416
+ }
44417
+ })(featheryDoc(), featheryWindow().mixpanel || []);
44418
+ featheryWindow().mixpanel.init(mixpanelConfig.metadata.api_key);
44481
44419
  }
44482
- };
44483
- function isFieldValueEmpty(value, servar) {
44484
- var _a;
44485
- if (ARRAY_FIELD_TYPES.includes(servar.type)) {
44486
- if (!value || value.length === 0)
44487
- return true;
44488
- // For file uploads and button groups, check if array contains only null/falsy values
44489
- if (['file_upload', 'button_group'].includes(servar.type)) {
44490
- // In repeatable containers, file upload values are stored as individual Files (not arrays)
44491
- // because changeValue extracts value[0] for each row. Handle both cases:
44492
- if (!Array.isArray(value)) {
44493
- return !value; // Single file or null (from repeatable container)
44420
+ return Promise.resolve();
44421
+ }
44422
+
44423
+ var rudderStackInstalled = false;
44424
+ function installRudderStack(rudderStackConfig) {
44425
+ return __awaiter$2(this, void 0, void 0, function () {
44426
+ var rudderanalytics_1, methods, i, method;
44427
+ return __generator(this, function (_a) {
44428
+ if (rudderStackConfig && !rudderStackInstalled) {
44429
+ rudderStackInstalled = true;
44430
+ dynamicImport('https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js');
44431
+ rudderanalytics_1 = (featheryWindow().rudderanalytics = []);
44432
+ methods = [
44433
+ 'load',
44434
+ 'page',
44435
+ 'track',
44436
+ 'identify',
44437
+ 'alias',
44438
+ 'group',
44439
+ 'ready',
44440
+ 'reset',
44441
+ 'getAnonymousId',
44442
+ 'setAnonymousId',
44443
+ 'getUserId',
44444
+ 'getUserTraits',
44445
+ 'getGroupId',
44446
+ 'getGroupTraits',
44447
+ 'startSession',
44448
+ 'endSession',
44449
+ 'getSessionId'
44450
+ ];
44451
+ for (i = 0; i < methods.length; i++) {
44452
+ method = methods[i];
44453
+ rudderanalytics_1[method] = (function (methodName) {
44454
+ return function () {
44455
+ rudderanalytics_1.push(
44456
+ // eslint-disable-next-line prefer-rest-params
44457
+ [methodName].concat(Array.prototype.slice.call(arguments)));
44458
+ };
44459
+ })(method);
44460
+ }
44461
+ rudderanalytics_1.load(rudderStackConfig.metadata.write_key, rudderStackConfig.metadata.data_plane_url);
44462
+ rudderanalytics_1.identify(initInfo().userId);
44494
44463
  }
44495
- if (value.every(function (val) { return !val; })) {
44496
- return true;
44464
+ return [2 /*return*/, Promise.resolve()];
44465
+ });
44466
+ });
44467
+ }
44468
+ function trackRudderEvent(title, properties, integ) {
44469
+ var trackEvents = integ === null || integ === void 0 ? void 0 : integ.metadata.track_events;
44470
+ if (!trackEvents || trackEvents.includes(title))
44471
+ featheryWindow().rudderanalytics.track(title, properties);
44472
+ }
44473
+
44474
+ var configMap = {};
44475
+ function installTrustedForm(trustedformConfig, formKey) {
44476
+ return __awaiter$2(this, void 0, void 0, function () {
44477
+ var tf, protocol, certField, pingField, rand, s;
44478
+ return __generator(this, function (_a) {
44479
+ if (!trustedformConfig)
44480
+ return [2 /*return*/];
44481
+ configMap[formKey] = trustedformConfig;
44482
+ tf = featheryDoc().createElement('script');
44483
+ tf.type = 'text/javascript';
44484
+ tf.async = true;
44485
+ protocol = featheryDoc().location.protocol === 'https:' ? 'https' : 'http';
44486
+ certField = trustedformConfig.metadata.certificate_field_key;
44487
+ pingField = trustedformConfig.metadata.ping_field_key;
44488
+ rand = new Date().getTime() + Math.random();
44489
+ tf.src = "".concat(protocol, "://api.trustedform.com/trustedform.js?field=").concat(certField, "&ping_field=").concat(pingField, "&l=").concat(rand);
44490
+ s = featheryDoc().getElementsByTagName('script')[0];
44491
+ s.parentNode.insertBefore(tf, s);
44492
+ return [2 /*return*/];
44493
+ });
44494
+ });
44495
+ }
44496
+ function gatherTrustedFormFields(existingFields, formKey) {
44497
+ var config = configMap[formKey];
44498
+ if (!config)
44499
+ return;
44500
+ ['certificate_field_key', 'ping_field_key'].forEach(function (attr) {
44501
+ var fieldKey = config.metadata[attr];
44502
+ if (!(fieldKey in fieldValues)) {
44503
+ // Not stored yet
44504
+ var el = featheryDoc().getElementsByName(fieldKey)[0];
44505
+ if (el) {
44506
+ var fieldVal = el.value;
44507
+ fieldValues[fieldKey] = fieldVal;
44508
+ existingFields[fieldKey] = fieldVal;
44497
44509
  }
44498
44510
  }
44499
- // If 'other' is selected for checkbox group, make sure it has a value
44500
- return servar.type === 'multiselect' && value.some(function (val) { return !val; });
44511
+ });
44512
+ }
44513
+
44514
+ var IMPORTED_URLS = new Set();
44515
+ function dynamicImport(dependencies, parallel, force) {
44516
+ if (parallel === void 0) { parallel = true; }
44517
+ if (force === void 0) { force = false; }
44518
+ if (typeof dependencies === 'string')
44519
+ dependencies = [dependencies];
44520
+ var newDependencies = [];
44521
+ dependencies.forEach(function (d) {
44522
+ var dup = IMPORTED_URLS.has(d);
44523
+ if (dup && force) {
44524
+ var base = d;
44525
+ var counter = 1;
44526
+ while (dup) {
44527
+ d = "".concat(base, "?version=").concat(counter);
44528
+ dup = IMPORTED_URLS.has(d);
44529
+ counter++;
44530
+ }
44531
+ }
44532
+ if (!dup) {
44533
+ IMPORTED_URLS.add(d);
44534
+ newDependencies.push(d);
44535
+ }
44536
+ });
44537
+ if (newDependencies.length === 0)
44538
+ return Promise.resolve();
44539
+ if (parallel) {
44540
+ return new Promise(function (resolve) {
44541
+ global.scriptjsLoadPromise.then(function ($script) {
44542
+ $script.default(newDependencies, function (lib) {
44543
+ resolve(lib);
44544
+ });
44545
+ });
44546
+ });
44501
44547
  }
44502
- var noVal;
44503
- switch (servar.type) {
44504
- case 'matrix':
44505
- // Each key in value needs to have an array with at least one value
44506
- noVal = servar.metadata.questions.some(function (_a) {
44507
- var id = _a.id;
44508
- return !value[id] || value[id].length === 0;
44548
+ else {
44549
+ return new Promise(function (resolve) {
44550
+ global.scriptjsLoadPromise.then(function ($script) {
44551
+ $script.default.order(newDependencies, resolve);
44509
44552
  });
44510
- break;
44511
- case 'select':
44512
- case 'signature':
44513
- noVal = !value;
44514
- break;
44515
- case 'checkbox':
44516
- // eslint-disable-next-line camelcase
44517
- noVal = !value && ((_a = servar.metadata) === null || _a === void 0 ? void 0 : _a.must_check);
44518
- break;
44519
- case 'payment_method':
44520
- noVal = !(value === null || value === void 0 ? void 0 : value.complete);
44521
- break;
44522
- case 'rating':
44523
- noVal = !value;
44524
- break;
44525
- default:
44526
- if (typeof value === 'string')
44527
- value = value.trim();
44528
- noVal = ['', null, undefined].includes(value);
44529
- break;
44553
+ });
44530
44554
  }
44531
- return noVal;
44532
44555
  }
44533
- /**
44534
- * Default validations.
44535
- * Returns the error message for a field value if it's invalid.
44536
- * Returns an empty string if it's valid.
44537
- */
44538
- function getStandardFieldError(value, servar, repeat) {
44539
- var defaultErrors = initInfo().defaultErrors;
44540
- if (isFieldValueEmpty(value, servar)) {
44541
- // If no value, error if field is required
44542
- return servar.required ? defaultErrors.required : '';
44543
- }
44544
- if (servar.min_length && value.length < servar.min_length) {
44545
- return defaultErrors.minimum.replace('{length}', servar.min_length);
44546
- }
44547
- var defaultErr = defaultErrors[servar.type];
44548
- // Check if value is badly formatted
44549
- if (servar.type === 'phone_number' && !validators.phone(value)) {
44550
- return defaultErr;
44551
- }
44552
- else if (servar.type === 'email' && !validators.email(value)) {
44553
- return defaultErr;
44554
- }
44555
- else if (servar.type === 'url' && !validators.url(value)) {
44556
- // Try appending https since user may have just omitted the protocol
44557
- var newVal = 'https://' + value;
44558
- if (validators.url(newVal)) {
44559
- if (servar.repeated) {
44560
- // @ts-ignore
44561
- fieldValues[servar === null || servar === void 0 ? void 0 : servar.key][repeat] = newVal;
44556
+ function initializeIntegrations(integs, featheryClient) {
44557
+ return __awaiter$2(this, void 0, void 0, function () {
44558
+ var gtm;
44559
+ return __generator(this, function (_a) {
44560
+ switch (_a.label) {
44561
+ case 0: return [4 /*yield*/, Promise.all([
44562
+ installArgyle(!!integs.argyle),
44563
+ installPlaid(!!integs.plaid),
44564
+ installFirebase(integs.firebase),
44565
+ installStytch(integs.stytch),
44566
+ installStripe(integs.stripe),
44567
+ installSegment(integs.segment),
44568
+ installGoogleAnalytics(integs['google-analytics']),
44569
+ installHeap(integs.heap),
44570
+ installAmplitude(integs.amplitude),
44571
+ installMixpanel(integs.mixpanel),
44572
+ installIntercom(integs['intercom-embedded']),
44573
+ installRudderStack(integs.rudderstack),
44574
+ installPersona(integs.persona),
44575
+ installAlloy(integs.alloy),
44576
+ installTrustedForm(integs.trustedform, featheryClient.formKey)
44577
+ ])];
44578
+ case 1:
44579
+ _a.sent();
44580
+ gtm = integs['google-tag-manager'];
44581
+ if (gtm)
44582
+ initializeTagManager(gtm);
44583
+ if (integs.firebase || integs.stytch) {
44584
+ authState.authFormKey = featheryClient.formKey;
44585
+ return [2 /*return*/, Auth.inferLoginOnLoad(featheryClient)];
44586
+ }
44587
+ return [2 /*return*/];
44562
44588
  }
44563
- else
44564
- fieldValues[servar.key] = newVal;
44565
- return '';
44566
- }
44567
- return defaultErr;
44568
- }
44569
- else if (servar.type === 'ssn' &&
44570
- value.length !== (servar.metadata.last_four_digits ? 4 : 9)) {
44571
- return defaultErr;
44572
- }
44573
- else if (servar.type === 'pin_input' &&
44574
- value.length !== servar.max_length) {
44575
- return defaultErr;
44589
+ });
44590
+ });
44591
+ }
44592
+ function trackEvent(integrations, title, stepId, formName, fieldData) {
44593
+ var metadata = { formName: formName };
44594
+ if (stepId)
44595
+ metadata.stepId = stepId;
44596
+ // Google Tag Manager
44597
+ // @ts-expect-error TS(2551): Property 'initialized' does not exist on type '{ d... Remove this comment to see the full error message
44598
+ if (TagManager.initialized) {
44599
+ var gtmData = __assign({}, metadata);
44600
+ if (fieldData === null || fieldData === void 0 ? void 0 : fieldData['google-tag-manager'])
44601
+ gtmData = __assign(__assign({}, gtmData), fieldData['google-tag-manager']);
44602
+ TagManager.dataLayer({ dataLayer: __assign(__assign({}, gtmData), { event: title }) });
44576
44603
  }
44577
- else if (servar.type === 'password') {
44578
- var meta = servar.metadata;
44579
- var msg = function (key) { return "Your password must have at least 1 ".concat(key); };
44580
- if (meta.letter_required && !LETTER_MATCH.test(value))
44581
- return msg('letter');
44582
- if (meta.uppercase_letter_required && !UPPERCASE_LETTER_MATCH.test(value))
44583
- return msg('uppercase letter');
44584
- if (meta.lowercase_letter_required && !LOWERCASE_LETTER_MATCH.test(value))
44585
- return msg('lowercase letter');
44586
- if (meta.number_required && !NUMBER_MATCH.test(value))
44587
- return msg('number');
44588
- if (meta.symbol_required && !SYMBOL_MATCH.test(value))
44589
- return msg('symbol');
44604
+ // RudderStack
44605
+ if (rudderStackInstalled) {
44606
+ var rudderData = __assign({}, metadata);
44607
+ if (title === 'FeatheryFormComplete')
44608
+ rudderData.fieldData = fieldValues;
44609
+ trackRudderEvent(title, rudderData, integrations === null || integrations === void 0 ? void 0 : integrations.rudderstack);
44590
44610
  }
44591
- // No error
44592
- return '';
44611
+ // Google Analytics
44612
+ if (gaInstalled)
44613
+ trackGAEvent(formName, title, stepId);
44614
+ // Segment
44615
+ var segmentData = __assign({}, metadata);
44616
+ if (fieldData === null || fieldData === void 0 ? void 0 : fieldData.segment)
44617
+ segmentData.submittedData = fieldData.segment;
44618
+ if (featheryWindow().analytics)
44619
+ featheryWindow().analytics.track(title, segmentData);
44620
+ var amplitudeData = __assign({}, metadata);
44621
+ if (fieldData === null || fieldData === void 0 ? void 0 : fieldData.amplitude)
44622
+ amplitudeData.submittedData = fieldData.amplitude;
44623
+ if (featheryWindow().amplitude)
44624
+ featheryWindow().amplitude.track(title, amplitudeData);
44625
+ if (featheryWindow().mixpanel)
44626
+ featheryWindow().mixpanel.track(title, metadata);
44593
44627
  }
44594
44628
 
44595
44629
  var QR_SCANNER_LIB_URL = 'https://unpkg.com/html5-qrcode';
@@ -45947,9 +45981,9 @@ function init(sdkKey, options) {
45947
45981
  if (runningInClient()) {
45948
45982
  // Dynamically load libraries that must be client side
45949
45983
  global.scriptjsLoadPromise = import(
45950
- /* webpackChunkName: "scriptjs" */ './fthry_script.BzxDIntC.js').then(function (n) { return n.s; });
45984
+ /* webpackChunkName: "scriptjs" */ './fthry_script.0KhNn8f9.js').then(function (n) { return n.s; });
45951
45985
  global.webfontloaderPromise = import(
45952
- /* webpackChunkName: "webfontloader" */ './fthry_webfontloader.CI8nQbb6.js').then(function (n) { return n.w; });
45986
+ /* webpackChunkName: "webfontloader" */ './fthry_webfontloader.Dyilj6id.js').then(function (n) { return n.w; });
45953
45987
  // Client-side tracking logic
45954
45988
  if (initState.userTracking === 'cookie') {
45955
45989
  var cookieKey = "feathery-user-id-".concat(sdkKey);
@@ -46095,7 +46129,7 @@ function getFieldValues() {
46095
46129
  return __assign({}, fieldValues);
46096
46130
  }
46097
46131
  function logFeatheryBadge() {
46098
- console.log('%c Feathery %c v' + "2.23.3" + ' ', // replaced with real version during build
46132
+ console.log('%c Feathery %c v' + "2.23.5" + ' ', // replaced with real version during build
46099
46133
  'background: #e2626e; color: white; padding: 2px 6px; border-radius: 3px 0 0 3px; font-weight: bold;', 'background: #fce7e9; color: #c5495a; padding: 2px 6px; border-radius: 0 3px 3px 0;');
46100
46134
  }
46101
46135
 
@@ -47528,39 +47562,39 @@ breakpoint) {
47528
47562
  return styles.getTarget('inner-container', undefined, viewport === 'mobile');
47529
47563
  };
47530
47564
 
47531
- var AddressLine1 = lazy(function () { return import(/* webpackChunkName: "AddressField" */ './fthry_index.Ce0LfPTs.js'); });
47532
- var ButtonGroupField = lazy(function () { return import(/* webpackChunkName: "ButtonGroupField" */ './fthry_index.hD4VI9ak.js'); });
47533
- var CheckboxField = lazy(function () { return import(/* webpackChunkName: "CheckboxField" */ './fthry_index.LL5LHx6u.js'); });
47565
+ var AddressLine1 = lazy(function () { return import(/* webpackChunkName: "AddressField" */ './fthry_index.C4cVkdmR.js'); });
47566
+ var ButtonGroupField = lazy(function () { return import(/* webpackChunkName: "ButtonGroupField" */ './fthry_index.BIkyi9OD.js'); });
47567
+ var CheckboxField = lazy(function () { return import(/* webpackChunkName: "CheckboxField" */ './fthry_index.CyjNCuWE.js'); });
47534
47568
  var CheckboxGroupField = lazy(function () {
47535
- return import(/* webpackChunkName: "CheckboxGroupField" */ './fthry_index.BJXPVhqn.js');
47569
+ return import(/* webpackChunkName: "CheckboxGroupField" */ './fthry_index.CnNPiyfF.js');
47536
47570
  });
47537
- var ColorPickerField = lazy(function () { return import(/* webpackChunkName: "ColorPickerField" */ './fthry_index.SaBEl6_L.js'); });
47538
- var CustomField = lazy(function () { return import(/* webpackChunkName: "CustomField" */ './fthry_index.E97uBUJr.js'); });
47571
+ var ColorPickerField = lazy(function () { return import(/* webpackChunkName: "ColorPickerField" */ './fthry_index.Degy27gw.js'); });
47572
+ var CustomField = lazy(function () { return import(/* webpackChunkName: "CustomField" */ './fthry_index.qQius3J9.js'); });
47539
47573
  var DateSelectorField = lazy(function () {
47540
- return import(/* webpackChunkName: "DateSelectorField" */ './fthry_index.saXzLiO5.js');
47574
+ return import(/* webpackChunkName: "DateSelectorField" */ './fthry_index.D86GTeP3.js');
47541
47575
  });
47542
- var DropdownField = lazy(function () { return import(/* webpackChunkName: "DropdownField" */ './fthry_index.LLvosXZC.js'); });
47576
+ var DropdownField = lazy(function () { return import(/* webpackChunkName: "DropdownField" */ './fthry_index.B0_n9jqc.js'); });
47543
47577
  var DropdownMultiField = lazy(function () {
47544
- return import(/* webpackChunkName: "DropdownMultiField" */ './fthry_index.DqN9FbBz.js');
47578
+ return import(/* webpackChunkName: "DropdownMultiField" */ './fthry_index.FjbxGNs2.js');
47545
47579
  });
47546
- var FileUploadField = lazy(function () { return import(/* webpackChunkName: "FileUploadField" */ './fthry_index.BdHFQJ4O.js'); });
47547
- var MatrixField = lazy(function () { return import(/* webpackChunkName: "MatrixField" */ './fthry_index.7fQDnsUX.js'); });
47548
- var PasswordField = lazy(function () { return import(/* webpackChunkName: "PasswordField" */ './fthry_index.C1kvOEHl.js'); });
47580
+ var FileUploadField = lazy(function () { return import(/* webpackChunkName: "FileUploadField" */ './fthry_index.D4ENNIPP.js'); });
47581
+ var MatrixField = lazy(function () { return import(/* webpackChunkName: "MatrixField" */ './fthry_index.CefyT_Xy.js'); });
47582
+ var PasswordField = lazy(function () { return import(/* webpackChunkName: "PasswordField" */ './fthry_index.C0FNSGu0.js'); });
47549
47583
  var PaymentMethodField = lazy(function () {
47550
- return import(/* webpackChunkName: "PaymentMethodField" */ './fthry_PaymentMethodField.DOD4xxBf.js');
47584
+ return import(/* webpackChunkName: "PaymentMethodField" */ './fthry_PaymentMethodField.CVKE3t_i.js');
47551
47585
  });
47552
- var PhoneField = lazy(function () { return import(/* webpackChunkName: "PhoneField" */ './fthry_index.BJAdYqCo.js'); });
47553
- var PinInputField = lazy(function () { return import(/* webpackChunkName: "PinInputField" */ './fthry_index.BbESsk-g.js'); });
47554
- var QRScanner = lazy(function () { return import(/* webpackChunkName: "QRScanner" */ './fthry_index.BykB3HX8.js'); });
47586
+ var PhoneField = lazy(function () { return import(/* webpackChunkName: "PhoneField" */ './fthry_index.Cy8OGyJ9.js'); });
47587
+ var PinInputField = lazy(function () { return import(/* webpackChunkName: "PinInputField" */ './fthry_index.CsQzji9M.js'); });
47588
+ var QRScanner = lazy(function () { return import(/* webpackChunkName: "QRScanner" */ './fthry_index.BbSZxIR5.js'); });
47555
47589
  var RadioButtonGroupField = lazy(function () {
47556
47590
  return import(
47557
- /* webpackChunkName: "RadioButtonGroupField" */ './fthry_index.D_445pef.js');
47591
+ /* webpackChunkName: "RadioButtonGroupField" */ './fthry_index.7TulZeVg.js');
47558
47592
  });
47559
- var RatingField = lazy(function () { return import(/* webpackChunkName: "RatingField" */ './fthry_index.DhrE0rpb.js'); });
47560
- var SignatureField = lazy(function () { return import(/* webpackChunkName: "SignatureField" */ './fthry_index.BIezS_Js.js'); });
47561
- var SliderField = lazy(function () { return import(/* webpackChunkName: "SliderField" */ './fthry_index.DjoYiCbm.js'); });
47562
- var TextField = lazy(function () { return import(/* webpackChunkName: "TextField" */ './fthry_index.CA8KDA0W.js'); });
47563
- var TextArea = lazy(function () { return import(/* webpackChunkName: "TextArea" */ './fthry_index.DITsZWwh.js'); });
47593
+ var RatingField = lazy(function () { return import(/* webpackChunkName: "RatingField" */ './fthry_index.BPmvHG0R.js'); });
47594
+ var SignatureField = lazy(function () { return import(/* webpackChunkName: "SignatureField" */ './fthry_index.5oEnjTzQ.js'); });
47595
+ var SliderField = lazy(function () { return import(/* webpackChunkName: "SliderField" */ './fthry_index.DoxZOyru.js'); });
47596
+ var TextField = lazy(function () { return import(/* webpackChunkName: "TextField" */ './fthry_index.BQTGcd6O.js'); });
47597
+ var TextArea = lazy(function () { return import(/* webpackChunkName: "TextArea" */ './fthry_index.Beh4LhUb.js'); });
47564
47598
  var Fields = {
47565
47599
  AddressLine1: AddressLine1,
47566
47600
  ButtonGroupField: ButtonGroupField,
@@ -48500,7 +48534,7 @@ function ElementSkeleton(_a) {
48500
48534
  }
48501
48535
  var templateObject_1;
48502
48536
 
48503
- var TableElement = lazy(function () { return import(/* webpackChunkName: "TableElement" */ './fthry_index.BbQn1vco.js'); });
48537
+ var TableElement = lazy(function () { return import(/* webpackChunkName: "TableElement" */ './fthry_index.AdQD-dII.js'); });
48504
48538
  var Basic = {
48505
48539
  ImageElement: ImageElement,
48506
48540
  VideoElement: VideoElement,
@@ -48797,4 +48831,4 @@ var Feathery = {
48797
48831
  renderAt: renderAt
48798
48832
  };
48799
48833
 
48800
- export { strlen as $, API_URL as A, formatDateString as B, countryData as C, DROPDOWN_Z_INDEX as D, ErrorInput as E, Fragment as F, Global as G, stringify$2 as H, rulesheet as I, COMMENT as J, middleware as K, combine as L, match as M, serialize as N, copy as O, replace as P, MOZ as Q, RULESET as R, MS as S, KEYFRAMES as T, DECLARATION as U, dealloc as V, WEBKIT as W, alloc as X, hash as Y, charat as Z, __assign as _, jsxs as a, indexof as a0, next as a1, token as a2, from as a3, peek as a4, delimit as a5, slice as a6, position as a7, compile as a8, isEmptyArray as a9, updateUserId as aA, updateTheme as aB, setFieldValues as aC, getFieldValues as aD, renderAt as aE, LoginForm as aF, useAuthClient as aG, Feathery as aH, StyledContainer as aI, toList as aa, useThumbnailData as ab, downloadFile as ac, CloseIcon as ad, justRemove as ae, getStripe as af, filterKeys as ag, ERROR_COLOR as ah, authState as ai, firebaseSMSCountries as aj, phoneLibPromise as ak, isNum as al, loadQRScanner as am, throttle as an, qrPromise as ao, devicePixelRatio as ap, toBase64 as aq, MODAL_Z_INDEX as ar, dataURLToFile as as, cls as at, getFieldValue$1 as au, emailPatternStr as av, replaceTextVariables as aw, ReactForm as ax, Elements as ay, init as az, __read as b, fieldValues as c, __values as d, __spreadArray as e, featheryDoc as f, getDefaultExportFromCjs as g, hoverStylesGuard as h, initInfo as i, jsx$1 as j, iosScrollOnFocus as k, __awaiter$2 as l, __generator as m, FeatheryClient as n, debounce as o, imgMaxSizeStyles as p, noTextSelectStyles as q, resetStyles as r, stringifyWithNull as s, FORM_Z_INDEX as t, useBorder as u, featheryWindow as v, css as w, __makeTemplateObject as x, isMobile as y, __rest$1 as z };
48834
+ export { strlen as $, API_URL as A, formatDateString as B, countryData as C, DROPDOWN_Z_INDEX as D, ErrorInput as E, Fragment as F, Global as G, stringify$2 as H, rulesheet as I, COMMENT as J, middleware as K, combine as L, match as M, serialize as N, copy as O, replace as P, MOZ as Q, RULESET as R, MS as S, KEYFRAMES as T, DECLARATION as U, dealloc as V, WEBKIT as W, alloc as X, hash as Y, charat as Z, __assign as _, jsxs as a, indexof as a0, next as a1, token as a2, from as a3, peek as a4, delimit as a5, slice as a6, position as a7, compile as a8, isEmptyArray as a9, init as aA, updateUserId as aB, updateTheme as aC, setFieldValues as aD, getFieldValues as aE, renderAt as aF, LoginForm as aG, useAuthClient as aH, Feathery as aI, StyledContainer as aJ, toList as aa, useThumbnailData as ab, downloadFile as ac, CloseIcon as ad, justRemove as ae, getStripe as af, filterKeys as ag, ERROR_COLOR as ah, phoneLib as ai, authState as aj, firebaseSMSCountries as ak, phoneLibPromise as al, isNum as am, loadQRScanner as an, throttle as ao, qrPromise as ap, devicePixelRatio as aq, toBase64 as ar, MODAL_Z_INDEX as as, dataURLToFile as at, cls as au, getFieldValue$1 as av, emailPatternStr as aw, replaceTextVariables as ax, ReactForm as ay, Elements as az, __read as b, fieldValues as c, __values as d, __spreadArray as e, featheryDoc as f, getDefaultExportFromCjs as g, hoverStylesGuard as h, initInfo as i, jsx$1 as j, iosScrollOnFocus as k, __awaiter$2 as l, __generator as m, FeatheryClient as n, debounce as o, imgMaxSizeStyles as p, noTextSelectStyles as q, resetStyles as r, stringifyWithNull as s, FORM_Z_INDEX as t, useBorder as u, featheryWindow as v, css as w, __makeTemplateObject as x, isMobile as y, __rest$1 as z };