@frak-labs/components 1.0.13 → 1.1.0-beta.316053a3

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 (49) hide show
  1. package/cdn/Banner.wHYQSyz3.js +183 -0
  2. package/cdn/ButtonShare.DIyDUgaT.js +1 -0
  3. package/cdn/ButtonWallet.DNxaFMHH.js +40 -0
  4. package/cdn/{GiftIcon.DcyE1R1V.js → GiftIcon.DV54EwfG.js} +1 -1
  5. package/cdn/OpenInAppButton.X1noMnvq.js +1 -0
  6. package/cdn/PostPurchase._SYhdjOf.js +89 -0
  7. package/cdn/components.js +1 -1
  8. package/cdn/defaults.CT8FNvot.js +58 -0
  9. package/cdn/embeddedWallet.BjQSXLkP.js +1 -0
  10. package/cdn/loader.js +168 -1
  11. package/cdn/replay-V6FXES7X.CgBxdfNp.js +1 -0
  12. package/cdn/rewards.D3nh4aTd.js +1 -0
  13. package/cdn/useGlobalComponents.BT0loDl8.js +1 -0
  14. package/cdn/useLightDomStyles.CZ1iTaa9.js +1 -0
  15. package/cdn/useReward.DWHEt1Zs.js +1 -0
  16. package/dist/{GiftIcon-BhL0bhVu.js → GiftIcon-DI0rUKHp.js} +7 -7
  17. package/dist/banner.d.ts +10 -2
  18. package/dist/banner.js +15 -13
  19. package/dist/buttonShare.d.ts +19 -2
  20. package/dist/buttonShare.js +23 -12
  21. package/dist/buttonWallet.js +2 -2
  22. package/dist/openInApp.js +4 -3
  23. package/dist/postPurchase.d.ts +8 -11
  24. package/dist/postPurchase.js +29 -18
  25. package/dist/rewards-CZkWSndn.js +290 -0
  26. package/dist/{useGlobalComponents-Da9LDlRy.js → useGlobalComponents-DFv33ujB.js} +1 -1
  27. package/dist/{useLightDomStyles-DRkTVy4s.js → useLightDomStyles-B_IbOqJZ.js} +1 -1
  28. package/dist/{usePlacement-NZOjZ6IR.js → usePlacement-DtwWaLHO.js} +5 -109
  29. package/dist/{useReward-B-yZ7nhY.js → useReward-D5zzFR11.js} +10 -5
  30. package/package.json +31 -19
  31. package/cdn/Banner.BM-XicfW.js +0 -183
  32. package/cdn/ButtonShare.DsCfkEG1.js +0 -1
  33. package/cdn/ButtonWallet.BQt3QmKr.js +0 -40
  34. package/cdn/OpenInAppButton.BIfTfSWS.js +0 -1
  35. package/cdn/PostPurchase.Bcnzehoo.js +0 -89
  36. package/cdn/actions-CMPlZ7CH.CJIqArwi.js +0 -1
  37. package/cdn/clientReady.ClcVd4_w.js +0 -1
  38. package/cdn/defaults.CIT5-NpH.js +0 -58
  39. package/cdn/embeddedWallet.BXl45f3Y.js +0 -1
  40. package/cdn/replay-V6FXES7X.efKsNT6s.js +0 -1
  41. package/cdn/rewards.CW3JGWuC.js +0 -1
  42. package/cdn/sharedBaseCss.css.BDzFcWnD.js +0 -154
  43. package/cdn/sharingPage.BjReoj_N.js +0 -1
  44. package/cdn/sharingPageProducts.BoDmfrdn.js +0 -1
  45. package/cdn/styleManager.Cun1-fKi.js +0 -1
  46. package/cdn/useGlobalComponents.DqV5lr6s.js +0 -1
  47. package/cdn/useLightDomStyles.BsQue5kI.js +0 -1
  48. package/cdn/useReward.CcsZ70zp.js +0 -1
  49. package/dist/rewards-BtPHdGcI.js +0 -149
@@ -1,6 +1,6 @@
1
1
  import register from "preact-custom-element";
2
2
  import * as coreSdkIndex from "@frak-labs/core-sdk";
3
- import { decompressJsonFromB64, deleteQueryParamCaseInsensitive, detectPageLanguage, getQueryParamCaseInsensitive, sdkConfigStore, setupClient, trackEvent, withCache } from "@frak-labs/core-sdk";
3
+ import { decodeProductsParam, deleteQueryParamCaseInsensitive, detectPageLanguage, getQueryParamCaseInsensitive, sdkConfigStore, setupClient, trackEvent, withCache } from "@frak-labs/core-sdk";
4
4
  import * as coreSdkActions from "@frak-labs/core-sdk/actions";
5
5
  import { displaySharingPage } from "@frak-labs/core-sdk/actions";
6
6
  import { useCallback, useEffect, useState } from "preact/hooks";
@@ -14,6 +14,7 @@ async function openSharingPage(targetInteraction, placement, options) {
14
14
  await displaySharingPage(window.FrakSetup.client, {
15
15
  ...options?.link && { link: options.link },
16
16
  ...options?.products?.length && { products: options.products },
17
+ ...options?.checkoutToken && { checkoutToken: options.checkoutToken },
17
18
  ...targetInteraction && { metadata: { targetInteraction } }
18
19
  }, placement);
19
20
  }
@@ -55,112 +56,6 @@ function detectListenerPreloads() {
55
56
  return document.querySelector(FRAK_COMPONENT_SELECTOR) !== null ? ["sharing"] : [];
56
57
  }
57
58
  //#endregion
58
- //#region src/utils/sharingPageProducts.ts
59
- /**
60
- * Whether `value` is a syntactically valid URL with an `http(s):` scheme.
61
- *
62
- * Used to gate `imageUrl` / `link` fields coming from untrusted inputs (the
63
- * public `products` prop on `<frak-post-purchase>`, decoded query params for
64
- * Klaviyo / email share links, etc.) — the listener-side sharing-page builder
65
- * calls `new URL(...)` on the incoming product link, and a `javascript:` URL
66
- * would be a XSS sink in any consumer that binds the value to an `href`.
67
- */
68
- function isHttpUrl(value) {
69
- try {
70
- const parsed = new URL(value);
71
- return parsed.protocol === "http:" || parsed.protocol === "https:";
72
- } catch {
73
- return false;
74
- }
75
- }
76
- /**
77
- * Coerce a raw `products` value into a candidate array suitable for
78
- * per-item normalisation, or null when it cannot be reduced to one.
79
- *
80
- * Accepts:
81
- * - Real arrays (JS-property surface, decompressed query payloads).
82
- * - JSON-stringified arrays (HTML-attribute surface — WP / Magento
83
- * server-render delivers attribute values as raw strings).
84
- *
85
- * Anything else (non-array non-string, JSON parse failure, JSON that
86
- * decodes to a non-array) is treated as "no products" so the share still
87
- * works without the product card section.
88
- */
89
- function coerceProductCandidates(products) {
90
- if (!products) return null;
91
- if (Array.isArray(products)) return products;
92
- if (typeof products !== "string") return null;
93
- try {
94
- const parsed = JSON.parse(products);
95
- return Array.isArray(parsed) ? parsed : null;
96
- } catch {
97
- return null;
98
- }
99
- }
100
- /**
101
- * Normalise one untrusted candidate into a {@link SharingPageProduct}, or
102
- * return null when the candidate has no usable title.
103
- *
104
- * The `products` payload is a public API boundary — merchants can set it
105
- * server-side via WP / Magento, imperatively from arbitrary JS, or via
106
- * email-template query params built by Klaviyo. Each entry is validated
107
- * structurally so a malformed `link` reaching `new URL(...)` downstream
108
- * would not crash the sharing-page builder, and so a `javascript:` URL
109
- * cannot slip through as `imageUrl` / `link`.
110
- */
111
- function normalizeProductCandidate(candidate) {
112
- if (!candidate || typeof candidate !== "object") return null;
113
- const item = candidate;
114
- const title = typeof item.title === "string" ? item.title.trim() : "";
115
- if (title === "") return null;
116
- const entry = { title };
117
- if (typeof item.imageUrl === "string" && isHttpUrl(item.imageUrl)) entry.imageUrl = item.imageUrl;
118
- if (typeof item.link === "string" && isHttpUrl(item.link)) entry.link = item.link;
119
- if (typeof item.utmContent === "string" && item.utmContent !== "") entry.utmContent = item.utmContent;
120
- return entry;
121
- }
122
- /**
123
- * Pipe `coerceProductCandidates` + `normalizeProductCandidate` over an
124
- * untrusted value and return a non-empty {@link SharingPageProduct}[] or
125
- * `undefined` when nothing usable came out.
126
- *
127
- * The undefined sentinel is what `openSharingPage` / `displaySharingPage`
128
- * expect when the caller has no products to show — the sharing page just
129
- * skips the product card section.
130
- */
131
- function sanitizeProductList(input) {
132
- const candidates = coerceProductCandidates(input);
133
- if (!candidates) return void 0;
134
- const sanitized = [];
135
- for (const candidate of candidates) {
136
- const entry = normalizeProductCandidate(candidate);
137
- if (entry) sanitized.push(entry);
138
- }
139
- return sanitized.length > 0 ? sanitized : void 0;
140
- }
141
- /**
142
- * Decode a `products` URL query param produced by
143
- * `compressJsonToB64(productsArray)` — the encoding Klaviyo (and any
144
- * other email tool) uses when embedding the product list of an order
145
- * confirmation into a Frak share CTA.
146
- *
147
- * The result is run through `sanitizeProductList` so every link / image
148
- * URL is structurally validated before reaching `new URL(...)` downstream.
149
- * Malformed / tampered payloads degrade gracefully to `undefined` — the
150
- * share still works, just without the product card section.
151
- */
152
- function decodeProductsParam(value) {
153
- if (!value) return void 0;
154
- let decoded;
155
- try {
156
- decoded = decompressJsonFromB64(value);
157
- } catch {
158
- return;
159
- }
160
- if (decoded === null) return void 0;
161
- return sanitizeProductList(decoded);
162
- }
163
- //#endregion
164
59
  //#region src/bootstrap/clientReady.ts
165
60
  const CUSTOM_EVENT_NAME = "frak:client";
166
61
  /**
@@ -453,7 +348,8 @@ function getPlacement(id) {
453
348
  * only re-renders when that placement actually changes.
454
349
  */
455
350
  function usePlacement(placementId) {
456
- return useSyncExternalStore(subscribeSdkConfig, useCallback(() => placementId ? getPlacement(placementId) : void 0, [placementId]));
351
+ const getSnapshot = useCallback(() => placementId ? getPlacement(placementId) : void 0, [placementId]);
352
+ return useSyncExternalStore(subscribeSdkConfig, getSnapshot);
457
353
  }
458
354
  //#endregion
459
- export { subscribeSdkConfig as a, sanitizeProductList as c, useLang as i, openSharingPage as l, buildStyleContent as n, useClientReady as o, lightDomBaseCss as r, registerWebComponent as s, usePlacement as t };
355
+ export { subscribeSdkConfig as a, openSharingPage as c, useLang as i, buildStyleContent as n, useClientReady as o, lightDomBaseCss as r, registerWebComponent as s, usePlacement as t };
@@ -1,4 +1,4 @@
1
- import { t as E } from "./rewards-BtPHdGcI.js";
1
+ import { r as q } from "./rewards-CZkWSndn.js";
2
2
  import { getMerchantInformation } from "@frak-labs/core-sdk/actions";
3
3
  import { useEffect, useState } from "preact/hooks";
4
4
  //#region src/hooks/useReward.ts
@@ -12,26 +12,31 @@ import { useEffect, useState } from "preact/hooks";
12
12
  * @param shouldUseReward - Whether to fetch the reward at all
13
13
  * @param targetInteraction - Optional filter by interaction type (e.g. "purchase")
14
14
  * @param audience - Reward side to display: `"referrer"` (default) or `"referee"`
15
+ * @param products - The products currently in view, when known. Purely
16
+ * advisory (see `matchesProductScope`): deprioritizes campaigns matching none
17
+ * of them, and changes nothing when omitted.
15
18
  * @returns Object containing the formatted reward string, or undefined if unavailable
16
19
  */
17
- function useReward(shouldUseReward, targetInteraction, audience) {
20
+ function useReward(shouldUseReward, targetInteraction, audience, products) {
18
21
  const [reward, setReward] = useState(void 0);
19
22
  useEffect(() => {
20
23
  if (!shouldUseReward) return;
21
24
  const client = window.FrakSetup?.client;
22
25
  if (!client) return;
23
26
  getMerchantInformation(client).then((merchantInfo) => {
24
- const best = E(merchantInfo.rewards, {
27
+ const best = q(merchantInfo.rewards, {
25
28
  currency: client.config.metadata?.currency,
26
29
  targetInteraction,
27
- audience
30
+ audience,
31
+ products
28
32
  });
29
33
  if (best && best.payoutType !== "percentage") setReward(best.formatted);
30
34
  }).catch(() => {});
31
35
  }, [
32
36
  shouldUseReward,
33
37
  targetInteraction,
34
- audience
38
+ audience,
39
+ products
35
40
  ]);
36
41
  return { reward };
37
42
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": "https://twitter.com/QNivelais"
12
12
  }
13
13
  ],
14
- "version": "1.0.13",
14
+ "version": "1.1.0-beta.316053a3",
15
15
  "description": "Frak Wallet components, helping any person to interact with the Frak wallet.",
16
16
  "repository": {
17
17
  "url": "https://github.com/frak-id/wallet",
@@ -28,7 +28,18 @@
28
28
  "web-components"
29
29
  ],
30
30
  "license": "GNU GPL 3.0",
31
- "sideEffects": false,
31
+ "sideEffects": [
32
+ "**/*.css",
33
+ "**/*.css.ts",
34
+ "**/components/*/index.ts",
35
+ "**/bootstrap/loader.ts",
36
+ "**/components.ts",
37
+ "./dist/buttonShare.js",
38
+ "./dist/buttonWallet.js",
39
+ "./dist/openInApp.js",
40
+ "./dist/postPurchase.js",
41
+ "./dist/banner.js"
42
+ ],
32
43
  "private": false,
33
44
  "publishConfig": {
34
45
  "access": "public"
@@ -92,32 +103,33 @@
92
103
  "publish": "echo 'Publishing components...'"
93
104
  },
94
105
  "dependencies": {
95
- "@frak-labs/core-sdk": "1.2.1",
96
- "@frak-labs/frame-connector": "0.2.0",
97
- "preact": "^10.29.0",
98
- "preact-custom-element": "^4.6.0",
99
- "@frak-labs/design-system": "0.0.0"
106
+ "@frak-labs/core-sdk": "1.3.0-beta.316053a3",
107
+ "@frak-labs/design-system": "0.0.0",
108
+ "@frak-labs/frame-connector": "1.3.0-beta.316053a3",
109
+ "preact": "^10.29.7",
110
+ "preact-custom-element": "^4.6.0"
100
111
  },
101
112
  "devDependencies": {
102
113
  "@frak-labs/test-foundation": "0.1.0",
103
- "@preact/preset-vite": "^2.10.4",
114
+ "@preact/preset-vite": "^2.10.6",
104
115
  "@rolldown/plugin-node-polyfills": "^1.0.3",
105
- "@testing-library/jest-dom": "^6.9.1",
116
+ "@testing-library/jest-dom": "^7.0.0",
106
117
  "@testing-library/preact": "^3.2.4",
107
118
  "@testing-library/user-event": "^14.6.1",
108
- "@types/jsdom": "^28.0.0",
109
- "@types/node": "^25.6.0",
119
+ "@types/jsdom": "^28.0.3",
120
+ "@types/node": "^25.9.5",
110
121
  "@types/preact-custom-element": "^4.0.4",
111
122
  "@typescript/native": "npm:typescript@^7.0.2",
112
- "@vanilla-extract/css": "^1.21.1",
123
+ "@vanilla-extract/css": "^1.21.2",
113
124
  "@vanilla-extract/integration": "^8.0.10",
114
- "@vanilla-extract/sprinkles": "^1.6.5",
115
- "@vanilla-extract/vite-plugin": "^5.2.4",
116
- "@vitest/coverage-v8": "^4.1.0",
117
- "@vitest/ui": "^4.1.0",
118
- "jsdom": "^29.0.0",
119
- "tsdown": "^0.22.0",
125
+ "@vanilla-extract/sprinkles": "^1.7.0",
126
+ "@vanilla-extract/vite-plugin": "^5.2.6",
127
+ "@vitest/coverage-v8": "^4.1.10",
128
+ "@vitest/ui": "^4.1.10",
129
+ "jsdom": "^29.1.1",
130
+ "rolldown": "~1.2.0",
131
+ "tsdown": "^0.22.14",
120
132
  "typescript": "^6.0.3",
121
- "vitest": "^4.1.4"
133
+ "vitest": "^4.1.10"
122
134
  }
123
135
  }
@@ -1,183 +0,0 @@
1
- import{t as e}from"./sharedBaseCss.css.BDzFcWnD.js";import{a as t,i as n,x as r}from"./clientReady.ClcVd4_w.js";import{d as i,v as a}from"./actions-CMPlZ7CH.CJIqArwi.js";import{a as o,d as s,f as c,l,m as u,n as d,p as f,s as p,t as m,u as ee}from"./defaults.CIT5-NpH.js";import{a as h,i as g,n as _,r as v,t as y}from"./GiftIcon.DcyE1R1V.js";import{t as b}from"./useGlobalComponents.DqV5lr6s.js";import{t as x}from"./useLightDomStyles.BsQue5kI.js";import{r as S}from"./rewards.CW3JGWuC.js";import{t as C}from"./useReward.CcsZ70zp.js";var w=`inAppBanner_body__1ibpiy74`,T=`inAppBanner_closeButton__1ibpiy77`,E=`inAppBanner_container__1ibpiy70`,D=`inAppBanner_cta__1ibpiy76`,O=`inAppBanner_description__1ibpiy75`,k=`inAppBanner_header__1ibpiy71`,A=`inAppBanner_iconWrapper__1ibpiy72`,j=`inAppBanner_title__1ibpiy73`;function te({title:e,description:t,cta:n,dismissLabel:r,onAction:i,onDismiss:a,className:o,classNames:s}){return u(`div`,{className:`${E}${o?` ${o}`:``}`,role:`alert`,children:[u(`div`,{className:k,children:[u(`span`,{className:`${A}${s?.icon?` ${s.icon}`:``}`,children:u(_,{width:20,height:20})}),u(`p`,{className:`${j}${s?.title?` ${s.title}`:``}`,children:e})]}),u(`div`,{className:w,children:[u(`p`,{className:`${O}${s?.description?` ${s.description}`:``}`,children:t}),u(`button`,{type:`button`,className:`${D}${s?.cta?` ${s.cta}`:``}`,onClick:i,children:[n,u(g,{width:14,height:14})]})]}),u(`button`,{type:`button`,className:`${T}${s?.close?` ${s.close}`:``}`,onClick:a,"aria-label":r,children:u(h,{width:16,height:16})})]})}var ne=`Banner_frakLogo__1gnumzi9`,re=`Banner_iconSvg__1gnumzi1`,ie=`Banner_referral__1gnumzi2 reset_base__1831jhd0 Banner_rootBase__1gnumzi0`,ae=`Banner_referralBody__1gnumzi5`,oe=`Banner_referralCta__1gnumzi8 sharedBaseCss_buttonReset__7cswil0`,se=`Banner_referralDescription__1gnumzi7 reset_base__1831jhd0`,ce=`Banner_referralIconWrapper__1gnumzi3`,le=`Banner_referralImage__1gnumzi4`,ue=`Banner_referralTitle__1gnumzi6 reset_base__1831jhd0`;function M({placement:h,classname:g=``,interaction:_,referralTitle:w,referralDescription:T,referralCta:E,inappTitle:D,inappDescription:O,inappCta:k,imageUrl:A,preview:j,previewMode:M,allowInappRedirect:N}){let P=!!j,F=o(),I=M===`inapp`?`inapp`:`referral`,L=N===!0||N===`true`,R=d(h),{shouldRender:z,isHidden:B,isClientReady:V}=p();x(`frak-banner`,h,R?.components?.banner?.css,`@keyframes keyframes_fadeIn__mnqmlt0 {
2
- from {
3
- opacity: 0;
4
- }
5
- to {
6
- opacity: 1;
7
- }
8
- }
9
- @keyframes keyframes_fadeOut__mnqmlt1 {
10
- from {
11
- opacity: 1;
12
- }
13
- to {
14
- opacity: 0;
15
- }
16
- }
17
- @keyframes keyframes_fadeInDown__mnqmlt2 {
18
- from {
19
- opacity: 0;
20
- transform: translateY(-4px);
21
- }
22
- to {
23
- opacity: 1;
24
- transform: translateY(0);
25
- }
26
- }.inAppBanner_container__1ibpiy70 {
27
- position: fixed;
28
- top: max(8px, env(safe-area-inset-top));
29
- left: 16px;
30
- right: 16px;
31
- z-index: 1000;
32
- display: flex;
33
- flex-direction: column;
34
- gap: 4px;
35
- padding: 12px 16px;
36
- padding-right: 32px;
37
- border-radius: 12px;
38
- background-color: #000000cc;
39
- backdrop-filter: blur(12px);
40
- -webkit-backdrop-filter: blur(12px);
41
- color: var(--text-onAction__pbq4ak6);
42
- animation: keyframes_fadeInDown__mnqmlt2 300ms ease-out;
43
- }
44
- .inAppBanner_header__1ibpiy71 {
45
- display: flex;
46
- align-items: center;
47
- gap: 8px;
48
- }
49
- .inAppBanner_iconWrapper__1ibpiy72 {
50
- flex-shrink: 0;
51
- width: 20px;
52
- height: 20px;
53
- display: flex;
54
- align-items: center;
55
- justify-content: center;
56
- color: var(--text-onAction__pbq4ak6);
57
- }
58
- .inAppBanner_title__1ibpiy73 {
59
- margin: 0;
60
- padding: 0;
61
- font-size: 16px;
62
- font-weight: 500;
63
- line-height: 26px;
64
- color: var(--text-onAction__pbq4ak6);
65
- }
66
- .inAppBanner_body__1ibpiy74 {
67
- display: flex;
68
- flex-wrap: wrap;
69
- align-items: baseline;
70
- gap: 0 4px;
71
- }
72
- .inAppBanner_description__1ibpiy75 {
73
- margin: 0;
74
- padding: 0;
75
- font-size: 14px;
76
- color: var(--text-onAction__pbq4ak6);
77
- line-height: 22px;
78
- opacity: 0.96;
79
- }
80
- .inAppBanner_cta__1ibpiy76 {
81
- all: unset;
82
- display: inline-flex;
83
- align-items: center;
84
- gap: 4px;
85
- color: #2bb2ff;
86
- font-size: 14px;
87
- font-weight: 600;
88
- text-decoration: underline;
89
- text-underline-offset: 2px;
90
- cursor: pointer;
91
- }
92
- .inAppBanner_cta__1ibpiy76:focus-visible {
93
- outline: 2px solid #2bb2ff;
94
- outline-offset: 2px;
95
- border-radius: 4px;
96
- }
97
- .inAppBanner_closeButton__1ibpiy77 {
98
- all: unset;
99
- position: absolute;
100
- top: 8px;
101
- right: 8px;
102
- width: 28px;
103
- height: 28px;
104
- display: flex;
105
- align-items: center;
106
- justify-content: center;
107
- border-radius: 9999px;
108
- color: #ffffff99;
109
- cursor: pointer;
110
- }
111
- .inAppBanner_closeButton__1ibpiy77:focus-visible {
112
- outline: 2px solid var(--text-onAction__pbq4ak6);
113
- outline-offset: 2px;
114
- }.Banner_rootBase__1gnumzi0 {
115
- position: relative;
116
- display: flex;
117
- animation: keyframes_fadeInDown__mnqmlt2 300ms ease-out;
118
- }
119
- .Banner_iconSvg__1gnumzi1 {
120
- width: 100%;
121
- height: 100%;
122
- }
123
- .Banner_referral__1gnumzi2 {
124
- flex-direction: row;
125
- align-items: center;
126
- gap: 16px;
127
- padding: 16px;
128
- background-color: #ffffff;
129
- color: var(--text-primary__pbq4ak0);
130
- border: 1px solid var(--border-default__pbq4akv);
131
- border-radius: 12px;
132
- }
133
- .Banner_referralIconWrapper__1gnumzi3 {
134
- flex-shrink: 0;
135
- align-self: flex-start;
136
- display: flex;
137
- align-items: center;
138
- justify-content: center;
139
- width: 40px;
140
- height: 40px;
141
- overflow: hidden;
142
- }
143
- .Banner_referralImage__1gnumzi4 {
144
- max-width: 100%;
145
- max-height: 100%;
146
- width: auto;
147
- height: auto;
148
- object-fit: contain;
149
- display: block;
150
- }
151
- .Banner_referralBody__1gnumzi5 {
152
- flex: 1;
153
- min-width: 0;
154
- }
155
- .Banner_referralTitle__1gnumzi6 {
156
- font-size: 16px;
157
- font-weight: 600;
158
- color: var(--text-primary__pbq4ak0);
159
- line-height: 22px;
160
- }
161
- .Banner_referralDescription__1gnumzi7 {
162
- margin-bottom: 8px;
163
- font-size: 14px;
164
- color: #979797;
165
- line-height: 22px;
166
- }
167
- .Banner_referralCta__1gnumzi8 {
168
- display: inline-block;
169
- padding: 8px 16px;
170
- border: 1px solid #000000;
171
- border-radius: 9999px;
172
- color: var(--text-primary__pbq4ak0);
173
- font-size: 10px;
174
- font-weight: 700;
175
- line-height: 12px;
176
- text-transform: uppercase;
177
- }
178
- .Banner_frakLogo__1gnumzi9 {
179
- position: absolute;
180
- right: 16px;
181
- bottom: 12px;
182
- pointer-events: none;
183
- }`,e);let[H,U]=s(!1),[W,G]=s(()=>P?I:L&&t?`inapp`:null),K=l(null);c(()=>{P&&G(I)},[P,I]);let{reward:q}=C(W===`referral`&&V,_,`referee`),[J,de]=s(null);c(()=>{let e=window.FrakSetup?.client;W!==`inapp`||P||!V||!e||i(e).then(e=>de(e)).catch(()=>{})},[W,P,V]),c(()=>{P||!W||H||K.current!==W&&V&&(r(window.FrakSetup?.client,`banner_impression`,{placement:h,variant:W,has_reward:W===`referral`?!!q:void 0}),K.current=W)},[W,H,V,P,h]),c(()=>{if(P||W===`inapp`)return;let e=()=>G(`referral`);return window.addEventListener(a,e),()=>window.removeEventListener(a,e)},[P,W]);let Y=f(async()=>{if(P)return;if(r(window.FrakSetup?.client,`banner_resolved`,{placement:h,variant:W??`referral`,outcome:`clicked`}),W===`referral`){U(!0);return}let e=J;if(!e&&window.FrakSetup?.client)try{e=await i(window.FrakSetup?.client)}catch{}let t=window.location.href;if(e){let n=new URL(t);n.searchParams.set(`fmt`,e),t=n.toString()}n(t)},[P,W,J,h]),fe=f(()=>{P||(r(window.FrakSetup?.client,`banner_resolved`,{placement:h,variant:W??`referral`,outcome:`dismissed`}),U(!0))},[P,W,h]),X=b(),Z=R?.components?.banner??X?.banner,Q=A??Z?.imageUrl,$=ee(()=>{let e=m[F].banner;if(W===`referral`){let t=q?e.referralTitleReward:e.referralTitle;return{title:S(w??Z?.referralTitle??t,q),description:S(T??Z?.referralDescription??e.referralDescription,q),cta:E??Z?.referralCta??e.referralCta}}return{title:S(D??Z?.inappTitle??e.inappTitle,void 0),description:S(O??Z?.inappDescription??e.inappDescription,void 0),cta:k??Z?.inappCta??e.inappCta}},[F,W,q,Z,w,T,E,D,O,k]);if(!W||!P&&(!z||B||H))return null;let pe=[ie,`frak-banner`,`frak-banner--${W}`,g].filter(Boolean).join(` `);return W===`inapp`?u(te,{title:$.title,description:$.description,cta:$.cta,dismissLabel:m[F].banner.dismissLabel,onAction:Y,onDismiss:fe,className:[`frak-banner`,`frak-banner--inapp`,g].filter(Boolean).join(` `),classNames:{icon:`frak-banner__icon`,title:`frak-banner__title`,description:`frak-banner__description`,cta:`frak-banner__cta`,close:`frak-banner__close`}}):u(`div`,{class:pe,role:`alert`,children:[u(`div`,{class:`${ce} frak-banner__icon`,children:Q?u(`img`,{src:Q,alt:``,class:le}):u(y,{class:re})}),u(`div`,{class:`${ae} frak-banner__text`,children:[u(`p`,{class:`${ue} frak-banner__title`,children:$.title}),u(`p`,{class:`${se} frak-banner__description`,children:$.description}),u(`button`,{type:`button`,class:`${oe} frak-banner__cta`,onClick:Y,children:$.cta})]}),u(v,{class:`${ne} frak-banner__logo`,width:42,height:24})]})}export{M as Banner};
@@ -1 +0,0 @@
1
- import{x as e}from"./clientReady.ClcVd4_w.js";import{t}from"./sharingPage.BjReoj_N.js";import{a as n,m as r,n as i,p as a,s as o,t as s,u as c}from"./defaults.CIT5-NpH.js";import{t as l}from"./useGlobalComponents.DqV5lr6s.js";import{t as u}from"./useLightDomStyles.BsQue5kI.js";import{r as d}from"./rewards.CW3JGWuC.js";import{t as f}from"./useReward.CcsZ70zp.js";import{t as p}from"./embeddedWallet.BXl45f3Y.js";function m({placement:m,text:h,classname:g=``,noRewardText:_,targetInteraction:v,clickAction:y,preview:b}){let x=!!b,S=n(),C=i(m),w=l(),T=C?.components?.buttonShare??w?.buttonShare;u(`frak-button-share`,m,T?.css);let E=c(()=>C?.targetInteraction===void 0?v:C.targetInteraction,[C?.targetInteraction,v]),D=T?.text??h??s[S].buttonShare.text,O=T?.noRewardText??_,k=c(()=>D.includes(`{REWARD}`),[D]),A=c(()=>T?.clickAction??y??`sharing-page`,[T?.clickAction,y]),{shouldRender:j,isHidden:M,isClientReady:N}=o(),{reward:P}=f(k&&N,E),F=c(()=>k?P?d(D,P):O??d(D,void 0):D,[k,D,O,P]),I=a(()=>{if(!x){if(e(window.FrakSetup.client,`share_button_clicked`,{placement:m,target_interaction:E,has_reward:!!P,click_action:A}),A===`embedded-wallet`){p(E,m);return}t(E,m)}},[x,A,E,m,P]);if(!x&&(!j||M))return null;let L=[`button`,`button__fadeIn`,g].filter(Boolean).join(` `);return r(`button`,{type:`button`,disabled:!x&&!N,class:L,onClick:I,children:F})}export{m as ButtonShare};
@@ -1,40 +0,0 @@
1
- import{a as e,d as t,f as n,h as r,m as i,n as a,r as o,s,t as c,u as l}from"./defaults.CIT5-NpH.js";import{t as u}from"./useReward.CcsZ70zp.js";import{t as d}from"./embeddedWallet.BXl45f3Y.js";function f(e){return i(`svg`,{fill:`none`,height:`1em`,viewBox:`0 0 28 28`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[i(`title`,{children:`Gift icon`}),i(`path`,{d:`m23.14 14v11.43h-18.29v-11.43m9.14 11.43v-17.14m0 0h-5.14c-0.76 0-1.48-0.3-2.02-0.84s-0.84-1.26-0.84-2.020.3-1.480.84-2.02 1.26-0.84 2.02-0.84c4 0 5.14 5.71 5.14 5.71zm0 0h5.14c0.76 0 1.48-0.3 2.02-0.84s0.84-1.260.84-2.02-0.3-1.48-0.84-2.02-1.26-0.84-2.02-0.84c-4 0-5.14 5.71-5.14 5.71zm-11.43 0h22.86v5.71h-22.86z`,stroke:`#fff`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]})}function p(){`vibrate`in navigator&&navigator.vibrate(10)}function m(e,t){p(),d(e,t)}function h({placement:d,classname:p=``,useReward:h,targetInteraction:g}){let _=e(),v=a(d),y=l(()=>v?.targetInteraction===void 0?g:v.targetInteraction,[v?.targetInteraction,g]),b=l(()=>h===!0,[h]),{shouldRender:x,isHidden:S,isClientReady:C}=s(),{reward:w}=u(b&&C,y),[T,E]=t(`right`);if(n(()=>{let e=v?.components?.buttonWallet?.position,t=window.FrakSetup?.modalWalletConfig?.metadata?.position;E(e??t??`right`)},[v?.components?.buttonWallet?.position]),!x||S)return null;let D=[`button`,`button__fadeIn`,T===`left`?`button__left`:`button__right`,p].filter(Boolean).join(` `);return i(r,{children:[i(`style`,{children:o(`
2
- .button {
3
- all: unset;
4
- position: fixed;
5
- bottom: 20px;
6
- z-index: 2000000;
7
- display: flex;
8
- justify-content: center;
9
- align-items: center;
10
- background-color: #3e557e;
11
- width: 45px;
12
- height: 45px;
13
- border-radius: 50%;
14
- cursor: pointer;
15
- text-align: center;
16
- font-size: 24px;
17
- }
18
-
19
- .button__left {
20
- left: 20px;
21
- }
22
-
23
- .button__right {
24
- right: 20px;
25
- }
26
-
27
- .reward {
28
- position: absolute;
29
- top: -4px;
30
- right: 27px;
31
- padding: 2px 3px;
32
- border-radius: 5px;
33
- background: #ff3f3f;
34
- font-size: 9px;
35
- color: #fff;
36
- font-weight: 600;
37
- white-space: nowrap;
38
- line-height: 9px;
39
- }
40
- `,v?.components?.buttonWallet?.css)}),i(`button`,{type:`button`,"aria-label":c[_].buttonWallet.ariaLabel,part:`button`,disabled:!C,class:D,onClick:()=>{m(y,d)},children:[i(f,{}),w&&i(`span`,{class:`reward`,children:w})]})]})}export{h as ButtonWallet};
@@ -1 +0,0 @@
1
- import{f as e,h as t,m as n,x as r}from"./clientReady.ClcVd4_w.js";import{a as i,m as a,n as o,s,t as c,u as l}from"./defaults.CIT5-NpH.js";import{t as u}from"./useLightDomStyles.BsQue5kI.js";function d(t=`wallet`,i){let a=window.FrakSetup?.client;a&&r(a,`open_in_app_clicked`,{path:t,placement:i}),e(`${n}${t}`,{onFallback:()=>{a&&r(a,`app_not_installed`,{path:t,placement:i})}})}function f(){return{isMobile:l(()=>t(),[])}}function p({placement:e,text:t,classname:n=``}){let r=i(),l=o(e),{shouldRender:p,isHidden:m,isClientReady:h}=s(),{isMobile:g}=f();u(`frak-open-in-app`,e,l?.components?.openInApp?.css);let _=l?.components?.openInApp?.text??t??c[r].openInApp.text;if(!g||!p||m)return null;let v=()=>{d(void 0,e)},y=[`button`,`button__fadeIn`,n].filter(Boolean).join(` `);return a(`button`,{type:`button`,"aria-label":c[r].openInApp.ariaLabel,disabled:!h,class:y,onClick:v,children:_})}export{p as OpenInAppButton};
@@ -1,89 +0,0 @@
1
- import{t as e}from"./sharedBaseCss.css.BDzFcWnD.js";import{B as t,x as n,z as r}from"./clientReady.ClcVd4_w.js";import{m as i,r as a,u as o}from"./actions-CMPlZ7CH.CJIqArwi.js";import{t as s}from"./sharingPage.BjReoj_N.js";import{n as c}from"./sharingPageProducts.BoDmfrdn.js";import{a as ee,d as l,f as u,l as te,m as d,n as f,p,s as m,t as h,u as g}from"./defaults.CIT5-NpH.js";import{r as ne,t as re}from"./GiftIcon.DcyE1R1V.js";import{t as ie}from"./useGlobalComponents.DqV5lr6s.js";import{t as ae}from"./useLightDomStyles.BsQue5kI.js";import{i as oe,n as _,r as v}from"./rewards.CW3JGWuC.js";var y=`PostPurchase_card__5fv5lh0`,se=`PostPurchase_cardLayout__5fv5lh1`,ce=`PostPurchase_cardLeft__5fv5lh2`,b=`PostPurchase_cardRight__5fv5lh3`,x=`PostPurchase_cta__5fv5lh6 sharedBaseCss_buttonReset__7cswil0`,le=`PostPurchase_customImage__5fv5lha`,ue=`PostPurchase_frakLogo__5fv5lhb`,de=`PostPurchase_giftIcon__5fv5lh8`,fe=`PostPurchase_icon__5fv5lh7`,pe=`PostPurchase_imageWrapper__5fv5lh9`,me=`PostPurchase_message__5fv5lh5`;function he(e,t,n){let r=e?.isReferred?`referee`:`referrer`,i=_(t.rewards,{targetInteraction:`purchase`,currency:n,audience:r});if(!i)return null;let{campaign:a}=i,o=e?.isReferred&&a.referee?`referee`:`referrer`;return{variant:o,reward:o===`referee`?a.referee:a.referrer,merchantDomain:t.onChainMetadata.domain}}function S({customerId:_,orderId:S,token:C,sharingUrl:ge,merchantId:w,placement:T,classname:E=``,variant:D,badgeText:O,referrerText:k,refereeText:A,ctaText:j,preview:M,previewVariant:N,products:P,imageUrl:F}){let I=!!M,{shouldRender:L,isHidden:R,isClientReady:z}=m(),B=f(T),V=ee();ae(`frak-post-purchase`,T,B?.components?.postPurchase?.css,`.PostPurchase_card__5fv5lh0 {
2
- padding: 16px;
3
- border-radius: 12px;
4
- background-color: var(--surface-background__pbq4akc);
5
- border: 1px solid var(--border-default__pbq4akv);
6
- }
7
- .PostPurchase_cardLayout__5fv5lh1 {
8
- display: flex;
9
- flex-direction: row;
10
- align-items: center;
11
- gap: 32px;
12
- }
13
- .PostPurchase_cardLeft__5fv5lh2 {
14
- flex-grow: 1;
15
- min-width: 0;
16
- display: flex;
17
- flex-direction: column;
18
- gap: 8px;
19
- }
20
- .PostPurchase_cardRight__5fv5lh3 {
21
- flex-shrink: 0;
22
- display: flex;
23
- flex-direction: column;
24
- align-items: flex-end;
25
- gap: 8px;
26
- text-align: right;
27
- }
28
- .PostPurchase_badge__5fv5lh4 {
29
- align-self: flex-start;
30
- background-color: #FFF534;
31
- border-radius: 4px;
32
- padding: 4px 8px;
33
- font-size: 12px;
34
- font-weight: 600;
35
- line-height: 12px;
36
- color: var(--text-primary__pbq4ak0);
37
- }
38
- .PostPurchase_message__5fv5lh5 {
39
- margin: 0;
40
- font-size: 16px;
41
- line-height: 22px;
42
- color: var(--text-primary__pbq4ak0);
43
- font-weight: 600;
44
- }
45
- .PostPurchase_cta__5fv5lh6 {
46
- display: inline-flex;
47
- align-items: center;
48
- justify-content: center;
49
- gap: 4px;
50
- padding: 12px 16px;
51
- border-radius: 9999px;
52
- background-color: var(--text-primary__pbq4ak0);
53
- color: var(--text-onAction__pbq4ak6);
54
- font-size: 12px;
55
- font-weight: bold;
56
- text-transform: uppercase;
57
- }
58
- .PostPurchase_cta__5fv5lh6:disabled {
59
- opacity: 0.7;
60
- cursor: default;
61
- }
62
- .PostPurchase_icon__5fv5lh7 {
63
- margin: -2px 0;
64
- }
65
- .PostPurchase_giftIcon__5fv5lh8 {
66
- display: block;
67
- flex-shrink: 0;
68
- }
69
- .PostPurchase_imageWrapper__5fv5lh9 {
70
- flex-shrink: 0;
71
- display: flex;
72
- align-items: center;
73
- justify-content: center;
74
- width: 80px;
75
- height: 80px;
76
- overflow: hidden;
77
- }
78
- .PostPurchase_customImage__5fv5lha {
79
- max-width: 100%;
80
- max-height: 100%;
81
- width: auto;
82
- height: auto;
83
- object-fit: contain;
84
- display: block;
85
- }
86
- .PostPurchase_frakLogo__5fv5lhb {
87
- display: block;
88
- margin-left: auto;
89
- }`,e);let[H,_e]=l(null),[U,W]=l(!1);u(()=>{I||!z||!_||!S||!C||a({customerId:_,orderId:S,token:C,merchantId:w}).catch(()=>{})},[I,z,_,S,C,w]),u(()=>{if(I||!z||U)return;let e=window.FrakSetup?.client;e&&Promise.all([o(e),i(e)]).then(([t,n])=>{W(!0),_e(he(t,n,e.config.metadata?.currency))}).catch(e=>{if(e instanceof t&&e.code===r.configError){W(!0);return}})},[I,z,U]);let G=te(null),K=D??H?.variant??(I?N??`referrer`:void 0),q=ge??H?.merchantDomain,J=g(()=>{if(!H?.reward)return;let e=window.FrakSetup?.client?.config?.metadata?.currency;return oe(H.reward,e)},[H?.reward]),ve=ie(),Y=B?.components?.postPurchase??ve?.postPurchase,X=O??Y?.badgeText,Z=F??Y?.imageUrl,Q=g(()=>{let e=h[V].postPurchase;return{message:K===`referee`?J?v(A??Y?.refereeText??e.refereeText,J):A??Y?.refereeNoRewardText??e.refereeNoRewardText:J?v(k??Y?.referrerText??e.referrerText,J):k??Y?.referrerNoRewardText??e.referrerNoRewardText,cta:J?v(j??Y?.ctaText??e.ctaText,J):j??Y?.ctaNoRewardText??e.ctaNoRewardText}},[V,K,J,Y,k,A,j]);u(()=>{K&&G.current!==K&&z&&(!I&&(!L||R)||(n(window.FrakSetup?.client,`post_purchase_impression`,{placement:T,variant:K,has_reward:!!H?.reward}),G.current=K))},[K,L,R,z,I,T,H?.reward]);let $=g(()=>c(P),[P]),ye=p(()=>{K&&(n(window.FrakSetup?.client,`post_purchase_clicked`,{placement:T,variant:K}),s(void 0,T,{link:q,products:$}))},[K,T,q,$]);return!K||!I&&(!L||R||!H)?null:d(`div`,{className:[y,E].filter(Boolean).join(` `),children:d(`div`,{class:se,children:[d(`div`,{class:ce,children:[X&&d(`span`,{class:`PostPurchase_badge__5fv5lh4`,children:X}),d(`p`,{class:me,children:Q.message}),d(`button`,{type:`button`,className:`${x} button`,disabled:!I&&!z,onClick:I?void 0:ye,children:[Q.cta,d(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:`${fe} button`,children:d(`path`,{d:`M13.9 11.14C13.99 11.05 14.15 11.11 14.15 11.24V11.64C14.15 13.05 12.63 14.19 10.75 14.19C8.87 14.19 7.34 13.05 7.34 11.64V11.24C7.34 11.11 7.51 11.05 7.59 11.14C8.35 11.93 9.48 12.43 10.75 12.43C12.01 12.43 13.15 11.93 13.9 11.14ZM1.85 9.65C1.85 9.51 2.01 9.44 2.1 9.54C2.85 10.32 3.99 10.82 5.25 10.82C5.52 10.82 5.79 10.8 6.04 10.76C6.26 10.72 6.47 10.88 6.47 11.1V12.17C6.47 12.32 6.37 12.45 6.22 12.48C5.92 12.55 5.59 12.59 5.25 12.59C3.37 12.59 1.85 11.45 1.85 10.04V9.65ZM10.75 6.21C12.63 6.21 14.15 7.35 14.15 8.75C14.15 10.16 12.63 11.3 10.75 11.3C8.87 11.3 7.34 10.16 7.34 8.75C7.34 7.35 8.87 6.21 10.75 6.21ZM1.85 6.85C1.85 6.71 2.01 6.65 2.1 6.74C2.85 7.53 3.99 8.03 5.25 8.03C5.52 8.03 5.79 8 6.04 7.96C6.26 7.92 6.47 8.09 6.47 8.3V9.37C6.47 9.52 6.37 9.65 6.22 9.69C5.92 9.75 5.59 9.79 5.25 9.79C3.37 9.79 1.85 8.65 1.85 7.24V6.85ZM5.25 1.81C7.13 1.81 8.66 2.95 8.66 4.36C8.66 5.76 7.13 6.9 5.25 6.9C3.37 6.9 1.85 5.76 1.85 4.36C1.85 2.95 3.37 1.81 5.25 1.81Z`,fill:`currentColor`})})]})]}),d(`div`,{class:b,children:[Z?d(`span`,{class:pe,children:d(`img`,{src:Z,alt:``,class:le})}):d(re,{className:de,width:80,height:80}),d(ne,{className:ue,width:42,height:24})]})]})})}export{S as PostPurchase};
@@ -1 +0,0 @@
1
- import{I as e,L as t,M as n,N as r,O as i,R as a,b as o,j as s,k as c,x as l}from"./clientReady.ClcVd4_w.js";async function u(e,t,n){return await e.request({method:`frak_displayEmbeddedWallet`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function d(e,{steps:t,metadata:n},r){return await e.request({method:`frak_displayModal`,params:r?[t,n,e.config.metadata,r]:[t,n,e.config.metadata]})}async function f(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function p(t){if(typeof window>`u`)return;let r=e();if(!r)return;let i=await o.resolveMerchantId();if(!i)return;let a=`frak-identity-ensured-${i}`;if(!window.sessionStorage.getItem(a))try{let e=n();(await fetch(`${e}/user/identity/ensure`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":t,"x-frak-client-id":r},body:JSON.stringify({merchantId:i})})).ok&&window.sessionStorage.setItem(a,`1`)}catch{}}async function m(e,n){return t(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:n?.cacheTime})}async function h(e,n){return t(()=>e.request({method:`frak_getMergeToken`}),{cacheKey:`frak_getMergeToken`,cacheTime:n?.cacheTime})}async function g(e,n){return t(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:n?.cacheTime})}async function _(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function v(t,n){try{await t.request({method:`frak_sendInteraction`,params:[n,{clientId:e()}]})}catch{}}function y(e,t,n){return c(t)?(l(e,`user_referred_started`,{referrer_client_id:t.c,referrer_wallet:t.w,wallet_status:n?.key}),v(e,{type:`arrival`,referrerClientId:t.c,referrerMerchantId:t.m,referrerWallet:t.w,referralTimestamp:t.t}),!0):i(t)?(l(e,`user_referred_started`,{referrer:t.r,wallet_status:n?.key}),v(e,{type:`arrival`,referrerWallet:t.r}),!0):!1}function b(t,n){let r=e();return!r&&!n?null:{v:2,m:t,t:Math.floor(Date.now()/1e3),...r?{c:r}:{},...n?{w:n}:{}}}function x(t,n){return c(t)?t.w&&n?.wallet?r(t.w,n.wallet):t.c?e()===t.c:!1:i(t)&&n?.wallet?r(t.r,n.wallet):!1}function S(e,{walletStatus:t,frakContext:n,options:r}){if(!n)return`no-referrer`;if(x(n,t))return`self-referral`;if(!y(e,n,t))return`no-referrer`;let i=c(n)?n.m:r?.merchantId,a=r?.alwaysAppendUrl&&i?b(i,t?.wallet):null;return s.replaceUrl({url:window.location?.href,context:a}),l(e,`user_referred_completed`,{status:`success`}),`success`}async function C(e,{options:t}={}){let n=s.parse({url:window.location.href}),r=await D(e);try{return S(e,{walletStatus:r,frakContext:n,options:t})}catch{}}const w=`frak:referral-success`;async function T(e){try{await C(e)===`success`&&window.dispatchEvent(new Event(w))}catch{}}async function E(t){if(typeof window>`u`)return;let r=window.sessionStorage.getItem(`frak-wallet-interaction-token`),i=e();if(!r&&!i)return;let a=t.merchantId??await o.resolveMerchantId();if(!a)return;let s={Accept:`application/json`,"Content-Type":`application/json`};r&&(s[`x-wallet-sdk-auth`]=r),i&&(s[`x-frak-client-id`]=i);let c=n();await fetch(`${c}/user/track/purchase`,{method:`POST`,headers:s,body:JSON.stringify({customerId:t.customerId,orderId:t.orderId,token:t.token,merchantId:a})})}function D(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(O(e,t),t));let n=new a,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{O(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function O(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),p(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function k(e,{metadata:t,login:n}){return A(e,{steps:{login:n??{}},metadata:t})}function A(e,t){function n(n){return A(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return A(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return A(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function a(n,r){return n&&(t.metadata=n(t.metadata??{})),await d(e,t,r)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function j(e,{tx:t,metadata:n}){return(await d(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function M(e=96){let t=Math.ceil(e/2),n=``;if(typeof crypto<`u`&&crypto.getRandomValues){let e=new Uint8Array(t);crypto.getRandomValues(e);for(let t=0;t<e.length;t++)n+=e[t].toString(16).padStart(2,`0`)}else for(let e=0;e<t;e++)n+=(Math.random()*256|0).toString(16).padStart(2,`0`);return n.substring(0,e)}async function N(e,{siwe:t,metadata:n}){let r=e.config?.domain??window.location.host,i=t?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`;return(await d(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??M(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}export{v as _,S as a,d as c,h as d,j as f,u as g,p as h,N as i,f as l,m,D as n,T as o,k as p,E as r,_ as s,C as t,g as u,w as v};