@frak-labs/components 1.0.8 → 1.0.10-beta.727c2f3f

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 (38) hide show
  1. package/cdn/Banner.De5nN3cX.js +167 -0
  2. package/cdn/{ButtonShare.D9-F0jJJ.js → ButtonShare.Bu3FfiV5.js} +1 -1
  3. package/cdn/{ButtonWallet.B0buPR_z.js → ButtonWallet.nvTBXwL2.js} +1 -1
  4. package/cdn/{GiftIcon.eRNTGQ_r.js → GiftIcon.DnSW4dJQ.js} +1 -1
  5. package/cdn/{OpenInAppButton.Dgb-qhM8.js → OpenInAppButton.CpO_E-l-.js} +1 -1
  6. package/cdn/PostPurchase.BhzdyhpA.js +89 -0
  7. package/cdn/components.js +1 -1
  8. package/cdn/embeddedWallet.CDUxjdX2.js +1 -0
  9. package/cdn/formatReward.DNFkBh_E.js +1 -0
  10. package/cdn/loader.js +1 -1
  11. package/cdn/replay-V6FXES7X.CNozpSRg.js +1 -0
  12. package/cdn/{useGlobalComponents.TG9kIYSc.js → useGlobalComponents.pjgSwLk9.js} +1 -1
  13. package/cdn/{useLightDomStyles.tjNBKcOr.js → useLightDomStyles.2RQE6Iby.js} +1 -1
  14. package/cdn/usePlacement.CRfzWKVY.js +58 -0
  15. package/cdn/useReward.DSMOMYCh.js +1 -0
  16. package/dist/{GiftIcon-BIp9FTJs.js → GiftIcon-WEWSJ8kV.js} +1 -1
  17. package/dist/banner.d.ts +1 -2
  18. package/dist/banner.js +63 -69
  19. package/dist/buttonShare.d.ts +1 -2
  20. package/dist/buttonShare.js +4 -4
  21. package/dist/buttonWallet.d.ts +1 -2
  22. package/dist/buttonWallet.js +2 -2
  23. package/dist/{formatReward-Cf2KpA3x.js → formatReward-D3CkH7It.js} +8 -2
  24. package/dist/openInApp.d.ts +1 -3
  25. package/dist/openInApp.js +2 -2
  26. package/dist/postPurchase.d.ts +1 -2
  27. package/dist/postPurchase.js +6 -5
  28. package/dist/{useLightDomStyles-C8giLInY.js → useLightDomStyles-DPKMhggr.js} +1 -1
  29. package/dist/{usePlacement-5kbU3BKj.js → usePlacement-DTN6H6vW.js} +68 -10
  30. package/dist/{useReward-ClVShg45.js → useReward-DSrQsn3r.js} +2 -2
  31. package/package.json +3 -3
  32. package/cdn/Banner.CcOWT4lZ.js +0 -178
  33. package/cdn/PostPurchase.BYxnAEyn.js +0 -89
  34. package/cdn/embeddedWallet.BS-9u4Be.js +0 -1
  35. package/cdn/formatReward.B1ZyoceC.js +0 -1
  36. package/cdn/replay-V6FXES7X.BoL9fAjx.js +0 -1
  37. package/cdn/usePlacement.BgMXY5CX.js +0 -58
  38. package/cdn/useReward.BtBpuMwt.js +0 -1
@@ -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, sdkConfigStore, setupClient, trackEvent, withCache } from "@frak-labs/core-sdk";
3
+ import { decompressJsonFromB64, deleteQueryParamCaseInsensitive, 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 { useEffect, useMemo, useState } from "preact/hooks";
@@ -17,6 +17,43 @@ async function openSharingPage(targetInteraction, placement, options) {
17
17
  }, placement);
18
18
  }
19
19
  //#endregion
20
+ //#region src/utils/dom/detectListenerPreloads.ts
21
+ /**
22
+ * Tags that count as "Frak components" for the purpose of preload detection.
23
+ *
24
+ * Kept in sync with the registry in `bootstrap/loader.ts#COMPONENTS_MAP` —
25
+ * any new public custom element should be added here too so the iframe
26
+ * preload hash reflects the user's actual page surface.
27
+ */
28
+ const FRAK_COMPONENT_SELECTOR = [
29
+ "frak-button-share",
30
+ "frak-button-wallet",
31
+ "frak-open-in-app",
32
+ "frak-post-purchase",
33
+ "frak-banner"
34
+ ].join(",");
35
+ /**
36
+ * Dynamically compute the iframe preload list based on which Frak components
37
+ * are present in the current document.
38
+ *
39
+ * Behaviour:
40
+ * - No `frak-*` element on the page → `[]` (caller should skip the
41
+ * `#preload=...` hash entirely so the listener doesn't warm chunks no one
42
+ * will use).
43
+ * - At least one `frak-*` element → `["sharing"]`. Every public component
44
+ * eventually opens the sharing flow (directly via `<frak-button-share>` or
45
+ * indirectly via wallet/post-purchase/banner CTAs), so a single hint
46
+ * covers the whole surface without bloating the iframe URL.
47
+ *
48
+ * Called once during {@link initFrakSdk}, before {@link setupClient} creates
49
+ * the iframe. Dynamically-mounted components (added after init) still work —
50
+ * the listener loads handlers on demand — they just skip the warm-up.
51
+ */
52
+ function detectListenerPreloads() {
53
+ if (typeof document === "undefined") return [];
54
+ return document.querySelector(FRAK_COMPONENT_SELECTOR) !== null ? ["sharing"] : [];
55
+ }
56
+ //#endregion
20
57
  //#region src/utils/sharingPageProducts.ts
21
58
  /**
22
59
  * Whether `value` is a syntactically valid URL with an `http(s):` scheme.
@@ -176,7 +213,7 @@ function initFrakSdk() {
176
213
  async function doInit() {
177
214
  if (!window.FrakSetup?.config) throw new Error("[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.");
178
215
  console.log("[Frak SDK] Starting initialization");
179
- const client = await setupClient({ config: window.FrakSetup.config });
216
+ const client = await setupClient({ config: withDynamicPreload(window.FrakSetup.config) });
180
217
  if (!client) throw new Error("[Frak SDK] Failed to create client");
181
218
  window.FrakSetup.client = client;
182
219
  console.log("[Frak SDK] Client initialized successfully");
@@ -185,6 +222,23 @@ async function doInit() {
185
222
  handleActionQueryParam();
186
223
  }
187
224
  /**
225
+ * Inject a dynamically-computed `preload` list when the caller hasn't set
226
+ * one explicitly.
227
+ *
228
+ * Rationale: the listener iframe warms Ring 1/Ring 2 chunks based on the
229
+ * `#preload=...` hash. The components CDN entry can detect which Frak
230
+ * components are actually on the page and avoid the warm-up cost when none
231
+ * are mounted. An explicit `config.preload` (including `[]`) is respected
232
+ * as an escape hatch.
233
+ */
234
+ function withDynamicPreload(config) {
235
+ if (config.preload !== void 0) return config;
236
+ return {
237
+ ...config,
238
+ preload: detectListenerPreloads()
239
+ };
240
+ }
241
+ /**
188
242
  * Check the query param for an auto-opening of the Frak sharing page.
189
243
  *
190
244
  * Supported params (all optional except `frakAction`):
@@ -203,18 +257,22 @@ async function doInit() {
203
257
  * soon as they are read, so refreshes / shares of the current URL do not
204
258
  * re-trigger the auto-open. Matches the `fmt` (merge token) and `sso`
205
259
  * cleanup patterns elsewhere in the SDK.
260
+ *
261
+ * Param keys and the `frakAction` keyword value are matched case-insensitively
262
+ * because some email tools and browsers lowercase the whole URL in transit
263
+ * (e.g. `?FrakAction=Share` → `?frakaction=share`).
206
264
  */
207
265
  function handleActionQueryParam() {
208
266
  const url = new URL(window.location.href);
209
- if (url.searchParams.get("frakAction") !== "share") return;
267
+ if (getQueryParamCaseInsensitive(url.searchParams, "frakAction")?.toLowerCase() !== "share") return;
210
268
  console.log("[Frak SDK] Auto open share via query param");
211
- const link = url.searchParams.get("link") ?? void 0;
212
- const placement = url.searchParams.get("placement") ?? void 0;
213
- const products = decodeProductsParam(url.searchParams.get("products"));
214
- url.searchParams.delete("frakAction");
215
- url.searchParams.delete("link");
216
- url.searchParams.delete("placement");
217
- url.searchParams.delete("products");
269
+ const link = getQueryParamCaseInsensitive(url.searchParams, "link") ?? void 0;
270
+ const placement = getQueryParamCaseInsensitive(url.searchParams, "placement") ?? void 0;
271
+ const products = decodeProductsParam(getQueryParamCaseInsensitive(url.searchParams, "products"));
272
+ deleteQueryParamCaseInsensitive(url.searchParams, "frakAction");
273
+ deleteQueryParamCaseInsensitive(url.searchParams, "link");
274
+ deleteQueryParamCaseInsensitive(url.searchParams, "placement");
275
+ deleteQueryParamCaseInsensitive(url.searchParams, "products");
218
276
  window.history.replaceState({}, "", url.toString());
219
277
  openSharingPage(void 0, placement, {
220
278
  link,
@@ -1,4 +1,4 @@
1
- import { n as formatEstimatedReward } from "./formatReward-Cf2KpA3x.js";
1
+ import { n as formatEstimatedReward } from "./formatReward-D3CkH7It.js";
2
2
  import { getCurrencyAmountKey, getSupportedCurrency } from "@frak-labs/core-sdk";
3
3
  import { getMerchantInformation } from "@frak-labs/core-sdk/actions";
4
4
  import { useEffect, useState } from "preact/hooks";
@@ -9,7 +9,7 @@ import { useEffect, useState } from "preact/hooks";
9
9
  function getRewardValue(reward, key) {
10
10
  switch (reward.payoutType) {
11
11
  case "fixed": return reward.amount[key];
12
- case "tiered": return reward.tiers.reduce((acc, tier) => Math.max(acc, tier.amount[key]), 0);
12
+ case "tiered": return reward.tiers.reduce((acc, tier) => "amount" in tier ? Math.max(acc, tier.amount[key]) : acc, 0);
13
13
  case "percentage": return 0;
14
14
  }
15
15
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": "https://twitter.com/QNivelais"
12
12
  }
13
13
  ],
14
- "version": "1.0.8",
14
+ "version": "1.0.10-beta.727c2f3f",
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",
@@ -86,8 +86,8 @@
86
86
  "publish": "echo 'Publishing components...'"
87
87
  },
88
88
  "dependencies": {
89
- "@frak-labs/core-sdk": "1.1.3",
90
- "@frak-labs/frame-connector": "0.2.0",
89
+ "@frak-labs/core-sdk": "1.1.5-beta.727c2f3f",
90
+ "@frak-labs/frame-connector": "0.2.0-beta.727c2f3f",
91
91
  "preact": "^10.29.0",
92
92
  "preact-custom-element": "^4.6.0",
93
93
  "@frak-labs/design-system": "0.0.0"
@@ -1,178 +0,0 @@
1
- import{T as e,b as t,d as n,s as r,u as i,v as a}from"./loader.js";import{a as o,c as s,d as c,i as l,l as u,o as d,s as f,t as ee,u as p}from"./usePlacement.BgMXY5CX.js";import{a as m,i as h,n as g,r as te,t as _}from"./GiftIcon.eRNTGQ_r.js";import{t as v}from"./useGlobalComponents.TG9kIYSc.js";import{t as ne}from"./useLightDomStyles.tjNBKcOr.js";import{t as re}from"./useReward.BtBpuMwt.js";var y=`inAppBanner_body__1ibpiy75`,b=`inAppBanner_closeButton__1ibpiy78`,x=`inAppBanner_container__1ibpiy71`,S=`inAppBanner_cta__1ibpiy77`,C=`inAppBanner_description__1ibpiy76`,w=`inAppBanner_header__1ibpiy72`,T=`inAppBanner_iconWrapper__1ibpiy73`,E=`inAppBanner_title__1ibpiy74`;function D({title:e,description:t,cta:n,dismissLabel:r,onAction:i,onDismiss:a,className:o,classNames:s}){return p(`div`,{className:`${x}${o?` ${o}`:``}`,role:`alert`,children:[p(`div`,{className:w,children:[p(`span`,{className:`${T}${s?.icon?` ${s.icon}`:``}`,children:p(g,{width:20,height:20})}),p(`p`,{className:`${E}${s?.title?` ${s.title}`:``}`,children:e})]}),p(`div`,{className:y,children:[p(`p`,{className:`${C}${s?.description?` ${s.description}`:``}`,children:t}),p(`button`,{type:`button`,className:`${S}${s?.cta?` ${s.cta}`:``}`,onClick:i,children:[n,p(h,{width:14,height:14})]})]}),p(`button`,{type:`button`,className:`${b}${s?.close?` ${s.close}`:``}`,onClick:a,"aria-label":r,children:p(m,{width:16,height:16})})]})}var O=`Banner_frakLogo__1gnumzia`,k=`Banner_iconSvg__1gnumzi2`,A=`Banner_referral__1gnumzi3 reset_base__1831jhd0 Banner_rootBase__1gnumzi1`,j=`Banner_referralBody__1gnumzi6`,M=`Banner_referralCta__1gnumzi9 sharedBaseCss_buttonReset__7cswil0`,ie=`Banner_referralDescription__1gnumzi8 reset_base__1831jhd0`,ae=`Banner_referralIconWrapper__1gnumzi4`,N=`Banner_referralImage__1gnumzi5`,P=`Banner_referralTitle__1gnumzi7 reset_base__1831jhd0`;function F({placement:c,classname:m=``,interaction:h,referralTitle:g,referralDescription:y,referralCta:b,inappTitle:x,inappDescription:S,inappCta:C,imageUrl:w,preview:T,previewMode:E,allowInappRedirect:F}){let I=!!T,L=E===`inapp`?`inapp`:`referral`,R=F===!0||F===`true`,z=ee(c),{shouldRender:B,isHidden:V,isClientReady:H}=l();ne(`frak-banner`,c,z?.components?.banner?.css,`@keyframes inAppBanner_fadeIn__1ibpiy70 {
2
- from {
3
- opacity: 0;
4
- transform: translateY(-4px);
5
- }
6
- to {
7
- opacity: 1;
8
- transform: translateY(0);
9
- }
10
- }
11
- .inAppBanner_container__1ibpiy71 {
12
- position: fixed;
13
- top: max(8px, env(safe-area-inset-top));
14
- left: 16px;
15
- right: 16px;
16
- z-index: 1000;
17
- display: flex;
18
- flex-direction: column;
19
- gap: 4px;
20
- padding: 12px 16px;
21
- padding-right: 32px;
22
- border-radius: 12px;
23
- background-color: #000000CC;
24
- backdrop-filter: blur(12px);
25
- -webkit-backdrop-filter: blur(12px);
26
- color: #ffffff;
27
- animation: inAppBanner_fadeIn__1ibpiy70 300ms ease-out;
28
- }
29
- .inAppBanner_header__1ibpiy72 {
30
- display: flex;
31
- align-items: center;
32
- gap: 8px;
33
- }
34
- .inAppBanner_iconWrapper__1ibpiy73 {
35
- flex-shrink: 0;
36
- width: 20px;
37
- height: 20px;
38
- display: flex;
39
- align-items: center;
40
- justify-content: center;
41
- color: #ffffff;
42
- }
43
- .inAppBanner_title__1ibpiy74 {
44
- margin: 0;
45
- padding: 0;
46
- font-size: 16px;
47
- font-weight: 500;
48
- line-height: 26px;
49
- color: var(--text-onAction__pbq4ak6);
50
- }
51
- .inAppBanner_body__1ibpiy75 {
52
- display: flex;
53
- flex-wrap: wrap;
54
- align-items: baseline;
55
- gap: 0 4px;
56
- }
57
- .inAppBanner_description__1ibpiy76 {
58
- margin: 0;
59
- padding: 0;
60
- font-size: 14px;
61
- color: var(--text-onAction__pbq4ak6);
62
- line-height: 22px;
63
- opacity: 0.96;
64
- }
65
- .inAppBanner_cta__1ibpiy77 {
66
- all: unset;
67
- display: inline-flex;
68
- align-items: center;
69
- gap: 4px;
70
- color: #2BB2FF;
71
- font-size: 14px;
72
- font-weight: 600;
73
- text-decoration: underline;
74
- text-underline-offset: 2px;
75
- cursor: pointer;
76
- }
77
- .inAppBanner_cta__1ibpiy77:focus-visible {
78
- outline: 2px solid #2BB2FF;
79
- outline-offset: 2px;
80
- border-radius: 4px;
81
- }
82
- .inAppBanner_closeButton__1ibpiy78 {
83
- all: unset;
84
- position: absolute;
85
- top: 8px;
86
- right: 8px;
87
- width: 28px;
88
- height: 28px;
89
- display: flex;
90
- align-items: center;
91
- justify-content: center;
92
- border-radius: 9999px;
93
- color: rgba(255, 255, 255, 0.6);
94
- cursor: pointer;
95
- }
96
- .inAppBanner_closeButton__1ibpiy78:focus-visible {
97
- outline: 2px solid #ffffff;
98
- outline-offset: 2px;
99
- }@keyframes Banner_fadeIn__1gnumzi0 {
100
- from {
101
- opacity: 0;
102
- transform: translateY(-4px);
103
- }
104
- to {
105
- opacity: 1;
106
- transform: translateY(0);
107
- }
108
- }
109
- .Banner_rootBase__1gnumzi1 {
110
- position: relative;
111
- display: flex;
112
- animation: Banner_fadeIn__1gnumzi0 300ms ease-out;
113
- }
114
- .Banner_iconSvg__1gnumzi2 {
115
- width: 100%;
116
- height: 100%;
117
- }
118
- .Banner_referral__1gnumzi3 {
119
- flex-direction: row;
120
- align-items: center;
121
- gap: 16px;
122
- padding: 16px;
123
- background-color: #ffffff;
124
- color: var(--text-primary__pbq4ak0);
125
- border: 1px solid var(--border-default__pbq4akv);
126
- border-radius: 12px;
127
- }
128
- .Banner_referralIconWrapper__1gnumzi4 {
129
- flex-shrink: 0;
130
- align-self: flex-start;
131
- display: flex;
132
- align-items: center;
133
- justify-content: center;
134
- width: 40px;
135
- height: 40px;
136
- overflow: hidden;
137
- }
138
- .Banner_referralImage__1gnumzi5 {
139
- max-width: 100%;
140
- max-height: 100%;
141
- width: auto;
142
- height: auto;
143
- object-fit: contain;
144
- display: block;
145
- }
146
- .Banner_referralBody__1gnumzi6 {
147
- flex: 1;
148
- min-width: 0;
149
- }
150
- .Banner_referralTitle__1gnumzi7 {
151
- font-size: 16px;
152
- font-weight: 600;
153
- color: var(--text-primary__pbq4ak0);
154
- line-height: 22px;
155
- }
156
- .Banner_referralDescription__1gnumzi8 {
157
- margin-bottom: 8px;
158
- font-size: 14px;
159
- color: #979797;
160
- line-height: 22px;
161
- }
162
- .Banner_referralCta__1gnumzi9 {
163
- display: inline-block;
164
- padding: 8px 16px;
165
- border: 1px solid #000000;
166
- border-radius: 9999px;
167
- color: var(--text-primary__pbq4ak0);
168
- font-size: 10px;
169
- font-weight: 700;
170
- line-height: 12px;
171
- text-transform: uppercase;
172
- }
173
- .Banner_frakLogo__1gnumzia {
174
- position: absolute;
175
- right: 16px;
176
- bottom: 12px;
177
- pointer-events: none;
178
- }`,e);let[U,W]=f(!1),[G,K]=f(()=>I?L:R&&a?`inapp`:null),q=o(null);u(()=>{I&&K(L)},[I,L]);let{reward:J}=re(G===`referral`&&H,h),[Y,X]=f(null);u(()=>{let e=window.FrakSetup?.client;G!==`inapp`||I||!H||!e||r(e).then(e=>X(e)).catch(()=>{})},[G,I,H]),u(()=>{I||!G||U||q.current!==G&&H&&(t(window.FrakSetup?.client,`banner_impression`,{placement:c,variant:G,has_reward:G===`referral`?!!J:void 0}),q.current=G)},[G,U,H,I,c]),u(()=>{if(I||G===`inapp`)return;let e=()=>K(`referral`);return window.addEventListener(i,e),()=>window.removeEventListener(i,e)},[I,G]);let Z=s(async()=>{if(I)return;if(t(window.FrakSetup?.client,`banner_resolved`,{placement:c,variant:G??`referral`,outcome:`clicked`}),G===`referral`){W(!0);return}let e=Y;if(!e&&window.FrakSetup?.client)try{e=await r(window.FrakSetup?.client)}catch{}let i=window.location.href;if(e){let t=new URL(i);t.searchParams.set(`fmt`,e),i=t.toString()}n(i)},[I,G,Y,c]),oe=s(()=>{I||(t(window.FrakSetup?.client,`banner_resolved`,{placement:c,variant:G??`referral`,outcome:`dismissed`}),W(!0))},[I,G,c]),se=v(),Q=z?.components?.banner??se?.banner,$=d(()=>{if(G===`referral`){let e=J?`Earn ${J} on purchases on this site`:`You've been referred!`;return{title:g??Q?.referralTitle??e,description:y??Q?.referralDescription??`Earn rewards after your purchase via the Frak partner app.`,cta:b??Q?.referralCta??`Got it`}}return{title:x??Q?.inappTitle??`Open in your browser`,description:S??Q?.inappDescription??`For a better experience and to earn your rewards, open this page in your default browser.`,cta:C??Q?.inappCta??`Open browser`}},[G,J,Q,g,y,b,x,S,C]);if(!G||!I&&(!B||V||U))return null;let ce=[A,`frak-banner`,`frak-banner--${G}`,m].filter(Boolean).join(` `);return G===`inapp`?p(D,{title:$.title,description:$.description,cta:$.cta,dismissLabel:`Dismiss`,onAction:Z,onDismiss:oe,className:[`frak-banner`,`frak-banner--inapp`,m].filter(Boolean).join(` `),classNames:{icon:`frak-banner__icon`,title:`frak-banner__title`,description:`frak-banner__description`,cta:`frak-banner__cta`,close:`frak-banner__close`}}):p(`div`,{class:ce,role:`alert`,children:[p(`div`,{class:`${ae} frak-banner__icon`,children:w?p(`img`,{src:w,alt:``,class:N}):p(_,{class:k})}),p(`div`,{class:`${j} frak-banner__text`,children:[p(`p`,{class:`${P} frak-banner__title`,children:$.title}),p(`p`,{class:`${ie} frak-banner__description`,children:$.description}),p(`button`,{type:`button`,class:`${M} frak-banner__cta`,onClick:Z,children:$.cta})]}),p(te,{class:`${O} frak-banner__logo`,width:42,height:24})]})}c(F,`frak-banner`,[`placement`,`classname`,`interaction`,`referralTitle`,`referralDescription`,`referralCta`,`inappTitle`,`inappDescription`,`inappCta`,`preview`,`previewMode`,`imageUrl`,`allowInappRedirect`],{shadow:!1});export{F as Banner};
@@ -1,89 +0,0 @@
1
- import{S as e,T as t,a as n,b as r,c as i,i as a,o,r as ee,x as te}from"./loader.js";import{a as ne,c as s,d as c,i as l,l as u,o as d,s as f,t as p,u as m}from"./usePlacement.BgMXY5CX.js";import{r as h,t as g}from"./GiftIcon.eRNTGQ_r.js";import{t as re}from"./useGlobalComponents.TG9kIYSc.js";import{t as ie}from"./useLightDomStyles.tjNBKcOr.js";import{n as ae,t as _}from"./formatReward.B1ZyoceC.js";var v=`PostPurchase_card__5fv5lh0`,y=`PostPurchase_cardLayout__5fv5lh1`,b=`PostPurchase_cardLeft__5fv5lh2`,x=`PostPurchase_cardRight__5fv5lh3`,S=`PostPurchase_cta__5fv5lh6 sharedBaseCss_buttonReset__7cswil0`,oe=`PostPurchase_customImage__5fv5lha`,se=`PostPurchase_frakLogo__5fv5lhb`,ce=`PostPurchase_giftIcon__5fv5lh8`,le=`PostPurchase_icon__5fv5lh7`,ue=`PostPurchase_imageWrapper__5fv5lh9`,de=`PostPurchase_message__5fv5lh5`;function fe(e,t){let n=t.rewards.find(e=>e.interactionTypeKey===`purchase`&&(e.referrer||e.referee));if(!n)return null;let r=e?.isReferred&&n.referee?`referee`:`referrer`;return{variant:r,reward:r===`referee`?n.referee:n.referrer,merchantDomain:t.onChainMetadata.domain}}function C({customerId:c,orderId:C,token:w,sharingUrl:T,merchantId:E,placement:D,classname:O=``,variant:k,badgeText:A,referrerText:j,refereeText:M,ctaText:N,preview:P,previewVariant:F,products:I,imageUrl:L}){let R=!!P,{shouldRender:z,isHidden:B,isClientReady:V}=l(),H=p(D);ie(`frak-post-purchase`,D,H?.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
- }`,t);let[U,pe]=f(null),[W,G]=f(!1);u(()=>{R||!V||!c||!C||!w||n({customerId:c,orderId:C,token:w,merchantId:E}).catch(()=>{})},[R,V,c,C,w,E]),u(()=>{if(R||!V||W)return;let t=window.FrakSetup?.client;t&&Promise.all([o(t),i(t)]).then(([e,t])=>{G(!0),pe(fe(e,t))}).catch(t=>{if(t instanceof e&&t.code===te.configError){G(!0);return}})},[R,V,W]);let K=ne(null),q=k??U?.variant??(R?F??`referrer`:void 0),J=T??U?.merchantDomain,Y=d(()=>{if(!U?.reward)return;let e=window.FrakSetup?.client?.config?.metadata?.currency;return ae(U.reward,e)},[U?.reward]),me=re(),X=H?.components?.postPurchase??me?.postPurchase,Z=A??X?.badgeText,Q=d(()=>({message:q===`referee`?Y?_(M??X?.refereeText??`You just earned {REWARD}! Share with friends to earn even more.`,Y):M??X?.refereeNoRewardText??`You just earned a reward! Share with friends to earn even more.`:Y?_(j??X?.referrerText??`Earn {REWARD} by sharing this with your friends!`,Y):j??X?.referrerNoRewardText??`Share this with your friends and earn rewards!`,cta:Y?_(N??X?.ctaText??`Share & earn {REWARD}`,Y):N??X?.ctaNoRewardText??`Share & earn`}),[q,Y,X,j,M,N]);u(()=>{q&&K.current!==q&&(!R&&(!z||B||!V)||(r(window.FrakSetup?.client,`post_purchase_impression`,{placement:D,variant:q,has_reward:!!U?.reward}),K.current=q))},[q,z,B,V,R,D,U?.reward]);let $=d(()=>ee(I),[I]),he=s(()=>{q&&(r(window.FrakSetup?.client,`post_purchase_clicked`,{placement:D,variant:q}),a(void 0,D,{link:J,products:$}))},[q,D,J,$]);return!q||!R&&(!z||B||!U)?null:m(`div`,{className:[v,O].filter(Boolean).join(` `),children:m(`div`,{class:y,children:[m(`div`,{class:b,children:[Z&&m(`span`,{class:`PostPurchase_badge__5fv5lh4`,children:Z}),m(`p`,{class:de,children:Q.message}),m(`button`,{type:`button`,className:`${S} button`,disabled:!R&&!V,onClick:R?void 0:he,children:[Q.cta,m(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:`${le} button`,children:m(`path`,{d:`M13.8984 11.144C13.9864 11.052 14.1543 11.1114 14.1543 11.2388V11.644C14.1543 13.0509 12.6288 14.1918 10.7471 14.1919C8.86523 14.1919 7.33984 13.051 7.33984 11.644V11.2388C7.33984 11.1114 7.50675 11.052 7.59473 11.144C8.3452 11.9295 9.47906 12.4292 10.7471 12.4292C12.0149 12.4291 13.148 11.9293 13.8984 11.144ZM1.8457 9.64795C1.8457 9.51169 2.01094 9.44452 2.10254 9.54053C2.85304 10.3238 3.98586 10.8247 5.25293 10.8247C5.52246 10.8247 5.78608 10.8026 6.04102 10.7593C6.25744 10.7225 6.46582 10.8816 6.46582 11.1011V12.1704C6.46564 12.319 6.36769 12.4507 6.22266 12.4829C5.91535 12.5512 5.58981 12.5874 5.25293 12.5874C3.3711 12.5874 1.8457 11.4469 1.8457 10.0396V9.64795ZM10.7471 6.20654C12.6288 6.20666 14.1543 7.3475 14.1543 8.75439C14.1541 10.1612 12.6287 11.3012 10.7471 11.3013C8.86535 11.3013 7.34004 10.1612 7.33984 8.75439C7.33984 7.34743 8.86523 6.20654 10.7471 6.20654ZM1.8457 6.8501C1.84597 6.71385 2.01208 6.64848 2.10352 6.74365C2.85393 7.52827 3.98602 8.0278 5.25293 8.02783C5.52282 8.02783 5.78667 8.00448 6.04199 7.96143C6.258 7.92499 6.46582 8.08514 6.46582 8.3042V9.37256C6.46582 9.52127 6.36783 9.65378 6.22266 9.68604C5.91537 9.75429 5.58979 9.79053 5.25293 9.79053C3.3711 9.79048 1.8457 8.64863 1.8457 7.24268V6.8501ZM5.25293 1.80811C7.13481 1.80811 8.66016 2.94856 8.66016 4.35596C8.66008 5.76331 7.13476 6.90381 5.25293 6.90381C3.37115 6.90376 1.84578 5.76328 1.8457 4.35596C1.8457 2.94858 3.3711 1.80815 5.25293 1.80811Z`,fill:`currentColor`})})]})]}),m(`div`,{class:x,children:[L?m(`span`,{class:ue,children:m(`img`,{src:L,alt:``,class:oe})}):m(g,{className:ce,width:80,height:80}),m(h,{className:se,width:42,height:24})]})]})})}c(C,`frak-post-purchase`,[`customerId`,`orderId`,`token`,`sharingUrl`,`merchantId`,`placement`,`classname`,`variant`,`badgeText`,`referrerText`,`refereeText`,`ctaText`,`products`,`preview`,`previewVariant`,`imageUrl`],{shadow:!1});export{C as PostPurchase};
@@ -1 +0,0 @@
1
- import{l as e}from"./loader.js";async function t(t,n){if(!window.FrakSetup?.client)return;let r=window.FrakSetup?.modalWalletConfig??{};await e(window.FrakSetup.client,t?{...r,metadata:{...r.metadata,targetInteraction:t}}:r,n)}export{t};
@@ -1 +0,0 @@
1
- import{f as e,h as t,p as n}from"./loader.js";function r(r,i,a){let o=t(i),s=n(o);switch(r.payoutType){case`fixed`:return e(Math.round(r.amount[s]),o);case`percentage`:return a===void 0?`${r.percent} %`:e(Math.round(r.percent*a/100),o);case`tiered`:{let t=r.tiers.reduce((e,t)=>Math.max(e,t.amount[s]),0);return e(Math.round(t),o)}}}function i(e,t){return t?e.replace(`{REWARD}`,t):e.replace(`{REWARD}`,``)}export{r as n,i as t};
@@ -1 +0,0 @@
1
- function e(){return()=>{}}var t=null;function n(n,r){if(typeof document>`u`||typeof window>`u`)return;t&&t();let i=n.maxEventsPerChunk??200,a=n.flushIntervalMs??1e4,o=n.maxPayloadBytes??1048576,s=[],c=0,l=null;function u(e){if(s.length===0)return;let t=JSON.stringify(s);if(new TextEncoder().encode(t).length>o){if(s.length>1){let t=Math.floor(s.length/2),n=s.slice(0,t),r=s.slice(t),i=e&&n.some(e=>e.type===2);s=n,u(i),s=r,u(!1);return}s=[];return}let n=s[0].timestamp,i=s[s.length-1].timestamp;try{r({chunk_index:c,events_count:s.length,is_full_snapshot:e,started_at:new Date(n).toISOString(),ended_at:new Date(i).toISOString(),payload:t}),c+=1,s=[]}catch(e){throw e}}function d(e){let t=e||s.some(e=>e.type===2);s.length>=i?u(t):e&&s.length>0&&u(!0)}let f=n.maskAllText!==!1,p=n.unmaskTextSelector,m=e({emit(e,t){s.push(e),d(!!t)},checkoutEveryNms:a,maskAllInputs:n.maskAllInputs??!0,maskTextSelector:f?`*`:`[data-openpanel-replay-mask]`,maskTextFn:f&&p?(e,t)=>t?.closest(p)?e:e.replace(/\S/g,`*`):void 0,blockSelector:n.blockSelector??`[data-openpanel-replay-block]`,blockClass:n.blockClass,ignoreSelector:n.ignoreSelector});l=setInterval(()=>{s.length>0&&u(s.some(e=>e.type===2))},a);function h(){document.visibilityState===`hidden`&&s.length>0&&u(s.some(e=>e.type===2))}function g(){s.length>0&&u(s.some(e=>e.type===2))}document.addEventListener(`visibilitychange`,h),window.addEventListener(`pagehide`,g),t=()=>{s.length>0&&u(s.some(e=>e.type===2)),l&&=(clearInterval(l),null),document.removeEventListener(`visibilitychange`,h),window.removeEventListener(`pagehide`,g),m?.(),t=null}}function r(){t&&t()}export{n as startReplayRecorder,r as stopReplayRecorder};
@@ -1,58 +0,0 @@
1
- import{C as e,n as t,t as n,y as r}from"./loader.js";var i,a,o,s,c,l,u,d,f,p,m,h={},g=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,t){for(var n in t)e[n]=t[n];return e}function b(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function x(e,t,n){var r,a,o,s={};for(o in t)o==`key`?r=t[o]:o==`ref`?a=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?i.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return S(e,s,r,a,null)}function S(e,t,n,r,i){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++o,__i:-1,__u:0};return i==null&&a.vnode!=null&&a.vnode(s),s}function C(e){return e.children}function w(e,t){this.props=e,this.context=t}function T(e,t){if(t==null)return e.__?T(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?T(e):null}function E(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],o=y({},t);o.__v=t.__v+1,a.vnode&&a.vnode(o),F(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??T(t),!!(32&t.__u),i),o.__v=t.__v,o.__.__k[o.__i]=o,re(r,o,i),t.__e=t.__=null,o.__e!=n&&D(o)}}function D(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),D(e)}function O(e){(!e.__d&&(e.__d=!0)&&s.push(e)&&!k.__r++||c!=a.debounceRendering)&&((c=a.debounceRendering)||l)(k)}function k(){try{for(var e,t=1;s.length;)s.length>t&&s.sort(u),e=s.shift(),t=s.length,E(e)}finally{s.length=k.__r=0}}function ee(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,_,v,y,b=r&&r.__k||g,x=t.length;for(c=A(n,t,b,c,x),d=0;d<x;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&b[p.__i]||h,p.__i=d,v=F(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&L(f.ref,null,p),u.push(p.ref,p.__c||m,p)),_==null&&m!=null&&(_=m),(y=!!(4&p.__u))||f.__k===p.__k?c=j(p,c,e,y):typeof p.type==`function`&&v!==void 0?c=v:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=_,c}function A(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=S(null,o,null,null,null):v(o)?o=e.__k[a]=S(C,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=S(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=te(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=T(s)),oe(s,s));return r}function j(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=j(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=T(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function M(e,t){return t||=[],e==null||typeof e==`boolean`||(v(e)?e.some(function(e){M(e,t)}):t.push(e)),t}function te(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ne(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||_.test(t)?n:n+`px`}function N(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ne(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ne(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(d,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n.u=r.u:(n.u=f,e.addEventListener(t,a?m:p,a)):e.removeEventListener(t,a?m:p,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function P(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=f++;else if(t.t<n.u)return;return n(a.event?a.event(t):t)}}}function F(e,t,n,r,i,o,s,c,l,u){var d,f,p,m,h,_,x,S,T,E,D,O,k,A,j,M=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[c=t.__e=n.__e]),(d=a.__b)&&d(t);n:if(typeof M==`function`)try{if(S=t.props,T=M.prototype&&M.prototype.render,E=(d=M.contextType)&&r[d.__c],D=d?E?E.props.value:d.__:r,n.__c?x=(f=t.__c=n.__c).__=f.__E:(T?t.__c=f=new M(S,D):(t.__c=f=new w(S,D),f.constructor=M,f.render=se),E&&E.sub(f),f.state||={},f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),T&&f.__s==null&&(f.__s=f.state),T&&M.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=y({},f.__s)),y(f.__s,M.getDerivedStateFromProps(S,f.__s))),m=f.props,h=f.state,f.__v=t,p)T&&M.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),T&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(T&&M.getDerivedStateFromProps==null&&S!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(S,D),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(S,f.__s,D)){t.__v!=n.__v&&(f.props=S,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),g.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&s.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(S,f.__s,D),T&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,_)})}if(f.context=D,f.props=S,f.__P=e,f.__e=!1,O=a.__r,k=0,T)f.state=f.__s,f.__d=!1,O&&O(t),d=f.render(f.props,f.state,f.context),g.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,O&&O(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++k<25);f.state=f.__s,f.getChildContext!=null&&(r=y(y({},r),f.getChildContext())),T&&!p&&f.getSnapshotBeforeUpdate!=null&&(_=f.getSnapshotBeforeUpdate(m,h)),A=d!=null&&d.type===C&&d.key==null?ie(d.props.children):d,c=ee(e,v(A)?A:[A],t,n,r,i,o,s,c,l,u),f.base=t.__e,t.__u&=-161,f.__h.length&&s.push(f),x&&(f.__E=f.__=null)}catch(e){if(t.__v=null,l||o!=null)if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,t.__e=c}else{for(j=o.length;j--;)b(o[j]);I(t)}else t.__e=n.__e,t.__k=n.__k,e.then||I(t);a.__e(e,t,n)}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=ae(n.__e,t,n,r,i,o,s,l,u);return(d=a.diffed)&&d(t),128&t.__u?void 0:c}function I(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(I))}function re(e,t,n){for(var r=0;r<n.length;r++)L(n[r],n[++r],n[++r]);a.__c&&a.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){a.__e(e,t.__v)}})}function ie(e){return typeof e!=`object`||!e||e.__b>0?e:v(e)?e.map(ie):y({},e)}function ae(e,t,n,r,o,s,c,l,u){var d,f,p,m,g,_,y,x=n.props||h,S=t.props,C=t.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){e=g,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&=(a.__m&&a.__m(t,s),!1),s=null}if(C==null)x===S||l&&e.data==S||(e.data=S);else{if(s&&=i.call(e.childNodes),!l&&s!=null)for(x={},d=0;d<e.attributes.length;d++)x[(g=e.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||N(e,d,null,g,o);for(d in S)g=S[d],d==`children`?m=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?_=g:d==`checked`?y=g:l&&typeof g!=`function`||x[d]===g||N(e,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=``),ee(t.type==`template`?e.content:e,v(m)?m:[m],t,n,r,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:n.__k&&T(n,0),l,u),s!=null)for(d=s.length;d--;)b(s[d]);l||(d=`value`,C==`progress`&&_==null?e.removeAttribute(`value`):_!=null&&(_!==e[d]||C==`progress`&&!_||C==`option`&&_!=x[d])&&N(e,d,_,x[d],o),d=`checked`,y!=null&&y!=e[d]&&N(e,d,y,x[d],o))}return e}function L(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){a.__e(e,n)}}function oe(e,t,n){var r,i;if(a.unmount&&a.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||L(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){a.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&oe(r[i],t,n||typeof e.type!=`function`);n||b(e.__e),e.__c=e.__=e.__e=void 0}function se(e,t,n){return this.constructor(e,n)}function R(e,t,n){var r,o,s,c;t==document&&(t=document.documentElement),a.__&&a.__(e,t),o=(r=typeof n==`function`)?null:n&&n.__k||t.__k,s=[],c=[],F(t,e=(!r&&n||t).__k=x(C,null,[e]),o||h,h,t.namespaceURI,!r&&n?[n]:o?null:t.firstChild?i.call(t.childNodes):null,s,!r&&n?n:o?o.__e:t.firstChild,r,c),re(s,e,c)}function ce(e,t){R(e,t,ce)}function z(e,t,n){var r,a,o,s,c=y({},e.props);for(o in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)o==`key`?r=t[o]:o==`ref`?a=t[o]:c[o]=t[o]===void 0&&s!=null?s[o]:t[o];return arguments.length>2&&(c.children=arguments.length>3?i.call(arguments,2):n),S(e.type,c,r||e.key,a||e.ref,null)}i=g.slice,a={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},o=0,w.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=y({},this.state);typeof e==`function`&&(e=e(y({},n),this.props)),e&&y(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),O(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),O(this))},w.prototype.render=C,s=[],l=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,u=function(e,t){return e.__v.__b-t.__v.__b},k.__r=0,d=/(PointerCapture)$|Capture$/i,f=0,p=P(!1),m=P(!0);function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},B.apply(this,arguments)}function V(e,t){if(e==null)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(i[n]=e[n]);return i}var le=[`context`,`children`],ue=[`useFragment`];function de(e,t,n,r){function i(){var t,n=Reflect.construct(HTMLElement,[],i);return n._vdomComponent=e,r&&r.shadow?(n._root=n.attachShadow({mode:r.mode||`open`,serializable:(t=r.serializable)!=null&&t}),r.adoptedStyleSheets&&(n._root.adoptedStyleSheets=r.adoptedStyleSheets)):n._root=n,n}return(i.prototype=Object.create(HTMLElement.prototype)).constructor=i,i.prototype.connectedCallback=function(){pe.call(this,r)},i.prototype.attributeChangedCallback=me,i.prototype.disconnectedCallback=he,n=n||e.observedAttributes||Object.keys(e.propTypes||{}),i.observedAttributes=n,e.formAssociated&&(i.formAssociated=!0),n.forEach(function(e){Object.defineProperty(i.prototype,e,{get:function(){return this._vdom?this._vdom.props[e]:this._props[e]},set:function(t){this._vdom?this.attributeChangedCallback(e,null,t):(this._props||={},this._props[e]=t);var n=typeof t;t!=null&&n!==`string`&&n!==`boolean`&&n!==`number`||this.setAttribute(e,t)}})}),customElements.define(t||e.tagName||e.displayName||e.name,i),i}function fe(e){this.getChildContext=function(){return e.context};var t=e.children;return z(t,V(e,le))}function pe(e){var t=new CustomEvent(`_preact`,{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(t),this._vdom=x(fe,B({},this._props,{context:t.detail.context}),_e(this,this._vdomComponent,e)),(this.hasAttribute(`hydrate`)?ce:R)(this._vdom,this._root)}function H(e){return e.replace(/-(\w)/g,function(e,t){return t?t.toUpperCase():``})}function me(e,t,n){if(this._vdom){var r={};r[e]=n??=void 0,r[H(e)]=n,this._vdom=z(this._vdom,r),R(this._vdom,this._root)}}function he(){R(this._vdom=null,this._root)}function ge(e,t){var n=this,r=e.useFragment,i=V(e,ue);return x(r?C:`slot`,B({},i,{ref:function(e){e?(n.ref=e,n._listener||(n._listener=function(e){e.stopPropagation(),e.detail.context=t},e.addEventListener(`_preact`,n._listener))):n.ref.removeEventListener(`_preact`,n._listener)}}))}function _e(e,t,n){if(e.nodeType===3)return e.data;if(e.nodeType!==1)return null;var r=[],i={},a=0,o=e.attributes,s=e.childNodes;for(a=o.length;a--;)o[a].name!==`slot`&&(i[o[a].name]=o[a].value,i[H(o[a].name)]=o[a].value);for(a=s.length;a--;){var c=_e(s[a],null,n),l=s[a].slot;l?i[l]=x(ge,{name:l},c):r[a]=c}var u=!(!n||!n.shadow),d=t?x(ge,{useFragment:!u},r):r;return!u&&t&&(e.innerHTML=``),x(t||e.nodeName.toLowerCase(),i,d)}function ve(t,r,i=[],a={shadow:!0}){typeof window<`u`&&(e(n),customElements.get(r)||de(t,r,i,a))}var ye=0;Array.isArray;function be(e,t,n,r,i,o){t||={};var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ye,__i:-1,__u:0,__source:i,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return a.vnode&&a.vnode(u),u}var U,W,G,xe,K=0,Se=[],q=a,Ce=q.__b,we=q.__r,Te=q.diffed,Ee=q.__c,De=q.unmount,Oe=q.__;function J(e,t){q.__h&&q.__h(W,e,K||t),K=0;var n=W.__H||={__:[],__h:[]};return e>=n.__.length&&n.__.push({}),n.__[e]}function Y(e){return K=1,ke(Ie,e)}function ke(e,t,n){var r=J(U++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ie(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.some(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a&&a.call(this,e,t,n)||o};W.__f=!0;var a=W.shouldComponentUpdate,o=W.componentWillUpdate;W.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},W.shouldComponentUpdate=i}return r.__N||r.__}function X(e,t){var n=J(U++,3);!q.__s&&Fe(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function Ae(e){return K=5,Z(function(){return{current:e}},[])}function Z(e,t){var n=J(U++,7);return Fe(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function je(e,t){return K=8,Z(function(){return e},t)}function Me(){for(var e;e=Se.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Q),t.__h.some($),t.__h=[]}catch(n){t.__h=[],q.__e(n,e.__v)}}}q.__b=function(e){W=null,Ce&&Ce(e)},q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Oe&&Oe(e,t)},q.__r=function(e){we&&we(e),U=0;var t=(W=e.__c).__H;t&&(G===W?(t.__h=[],W.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Q),t.__h.some($),t.__h=[],U=0)),G=W},q.diffed=function(e){Te&&Te(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Se.push(t)!==1&&xe===q.requestAnimationFrame||((xe=q.requestAnimationFrame)||Pe)(Me)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),G=W=null},q.__c=function(e,t){t.some(function(e){try{e.__h.some(Q),e.__h=e.__h.filter(function(e){return!e.__||$(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],q.__e(n,e.__v)}}),Ee&&Ee(e,t)},q.unmount=function(e){De&&De(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Q(e)}catch(e){t=e}}),n.__H=void 0,t&&q.__e(t,n.__v))};var Ne=typeof requestAnimationFrame==`function`;function Pe(e){var t,n=function(){clearTimeout(r),Ne&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ne&&(t=requestAnimationFrame(n))}function Q(e){var t=W,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),W=t}function $(e){var t=W;e.__c=e.__(),W=t}function Fe(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ie(e,t){return typeof t==`function`?t(e):t}function Le(){let[e,n]=Y(()=>window.FrakSetup?.config?.waitForBackendConfig===!1?!0:r.isResolved),[i,a]=Y(()=>r.getConfig().hidden??!1),[o,s]=Y(()=>!!window.FrakSetup?.client);return X(()=>{let e=r.getConfig();e.isResolved&&(n(!0),a(e.hidden??!1)),window.FrakSetup?.client&&s(!0);let i=e=>{let t=e.detail;t.isResolved&&n(!0),a(t.hidden??!1)};window.addEventListener(`frak:config`,i);let o=()=>s(!0);return t(`add`,o),()=>{window.removeEventListener(`frak:config`,i),t(`remove`,o)}},[]),{shouldRender:e,isHidden:i,isClientReady:o}}const Re=`
2
- :host {
3
- display: contents;
4
- }
5
-
6
- :host([hidden]) {
7
- display: none;
8
- }
9
-
10
- .button:disabled {
11
- opacity: 0.7;
12
- cursor: default;
13
- }
14
-
15
- .button__fadeIn {
16
- animation: frak-fadeIn 300ms ease-in;
17
- }
18
-
19
- @keyframes frak-fadeIn {
20
- from {
21
- opacity: 0;
22
- }
23
-
24
- to {
25
- opacity: 1;
26
- }
27
- }
28
- `;function ze(e,t){return t?`${Re}\n${e}\n${t}`:`${Re}\n${e}`}const Be=`
29
- :where(frak-button-share, frak-open-in-app) {
30
- display: contents;
31
- }
32
-
33
- :where(frak-button-share .button, frak-open-in-app .button) {
34
- display: flex;
35
- align-items: center;
36
- justify-content: center;
37
- gap: 10px;
38
- }
39
-
40
- :where(frak-button-share .button:disabled, frak-open-in-app .button:disabled) {
41
- opacity: 0.7;
42
- cursor: default;
43
- }
44
-
45
- :where(frak-button-share .button__fadeIn, frak-open-in-app .button__fadeIn) {
46
- animation: frak-fadeIn 300ms ease-in;
47
- }
48
-
49
- @keyframes frak-fadeIn {
50
- from {
51
- opacity: 0;
52
- }
53
-
54
- to {
55
- opacity: 1;
56
- }
57
- }
58
- `;function Ve(e){return r.getConfig().placements?.[e]}function He(e){let[t,n]=Y(0);return X(()=>{let e=e=>{n(e=>e+1)};return window.addEventListener(`frak:config`,e),n(e=>e+1),()=>window.removeEventListener(`frak:config`,e)},[]),Z(()=>e?Ve(e):void 0,[e,t])}export{Ae as a,je as c,ve as d,M as f,w as g,a as h,Le as i,X as l,C as m,ze as n,Z as o,x as p,Be as r,Y as s,He as t,be as u};
@@ -1 +0,0 @@
1
- import{c as e,h as t,p as n}from"./loader.js";import{l as r,s as i}from"./usePlacement.BgMXY5CX.js";import{n as a}from"./formatReward.B1ZyoceC.js";function o(e,t){switch(e.payoutType){case`fixed`:return e.amount[t];case`tiered`:return e.tiers.reduce((e,n)=>Math.max(e,n.amount[t]),0);case`percentage`:return 0}}function s({rewards:e},r,i){let s=(i?e.filter(e=>e.interactionTypeKey===i):e).map(e=>e.referrer).filter(e=>e!==void 0);if(s.length===0)return;let c=n(t(r)),l=s[0],u=o(l,c);for(let e=1;e<s.length;e++){let t=o(s[e],c);t>u&&(l=s[e],u=t)}if(u<=0){let e=s.find(e=>e.payoutType===`percentage`);if(!e)return;l=e}return a(l,r)}function c(t,n){let[a,o]=i(void 0);return r(()=>{if(!t)return;let r=window.FrakSetup?.client;r&&e(r).then(e=>{let t=r.config.metadata?.currency,i=s(e,t,n);i&&o(i)}).catch(()=>{})},[t,n]),{reward:a}}export{c as t};