fansunited-frontend-core 0.0.43 → 0.0.45

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 (47) hide show
  1. package/components/Notification.d.ts.map +1 -1
  2. package/components/Notification.js +36 -0
  3. package/components/Notification.js.map +1 -0
  4. package/functions/functions.d.ts +3 -3
  5. package/functions/functions.d.ts.map +1 -1
  6. package/functions/functions.js +4 -0
  7. package/functions/functions.js.map +1 -0
  8. package/functions/helpers.d.ts +7 -6
  9. package/functions/helpers.d.ts.map +1 -1
  10. package/functions/helpers.js +152 -0
  11. package/functions/helpers.js.map +1 -0
  12. package/index.es.js +11263 -7801
  13. package/interfaces/interfaces.d.ts +29 -1
  14. package/interfaces/interfaces.d.ts.map +1 -1
  15. package/locales/bg.json +240 -0
  16. package/locales/bg.json.d.ts +240 -0
  17. package/locales/de.json +231 -0
  18. package/locales/de.json.d.ts +232 -2
  19. package/locales/el.json +231 -0
  20. package/locales/el.json.d.ts +232 -2
  21. package/locales/en.json +240 -0
  22. package/locales/en.json.d.ts +240 -0
  23. package/locales/es.json +231 -0
  24. package/locales/es.json.d.ts +232 -2
  25. package/locales/fr-be.json +231 -0
  26. package/locales/fr-be.json.d.ts +232 -2
  27. package/locales/fr.json +231 -0
  28. package/locales/fr.json.d.ts +232 -2
  29. package/locales/it.json +231 -0
  30. package/locales/it.json.d.ts +232 -2
  31. package/locales/pl.json +231 -0
  32. package/locales/pl.json.d.ts +232 -2
  33. package/locales/pt-br.json +231 -0
  34. package/locales/pt-br.json.d.ts +232 -2
  35. package/locales/pt.json +231 -0
  36. package/locales/pt.json.d.ts +232 -2
  37. package/locales/ro.json +231 -0
  38. package/locales/ro.json.d.ts +232 -2
  39. package/locales/sk.json +231 -0
  40. package/locales/sk.json.d.ts +232 -2
  41. package/locales/sr.json +231 -0
  42. package/locales/sr.json.d.ts +232 -2
  43. package/package.json +1 -1
  44. package/types/types.d.ts +2 -1
  45. package/types/types.d.ts.map +1 -1
  46. package/types/types.js +2 -0
  47. package/types/types.js.map +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Notification.d.ts","sourceRoot":"","sources":["../../src/components/Notification.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,iBAAiB;IACzB,YAAY,EAAE,iBAAiB,CAAC;IAChC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA6D7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"Notification.d.ts","sourceRoot":"","sources":["../../src/components/Notification.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,iBAAiB;IACzB,YAAY,EAAE,iBAAiB,CAAC;IAChC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA+D7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import ReactDOM from "react-dom";
3
+ import { Box, Typography, Snackbar } from "@mui/joy";
4
+ import CheckCircleIcon from "@mui/icons-material/CheckCircle";
5
+ import ErrorIcon from "@mui/icons-material/Error";
6
+ import { useCornerRadius, useFontFamily } from "../functions/theme";
7
+ import { useConstantContext } from "../hooks/useConstantContext";
8
+ import { ConstantsContext } from "../providers/ConstantsProvider";
9
+ const Notification = ({ notification, onClose, }) => {
10
+ const borderRadius = useCornerRadius();
11
+ const fontFamily = useFontFamily();
12
+ const { shadowRootElement } = useConstantContext(ConstantsContext);
13
+ if (!notification.open) {
14
+ return null;
15
+ }
16
+ return ReactDOM.createPortal(_jsx(Snackbar, { open: notification.open, onClose: onClose, autoHideDuration: notification.variant === "error" ? 5000 : 3000, anchorOrigin: { vertical: "top", horizontal: "center" }, color: notification.variant === "success" ? "success" : "danger", variant: "soft", startDecorator: notification.variant === "success" ? _jsx(CheckCircleIcon, {}) : _jsx(ErrorIcon, {}), sx: {
17
+ borderRadius: borderRadius.sm,
18
+ fontFamily: fontFamily.secondary,
19
+ minWidth: "300px",
20
+ maxWidth: "400px",
21
+ zIndex: 9999,
22
+ position: "fixed",
23
+ }, children: _jsxs(Box, { sx: { display: "flex", flexDirection: "column", gap: "4px" }, children: [notification.title && (_jsx(Typography, { level: "title-md", sx: {
24
+ fontWeight: 600,
25
+ fontSize: "16px",
26
+ lineHeight: 1.2,
27
+ color: "inherit",
28
+ }, children: notification.title })), notification.message && (_jsx(Typography, { level: "body-sm", sx: {
29
+ fontSize: "14px",
30
+ lineHeight: 1.3,
31
+ color: "inherit",
32
+ opacity: 0.9,
33
+ }, children: notification.message }))] }) }), shadowRootElement ?? document.body);
34
+ };
35
+ export default Notification;
36
+ //# sourceMappingURL=Notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Notification.js","sourceRoot":"","sources":["../../src/components/Notification.tsx"],"names":[],"mappings":";AACA,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,SAAS,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,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AAE,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,aAC9D,YAAY,CAAC,KAAK,IAAI,CACrB,KAAC,UAAU,IACT,KAAK,EAAC,UAAU,EAChB,EAAE,EAAE;wBACF,UAAU,EAAE,GAAG;wBACf,QAAQ,EAAE,MAAM;wBAChB,UAAU,EAAE,GAAG;wBACf,KAAK,EAAE,SAAS;qBACjB,YAEA,YAAY,CAAC,KAAK,GACR,CACd,EACA,YAAY,CAAC,OAAO,IAAI,CACvB,KAAC,UAAU,IACT,KAAK,EAAC,SAAS,EACf,EAAE,EAAE;wBACF,QAAQ,EAAE,MAAM;wBAChB,UAAU,EAAE,GAAG;wBACf,KAAK,EAAE,SAAS;wBAChB,OAAO,EAAE,GAAG;qBACb,YAEA,YAAY,CAAC,OAAO,GACV,CACd,IACG,GACG,EACX,iBAAiB,IAAI,QAAQ,CAAC,IAAI,CACnC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,4 +1,4 @@
1
- export { useSpacingScale, getSpacing, isMobile, isExtraSmall, isTablet, isDesktop, useFontFamily, useCornerRadius, useColors, useBorderSize, useInternalTheme, useImageBackgroundGradient, isLarge, useCurrentThemeMode, } from './theme';
2
- export { stripHtmlTags, hexToRgb, isAndroid, getDefaultCountryByCode, getDefaultCountryByLanguage, extractBrandingModelProperties, extractBrandingProperties, sanitizeBackgroundUrl, mapContentTypeToConsentEntityType, getBrandingClickUrl, getRelatedInfoPageId, isWithPrize, } from './helpers';
3
- export { initializeI18n } from './i18n';
1
+ export { useSpacingScale, getSpacing, isMobile, isExtraSmall, isTablet, isDesktop, useFontFamily, useCornerRadius, useColors, useBorderSize, useInternalTheme, useImageBackgroundGradient, isLarge, useCurrentThemeMode, } from "./theme";
2
+ export { stripHtmlTags, hexToRgb, isAndroid, getDefaultCountryByCode, getDefaultCountryByLanguage, extractBrandingModelProperties, extractBrandingProperties, sanitizeBackgroundUrl, mapContentTypeToConsentEntityType, getBrandingClickUrl, getRelatedInfoPageId, isWithPrize, extractSdkError, extractSdkErrorMessage, } from "./helpers";
3
+ export { initializeI18n } from "./i18n";
4
4
  //# sourceMappingURL=functions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/functions/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,aAAa,EACb,eAAe,EACf,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,0BAA0B,EAC1B,OAAO,EACP,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,aAAa,EACb,QAAQ,EACR,SAAS,EACT,uBAAuB,EACvB,2BAA2B,EAC3B,8BAA8B,EAC9B,yBAAyB,EACzB,qBAAqB,EACrB,iCAAiC,EACjC,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,GACZ,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/functions/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,aAAa,EACb,eAAe,EACf,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,0BAA0B,EAC1B,OAAO,EACP,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,aAAa,EACb,QAAQ,EACR,SAAS,EACT,uBAAuB,EACvB,2BAA2B,EAC3B,8BAA8B,EAC9B,yBAAyB,EACzB,qBAAqB,EACrB,iCAAiC,EACjC,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,sBAAsB,GACvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { useSpacingScale, getSpacing, isMobile, isExtraSmall, isTablet, isDesktop, useFontFamily, useCornerRadius, useColors, useBorderSize, useInternalTheme, useImageBackgroundGradient, isLarge, useCurrentThemeMode, } from "./theme";
2
+ export { stripHtmlTags, hexToRgb, isAndroid, getDefaultCountryByCode, getDefaultCountryByLanguage, extractBrandingModelProperties, extractBrandingProperties, sanitizeBackgroundUrl, mapContentTypeToConsentEntityType, getBrandingClickUrl, getRelatedInfoPageId, isWithPrize, extractSdkError, extractSdkErrorMessage, } from "./helpers";
3
+ export { initializeI18n } from "./i18n";
4
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/functions/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,aAAa,EACb,eAAe,EACf,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,0BAA0B,EAC1B,OAAO,EACP,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,aAAa,EACb,QAAQ,EACR,SAAS,EACT,uBAAuB,EACvB,2BAA2B,EAC3B,8BAA8B,EAC9B,yBAAyB,EACzB,qBAAqB,EACrB,iCAAiC,EACjC,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,sBAAsB,GACvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC"}
@@ -1,12 +1,11 @@
1
- import { BrandingColorsModel, BrandingModel, ConsentEntityType, RelatedEntityRelationship } from 'fansunited-sdk-esm';
2
- import { Branding, BrandingColors } from '../interfaces/interfaces';
3
-
1
+ import { BrandingColorsModel, BrandingModel, ConsentEntityType, FansUnitedSDKModel, RelatedEntityRelationship } from "fansunited-sdk-esm";
2
+ import { Branding, BrandingColors, SdkError } from "../interfaces/interfaces";
4
3
  export declare const stripHtmlTags: (html: string | null) => string;
5
4
  export declare const hexToRgb: (hex: string) => string;
6
5
  export declare const isAndroid: () => boolean;
7
- export declare const getDefaultCountryByCode: (phoneCountryCode: string | null) => import('..').CountryType | null;
8
- export declare const getDefaultCountryByLanguage: (language: string | null) => import('..').CountryType | null;
9
- export declare const getCountryByCode: (code: string) => import('..').CountryType | null;
6
+ export declare const getDefaultCountryByCode: (phoneCountryCode: string | null) => import("..").CountryType | null;
7
+ export declare const getDefaultCountryByLanguage: (language: string | null) => import("..").CountryType | null;
8
+ export declare const getCountryByCode: (code: string) => import("..").CountryType | null;
10
9
  export declare const extractBrandingModelProperties: (branding: BrandingModel | null) => {
11
10
  brandingImage: string | null;
12
11
  brandingColors: BrandingColorsModel | null;
@@ -33,4 +32,6 @@ export declare const mapContentTypeToConsentEntityType: (type: string | undefine
33
32
  export declare const getBrandingClickUrl: (primaryUrl: string | null | undefined, secondaryUrl: string | null | undefined, target: "image" | "logo") => string | null;
34
33
  export declare const getRelatedInfoPageId: (related: RelatedEntityRelationship[] | undefined | null) => string | null;
35
34
  export declare const isWithPrize: (flags: string[]) => boolean;
35
+ export declare const extractSdkError: (err: unknown, sdk: FansUnitedSDKModel) => SdkError;
36
+ export declare const extractSdkErrorMessage: (err: unknown, sdk: FansUnitedSDKModel, fallback?: string) => string;
36
37
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/functions/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEpE,eAAO,MAAM,aAAa,SAAU,MAAM,GAAG,IAAI,KAAG,MAKnD,CAAC;AAEF,eAAO,MAAM,QAAQ,QAAS,MAAM,KAAG,MAUtC,CAAC;AAGF,eAAO,MAAM,SAAS,QAA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AM,SAAS,QAAO,OAE5B,CAAC;AAEF,eAAO,MAAM,uBAAuB,qBAAsB,MAAM,GAAG,IAAI,oCAItE,CAAC;AAEF,eAAO,MAAM,2BAA2B,aAAc,MAAM,GAAG,IAAI,oCAIlE,CAAC;AAEF,eAAO,MAAM,gBAAgB,SAAU,MAAM,oCAE5C,CAAC;AAEF,eAAO,MAAM,8BAA8B,aAC/B,aAAa,GAAG,IAAI;;;;CAoB/B,CAAC;AAEF,eAAO,MAAM,yBAAyB,aAAc,QAAQ,GAAG,IAAI;;;;CAmBlE,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAS,MAAM,WAMhD,CAAC;AAEF,eAAO,MAAM,iCAAiC,SACtC,MAAM,GAAG,SAAS,GAAG,IAAI,KAC9B,iBAAiB,GAAG,SAsBtB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,eAClB,MAAM,GAAG,IAAI,GAAG,SAAS,gBACvB,MAAM,GAAG,IAAI,GAAG,SAAS,UAC/B,OAAO,GAAG,MAAM,KACvB,MAAM,GAAG,IAUX,CAAC;AAEF,eAAO,MAAM,oBAAoB,YACtB,yBAAyB,EAAE,GAAG,SAAS,GAAG,IAAI,KACtD,MAAM,GAAG,IAQX,CAAC;AAEF,eAAO,MAAM,WAAW,UAAW,MAAM,EAAE,KAAG,OAI7C,CAAC;AAQF,eAAO,MAAM,eAAe,QACrB,OAAO,OACP,kBAAkB,KACtB,QAkBF,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAC5B,OAAO,OACP,kBAAkB,wBAEtB,MAAuD,CAAC"}
@@ -0,0 +1,152 @@
1
+ import { countries, languageToCountryCode } from "../constants/constants";
2
+ import { isMobile } from "./theme";
3
+ export const stripHtmlTags = (html) => {
4
+ const tmp = document.createElement("div");
5
+ tmp.innerHTML = html || "";
6
+ return tmp.textContent || tmp.innerText || "";
7
+ };
8
+ export const hexToRgb = (hex) => {
9
+ // Remove the hash if present
10
+ hex = hex.replace(/^#/, "");
11
+ // Parse the hex values
12
+ const r = parseInt(hex.substring(0, 2), 16);
13
+ const g = parseInt(hex.substring(2, 4), 16);
14
+ const b = parseInt(hex.substring(4, 6), 16);
15
+ return `${r}, ${g}, ${b}`;
16
+ };
17
+ // Helper function to check if running on Android
18
+ export const isAndroid = () => {
19
+ return /Android/i.test(navigator.userAgent);
20
+ };
21
+ export const getDefaultCountryByCode = (phoneCountryCode) => {
22
+ const code = phoneCountryCode || "44";
23
+ return countries.find((country) => country.phone === code) || null;
24
+ };
25
+ export const getDefaultCountryByLanguage = (language) => {
26
+ const code = language ? languageToCountryCode[language] : "GB";
27
+ return countries.find((country) => country.code === code) || null;
28
+ };
29
+ export const getCountryByCode = (code) => {
30
+ return countries.find((country) => country.code === code) || null;
31
+ };
32
+ export const extractBrandingModelProperties = (branding) => {
33
+ const mobile = isMobile();
34
+ let brandingImage = branding?.images?.backgroundImage || null;
35
+ let brandingLogo = branding?.images?.mainLogo || null;
36
+ let brandingColors = null;
37
+ if (mobile && branding?.images) {
38
+ brandingImage =
39
+ branding.images.mobileBackgroundImage ||
40
+ branding.images.backgroundImage ||
41
+ null;
42
+ brandingLogo = branding.images.mobileLogo || branding.images.mainLogo;
43
+ }
44
+ if (branding?.colors) {
45
+ brandingColors = branding.colors;
46
+ }
47
+ return { brandingImage, brandingColors, brandingLogo };
48
+ };
49
+ export const extractBrandingProperties = (branding) => {
50
+ const mobile = isMobile();
51
+ let brandingImage = branding?.images?.background_image || null;
52
+ let brandingLogo = branding?.images?.main_logo || null;
53
+ let brandingColors = null;
54
+ if (mobile && branding?.images) {
55
+ brandingImage =
56
+ branding.images.mobile_background_image ||
57
+ branding.images.background_image ||
58
+ null;
59
+ brandingLogo = branding.images.mobile_logo || branding.images.main_logo;
60
+ }
61
+ if (branding?.colors) {
62
+ brandingColors = branding.colors;
63
+ }
64
+ return { brandingImage, brandingColors, brandingLogo };
65
+ };
66
+ export const sanitizeBackgroundUrl = (url) => {
67
+ try {
68
+ return `url("${url}")`;
69
+ }
70
+ catch {
71
+ return "none";
72
+ }
73
+ };
74
+ export const mapContentTypeToConsentEntityType = (type) => {
75
+ if (!type)
76
+ return undefined;
77
+ // Backward compatibility: map generic "quiz" to "classic_quiz"
78
+ if (type === "quiz")
79
+ return "classic_quiz";
80
+ // If already valid, pass through
81
+ const valid = [
82
+ "template",
83
+ "classic_quiz",
84
+ "personality_quiz",
85
+ "either_or",
86
+ "match_quiz",
87
+ "top_x",
88
+ "bracket",
89
+ "standing",
90
+ "poll",
91
+ ];
92
+ if (valid.includes(type))
93
+ return type;
94
+ // Fallback: don't set entityType if unknown
95
+ console.warn(`[CollectLead] Unknown content type "${type}" for consents; omitting entityType.`);
96
+ return undefined;
97
+ };
98
+ /**
99
+ * Get the appropriate URL for branding elements based on primaryUrl and secondaryUrl
100
+ * @param primaryUrl - Primary URL from branding.urls.primaryUrl
101
+ * @param secondaryUrl - Secondary URL from branding.urls.secondaryUrl
102
+ * @param target - Target element type: 'image' or 'logo'
103
+ * @returns The appropriate URL or null
104
+ *
105
+ * Logic:
106
+ * - For images: use primaryUrl if available, otherwise null
107
+ * - For logos: use secondaryUrl if available, otherwise primaryUrl if available, otherwise null
108
+ */
109
+ export const getBrandingClickUrl = (primaryUrl, secondaryUrl, target) => {
110
+ const primary = primaryUrl?.trim() || null;
111
+ const secondary = secondaryUrl?.trim() || null;
112
+ if (target === "image") {
113
+ return primary;
114
+ }
115
+ // For logo: secondary takes priority, fallback to primary
116
+ return secondary || primary;
117
+ };
118
+ export const getRelatedInfoPageId = (related) => {
119
+ if (!related?.length)
120
+ return null;
121
+ const match = related.find((r) => r.entityType === "info_page" && r.entityRelationship === "relatedTo");
122
+ return match?.entityId ?? null;
123
+ };
124
+ export const isWithPrize = (flags) => {
125
+ if (!flags)
126
+ return false;
127
+ return flags.some((flag) => flag.toLowerCase() === "prize");
128
+ };
129
+ const FALLBACK_SDK_ERROR = {
130
+ code: 500,
131
+ status: "internal_error",
132
+ message: "An error occurred. Please try again.",
133
+ };
134
+ export const extractSdkError = (err, sdk) => {
135
+ const config = sdk.helpers.getSDKConfiguration();
136
+ if (config.errorHandlingMode === "standard") {
137
+ const e = err;
138
+ return {
139
+ code: e.error?.code ?? FALLBACK_SDK_ERROR.code,
140
+ status: e.error?.status ?? FALLBACK_SDK_ERROR.status,
141
+ message: e.error?.message ?? FALLBACK_SDK_ERROR.message,
142
+ };
143
+ }
144
+ const e = err;
145
+ return {
146
+ code: e.data?.error?.code ?? FALLBACK_SDK_ERROR.code,
147
+ status: e.data?.error?.status ?? FALLBACK_SDK_ERROR.status,
148
+ message: e.data?.error?.message ?? FALLBACK_SDK_ERROR.message,
149
+ };
150
+ };
151
+ export const extractSdkErrorMessage = (err, sdk, fallback = FALLBACK_SDK_ERROR.message) => extractSdkError(err, sdk).message || fallback;
152
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/functions/helpers.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAmB,EAAU,EAAE;IAC3D,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,GAAG,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAE3B,OAAO,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAU,EAAE;IAC9C,6BAA6B;IAC7B,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAE5B,uBAAuB;IACvB,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CA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