@frak-labs/components 1.0.5 → 1.0.6
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.
- package/cdn/{Banner.CIxY6tCU.js → Banner.CcOWT4lZ.js} +2 -2
- package/cdn/ButtonShare.C3yHDv8Z.js +1 -0
- package/cdn/ButtonWallet.B0buPR_z.js +40 -0
- package/cdn/PostPurchase.BYxnAEyn.js +89 -0
- package/cdn/components.js +1 -1
- package/cdn/embeddedWallet.BS-9u4Be.js +1 -0
- package/cdn/loader.js +1 -1
- package/cdn/useReward.BtBpuMwt.js +1 -0
- package/dist/banner.js +2 -2
- package/dist/buttonShare.js +3 -3
- package/dist/buttonWallet.js +17 -1
- package/dist/embeddedWallet-By3_p5Xc.js +18 -0
- package/dist/openInApp.js +2 -2
- package/dist/postPurchase.js +3 -74
- package/dist/{useLightDomStyles-DVe5UDg6.js → useLightDomStyles-C8giLInY.js} +1 -1
- package/dist/{usePlacement-DzEuVg_u.js → usePlacement-5kbU3BKj.js} +144 -30
- package/package.json +2 -2
- package/cdn/ButtonShare.elMtdxF3.js +0 -1
- package/cdn/ButtonWallet.BUUPX0gO.js +0 -40
- package/cdn/PostPurchase.Cy7-FrRh.js +0 -89
- package/cdn/sharingPage.BYsqcN9O.js +0 -1
- package/cdn/useReward.B530suzR.js +0 -1
- package/dist/sharingPage-D6fQEXV9.js +0 -15
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{T as e,b as t,
|
|
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
2
|
from {
|
|
3
3
|
opacity: 0;
|
|
4
4
|
transform: translateY(-4px);
|
|
@@ -175,4 +175,4 @@ import{T as e,b as t,c as n,d as r,u as i,v as a}from"./loader.js";import{a as o
|
|
|
175
175
|
right: 16px;
|
|
176
176
|
bottom: 12px;
|
|
177
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||
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as e,i as t}from"./loader.js";import{c as n,d as r,i,o as a,t as o,u as s}from"./usePlacement.BgMXY5CX.js";import{t as c}from"./useGlobalComponents.TG9kIYSc.js";import{t as l}from"./useLightDomStyles.tjNBKcOr.js";import{t as u}from"./formatReward.B1ZyoceC.js";import{t as d}from"./useReward.BtBpuMwt.js";import{t as f}from"./embeddedWallet.BS-9u4Be.js";function p({placement:r,text:p=`Share and earn!`,classname:m=``,useReward:h,noRewardText:g,targetInteraction:_,clickAction:v,preview:y}){let b=!!y,x=o(r),S=c(),C=x?.components?.buttonShare??S?.buttonShare;l(`frak-button-share`,r,C?.css);let w=a(()=>x?.targetInteraction===void 0?_:x.targetInteraction,[x?.targetInteraction,_]),T=C?.text??p,E=C?.noRewardText??g,D=a(()=>C?.useReward??h===!0,[C?.useReward,h]),O=a(()=>C?.clickAction??v??`sharing-page`,[C?.clickAction,v]),{shouldRender:k,isHidden:A,isClientReady:j}=i(),{reward:M}=d(D&&j,w),N=a(()=>D?M?T.includes(`{REWARD}`)?u(T,M):`${T} ${M}`:E??u(T,void 0):T,[D,T,E,M]),P=n(()=>{if(!b){if(e(window.FrakSetup.client,`share_button_clicked`,{placement:r,target_interaction:w,has_reward:!!M,click_action:O}),O===`embedded-wallet`){f(w,r);return}t(w,r)}},[b,O,w,r,M]);if(!b&&(!k||A))return null;let F=[`button`,`button__fadeIn`,m].filter(Boolean).join(` `);return s(`button`,{type:`button`,disabled:!b&&!j,class:F,onClick:P,children:N})}r(p,`frak-button-share`,[`text`,`placement`,`classname`,`clickAction`,`useReward`,`noRewardText`,`targetInteraction`,`preview`],{shadow:!1});export{p as ButtonShare};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import{d as e,i as t,l as n,m as r,n as i,o as a,s as o,t as s,u as c}from"./usePlacement.BgMXY5CX.js";import{t as l}from"./useReward.BtBpuMwt.js";import{t as u}from"./embeddedWallet.BS-9u4Be.js";function d(e){return c(`svg`,{fill:`none`,height:`1em`,viewBox:`0 0 28 28`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[c(`title`,{children:`Gift icon`}),c(`path`,{d:`m23.1427 13.9999v11.4285h-18.2857v-11.4285m9.1429 11.4285v-17.14282m0 0h-5.1429c-.75776 0-1.48448-.30102-2.0203-.83684s-.83684-1.26255-.83684-2.02031.30102-1.48448.83684-2.0203 1.26254-.83684 2.0203-.83684c4 0 5.1429 5.71429 5.1429 5.71429zm0 0h5.1428c.7578 0 1.4845-.30102 2.0203-.83684s.8369-1.26255.8369-2.02031-.3011-1.48448-.8369-2.0203-1.2625-.83684-2.0203-.83684c-4 0-5.1428 5.71429-5.1428 5.71429zm-11.42861 0h22.85711v5.71432h-22.85711z`,stroke:`#fff`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]})}function f(){`vibrate`in navigator&&navigator.vibrate(10)}function p(e,t){f(),u(e,t)}function m({placement:e,classname:u=``,useReward:f,targetInteraction:m}){let h=s(e),g=a(()=>h?.targetInteraction===void 0?m:h.targetInteraction,[h?.targetInteraction,m]),_=a(()=>f===!0,[f]),{shouldRender:v,isHidden:y,isClientReady:b}=t(),{reward:x}=l(_&&b,g),[S,C]=o(`right`);if(n(()=>{let e=h?.components?.buttonWallet?.position,t=window.FrakSetup?.modalWalletConfig?.metadata?.position;C(e??t??`right`)},[h?.components?.buttonWallet?.position]),!v||y)return null;let w=[`button`,`button__fadeIn`,S===`left`?`button__left`:`button__right`,u].filter(Boolean).join(` `);return c(r,{children:[c(`style`,{children:i(`
|
|
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
|
+
`,h?.components?.buttonWallet?.css)}),c(`button`,{type:`button`,"aria-label":`Open wallet`,part:`button`,disabled:!b,class:w,onClick:()=>{p(g,e)},children:[c(d,{}),x&&c(`span`,{class:`reward`,children:x})]})]})}e(m,`frak-button-wallet`,[`placement`,`classname`,`useReward`,`targetInteraction`],{shadow:!0});export{m as ButtonWallet};
|
|
@@ -0,0 +1,89 @@
|
|
|
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};
|
package/cdn/components.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import(`https://cdn.jsdelivr.net/npm/@frak-labs/components@latest/cdn/loader.js?v=
|
|
1
|
+
import(`https://cdn.jsdelivr.net/npm/@frak-labs/components@latest/cdn/loader.js?v=1779292046525`);
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
package/cdn/loader.js
CHANGED
|
@@ -151,4 +151,4 @@ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],en
|
|
|
151
151
|
}
|
|
152
152
|
.sharedBaseCss_buttonReset__7cswil0:focus-visible {
|
|
153
153
|
outline-color: currentColor;
|
|
154
|
-
}`;function r(e,t){let n=document.getElementById(e);if(n){n.textContent!==t&&(n.textContent=t);return}let r=document.createElement(`style`);r.id=e,r.textContent=t,document.head.appendChild(r)}function i(e,t){let n=`frak-base-${e}`;if(document.getElementById(n)||!t)return;let r=document.createElement(`style`);r.id=n,r.textContent=t,document.head.appendChild(r)}function a(e,t,n){r(`frak-placement-${e}-${t}`,n)}const o={injectBase:i,injectPlacement:a};function s(e){document.readyState===`complete`||document.readyState===`interactive`?setTimeout(e,1):document.addEventListener(`DOMContentLoaded`,e)}const c={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006,userRejected:-32007};var l=class extends Error{code;data;constructor(e,t,n){super(t),this.code=e,this.data=n}toJSON(){return{code:this.code,message:this.message,data:this.data}}},u=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}};function d(e){let{emittingTransport:t,listeningTransport:n,targetOrigin:r,middleware:i=[],lifecycleHandlers:a}=e,o=new Map;function s(e){return typeof e!=`object`||!e?!1:`clientLifecycle`in e||`iframeLifecycle`in e}function c(e){return typeof e!=`object`||!e?!1:`id`in e&&`topic`in e&&`data`in e}async function d(e){try{`clientLifecycle`in e&&a?.clientLifecycle?await a.clientLifecycle(e,{origin:r,source:null}):`iframeLifecycle`in e&&a?.iframeLifecycle&&await a.iframeLifecycle(e,{origin:r,source:null})}catch{}}async function f(e){let t={origin:r,source:null};for(let n of i)n.onRequest&&await n.onRequest(e,t);return e}async function p(e,t){let n={origin:r,source:null},a=t;for(let t of i)t.onResponse&&(a=await t.onResponse(e,a,n));return a}async function m(e){try{if(new URL(e.origin).origin.toLowerCase()!==new URL(r).origin.toLowerCase())return}catch{return}if(s(e.data)){await d(e.data);return}if(!c(e.data))return;let t;try{let n=e.data.data,r=n instanceof Uint8Array||ArrayBuffer.isView(n)?{result:n}:n;t=await p(e.data,r)}catch{return}let n=o.get(e.data.id);n&&n(t)}async function h(e){let n=e;try{n=await f(e)}catch(e){throw e}t.postMessage(n,r)}function g(e){t.postMessage(e,r)}function _(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}n.addEventListener(`message`,m);function v(e){let t=_(),n=new u;return o.set(t,e=>{e.error?n.reject(new l(e.error.code,e.error.message,e.error.data)):n.resolve(e.result),o.delete(t)}),h({id:t,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{o.delete(t),n.reject(e)}),n.promise}function y(e,t){let n=_();return o.set(n,e=>{e.error?o.delete(n):t(e.result)}),h({id:n,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{o.delete(n)}),()=>{o.delete(n)}}function b(){n.removeEventListener(`message`,m),o.clear()}return{request:v,listen:y,sendLifecycle:g,cleanup:b}}function f(e){return new TextEncoder().encode(JSON.stringify(e))}function p(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}const m=`frak-client-id`;function h(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function g(){if(typeof window>`u`||!window.localStorage)return h();let e=localStorage.getItem(m);return e||(e=h(),localStorage.setItem(m,e)),e}var _=class extends Map{maxSize;constructor(e){super(),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&(super.delete(e),super.set(e,t)),t}set(e,t){if(super.has(e)&&super.delete(e),super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=super.keys().next().value;e!==void 0&&super.delete(e)}return this}};const v=new _(1024),y=new _(1024),b=new _(1024);async function x(e,{cacheKey:t,cacheTime:n=3e4}){if(n>0){let e=y.get(t);if(e&&Date.now()-e.created<n)return e.data}let r=b.get(t);if(r&&Date.now()-r<1e3)throw Error(`Cache: ${t} recently failed, backing off`);let i=v.get(t);i||(i=e(),v.set(t,i));try{let e=await i;return y.set(t,{data:e,created:Date.now()}),b.delete(t),e}catch(e){throw b.set(t,Date.now()),e}finally{v.delete(t)}}function S(){v.clear(),y.clear(),b.clear()}const C=`https://backend.frak.id`;function ee(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function te(e){return ee(e)?`https://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:C}function w(e){if(e)return te(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return te(e)}return C}const T=`__frakSdkConfig`,ne=`frak-config-cache`,E=`frak-merchant-id`,D={key:ne},O=typeof window<`u`;function k(){return{isResolved:!1,merchantId:``}}let A=null;function re(){if(!O)return null;try{let e=localStorage.getItem(D.key);if(!e)return null;let t=JSON.parse(e);return t.config?.isResolved?(A=t,t):null}catch{return null}}function ie(){return(A??re())?.config}function ae(){let e=A??re();return e?Date.now()-e.timestamp<3e4:!1}function oe(e){if(!(!O||!e.isResolved))try{let t={config:e,timestamp:Date.now()};localStorage.setItem(D.key,JSON.stringify(t)),A=t}catch{}}function se(){if(O){A=null;try{localStorage.removeItem(D.key)}catch{}}}function ce(){O&&(window[T]||(window[T]=ie()??k()))}ce();function j(){return O?window[T]??k():k()}function le(e){O&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function ue(e){return e??(O?window.location.hostname:``)}async function de(e,t,n){try{let r=w(t),i=n?`&lang=${encodeURIComponent(n)}`:``,a=await fetch(`${r}/user/merchant/resolve?domain=${encodeURIComponent(e)}${i}`);if(!a.ok)return;let o=await a.json();if(O)try{sessionStorage.setItem(E,o.merchantId)}catch{}return o}catch{return}}const M={getConfig:j,get isResolved(){return j().isResolved},get isCacheFresh(){return ae()},setCacheScope(e,t){D.key=`${ne}:${`${e}:${t??``}`}`,A=null},setConfig(e){if(O&&(window[T]=e),oe(e),le(e),O&&e.merchantId)try{sessionStorage.setItem(E,e.merchantId)}catch{}},reset(){let e=ie()??k();O&&(window[T]=e),le(e)},clearCache(){if(se(),S(),O)try{sessionStorage.removeItem(E)}catch{}},resolve(e,t,n){let r=ue(e);return r?x(async()=>{let e=await de(r,t,n);if(!e)throw Error(`Config resolution returned empty`);return e},{cacheKey:`sdkConfig:${r}:${n??``}`,cacheTime:1/0}).catch(()=>void 0):Promise.resolve(void 0)},getMerchantId(){let e=j();if(e.isResolved&&e.merchantId)return e.merchantId;if(O)try{return sessionStorage.getItem(E)??void 0}catch{}},async resolveMerchantId(e,t){return M.getMerchantId()||(await M.resolve(e,t))?.merchantId}};function N(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function P(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function fe(e){return N(f(e))}function pe(e,t,n,r,i,a){let o=fe(me({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:a,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:i})),s=new URL(e);return s.pathname=`/sso`,s.searchParams.set(`p`,o),s.toString()}function me(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const he=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,ge=`frak-sso`;async function _e(e,t){let{metadata:n,customizations:r,walletUrl:i}=e.config;if(t.openInSameWindow??!!t.redirectUrl)return await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]});let a=t.ssoPopupUrl??pe(i??`https://wallet.frak.id`,t,await M.resolveMerchantId()??``,n.name,g(),r?.css),o=window.open(a,ge,he);if(!o)throw Error(`Popup was blocked. Please allow popups for this site.`);return o.focus(),await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]})??{}}function F(e,t,n){if(e)try{e.openPanel?.track(t,n)}catch{}}const ve=/^0x[a-fA-F0-9]{40}$/;function I(e){return typeof e==`string`&&ve.test(e)}function ye(e,t){return e.toLowerCase()===t.toLowerCase()}function be(e){let t=new Uint8Array(20);for(let n=0;n<20;n++){let r=Number.parseInt(e.substring(2+n*2,4+n*2),16);if(Number.isNaN(r))throw Error(`Invalid address: ${e}`);t[n]=r}return t}const xe=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Se(e){let t=`0x`;for(let n=0;n<20;n++)t+=xe[e[n]];return t}function Ce(e){return`r`in e&&!(`v`in e)}function L(e){return`v`in e&&e.v===2}const we=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Te(e){return typeof e==`string`&&we.test(e)}function Ee(e){let t=e.replace(/-/g,``),n=new Uint8Array(16);for(let e=0;e<16;e++)n[e]=Number.parseInt(t.substring(e*2,e*2+2),16);return n}function De(e){let t=``;for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,`0`);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20,32)}`}function Oe(e){if(!Te(e.m)||!Number.isInteger(e.t)||e.t<0||e.t>4294967295)return null;let t=typeof e.c==`string`&&e.c.length>0,n=typeof e.w==`string`&&I(e.w);if(!t&&!n||t&&!Te(e.c))return null;let r=new Uint8Array(21+(t?16:0)+(n?20:0)),i=new DataView(r.buffer,r.byteOffset,r.byteLength),a=0;return r[a++]=2|(t?16:0)|(n?32:0),r.set(Ee(e.m),a),a+=16,i.setUint32(a,e.t,!1),a+=4,t&&(r.set(Ee(e.c),a),a+=16),n&&(r.set(be(e.w),a),a+=20),r}function ke(e){if(e.length<21)return null;let t=e[0];if((t&15)!=2||t&192)return null;let n=(t&16)!=0,r=(t&32)!=0;if(!n&&!r)return null;let i=21+(n?16:0)+(r?20:0);if(e.length!==i)return null;let a=1,o=De(e.subarray(a,a+16));a+=16;let s=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(a,!1);a+=4;let c={v:2,m:o,t:s};if(n&&(c.c=De(e.subarray(a,a+16)),a+=16),r){let t=Se(e.subarray(a,a+20));if(!I(t))return null;c.w=t,a+=20}return c}const R=`fCtx`;function z(e){if(e)try{if(L(e)){let t=Oe(e);return t?N(t):void 0}return N(be(e.r))}catch{}}function Ae(e){if(!(!e||e.length===0))try{let t=P(e);if(t.length!==20)return ke(t)||void 0;let n=Se(t);if(I(n))return{r:n}}catch{}}function je({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(R);return t?Ae(t):null}const Me=`frak`;function Ne(e,t){let n=L(e);return{utm_source:t.utmSource??Me,utm_medium:t.utmMedium??`referral`,utm_campaign:t.utmCampaign??(n?e.m:void 0),utm_content:t.utmContent,utm_term:t.utmTerm,via:t.via??Me,ref:t.ref??(n?e.c:void 0)}}function Pe(e,t,n){let r=Ne(t,n??{});for(let[t,n]of Object.entries(r))n===void 0||n===``||e.searchParams.has(t)||e.searchParams.set(t,n)}function Fe({url:e,context:t,attribution:n}){if(!e)return null;let r=z(t);if(!r)return null;let i=new URL(e);return i.searchParams.set(R,r),Pe(i,t,n),i.toString()}function Ie(e){let t=new URL(e);return t.searchParams.delete(R),t.toString()}function Le({url:e,context:t}){if(!window.location?.href||typeof window>`u`)return;let n=e??window.location.href,r;r=t===null?Ie(n):Fe({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const B={compress:z,decompress:Ae,parse:je,update:Fe,remove:Ie,replaceUrl:Le};var Re=class{constructor(e){this.baseUrl=e.baseUrl,this.headers={"Content-Type":`application/json`,...e.defaultHeaders},this.maxRetries=e.maxRetries??3,this.initialRetryDelay=e.initialRetryDelay??500}async resolveHeaders(){let e={};for(let[t,n]of Object.entries(this.headers)){let r=await n;r!==null&&(e[t]=r)}return e}addHeader(e,t){this.headers[e]=t}async post(e,t,n,r){try{let r=await fetch(e,{method:`POST`,headers:await this.resolveHeaders(),body:t?JSON.stringify(t??{}):void 0,keepalive:!0,...n});if(r.status===401)return null;if(r.status!==200&&r.status!==202)throw Error(`HTTP error! status: ${r.status}`);let i=await r.text();return i?JSON.parse(i):null}catch{if(r<this.maxRetries){let i=this.initialRetryDelay*2**r;return await new Promise(e=>setTimeout(e,i)),this.post(e,t,n,r+1)}return null}}async fetch(e,t,n={}){let r=`${this.baseUrl}${e}`;return this.post(r,t,n,0)}},ze=class{constructor(e){this.groups=[],this.queue=[],this.options=e;let t={"openpanel-client-id":e.clientId};e.clientSecret&&(t[`openpanel-client-secret`]=e.clientSecret),t[`openpanel-sdk-name`]=e.sdk||`node`,t[`openpanel-sdk-version`]=e.sdkVersion||`1.3.1`,this.api=new Re({baseUrl:e.apiUrl||`https://api.openpanel.dev`,defaultHeaders:t})}init(){}ready(){this.options.disabled=!1,this.options.waitForProfile=!1,this.flush()}shouldQueue(e){return!!(this.options.disabled||this.options.waitForProfile&&!this.profileId||e.type===`replay`&&!this.sessionId)}addQueue(e){e.type===`track`&&(e.payload.properties={...e.payload.properties??{},__timestamp:new Date().toISOString()}),this.queue.push(e)}async send(e){if(this.options.filter&&!this.options.filter(e))return Promise.resolve();if(this.shouldQueue(e))return this.addQueue(e),Promise.resolve();let t=await this.api.fetch(`/track`,e,{keepalive:e.type!==`replay`});this.deviceId=t?.deviceId;let n=!!this.sessionId;return this.sessionId=t?.sessionId,!n&&this.sessionId&&this.flush(),t}setGlobalProperties(e){this.global={...this.global,...e}}track(e,t){this.log(`track event`,e,t);let{groups:n,profileId:r,...i}=t??{},a=[...new Set([...this.groups,...n??[]])];return this.send({type:`track`,payload:{name:e,profileId:r??this.profileId,groups:a.length>0?a:void 0,properties:{...this.global??{},...i}}})}identify(e){if(this.log(`identify user`,e),e.profileId&&(this.profileId=e.profileId,this.flush()),e.profileId&&Object.keys(e).length>1)return this.send({type:`identify`,payload:{...e,properties:{...this.global,...e.properties}}})}upsertGroup(e){return this.log(`upsert group`,e),this.send({type:`group`,payload:e})}setGroup(e){return this.log(`set group`,e),this.groups.includes(e)||(this.groups=[...this.groups,e]),this.send({type:`assign_group`,payload:{groupIds:[e],profileId:this.profileId}})}setGroups(e){return this.log(`set groups`,e),this.groups=[...new Set([...this.groups,...e])],this.send({type:`assign_group`,payload:{groupIds:e,profileId:this.profileId}})}alias(e){}increment(e){return this.send({type:`increment`,payload:e})}decrement(e){return this.send({type:`decrement`,payload:e})}revenue(e,t){let n=t?.deviceId;return delete t?.deviceId,this.track(`revenue`,{...t??{},...n?{__deviceId:n}:{},__revenue:e})}getDeviceId(){return this.deviceId??``}getSessionId(){return this.sessionId??``}fetchDeviceId(){return Promise.resolve(this.deviceId??``)}clear(){this.profileId=void 0,this.groups=[],this.deviceId=void 0,this.sessionId=void 0}buildFlushPayload(e){if(e.type===`replay`)return e.payload;if(e.type===`track`){let t=`groups`in e.payload?e.payload.groups??[]:[],n=[...new Set([...this.groups,...t])];return{...e.payload,profileId:e.payload.profileId??this.profileId,groups:n.length>0?n:void 0}}return e.type===`identify`||e.type===`increment`||e.type===`decrement`||e.type===`assign_group`?{...e.payload,profileId:e.payload.profileId??this.profileId}:e.payload}flush(){let e=[];for(let t of this.queue){if(this.shouldQueue(t)){e.push(t);continue}let n=this.buildFlushPayload(t);this.send({...t,payload:n})}this.queue=e}log(...e){this.options.debug}},Be=typeof document<`u`?document.currentScript:null;function Ve(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var He=class extends ze{constructor(e){if(super({sdk:`web`,sdkVersion:`1.4.1`,...e}),this.options=e,this.lastPath=``,this.pendingRevenues=[],!this.isServer()){try{let e=sessionStorage.getItem(`openpanel-pending-revenues`);if(e){let t=JSON.parse(e);Array.isArray(t)&&(this.pendingRevenues=t)}}catch{this.pendingRevenues=[]}if(this.setGlobalProperties({__referrer:document.referrer}),this.options.trackScreenViews&&(this.trackScreenViews(),setTimeout(()=>this.screenView(),0)),this.options.trackOutgoingLinks&&this.trackOutgoingLinks(),this.options.trackAttributes&&this.trackAttributes(),this.options.sessionReplay?.enabled){let e=this.options.sessionReplay.sampleRate??1;Math.random()<e&&this.loadReplayModule().then(e=>{e&&e.startReplayRecorder(this.options.sessionReplay,e=>{this.send({type:`replay`,payload:{...e}})})})}}}async loadReplayModule(){try{if(typeof __OPENPANEL_REPLAY_URL__<`u`){let e=Be,t=this.options.sessionReplay?.scriptUrl||e?.src?.replace(`.js`,`-replay.js`)||`https://openpanel.dev/op1-replay.js`;return window.__openpanel_replay?window.__openpanel_replay:new Promise(e=>{let n=document.createElement(`script`);n.src=t,n.onload=()=>{e(window.__openpanel_replay??null)},n.onerror=()=>{e(null)},document.head.appendChild(n)})}return await import(`./replay-V6FXES7X.BoL9fAjx.js`)}catch{return null}}debounce(e,t){clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(e,t)}isServer(){return typeof document>`u`}trackOutgoingLinks(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`a`);if(n&&t){let e=n.getAttribute(`href`);if(e?.startsWith(`http`))try{let r=new URL(e),i=window.location.hostname;r.hostname!==i&&super.track(`link_out`,{href:e,text:n.innerText||n.getAttribute(`title`)||t.getAttribute(`alt`)||t.getAttribute(`title`)})}catch{}}})}trackScreenViews(){if(this.isServer())return;let e=history.pushState;history.pushState=function(...t){let n=e.apply(this,t);return window.dispatchEvent(new Event(`pushstate`)),window.dispatchEvent(new Event(`locationchange`)),n};let t=history.replaceState;history.replaceState=function(...e){let n=t.apply(this,e);return window.dispatchEvent(new Event(`replacestate`)),window.dispatchEvent(new Event(`locationchange`)),n},window.addEventListener(`popstate`,()=>{window.dispatchEvent(new Event(`locationchange`))});let n=()=>this.debounce(()=>this.screenView(),50);this.options.trackHashChanges?window.addEventListener(`hashchange`,n):window.addEventListener(`locationchange`,n)}trackAttributes(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`button`),r=t.closest(`a`),i=n?.getAttribute(`data-track`)?n:r?.getAttribute(`data-track`)?r:null;if(i){let e={};for(let t of i.attributes)t.name.startsWith(`data-`)&&t.name!==`data-track`&&(e[Ve(t.name.replace(/^data-/,``))]=t.value);let t=i.getAttribute(`data-track`);t&&super.track(t,e)}})}track(e,t){return super.track(e,{...t,__path:this.lastPath})}screenView(e,t){if(this.isServer())return;let n,r;typeof e==`string`?(n=e,r=t):(n=window.location.href,r=e),this.lastPath!==n&&(this.lastPath=n,super.track(`screen_view`,{...r??{},__path:n,__title:document.title}))}async flushRevenue(){let e=this.pendingRevenues.map(e=>super.revenue(e.amount,e.properties));await Promise.all(e),this.clearRevenue()}clearRevenue(){if(this.pendingRevenues=[],!this.isServer())try{sessionStorage.removeItem(`openpanel-pending-revenues`)}catch{}}pendingRevenue(e,t){if(this.pendingRevenues.push({amount:e,properties:t}),!this.isServer())try{sessionStorage.setItem(`openpanel-pending-revenues`,JSON.stringify(this.pendingRevenues))}catch{}}};const V=`nexus-wallet-backup`,H=`frakwallet://`;function Ue(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}})}).catch(e=>{}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()))}function We(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}const Ge=H.replace(`://`,``);function Ke(e){return`intent://${e.slice(13)}#Intent;scheme=${Ge};end`}function U(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=We()&&qe(e)?Ke(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function qe(e){return e.startsWith(H)}const W={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function Je({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);r.id=W.id,r.name=W.name,r.allow=W.allow,r.style.zIndex=W.style.zIndex.toString(),Ye({iframe:r,isVisible:!1});let i=t?.walletUrl??e??`https://wallet.frak.id`,a=g();return Ze(i),Ze(w(i)),r.src=`${i}/listener?clientId=${encodeURIComponent(a)}`,new Promise(e=>{r.addEventListener(`load`,()=>e(r)),document.body.appendChild(r)})}function Ye({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function Xe(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch{return null}}function Ze(e){if(!(typeof document>`u`))try{let t=new URL(e).origin,n=`link[rel="preconnect"][data-frak-preconnect="${t}"]`;if(document.head.querySelector(n))return;let r=document.createElement(`link`);r.rel=`preconnect`,r.href=t,r.crossOrigin=``,r.dataset.frakPreconnect=t,document.head.appendChild(r)}catch{}}const Qe=(()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent;if(!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1))return!1;let t=e.toLowerCase();return t.includes(`instagram`)||t.includes(`fban`)||t.includes(`fbav`)||t.includes(`facebook`)})();function $e(e){e?localStorage.setItem(V,e):localStorage.removeItem(V)}function G(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=nt(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function et(e){let t=new URL(window.location.href);e&&t.searchParams.set(`fmt`,e);let n=t.protocol===`http:`?`x-safari-http`:`x-safari-https`;window.location.href=`${n}://${t.host}${t.pathname}${t.search}${t.hash}`}function tt(e){return e.includes(`/common/social`)}function nt(e,t){if(!t)return e;try{let n=new URL(e);return n.searchParams.set(`fmt`,t),n.toString()}catch{return`${e}${e.includes(`?`)?`&`:`?`}fmt=${encodeURIComponent(t)}`}}function rt(e,t,n,r,i){if(i){let e=G(t,r);window.open(e,`_blank`);return}if(qe(t)){let i=G(t,r);U(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(Qe&&tt(t))et(r);else{let e=G(t,r);window.location.href=e}}function it({iframe:e,targetOrigin:t}){let n=new u;return{handleEvent:r=>{if(!(`iframeLifecycle`in r))return;let{iframeLifecycle:i,data:a}=r;switch(i){case`connected`:n.resolve(!0);break;case`do-backup`:$e(a.backup);break;case`remove-backup`:localStorage.removeItem(V);break;case`show`:case`hide`:Ye({iframe:e,isVisible:i===`show`});break;case`redirect`:rt(e,a.baseRedirectUrl,t,a.mergeToken,a.openInNewTab);break}},isConnected:n.promise}}function at({config:e,iframe:t}){let n=e?.walletUrl??`https://wallet.frak.id`,r=typeof navigator<`u`?navigator.language?.split(`-`)[0]:void 0,i=e.metadata.lang??(r===`en`||r===`fr`?r:void 0),a=e.domain??(typeof window<`u`?window.location.hostname:``);M.setCacheScope(a,i),M.reset();let o=M.isCacheFresh?void 0:M.resolve(e.domain,e.walletUrl,i),s=it({iframe:t,targetOrigin:n}),f=new u,p=Date.now();if(!t.contentWindow)throw new l(c.configError,`The iframe does not have a content window`);let m=d({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await s.isConnected)throw new l(c.clientNotConnected,`The iframe provider isn't connected yet`);return await f.promise,t}}],lifecycleHandlers:{iframeLifecycle:(e,t)=>{s.handleEvent(e)}}}),h=ot(m,s),_=async()=>{h(),m.cleanup(),t.remove(),S(),M.clearCache(),M.reset()},v;{v=new He({apiUrl:`https://op-api.gcp.frak.id`,clientId:`f305d11d-b93b-487c-80d4-92deb7903e98`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdkVersion`in t.properties||(t.properties={...t.properties,sdkVersion:`1.1.0`,userAnonymousClientId:g()}),!0)}),v.setGlobalProperties({sdkVersion:`1.1.0`,userAnonymousClientId:g()}),v.init(),v.track(`sdk_initialized`,{sdkVersion:`1.1.0`});let e=!1,t=setTimeout(()=>{e||(e=!0,v?.track(`sdk_iframe_handshake_failed`,{reason:`timeout`}))},3e4);s.isConnected.then(()=>{e||(e=!0,clearTimeout(t),v?.track(`sdk_iframe_connected`,{handshake_duration_ms:Date.now()-p}))}).catch(()=>{e||(e=!0,clearTimeout(t),v?.track(`sdk_iframe_handshake_failed`,{reason:`unknown`}))})}let y=st({config:e,rpcClient:m,lifecycleManager:s,configPromise:o,contextSent:f,openPanel:v}).then(()=>{}).catch(e=>{throw f.reject(e),e});return{config:e,waitForConnection:s.isConnected,waitForSetup:y,request:m.request,listenerRequest:m.listen,destroy:_,openPanel:v}}function ot(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,250),r=setTimeout(()=>{o()},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function st({config:e,rpcClient:t,lifecycleManager:n,configPromise:r,contextSent:i,openPanel:a}){await n.isConnected,Ue(t,n.isConnected);let o=new URL(window.location.href),s=o.searchParams.get(`fmt`)??void 0;s&&(o.searchParams.delete(`fmt`),window.history.replaceState({},``,o.toString()));let c=t=>{let n=t?.merchantId??e.metadata.merchantId??``,r=t?.domain??``,i=t?.allowedDomains??[],a=t?.sdkConfig,o=a?.attribution||e.attribution?{...e.attribution,...a?.attribution}:void 0;M.setConfig(a?{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,hasRawSdkConfig:!0,name:a.name??e.metadata.name,logoUrl:a.logoUrl??e.metadata.logoUrl,homepageLink:a.homepageLink??e.metadata.homepageLink,lang:a.lang??e.metadata.lang,currency:a.currency??e.metadata.currency,hidden:a.hidden,css:a.css,translations:a.translations,placements:a.placements,components:a.components,attribution:o}:{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,name:e.metadata.name,logoUrl:e.metadata.logoUrl,homepageLink:e.metadata.homepageLink,lang:e.metadata.lang,currency:e.metadata.currency,attribution:o})},l=!1,u=e=>{let n=l?void 0:s;l=!0;let r=e.hasRawSdkConfig?{name:e.name,logoUrl:e.logoUrl,homepageLink:e.homepageLink,lang:e.lang,currency:e.currency,hidden:e.hidden,css:e.css,translations:e.translations,placements:e.placements,attribution:e.attribution}:e.attribution?{attribution:e.attribution}:void 0,i=g();if(a){let t=a.global??{};a.setGlobalProperties({...t,merchantId:e.merchantId,domain:e.domain??``})}t.sendLifecycle({clientLifecycle:`resolved-config`,data:{merchantId:e.merchantId,domain:e.domain??``,allowedDomains:e.allowedDomains??[],sourceUrl:window.location.href,...i&&{sdkAnonymousId:i},...n&&{pendingMergeToken:n},...r&&{sdkConfig:r}}})};M.isResolved&&(u(M.getConfig()),i.resolve()),r&&(c(await r),u(M.getConfig()),i.resolve());async function d(){let n=e.customizations?.css;n&&t.sendLifecycle({clientLifecycle:`modal-css`,data:{cssLink:n}})}async function f(){let n=e.customizations?.i18n;n&&t.sendLifecycle({clientLifecycle:`modal-i18n`,data:{i18n:n}})}async function p(){if(typeof window>`u`)return;let e=window.localStorage.getItem(V);e&&t.sendLifecycle({clientLifecycle:`restore-backup`,data:{backup:e}})}(await Promise.allSettled([d(),f(),p()])).some(e=>e.status===`rejected`)&&a?.track(`sdk_iframe_handshake_failed`,{reason:`asset_push`})}function ct(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent;return!!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1)}const K=ct();function lt(){return typeof navigator>`u`?!1:K?!0:/Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function ut(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return e.includes(`instagram`)||e.includes(`fban`)||e.includes(`fbav`)||e.includes(`facebook`)}const dt=ut();function ft(e){K&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:K&&e.startsWith(`http://`)?window.location.href=`x-safari-http://${e.slice(7)}`:window.location.href=`https://backend.frak.id/common/social?u=${encodeURIComponent(e)}`}function pt(e){return p(P(e))}const q={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function J(e){return e&&e in q?e:`eur`}function mt(e){return e?q[e]??q.eur:q.eur}function ht(e,t){let n=mt(t),r=J(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function gt(e){return e?`${e}Amount`:`eurAmount`}async function _t({config:e}){let t=vt(e),n=await Je({config:t});if(!n)return;let r=at({config:t,iframe:n});if(await r.waitForSetup,await r.waitForConnection)return r}function vt(e){let t=J(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}function yt({perCall:e,defaults:t,productUtmContent:n}){if(e===null)return;let r=e!==void 0,i=t!==void 0&&Object.keys(t).length>0;if(!r&&!i&&!(n!==void 0&&n!==``))return;let a={...t,...e??{}},o=n??e?.utmContent;return o!==void 0&&o!==``?a.utmContent=o:delete a.utmContent,a}var bt=t({DEEP_LINK_SCHEME:()=>H,FrakContextManager:()=>B,base64urlDecode:()=>P,base64urlEncode:()=>N,baseIframeProps:()=>W,clearAllCache:()=>S,compressJsonToB64:()=>fe,createIFrameFrakClient:()=>at,decompressJsonFromB64:()=>pt,findIframeInOpener:()=>Xe,formatAmount:()=>ht,generateSsoUrl:()=>pe,getBackendUrl:()=>w,getClientId:()=>g,getCurrencyAmountKey:()=>gt,getSupportedCurrency:()=>J,isIOS:()=>K,isInAppBrowser:()=>dt,isMobile:()=>lt,mergeAttribution:()=>yt,redirectToExternalBrowser:()=>ft,sdkConfigStore:()=>M,setupClient:()=>_t,ssoPopupFeatures:()=>he,ssoPopupName:()=>ge,trackEvent:()=>F,triggerDeepLinkWithFallback:()=>U,withCache:()=>x});async function xt(e,t,n){return await e.request({method:`frak_displayEmbeddedWallet`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function Y(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 St(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function Ct(e){if(typeof window>`u`)return;let t=g();if(!t)return;let n=await M.resolveMerchantId();if(!n)return;let r=`frak-identity-ensured-${n}`;if(!window.sessionStorage.getItem(r))try{let i=w();(await fetch(`${i}/user/identity/ensure`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":e,"x-frak-client-id":t},body:JSON.stringify({merchantId:n})})).ok&&window.sessionStorage.setItem(r,`1`)}catch{}}async function wt(e,t){return x(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:t?.cacheTime})}async function Tt(e,t){return x(()=>e.request({method:`frak_getMergeToken`}),{cacheKey:`frak_getMergeToken`,cacheTime:t?.cacheTime})}async function Et(e,t){return x(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:t?.cacheTime})}async function Dt(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function X(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t,{clientId:g()}]})}catch{}}function Ot(e,t,n){return L(t)?(F(e,`user_referred_started`,{referrerClientId:t.c,referrerWallet:t.w,walletStatus:n?.key}),X(e,{type:`arrival`,referrerClientId:t.c,referrerMerchantId:t.m,referrerWallet:t.w,referralTimestamp:t.t}),!0):Ce(t)?(F(e,`user_referred_started`,{referrer:t.r,walletStatus:n?.key}),X(e,{type:`arrival`,referrerWallet:t.r}),!0):!1}function kt(e,t){let n=g();return!n&&!t?null:{v:2,m:e,t:Math.floor(Date.now()/1e3),...n?{c:n}:{},...t?{w:t}:{}}}function At(e,t){return L(e)?e.w&&t?.wallet?ye(e.w,t.wallet):e.c?g()===e.c:!1:Ce(e)&&t?.wallet?ye(e.r,t.wallet):!1}function jt(e,{walletStatus:t,frakContext:n,options:r}){if(!n)return`no-referrer`;if(At(n,t))return`self-referral`;if(!Ot(e,n,t))return`no-referrer`;let i=L(n)?n.m:r?.merchantId,a=r?.alwaysAppendUrl&&i?kt(i,t?.wallet):null;return B.replaceUrl({url:window.location?.href,context:a}),F(e,`user_referred_completed`,{status:`success`}),`success`}async function Mt(e,{options:t}={}){let n=B.parse({url:window.location.href}),r=await Q(e);try{return jt(e,{walletStatus:r,frakContext:n,options:t})}catch{}}const Z=`frak:referral-success`;async function Nt(e){try{await Mt(e)===`success`&&window.dispatchEvent(new Event(Z))}catch{}}async function Pt(e){if(typeof window>`u`)return;let t=window.sessionStorage.getItem(`frak-wallet-interaction-token`),n=g();if(!t&&!n)return;let r=e.merchantId??await M.resolveMerchantId();if(!r)return;let i={Accept:`application/json`,"Content-Type":`application/json`};t&&(i[`x-wallet-sdk-auth`]=t),n&&(i[`x-frak-client-id`]=n);let a=w();await fetch(`${a}/user/track/purchase`,{method:`POST`,headers:i,body:JSON.stringify({customerId:e.customerId,orderId:e.orderId,token:e.token,merchantId:r})})}function Q(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(Ft(e,t),t));let n=new u,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{Ft(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function Ft(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),Ct(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function It(e,{metadata:t,login:n}){return $(e,{steps:{login:n??{}},metadata:t})}function $(e,t){function n(n){return $(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return $(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return $(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 Y(e,t,r)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function Lt(e,{tx:t,metadata:n}){return(await Y(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function Rt(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 zt(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 Y(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??Rt(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var Bt=t({REFERRAL_SUCCESS_EVENT:()=>Z,displayEmbeddedWallet:()=>xt,displayModal:()=>Y,displaySharingPage:()=>St,ensureIdentity:()=>Ct,getMerchantInformation:()=>wt,getMergeToken:()=>Tt,getUserReferralStatus:()=>Et,modalBuilder:()=>It,openSso:()=>_e,prepareSso:()=>Dt,processReferral:()=>jt,referralInteraction:()=>Mt,sendInteraction:()=>X,sendTransaction:()=>Lt,setupReferral:()=>Nt,siweAuthenticate:()=>zt,trackPurchaseStatus:()=>Pt,watchWalletStatus:()=>Q});async function Vt(e,t){if(!window.FrakSetup?.client)return;let n=window.FrakSetup?.modalWalletConfig??{};await xt(window.FrakSetup.client,e?{...n,metadata:{...n.metadata,targetInteraction:e}}:n,t)}function Ht(){`vibrate`in navigator&&navigator.vibrate(10)}function Ut(e,t){Ht(),Vt(e,t)}const Wt=`frak:client`;function Gt(){let e=new CustomEvent(Wt);window.dispatchEvent(e)}function Kt(e,t){if(window.FrakSetup?.client&&e===`add`){t();return}(e===`add`?window.addEventListener:window.removeEventListener)(Wt,t,!1)}function qt(){return window.FrakSetup.core={...bt,...Bt},window.FrakSetup?.client?Promise.resolve():x(()=>Jt(),{cacheKey:`frak-sdk-init`,cacheTime:1/0}).catch(e=>{F(window.FrakSetup?.client,`sdk_init_failed`,{reason:e instanceof Error?e.message:typeof e==`string`?e:`unknown`,config_missing:!window.FrakSetup?.config})})}async function Jt(){if(!window.FrakSetup?.config)throw Error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`);let e=await _t({config:window.FrakSetup.config});if(!e)throw Error(`[Frak SDK] Failed to create client`);window.FrakSetup.client=e,Gt(),Nt(e),Yt()}function Yt(){let e=new URLSearchParams(window.location.search).get(`frakAction`);e&&e===`share`&&Ut()}o.injectBase(`shared`,n),o.injectBase(`fouce`,`frak-button-share:not(:defined), frak-button-wallet:not(:defined), frak-open-in-app:not(:defined), frak-post-purchase:not(:defined), frak-banner:not(:defined) { display: none !important; }`),s(qt);const Xt={"button-share":()=>import(`./ButtonShare.elMtdxF3.js`),"button-wallet":()=>import(`./ButtonWallet.BUUPX0gO.js`),"open-in-app":()=>import(`./OpenInAppButton.Dgb-qhM8.js`),"post-purchase":()=>import(`./PostPurchase.Cy7-FrRh.js`),banner:()=>import(`./Banner.CIxY6tCU.js`)},Zt=new MutationObserver(e=>{for(let{addedNodes:t}of e)for(let e of Array.from(t))e.nodeType===Node.ELEMENT_NODE&&Qt(e)});async function Qt(e){let t=e instanceof Element?e.tagName.toLowerCase():``,n=t?.startsWith(`frak-`),r=Array.from(e.querySelectorAll(`:not(:defined)`)).map(e=>e.tagName.toLowerCase()).filter(e=>e.startsWith(`frak-`));n&&!customElements.get(t)&&r.push(t);let i=[...new Set(r)];await Promise.allSettled(i.map(e=>$t(e)))}async function $t(e){if(customElements.get(e))return Promise.resolve();try{let t=e.replace(/^frak-/i,``);if(!(t in Xt))throw Error(`Component ${e} is not supported.`);await Xt[t]()}catch{}}Qt(document.body),Zt.observe(document.documentElement,{subtree:!0,childList:!0});export{s as C,l as S,n as T,H as _,Pt as a,F as b,Tt as c,ft as d,ht as f,U as g,J as h,Vt as i,wt as l,lt as m,Kt as n,St as o,gt as p,Ut as r,Et as s,qt as t,Z as u,dt as v,o as w,c as x,M as y};
|
|
154
|
+
}`;function r(e,t){let n=document.getElementById(e);if(n){n.textContent!==t&&(n.textContent=t);return}let r=document.createElement(`style`);r.id=e,r.textContent=t,document.head.appendChild(r)}function i(e,t){let n=`frak-base-${e}`;if(document.getElementById(n)||!t)return;let r=document.createElement(`style`);r.id=n,r.textContent=t,document.head.appendChild(r)}function a(e,t,n){r(`frak-placement-${e}-${t}`,n)}const o={injectBase:i,injectPlacement:a};function s(e){document.readyState===`complete`||document.readyState===`interactive`?setTimeout(e,1):document.addEventListener(`DOMContentLoaded`,e)}const c={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006,userRejected:-32007};var l=class extends Error{code;data;constructor(e,t,n){super(t),this.code=e,this.data=n}toJSON(){return{code:this.code,message:this.message,data:this.data}}},u=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}};function d(e){let{emittingTransport:t,listeningTransport:n,targetOrigin:r,middleware:i=[],lifecycleHandlers:a}=e,o=new Map;function s(e){return typeof e!=`object`||!e?!1:`clientLifecycle`in e||`iframeLifecycle`in e}function c(e){return typeof e!=`object`||!e?!1:`id`in e&&`topic`in e&&`data`in e}async function d(e){try{`clientLifecycle`in e&&a?.clientLifecycle?await a.clientLifecycle(e,{origin:r,source:null}):`iframeLifecycle`in e&&a?.iframeLifecycle&&await a.iframeLifecycle(e,{origin:r,source:null})}catch{}}async function f(e){let t={origin:r,source:null};for(let n of i)n.onRequest&&await n.onRequest(e,t);return e}async function p(e,t){let n={origin:r,source:null},a=t;for(let t of i)t.onResponse&&(a=await t.onResponse(e,a,n));return a}async function m(e){try{if(new URL(e.origin).origin.toLowerCase()!==new URL(r).origin.toLowerCase())return}catch{return}if(s(e.data)){await d(e.data);return}if(!c(e.data))return;let t;try{let n=e.data.data,r=n instanceof Uint8Array||ArrayBuffer.isView(n)?{result:n}:n;t=await p(e.data,r)}catch{return}let n=o.get(e.data.id);n&&n(t)}async function h(e){let n=e;try{n=await f(e)}catch(e){throw e}t.postMessage(n,r)}function g(e){t.postMessage(e,r)}function _(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}n.addEventListener(`message`,m);function v(e){let t=_(),n=new u;return o.set(t,e=>{e.error?n.reject(new l(e.error.code,e.error.message,e.error.data)):n.resolve(e.result),o.delete(t)}),h({id:t,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{o.delete(t),n.reject(e)}),n.promise}function y(e,t){let n=_();return o.set(n,e=>{e.error?o.delete(n):t(e.result)}),h({id:n,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{o.delete(n)}),()=>{o.delete(n)}}function b(){n.removeEventListener(`message`,m),o.clear()}return{request:v,listen:y,sendLifecycle:g,cleanup:b}}function f(e){return new TextEncoder().encode(JSON.stringify(e))}function p(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}const m=`frak-client-id`;function h(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function g(){if(typeof window>`u`||!window.localStorage)return h();let e=localStorage.getItem(m);return e||(e=h(),localStorage.setItem(m,e)),e}var _=class extends Map{maxSize;constructor(e){super(),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&(super.delete(e),super.set(e,t)),t}set(e,t){if(super.has(e)&&super.delete(e),super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=super.keys().next().value;e!==void 0&&super.delete(e)}return this}};const v=new _(1024),y=new _(1024),b=new _(1024);async function x(e,{cacheKey:t,cacheTime:n=3e4}){if(n>0){let e=y.get(t);if(e&&Date.now()-e.created<n)return e.data}let r=b.get(t);if(r&&Date.now()-r<1e3)throw Error(`Cache: ${t} recently failed, backing off`);let i=v.get(t);i||(i=e(),v.set(t,i));try{let e=await i;return y.set(t,{data:e,created:Date.now()}),b.delete(t),e}catch(e){throw b.set(t,Date.now()),e}finally{v.delete(t)}}function S(){v.clear(),y.clear(),b.clear()}const C=`https://backend.frak.id`;function ee(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function te(e){return ee(e)?`https://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:C}function w(e){if(e)return te(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return te(e)}return C}const T=`__frakSdkConfig`,ne=`frak-config-cache`,E=`frak-merchant-id`,D={key:ne},O=typeof window<`u`;function k(){return{isResolved:!1,merchantId:``}}let A=null;function re(){if(!O)return null;try{let e=localStorage.getItem(D.key);if(!e)return null;let t=JSON.parse(e);return t.config?.isResolved?(A=t,t):null}catch{return null}}function ie(){return(A??re())?.config}function ae(){let e=A??re();return e?Date.now()-e.timestamp<3e4:!1}function oe(e){if(!(!O||!e.isResolved))try{let t={config:e,timestamp:Date.now()};localStorage.setItem(D.key,JSON.stringify(t)),A=t}catch{}}function se(){if(O){A=null;try{localStorage.removeItem(D.key)}catch{}}}function ce(){O&&(window[T]||(window[T]=ie()??k()))}ce();function j(){return O?window[T]??k():k()}function le(e){O&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function ue(e){return e??(O?window.location.hostname:``)}async function de(e,t,n){try{let r=w(t),i=n?`&lang=${encodeURIComponent(n)}`:``,a=await fetch(`${r}/user/merchant/resolve?domain=${encodeURIComponent(e)}${i}`);if(!a.ok)return;let o=await a.json();if(O)try{sessionStorage.setItem(E,o.merchantId)}catch{}return o}catch{return}}const M={getConfig:j,get isResolved(){return j().isResolved},get isCacheFresh(){return ae()},setCacheScope(e,t){D.key=`${ne}:${`${e}:${t??``}`}`,A=null},setConfig(e){if(O&&(window[T]=e),oe(e),le(e),O&&e.merchantId)try{sessionStorage.setItem(E,e.merchantId)}catch{}},reset(){let e=ie()??k();O&&(window[T]=e),le(e)},clearCache(){if(se(),S(),O)try{sessionStorage.removeItem(E)}catch{}},resolve(e,t,n){let r=ue(e);return r?x(async()=>{let e=await de(r,t,n);if(!e)throw Error(`Config resolution returned empty`);return e},{cacheKey:`sdkConfig:${r}:${n??``}`,cacheTime:1/0}).catch(()=>void 0):Promise.resolve(void 0)},getMerchantId(){let e=j();if(e.isResolved&&e.merchantId)return e.merchantId;if(O)try{return sessionStorage.getItem(E)??void 0}catch{}},async resolveMerchantId(e,t){return M.getMerchantId()||(await M.resolve(e,t))?.merchantId}};function N(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function P(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function fe(e){return N(f(e))}function pe(e,t,n,r,i,a){let o=fe(me({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:a,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:i})),s=new URL(e);return s.pathname=`/sso`,s.searchParams.set(`p`,o),s.toString()}function me(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const he=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,ge=`frak-sso`;async function _e(e,t){let{metadata:n,customizations:r,walletUrl:i}=e.config,a={...t,directExit:t.directExit??!t.redirectUrl};if(a.openInSameWindow??!!a.redirectUrl)return await e.request({method:`frak_openSso`,params:[a,n.name,r?.css]});let o=a.ssoPopupUrl??pe(i??`https://wallet.frak.id`,a,await M.resolveMerchantId()??``,n.name,g(),r?.css),s=window.open(o,ge,he);if(!s)throw Error(`Popup was blocked. Please allow popups for this site.`);return s.focus(),await e.request({method:`frak_openSso`,params:[a,n.name,r?.css]})??{}}function F(e,t,n){if(e)try{e.openPanel?.track(t,n)}catch{}}const ve=/^0x[a-fA-F0-9]{40}$/;function I(e){return typeof e==`string`&&ve.test(e)}function ye(e,t){return e.toLowerCase()===t.toLowerCase()}function be(e){let t=new Uint8Array(20);for(let n=0;n<20;n++){let r=Number.parseInt(e.substring(2+n*2,4+n*2),16);if(Number.isNaN(r))throw Error(`Invalid address: ${e}`);t[n]=r}return t}const xe=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Se(e){let t=`0x`;for(let n=0;n<20;n++)t+=xe[e[n]];return t}function Ce(e){return`r`in e&&!(`v`in e)}function L(e){return`v`in e&&e.v===2}const we=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Te(e){return typeof e==`string`&&we.test(e)}function Ee(e){let t=e.replace(/-/g,``),n=new Uint8Array(16);for(let e=0;e<16;e++)n[e]=Number.parseInt(t.substring(e*2,e*2+2),16);return n}function De(e){let t=``;for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,`0`);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20,32)}`}function Oe(e){if(!Te(e.m)||!Number.isInteger(e.t)||e.t<0||e.t>4294967295)return null;let t=typeof e.c==`string`&&e.c.length>0,n=typeof e.w==`string`&&I(e.w);if(!t&&!n||t&&!Te(e.c))return null;let r=new Uint8Array(21+(t?16:0)+(n?20:0)),i=new DataView(r.buffer,r.byteOffset,r.byteLength),a=0;return r[a++]=2|(t?16:0)|(n?32:0),r.set(Ee(e.m),a),a+=16,i.setUint32(a,e.t,!1),a+=4,t&&(r.set(Ee(e.c),a),a+=16),n&&(r.set(be(e.w),a),a+=20),r}function ke(e){if(e.length<21)return null;let t=e[0];if((t&15)!=2||t&192)return null;let n=(t&16)!=0,r=(t&32)!=0;if(!n&&!r)return null;let i=21+(n?16:0)+(r?20:0);if(e.length!==i)return null;let a=1,o=De(e.subarray(a,a+16));a+=16;let s=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(a,!1);a+=4;let c={v:2,m:o,t:s};if(n&&(c.c=De(e.subarray(a,a+16)),a+=16),r){let t=Se(e.subarray(a,a+20));if(!I(t))return null;c.w=t,a+=20}return c}const R=`fCtx`;function z(e){if(e)try{if(L(e)){let t=Oe(e);return t?N(t):void 0}return N(be(e.r))}catch{}}function Ae(e){if(!(!e||e.length===0))try{let t=P(e);if(t.length!==20)return ke(t)||void 0;let n=Se(t);if(I(n))return{r:n}}catch{}}function je({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(R);return t?Ae(t):null}const Me=`frak`;function Ne(e,t){let n=L(e);return{utm_source:t.utmSource??Me,utm_medium:t.utmMedium??`referral`,utm_campaign:t.utmCampaign??(n?e.m:void 0),utm_content:t.utmContent,utm_term:t.utmTerm,via:t.via??Me,ref:t.ref??(n?e.c:void 0)}}function Pe(e,t,n){let r=Ne(t,n??{});for(let[t,n]of Object.entries(r))n===void 0||n===``||e.searchParams.has(t)||e.searchParams.set(t,n)}function Fe({url:e,context:t,attribution:n}){if(!e)return null;let r=z(t);if(!r)return null;let i=new URL(e);return i.searchParams.set(R,r),Pe(i,t,n),i.toString()}function Ie(e){let t=new URL(e);return t.searchParams.delete(R),t.toString()}function Le({url:e,context:t}){if(!window.location?.href||typeof window>`u`)return;let n=e??window.location.href,r;r=t===null?Ie(n):Fe({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const B={compress:z,decompress:Ae,parse:je,update:Fe,remove:Ie,replaceUrl:Le};var Re=class{constructor(e){this.baseUrl=e.baseUrl,this.headers={"Content-Type":`application/json`,...e.defaultHeaders},this.maxRetries=e.maxRetries??3,this.initialRetryDelay=e.initialRetryDelay??500}async resolveHeaders(){let e={};for(let[t,n]of Object.entries(this.headers)){let r=await n;r!==null&&(e[t]=r)}return e}addHeader(e,t){this.headers[e]=t}async post(e,t,n,r){try{let r=await fetch(e,{method:`POST`,headers:await this.resolveHeaders(),body:t?JSON.stringify(t??{}):void 0,keepalive:!0,...n});if(r.status===401)return null;if(r.status!==200&&r.status!==202)throw Error(`HTTP error! status: ${r.status}`);let i=await r.text();return i?JSON.parse(i):null}catch{if(r<this.maxRetries){let i=this.initialRetryDelay*2**r;return await new Promise(e=>setTimeout(e,i)),this.post(e,t,n,r+1)}return null}}async fetch(e,t,n={}){let r=`${this.baseUrl}${e}`;return this.post(r,t,n,0)}},ze=class{constructor(e){this.groups=[],this.queue=[],this.options=e;let t={"openpanel-client-id":e.clientId};e.clientSecret&&(t[`openpanel-client-secret`]=e.clientSecret),t[`openpanel-sdk-name`]=e.sdk||`node`,t[`openpanel-sdk-version`]=e.sdkVersion||`1.3.1`,this.api=new Re({baseUrl:e.apiUrl||`https://api.openpanel.dev`,defaultHeaders:t})}init(){}ready(){this.options.disabled=!1,this.options.waitForProfile=!1,this.flush()}shouldQueue(e){return!!(this.options.disabled||this.options.waitForProfile&&!this.profileId||e.type===`replay`&&!this.sessionId)}addQueue(e){e.type===`track`&&(e.payload.properties={...e.payload.properties??{},__timestamp:new Date().toISOString()}),this.queue.push(e)}async send(e){if(this.options.filter&&!this.options.filter(e))return Promise.resolve();if(this.shouldQueue(e))return this.addQueue(e),Promise.resolve();let t=await this.api.fetch(`/track`,e,{keepalive:e.type!==`replay`});this.deviceId=t?.deviceId;let n=!!this.sessionId;return this.sessionId=t?.sessionId,!n&&this.sessionId&&this.flush(),t}setGlobalProperties(e){this.global={...this.global,...e}}track(e,t){this.log(`track event`,e,t);let{groups:n,profileId:r,...i}=t??{},a=[...new Set([...this.groups,...n??[]])];return this.send({type:`track`,payload:{name:e,profileId:r??this.profileId,groups:a.length>0?a:void 0,properties:{...this.global??{},...i}}})}identify(e){if(this.log(`identify user`,e),e.profileId&&(this.profileId=e.profileId,this.flush()),e.profileId&&Object.keys(e).length>1)return this.send({type:`identify`,payload:{...e,properties:{...this.global,...e.properties}}})}upsertGroup(e){return this.log(`upsert group`,e),this.send({type:`group`,payload:e})}setGroup(e){return this.log(`set group`,e),this.groups.includes(e)||(this.groups=[...this.groups,e]),this.send({type:`assign_group`,payload:{groupIds:[e],profileId:this.profileId}})}setGroups(e){return this.log(`set groups`,e),this.groups=[...new Set([...this.groups,...e])],this.send({type:`assign_group`,payload:{groupIds:e,profileId:this.profileId}})}alias(e){}increment(e){return this.send({type:`increment`,payload:e})}decrement(e){return this.send({type:`decrement`,payload:e})}revenue(e,t){let n=t?.deviceId;return delete t?.deviceId,this.track(`revenue`,{...t??{},...n?{__deviceId:n}:{},__revenue:e})}getDeviceId(){return this.deviceId??``}getSessionId(){return this.sessionId??``}fetchDeviceId(){return Promise.resolve(this.deviceId??``)}clear(){this.profileId=void 0,this.groups=[],this.deviceId=void 0,this.sessionId=void 0}buildFlushPayload(e){if(e.type===`replay`)return e.payload;if(e.type===`track`){let t=`groups`in e.payload?e.payload.groups??[]:[],n=[...new Set([...this.groups,...t])];return{...e.payload,profileId:e.payload.profileId??this.profileId,groups:n.length>0?n:void 0}}return e.type===`identify`||e.type===`increment`||e.type===`decrement`||e.type===`assign_group`?{...e.payload,profileId:e.payload.profileId??this.profileId}:e.payload}flush(){let e=[];for(let t of this.queue){if(this.shouldQueue(t)){e.push(t);continue}let n=this.buildFlushPayload(t);this.send({...t,payload:n})}this.queue=e}log(...e){this.options.debug}},Be=typeof document<`u`?document.currentScript:null;function Ve(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var He=class extends ze{constructor(e){if(super({sdk:`web`,sdkVersion:`1.4.1`,...e}),this.options=e,this.lastPath=``,this.pendingRevenues=[],!this.isServer()){try{let e=sessionStorage.getItem(`openpanel-pending-revenues`);if(e){let t=JSON.parse(e);Array.isArray(t)&&(this.pendingRevenues=t)}}catch{this.pendingRevenues=[]}if(this.setGlobalProperties({__referrer:document.referrer}),this.options.trackScreenViews&&(this.trackScreenViews(),setTimeout(()=>this.screenView(),0)),this.options.trackOutgoingLinks&&this.trackOutgoingLinks(),this.options.trackAttributes&&this.trackAttributes(),this.options.sessionReplay?.enabled){let e=this.options.sessionReplay.sampleRate??1;Math.random()<e&&this.loadReplayModule().then(e=>{e&&e.startReplayRecorder(this.options.sessionReplay,e=>{this.send({type:`replay`,payload:{...e}})})})}}}async loadReplayModule(){try{if(typeof __OPENPANEL_REPLAY_URL__<`u`){let e=Be,t=this.options.sessionReplay?.scriptUrl||e?.src?.replace(`.js`,`-replay.js`)||`https://openpanel.dev/op1-replay.js`;return window.__openpanel_replay?window.__openpanel_replay:new Promise(e=>{let n=document.createElement(`script`);n.src=t,n.onload=()=>{e(window.__openpanel_replay??null)},n.onerror=()=>{e(null)},document.head.appendChild(n)})}return await import(`./replay-V6FXES7X.BoL9fAjx.js`)}catch{return null}}debounce(e,t){clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(e,t)}isServer(){return typeof document>`u`}trackOutgoingLinks(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`a`);if(n&&t){let e=n.getAttribute(`href`);if(e?.startsWith(`http`))try{let r=new URL(e),i=window.location.hostname;r.hostname!==i&&super.track(`link_out`,{href:e,text:n.innerText||n.getAttribute(`title`)||t.getAttribute(`alt`)||t.getAttribute(`title`)})}catch{}}})}trackScreenViews(){if(this.isServer())return;let e=history.pushState;history.pushState=function(...t){let n=e.apply(this,t);return window.dispatchEvent(new Event(`pushstate`)),window.dispatchEvent(new Event(`locationchange`)),n};let t=history.replaceState;history.replaceState=function(...e){let n=t.apply(this,e);return window.dispatchEvent(new Event(`replacestate`)),window.dispatchEvent(new Event(`locationchange`)),n},window.addEventListener(`popstate`,()=>{window.dispatchEvent(new Event(`locationchange`))});let n=()=>this.debounce(()=>this.screenView(),50);this.options.trackHashChanges?window.addEventListener(`hashchange`,n):window.addEventListener(`locationchange`,n)}trackAttributes(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`button`),r=t.closest(`a`),i=n?.getAttribute(`data-track`)?n:r?.getAttribute(`data-track`)?r:null;if(i){let e={};for(let t of i.attributes)t.name.startsWith(`data-`)&&t.name!==`data-track`&&(e[Ve(t.name.replace(/^data-/,``))]=t.value);let t=i.getAttribute(`data-track`);t&&super.track(t,e)}})}track(e,t){return super.track(e,{...t,__path:this.lastPath})}screenView(e,t){if(this.isServer())return;let n,r;typeof e==`string`?(n=e,r=t):(n=window.location.href,r=e),this.lastPath!==n&&(this.lastPath=n,super.track(`screen_view`,{...r??{},__path:n,__title:document.title}))}async flushRevenue(){let e=this.pendingRevenues.map(e=>super.revenue(e.amount,e.properties));await Promise.all(e),this.clearRevenue()}clearRevenue(){if(this.pendingRevenues=[],!this.isServer())try{sessionStorage.removeItem(`openpanel-pending-revenues`)}catch{}}pendingRevenue(e,t){if(this.pendingRevenues.push({amount:e,properties:t}),!this.isServer())try{sessionStorage.setItem(`openpanel-pending-revenues`,JSON.stringify(this.pendingRevenues))}catch{}}};const V=`nexus-wallet-backup`,H=`frakwallet://`;function Ue(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}})}).catch(e=>{}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()))}function We(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}const Ge=H.replace(`://`,``);function Ke(e){return`intent://${e.slice(13)}#Intent;scheme=${Ge};end`}function U(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=We()&&qe(e)?Ke(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function qe(e){return e.startsWith(H)}const W={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function Je({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);r.id=W.id,r.name=W.name,r.allow=W.allow,r.style.zIndex=W.style.zIndex.toString(),Ye({iframe:r,isVisible:!1});let i=t?.walletUrl??e??`https://wallet.frak.id`,a=g();return Ze(i),Ze(w(i)),r.src=`${i}/listener?clientId=${encodeURIComponent(a)}`,new Promise(e=>{r.addEventListener(`load`,()=>e(r)),document.body.appendChild(r)})}function Ye({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function Xe(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch{return null}}function Ze(e){if(!(typeof document>`u`))try{let t=new URL(e).origin,n=`link[rel="preconnect"][data-frak-preconnect="${t}"]`;if(document.head.querySelector(n))return;let r=document.createElement(`link`);r.rel=`preconnect`,r.href=t,r.crossOrigin=``,r.dataset.frakPreconnect=t,document.head.appendChild(r)}catch{}}const Qe=(()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent;if(!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1))return!1;let t=e.toLowerCase();return t.includes(`instagram`)||t.includes(`fban`)||t.includes(`fbav`)||t.includes(`facebook`)})();function $e(e){e?localStorage.setItem(V,e):localStorage.removeItem(V)}function G(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=nt(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function et(e){let t=new URL(window.location.href);e&&t.searchParams.set(`fmt`,e);let n=t.protocol===`http:`?`x-safari-http`:`x-safari-https`;window.location.href=`${n}://${t.host}${t.pathname}${t.search}${t.hash}`}function tt(e){return e.includes(`/common/social`)}function nt(e,t){if(!t)return e;try{let n=new URL(e);return n.searchParams.set(`fmt`,t),n.toString()}catch{return`${e}${e.includes(`?`)?`&`:`?`}fmt=${encodeURIComponent(t)}`}}function rt(e,t,n,r,i){if(i){let e=G(t,r);window.open(e,`_blank`);return}if(qe(t)){let i=G(t,r);U(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(Qe&&tt(t))et(r);else{let e=G(t,r);window.location.href=e}}function it({iframe:e,targetOrigin:t}){let n=new u;return{handleEvent:r=>{if(!(`iframeLifecycle`in r))return;let{iframeLifecycle:i,data:a}=r;switch(i){case`connected`:n.resolve(!0);break;case`do-backup`:$e(a.backup);break;case`remove-backup`:localStorage.removeItem(V);break;case`show`:case`hide`:Ye({iframe:e,isVisible:i===`show`});break;case`redirect`:rt(e,a.baseRedirectUrl,t,a.mergeToken,a.openInNewTab);break}},isConnected:n.promise}}function at({config:e,iframe:t}){let n=e?.walletUrl??`https://wallet.frak.id`,r=typeof navigator<`u`?navigator.language?.split(`-`)[0]:void 0,i=e.metadata.lang??(r===`en`||r===`fr`?r:void 0),a=e.domain??(typeof window<`u`?window.location.hostname:``);M.setCacheScope(a,i),M.reset();let o=M.isCacheFresh?void 0:M.resolve(e.domain,e.walletUrl,i),s=it({iframe:t,targetOrigin:n}),f=new u,p=Date.now();if(!t.contentWindow)throw new l(c.configError,`The iframe does not have a content window`);let m=d({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await s.isConnected)throw new l(c.clientNotConnected,`The iframe provider isn't connected yet`);return await f.promise,t}}],lifecycleHandlers:{iframeLifecycle:(e,t)=>{s.handleEvent(e)}}}),h=ot(m,s),_=async()=>{h(),m.cleanup(),t.remove(),S(),M.clearCache(),M.reset()},v;{v=new He({apiUrl:`https://op-api.gcp.frak.id`,clientId:`f305d11d-b93b-487c-80d4-92deb7903e98`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdkVersion`in t.properties||(t.properties={...t.properties,sdkVersion:`1.1.1`,userAnonymousClientId:g()}),!0)}),v.setGlobalProperties({sdkVersion:`1.1.1`,userAnonymousClientId:g()}),v.init(),v.track(`sdk_initialized`,{sdkVersion:`1.1.1`});let e=!1,t=setTimeout(()=>{e||(e=!0,v?.track(`sdk_iframe_handshake_failed`,{reason:`timeout`}))},3e4);s.isConnected.then(()=>{e||(e=!0,clearTimeout(t),v?.track(`sdk_iframe_connected`,{handshake_duration_ms:Date.now()-p}))}).catch(()=>{e||(e=!0,clearTimeout(t),v?.track(`sdk_iframe_handshake_failed`,{reason:`unknown`}))})}let y=st({config:e,rpcClient:m,lifecycleManager:s,configPromise:o,contextSent:f,openPanel:v}).then(()=>{}).catch(e=>{throw f.reject(e),e});return{config:e,waitForConnection:s.isConnected,waitForSetup:y,request:m.request,listenerRequest:m.listen,destroy:_,openPanel:v}}function ot(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,250),r=setTimeout(()=>{o()},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function st({config:e,rpcClient:t,lifecycleManager:n,configPromise:r,contextSent:i,openPanel:a}){await n.isConnected,Ue(t,n.isConnected);let o=new URL(window.location.href),s=o.searchParams.get(`fmt`)??void 0;s&&(o.searchParams.delete(`fmt`),window.history.replaceState({},``,o.toString()));let c=t=>{let n=t?.merchantId??e.metadata.merchantId??``,r=t?.domain??``,i=t?.allowedDomains??[],a=t?.sdkConfig,o=a?.attribution||e.attribution?{...e.attribution,...a?.attribution}:void 0;M.setConfig(a?{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,hasRawSdkConfig:!0,name:a.name??e.metadata.name,logoUrl:a.logoUrl??e.metadata.logoUrl,homepageLink:a.homepageLink??e.metadata.homepageLink,lang:a.lang??e.metadata.lang,currency:a.currency??e.metadata.currency,hidden:a.hidden,css:a.css,translations:a.translations,placements:a.placements,components:a.components,attribution:o}:{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,name:e.metadata.name,logoUrl:e.metadata.logoUrl,homepageLink:e.metadata.homepageLink,lang:e.metadata.lang,currency:e.metadata.currency,attribution:o})},l=!1,u=e=>{let n=l?void 0:s;l=!0;let r=e.hasRawSdkConfig?{name:e.name,logoUrl:e.logoUrl,homepageLink:e.homepageLink,lang:e.lang,currency:e.currency,hidden:e.hidden,css:e.css,translations:e.translations,placements:e.placements,attribution:e.attribution}:e.attribution?{attribution:e.attribution}:void 0,i=g();if(a){let t=a.global??{};a.setGlobalProperties({...t,merchantId:e.merchantId,domain:e.domain??``})}t.sendLifecycle({clientLifecycle:`resolved-config`,data:{merchantId:e.merchantId,domain:e.domain??``,allowedDomains:e.allowedDomains??[],sourceUrl:window.location.href,...i&&{sdkAnonymousId:i},...n&&{pendingMergeToken:n},...r&&{sdkConfig:r}}})};M.isResolved&&(u(M.getConfig()),i.resolve()),r&&(c(await r),u(M.getConfig()),i.resolve());async function d(){let n=e.customizations?.css;n&&t.sendLifecycle({clientLifecycle:`modal-css`,data:{cssLink:n}})}async function f(){let n=e.customizations?.i18n;n&&t.sendLifecycle({clientLifecycle:`modal-i18n`,data:{i18n:n}})}async function p(){if(typeof window>`u`)return;let e=window.localStorage.getItem(V);e&&t.sendLifecycle({clientLifecycle:`restore-backup`,data:{backup:e}})}(await Promise.allSettled([d(),f(),p()])).some(e=>e.status===`rejected`)&&a?.track(`sdk_iframe_handshake_failed`,{reason:`asset_push`})}function ct(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent;return!!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1)}const K=ct();function lt(){return typeof navigator>`u`?!1:K?!0:/Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function ut(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return e.includes(`instagram`)||e.includes(`fban`)||e.includes(`fbav`)||e.includes(`facebook`)}const dt=ut();function ft(e){K&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:K&&e.startsWith(`http://`)?window.location.href=`x-safari-http://${e.slice(7)}`:window.location.href=`https://backend.frak.id/common/social?u=${encodeURIComponent(e)}`}function pt(e){return p(P(e))}const q={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function J(e){return e&&e in q?e:`eur`}function mt(e){return e?q[e]??q.eur:q.eur}function ht(e,t){let n=mt(t),r=J(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function gt(e){return e?`${e}Amount`:`eurAmount`}async function _t({config:e}){let t=vt(e),n=await Je({config:t});if(!n)return;let r=at({config:t,iframe:n});if(await r.waitForSetup,await r.waitForConnection)return r}function vt(e){let t=J(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}function yt({perCall:e,defaults:t,productUtmContent:n}){if(e===null)return;let r=e!==void 0,i=t!==void 0&&Object.keys(t).length>0;if(!r&&!i&&!(n!==void 0&&n!==``))return;let a={...t,...e??{}},o=n??e?.utmContent;return o!==void 0&&o!==``?a.utmContent=o:delete a.utmContent,a}var bt=t({DEEP_LINK_SCHEME:()=>H,FrakContextManager:()=>B,base64urlDecode:()=>P,base64urlEncode:()=>N,baseIframeProps:()=>W,clearAllCache:()=>S,compressJsonToB64:()=>fe,createIFrameFrakClient:()=>at,decompressJsonFromB64:()=>pt,findIframeInOpener:()=>Xe,formatAmount:()=>ht,generateSsoUrl:()=>pe,getBackendUrl:()=>w,getClientId:()=>g,getCurrencyAmountKey:()=>gt,getSupportedCurrency:()=>J,isIOS:()=>K,isInAppBrowser:()=>dt,isMobile:()=>lt,mergeAttribution:()=>yt,redirectToExternalBrowser:()=>ft,sdkConfigStore:()=>M,setupClient:()=>_t,ssoPopupFeatures:()=>he,ssoPopupName:()=>ge,trackEvent:()=>F,triggerDeepLinkWithFallback:()=>U,withCache:()=>x});async function xt(e,t,n){return await e.request({method:`frak_displayEmbeddedWallet`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function Y(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 St(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function Ct(e){if(typeof window>`u`)return;let t=g();if(!t)return;let n=await M.resolveMerchantId();if(!n)return;let r=`frak-identity-ensured-${n}`;if(!window.sessionStorage.getItem(r))try{let i=w();(await fetch(`${i}/user/identity/ensure`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":e,"x-frak-client-id":t},body:JSON.stringify({merchantId:n})})).ok&&window.sessionStorage.setItem(r,`1`)}catch{}}async function wt(e,t){return x(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:t?.cacheTime})}async function Tt(e,t){return x(()=>e.request({method:`frak_getMergeToken`}),{cacheKey:`frak_getMergeToken`,cacheTime:t?.cacheTime})}async function Et(e,t){return x(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:t?.cacheTime})}async function Dt(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function X(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t,{clientId:g()}]})}catch{}}function Ot(e,t,n){return L(t)?(F(e,`user_referred_started`,{referrerClientId:t.c,referrerWallet:t.w,walletStatus:n?.key}),X(e,{type:`arrival`,referrerClientId:t.c,referrerMerchantId:t.m,referrerWallet:t.w,referralTimestamp:t.t}),!0):Ce(t)?(F(e,`user_referred_started`,{referrer:t.r,walletStatus:n?.key}),X(e,{type:`arrival`,referrerWallet:t.r}),!0):!1}function kt(e,t){let n=g();return!n&&!t?null:{v:2,m:e,t:Math.floor(Date.now()/1e3),...n?{c:n}:{},...t?{w:t}:{}}}function At(e,t){return L(e)?e.w&&t?.wallet?ye(e.w,t.wallet):e.c?g()===e.c:!1:Ce(e)&&t?.wallet?ye(e.r,t.wallet):!1}function jt(e,{walletStatus:t,frakContext:n,options:r}){if(!n)return`no-referrer`;if(At(n,t))return`self-referral`;if(!Ot(e,n,t))return`no-referrer`;let i=L(n)?n.m:r?.merchantId,a=r?.alwaysAppendUrl&&i?kt(i,t?.wallet):null;return B.replaceUrl({url:window.location?.href,context:a}),F(e,`user_referred_completed`,{status:`success`}),`success`}async function Z(e,{options:t}={}){let n=B.parse({url:window.location.href}),r=await Pt(e);try{return jt(e,{walletStatus:r,frakContext:n,options:t})}catch{}}const Q=`frak:referral-success`;async function Mt(e){try{await Z(e)===`success`&&window.dispatchEvent(new Event(Q))}catch{}}async function Nt(e){if(typeof window>`u`)return;let t=window.sessionStorage.getItem(`frak-wallet-interaction-token`),n=g();if(!t&&!n)return;let r=e.merchantId??await M.resolveMerchantId();if(!r)return;let i={Accept:`application/json`,"Content-Type":`application/json`};t&&(i[`x-wallet-sdk-auth`]=t),n&&(i[`x-frak-client-id`]=n);let a=w();await fetch(`${a}/user/track/purchase`,{method:`POST`,headers:i,body:JSON.stringify({customerId:e.customerId,orderId:e.orderId,token:e.token,merchantId:r})})}function Pt(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(Ft(e,t),t));let n=new u,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{Ft(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function Ft(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),Ct(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function It(e,{metadata:t,login:n}){return $(e,{steps:{login:n??{}},metadata:t})}function $(e,t){function n(n){return $(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return $(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return $(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 Y(e,t,r)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function Lt(e,{tx:t,metadata:n}){return(await Y(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function Rt(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 zt(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 Y(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??Rt(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var Bt=t({REFERRAL_SUCCESS_EVENT:()=>Q,displayEmbeddedWallet:()=>xt,displayModal:()=>Y,displaySharingPage:()=>St,ensureIdentity:()=>Ct,getMerchantInformation:()=>wt,getMergeToken:()=>Tt,getUserReferralStatus:()=>Et,modalBuilder:()=>It,openSso:()=>_e,prepareSso:()=>Dt,processReferral:()=>jt,referralInteraction:()=>Z,sendInteraction:()=>X,sendTransaction:()=>Lt,setupReferral:()=>Mt,siweAuthenticate:()=>zt,trackPurchaseStatus:()=>Nt,watchWalletStatus:()=>Pt});async function Vt(e,t,n){window.FrakSetup?.client&&await St(window.FrakSetup.client,{...n?.link&&{link:n.link},...n?.products?.length&&{products:n.products},...e&&{metadata:{targetInteraction:e}}},t)}function Ht(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function Ut(e){if(!e)return null;if(Array.isArray(e))return e;if(typeof e!=`string`)return null;try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function Wt(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.title==`string`?t.title.trim():``;if(n===``)return null;let r={title:n};return typeof t.imageUrl==`string`&&Ht(t.imageUrl)&&(r.imageUrl=t.imageUrl),typeof t.link==`string`&&Ht(t.link)&&(r.link=t.link),typeof t.utmContent==`string`&&t.utmContent!==``&&(r.utmContent=t.utmContent),r}function Gt(e){let t=Ut(e);if(!t)return;let n=[];for(let e of t){let t=Wt(e);t&&n.push(t)}return n.length>0?n:void 0}function Kt(e){if(!e)return;let t;try{t=pt(e)}catch{return}if(t!==null)return Gt(t)}const qt=`frak:client`;function Jt(){let e=new CustomEvent(qt);window.dispatchEvent(e)}function Yt(e,t){if(window.FrakSetup?.client&&e===`add`){t();return}(e===`add`?window.addEventListener:window.removeEventListener)(qt,t,!1)}function Xt(){return window.FrakSetup.core={...bt,...Bt},window.FrakSetup?.client?Promise.resolve():x(()=>Zt(),{cacheKey:`frak-sdk-init`,cacheTime:1/0}).catch(e=>{F(window.FrakSetup?.client,`sdk_init_failed`,{reason:e instanceof Error?e.message:typeof e==`string`?e:`unknown`,config_missing:!window.FrakSetup?.config})})}async function Zt(){if(!window.FrakSetup?.config)throw Error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`);let e=await _t({config:window.FrakSetup.config});if(!e)throw Error(`[Frak SDK] Failed to create client`);window.FrakSetup.client=e,Jt(),Mt(e),Qt()}function Qt(){let e=new URL(window.location.href);if(e.searchParams.get(`frakAction`)!==`share`)return;let t=e.searchParams.get(`link`)??void 0,n=e.searchParams.get(`placement`)??void 0,r=Kt(e.searchParams.get(`products`));e.searchParams.delete(`frakAction`),e.searchParams.delete(`link`),e.searchParams.delete(`placement`),e.searchParams.delete(`products`),window.history.replaceState({},``,e.toString()),Vt(void 0,n,{link:t,products:r})}o.injectBase(`shared`,n),o.injectBase(`fouce`,`frak-button-share:not(:defined), frak-button-wallet:not(:defined), frak-open-in-app:not(:defined), frak-post-purchase:not(:defined), frak-banner:not(:defined) { display: none !important; }`),s(Xt);const $t={"button-share":()=>import(`./ButtonShare.C3yHDv8Z.js`),"button-wallet":()=>import(`./ButtonWallet.B0buPR_z.js`),"open-in-app":()=>import(`./OpenInAppButton.Dgb-qhM8.js`),"post-purchase":()=>import(`./PostPurchase.BYxnAEyn.js`),banner:()=>import(`./Banner.CcOWT4lZ.js`)},en=new MutationObserver(e=>{for(let{addedNodes:t}of e)for(let e of Array.from(t))e.nodeType===Node.ELEMENT_NODE&&tn(e)});async function tn(e){let t=e instanceof Element?e.tagName.toLowerCase():``,n=t?.startsWith(`frak-`),r=Array.from(e.querySelectorAll(`:not(:defined)`)).map(e=>e.tagName.toLowerCase()).filter(e=>e.startsWith(`frak-`));n&&!customElements.get(t)&&r.push(t);let i=[...new Set(r)];await Promise.allSettled(i.map(e=>nn(e)))}async function nn(e){if(customElements.get(e))return Promise.resolve();try{let t=e.replace(/^frak-/i,``);if(!(t in $t))throw Error(`Component ${e} is not supported.`);await $t[t]()}catch{}}tn(document.body),en.observe(document.documentElement,{subtree:!0,childList:!0});export{s as C,l as S,n as T,H as _,Nt as a,F as b,wt as c,ft as d,ht as f,U as g,J as h,Vt as i,xt as l,lt as m,Yt as n,Et as o,gt as p,Gt as r,Tt as s,Xt as t,Q as u,dt as v,o as w,c as x,M as y};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
package/dist/banner.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as registerWebComponent, i as useClientReady, t as usePlacement } from "./usePlacement-
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, t as usePlacement } from "./usePlacement-5kbU3BKj.js";
|
|
2
2
|
import { t as useGlobalComponents } from "./useGlobalComponents-mSs9unyN.js";
|
|
3
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-
|
|
3
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-C8giLInY.js";
|
|
4
4
|
import { t as useReward } from "./useReward-ClVShg45.js";
|
|
5
5
|
import { a as ExternalLinkIcon, i as LogoFrakWithName, n as cssSource$3, o as CloseCircleIcon, r as WarningIcon, t as GiftIcon } from "./GiftIcon-BIp9FTJs.js";
|
|
6
6
|
import { isInAppBrowser, redirectToExternalBrowser, trackEvent } from "@frak-labs/core-sdk";
|
package/dist/buttonShare.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as registerWebComponent, i as useClientReady, s as
|
|
2
|
-
import { t as
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, s as openSharingPage, t as usePlacement } from "./usePlacement-5kbU3BKj.js";
|
|
2
|
+
import { t as openEmbeddedWallet } from "./embeddedWallet-By3_p5Xc.js";
|
|
3
3
|
import { t as useGlobalComponents } from "./useGlobalComponents-mSs9unyN.js";
|
|
4
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-
|
|
4
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-C8giLInY.js";
|
|
5
5
|
import { t as applyRewardPlaceholder } from "./formatReward-Cf2KpA3x.js";
|
|
6
6
|
import { t as useReward } from "./useReward-ClVShg45.js";
|
|
7
7
|
import { trackEvent } from "@frak-labs/core-sdk";
|
package/dist/buttonWallet.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { a as registerWebComponent, i as useClientReady, n as buildStyleContent,
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, n as buildStyleContent, t as usePlacement } from "./usePlacement-5kbU3BKj.js";
|
|
2
|
+
import { t as openEmbeddedWallet } from "./embeddedWallet-By3_p5Xc.js";
|
|
2
3
|
import { t as useReward } from "./useReward-ClVShg45.js";
|
|
3
4
|
import { useEffect, useMemo, useState } from "preact/hooks";
|
|
4
5
|
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
@@ -20,6 +21,21 @@ function GiftIcon(props) {
|
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
//#endregion
|
|
24
|
+
//#region src/utils/browser/safeVibrate.ts
|
|
25
|
+
/**
|
|
26
|
+
* Attempt to vibrate the device
|
|
27
|
+
*/
|
|
28
|
+
function safeVibrate() {
|
|
29
|
+
if ("vibrate" in navigator) navigator.vibrate(10);
|
|
30
|
+
else console.log("Vibration not supported");
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/components/ButtonWallet/utils.ts
|
|
34
|
+
function openWalletModal(targetInteraction, placement) {
|
|
35
|
+
safeVibrate();
|
|
36
|
+
openEmbeddedWallet(targetInteraction, placement);
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
23
39
|
//#region src/components/ButtonWallet/ButtonWallet.tsx
|
|
24
40
|
const componentCss = `
|
|
25
41
|
.button {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { displayEmbeddedWallet } from "@frak-labs/core-sdk/actions";
|
|
2
|
+
//#region src/actions/embeddedWallet.ts
|
|
3
|
+
async function openEmbeddedWallet(targetInteraction, placement) {
|
|
4
|
+
if (!window.FrakSetup?.client) {
|
|
5
|
+
console.error("Frak client not found");
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const modalWalletConfig = window.FrakSetup?.modalWalletConfig ?? {};
|
|
9
|
+
await displayEmbeddedWallet(window.FrakSetup.client, targetInteraction ? {
|
|
10
|
+
...modalWalletConfig,
|
|
11
|
+
metadata: {
|
|
12
|
+
...modalWalletConfig.metadata,
|
|
13
|
+
targetInteraction
|
|
14
|
+
}
|
|
15
|
+
} : modalWalletConfig, placement);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { openEmbeddedWallet as t };
|
package/dist/openInApp.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as registerWebComponent, i as useClientReady, t as usePlacement } from "./usePlacement-
|
|
2
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, t as usePlacement } from "./usePlacement-5kbU3BKj.js";
|
|
2
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-C8giLInY.js";
|
|
3
3
|
import { DEEP_LINK_SCHEME, isMobile, trackEvent, triggerDeepLinkWithFallback } from "@frak-labs/core-sdk";
|
|
4
4
|
import { useMemo } from "preact/hooks";
|
|
5
5
|
import { jsx } from "preact/jsx-runtime";
|
package/dist/postPurchase.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { a as registerWebComponent, i as useClientReady, t as usePlacement } from "./usePlacement-
|
|
2
|
-
import { t as openSharingPage } from "./sharingPage-D6fQEXV9.js";
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, o as sanitizeProductList, s as openSharingPage, t as usePlacement } from "./usePlacement-5kbU3BKj.js";
|
|
3
2
|
import { t as useGlobalComponents } from "./useGlobalComponents-mSs9unyN.js";
|
|
4
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-
|
|
3
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-C8giLInY.js";
|
|
5
4
|
import { n as formatEstimatedReward, t as applyRewardPlaceholder } from "./formatReward-Cf2KpA3x.js";
|
|
6
5
|
import { i as LogoFrakWithName, n as cssSource$2, t as GiftIcon } from "./GiftIcon-BIp9FTJs.js";
|
|
7
6
|
import { trackEvent } from "@frak-labs/core-sdk";
|
|
@@ -112,67 +111,6 @@ var imageWrapper = "PostPurchase_imageWrapper__5fv5lh9";
|
|
|
112
111
|
var message = "PostPurchase_message__5fv5lh5";
|
|
113
112
|
const cssSource = cssSource$1;
|
|
114
113
|
//#endregion
|
|
115
|
-
//#region src/components/PostPurchase/products.ts
|
|
116
|
-
/**
|
|
117
|
-
* Whether `value` is a syntactically valid URL with an `http(s):` scheme.
|
|
118
|
-
*
|
|
119
|
-
* Used to gate `imageUrl` / `link` fields coming from the public `products`
|
|
120
|
-
* prop — the listener-side sharing-page builder calls `new URL(...)` on the
|
|
121
|
-
* incoming product link, and a `javascript:` URL would be a XSS sink in any
|
|
122
|
-
* consumer that binds the value to an `href`.
|
|
123
|
-
*/
|
|
124
|
-
function isHttpUrl(value) {
|
|
125
|
-
try {
|
|
126
|
-
const parsed = new URL(value);
|
|
127
|
-
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
128
|
-
} catch {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Coerce a raw `products` prop value into a candidate array suitable for
|
|
134
|
-
* per-item normalisation, or null when it cannot be reduced to one.
|
|
135
|
-
*
|
|
136
|
-
* Surfaces that set the prop via the JS property (`el.products = [...]`)
|
|
137
|
-
* deliver a real array; surfaces that bind it as an HTML attribute
|
|
138
|
-
* (WP / Magento server-render) deliver a JSON-stringified array. Anything
|
|
139
|
-
* else (truthy non-array non-string, JSON parse failure, JSON that decodes
|
|
140
|
-
* to a non-array) is treated as "no products" so the share still works
|
|
141
|
-
* without the product card section.
|
|
142
|
-
*/
|
|
143
|
-
function coerceProductCandidates(products) {
|
|
144
|
-
if (!products) return null;
|
|
145
|
-
if (Array.isArray(products)) return products;
|
|
146
|
-
if (typeof products !== "string") return null;
|
|
147
|
-
try {
|
|
148
|
-
const parsed = JSON.parse(products);
|
|
149
|
-
return Array.isArray(parsed) ? parsed : null;
|
|
150
|
-
} catch {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Normalise one untrusted candidate into a {@link SharingPageProduct}, or
|
|
156
|
-
* return null when the candidate has no usable title.
|
|
157
|
-
*
|
|
158
|
-
* The `products` prop is a public API boundary (merchants can set it
|
|
159
|
-
* server-side via WP/Magento or imperatively from arbitrary JS). Each entry
|
|
160
|
-
* is validated structurally so a malformed `link` reaching `new URL(...)`
|
|
161
|
-
* downstream would not crash the sharing-page builder, and so a
|
|
162
|
-
* `javascript:` URL cannot slip through as `imageUrl` / `link`.
|
|
163
|
-
*/
|
|
164
|
-
function normalizeProductCandidate(candidate) {
|
|
165
|
-
if (!candidate || typeof candidate !== "object") return null;
|
|
166
|
-
const item = candidate;
|
|
167
|
-
const title = typeof item.title === "string" ? item.title.trim() : "";
|
|
168
|
-
if (title === "") return null;
|
|
169
|
-
const entry = { title };
|
|
170
|
-
if (typeof item.imageUrl === "string" && isHttpUrl(item.imageUrl)) entry.imageUrl = item.imageUrl;
|
|
171
|
-
if (typeof item.link === "string" && isHttpUrl(item.link)) entry.link = item.link;
|
|
172
|
-
if (typeof item.utmContent === "string" && item.utmContent !== "") entry.utmContent = item.utmContent;
|
|
173
|
-
return entry;
|
|
174
|
-
}
|
|
175
|
-
//#endregion
|
|
176
114
|
//#region src/components/PostPurchase/PostPurchase.tsx
|
|
177
115
|
/**
|
|
178
116
|
* Given referral status and merchant info, compute the display variant
|
|
@@ -303,16 +241,7 @@ function PostPurchase({ customerId, orderId, token, sharingUrl, merchantId, plac
|
|
|
303
241
|
placementId,
|
|
304
242
|
context?.reward
|
|
305
243
|
]);
|
|
306
|
-
const parsedProducts = useMemo(() =>
|
|
307
|
-
const candidates = coerceProductCandidates(products);
|
|
308
|
-
if (!candidates) return void 0;
|
|
309
|
-
const sanitized = [];
|
|
310
|
-
for (const candidate of candidates) {
|
|
311
|
-
const entry = normalizeProductCandidate(candidate);
|
|
312
|
-
if (entry) sanitized.push(entry);
|
|
313
|
-
}
|
|
314
|
-
return sanitized.length > 0 ? sanitized : void 0;
|
|
315
|
-
}, [products]);
|
|
244
|
+
const parsedProducts = useMemo(() => sanitizeProductList(products), [products]);
|
|
316
245
|
const handleClick = useCallback(() => {
|
|
317
246
|
if (!resolvedVariant) return;
|
|
318
247
|
trackEvent(window.FrakSetup?.client, "post_purchase_clicked", {
|
|
@@ -1,38 +1,126 @@
|
|
|
1
1
|
import register from "preact-custom-element";
|
|
2
2
|
import * as coreSdkIndex from "@frak-labs/core-sdk";
|
|
3
|
-
import { sdkConfigStore, setupClient, trackEvent, withCache } from "@frak-labs/core-sdk";
|
|
3
|
+
import { decompressJsonFromB64, sdkConfigStore, setupClient, trackEvent, withCache } from "@frak-labs/core-sdk";
|
|
4
4
|
import * as coreSdkActions from "@frak-labs/core-sdk/actions";
|
|
5
|
-
import {
|
|
5
|
+
import { displaySharingPage } from "@frak-labs/core-sdk/actions";
|
|
6
6
|
import { useEffect, useMemo, useState } from "preact/hooks";
|
|
7
|
-
//#region src/actions/
|
|
8
|
-
async function
|
|
7
|
+
//#region src/actions/sharingPage.ts
|
|
8
|
+
async function openSharingPage(targetInteraction, placement, options) {
|
|
9
9
|
if (!window.FrakSetup?.client) {
|
|
10
10
|
console.error("Frak client not found");
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
...
|
|
16
|
-
metadata: {
|
|
17
|
-
|
|
18
|
-
targetInteraction
|
|
19
|
-
}
|
|
20
|
-
} : modalWalletConfig, placement);
|
|
13
|
+
await displaySharingPage(window.FrakSetup.client, {
|
|
14
|
+
...options?.link && { link: options.link },
|
|
15
|
+
...options?.products?.length && { products: options.products },
|
|
16
|
+
...targetInteraction && { metadata: { targetInteraction } }
|
|
17
|
+
}, placement);
|
|
21
18
|
}
|
|
22
19
|
//#endregion
|
|
23
|
-
//#region src/utils/
|
|
20
|
+
//#region src/utils/sharingPageProducts.ts
|
|
24
21
|
/**
|
|
25
|
-
*
|
|
22
|
+
* Whether `value` is a syntactically valid URL with an `http(s):` scheme.
|
|
23
|
+
*
|
|
24
|
+
* Used to gate `imageUrl` / `link` fields coming from untrusted inputs (the
|
|
25
|
+
* public `products` prop on `<frak-post-purchase>`, decoded query params for
|
|
26
|
+
* Klaviyo / email share links, etc.) — the listener-side sharing-page builder
|
|
27
|
+
* calls `new URL(...)` on the incoming product link, and a `javascript:` URL
|
|
28
|
+
* would be a XSS sink in any consumer that binds the value to an `href`.
|
|
26
29
|
*/
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
function isHttpUrl(value) {
|
|
31
|
+
try {
|
|
32
|
+
const parsed = new URL(value);
|
|
33
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
34
|
+
} catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
30
37
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Coerce a raw `products` value into a candidate array suitable for
|
|
40
|
+
* per-item normalisation, or null when it cannot be reduced to one.
|
|
41
|
+
*
|
|
42
|
+
* Accepts:
|
|
43
|
+
* - Real arrays (JS-property surface, decompressed query payloads).
|
|
44
|
+
* - JSON-stringified arrays (HTML-attribute surface — WP / Magento
|
|
45
|
+
* server-render delivers attribute values as raw strings).
|
|
46
|
+
*
|
|
47
|
+
* Anything else (non-array non-string, JSON parse failure, JSON that
|
|
48
|
+
* decodes to a non-array) is treated as "no products" so the share still
|
|
49
|
+
* works without the product card section.
|
|
50
|
+
*/
|
|
51
|
+
function coerceProductCandidates(products) {
|
|
52
|
+
if (!products) return null;
|
|
53
|
+
if (Array.isArray(products)) return products;
|
|
54
|
+
if (typeof products !== "string") return null;
|
|
55
|
+
try {
|
|
56
|
+
const parsed = JSON.parse(products);
|
|
57
|
+
return Array.isArray(parsed) ? parsed : null;
|
|
58
|
+
} catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Normalise one untrusted candidate into a {@link SharingPageProduct}, or
|
|
64
|
+
* return null when the candidate has no usable title.
|
|
65
|
+
*
|
|
66
|
+
* The `products` payload is a public API boundary — merchants can set it
|
|
67
|
+
* server-side via WP / Magento, imperatively from arbitrary JS, or via
|
|
68
|
+
* email-template query params built by Klaviyo. Each entry is validated
|
|
69
|
+
* structurally so a malformed `link` reaching `new URL(...)` downstream
|
|
70
|
+
* would not crash the sharing-page builder, and so a `javascript:` URL
|
|
71
|
+
* cannot slip through as `imageUrl` / `link`.
|
|
72
|
+
*/
|
|
73
|
+
function normalizeProductCandidate(candidate) {
|
|
74
|
+
if (!candidate || typeof candidate !== "object") return null;
|
|
75
|
+
const item = candidate;
|
|
76
|
+
const title = typeof item.title === "string" ? item.title.trim() : "";
|
|
77
|
+
if (title === "") return null;
|
|
78
|
+
const entry = { title };
|
|
79
|
+
if (typeof item.imageUrl === "string" && isHttpUrl(item.imageUrl)) entry.imageUrl = item.imageUrl;
|
|
80
|
+
if (typeof item.link === "string" && isHttpUrl(item.link)) entry.link = item.link;
|
|
81
|
+
if (typeof item.utmContent === "string" && item.utmContent !== "") entry.utmContent = item.utmContent;
|
|
82
|
+
return entry;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Pipe `coerceProductCandidates` + `normalizeProductCandidate` over an
|
|
86
|
+
* untrusted value and return a non-empty {@link SharingPageProduct}[] or
|
|
87
|
+
* `undefined` when nothing usable came out.
|
|
88
|
+
*
|
|
89
|
+
* The undefined sentinel is what `openSharingPage` / `displaySharingPage`
|
|
90
|
+
* expect when the caller has no products to show — the sharing page just
|
|
91
|
+
* skips the product card section.
|
|
92
|
+
*/
|
|
93
|
+
function sanitizeProductList(input) {
|
|
94
|
+
const candidates = coerceProductCandidates(input);
|
|
95
|
+
if (!candidates) return void 0;
|
|
96
|
+
const sanitized = [];
|
|
97
|
+
for (const candidate of candidates) {
|
|
98
|
+
const entry = normalizeProductCandidate(candidate);
|
|
99
|
+
if (entry) sanitized.push(entry);
|
|
100
|
+
}
|
|
101
|
+
return sanitized.length > 0 ? sanitized : void 0;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Decode a `products` URL query param produced by
|
|
105
|
+
* `compressJsonToB64(productsArray)` — the encoding Klaviyo (and any
|
|
106
|
+
* other email tool) uses when embedding the product list of an order
|
|
107
|
+
* confirmation into a Frak share CTA.
|
|
108
|
+
*
|
|
109
|
+
* The result is run through `sanitizeProductList` so every link / image
|
|
110
|
+
* URL is structurally validated before reaching `new URL(...)` downstream.
|
|
111
|
+
* Malformed / tampered payloads degrade gracefully to `undefined` — the
|
|
112
|
+
* share still works, just without the product card section.
|
|
113
|
+
*/
|
|
114
|
+
function decodeProductsParam(value) {
|
|
115
|
+
if (!value) return void 0;
|
|
116
|
+
let decoded;
|
|
117
|
+
try {
|
|
118
|
+
decoded = decompressJsonFromB64(value);
|
|
119
|
+
} catch {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (decoded === null) return void 0;
|
|
123
|
+
return sanitizeProductList(decoded);
|
|
36
124
|
}
|
|
37
125
|
//#endregion
|
|
38
126
|
//#region src/bootstrap/clientReady.ts
|
|
@@ -97,15 +185,41 @@ async function doInit() {
|
|
|
97
185
|
handleActionQueryParam();
|
|
98
186
|
}
|
|
99
187
|
/**
|
|
100
|
-
* Check the query param
|
|
188
|
+
* Check the query param for an auto-opening of the Frak sharing page.
|
|
189
|
+
*
|
|
190
|
+
* Supported params (all optional except `frakAction`):
|
|
191
|
+
* - `frakAction=share` triggers the auto-open.
|
|
192
|
+
* - `link` overrides the URL the sharing page generates outbound shares for.
|
|
193
|
+
* When omitted, the listener falls back to the merchant domain.
|
|
194
|
+
* - `products` is a base64-encoded compressed JSON payload of
|
|
195
|
+
* `SharingPageProduct[]` — produced by `compressJsonToB64(productsArray)`
|
|
196
|
+
* on the sender side (e.g. a Klaviyo email template). Used by
|
|
197
|
+
* post-purchase emails to surface the items the customer just bought as
|
|
198
|
+
* product cards on the sharing page.
|
|
199
|
+
* - `placement` lets the caller scope backend-driven CSS / config to a
|
|
200
|
+
* specific placement (mirrors the prop on the components).
|
|
201
|
+
*
|
|
202
|
+
* The four params are stripped from the URL via `history.replaceState` as
|
|
203
|
+
* soon as they are read, so refreshes / shares of the current URL do not
|
|
204
|
+
* re-trigger the auto-open. Matches the `fmt` (merge token) and `sso`
|
|
205
|
+
* cleanup patterns elsewhere in the SDK.
|
|
101
206
|
*/
|
|
102
207
|
function handleActionQueryParam() {
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
208
|
+
const url = new URL(window.location.href);
|
|
209
|
+
if (url.searchParams.get("frakAction") !== "share") return;
|
|
210
|
+
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");
|
|
218
|
+
window.history.replaceState({}, "", url.toString());
|
|
219
|
+
openSharingPage(void 0, placement, {
|
|
220
|
+
link,
|
|
221
|
+
products
|
|
222
|
+
});
|
|
109
223
|
}
|
|
110
224
|
//#endregion
|
|
111
225
|
//#region src/utils/browser/onDocumentReady.ts
|
|
@@ -250,4 +364,4 @@ function usePlacement(placementId) {
|
|
|
250
364
|
return useMemo(() => placementId ? getPlacement(placementId) : void 0, [placementId, configVersion]);
|
|
251
365
|
}
|
|
252
366
|
//#endregion
|
|
253
|
-
export { registerWebComponent as a, useClientReady as i, buildStyleContent as n,
|
|
367
|
+
export { registerWebComponent as a, useClientReady as i, buildStyleContent as n, sanitizeProductList as o, lightDomBaseCss as r, openSharingPage as s, usePlacement as t };
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "https://twitter.com/QNivelais"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
|
-
"version": "1.0.
|
|
14
|
+
"version": "1.0.6",
|
|
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,7 +86,7 @@
|
|
|
86
86
|
"publish": "echo 'Publishing components...'"
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"@frak-labs/core-sdk": "1.1.
|
|
89
|
+
"@frak-labs/core-sdk": "1.1.1",
|
|
90
90
|
"@frak-labs/frame-connector": "0.2.0",
|
|
91
91
|
"preact": "^10.29.0",
|
|
92
92
|
"preact-custom-element": "^4.6.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as e,i as t}from"./loader.js";import{c as n,d as r,i,o as a,t as o,u as s}from"./usePlacement.BgMXY5CX.js";import{t as c}from"./useGlobalComponents.TG9kIYSc.js";import{t as l}from"./useLightDomStyles.tjNBKcOr.js";import{t as u}from"./formatReward.B1ZyoceC.js";import{t as d}from"./useReward.B530suzR.js";import{t as f}from"./sharingPage.BYsqcN9O.js";function p({placement:r,text:p=`Share and earn!`,classname:m=``,useReward:h,noRewardText:g,targetInteraction:_,clickAction:v,preview:y}){let b=!!y,x=o(r),S=c(),C=x?.components?.buttonShare??S?.buttonShare;l(`frak-button-share`,r,C?.css);let w=a(()=>x?.targetInteraction===void 0?_:x.targetInteraction,[x?.targetInteraction,_]),T=C?.text??p,E=C?.noRewardText??g,D=a(()=>C?.useReward??h===!0,[C?.useReward,h]),O=a(()=>C?.clickAction??v??`sharing-page`,[C?.clickAction,v]),{shouldRender:k,isHidden:A,isClientReady:j}=i(),{reward:M}=d(D&&j,w),N=a(()=>D?M?T.includes(`{REWARD}`)?u(T,M):`${T} ${M}`:E??u(T,void 0):T,[D,T,E,M]),P=n(()=>{if(!b){if(e(window.FrakSetup.client,`share_button_clicked`,{placement:r,target_interaction:w,has_reward:!!M,click_action:O}),O===`embedded-wallet`){t(w,r);return}f(w,r)}},[b,O,w,r,M]);if(!b&&(!k||A))return null;let F=[`button`,`button__fadeIn`,m].filter(Boolean).join(` `);return s(`button`,{type:`button`,disabled:!b&&!j,class:F,onClick:P,children:N})}r(p,`frak-button-share`,[`text`,`placement`,`classname`,`clickAction`,`useReward`,`noRewardText`,`targetInteraction`,`preview`],{shadow:!1});export{p as ButtonShare};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./loader.js";import{d as t,i as n,l as r,m as i,n as a,o,s,t as c,u as l}from"./usePlacement.BgMXY5CX.js";import{t as u}from"./useReward.B530suzR.js";function d(e){return l(`svg`,{fill:`none`,height:`1em`,viewBox:`0 0 28 28`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[l(`title`,{children:`Gift icon`}),l(`path`,{d:`m23.1427 13.9999v11.4285h-18.2857v-11.4285m9.1429 11.4285v-17.14282m0 0h-5.1429c-.75776 0-1.48448-.30102-2.0203-.83684s-.83684-1.26255-.83684-2.02031.30102-1.48448.83684-2.0203 1.26254-.83684 2.0203-.83684c4 0 5.1429 5.71429 5.1429 5.71429zm0 0h5.1428c.7578 0 1.4845-.30102 2.0203-.83684s.8369-1.26255.8369-2.02031-.3011-1.48448-.8369-2.0203-1.2625-.83684-2.0203-.83684c-4 0-5.1428 5.71429-5.1428 5.71429zm-11.42861 0h22.85711v5.71432h-22.85711z`,stroke:`#fff`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]})}function f({placement:t,classname:f=``,useReward:p,targetInteraction:m}){let h=c(t),g=o(()=>h?.targetInteraction===void 0?m:h.targetInteraction,[h?.targetInteraction,m]),_=o(()=>p===!0,[p]),{shouldRender:v,isHidden:y,isClientReady:b}=n(),{reward:x}=u(_&&b,g),[S,C]=s(`right`);if(r(()=>{let e=h?.components?.buttonWallet?.position,t=window.FrakSetup?.modalWalletConfig?.metadata?.position;C(e??t??`right`)},[h?.components?.buttonWallet?.position]),!v||y)return null;let w=[`button`,`button__fadeIn`,S===`left`?`button__left`:`button__right`,f].filter(Boolean).join(` `);return l(i,{children:[l(`style`,{children:a(`
|
|
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
|
-
`,h?.components?.buttonWallet?.css)}),l(`button`,{type:`button`,"aria-label":`Open wallet`,part:`button`,disabled:!b,class:w,onClick:()=>{e(g,t)},children:[l(d,{}),x&&l(`span`,{class:`reward`,children:x})]})]})}t(f,`frak-button-wallet`,[`placement`,`classname`,`useReward`,`targetInteraction`],{shadow:!0});export{f as ButtonWallet};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import{S as e,T as t,a as n,b as r,l as i,s as a,x as o}from"./loader.js";import{a as s,c,d as l,i as ee,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 _}from"./useGlobalComponents.TG9kIYSc.js";import{t as v}from"./useLightDomStyles.tjNBKcOr.js";import{n as te,t as y}from"./formatReward.B1ZyoceC.js";import{t as b}from"./sharingPage.BYsqcN9O.js";var ne=`PostPurchase_card__5fv5lh0`,re=`PostPurchase_cardLayout__5fv5lh1`,ie=`PostPurchase_cardLeft__5fv5lh2`,ae=`PostPurchase_cardRight__5fv5lh3`,oe=`PostPurchase_cta__5fv5lh6 sharedBaseCss_buttonReset__7cswil0`,se=`PostPurchase_customImage__5fv5lha`,ce=`PostPurchase_frakLogo__5fv5lhb`,le=`PostPurchase_giftIcon__5fv5lh8`,ue=`PostPurchase_icon__5fv5lh7`,de=`PostPurchase_imageWrapper__5fv5lh9`,fe=`PostPurchase_message__5fv5lh5`;function x(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function pe(e){if(!e)return null;if(Array.isArray(e))return e;if(typeof e!=`string`)return null;try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function S(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.title==`string`?t.title.trim():``;if(n===``)return null;let r={title:n};return typeof t.imageUrl==`string`&&x(t.imageUrl)&&(r.imageUrl=t.imageUrl),typeof t.link==`string`&&x(t.link)&&(r.link=t.link),typeof t.utmContent==`string`&&t.utmContent!==``&&(r.utmContent=t.utmContent),r}function C(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 w({customerId:l,orderId:x,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}=ee(),H=p(D);v(`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,me]=f(null),[W,G]=f(!1);u(()=>{R||!V||!l||!x||!w||n({customerId:l,orderId:x,token:w,merchantId:E}).catch(()=>{})},[R,V,l,x,w,E]),u(()=>{if(R||!V||W)return;let t=window.FrakSetup?.client;t&&Promise.all([a(t),i(t)]).then(([e,t])=>{G(!0),me(C(e,t))}).catch(t=>{if(t instanceof e&&t.code===o.configError){G(!0);return}})},[R,V,W]);let K=s(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 te(U.reward,e)},[U?.reward]),he=_(),X=H?.components?.postPurchase??he?.postPurchase,Z=A??X?.badgeText,Q=d(()=>({message:q===`referee`?Y?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?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?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(()=>{let e=pe(I);if(!e)return;let t=[];for(let n of e){let e=S(n);e&&t.push(e)}return t.length>0?t:void 0},[I]),ge=c(()=>{q&&(r(window.FrakSetup?.client,`post_purchase_clicked`,{placement:D,variant:q}),b(void 0,D,{link:J,products:$}))},[q,D,J,$]);return!q||!R&&(!z||B||!U)?null:m(`div`,{className:[ne,O].filter(Boolean).join(` `),children:m(`div`,{class:re,children:[m(`div`,{class:ie,children:[Z&&m(`span`,{class:`PostPurchase_badge__5fv5lh4`,children:Z}),m(`p`,{class:fe,children:Q.message}),m(`button`,{type:`button`,className:`${oe} button`,disabled:!R&&!V,onClick:R?void 0:ge,children:[Q.cta,m(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:`${ue} 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:ae,children:[L?m(`span`,{class:de,children:m(`img`,{src:L,alt:``,class:se})}):m(g,{className:le,width:80,height:80}),m(h,{className:ce,width:42,height:24})]})]})})}l(w,`frak-post-purchase`,[`customerId`,`orderId`,`token`,`sharingUrl`,`merchantId`,`placement`,`classname`,`variant`,`badgeText`,`referrerText`,`refereeText`,`ctaText`,`products`,`preview`,`previewVariant`,`imageUrl`],{shadow:!1});export{w as PostPurchase};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./loader.js";async function t(t,n,r){window.FrakSetup?.client&&await e(window.FrakSetup.client,{...r?.link&&{link:r.link},...r?.products?.length&&{products:r.products},...t&&{metadata:{targetInteraction:t}}},n)}export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as e,l 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:t},r,i){let s=(i?t.filter(e=>e.interactionTypeKey===i):t).map(e=>e.referrer).filter(e=>e!==void 0);if(s.length===0)return;let c=n(e(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(e,n){let[a,o]=i(void 0);return r(()=>{if(!e)return;let r=window.FrakSetup?.client;r&&t(r).then(e=>{let t=r.config.metadata?.currency,i=s(e,t,n);i&&o(i)}).catch(()=>{})},[e,n]),{reward:a}}export{c as t};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { displaySharingPage } from "@frak-labs/core-sdk/actions";
|
|
2
|
-
//#region src/actions/sharingPage.ts
|
|
3
|
-
async function openSharingPage(targetInteraction, placement, options) {
|
|
4
|
-
if (!window.FrakSetup?.client) {
|
|
5
|
-
console.error("Frak client not found");
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
await displaySharingPage(window.FrakSetup.client, {
|
|
9
|
-
...options?.link && { link: options.link },
|
|
10
|
-
...options?.products?.length && { products: options.products },
|
|
11
|
-
...targetInteraction && { metadata: { targetInteraction } }
|
|
12
|
-
}, placement);
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
export { openSharingPage as t };
|