@frak-labs/components 1.2.3-beta.9b2f57a0 → 1.2.4-beta.683f5bca

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +28 -0
  2. package/cdn/Ambassador.D7jdEkz6.js +313 -0
  3. package/cdn/Banner.BnzLkajr.js +183 -0
  4. package/cdn/ButtonShare.B4MdZ4eH.js +1 -0
  5. package/cdn/ButtonWallet.D9B0abq9.js +40 -0
  6. package/cdn/GiftIcon.Be-UU58r.js +1 -0
  7. package/cdn/OpenInAppButton.BaRZ25xH.js +1 -0
  8. package/cdn/PostPurchase.Cl54N_nH.js +89 -0
  9. package/cdn/components.js +1 -1
  10. package/cdn/jsxRuntime.module.CgbYebLx.js +58 -0
  11. package/cdn/loader.js +1 -1
  12. package/cdn/qr.Bdg4-2EI.js +5 -0
  13. package/cdn/{rewards.0JylBHNY.js → rewards.B_p05JY_.js} +1 -1
  14. package/cdn/useGlobalComponents.da05dAlQ.js +1 -0
  15. package/cdn/useLightDomStyles.CkTNHin8.js +1 -0
  16. package/cdn/usePlacement.b__OilKu.js +1 -0
  17. package/cdn/useReward.Duy0EWvi.js +1 -0
  18. package/dist/{GiftIcon-BmGGodb2.js → GiftIcon-DNqgjTjb.js} +1 -4
  19. package/dist/ambassador.d.ts +165 -0
  20. package/dist/ambassador.js +1660 -0
  21. package/dist/banner.js +7 -5
  22. package/dist/buttonShare.js +5 -4
  23. package/dist/buttonWallet.js +3 -2
  24. package/dist/i18n/defaults.d.ts +70 -9
  25. package/dist/i18n/defaults.js +123 -9
  26. package/dist/openInApp.js +3 -2
  27. package/dist/postPurchase.js +6 -4
  28. package/dist/sharedBaseCss.css-ChRUA1zY.js +5 -0
  29. package/dist/{usePlacement-iFDQqtJn.js → sharedCss-C9ZC0Pyc.js} +9 -20
  30. package/dist/{useGlobalComponents-Cj7uGBwD.js → useGlobalComponents-BL-5N4ks.js} +1 -1
  31. package/dist/{useLightDomStyles-D7bYu-ew.js → useLightDomStyles-DWfNMBBn.js} +1 -1
  32. package/dist/usePlacement-DHASvxJw.js +21 -0
  33. package/dist/{useReward-k7RF3DhH.js → useReward-DEhiMfgl.js} +8 -2
  34. package/package.json +14 -5
  35. package/cdn/Banner.DUI-0KQP.js +0 -183
  36. package/cdn/ButtonShare.bYtZAlc0.js +0 -1
  37. package/cdn/ButtonWallet.ENPAuGPm.js +0 -40
  38. package/cdn/GiftIcon.pcCM0-Fr.js +0 -1
  39. package/cdn/OpenInAppButton.BoGl6QtG.js +0 -1
  40. package/cdn/PostPurchase.DGkoI2iK.js +0 -89
  41. package/cdn/defaults.tvSp2rcs.js +0 -58
  42. package/cdn/useGlobalComponents.DKsas1_6.js +0 -1
  43. package/cdn/useLightDomStyles.DrKjTWoi.js +0 -1
  44. package/cdn/useReward.DwuOhcD2.js +0 -1
@@ -0,0 +1,40 @@
1
+ import{C as e,r as t}from"./loader.js";import{a as n,c as r,f as i,h as a,l as o,m as s,n as c,p as l,r as u,t as d}from"./jsxRuntime.module.CgbYebLx.js";import{t as f}from"./useReward.Duy0EWvi.js";import{t as p}from"./usePlacement.b__OilKu.js";function m(){`vibrate`in navigator&&navigator.vibrate(10)}function h(e){return d(`svg`,{fill:`none`,height:`1em`,viewBox:`0 0 28 28`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[d(`title`,{children:`Gift icon`}),d(`path`,{d:`m23.14 14v11.43h-18.29v-11.43m9.14 11.43v-17.14m0 0h-5.14c-0.76 0-1.48-0.3-2.02-0.84s-0.84-1.26-0.84-2.020.3-1.480.84-2.02 1.26-0.84 2.02-0.84c4 0 5.14 5.71 5.14 5.71zm0 0h5.14c0.76 0 1.48-0.3 2.02-0.84s0.84-1.260.84-2.02-0.3-1.48-0.84-2.02-1.26-0.84-2.02-0.84c-4 0-5.14 5.71-5.14 5.71zm-11.43 0h22.86v5.71h-22.86z`,stroke:`#fff`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]})}function g({placement:s,classname:g=``,useReward:_,targetInteraction:v}){let y=n(),b=p(s),x=b?.targetInteraction===void 0?v:b.targetInteraction,S=_===!0,{shouldRender:C,isHidden:w,isClientReady:T}=r(),{reward:E}=f(S&&T,x),D=b?.components?.buttonWallet?.position??window.FrakSetup?.modalWalletConfig?.metadata?.position??`right`,O=o(!1);i(()=>{O.current||T&&C&&!w&&(e(window.FrakSetup?.client,`share_button_impression`,{placement:s,target_interaction:x,has_reward:!!E}),O.current=!0)},[T,C,w,s,x]);let k=l(()=>{e(window.FrakSetup.client,`share_button_clicked`,{placement:s,target_interaction:x,has_reward:!!E,click_action:`sharing-page`}),m(),t(x,s)},[s,x,E]);if(!C||w)return null;let A=[`button`,`button__fadeIn`,D===`left`?`button__left`:`button__right`,g].filter(Boolean).join(` `);return d(a,{children:[d(`style`,{children:u(`
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
+ `,b?.components?.buttonWallet?.css)}),d(`button`,{type:`button`,"aria-label":c[y].buttonWallet.ariaLabel,part:`button`,disabled:!T,class:A,onClick:k,children:[d(h,{}),E&&d(`span`,{class:`reward`,children:E})]})]})}s(g,`frak-button-wallet`,[`placement`,`classname`,`useReward`,`targetInteraction`],{shadow:!0});export{g as ButtonWallet};
@@ -0,0 +1 @@
1
+ import{t as e}from"./jsxRuntime.module.CgbYebLx.js";function t(t){return e(`svg`,{width:`15`,height:`15`,viewBox:`0 0 15 15`,fill:`none`,"aria-hidden":`true`,...t,children:e(`path`,{d:`M7.33 0C11.38 0 14.67 3.28 14.67 7.33C14.67 11.38 11.38 14.67 7.33 14.67C3.28 14.67 0 11.38 0 7.33C0 3.28 3.28 0 7.33 0ZM10.39 4.28C10.15 4.04 9.76 4.04 9.52 4.28L7.33 6.47L5.14 4.28C4.9 4.04 4.52 4.04 4.28 4.28C4.04 4.52 4.04 4.9 4.28 5.14L6.47 7.33L4.28 9.52C4.04 9.76 4.04 10.15 4.28 10.39C4.52 10.63 4.9 10.63 5.14 10.39L7.33 8.2L9.52 10.39C9.76 10.63 10.15 10.63 10.39 10.39C10.63 10.15 10.63 9.76 10.39 9.52L8.2 7.33L10.39 5.14C10.63 4.9 10.63 4.52 10.39 4.28Z`,fill:`currentColor`})})}function n(t){return e(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":`true`,...t,children:e(`path`,{d:`M5.46 0C5.76 0 6 0.24 6 0.55C6 0.85 5.76 1.09 5.46 1.09H4.36C3.05 1.09 2.28 1.36 1.82 1.82C1.36 2.28 1.09 3.05 1.09 4.36V7.64C1.09 8.95 1.36 9.72 1.82 10.18C2.28 10.64 3.05 10.91 4.36 10.91H7.64C8.95 10.91 9.72 10.64 10.18 10.18C10.64 9.72 10.91 8.95 10.91 7.64V6.55C10.91 6.24 11.15 6 11.46 6C11.76 6 12 6.24 12 6.55V7.64C12 9.05 11.72 10.19 10.95 10.95C10.19 11.72 9.05 12 7.64 12H4.36C2.95 12 1.81 11.72 1.05 10.95C0.28 10.19 6.04e-05 9.05 0 7.64V4.36C0 2.95 0.28 1.81 1.05 1.05C1.81 0.28 2.95 0 4.36 0H5.46ZM11.45 0C11.76 2.2e-05 12 0.24 12 0.55V3.16C12 3.47 11.76 3.71 11.45 3.71C11.15 3.71 10.91 3.46 10.91 3.16V1.86L6.93 5.84C6.72 6.05 6.37 6.05 6.16 5.84C5.95 5.63 5.95 5.28 6.16 5.07L10.14 1.09H8.84C8.54 1.09 8.29 0.85 8.29 0.55C8.29 0.24 8.53 0 8.84 0H11.45Z`,fill:`currentColor`})})}function r(t){return e(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:t.width??`63`,height:t.height??`24`,fill:`none`,viewBox:`0 0 63 24`,...t,children:[e(`title`,{children:`Frak`}),e(`rect`,{width:`24`,height:`24`,rx:`6`,fill:`#0043EF`}),e(`path`,{fill:`white`,d:`M9.77 15.91L5.15 14.35C5.06 14.32 4.97 14.38 4.97 14.47V17.33C4.97 17.39 5.01 17.44 5.06 17.46L9.68 19.02C9.77 19.05 9.86 18.98 9.86 18.89V16.04C9.86 15.98 9.82 15.93 9.77 15.91ZM14.58 10.44L9.95 12C9.9 12.02 9.86 12.07 9.86 12.13V14.98C9.86 15.08 9.95 15.14 10.04 15.11L14.66 13.55C14.72 13.53 14.76 13.48 14.76 13.42V10.57C14.76 10.47 14.66 10.41 14.58 10.44ZM18.92 5.02L11.18 7.51C11.12 7.53 11.08 7.58 11.08 7.64V10.57C11.08 10.62 11.14 10.66 11.2 10.65L18.94 8.15C18.99 8.14 19.03 8.08 19.03 8.02V5.1C19.03 5.04 18.97 5 18.92 5.02Z`}),e(`path`,{fill:`currentColor`,d:`M52.72 9.51C52.83 9.51 52.91 9.6 52.91 9.7L52.84 18.21C52.84 18.31 52.76 18.39 52.66 18.39L52.64 18.39H51.3C51.15 18.39 50.78 18.25 50.39 18C49.86 18.25 49.27 18.39 48.64 18.39H48.39C47.24 18.39 46.19 17.91 45.43 17.14C44.67 16.38 44.2 15.32 44.2 14.15C44.2 12.98 44.67 11.92 45.43 11.15C46.16 10.41 47.16 9.94 48.26 9.91C49.17 9.86 49.99 9.99 50.49 10.5V9.7C50.49 9.6 50.57 9.51 50.68 9.51H52.72ZM35.35 5.62H36.96C37.09 5.62 37.19 5.72 37.19 5.85V7.81C37.19 7.94 37.09 8.04 36.96 8.04H34.92C34.32 8.04 33.63 8.64 33.63 9.25V10.61C34.26 9.98 34.93 9.65 35.35 9.63H36.46C36.59 9.63 36.69 9.73 36.69 9.86V11.82C36.69 11.95 36.59 12.05 36.46 12.05H34.92C34.31 12.05 33.63 12.65 33.63 13.27V18.2C33.63 18.3 33.54 18.39 33.44 18.39H31.39C31.29 18.39 31.21 18.3 31.21 18.2V9.94C31.21 9.87 31.2 9.8 31.2 9.73C31.24 8.88 31.15 5.44 35.35 5.62ZM39.93 9.63C40.04 9.63 40.12 9.72 40.12 9.82V10.61C40.76 9.98 41.58 9.63 41.85 9.63H43.46C43.58 9.63 43.68 9.73 43.69 9.86V11.82C43.68 11.95 43.58 12.05 43.46 12.05H41.41C40.81 12.05 40.12 12.65 40.12 13.27V18.2C40.12 18.3 40.04 18.39 39.93 18.39H37.89C37.79 18.39 37.7 18.3 37.7 18.2V9.82C37.7 9.72 37.79 9.63 37.89 9.63H39.93ZM56.2 7.01C56.3 7.01 56.39 7.09 56.39 7.2V13.45L59.83 10.19C59.87 10.16 59.91 10.14 59.96 10.14H62.28C62.45 10.14 62.54 10.34 62.42 10.46L59.3 13.63L62.8 18.07C62.9 18.2 62.81 18.39 62.65 18.39H60.24C60.18 18.39 60.13 18.36 60.09 18.31L57.67 15.32C57.6 15.23 57.47 15.22 57.39 15.3L56.39 16.29V18.19C56.39 18.3 56.3 18.39 56.2 18.39H54.19C54.08 18.39 54 18.3 54 18.19V7.2C54 7.09 54.08 7.01 54.19 7.01H56.2ZM48.37 11.96C47.78 11.96 47.24 12.21 46.85 12.6C46.46 13 46.22 13.54 46.22 14.14C46.22 14.73 46.46 15.28 46.85 15.67C47.24 16.07 47.78 16.31 48.37 16.31H48.66C49.25 16.31 49.79 16.07 50.18 15.67C50.57 15.28 50.81 14.73 50.81 14.14C50.81 13.54 50.57 12.99 50.18 12.6C49.79 12.21 49.25 11.96 48.66 11.96H48.37Z`})]})}2*Math.PI*11;function i(t){return e(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,...t,children:e(`path`,{d:`M8 0C12.42 0 16 3.58 16 8C16 12.42 12.42 16 8 16C3.58 16 0 12.42 0 8C0 3.58 3.58 0 8 0ZM8 1.5C4.41 1.5 1.5 4.41 1.5 8C1.5 11.59 4.41 14.5 8 14.5C11.59 14.5 14.5 11.59 14.5 8C14.5 4.41 11.59 1.5 8 1.5ZM8.1 10.21C8.82 10.21 9.24 10.63 9.24 11.33C9.24 12.03 8.82 12.46 8.1 12.46C7.36 12.46 6.97 12.03 6.97 11.33C6.97 10.63 7.36 10.21 8.1 10.21ZM8.85 3.54C9.01 3.54 9.15 3.68 9.15 3.84V4.75L8.84 8.37C8.83 8.53 8.7 8.65 8.54 8.65H7.63C7.47 8.65 7.34 8.52 7.33 8.37L7.08 4.75V3.84C7.09 3.68 7.22 3.54 7.38 3.54H8.85Z`,fill:`currentColor`})})}function a(t){return e(`svg`,{viewBox:`0 0 100 100`,fill:`none`,"aria-hidden":`true`,...t,children:[e(`circle`,{cx:`38`,cy:`28`,r:`23`,fill:`#FFF533`}),e(`path`,{d:`M50 38C30 10 12 30 50 38Z`,stroke:`#222222`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`}),e(`path`,{d:`M50 38C70 10 88 30 50 38Z`,stroke:`#222222`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`}),e(`rect`,{x:`10`,y:`38`,width:`80`,height:`16`,rx:`2`,stroke:`#222222`,"stroke-width":`4`}),e(`path`,{d:`M15 54V89C15 90.6 16.4 92 18 92H82C83.6 92 85 90.6 85 89V54`,stroke:`#222222`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`}),e(`line`,{x1:`50`,y1:`54`,x2:`50`,y2:`92`,stroke:`#222222`,"stroke-width":`4`,"stroke-linecap":`round`})]})}export{t as a,n as i,i as n,r,a as t};
@@ -0,0 +1 @@
1
+ import{C as e,_ as t,f as n,g as r}from"./loader.js";import{a as i,c as a,m as o,n as s,t as c}from"./jsxRuntime.module.CgbYebLx.js";import{t as l}from"./useLightDomStyles.CkTNHin8.js";import{t as u}from"./usePlacement.b__OilKu.js";function d(r=`wallet`,i){let a=window.FrakSetup?.client;a&&e(a,`open_in_app_clicked`,{path:r,placement:i});let o=`${t}${r}`;n(o,{onFallback:()=>{a&&e(a,`app_not_installed`,{path:r,placement:i})}})}function f(){return{isMobile:r()}}function p({placement:e,text:t,classname:n=``}){let r=i(),o=u(e),{shouldRender:p,isHidden:m,isClientReady:h}=a(),{isMobile:g}=f();l(`frak-open-in-app`,e,o?.components?.openInApp?.css);let _=o?.components?.openInApp?.text??t??s[r].openInApp.text;if(!g||!p||m)return null;let v=()=>{d(void 0,e)},y=[`button`,`button__fadeIn`,n].filter(Boolean).join(` `);return c(`button`,{type:`button`,"aria-label":s[r].openInApp.ariaLabel,disabled:!h,class:y,onClick:v,children:_})}o(p,`frak-open-in-app`,[`text`,`placement`,`classname`],{shadow:!1});export{p as OpenInAppButton};
@@ -0,0 +1,89 @@
1
+ import{C as e,E as t,T as n,a as r,k as i,l as a,r as o,s,u as ee}from"./loader.js";import{a as c,c as l,d as u,f as d,l as te,m as f,n as p,p as ne,t as m,u as h}from"./jsxRuntime.module.CgbYebLx.js";import{i as g,n as _,t as re}from"./rewards.B_p05JY_.js";import{t as v}from"./useGlobalComponents.da05dAlQ.js";import{t as y}from"./useLightDomStyles.CkTNHin8.js";import{r as b,t as x}from"./GiftIcon.Be-UU58r.js";import{t as ie}from"./usePlacement.b__OilKu.js";var ae=`PostPurchase_card__5fv5lh0`,oe=`PostPurchase_cardLayout__5fv5lh1`,se=`PostPurchase_cardLeft__5fv5lh2`,ce=`PostPurchase_cardRight__5fv5lh3`,le=`PostPurchase_cta__5fv5lh6 sharedBaseCss_buttonReset__7cswil0`,ue=`PostPurchase_customImage__5fv5lha`,de=`PostPurchase_frakLogo__5fv5lhb`,fe=`PostPurchase_giftIcon__5fv5lh8`,pe=`PostPurchase_icon__5fv5lh7`,me=`PostPurchase_imageWrapper__5fv5lh9`,he=`PostPurchase_message__5fv5lh5`;function ge(e){let t=e?.trim();if(!t)return;let n=/^https?:\/\//i.test(t)?t:`https://${t}`;try{return new URL(n).toString()}catch{return}}function _e(e,t,n,r){let i=e?.isReferred?`referee`:`referrer`,a=_(t.rewards,{targetInteraction:`purchase`,currency:n,audience:i,products:r});if(!a)return null;let{campaign:o}=a,s=e?.isReferred&&o.referee?`referee`:`referrer`;return{variant:s,reward:s===`referee`?o.referee:o.referrer,merchantDomain:t.onChainMetadata.domain}}function S({customerId:f,orderId:_,token:S,sharingUrl:ve,merchantId:C,placement:w,classname:T=``,variant:E,badgeText:D,referrerText:O,refereeText:k,ctaText:A,preview:j,previewVariant:M,products:N,imageUrl:P}){let F=!!j,{shouldRender:I,isHidden:L,isClientReady:R}=l(),z=ie(w),B=c(),V=h(()=>ee(N),[N]);y(`frak-post-purchase`,w,z?.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
+ }`,i);let[H,ye]=u(null),[U,W]=u(!1);d(()=>{F||R&&f&&_&&S&&s({customerId:f,orderId:_,token:S,merchantId:C}).catch(()=>{})},[F,R,f,_,S,C]),d(()=>{if(F||!R||U)return;let e=window.FrakSetup?.client;e&&Promise.all([a(e),r(e)]).then(([e,t])=>{W(!0),ye({referralStatus:e,merchantInfo:t})}).catch(e=>{if(e instanceof t&&e.code===n.configError){W(!0);return}console.warn(`[Frak] Post-purchase context error`,e)})},[F,R,U]);let G=h(()=>H?_e(H.referralStatus,H.merchantInfo,window.FrakSetup?.client?.config?.metadata?.currency,V):null,[H,V]),K=te(null),q=E??G?.variant??(F?M??`referrer`:void 0),J=ge(ve??G?.merchantDomain),Y=h(()=>{if(!G?.reward)return;let e=window.FrakSetup?.client?.config?.metadata?.currency;return re(G.reward,e)},[G?.reward]),be=v(),X=z?.components?.postPurchase??be?.postPurchase,Z=D??X?.badgeText,Q=P??X?.imageUrl,$=h(()=>{let e=p[B].postPurchase;return{message:q===`referee`?Y?g(k??X?.refereeText??e.refereeText,Y):k??X?.refereeNoRewardText??e.refereeNoRewardText:Y?g(O??X?.referrerText??e.referrerText,Y):O??X?.referrerNoRewardText??e.referrerNoRewardText,cta:Y?g(A??X?.ctaText??e.ctaText,Y):A??X?.ctaNoRewardText??e.ctaNoRewardText}},[B,q,Y,X,O,k,A]);d(()=>{q&&K.current!==q&&R&&(F||I&&!L)&&(e(window.FrakSetup?.client,`post_purchase_impression`,{placement:w,variant:q,has_reward:!!G?.reward}),K.current=q)},[q,I,L,R,F,w,G?.reward]);let xe=ne(()=>{q&&(e(window.FrakSetup?.client,`post_purchase_clicked`,{placement:w,variant:q}),o(void 0,w,{link:J,products:V,checkoutToken:S}))},[q,w,J,V,S]);if(!q||!F&&(!I||L||!G))return null;let Se=[ae,T].filter(Boolean).join(` `);return m(`div`,{className:Se,children:m(`div`,{class:oe,children:[m(`div`,{class:se,children:[Z&&m(`span`,{class:`PostPurchase_badge__5fv5lh4`,children:Z}),m(`p`,{class:he,children:$.message}),m(`button`,{type:`button`,className:`${le} button`,disabled:!F&&!R,onClick:F?void 0:xe,children:[$.cta,m(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:`${pe} button`,children:m(`path`,{d:`M13.9 11.14C13.99 11.05 14.15 11.11 14.15 11.24V11.64C14.15 13.05 12.63 14.19 10.75 14.19C8.87 14.19 7.34 13.05 7.34 11.64V11.24C7.34 11.11 7.51 11.05 7.59 11.14C8.35 11.93 9.48 12.43 10.75 12.43C12.01 12.43 13.15 11.93 13.9 11.14ZM1.85 9.65C1.85 9.51 2.01 9.44 2.1 9.54C2.85 10.32 3.99 10.82 5.25 10.82C5.52 10.82 5.79 10.8 6.04 10.76C6.26 10.72 6.47 10.88 6.47 11.1V12.17C6.47 12.32 6.37 12.45 6.22 12.48C5.92 12.55 5.59 12.59 5.25 12.59C3.37 12.59 1.85 11.45 1.85 10.04V9.65ZM10.75 6.21C12.63 6.21 14.15 7.35 14.15 8.75C14.15 10.16 12.63 11.3 10.75 11.3C8.87 11.3 7.34 10.16 7.34 8.75C7.34 7.35 8.87 6.21 10.75 6.21ZM1.85 6.85C1.85 6.71 2.01 6.65 2.1 6.74C2.85 7.53 3.99 8.03 5.25 8.03C5.52 8.03 5.79 8 6.04 7.96C6.26 7.92 6.47 8.09 6.47 8.3V9.37C6.47 9.52 6.37 9.65 6.22 9.69C5.92 9.75 5.59 9.79 5.25 9.79C3.37 9.79 1.85 8.65 1.85 7.24V6.85ZM5.25 1.81C7.13 1.81 8.66 2.95 8.66 4.36C8.66 5.76 7.13 6.9 5.25 6.9C3.37 6.9 1.85 5.76 1.85 4.36C1.85 2.95 3.37 1.81 5.25 1.81Z`,fill:`currentColor`})})]})]}),m(`div`,{class:ce,children:[Q?m(`span`,{class:me,children:m(`img`,{src:Q,alt:``,class:ue})}):m(x,{className:fe,width:80,height:80}),m(b,{className:de,width:42,height:24})]})]})})}f(S,`frak-post-purchase`,[`customerId`,`orderId`,`token`,`sharingUrl`,`merchantId`,`placement`,`classname`,`variant`,`badgeText`,`referrerText`,`refereeText`,`ctaText`,`products`,`preview`,`previewVariant`,`imageUrl`],{shadow:!1});export{S as PostPurchase};
package/cdn/components.js CHANGED
@@ -1 +1 @@
1
- import(`https://cdn.jsdelivr.net/npm/@frak-labs/components@1.2.3-beta.9b2f57a0/cdn/loader.js`);
1
+ import(`https://cdn.jsdelivr.net/npm/@frak-labs/components@1.2.4-beta.683f5bca/cdn/loader.js`);
@@ -0,0 +1,58 @@
1
+ import{D as e,m as t,n,t as r,w as i}from"./loader.js";var a,o,s,c,l,u,d,f,p,m,h,g,_,v,y={},b=[],x=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,S=Array.isArray;function C(e,t){for(var n in t)e[n]=t[n];return e}function w(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function T(e,t,n){var r,i,o,s={};for(o in t)o==`key`?r=t[o]:o==`ref`?i=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?a.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return E(e,s,r,i,null)}function E(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++s,__i:-1,__u:0};return i==null&&o.vnode!=null&&o.vnode(a),a}function D(e){return e.children}function O(e,t){this.props=e,this.context=t}function k(e,t){if(t==null)return e.__?k(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?k(e):null}function A(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=C({},t);a.__v=t.__v+1,o.vnode&&o.vnode(a),L(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??k(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,oe(r,a,i),t.__e=t.__=null,a.__e!=n&&j(a)}}function j(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),j(e)}function M(e){(!e.__d&&(e.__d=!0)&&c.push(e)&&!N.__r++||l!=o.debounceRendering)&&((l=o.debounceRendering)||u)(N)}function N(){try{for(var e,t=1;c.length;)c.length>t&&c.sort(d),e=c.shift(),t=c.length,A(e)}finally{c.length=N.__r=0}}function ee(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r&&r.__k||b,v=t.length;for(c=P(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&_[p.__i]||y,p.__i=d,g=L(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&R(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),4&p.__u?(c=te(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function P(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=E(null,o,null,null,null):S(o)?o=e.__k[a]=E(D,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=E(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=ne(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=k(s)),le(s,s));return r}function te(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=te(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=k(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function F(e,t){return t||=[],e==null||typeof e==`boolean`||(S(e)?e.some(function(e){F(e,t)}):t.push(e)),t}function ne(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function re(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||x.test(t)?n:n+`px`}function I(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||re(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||re(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(h,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[m]=r[m]:(n[m]=g,e.addEventListener(t,a?v:_,a)):e.removeEventListener(t,a?v:_,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function ie(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[p]==null)t[p]=g++;else if(t[p]<n[m])return;return n(o.event?o.event(t):t)}}}function L(e,t,n,r,i,a,s,c,l,u){var d,f,p,m,h,g,_,v,y,x,T,E,A,j,M,N,P=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),a=[c=t.__e=n.__e]),(d=o.__b)&&d(t);n:if(typeof P==`function`){f=s.length;try{if(y=t.props,x=P.prototype&&P.prototype.render,T=(d=P.contextType)&&r[d.__c],E=d?T?T.props.value:d.__:r,n.__c?v=(p=t.__c=n.__c).__=p.__E:(x?t.__c=p=new P(y,E):(t.__c=p=new O(y,E),p.constructor=P,p.render=ue),T&&T.sub(p),p.state||(p.state={}),p.__n=r,m=p.__d=!0,p.__h=[],p._sb=[]),x&&p.__s==null&&(p.__s=p.state),x&&P.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=C({},p.__s)),C(p.__s,P.getDerivedStateFromProps(y,p.__s))),h=p.props,g=p.state,p.__v=t,m)x&&P.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),x&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(x&&P.getDerivedStateFromProps==null&&y!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(y,E),t.__v==n.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(y,p.__s,E)){t.__v!=n.__v&&(p.props=y,p.state=p.__s,p.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),b.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=k(n);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(y,p.__s,E),x&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,g,_)})}if(p.context=E,p.props=y,p.__P=e,p.__e=!1,A=o.__r,j=0,x)p.state=p.__s,p.__d=!1,A&&A(t),d=p.render(p.props,p.state,p.context),b.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,A&&A(t),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++j<25);p.state=p.__s,p.getChildContext!=null&&(r=C(C({},r),p.getChildContext())),x&&!m&&p.getSnapshotBeforeUpdate!=null&&(_=p.getSnapshotBeforeUpdate(h,g)),M=d!=null&&d.type===D&&d.key==null?se(d.props.children):d,c=ee(e,S(M)?M:[M],t,n,r,i,a,s,c,l,u),p.base=t.__e,t.__u&=-161,p.__h.length&&s.push(p),v&&(p.__E=p.__=null)}catch(e){if(s.length=f,t.__v=null,l||a!=null){if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;a!=null&&(a[a.indexOf(c)]=null),t.__e=c}else if(a!=null)for(N=a.length;N--;)w(a[N])}else t.__e=n.__e;t.__k??=n.__k||[],e.then||ae(t),o.__e(e,t,n)}}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=ce(n.__e,t,n,r,i,a,s,l,u);return(d=o.diffed)&&d(t),128&t.__u?void 0:c}function ae(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ae))}function oe(e,t,n){for(var r=0;r<n.length;r++)R(n[r],n[++r],n[++r]);o.__c&&o.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){o.__e(e,t.__v)}})}function se(e){return typeof e!=`object`||!e||e.__b>0?e:S(e)?e.map(se):e.constructor===void 0?C({},e):null}function ce(e,t,n,r,i,s,c,l,u){var d,f,p,m,h,g,_,v=n.props||y,b=t.props,x=t.type;if(x==`svg`?i=`http://www.w3.org/2000/svg`:x==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d<s.length;d++)if((h=s[d])&&`setAttribute`in h==!!x&&(x?h.localName==x:h.nodeType==3)){e=h,s[d]=null;break}}if(e==null){if(x==null)return document.createTextNode(b);e=document.createElementNS(i,x,b.is&&b),l&&=(o.__m&&o.__m(t,s),!1),s=null}if(x==null)v===b||l&&e.data==b||(e.data=b);else{if(s=x==`textarea`&&b.defaultValue!=null?null:s&&a.call(e.childNodes),!l&&s!=null)for(v={},d=0;d<e.attributes.length;d++)v[(h=e.attributes[d]).name]=h.value;for(d in v)h=v[d],d==`dangerouslySetInnerHTML`?p=h:d==`children`||d in b||d==`value`&&`defaultValue`in b||d==`checked`&&`defaultChecked`in b||I(e,d,null,h,i);for(d in b)h=b[d],d==`children`?m=h:d==`dangerouslySetInnerHTML`?f=h:d==`value`?g=h:d==`checked`?_=h:l&&typeof h!=`function`||v[d]===h||I(e,d,h,v[d],i);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=``),ee(t.type==`template`?e.content:e,S(m)?m:[m],t,n,r,x==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,s,c,s?s[0]:n.__k&&k(n,0),l,u),s!=null)for(d=s.length;d--;)w(s[d]);l&&x!=`textarea`||(d=`value`,x==`progress`&&g==null?e.removeAttribute(`value`):g!=null&&(g!==e[d]||x==`progress`&&!g||x==`option`&&g!=v[d])&&I(e,d,g,v[d],i),d=`checked`,_!=null&&_!=e[d]&&I(e,d,_,v[d],i))}return e}function R(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){o.__e(e,n)}}function le(e,t,n){var r,i;if(o.unmount&&o.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||R(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){o.__e(e,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&le(r[i],t,n||typeof e.type!=`function`);n||w(e.__e),e.__c=e.__=e.__e=void 0}function ue(e,t,n){return this.constructor(e,n)}function z(e,t,n){var r,i,s,c;t==document&&(t=document.documentElement),o.__&&o.__(e,t),i=(r=typeof n==`function`)?null:n&&n.__k||t.__k,s=[],c=[],L(t,e=(!r&&n||t).__k=T(D,null,[e]),i||y,y,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?a.call(t.childNodes):null,s,!r&&n?n:i?i.__e:t.firstChild,r,c),oe(s,e,c),e.props.children=null}function de(e,t){z(e,t,de)}function fe(e,t,n){var r,i,o,s,c=C({},e.props);for(o in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)o==`key`?r=t[o]:o==`ref`?i=t[o]:c[o]=t[o]===void 0&&s!=null?s[o]:t[o];return arguments.length>2&&(c.children=arguments.length>3?a.call(arguments,2):n),E(e.type,c,r||e.key,i||e.ref,null)}a=b.slice,o={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},s=0,O.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=C({},this.state);typeof e==`function`&&(e=e(C({},n),this.props)),e&&C(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),M(this))},O.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),M(this))},O.prototype.render=D,c=[],u=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,d=function(e,t){return e.__v.__b-t.__v.__b},N.__r=0,f=Math.random().toString(8),p=`__d`+f,m=`__a`+f,h=/(PointerCapture)$|Capture$/i,g=0,_=ie(!1),v=ie(!0);function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},B.apply(this,arguments)}function pe(e,t){if(e==null)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(i[n]=e[n]);return i}var me=[`context`,`children`],he=[`useFragment`];function ge(e,t,n,r){function i(){var t,n=Reflect.construct(HTMLElement,[],i);return n._vdomComponent=e,r&&r.shadow?(n._root=n.attachShadow({mode:r.mode||`open`,serializable:(t=r.serializable)!=null&&t}),r.adoptedStyleSheets&&(n._root.adoptedStyleSheets=r.adoptedStyleSheets)):n._root=n,n}return(i.prototype=Object.create(HTMLElement.prototype)).constructor=i,i.prototype.connectedCallback=function(){ve.call(this,r)},i.prototype.attributeChangedCallback=be,i.prototype.disconnectedCallback=xe,n=n||e.observedAttributes||Object.keys(e.propTypes||{}),i.observedAttributes=n,e.formAssociated&&(i.formAssociated=!0),n.forEach(function(e){Object.defineProperty(i.prototype,e,{get:function(){return this._vdom?this._vdom.props[e]:this._props[e]},set:function(t){this._vdom?this.attributeChangedCallback(e,null,t):(this._props||={},this._props[e]=t);var n=typeof t;t!=null&&n!==`string`&&n!==`boolean`&&n!==`number`||this.setAttribute(e,t)}})}),customElements.define(t||e.tagName||e.displayName||e.name,i),i}function _e(e){this.getChildContext=function(){return e.context};var t=e.children;return fe(t,pe(e,me))}function ve(e){var t=new CustomEvent(`_preact`,{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(t),this._vdom=T(_e,B({},this._props,{context:t.detail.context}),Ce(this,this._vdomComponent,e)),(this.hasAttribute(`hydrate`)?de:z)(this._vdom,this._root)}function ye(e){return e.replace(/-(\w)/g,function(e,t){return t?t.toUpperCase():``})}function be(e,t,n){if(this._vdom){var r={};r[e]=n??=void 0,r[ye(e)]=n,this._vdom=fe(this._vdom,r),z(this._vdom,this._root)}}function xe(){z(this._vdom=null,this._root)}function Se(e,t){var n=this,r=e.useFragment,i=pe(e,he);return T(r?D:`slot`,B({},i,{ref:function(e){e?(n.ref=e,n._listener||(n._listener=function(e){e.stopPropagation(),e.detail.context=t},e.addEventListener(`_preact`,n._listener))):n.ref.removeEventListener(`_preact`,n._listener)}}))}function Ce(e,t,n){if(e.nodeType===3)return e.data;if(e.nodeType!==1)return null;var r=[],i={},a=0,o=e.attributes,s=e.childNodes;for(a=o.length;a--;)o[a].name!==`slot`&&(i[o[a].name]=o[a].value,i[ye(o[a].name)]=o[a].value);for(a=s.length;a--;){var c=Ce(s[a],null,n),l=s[a].slot;l?i[l]=T(Se,{name:l},c):r[a]=c}var u=!(!n||!n.shadow),d=t?T(Se,{useFragment:!u},r):r;return!u&&t&&(e.innerHTML=``),T(t||e.nodeName.toLowerCase(),i,d)}function we(t,n,i=[],a={shadow:!0}){if(typeof window<`u`&&(e(r),!customElements.get(n))){let e=i.map(String),r=e.map(e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)).filter(t=>!e.includes(t));ge(t,n,[...e,...r],a)}}var V,H,U,Te,W=0,Ee=[],G=o,De=G.__b,Oe=G.__r,ke=G.diffed,Ae=G.__c,je=G.unmount,Me=G.__;function K(e,t){G.__h&&G.__h(H,e,W||t),W=0;var n=H.__H||(H.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function q(e){return W=1,Ne(Be,e)}function Ne(e,t,n){var r=K(V++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Be(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=H,!H.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};H.__f=!0;var a=H.shouldComponentUpdate,o=H.componentWillUpdate;H.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},H.shouldComponentUpdate=i}return r.__N||r.__}function J(e,t){var n=K(V++,3);!G.__s&&Q(n.__H,t)&&(n.__=e,n.u=t,H.__H.__h.push(n))}function Pe(e,t){var n=K(V++,4);!G.__s&&Q(n.__H,t)&&(n.__=e,n.u=t,H.__h.push(n))}function Fe(e){return W=5,Y(function(){return{current:e}},[])}function Y(e,t){var n=K(V++,7);return Q(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ie(e,t){return W=8,Y(function(){return e},t)}function Le(){for(var e;e=Ee.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(X),t.__h.some(Z),t.__h=[]}catch(n){t.__h=[],G.__e(n,e.__v)}}}G.__b=function(e){H=null,De&&De(e)},G.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Me&&Me(e,t)},G.__r=function(e){Oe&&Oe(e),V=0;var t=(H=e.__c).__H;t&&(U===H?(t.__h=[],H.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(X),t.__h.some(Z),t.__h=[],V=0)),U=H},G.diffed=function(e){ke&&ke(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ee.push(t)!==1&&Te===G.requestAnimationFrame||((Te=G.requestAnimationFrame)||ze)(Le)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),U=H=null},G.__c=function(e,t){t.some(function(e){try{e.__h.some(X),e.__h=e.__h.filter(function(e){return!e.__||Z(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],G.__e(n,e.__v)}}),Ae&&Ae(e,t)},G.unmount=function(e){je&&je(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{X(e)}catch(e){t=e}}),n.__H=void 0,t&&G.__e(t,n.__v))};var Re=typeof requestAnimationFrame==`function`;function ze(e){var t,n=function(){clearTimeout(r),Re&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Re&&(t=requestAnimationFrame(n))}function X(e){var t=H,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),H=t}function Z(e){var t=H;e.__c=e.__(),H=t}function Q(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Be(e,t){return typeof t==`function`?t(e):t}function Ve(){let[e,t]=q(()=>window.FrakSetup?.config?.waitForBackendConfig===!1||i.isResolved),[r,a]=q(()=>i.getConfig().hidden??!1),[o,s]=q(()=>!!window.FrakSetup?.client);return J(()=>{let e=i.getConfig();e.isResolved&&(t(!0),a(e.hidden??!1)),window.FrakSetup?.client&&s(!0);let r=e=>{let n=e.detail;n.isResolved&&t(!0),a(n.hidden??!1)};window.addEventListener(`frak:config`,r);let o=()=>s(!0);return n(`add`,o),()=>{window.removeEventListener(`frak:config`,r),n(`remove`,o)}},[]),{shouldRender:e,isHidden:r,isClientReady:o}}function He(e,t){for(var n in t)e[n]=t[n];return e}function Ue(e,t){for(var n in e)if(n!==`__source`&&!(n in t))return!0;for(var r in t)if(r!==`__source`&&e[r]!==t[r])return!0;return!1}function We(e,t){var n=t(),r=q({t:{__:n,u:t}}),i=r[0].t,a=r[1];return Pe(function(){i.__=n,i.u=t,Ge(i)&&a({t:i})},[e,n,t]),J(function(){return Ge(i)&&a({t:i}),e(function(){Ge(i)&&a({t:i})})},[e]),n}function Ge(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function Ke(e,t){this.props=e,this.context=t}(Ke.prototype=new O).isPureReactComponent=!0,Ke.prototype.shouldComponentUpdate=function(e,t){return Ue(this.props,e)||Ue(this.state,t)};var qe=o.__b;o.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),qe&&qe(e)},typeof Symbol<`u`&&Symbol.for;var Je=o.__e;o.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e??(t.__e=n.__e,t.__k=n.__k||[]),i.__c(e,t)}Je(e,t,n,r)};var Ye=o.unmount;function Xe(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=He({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return Xe(e,t,n)})),e}function Ze(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return Ze(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function Qe(){this.__u=0,this.o=null,this.__b=null}function $e(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function $(){this.i=null,this.l=null}o.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Ye&&Ye(e)},(Qe.prototype=new O).__c=function(e,t){var n=t.__c,r=this;r.o??=[],r.o.push(n);var i=$e(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=Ze(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},Qe.prototype.componentWillUnmount=function(){this.o=[]},Qe.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(`div`),r=this.__v.__k[0].__c;this.__v.__k[0]=Xe(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&T(D,null,e.fallback);return i&&(i.__u&=-33),[T(D,null,t.__a?null:e.children),i]};var et=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==`t`||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};($.prototype=new O).__a=function(e){var t=this,n=$e(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),et(t,e,r)):i()};n?n(a):a()}},$.prototype.render=function(e){this.i=null,this.l=new Map;var t=F(e.children);e.revealOrder&&e.revealOrder[0]===`b`&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},$.prototype.componentDidUpdate=$.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){et(e,n,t)})};var tt=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,nt=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,rt=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,it=/[A-Z0-9]/g,at=typeof document<`u`,ot=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};O.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(O.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var st=o.event;o.event=function(e){return st&&(e=st(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var ct={configurable:!0,get:function(){return this.class}},lt=o.vnode;o.vnode=function(e){typeof e.type==`string`&&function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a===`value`&&`defaultValue`in t&&o==null||at&&a===`children`&&n===`noscript`||a===`class`||a===`className`)){var s=a.toLowerCase();a===`defaultValue`&&`value`in t&&t.value==null?a=`value`:a===`download`&&!0===o?o=``:s===`translate`&&o===`no`?o=!1:s[0]===`o`&&s[1]===`n`?s===`ondoubleclick`?a=`ondblclick`:s!==`onchange`||n!==`input`&&n!==`textarea`||ot(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:rt.test(a)&&(a=s):s=a=`oninput`:i&&nt.test(a)?a=a.replace(it,`-$&`).toLowerCase():o===null&&(o=void 0),s===`oninput`&&r[a=s]&&(a=`oninputCapture`),r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=F(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=F(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",ct)):t.className&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=tt,lt&&lt(e)};var ut=o.__r;o.__r=function(e){ut&&ut(e),e.__c};var dt=o.diffed;o.diffed=function(e){dt&&dt(e);var t=e.props,n=e.__e;n!=null&&e.type===`textarea`&&`value`in t&&t.value!==n.value&&(n.value=t.value==null?``:t.value)};function ft(e){return typeof window>`u`?()=>{}:(window.addEventListener(`frak:config`,e),()=>window.removeEventListener(`frak:config`,e))}function pt(){return We(ft,()=>i.getConfig().lang??t()??`en`)}const mt=`
2
+ :host {
3
+ display: contents;
4
+ }
5
+
6
+ :host([hidden]) {
7
+ display: none;
8
+ }
9
+
10
+ .button:disabled {
11
+ opacity: 0.7;
12
+ cursor: default;
13
+ }
14
+
15
+ .button__fadeIn {
16
+ animation: frak-fadeIn 300ms ease-in;
17
+ }
18
+
19
+ @keyframes frak-fadeIn {
20
+ from {
21
+ opacity: 0;
22
+ }
23
+
24
+ to {
25
+ opacity: 1;
26
+ }
27
+ }
28
+ `;function ht(e,t){return t?`${mt}\n${e}\n${t}`:`${mt}\n${e}`}const gt=`
29
+ :where(frak-button-share, frak-open-in-app) {
30
+ display: contents;
31
+ }
32
+
33
+ :where(frak-button-share .button, frak-open-in-app .button) {
34
+ display: flex;
35
+ align-items: center;
36
+ justify-content: center;
37
+ gap: 10px;
38
+ }
39
+
40
+ :where(frak-button-share .button:disabled, frak-open-in-app .button:disabled) {
41
+ opacity: 0.7;
42
+ cursor: default;
43
+ }
44
+
45
+ :where(frak-button-share .button__fadeIn, frak-open-in-app .button__fadeIn) {
46
+ animation: frak-fadeIn 300ms ease-in;
47
+ }
48
+
49
+ @keyframes frak-fadeIn {
50
+ from {
51
+ opacity: 0;
52
+ }
53
+
54
+ to {
55
+ opacity: 1;
56
+ }
57
+ }
58
+ `,_t={en:{buttonShare:{text:`Share & earn {REWARD}!`},postPurchase:{refereeText:`You just earned {REWARD}! Share with friends to earn even more.`,refereeNoRewardText:`You just earned a reward! Share with friends to earn even more.`,referrerText:`Earn {REWARD} by sharing this with your friends!`,referrerNoRewardText:`Share this with your friends and earn rewards!`,ctaText:`Share & earn {REWARD}`,ctaNoRewardText:`Share & earn`},openInApp:{text:`Open in App`,ariaLabel:`Open in Frak Wallet app`},buttonWallet:{ariaLabel:`Share and earn rewards`},banner:{referralTitleReward:`Earn {REWARD} on purchases`,referralTitle:`You've been referred!`,referralDescription:`Earn rewards after your purchase via the Frak partner app.`,referralCta:`Got it`,inappTitle:`Open in your browser`,inappDescription:`For a better experience and to earn your rewards, open this page in your default browser.`,inappCta:`Open browser`,dismissLabel:`Dismiss`},ambassador:{heroEyebrow:`Ambassador program`,heroHeadline:`Become an ambassador for {BRAND}`,heroLede:`Love our products? Tell the people around you! Earn a reward as soon as someone buys thanks to you.`,heroLedeReward:`Love our products? Tell the people around you! Earn {REWARD} as soon as someone buys thanks to you.`,heroCtaLabel:`Become an ambassador`,heroFacesCaption:`No form, no waiting: anyone can become an ambassador right away.`,heroImageAlt:`{BRAND} ambassadors`,heroRewardCaption:`for you, on every sale`,heroRewardRefereePill:`+ {REWARD} for your friend`,heroRewardRefereePillNoReward:`+ a perk for your friend`,rewardEyebrow:`Referral program`,rewardHeadingReward:`{REWARD} for you on every sale`,rewardHeadingNoReward:`A reward for you on every sale`,rewardEstimateCaption:`Estimate: the amount depends on the campaign and your friend's order.`,rewardLede:`No cap: the more you share, the more sales your link brings in, and the more you earn!`,rewardCtaLabel:`Get my link`,rewardFooterCaption:`Free · no commitment · paid to your bank account`,rewardNoBankDetails:`no bank details needed to start`,rewardFallbackLabel:`A reward`,explainerTitle:`How it works`,explainerLede:`Three steps, nothing more.`,explainerStep1Title:`I share with the people close to me`,explainerStep1Description:`On WhatsApp, in an Instagram story, on TikTok… my unique link, generated automatically.`,explainerStep2Title:`I get paid`,explainerStep2Description:`Credited automatically to my wallet for every sale made through my referral link.`,explainerStep3Title:`I collect my money`,explainerStep3Description:`With the Frak app, I transfer my earnings to my bank account.`,winWinHeading:`Your friends win too`,winWinLede:`Recommend {BRAND} to the people close to you: they discover great products, and thanks to your link they get cashback on their first order. They can thank you for it!`,winWinCard1Title:`You`,winWinCard1Description:`to your secure wallet, on every sale`,winWinCard2Title:`Your friend`,winWinCard2Description:`in cashback to their secure wallet, on their first order`,referralHeading:`Your ambassador link`,referralLede:`Finally, a referral program that really pays!`,referralCtaLabel:`Share my link`,storeHeading:`Track your earnings in real time`,storeLede:`The Frak app notifies you as soon as a friend orders, and centralizes your earnings across every partner brand.`,storeAppBadgeAriaLabel:`Download on the App Store`,storePlayBadgeAriaLabel:`Get it on Google Play`,storeQrLabel:`QR code to install the Frak app`,storeQrCaption:`Scan to install`,faqHeading:`Frequently asked questions`,faq1Question:`Is it really free?`,faq1Answer:`Yes, completely free. No subscription, no hidden fees. Your earnings land in your Frak wallet: real money, transferable to a bank account, with no fees.`,faq2Question:`When do I get my money?`,faq2Answer:`For every order generated by your link, your earnings are credited automatically to your Frak wallet. They become transferable once the brand confirms the purchase, with no minimum amount.`,faq3Question:`Do my friends pay more with my link?`,faq3Answer:`No, quite the opposite: you win and so do your friends. By ordering through your link, they also get cashback on their purchase.`,faq3AnswerNoReward:`No. Your link doesn't change the price: your friends pay exactly what everyone else pays.`,faq4Question:`Do I need to be an influencer?`,faq4Answer:`No, not at all. No application, no minimum follower count: the program is open to all our customers, whatever the size of your network.`,faq5Question:`What is Frak?`,faq5AnswerBeforeLink:`The partner that handles referral tracking and payouts for {BRAND}. `,faq5AnswerLinkText:`Frak`,faq5AnswerAfterLink:` never sells any data to third parties.`,attributionBeforeLink:`Program powered by `,attributionLinkText:`Frak`}},fr:{buttonShare:{text:`Partagez et gagnez {REWARD} !`},postPurchase:{refereeText:`Vous venez de gagner {REWARD} ! Partagez avec vos amis pour gagner encore plus.`,refereeNoRewardText:`Vous venez de gagner une récompense ! Partagez avec vos amis pour gagner encore plus.`,referrerText:`Gagnez {REWARD} en partageant avec vos amis !`,referrerNoRewardText:`Partagez avec vos amis et gagnez des récompenses !`,ctaText:`Partagez et gagnez {REWARD}`,ctaNoRewardText:`Partagez et gagnez`},openInApp:{text:`Ouvrir dans l'app`,ariaLabel:`Ouvrir dans l'app Frak Wallet`},buttonWallet:{ariaLabel:`Partagez et gagnez des récompenses`},banner:{referralTitleReward:`Gagnez {REWARD} sur vos achats`,referralTitle:`Vous avez été parrainé !`,referralDescription:`Gagnez des récompenses après votre achat via l'application partenaire Frak.`,referralCta:`J'ai compris`,inappTitle:`Ouvrez dans votre navigateur`,inappDescription:`Pour une meilleure expérience et pour gagner vos récompenses, ouvrez cette page dans votre navigateur par défaut.`,inappCta:`Ouvrir le navigateur`,dismissLabel:`Fermer`},ambassador:{heroEyebrow:`Programme ambassadeur`,heroHeadline:`Devenez ambassadeur {BRAND}`,heroLede:`Vous aimez nos produits\xA0? Parlez-en autour de vous\xA0! Gagnez une récompense dès qu’un achat est réalisé grâce à vous.`,heroLedeReward:`Vous aimez nos produits\xA0? Parlez-en autour de vous\xA0! Gagnez {REWARD} dès qu’un achat est réalisé grâce à vous.`,heroCtaLabel:`Devenir ambassadeur`,heroFacesCaption:`Pas de formulaire, pas d’attente\xA0: tout le monde peut devenir ambassadeur immédiatement.`,heroImageAlt:`Ambassadrices et ambassadeurs {BRAND}`,heroRewardCaption:`pour vous, à chaque vente`,heroRewardRefereePill:`+ {REWARD} offerts à votre filleul`,heroRewardRefereePillNoReward:`+ un avantage pour votre filleul`,rewardEyebrow:`Programme de parrainage`,rewardHeadingReward:`{REWARD} pour vous à chaque vente`,rewardHeadingNoReward:`Une récompense pour vous à chaque vente`,rewardEstimateCaption:`Estimation\xA0: le montant dépend de la campagne et du panier de votre proche.`,rewardLede:`Pas de plafond\xA0: plus vous partagez, plus de ventes sont générées grâce à votre lien, plus vous gagnez\xA0!`,rewardCtaLabel:`Obtenir mon lien`,rewardFooterCaption:`Gratuit · sans engagement · versé sur votre compte bancaire`,rewardNoBankDetails:`sans donnée bancaire pour commencer`,rewardFallbackLabel:`Une récompense`,explainerTitle:`Comment ça marche`,explainerLede:`Trois gestes, rien de plus.`,explainerStep1Title:`Je partage à mes proches`,explainerStep1Description:`Via WhatsApp, en story Instagram, sur TikTok… mon lien unique, généré automatiquement.`,explainerStep2Title:`Je reçois de l’argent`,explainerStep2Description:`Crédité automatiquement dans mon porte-monnaie à chaque vente générée grâce à mon lien de recommandation.`,explainerStep3Title:`Je récupère mon argent`,explainerStep3Description:`En téléchargeant l’app Frak, je transfère mes gains sur mon compte bancaire.`,winWinHeading:`Vos proches y gagnent aussi`,winWinLede:`En conseillant {BRAND} à vos proches, non seulement vous leur faites découvrir de super produits, mais en plus, grâce à votre lien, ils bénéficient d’un cashback sur leur première commande\xA0: ils peuvent vous dire merci\xA0!`,winWinCard1Title:`Vous`,winWinCard1Description:`sur votre porte-monnaie sécurisé, à chaque vente`,winWinCard2Title:`Votre filleul`,winWinCard2Description:`en cashback sur son porte-monnaie sécurisé, à sa première commande`,referralHeading:`Votre lien d’ambassadeur`,referralLede:`Enfin un vrai programme de parrainage rémunérateur\xA0!`,referralCtaLabel:`Partager mon lien`,storeHeading:`Suivez vos gains en temps réel`,storeLede:`L’app Frak vous prévient dès qu’un ami commande, et centralise vos gains sur toutes les marques partenaires.`,storeAppBadgeAriaLabel:`Télécharger dans l’App Store`,storePlayBadgeAriaLabel:`Disponible sur Google Play`,storeQrLabel:`QR code pour installer l’app Frak`,storeQrCaption:`Scannez pour installer`,faqHeading:`Questions fréquentes`,faq1Question:`C’est vraiment gratuit\xA0?`,faq1Answer:`Oui, totalement gratuit. Pas d’abonnement, pas de frais cachés. Vos gains arrivent dans votre porte-monnaie Frak\xA0: de l’argent réel, transférable vers un compte bancaire, sans commission.`,faq2Question:`Quand est-ce que je reçois mon argent\xA0?`,faq2Answer:`À chaque commande générée par votre lien, vos gains sont crédités automatiquement dans votre porte-monnaie Frak. Ils deviennent transférables une fois l’achat confirmé par la marque, sans montant minimum.`,faq3Question:`Mes amis paient-ils plus cher avec mon lien\xA0?`,faq3Answer:`Non, au contraire\xA0: vous êtes gagnant et vos proches aussi. En commandant via votre lien, ils reçoivent eux aussi un cashback sur leur achat.`,faq3AnswerNoReward:`Non. Votre lien ne change rien au prix\xA0: vos proches paient exactement le même montant que tout le monde.`,faq4Question:`Il faut être influenceur\xA0?`,faq4Answer:`Non, pas du tout. Aucune candidature, aucun minimum de followers\xA0: le programme est ouvert à tous nos clients, quelle que soit la taille de votre réseau.`,faq5Question:`C’est quoi Frak\xA0?`,faq5AnswerBeforeLink:`Le partenaire qui gère le suivi des parrainages et le versement des gains pour {BRAND}. `,faq5AnswerLinkText:`Frak`,faq5AnswerAfterLink:` ne vend aucune donnée à des tiers.`,attributionBeforeLink:`Programme propulsé par `,attributionLinkText:`Frak`}}};var vt=0;Array.isArray;function yt(e,t,n,r,i,a){t||={};var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--vt,__i:-1,__u:0,__source:i,__self:a};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return o.vnode&&o.vnode(u),u}export{pt as a,Ve as c,q as d,J as f,D as h,gt as i,Fe as l,we as m,_t as n,ft as o,Ie as p,ht as r,We as s,yt as t,Y as u};
package/cdn/loader.js CHANGED
@@ -121,4 +121,4 @@ super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=H;if(Ne(e,`tag`),e<0||e>255)throw new
121
121
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
122
122
  const G=an(en({p:BigInt(`0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff`),n:BigInt(`0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551`),h:BigInt(1),a:BigInt(`0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc`),b:BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`),Gx:BigInt(`0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296`),Gy:BigInt(`0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5`)}),be),on=`pkcs8`,sn=on,cn=`spki`
123
123
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
124
- ;function K(){let e=globalThis?.crypto?.subtle;if(typeof e==`object`&&e)return e;throw Error(`crypto.subtle must be defined`)}function ln(e,t){return async function(n){let r=await e();return{secretKey:r,publicKey:await t(r)}}}function un(e){let t=e.match(/[0-9a-f]{2}/gi);if(!t||t.length*2!==e.length)throw Error(`invalid hex`);return Uint8Array.from(t,e=>Number.parseInt(e,16))}function dn(e){let t={...e};for(let[e,n]of Object.entries(t))Array.isArray(n)&&(t[e]=n.slice());return t}function fn(e,t){if(t.type!==e)throw Error(`invalid key type, expected ${e}`)}function pn(e,t,n,r){let i=t?[`deriveBits`]:[`sign`],a=t?[]:[`verify`],o=(e,t)=>t===`jwk`?e:new Uint8Array(e),s={async import(t,n){let r=await K().importKey(n,t,e,!0,a);return fn(`public`,r),r},async export(e,t){fn(`public`,e);let n=await K().exportKey(t,e);return o(n,t)},async convert(e,t,n){return s.export(await s.import(e,t),n)}},c={async import(a,o){let s=K(),c;if(o===`raw`){let t=j(a,n,`secretKey`),o=un(r),l=new Uint8Array(o.length+t.length);l.set(o,0),l.set(t,o.length),c=await s.importKey(on,l,e,!0,i)}else t&&o===`jwk`&&(a={...a,key_ops:i}),c=await s.importKey(o,a,e,!0,i);return fn(`private`,c),c},async export(e,t){let r=K();if(fn(`private`,e),t===`raw`){let t=(await r.exportKey(`jwk`,e)).d.replace(/-/g,`+`).replace(/_/g,`/`),i=t.length%4?`=`.repeat(4-t.length%4):``,a=atob(t+i),o=Uint8Array.from(a,e=>e.charCodeAt(0)),s=new Uint8Array(n);return s.set(o,n-o.length),s}let i=await r.exportKey(t,e);return o(i,t)},async convert(e,t,n){return c.export(await c.import(e,t),n)}};async function l(e,t={}){L(t,{},{formatSec:`string`,formatPub:`string`},`opts`);let n=t.formatSec??sn,r=t.formatPub??cn,i=n===`jwk`?{...e}:await c.convert(e,n,`jwk`);return delete i.d,i.key_ops=a,r===`jwk`?i:s.convert(i,`jwk`,r)}async function u(t=sn){let n=await K().generateKey(e,!0,i);return c.export(n.privateKey,t)}let d;return{pub:s,priv:c,async isSupported(){if(d!==void 0)return d;try{let n=K(),r=await n.generateKey(e,!0,i);return await c.export(r.privateKey,`jwk`),t&&await n.deriveBits({name:typeof e==`string`?e:e.name,public:r.publicKey},r.privateKey,8),d=!0}catch{return d=!1}},getPublicKey:l,keygen:ln(u,l),utils:Object.freeze({randomSecretKey:u,convertPublicKey:s.convert,convertSecretKey:c.convert})}}function mn(e,t){return{async sign(n,r,i={}){L(i,{},{formatSec:`string`,formatPub:`string`},`opts`);let a=ze(j(n,void 0,`message`)),o=await e.priv.import(r,i.formatSec??sn),s=await K().sign(t,o,a);return new Uint8Array(s)},async verify(n,r,i,a={}){L(a,{},{formatSec:`string`,formatPub:`string`},`opts`);let o=ze(j(n,void 0,`signature`)),s=ze(j(r,void 0,`message`)),c=await e.pub.import(i,a.formatPub??cn);return await K().verify(t,c,o,s)}}}function hn(e,t,n){return{async getSharedSecret(r,i,a={}){L(a,{},{formatSec:`string`,formatPub:`string`},`opts`);let o=a.formatSec===void 0?sn:a.formatSec,s=a.formatPub===void 0?cn:a.formatPub,c=De(i)?ze(j(i,void 0,`publicKey`)):dn(i),l=await e.priv.import(r,o),u=await e.pub.import(c,s),d=await K().deriveBits({name:typeof t==`string`?t:t.name,public:u},l,8*n);return new Uint8Array(d)}}}function gn(e,t,n,r){let i={name:`ECDH`,namedCurve:e},a=pn({name:`ECDSA`,namedCurve:e},!1,n,r),o=pn(i,!0,n,r);return Object.freeze({name:e,isSupported:a.isSupported,getPublicKey:a.getPublicKey,keygen:ln(a.utils.randomSecretKey,a.getPublicKey),...mn(a,{name:`ECDSA`,hash:{name:t}}),...hn(o,i,n),utils:Object.freeze({...a.utils,async convertSecretKey(e,t,n){let r=t===`jwk`?e:void 0;return Array.isArray(r?.key_ops)&&r.key_ops.length===1&&r.key_ops[0]===`deriveBits`?o.utils.convertSecretKey(e,t,n):a.utils.convertSecretKey(e,t,n)}})})}const _n=gn(`P-256`,`SHA-256`,32,`3041020100301306072a8648ce3d020106082a8648ce3d030107042730250201010420`),vn={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 yn=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}}},bn=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 xn(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 l(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(e){console.error(`[RPC Client] Lifecycle handler error:`,e)}}async function u(e){let t={origin:r,source:null};for(let n of i)n.onRequest&&await n.onRequest(e,t);return e}async function d(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 f(e){try{if(new URL(e.origin).origin.toLowerCase()!==new URL(r).origin.toLowerCase())return}catch(e){console.error(`[RPC Client] Invalid origin`,e);return}if(s(e.data)){await l(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 d(e.data,r)}catch(e){console.error(`[RPC Client] Middleware error on response:`,e);return}let n=o.get(e.data.id);n&&n(t)}async function p(e){let n=await u(e);t.postMessage(n,r)}function m(e){t.postMessage(e,r)}function h(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}n.addEventListener(`message`,f);function g(e){let t=h(),n=new bn;return o.set(t,e=>{e.error?n.reject(new yn(e.error.code,e.error.message,e.error.data)):n.resolve(e.result),o.delete(t)}),p({id:t,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{o.delete(t),n.reject(e)}),n.promise}function _(e,t){let n=h();return o.set(n,e=>{e.error?(console.error(`[RPC Client] Listener error:`,e.error),o.delete(n)):t(e.result)}),p({id:n,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{console.error(`[RPC Client] Failed to send listener request:`,e),o.delete(n)}),()=>{o.delete(n)}}function v(){n.removeEventListener(`message`,f),o.clear()}return{request:g,listen:_,sendLifecycle:m,cleanup:v}}function Sn(e){return new TextEncoder().encode(JSON.stringify(e))}function Cn(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}const wn=`__frakEnv`,Tn={prod:{wallet:`https://wallet.frak.id`,backend:`https://backend.frak.id`},dev:{wallet:`https://wallet-dev.frak.id`,backend:`https://backend.gcp-dev.frak.id`}};function En(){return typeof window<`u`}let Dn=Tn.prod;function On(e){return e.replace(/\/+$/,``)}function kn(e){return typeof e==`string`?Object.hasOwn(Tn,e)?Tn[e]:(console.error(`[Frak SDK] Unknown env "${e}", falling back to production. Expected "prod", "dev", or { wallet, backend }.`),Tn.prod):!e?.wallet||!e?.backend?(console.error("[Frak SDK] env must state both `wallet` and `backend` origins, falling back to production. Received:",e),Tn.prod):{wallet:On(e.wallet),backend:On(e.backend)}}function An(e){if(!e)return jn();let t=kn(e),n=En()?window[wn]:void 0;return n&&(n.wallet!==t.wallet||n.backend!==t.backend)&&console.warn(`[Frak SDK] env changed after being published; the last value wins for every SDK call on this page.`,{previous:n,next:t}),Dn=t,En()&&(window[wn]=t),t}function jn(){return En()?window[wn]??Dn:Dn}function Mn(){return jn().wallet}function q(){return jn().backend}var Nn=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}};let Pn;function Fn(){return Pn||={promiseCache:new Nn(1024),responseCache:new Nn(1024),failureCache:new Nn(1024)},Pn}async function In(e,{cacheKey:t,cacheTime:n=3e4}){let{promiseCache:r,responseCache:i,failureCache:a}=Fn();if(n>0){let e=i.get(t);if(e&&Date.now()-e.created<n)return e.data}let o=a.get(t);if(o&&Date.now()-o<1e3)throw Error(`Cache: ${t} recently failed, backing off`);let s=r.get(t);s||(s=e(),r.set(t,s));try{let e=await s;return i.set(t,{data:e,created:Date.now()}),a.delete(t),e}catch(e){throw a.set(t,Date.now()),e}finally{r.delete(t)}}function Ln(){Pn&&(Pn.promiseCache.clear(),Pn.responseCache.clear(),Pn.failureCache.clear())}const Rn=`__frakSdkConfig`,zn=`frak-config-cache`,Bn=`frak-merchant-id`,Vn={key:zn},J=typeof window<`u`;function Hn(){return{isResolved:!1,merchantId:``}}let Un=null;function Wn(){if(!J)return null;try{let e=localStorage.getItem(Vn.key);if(!e)return null;let t=JSON.parse(e);return t.config?.isResolved?(Un=t,t):null}catch{return null}}function Gn(){return(Un??Wn())?.config}function Kn(){let e=Un??Wn();return e?Date.now()-e.timestamp<3e4:!1}function qn(e){if(J&&e.isResolved)try{let t={config:e,timestamp:Date.now()};localStorage.setItem(Vn.key,JSON.stringify(t)),Un=t}catch{}}function Jn(){if(J){Un=null;try{localStorage.removeItem(Vn.key)}catch{}}}function Yn(){J&&(window[Rn]||(window[Rn]=Gn()??Hn()))}function Xn(){return J?(Yn(),window[Rn]??Hn()):Hn()}function Zn(e){J&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function Qn(e){return e??(J?window.location.hostname:``)}async function $n(e,t){try{let n=q(),r=t?`&lang=${encodeURIComponent(t)}`:``,i=await fetch(`${n}/user/merchant/resolve?domain=${encodeURIComponent(e)}${r}`);if(!i.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${e}: ${i.status}`);return}let a=await i.json();if(J)try{sessionStorage.setItem(Bn,a.merchantId)}catch{}return a}catch(e){console.warn(`[Frak SDK] Failed to fetch merchant config:`,e);return}}const Y={getConfig:Xn,get isResolved(){return Xn().isResolved},get isCacheFresh(){return Kn()},setCacheScope(e,t){let n=`${e}:${t??``}`;Vn.key=`${zn}:${n}`,Un=null},setConfig(e){if(J&&(window[Rn]=e),qn(e),Zn(e),J&&e.merchantId)try{sessionStorage.setItem(Bn,e.merchantId)}catch{}},reset(){let e=Gn()??Hn();J&&(window[Rn]=e),Zn(e)},clearCache(){if(Jn(),Ln(),J)try{sessionStorage.removeItem(Bn)}catch{}},resolve(e,t){let n=Qn(e);return n?In(async()=>{let e=await $n(n,t);if(!e)throw Error(`Config resolution returned empty`);return e},{cacheKey:`sdkConfig:${n}:${t??``}`,cacheTime:1/0}).catch(()=>void 0):Promise.resolve(void 0)},getMerchantId(){let e=Xn();if(e.isResolved&&e.merchantId)return e.merchantId;if(J)try{return sessionStorage.getItem(Bn)??void 0}catch{}},async resolveMerchantId(e){return Y.getMerchantId()||(await Y.resolve(e))?.merchantId}};function er(){if(!(typeof navigator>`u`))return navigator.locks}async function tr(e,t,n={}){let r=er();if(!r)return t();if(n.ifAvailable){let n=!1;try{return await r.request(e,{ifAvailable:!0},async e=>{if(e)return n=!0,t()})}catch(e){if(n)throw e;return t()}}let i=new AbortController,a=setTimeout(()=>i.abort(),5e3),o=!1;try{return await r.request(e,{signal:i.signal},()=>(o=!0,t()))}catch(e){if(o)throw e;return t()}finally{clearTimeout(a)}}async function nr(e){return p(be(e))}const rr=`frak-client-id`,ir=`frak-client-key`,ar=`frak-client-id-legacy`,or=h(`308187020100301306072a8648ce3d020106082a8648ce3d030107046d306b0201010420`),sr=h(`a144034200`),cr={formatSec:`pkcs8`,formatPub:`raw`};function lr(e,t){let n=new Uint8Array(or.length+32+sr.length+65),r=0;for(let i of[or,e,sr,t])n.set(i,r),r+=i.length;return n}const ur=new Uint8Array(32).fill(1),dr=new Uint8Array(32);let fr=null;async function pr(){try{if(!await _n.isSupported())return G;let e=lr(ur,G.getPublicKey(ur,!1));return await _n.sign(dr,e,cr),_n}catch{return G}}function mr(){return fr??=pr(),fr}function hr(e,t,n,r){if(e===_n){let e=lr(n,r);return _n.sign(t,e,cr)}return Promise.resolve(G.sign(t,n,{prehash:!0}))}const gr=()=>typeof window<`u`&&!!window.localStorage;let _r=null;function vr(e){let t=m(e);if(_r?.keyHex===t)return _r.publicKey;let n=G.getPublicKey(e,!1);return _r={keyHex:t,publicKey:n},n}function yr(){if(gr())return localStorage.getItem(ar)??void 0}function br(){gr()&&localStorage.removeItem(ar)}function xr(){let e=localStorage.getItem(ir);if(!e)return null;if(!/^[0-9a-f]{64}$/i.test(e))throw Error(`[Frak SDK] Corrupt client key`);return h(e)}function Sr(e){try{for(let[t,n]of e)localStorage.setItem(t,n)}catch{}}async function Cr(){if(!gr())throw Error(`[Frak SDK] No window/localStorage available to derive a client id`);if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`[Frak SDK] crypto.getRandomValues unavailable, cannot derive a client id`);return tr(`frak-identity-key`,wr)}async function wr(){let e=localStorage.getItem(rr),t,n,r;try{t=xr(),n=t??G.utils.randomSecretKey(),r=await nr(vr(n))}catch(e){throw localStorage.removeItem(ir),_r=null,e}if(t){e!==r&&Sr([[rr,r]]);let t=yr();return{clientId:r,...t&&{pendingLegacyId:t}}}return Sr([...e?[[ar,e]]:[],[ir,m(n)],[rr,r]]),{clientId:r,...e&&{pendingLegacyId:e}}}async function X(e){if(!gr())return null;try{let t=xr();if(!t)return null;let n=e.ts??Math.floor(Date.now()/1e3),r=f({op:e.op,merchantId:e.merchantId,anonymousId:e.anonymousId,binding:e.binding??new Uint8Array,ts:n}),i=vr(t),a=await mr(),o;try{o=await hr(a,r,t,i)}catch(e){if(a===G)throw e;fr=Promise.resolve(G),o=await hr(G,r,t,i)}return _({v:1,pk:i,ts:n,sig:o})}catch{return null}}function Tr(){return{"x-frak-sdk-version":`1.4.2-beta.9b2f57a0`}}const Er=new Set([`PROOF_REQUIRED`,`PROOF_OR_TOKEN_REQUIRED`,`MISSING_ANONYMOUS_ID`]);async function Dr(e){if(e.status>=500||e.status===403)return!0;try{let t=await e.clone().json();return typeof t.code==`string`&&Er.has(t.code)}catch{return!1}}async function Or({legacyId:e,derivedId:t}){if(!(typeof window>`u`)){if(!e||e===t){br();return}await tr(`frak-legacy-merge`,async()=>{yr()===e&&await kr({legacyId:e,derivedId:t})},{ifAvailable:!0})}}async function kr({legacyId:e,derivedId:t}){try{let n=await Y.resolveMerchantId();if(!n)return;let r=await X({op:`frak-merge-v1`,merchantId:n,anonymousId:t});if(!r)return;let i=q(),a=await fetch(`${i}/user/identity/merge/initiate`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,...Tr()},body:JSON.stringify({sourceAnonymousId:t,merchantId:n,proof:r})});if(!a.ok){await Dr(a)||br();return}let{mergeToken:o}=await a.json();if(!o)return;let s=await fetch(`${i}/user/identity/merge/execute`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,...Tr()},body:JSON.stringify({mergeToken:o,targetAnonymousId:e,merchantId:n})});if(s.ok){br();return}await Dr(s)||br()}catch{}}let Ar=null,jr=null;async function Mr(){return Ar||jr||(jr=Cr().then(({clientId:e,pendingLegacyId:t})=>(Ar=e,t&&Or({legacyId:t,derivedId:e}),e)),jr)}function Nr(){if(Ar)return Ar;Mr().catch(()=>{})}async function Z(){return Ar||Mr()}function Pr(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function Fr(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 Ir(e){return Pr(Sn(e))}function Lr(e,t,n,r,i,a,o){let s=Ir(Rr({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,proof:o})),c=new URL(e);return c.pathname=`/sso`,c.searchParams.set(`p`,s),c.toString()}function Rr(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},pf:e.proof}}function zr(e){return{...e,directExit:e.directExit??!e.redirectUrl}}async function Br(e,t){let{metadata:n,customizations:r}=e.config,i=Nr()??await Z().catch(()=>void 0),a=await Y.resolveMerchantId()??``,o=i&&a?await X({op:`frak-sso-v1`,merchantId:a,anonymousId:i}):null;return{ssoUrl:Lr(Mn(),zr(t),a,n.name,i,r?.css,o??void 0)}}const Vr=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,Hr=`frak-sso`;async function Ur(e,t){let{metadata:n,customizations:r}=e.config;if(`ssoUrl`in t)return Wr(t.ssoUrl),await e.request({method:`frak_openSso`,params:[{},n.name,r?.css]})??{};let i=zr(t);return i.openInSameWindow??!!i.redirectUrl?await e.request({method:`frak_openSso`,params:[i,n.name,r?.css]}):(Wr(i.ssoPopupUrl??(await Br(e,i)).ssoUrl),await e.request({method:`frak_openSso`,params:[i,n.name,r?.css]})??{})}function Wr(e){let t=window.open(e,Hr,Vr);if(!t)throw Error(`Popup was blocked. Please allow popups for this site.`);t.focus()}function Q(e,t,n){if(e)try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}function Gr(e,t){let n=e.get(t);if(n!==null)return n;let r=t.toLowerCase();for(let[t,n]of e)if(t.toLowerCase()===r)return n;return null}function $(e,t){let n=t.toLowerCase(),r=[...e.keys()].filter(e=>e.toLowerCase()===n);for(let t of r)e.delete(t)}const Kr=/^0x[a-fA-F0-9]{40}$/;function qr(e){return typeof e==`string`&&Kr.test(e)}function Jr(e,t){return e.toLowerCase()===t.toLowerCase()}function Yr(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 Xr=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Zr(e){let t=`0x`;for(let n=0;n<20;n++)t+=Xr[e[n]];return t}function Qr(e){return`r`in e&&!(`v`in e)}function $r(e){return`v`in e&&e.v===2}const ei=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ti(e){return typeof e==`string`&&ei.test(e)}function ni(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 ri(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 ii(e){if(!ti(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`&&qr(e.w);if(!t&&!n||t&&!ti(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(ni(e.m),a),a+=16,i.setUint32(a,e.t,!1),a+=4,t&&(r.set(ni(e.c),a),a+=16),n&&(r.set(Yr(e.w),a),a+=20),r}function ai(e){if(e.length<21)return null;let t=e[0];if((t&15)!=2||t&192)return null;let n=!!(t&16),r=!!(t&32);if(!n&&!r)return null;let i=21+(n?16:0)+(r?20:0);if(e.length!==i)return null;let a=1,o=ri(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=ri(e.subarray(a,a+16)),a+=16),r){let t=Zr(e.subarray(a,a+20));if(!qr(t))return null;c.w=t,a+=20}return c}const oi=`fCtx`;function si(e){try{return new URL(e)}catch{return null}}function ci(e){if(e)try{if($r(e)){let t=ii(e);return t?Pr(t):void 0}return Pr(Yr(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function li(e){if(e&&e.length!==0)try{let t=Fr(e);if(t.length!==20)return ai(t)||void 0;let n=Zr(t);if(qr(n))return{r:n}}catch(t){console.error(`Error decompressing Frak context`,{e:t,context:e})}}function ui({url:e}){if(!e)return null;let t=si(e);if(!t)return null;let n=Gr(t.searchParams,oi);return n?li(n):null}function di(e){return{utm_source:e.utmSource??`frak`,utm_medium:e.utmMedium??void 0,utm_campaign:e.utmCampaign??void 0,utm_content:e.utmContent,utm_term:e.utmTerm,via:e.via??void 0,ref:e.ref??void 0}}function fi(e,t){let n=di(t??{});for(let[t,r]of Object.entries(n))r!==void 0&&r!==``&&(e.searchParams.has(t)||e.searchParams.set(t,r))}function pi({url:e,context:t,attribution:n}){if(!e)return null;let r=ci(t);if(!r)return null;let i=si(e);return i?($(i.searchParams,oi),i.searchParams.set(oi,r),fi(i,n),i.toString()):null}function mi(e){let t=si(e);return t?($(t.searchParams,oi),t.toString()):e}function hi({url:e,context:t}){if(typeof window>`u`||!window.location?.href){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?mi(n):pi({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const gi={compress:ci,decompress:li,parse:ui,update:pi,remove:mi,replaceUrl:hi},_i={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function vi(e){return e&&e in _i?e:`eur`}function yi(e){return e?_i[e]??_i.eur:_i.eur}function bi(e,t){let n=yi(t),r=vi(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function xi(e){return e.formatToParts(1.1).find(e=>e.type===`decimal`)?.value??`.`}function Si(e,t){let n=yi(t),r=vi(t),i=new Intl.NumberFormat(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2}),a=i.formatToParts(e),o=``,s=``,c=``,l=`suffix`,u=!1;for(let e of a)switch(e.type){case`integer`:case`group`:o+=e.value,u=!0;break;case`decimal`:case`fraction`:s+=e.value;break;case`currency`:c=e.value,l=u?`suffix`:`prefix`}return{integer:o,decimals:s||`${xi(i)}00`,unit:c,unitPosition:l}}function Ci(e){return{integer:String(e),unit:`%`,unitPosition:`suffix`}}function wi(e){return e?`${e}Amount`:`eurAmount`}var Ti=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(i){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 console.error(`Max retries reached:`,i),null}}async fetch(e,t,n={}){let r=`${this.baseUrl}${e}`;return this.post(r,t,n,0)}},Ei=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 Ti({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&&console.log(`[OpenPanel.dev]`,...e)}},Di=typeof document<`u`?document.currentScript:null;function Oi(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var ki=class extends Ei{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=Di,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=()=>{console.warn(`[OpenPanel] Failed to load replay script from`,t),e(null)},document.head.appendChild(n)})}return await import(`./replay-V6FXES7X.CgBxdfNp.js`)}catch(e){return console.warn(`[OpenPanel] Failed to load replay module`,e),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[Oi(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 Ai=`nexus-wallet-backup`,ji=`frakwallet://`;function Mi(e){let t=e?.split(`-`)[0]?.toLowerCase();return t===`en`||t===`fr`?t:void 0}function Ni(){return(typeof document<`u`?Mi(document.documentElement.lang):void 0)||(typeof navigator<`u`?Mi(navigator.language):void 0)}function Pi(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=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()))}function Fi(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}const Ii=ji.replace(`://`,``);function Li(e){return`intent://${e.slice(13)}#Intent;scheme=${Ii};end`}function Ri(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=Fi()&&zi(e)?Li(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function zi(e){return e.startsWith(ji)}function Bi(){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 Vi=Bi();function Hi(){return typeof navigator>`u`?!1:Vi?!0:/Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function Ui(){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 Wi=Ui();function Gi(e){Vi&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:Vi&&e.startsWith(`http://`)?window.location.href=`x-safari-http://${e.slice(7)}`:window.location.href=`${q()}/common/social?u=${encodeURIComponent(e)}`}const Ki={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`}};async function qi({config:e}){let t=document.querySelector(`#frak-wallet`);t&&t.remove();let n=document.createElement(`iframe`);n.id=Ki.id,n.name=Ki.name,n.allow=Ki.allow,n.style.zIndex=Ki.style.zIndex.toString(),Yi({iframe:n,isVisible:!1});let r=An(e?.env).wallet,i=await Mr().catch(e=>{console.warn(`[Frak SDK] Unable to derive a client id`,e)});return $i(r),$i(q()),n.src=Ji({walletUrl:r,clientId:i,preload:e?.preload}),new Promise(e=>{n.addEventListener(`load`,()=>e(n)),document.body.appendChild(n)})}function Ji({walletUrl:e=Mn(),clientId:t,preload:n}){let r=t?`${e}/listener?clientId=${encodeURIComponent(t)}`:`${e}/listener`;return!n||n.length===0?r:`${r}#preload=${n.join(`,`)}`}function Yi({iframe:e,isVisible:t}){if(!t){Zi(e),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.backgroundColor=`transparent`,e.style.border=`0`,e.style.margin=`0`,e.style.padding=`0`,e.style.pointerEvents=`auto`,Xi(e)}function Xi(e){if(typeof e.showPopover==`function`&&!e.hasAttribute(`popover`))try{e.setAttribute(`popover`,`manual`),e.showPopover()}catch{e.removeAttribute(`popover`)}}function Zi(e){if(typeof e.hidePopover==`function`){try{e.hidePopover()}catch{}e.removeAttribute(`popover`)}}function Qi(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(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}function $i(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 ea=Vi&&Wi;function ta(e){e?localStorage.setItem(Ai,e):localStorage.removeItem(Ai)}function na(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=aa(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function ra(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 ia(e){return e.includes(`/common/social`)}function aa(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 oa(e,t,n,r,i){if(i){let e=na(t,r);window.open(e,`_blank`);return}if(zi(t)){let i=na(t,r);Ri(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(ea&&ia(t))ra(r);else{let e=na(t,r);window.location.href=e}}function sa({iframe:e,targetOrigin:t}){let n=new bn;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`:ta(a.backup);break;case`remove-backup`:localStorage.removeItem(Ai);break;case`show`:case`hide`:Yi({iframe:e,isVisible:i===`show`});break;case`redirect`:oa(e,a.baseRedirectUrl,t,a.mergeToken,a.openInNewTab)}},isConnected:n.promise}}async function ca({config:e,iframe:t}){let n=An(e.env).wallet,r=e.metadata.lang??Ni(),i=e.domain??(typeof window<`u`?window.location.hostname:``);Y.setCacheScope(i,r),Y.reset();let a=Y.isCacheFresh?void 0:Y.resolve(e.domain,r),o=await Z().catch(()=>void 0),s=sa({iframe:t,targetOrigin:n}),c=new bn,l=Date.now();if(!t.contentWindow)throw new yn(vn.configError,`The iframe does not have a content window`);let u=xn({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await s.isConnected)throw new yn(vn.clientNotConnected,`The iframe provider isn't connected yet`);return await c.promise,t}}],lifecycleHandlers:{iframeLifecycle:(e,t)=>{s.handleEvent(e)}}}),d=la(u,s),f,p=!1,m=async()=>{p=!0,d(),f?.(),u.cleanup(),t.remove(),Ln(),Y.clearCache(),Y.reset()},h;{h=new ki({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!1,trackOutgoingLinks:!1,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdk_version`in t.properties||(t.properties={...t.properties,sdk_version:`1.4.2-beta.9b2f57a0`,...o&&{user_anonymous_client_id:o,__deviceId:o}}),!0)}),h.setGlobalProperties({sdk_version:`1.4.2-beta.9b2f57a0`,...o&&{user_anonymous_client_id:o,__deviceId:o}}),h.init(),h.track(`sdk_initialized`,{sdk_version:`1.4.2-beta.9b2f57a0`});let e=!1,t=setTimeout(()=>{e||(e=!0,h?.track(`sdk_iframe_handshake_failed`,{reason:`timeout`}))},3e4);s.isConnected.then(()=>{e||(e=!0,clearTimeout(t),h?.track(`sdk_iframe_connected`,{handshake_duration_ms:Date.now()-l}))}).catch(()=>{e||(e=!0,clearTimeout(t),h?.track(`sdk_iframe_handshake_failed`,{reason:`unknown`}))})}let g=ma({config:e,rpcClient:u,lifecycleManager:s,configPromise:a,contextSent:c,openPanel:h,clientId:o}).then(e=>{if(p){e();return}f=e}).catch(e=>{throw c.reject(e),e});return{config:e,waitForConnection:s.isConnected,waitForSetup:g,request:u.request,listenerRequest:u.listen,destroy:m,openPanel:h}}function la(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}function ua(e){return 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}function da(e,t){if(!e)return;let n=e.global??{};e.setGlobalProperties({...n,merchant_id:t.merchantId,domain:t.domain??``})}async function fa(e){let t=new TextEncoder().encode(e);if(typeof crypto<`u`&&crypto.subtle)try{let e=await crypto.subtle.digest(`SHA-256`,t);return new Uint8Array(e)}catch{}try{return be(t)}catch{return}}async function pa({merchantId:e,anonymousId:t,pendingMergeToken:n}){let r=n?await fa(n):void 0,[i,a,o]=await Promise.all([r?X({op:`frak-merge-v1`,merchantId:e,anonymousId:t,binding:r}):Promise.resolve(null),X({op:`frak-merge-v1`,merchantId:e,anonymousId:t}),X({op:`frak-install-v1`,merchantId:e,anonymousId:t})]);if(i||a||o)return{anonymousId:t,proofs:{...i&&{merge:i},...a&&{mergeSource:a},...o&&{install:o}}}}async function ma({config:e,rpcClient:t,lifecycleManager:n,configPromise:r,contextSent:i,openPanel:a,clientId:o}){await n.isConnected,Pi(t,n.isConnected);let s=new URL(window.location.href),c=s.searchParams.get(`fmt`)??void 0;c&&(s.searchParams.delete(`fmt`),window.history.replaceState({},``,s.toString()));let l=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;Y.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})},u=!1,d=Promise.resolve(),f=e=>{let n=u?void 0:c;u=!0;let r=ua(e),i=o,s=window.location.href;return da(a,e),d=d.then(async()=>{t.sendLifecycle({clientLifecycle:`resolved-config`,data:{merchantId:e.merchantId,domain:e.domain??``,allowedDomains:e.allowedDomains??[],sourceUrl:s,...i&&{sdkAnonymousId:i},...n&&{pendingMergeToken:n},...r&&{sdkConfig:r},...i&&{sdkIdentity:await pa({merchantId:e.merchantId,anonymousId:i,pendingMergeToken:n})}}})}).catch(e=>{console.error(`Failed to send lifecycle config`,e)}),d};Y.isResolved&&f(Y.getConfig()).then(i.resolve),r&&(l(await r),f(Y.getConfig()).then(i.resolve));async function p(){let n=e.customizations?.css;n&&t.sendLifecycle({clientLifecycle:`modal-css`,data:{cssLink:n}})}async function m(){let n=e.customizations?.i18n;n&&t.sendLifecycle({clientLifecycle:`modal-i18n`,data:{i18n:n}})}async function h(){if(typeof window>`u`)return;let e=window.localStorage.getItem(Ai);e&&t.sendLifecycle({clientLifecycle:`restore-backup`,data:{backup:e}})}return(await Promise.allSettled([p(),m(),h()])).some(e=>e.status===`rejected`)&&a?.track(`sdk_iframe_handshake_failed`,{reason:`asset_push`}),ha(f)}function ha(e){if(typeof document>`u`)return()=>{};let t=0,n=n=>{if(document.visibilityState!==`visible`||!Y.isResolved)return;let r=Date.now();n&&r-t<6e4||(t=r,e(Y.getConfig()))},r=()=>n(!0),i=setInterval(()=>n(!1),3e5);return document.addEventListener(`visibilitychange`,r),()=>{clearInterval(i),document.removeEventListener(`visibilitychange`,r)}}function ga(e){return Cn(Fr(e))}function _a(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function va(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 ya(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e==`string`&&e.trim()!==``){let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}}function ba(e){if(typeof e!=`string`)return;let t=e.trim();return t===``?void 0:t}function xa(e){if(!e||typeof e!=`object`)return;let t=e,n={},r=ba(t.productId);r!==void 0&&(n.productId=r);let i=ba(t.sku);i!==void 0&&(n.sku=i);let a=ba(t.name);a!==void 0&&(n.name=a);let o=ya(t.quantity);o!==void 0&&(n.quantity=o);let s=ya(t.unitPrice);s!==void 0&&(n.unitPrice=s);let c=ya(t.totalPrice);return c!==void 0&&(n.totalPrice=c),Object.keys(n).length>0?n:void 0}function Sa(e){let t=va(e);if(!t)return;let n=[];for(let e of t){let t=xa(e);t&&n.push(t)}return n.length>0?n:void 0}function Ca(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.title==`string`?t.title.trim():``,r=xa(e);if(n===``&&!r)return null;let i={...r};return n!==``&&(i.title=n),typeof t.imageUrl==`string`&&_a(t.imageUrl)&&(i.imageUrl=t.imageUrl),typeof t.link==`string`&&_a(t.link)&&(i.link=t.link),typeof t.utmContent==`string`&&t.utmContent!==``&&(i.utmContent=t.utmContent),i}function wa(e){let t=va(e);if(!t)return;let n=[];for(let e of t){let t=Ca(e);t&&n.push(t)}return n.length>0?n:void 0}function Ta(e){if(!e)return;let t;try{t=ga(e)}catch{return}if(t!==null)return wa(t)}async function Ea({config:e}){let t=Da(e),n=await qi({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=await ca({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function Da(e){let t=vi(e.metadata.currency);return{...e,metadata:{...e.metadata,currency:t}}}function Oa({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 ka=t({DEEP_LINK_SCHEME:()=>ji,FrakContextManager:()=>gi,areAddressesEqual:()=>Jr,base64urlDecode:()=>Fr,base64urlEncode:()=>Pr,baseIframeProps:()=>Ki,buildListenerUrl:()=>Ji,clearAllCache:()=>Ln,coerceProductCandidates:()=>va,compressJsonToB64:()=>Ir,createIFrameFrakClient:()=>ca,decodeProductsParam:()=>Ta,decompressJsonFromB64:()=>ga,deleteQueryParamCaseInsensitive:()=>$,detectPageLanguage:()=>Ni,findIframeInOpener:()=>Qi,formatAmount:()=>bi,formatAmountParts:()=>Si,generateSsoUrl:()=>Lr,getBackendUrl:()=>q,getClientId:()=>Nr,getClientIdAsync:()=>Z,getCurrencyAmountKey:()=>wi,getEnvironment:()=>jn,getQueryParamCaseInsensitive:()=>Gr,getSupportedCurrency:()=>vi,isIOS:()=>Vi,isInAppBrowser:()=>Wi,isMobile:()=>Hi,mergeAttribution:()=>Oa,normalizeProductDetails:()=>xa,normalizeSharingProduct:()=>Ca,redirectToExternalBrowser:()=>Gi,sanitizeProductDetailsList:()=>Sa,sanitizeSharingProducts:()=>wa,sdkConfigStore:()=>Y,setEnvironment:()=>An,setupClient:()=>Ea,ssoPopupFeatures:()=>Vr,ssoPopupName:()=>Hr,trackEvent:()=>Q,triggerDeepLinkWithFallback:()=>Ri,withCache:()=>In});async function Aa(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 ja(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function Ma(e){if(typeof window>`u`)return;let t=await Z().catch(()=>void 0);if(!t)return;let n=await Y.resolveMerchantId();if(!n)return;let r=`frak-identity-ensured-${n}-${t}`;if(!window.sessionStorage.getItem(r))try{let i=q(),a=await X({op:`frak-ensure-v1`,merchantId:n,anonymousId:t});(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,...Tr()},body:JSON.stringify({merchantId:n,...a&&{proof:a}})})).ok&&window.sessionStorage.setItem(r,`1`)}catch{}}async function Na(e,t){return In(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:t?.cacheTime})}async function Pa(e,t){return In(async()=>{let t=await Z().catch(()=>void 0),n=await Y.resolveMerchantId(),r=t&&n?await X({op:`frak-merge-v1`,merchantId:n,anonymousId:t}):null;return e.request({method:`frak_getMergeToken`,params:r?[r]:void 0})},{cacheKey:`frak_getMergeToken`,cacheTime:t?.cacheTime})}async function Fa(e,t){return In(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:t?.cacheTime})}async function Ia(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function La(e,t){try{let n=await Z().catch(()=>void 0);await e.request({method:`frak_sendInteraction`,params:[t,{clientId:n}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}function Ra(e,t,n){return $r(t)?(Q(e,`user_referred_started`,{referrer_client_id:t.c,referrer_wallet:t.w,wallet_status:n?.key}),La(e,{type:`arrival`,referrerClientId:t.c,referrerMerchantId:t.m,referrerWallet:t.w,referralTimestamp:t.t}),!0):Qr(t)?(Q(e,`user_referred_started`,{referrer:t.r,wallet_status:n?.key}),La(e,{type:`arrival`,referrerWallet:t.r}),!0):!1}function za(e,t,n){return!t&&!n?null:{v:2,m:e,t:Math.floor(Date.now()/1e3),...t?{c:t}:{},...n?{w:n}:{}}}function Ba(e,t,n){return $r(e)?e.w&&n?.wallet?Jr(e.w,n.wallet):e.c?t===e.c:!1:Qr(e)&&n?.wallet?Jr(e.r,n.wallet):!1}async function Va(e,{walletStatus:t,frakContext:n,options:r}){if(!n)return`no-referrer`;let i=await Z().catch(()=>void 0);if(Ba(n,i,t))return`self-referral`;if(!Ra(e,n,t))return`no-referrer`;let a=$r(n)?n.m:r?.merchantId,o=r?.alwaysAppendUrl&&a?za(a,i,t?.wallet):null;return gi.replaceUrl({url:window.location.href,context:o}),Q(e,`user_referred_completed`,{status:`success`}),`success`}async function Ha(e,{options:t}={}){let n=gi.parse({url:window.location.href}),r=await Ka(e);try{return await Va(e,{walletStatus:r,frakContext:n,options:t})}catch(e){console.warn(`Error processing referral`,{error:e})}}const Ua=`frak:referral-success`;async function Wa(e){try{await Ha(e)===`success`&&window.dispatchEvent(new Event(Ua))}catch(e){console.warn(`[Frak] Referral setup failed`,e)}}async function Ga(e){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let t=window.sessionStorage.getItem(`frak-wallet-interaction-token`),n=await Z().catch(()=>void 0);if(!t&&!n){console.warn(`[Frak] No identity found, skipping purchase check`);return}let r=e.merchantId??await Y.resolveMerchantId();if(!r){console.warn(`[Frak] No merchant id found, skipping purchase check`);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=q();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 Ka(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(qa(e,t),t));let n=new bn,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{qa(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function qa(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),Ma(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function Ja(e,{metadata:t,login:n}){return Ya(e,{steps:{login:n??{}},metadata:t})}function Ya(e,t){function n(n){return Ya(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return Ya(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}async function i(n,r){return n&&(t.metadata=n(t.metadata??{})),await Aa(e,t,r)}return{params:t,sendTx:n,reward:r,display:i}}async function Xa(e,{tx:t,metadata:n}){return(await Aa(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function Za(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 Qa(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 Aa(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??Za(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var $a=t({REFERRAL_SUCCESS_EVENT:()=>Ua,displayModal:()=>Aa,displaySharingPage:()=>ja,ensureIdentity:()=>Ma,getMerchantInformation:()=>Na,getMergeToken:()=>Pa,getUserReferralStatus:()=>Fa,modalBuilder:()=>Ja,openSso:()=>Ur,prepareSso:()=>Ia,prepareSsoUrl:()=>Br,processReferral:()=>Va,referralInteraction:()=>Ha,sendInteraction:()=>La,sendTransaction:()=>Xa,setupReferral:()=>Wa,siweAuthenticate:()=>Qa,trackPurchaseStatus:()=>Ga,watchWalletStatus:()=>Ka});async function eo(e,t,n){if(!window.FrakSetup?.client){console.error(`Frak client not found`);return}await ja(window.FrakSetup.client,{...n?.link&&{link:n.link},...n?.products?.length&&{products:n.products},...n?.checkoutToken&&{checkoutToken:n.checkoutToken},...e&&{metadata:{targetInteraction:e}}},t)}const to=[`frak-button-share`,`frak-button-wallet`,`frak-open-in-app`,`frak-post-purchase`,`frak-banner`].join(`,`);function no(){return typeof document>`u`||document.querySelector(to)===null?[]:[`sharing`]}const ro=`frak:client`;function io(){let e=new CustomEvent(ro);window.dispatchEvent(e)}function ao(e,t){if(window.FrakSetup?.client&&e===`add`){t();return}(e===`add`?window.addEventListener:window.removeEventListener)(ro,t,!1)}function oo(){return window.FrakSetup.core={...ka,...$a},window.FrakSetup?.client?Promise.resolve():In(()=>so(),{cacheKey:`frak-sdk-init`,cacheTime:1/0}).catch(e=>{Q(window.FrakSetup?.client,`sdk_init_failed`,{reason:e instanceof Error?e.message:typeof e==`string`?e:`unknown`,config_missing:!window.FrakSetup?.config})})}async function so(){if(!window.FrakSetup?.config)throw Error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`);let e=await Ea({config:co(window.FrakSetup.config)});if(!e)throw Error(`[Frak SDK] Failed to create client`);window.FrakSetup.client=e,io(),Wa(e),lo()}function co(e){return e.preload===void 0?{...e,preload:no()}:e}function lo(){let e=new URL(window.location.href);if(Gr(e.searchParams,`frakAction`)?.toLowerCase()!==`share`)return;let t=Gr(e.searchParams,`link`)??void 0,n=Gr(e.searchParams,`placement`)??void 0,r=Ta(Gr(e.searchParams,`products`));$(e.searchParams,`frakAction`),$(e.searchParams,`link`),$(e.searchParams,`placement`),$(e.searchParams,`products`),window.history.replaceState({},``,e.toString()),Q(window.FrakSetup?.client,`sharing_page_auto_opened`,{placement:n,has_link:!!t,has_products:!!r?.length}),eo(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(oo);const uo={"button-share":()=>import(`./ButtonShare.bYtZAlc0.js`),"button-wallet":()=>import(`./ButtonWallet.ENPAuGPm.js`),"open-in-app":()=>import(`./OpenInAppButton.BoGl6QtG.js`),"post-purchase":()=>import(`./PostPurchase.DGkoI2iK.js`),banner:()=>import(`./Banner.DUI-0KQP.js`)},fo=new MutationObserver(e=>{for(let{addedNodes:t}of e)for(let e of Array.from(t))e.nodeType===Node.ELEMENT_NODE&&po(e)});async function po(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=>mo(e)))}async function mo(e){if(customElements.get(e))return Promise.resolve();let t=e.replace(/^frak-/i,``);if(!(t in uo)){console.error(`Component ${e} is not supported.`);return}try{await uo[t]()}catch(e){console.error(e)}}po(document.body),fo.observe(document.documentElement,{subtree:!0,childList:!0});export{Y as C,o as D,s as E,n as O,Q as S,yn as T,Si as _,Ua as a,wi as b,Na as c,Ri as d,Sa as f,ji as g,Hi as h,Ga as i,wa as l,Gi as m,ao as n,Fa as o,Ni as p,eo as r,Pa as s,oo as t,Wi as u,Ci as v,vn as w,vi as x,bi as y};
124
+ ;function K(){let e=globalThis?.crypto?.subtle;if(typeof e==`object`&&e)return e;throw Error(`crypto.subtle must be defined`)}function ln(e,t){return async function(n){let r=await e();return{secretKey:r,publicKey:await t(r)}}}function un(e){let t=e.match(/[0-9a-f]{2}/gi);if(!t||t.length*2!==e.length)throw Error(`invalid hex`);return Uint8Array.from(t,e=>Number.parseInt(e,16))}function dn(e){let t={...e};for(let[e,n]of Object.entries(t))Array.isArray(n)&&(t[e]=n.slice());return t}function fn(e,t){if(t.type!==e)throw Error(`invalid key type, expected ${e}`)}function pn(e,t,n,r){let i=t?[`deriveBits`]:[`sign`],a=t?[]:[`verify`],o=(e,t)=>t===`jwk`?e:new Uint8Array(e),s={async import(t,n){let r=await K().importKey(n,t,e,!0,a);return fn(`public`,r),r},async export(e,t){fn(`public`,e);let n=await K().exportKey(t,e);return o(n,t)},async convert(e,t,n){return s.export(await s.import(e,t),n)}},c={async import(a,o){let s=K(),c;if(o===`raw`){let t=j(a,n,`secretKey`),o=un(r),l=new Uint8Array(o.length+t.length);l.set(o,0),l.set(t,o.length),c=await s.importKey(on,l,e,!0,i)}else t&&o===`jwk`&&(a={...a,key_ops:i}),c=await s.importKey(o,a,e,!0,i);return fn(`private`,c),c},async export(e,t){let r=K();if(fn(`private`,e),t===`raw`){let t=(await r.exportKey(`jwk`,e)).d.replace(/-/g,`+`).replace(/_/g,`/`),i=t.length%4?`=`.repeat(4-t.length%4):``,a=atob(t+i),o=Uint8Array.from(a,e=>e.charCodeAt(0)),s=new Uint8Array(n);return s.set(o,n-o.length),s}let i=await r.exportKey(t,e);return o(i,t)},async convert(e,t,n){return c.export(await c.import(e,t),n)}};async function l(e,t={}){L(t,{},{formatSec:`string`,formatPub:`string`},`opts`);let n=t.formatSec??sn,r=t.formatPub??cn,i=n===`jwk`?{...e}:await c.convert(e,n,`jwk`);return delete i.d,i.key_ops=a,r===`jwk`?i:s.convert(i,`jwk`,r)}async function u(t=sn){let n=await K().generateKey(e,!0,i);return c.export(n.privateKey,t)}let d;return{pub:s,priv:c,async isSupported(){if(d!==void 0)return d;try{let n=K(),r=await n.generateKey(e,!0,i);return await c.export(r.privateKey,`jwk`),t&&await n.deriveBits({name:typeof e==`string`?e:e.name,public:r.publicKey},r.privateKey,8),d=!0}catch{return d=!1}},getPublicKey:l,keygen:ln(u,l),utils:Object.freeze({randomSecretKey:u,convertPublicKey:s.convert,convertSecretKey:c.convert})}}function mn(e,t){return{async sign(n,r,i={}){L(i,{},{formatSec:`string`,formatPub:`string`},`opts`);let a=ze(j(n,void 0,`message`)),o=await e.priv.import(r,i.formatSec??sn),s=await K().sign(t,o,a);return new Uint8Array(s)},async verify(n,r,i,a={}){L(a,{},{formatSec:`string`,formatPub:`string`},`opts`);let o=ze(j(n,void 0,`signature`)),s=ze(j(r,void 0,`message`)),c=await e.pub.import(i,a.formatPub??cn);return await K().verify(t,c,o,s)}}}function hn(e,t,n){return{async getSharedSecret(r,i,a={}){L(a,{},{formatSec:`string`,formatPub:`string`},`opts`);let o=a.formatSec===void 0?sn:a.formatSec,s=a.formatPub===void 0?cn:a.formatPub,c=De(i)?ze(j(i,void 0,`publicKey`)):dn(i),l=await e.priv.import(r,o),u=await e.pub.import(c,s),d=await K().deriveBits({name:typeof t==`string`?t:t.name,public:u},l,8*n);return new Uint8Array(d)}}}function gn(e,t,n,r){let i={name:`ECDH`,namedCurve:e},a=pn({name:`ECDSA`,namedCurve:e},!1,n,r),o=pn(i,!0,n,r);return Object.freeze({name:e,isSupported:a.isSupported,getPublicKey:a.getPublicKey,keygen:ln(a.utils.randomSecretKey,a.getPublicKey),...mn(a,{name:`ECDSA`,hash:{name:t}}),...hn(o,i,n),utils:Object.freeze({...a.utils,async convertSecretKey(e,t,n){let r=t===`jwk`?e:void 0;return Array.isArray(r?.key_ops)&&r.key_ops.length===1&&r.key_ops[0]===`deriveBits`?o.utils.convertSecretKey(e,t,n):a.utils.convertSecretKey(e,t,n)}})})}const _n=gn(`P-256`,`SHA-256`,32,`3041020100301306072a8648ce3d020106082a8648ce3d030107042730250201010420`),vn={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 yn=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}}},bn=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 xn(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 l(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(e){console.error(`[RPC Client] Lifecycle handler error:`,e)}}async function u(e){let t={origin:r,source:null};for(let n of i)n.onRequest&&await n.onRequest(e,t);return e}async function d(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 f(e){try{if(new URL(e.origin).origin.toLowerCase()!==new URL(r).origin.toLowerCase())return}catch(e){console.error(`[RPC Client] Invalid origin`,e);return}if(s(e.data)){await l(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 d(e.data,r)}catch(e){console.error(`[RPC Client] Middleware error on response:`,e);return}let n=o.get(e.data.id);n&&n(t)}async function p(e){let n=await u(e);t.postMessage(n,r)}function m(e){t.postMessage(e,r)}function h(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}n.addEventListener(`message`,f);function g(e){let t=h(),n=new bn;return o.set(t,e=>{e.error?n.reject(new yn(e.error.code,e.error.message,e.error.data)):n.resolve(e.result),o.delete(t)}),p({id:t,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{o.delete(t),n.reject(e)}),n.promise}function _(e,t){let n=h();return o.set(n,e=>{e.error?(console.error(`[RPC Client] Listener error:`,e.error),o.delete(n)):t(e.result)}),p({id:n,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{console.error(`[RPC Client] Failed to send listener request:`,e),o.delete(n)}),()=>{o.delete(n)}}function v(){n.removeEventListener(`message`,f),o.clear()}return{request:g,listen:_,sendLifecycle:m,cleanup:v}}function Sn(e){return new TextEncoder().encode(JSON.stringify(e))}function Cn(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}const wn=`__frakEnv`,Tn={prod:{wallet:`https://wallet.frak.id`,backend:`https://backend.frak.id`},dev:{wallet:`https://wallet-dev.frak.id`,backend:`https://backend.gcp-dev.frak.id`}};function En(){return typeof window<`u`}let Dn=Tn.prod;function On(e){return e.replace(/\/+$/,``)}function kn(e){return typeof e==`string`?Object.hasOwn(Tn,e)?Tn[e]:(console.error(`[Frak SDK] Unknown env "${e}", falling back to production. Expected "prod", "dev", or { wallet, backend }.`),Tn.prod):!e?.wallet||!e?.backend?(console.error("[Frak SDK] env must state both `wallet` and `backend` origins, falling back to production. Received:",e),Tn.prod):{wallet:On(e.wallet),backend:On(e.backend)}}function An(e){if(!e)return jn();let t=kn(e),n=En()?window[wn]:void 0;return n&&(n.wallet!==t.wallet||n.backend!==t.backend)&&console.warn(`[Frak SDK] env changed after being published; the last value wins for every SDK call on this page.`,{previous:n,next:t}),Dn=t,En()&&(window[wn]=t),t}function jn(){return En()?window[wn]??Dn:Dn}function Mn(){return jn().wallet}function q(){return jn().backend}var Nn=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}};let Pn;function Fn(){return Pn||={promiseCache:new Nn(1024),responseCache:new Nn(1024),failureCache:new Nn(1024)},Pn}async function In(e,{cacheKey:t,cacheTime:n=3e4}){let{promiseCache:r,responseCache:i,failureCache:a}=Fn();if(n>0){let e=i.get(t);if(e&&Date.now()-e.created<n)return e.data}let o=a.get(t);if(o&&Date.now()-o<1e3)throw Error(`Cache: ${t} recently failed, backing off`);let s=r.get(t);s||(s=e(),r.set(t,s));try{let e=await s;return i.set(t,{data:e,created:Date.now()}),a.delete(t),e}catch(e){throw a.set(t,Date.now()),e}finally{r.delete(t)}}function Ln(){Pn&&(Pn.promiseCache.clear(),Pn.responseCache.clear(),Pn.failureCache.clear())}const Rn=`__frakSdkConfig`,zn=`frak-config-cache`,Bn=`frak-merchant-id`,Vn={key:zn},J=typeof window<`u`;function Hn(){return{isResolved:!1,merchantId:``}}let Un=null;function Wn(){if(!J)return null;try{let e=localStorage.getItem(Vn.key);if(!e)return null;let t=JSON.parse(e);return t.config?.isResolved?(Un=t,t):null}catch{return null}}function Gn(){return(Un??Wn())?.config}function Kn(){let e=Un??Wn();return e?Date.now()-e.timestamp<3e4:!1}function qn(e){if(J&&e.isResolved)try{let t={config:e,timestamp:Date.now()};localStorage.setItem(Vn.key,JSON.stringify(t)),Un=t}catch{}}function Jn(){if(J){Un=null;try{localStorage.removeItem(Vn.key)}catch{}}}function Yn(){J&&(window[Rn]||(window[Rn]=Gn()??Hn()))}function Xn(){return J?(Yn(),window[Rn]??Hn()):Hn()}function Zn(e){J&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function Qn(e){return e??(J?window.location.hostname:``)}async function $n(e,t){try{let n=q(),r=t?`&lang=${encodeURIComponent(t)}`:``,i=await fetch(`${n}/user/merchant/resolve?domain=${encodeURIComponent(e)}${r}`);if(!i.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${e}: ${i.status}`);return}let a=await i.json();if(J)try{sessionStorage.setItem(Bn,a.merchantId)}catch{}return a}catch(e){console.warn(`[Frak SDK] Failed to fetch merchant config:`,e);return}}const Y={getConfig:Xn,get isResolved(){return Xn().isResolved},get isCacheFresh(){return Kn()},setCacheScope(e,t){let n=`${e}:${t??``}`;Vn.key=`${zn}:${n}`,Un=null},setConfig(e){if(J&&(window[Rn]=e),qn(e),Zn(e),J&&e.merchantId)try{sessionStorage.setItem(Bn,e.merchantId)}catch{}},reset(){let e=Gn()??Hn();J&&(window[Rn]=e),Zn(e)},clearCache(){if(Jn(),Ln(),J)try{sessionStorage.removeItem(Bn)}catch{}},resolve(e,t){let n=Qn(e);return n?In(async()=>{let e=await $n(n,t);if(!e)throw Error(`Config resolution returned empty`);return e},{cacheKey:`sdkConfig:${n}:${t??``}`,cacheTime:1/0}).catch(()=>void 0):Promise.resolve(void 0)},getMerchantId(){let e=Xn();if(e.isResolved&&e.merchantId)return e.merchantId;if(J)try{return sessionStorage.getItem(Bn)??void 0}catch{}},async resolveMerchantId(e){return Y.getMerchantId()||(await Y.resolve(e))?.merchantId}};function er(){if(!(typeof navigator>`u`))return navigator.locks}async function tr(e,t,n={}){let r=er();if(!r)return t();if(n.ifAvailable){let n=!1;try{return await r.request(e,{ifAvailable:!0},async e=>{if(e)return n=!0,t()})}catch(e){if(n)throw e;return t()}}let i=new AbortController,a=setTimeout(()=>i.abort(),5e3),o=!1;try{return await r.request(e,{signal:i.signal},()=>(o=!0,t()))}catch(e){if(o)throw e;return t()}finally{clearTimeout(a)}}async function nr(e){return p(be(e))}const rr=`frak-client-id`,ir=`frak-client-key`,ar=`frak-client-id-legacy`,or=h(`308187020100301306072a8648ce3d020106082a8648ce3d030107046d306b0201010420`),sr=h(`a144034200`),cr={formatSec:`pkcs8`,formatPub:`raw`};function lr(e,t){let n=new Uint8Array(or.length+32+sr.length+65),r=0;for(let i of[or,e,sr,t])n.set(i,r),r+=i.length;return n}const ur=new Uint8Array(32).fill(1),dr=new Uint8Array(32);let fr=null;async function pr(){try{if(!await _n.isSupported())return G;let e=lr(ur,G.getPublicKey(ur,!1));return await _n.sign(dr,e,cr),_n}catch{return G}}function mr(){return fr??=pr(),fr}function hr(e,t,n,r){if(e===_n){let e=lr(n,r);return _n.sign(t,e,cr)}return Promise.resolve(G.sign(t,n,{prehash:!0}))}const gr=()=>typeof window<`u`&&!!window.localStorage;let _r=null;function vr(e){let t=m(e);if(_r?.keyHex===t)return _r.publicKey;let n=G.getPublicKey(e,!1);return _r={keyHex:t,publicKey:n},n}function yr(){if(gr())return localStorage.getItem(ar)??void 0}function br(){gr()&&localStorage.removeItem(ar)}function xr(){let e=localStorage.getItem(ir);if(!e)return null;if(!/^[0-9a-f]{64}$/i.test(e))throw Error(`[Frak SDK] Corrupt client key`);return h(e)}function Sr(e){try{for(let[t,n]of e)localStorage.setItem(t,n)}catch{}}async function Cr(){if(!gr())throw Error(`[Frak SDK] No window/localStorage available to derive a client id`);if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`[Frak SDK] crypto.getRandomValues unavailable, cannot derive a client id`);return tr(`frak-identity-key`,wr)}async function wr(){let e=localStorage.getItem(rr),t,n,r;try{t=xr(),n=t??G.utils.randomSecretKey(),r=await nr(vr(n))}catch(e){throw localStorage.removeItem(ir),_r=null,e}if(t){e!==r&&Sr([[rr,r]]);let t=yr();return{clientId:r,...t&&{pendingLegacyId:t}}}return Sr([...e?[[ar,e]]:[],[ir,m(n)],[rr,r]]),{clientId:r,...e&&{pendingLegacyId:e}}}async function X(e){if(!gr())return null;try{let t=xr();if(!t)return null;let n=e.ts??Math.floor(Date.now()/1e3),r=f({op:e.op,merchantId:e.merchantId,anonymousId:e.anonymousId,binding:e.binding??new Uint8Array,ts:n}),i=vr(t),a=await mr(),o;try{o=await hr(a,r,t,i)}catch(e){if(a===G)throw e;fr=Promise.resolve(G),o=await hr(G,r,t,i)}return _({v:1,pk:i,ts:n,sig:o})}catch{return null}}function Tr(){return{"x-frak-sdk-version":`1.4.2-beta.683f5bca`}}const Er=new Set([`PROOF_REQUIRED`,`PROOF_OR_TOKEN_REQUIRED`,`MISSING_ANONYMOUS_ID`]);async function Dr(e){if(e.status>=500||e.status===403)return!0;try{let t=await e.clone().json();return typeof t.code==`string`&&Er.has(t.code)}catch{return!1}}async function Or({legacyId:e,derivedId:t}){if(!(typeof window>`u`)){if(!e||e===t){br();return}await tr(`frak-legacy-merge`,async()=>{yr()===e&&await kr({legacyId:e,derivedId:t})},{ifAvailable:!0})}}async function kr({legacyId:e,derivedId:t}){try{let n=await Y.resolveMerchantId();if(!n)return;let r=await X({op:`frak-merge-v1`,merchantId:n,anonymousId:t});if(!r)return;let i=q(),a=await fetch(`${i}/user/identity/merge/initiate`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,...Tr()},body:JSON.stringify({sourceAnonymousId:t,merchantId:n,proof:r})});if(!a.ok){await Dr(a)||br();return}let{mergeToken:o}=await a.json();if(!o)return;let s=await fetch(`${i}/user/identity/merge/execute`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,...Tr()},body:JSON.stringify({mergeToken:o,targetAnonymousId:e,merchantId:n})});if(s.ok){br();return}await Dr(s)||br()}catch{}}let Ar=null,jr=null;async function Mr(){return Ar||jr||(jr=Cr().then(({clientId:e,pendingLegacyId:t})=>(Ar=e,t&&Or({legacyId:t,derivedId:e}),e)),jr)}function Nr(){if(Ar)return Ar;Mr().catch(()=>{})}async function Z(){return Ar||Mr()}function Pr(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function Fr(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 Ir(e){return Pr(Sn(e))}function Lr(e,t,n,r,i,a,o){let s=Ir(Rr({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,proof:o})),c=new URL(e);return c.pathname=`/sso`,c.searchParams.set(`p`,s),c.toString()}function Rr(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},pf:e.proof}}function zr(e){return{...e,directExit:e.directExit??!e.redirectUrl}}async function Br(e,t){let{metadata:n,customizations:r}=e.config,i=Nr()??await Z().catch(()=>void 0),a=await Y.resolveMerchantId()??``,o=i&&a?await X({op:`frak-sso-v1`,merchantId:a,anonymousId:i}):null;return{ssoUrl:Lr(Mn(),zr(t),a,n.name,i,r?.css,o??void 0)}}const Vr=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,Hr=`frak-sso`;async function Ur(e,t){let{metadata:n,customizations:r}=e.config;if(`ssoUrl`in t)return Wr(t.ssoUrl),await e.request({method:`frak_openSso`,params:[{},n.name,r?.css]})??{};let i=zr(t);return i.openInSameWindow??!!i.redirectUrl?await e.request({method:`frak_openSso`,params:[i,n.name,r?.css]}):(Wr(i.ssoPopupUrl??(await Br(e,i)).ssoUrl),await e.request({method:`frak_openSso`,params:[i,n.name,r?.css]})??{})}function Wr(e){let t=window.open(e,Hr,Vr);if(!t)throw Error(`Popup was blocked. Please allow popups for this site.`);t.focus()}function Q(e,t,n){if(e)try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}function Gr(e,t){let n=e.get(t);if(n!==null)return n;let r=t.toLowerCase();for(let[t,n]of e)if(t.toLowerCase()===r)return n;return null}function $(e,t){let n=t.toLowerCase(),r=[...e.keys()].filter(e=>e.toLowerCase()===n);for(let t of r)e.delete(t)}const Kr=/^0x[a-fA-F0-9]{40}$/;function qr(e){return typeof e==`string`&&Kr.test(e)}function Jr(e,t){return e.toLowerCase()===t.toLowerCase()}function Yr(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 Xr=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Zr(e){let t=`0x`;for(let n=0;n<20;n++)t+=Xr[e[n]];return t}function Qr(e){return`r`in e&&!(`v`in e)}function $r(e){return`v`in e&&e.v===2}const ei=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ti(e){return typeof e==`string`&&ei.test(e)}function ni(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 ri(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 ii(e){if(!ti(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`&&qr(e.w);if(!t&&!n||t&&!ti(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(ni(e.m),a),a+=16,i.setUint32(a,e.t,!1),a+=4,t&&(r.set(ni(e.c),a),a+=16),n&&(r.set(Yr(e.w),a),a+=20),r}function ai(e){if(e.length<21)return null;let t=e[0];if((t&15)!=2||t&192)return null;let n=!!(t&16),r=!!(t&32);if(!n&&!r)return null;let i=21+(n?16:0)+(r?20:0);if(e.length!==i)return null;let a=1,o=ri(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=ri(e.subarray(a,a+16)),a+=16),r){let t=Zr(e.subarray(a,a+20));if(!qr(t))return null;c.w=t,a+=20}return c}const oi=`fCtx`;function si(e){try{return new URL(e)}catch{return null}}function ci(e){if(e)try{if($r(e)){let t=ii(e);return t?Pr(t):void 0}return Pr(Yr(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function li(e){if(e&&e.length!==0)try{let t=Fr(e);if(t.length!==20)return ai(t)||void 0;let n=Zr(t);if(qr(n))return{r:n}}catch(t){console.error(`Error decompressing Frak context`,{e:t,context:e})}}function ui({url:e}){if(!e)return null;let t=si(e);if(!t)return null;let n=Gr(t.searchParams,oi);return n?li(n):null}function di(e){return{utm_source:e.utmSource??`frak`,utm_medium:e.utmMedium??void 0,utm_campaign:e.utmCampaign??void 0,utm_content:e.utmContent,utm_term:e.utmTerm,via:e.via??void 0,ref:e.ref??void 0}}function fi(e,t){let n=di(t??{});for(let[t,r]of Object.entries(n))r!==void 0&&r!==``&&(e.searchParams.has(t)||e.searchParams.set(t,r))}function pi({url:e,context:t,attribution:n}){if(!e)return null;let r=ci(t);if(!r)return null;let i=si(e);return i?($(i.searchParams,oi),i.searchParams.set(oi,r),fi(i,n),i.toString()):null}function mi(e){let t=si(e);return t?($(t.searchParams,oi),t.toString()):e}function hi({url:e,context:t}){if(typeof window>`u`||!window.location?.href){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?mi(n):pi({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const gi={compress:ci,decompress:li,parse:ui,update:pi,remove:mi,replaceUrl:hi},_i={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function vi(e){return e&&e in _i?e:`eur`}function yi(e){return e?_i[e]??_i.eur:_i.eur}function bi(e,t){let n=yi(t),r=vi(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function xi(e){return e.formatToParts(1.1).find(e=>e.type===`decimal`)?.value??`.`}function Si(e,t){let n=yi(t),r=vi(t),i=new Intl.NumberFormat(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2}),a=i.formatToParts(e),o=``,s=``,c=``,l=`suffix`,u=!1;for(let e of a)switch(e.type){case`integer`:case`group`:o+=e.value,u=!0;break;case`decimal`:case`fraction`:s+=e.value;break;case`currency`:c=e.value,l=u?`suffix`:`prefix`}return{integer:o,decimals:s||`${xi(i)}00`,unit:c,unitPosition:l}}function Ci(e){return{integer:String(e),unit:`%`,unitPosition:`suffix`}}function wi(e){return e?`${e}Amount`:`eurAmount`}var Ti=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(i){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 console.error(`Max retries reached:`,i),null}}async fetch(e,t,n={}){let r=`${this.baseUrl}${e}`;return this.post(r,t,n,0)}},Ei=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 Ti({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&&console.log(`[OpenPanel.dev]`,...e)}},Di=typeof document<`u`?document.currentScript:null;function Oi(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var ki=class extends Ei{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=Di,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=()=>{console.warn(`[OpenPanel] Failed to load replay script from`,t),e(null)},document.head.appendChild(n)})}return await import(`./replay-V6FXES7X.CgBxdfNp.js`)}catch(e){return console.warn(`[OpenPanel] Failed to load replay module`,e),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[Oi(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 Ai=`nexus-wallet-backup`,ji=`frakwallet://`;function Mi(e){let t=e?.split(`-`)[0]?.toLowerCase();return t===`en`||t===`fr`?t:void 0}function Ni(){return(typeof document<`u`?Mi(document.documentElement.lang):void 0)||(typeof navigator<`u`?Mi(navigator.language):void 0)}function Pi(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=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()))}function Fi(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}const Ii=ji.replace(`://`,``);function Li(e){return`intent://${e.slice(13)}#Intent;scheme=${Ii};end`}function Ri(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=Fi()&&zi(e)?Li(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function zi(e){return e.startsWith(ji)}function Bi(){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 Vi=Bi();function Hi(){return typeof navigator>`u`?!1:Vi?!0:/Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function Ui(){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 Wi=Ui();function Gi(e){Vi&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:Vi&&e.startsWith(`http://`)?window.location.href=`x-safari-http://${e.slice(7)}`:window.location.href=`${q()}/common/social?u=${encodeURIComponent(e)}`}const Ki={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`}};async function qi({config:e}){let t=document.querySelector(`#frak-wallet`);t&&t.remove();let n=document.createElement(`iframe`);n.id=Ki.id,n.name=Ki.name,n.allow=Ki.allow,n.style.zIndex=Ki.style.zIndex.toString(),Yi({iframe:n,isVisible:!1});let r=An(e?.env).wallet,i=await Mr().catch(e=>{console.warn(`[Frak SDK] Unable to derive a client id`,e)});return $i(r),$i(q()),n.src=Ji({walletUrl:r,clientId:i,preload:e?.preload}),new Promise(e=>{n.addEventListener(`load`,()=>e(n)),document.body.appendChild(n)})}function Ji({walletUrl:e=Mn(),clientId:t,preload:n}){let r=t?`${e}/listener?clientId=${encodeURIComponent(t)}`:`${e}/listener`;return!n||n.length===0?r:`${r}#preload=${n.join(`,`)}`}function Yi({iframe:e,isVisible:t}){if(!t){Zi(e),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.backgroundColor=`transparent`,e.style.border=`0`,e.style.margin=`0`,e.style.padding=`0`,e.style.pointerEvents=`auto`,Xi(e)}function Xi(e){if(typeof e.showPopover==`function`&&!e.hasAttribute(`popover`))try{e.setAttribute(`popover`,`manual`),e.showPopover()}catch{e.removeAttribute(`popover`)}}function Zi(e){if(typeof e.hidePopover==`function`){try{e.hidePopover()}catch{}e.removeAttribute(`popover`)}}function Qi(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(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}function $i(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 ea=Vi&&Wi;function ta(e){e?localStorage.setItem(Ai,e):localStorage.removeItem(Ai)}function na(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=aa(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function ra(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 ia(e){return e.includes(`/common/social`)}function aa(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 oa(e,t,n,r,i){if(i){let e=na(t,r);window.open(e,`_blank`);return}if(zi(t)){let i=na(t,r);Ri(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(ea&&ia(t))ra(r);else{let e=na(t,r);window.location.href=e}}function sa({iframe:e,targetOrigin:t}){let n=new bn;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`:ta(a.backup);break;case`remove-backup`:localStorage.removeItem(Ai);break;case`show`:case`hide`:Yi({iframe:e,isVisible:i===`show`});break;case`redirect`:oa(e,a.baseRedirectUrl,t,a.mergeToken,a.openInNewTab)}},isConnected:n.promise}}async function ca({config:e,iframe:t}){let n=An(e.env).wallet,r=e.metadata.lang??Ni(),i=e.domain??(typeof window<`u`?window.location.hostname:``);Y.setCacheScope(i,r),Y.reset();let a=Y.isCacheFresh?void 0:Y.resolve(e.domain,r),o=await Z().catch(()=>void 0),s=sa({iframe:t,targetOrigin:n}),c=new bn,l=Date.now();if(!t.contentWindow)throw new yn(vn.configError,`The iframe does not have a content window`);let u=xn({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await s.isConnected)throw new yn(vn.clientNotConnected,`The iframe provider isn't connected yet`);return await c.promise,t}}],lifecycleHandlers:{iframeLifecycle:(e,t)=>{s.handleEvent(e)}}}),d=la(u,s),f,p=!1,m=async()=>{p=!0,d(),f?.(),u.cleanup(),t.remove(),Ln(),Y.clearCache(),Y.reset()},h;{h=new ki({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!1,trackOutgoingLinks:!1,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdk_version`in t.properties||(t.properties={...t.properties,sdk_version:`1.4.2-beta.683f5bca`,...o&&{user_anonymous_client_id:o,__deviceId:o}}),!0)}),h.setGlobalProperties({sdk_version:`1.4.2-beta.683f5bca`,...o&&{user_anonymous_client_id:o,__deviceId:o}}),h.init(),h.track(`sdk_initialized`,{sdk_version:`1.4.2-beta.683f5bca`});let e=!1,t=setTimeout(()=>{e||(e=!0,h?.track(`sdk_iframe_handshake_failed`,{reason:`timeout`}))},3e4);s.isConnected.then(()=>{e||(e=!0,clearTimeout(t),h?.track(`sdk_iframe_connected`,{handshake_duration_ms:Date.now()-l}))}).catch(()=>{e||(e=!0,clearTimeout(t),h?.track(`sdk_iframe_handshake_failed`,{reason:`unknown`}))})}let g=ma({config:e,rpcClient:u,lifecycleManager:s,configPromise:a,contextSent:c,openPanel:h,clientId:o}).then(e=>{if(p){e();return}f=e}).catch(e=>{throw c.reject(e),e});return{config:e,waitForConnection:s.isConnected,waitForSetup:g,request:u.request,listenerRequest:u.listen,destroy:m,openPanel:h}}function la(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}function ua(e){return 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}function da(e,t){if(!e)return;let n=e.global??{};e.setGlobalProperties({...n,merchant_id:t.merchantId,domain:t.domain??``})}async function fa(e){let t=new TextEncoder().encode(e);if(typeof crypto<`u`&&crypto.subtle)try{let e=await crypto.subtle.digest(`SHA-256`,t);return new Uint8Array(e)}catch{}try{return be(t)}catch{return}}async function pa({merchantId:e,anonymousId:t,pendingMergeToken:n}){let r=n?await fa(n):void 0,[i,a,o]=await Promise.all([r?X({op:`frak-merge-v1`,merchantId:e,anonymousId:t,binding:r}):Promise.resolve(null),X({op:`frak-merge-v1`,merchantId:e,anonymousId:t}),X({op:`frak-install-v1`,merchantId:e,anonymousId:t})]);if(i||a||o)return{anonymousId:t,proofs:{...i&&{merge:i},...a&&{mergeSource:a},...o&&{install:o}}}}async function ma({config:e,rpcClient:t,lifecycleManager:n,configPromise:r,contextSent:i,openPanel:a,clientId:o}){await n.isConnected,Pi(t,n.isConnected);let s=new URL(window.location.href),c=s.searchParams.get(`fmt`)??void 0;c&&(s.searchParams.delete(`fmt`),window.history.replaceState({},``,s.toString()));let l=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;Y.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})},u=!1,d=Promise.resolve(),f=e=>{let n=u?void 0:c;u=!0;let r=ua(e),i=o,s=window.location.href;return da(a,e),d=d.then(async()=>{t.sendLifecycle({clientLifecycle:`resolved-config`,data:{merchantId:e.merchantId,domain:e.domain??``,allowedDomains:e.allowedDomains??[],sourceUrl:s,...i&&{sdkAnonymousId:i},...n&&{pendingMergeToken:n},...r&&{sdkConfig:r},...i&&{sdkIdentity:await pa({merchantId:e.merchantId,anonymousId:i,pendingMergeToken:n})}}})}).catch(e=>{console.error(`Failed to send lifecycle config`,e)}),d};Y.isResolved&&f(Y.getConfig()).then(i.resolve),r&&(l(await r),f(Y.getConfig()).then(i.resolve));async function p(){let n=e.customizations?.css;n&&t.sendLifecycle({clientLifecycle:`modal-css`,data:{cssLink:n}})}async function m(){let n=e.customizations?.i18n;n&&t.sendLifecycle({clientLifecycle:`modal-i18n`,data:{i18n:n}})}async function h(){if(typeof window>`u`)return;let e=window.localStorage.getItem(Ai);e&&t.sendLifecycle({clientLifecycle:`restore-backup`,data:{backup:e}})}return(await Promise.allSettled([p(),m(),h()])).some(e=>e.status===`rejected`)&&a?.track(`sdk_iframe_handshake_failed`,{reason:`asset_push`}),ha(f)}function ha(e){if(typeof document>`u`)return()=>{};let t=0,n=n=>{if(document.visibilityState!==`visible`||!Y.isResolved)return;let r=Date.now();n&&r-t<6e4||(t=r,e(Y.getConfig()))},r=()=>n(!0),i=setInterval(()=>n(!1),3e5);return document.addEventListener(`visibilitychange`,r),()=>{clearInterval(i),document.removeEventListener(`visibilitychange`,r)}}function ga(e){return Cn(Fr(e))}function _a(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function va(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 ya(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e==`string`&&e.trim()!==``){let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}}function ba(e){if(typeof e!=`string`)return;let t=e.trim();return t===``?void 0:t}function xa(e){if(!e||typeof e!=`object`)return;let t=e,n={},r=ba(t.productId);r!==void 0&&(n.productId=r);let i=ba(t.sku);i!==void 0&&(n.sku=i);let a=ba(t.name);a!==void 0&&(n.name=a);let o=ya(t.quantity);o!==void 0&&(n.quantity=o);let s=ya(t.unitPrice);s!==void 0&&(n.unitPrice=s);let c=ya(t.totalPrice);return c!==void 0&&(n.totalPrice=c),Object.keys(n).length>0?n:void 0}function Sa(e){let t=va(e);if(!t)return;let n=[];for(let e of t){let t=xa(e);t&&n.push(t)}return n.length>0?n:void 0}function Ca(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.title==`string`?t.title.trim():``,r=xa(e);if(n===``&&!r)return null;let i={...r};return n!==``&&(i.title=n),typeof t.imageUrl==`string`&&_a(t.imageUrl)&&(i.imageUrl=t.imageUrl),typeof t.link==`string`&&_a(t.link)&&(i.link=t.link),typeof t.utmContent==`string`&&t.utmContent!==``&&(i.utmContent=t.utmContent),i}function wa(e){let t=va(e);if(!t)return;let n=[];for(let e of t){let t=Ca(e);t&&n.push(t)}return n.length>0?n:void 0}function Ta(e){if(!e)return;let t;try{t=ga(e)}catch{return}if(t!==null)return wa(t)}async function Ea({config:e}){let t=Da(e),n=await qi({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=await ca({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function Da(e){let t=vi(e.metadata.currency);return{...e,metadata:{...e.metadata,currency:t}}}function Oa({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 ka=t({DEEP_LINK_SCHEME:()=>ji,FrakContextManager:()=>gi,areAddressesEqual:()=>Jr,base64urlDecode:()=>Fr,base64urlEncode:()=>Pr,baseIframeProps:()=>Ki,buildListenerUrl:()=>Ji,clearAllCache:()=>Ln,coerceProductCandidates:()=>va,compressJsonToB64:()=>Ir,createIFrameFrakClient:()=>ca,decodeProductsParam:()=>Ta,decompressJsonFromB64:()=>ga,deleteQueryParamCaseInsensitive:()=>$,detectPageLanguage:()=>Ni,findIframeInOpener:()=>Qi,formatAmount:()=>bi,formatAmountParts:()=>Si,generateSsoUrl:()=>Lr,getBackendUrl:()=>q,getClientId:()=>Nr,getClientIdAsync:()=>Z,getCurrencyAmountKey:()=>wi,getEnvironment:()=>jn,getQueryParamCaseInsensitive:()=>Gr,getSupportedCurrency:()=>vi,isIOS:()=>Vi,isInAppBrowser:()=>Wi,isMobile:()=>Hi,mergeAttribution:()=>Oa,normalizeProductDetails:()=>xa,normalizeSharingProduct:()=>Ca,redirectToExternalBrowser:()=>Gi,sanitizeProductDetailsList:()=>Sa,sanitizeSharingProducts:()=>wa,sdkConfigStore:()=>Y,setEnvironment:()=>An,setupClient:()=>Ea,ssoPopupFeatures:()=>Vr,ssoPopupName:()=>Hr,trackEvent:()=>Q,triggerDeepLinkWithFallback:()=>Ri,withCache:()=>In});async function Aa(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 ja(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function Ma(e){if(typeof window>`u`)return;let t=await Z().catch(()=>void 0);if(!t)return;let n=await Y.resolveMerchantId();if(!n)return;let r=`frak-identity-ensured-${n}-${t}`;if(!window.sessionStorage.getItem(r))try{let i=q(),a=await X({op:`frak-ensure-v1`,merchantId:n,anonymousId:t});(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,...Tr()},body:JSON.stringify({merchantId:n,...a&&{proof:a}})})).ok&&window.sessionStorage.setItem(r,`1`)}catch{}}async function Na({merchantId:e,checkoutToken:t}={}){let n=e??await Y.resolveMerchantId();if(!n)return;let r=Mn(),i=encodeURIComponent(n),a=t?`&checkoutToken=${encodeURIComponent(t)}`:``,o=await Z().catch(()=>void 0);if(!o)return`${r}/install?m=${i}${a}`;let s=await X({op:`frak-install-v1`,merchantId:n,anonymousId:o}),c=`${r}/install?m=${i}&a=${encodeURIComponent(o)}${a}`;return s?`${c}#p=${encodeURIComponent(s)}`:c}async function Pa(e,t){return In(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:t?.cacheTime})}async function Fa(e,t){return In(async()=>{let t=await Z().catch(()=>void 0),n=await Y.resolveMerchantId(),r=t&&n?await X({op:`frak-merge-v1`,merchantId:n,anonymousId:t}):null;return e.request({method:`frak_getMergeToken`,params:r?[r]:void 0})},{cacheKey:`frak_getMergeToken`,cacheTime:t?.cacheTime})}async function Ia(e,t){return In(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:t?.cacheTime})}async function La(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function Ra(e,t){try{let n=await Z().catch(()=>void 0);await e.request({method:`frak_sendInteraction`,params:[t,{clientId:n}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}function za(e,t,n){return $r(t)?(Q(e,`user_referred_started`,{referrer_client_id:t.c,referrer_wallet:t.w,wallet_status:n?.key}),Ra(e,{type:`arrival`,referrerClientId:t.c,referrerMerchantId:t.m,referrerWallet:t.w,referralTimestamp:t.t}),!0):Qr(t)?(Q(e,`user_referred_started`,{referrer:t.r,wallet_status:n?.key}),Ra(e,{type:`arrival`,referrerWallet:t.r}),!0):!1}function Ba(e,t,n){return!t&&!n?null:{v:2,m:e,t:Math.floor(Date.now()/1e3),...t?{c:t}:{},...n?{w:n}:{}}}function Va(e,t,n){return $r(e)?e.w&&n?.wallet?Jr(e.w,n.wallet):e.c?t===e.c:!1:Qr(e)&&n?.wallet?Jr(e.r,n.wallet):!1}async function Ha(e,{walletStatus:t,frakContext:n,options:r}){if(!n)return`no-referrer`;let i=await Z().catch(()=>void 0);if(Va(n,i,t))return`self-referral`;if(!za(e,n,t))return`no-referrer`;let a=$r(n)?n.m:r?.merchantId,o=r?.alwaysAppendUrl&&a?Ba(a,i,t?.wallet):null;return gi.replaceUrl({url:window.location.href,context:o}),Q(e,`user_referred_completed`,{status:`success`}),`success`}async function Ua(e,{options:t}={}){let n=gi.parse({url:window.location.href}),r=await qa(e);try{return await Ha(e,{walletStatus:r,frakContext:n,options:t})}catch(e){console.warn(`Error processing referral`,{error:e})}}const Wa=`frak:referral-success`;async function Ga(e){try{await Ua(e)===`success`&&window.dispatchEvent(new Event(Wa))}catch(e){console.warn(`[Frak] Referral setup failed`,e)}}async function Ka(e){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let t=window.sessionStorage.getItem(`frak-wallet-interaction-token`),n=await Z().catch(()=>void 0);if(!t&&!n){console.warn(`[Frak] No identity found, skipping purchase check`);return}let r=e.merchantId??await Y.resolveMerchantId();if(!r){console.warn(`[Frak] No merchant id found, skipping purchase check`);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=q();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 qa(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(Ja(e,t),t));let n=new bn,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{Ja(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function Ja(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),Ma(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function Ya(e,{metadata:t,login:n}){return Xa(e,{steps:{login:n??{}},metadata:t})}function Xa(e,t){function n(n){return Xa(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return Xa(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}async function i(n,r){return n&&(t.metadata=n(t.metadata??{})),await Aa(e,t,r)}return{params:t,sendTx:n,reward:r,display:i}}async function Za(e,{tx:t,metadata:n}){return(await Aa(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function Qa(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 $a(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 Aa(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??Qa(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var eo=t({REFERRAL_SUCCESS_EVENT:()=>Wa,displayModal:()=>Aa,displaySharingPage:()=>ja,ensureIdentity:()=>Ma,getInstallUrl:()=>Na,getMerchantInformation:()=>Pa,getMergeToken:()=>Fa,getUserReferralStatus:()=>Ia,modalBuilder:()=>Ya,openSso:()=>Ur,prepareSso:()=>La,prepareSsoUrl:()=>Br,processReferral:()=>Ha,referralInteraction:()=>Ua,sendInteraction:()=>Ra,sendTransaction:()=>Za,setupReferral:()=>Ga,siweAuthenticate:()=>$a,trackPurchaseStatus:()=>Ka,watchWalletStatus:()=>qa});async function to(e,t,n){if(!window.FrakSetup?.client){console.error(`Frak client not found`);return}await ja(window.FrakSetup.client,{...n?.link&&{link:n.link},...n?.products?.length&&{products:n.products},...n?.checkoutToken&&{checkoutToken:n.checkoutToken},...e&&{metadata:{targetInteraction:e}}},t).catch(e=>console.error(`Frak sharing page failed`,e))}const no=[`frak-button-share`,`frak-button-wallet`,`frak-open-in-app`,`frak-post-purchase`,`frak-banner`].join(`,`);function ro(){return typeof document>`u`||document.querySelector(no)===null?[]:[`sharing`]}const io=`frak:client`;function ao(){let e=new CustomEvent(io);window.dispatchEvent(e)}function oo(e,t){if(window.FrakSetup?.client&&e===`add`){t();return}(e===`add`?window.addEventListener:window.removeEventListener)(io,t,!1)}function so(){return window.FrakSetup.core={...ka,...eo},window.FrakSetup?.client?Promise.resolve():In(()=>co(),{cacheKey:`frak-sdk-init`,cacheTime:1/0}).catch(e=>{Q(window.FrakSetup?.client,`sdk_init_failed`,{reason:e instanceof Error?e.message:typeof e==`string`?e:`unknown`,config_missing:!window.FrakSetup?.config})})}async function co(){if(!window.FrakSetup?.config)throw Error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`);let e=await Ea({config:lo(window.FrakSetup.config)});if(!e)throw Error(`[Frak SDK] Failed to create client`);window.FrakSetup.client=e,ao(),Ga(e),uo()}function lo(e){return e.preload===void 0?{...e,preload:ro()}:e}function uo(){let e=new URL(window.location.href);if(Gr(e.searchParams,`frakAction`)?.toLowerCase()!==`share`)return;let t=Gr(e.searchParams,`link`)??void 0,n=Gr(e.searchParams,`placement`)??void 0,r=Ta(Gr(e.searchParams,`products`));$(e.searchParams,`frakAction`),$(e.searchParams,`link`),$(e.searchParams,`placement`),$(e.searchParams,`products`),window.history.replaceState({},``,e.toString()),Q(window.FrakSetup?.client,`sharing_page_auto_opened`,{placement:n,has_link:!!t,has_products:!!r?.length}),to(void 0,n,{link:t,products:r})}o.injectBase(`shared`,n),o.injectBase(`fouce`,`frak-ambassador:not(:defined), 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(so);const fo={ambassador:()=>import(`./Ambassador.D7jdEkz6.js`),"button-share":()=>import(`./ButtonShare.B4MdZ4eH.js`),"button-wallet":()=>import(`./ButtonWallet.D9B0abq9.js`),"open-in-app":()=>import(`./OpenInAppButton.BaRZ25xH.js`),"post-purchase":()=>import(`./PostPurchase.Cl54N_nH.js`),banner:()=>import(`./Banner.BnzLkajr.js`)},po=new MutationObserver(e=>{for(let{addedNodes:t}of e)for(let e of Array.from(t))e.nodeType===Node.ELEMENT_NODE&&mo(e)});async function mo(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=>ho(e)))}async function ho(e){if(customElements.get(e))return Promise.resolve();let t=e.replace(/^frak-/i,``);if(!(t in fo)){console.error(`Component ${e} is not supported.`);return}try{await fo[t]()}catch(e){console.error(e)}}mo(document.body),po.observe(document.documentElement,{subtree:!0,childList:!0});export{Q as C,s as D,yn as E,o as O,vi as S,vn as T,ji as _,Pa as a,bi as b,Fa as c,Wi as d,Ri as f,Hi as g,Gi as h,Wa as i,n as k,Ia as l,Ni as m,oo as n,Na as o,Sa as p,to as r,Ka as s,so as t,wa as u,Si as v,Y as w,wi as x,Ci as y};
@@ -0,0 +1,5 @@
1
+ /*!
2
+ * Copyright (c) 2023 Paul Miller (paulmillr.com)
3
+ * SPDX-License-Identifier: MIT OR Apache-2.0
4
+ */
5
+ const e=(()=>{let e=[];for(let t=1;t<=40;t++){let n=(16*t+128)*t+64;if(t>=2){let e=Math.floor(t/7)+2;n-=(25*e-10)*e-55,t>=7&&(n-=36)}e.push(n>>>3)}return e})(),t=[`low`,`medium`,`quartile`,`high`],n={low:[7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],medium:[10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],quartile:[13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],high:[17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},r={low:[1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],medium:[1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],quartile:[1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],high:[1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},i={low:1,medium:0,quartile:3,high:2},a=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;function o(e){if(e=v(e),e===1)return[];let t=21+4*(e-1)-7,n=Math.ceil((t-6)/28),r=Math.floor((t-6)/n);r%2?r+=1:(t-6)%n*2>=n&&(r+=2);let i=[6];for(let e=1;e<n;e++)i.push(t-(n-e)*r);return i.push(t),i}function s(e,t){let n=i[e]<<3|t,r=n;for(let e=0;e<10;e++)r=r<<1^(r>>9)*1335;return(n<<10|r)^21522}function c(e){let t=e;for(let e=0;e<12;e++)t=t<<1^(t>>11)*7973;return e<<12|t}const l={numeric:1,alphanumeric:2,byte:4},u={numeric:[10,12,14],alphanumeric:[9,11,13],byte:[8,16,16]},d=(()=>{let e=new Uint8Array(510),t=new Uint8Array(256);for(let n=0,r=1;n<255;n++)e[n]=e[n+255]=r,t[r]=n,r<<=1,r&256&&(r^=285);return{exp:e,log:t}})();function f(e){let{exp:t,log:n}=d,r=new Uint8Array(e);r[e-1]=1;for(let i=0,a=1;i<e;i++){for(let i=0;i<e;i++){let o=r[i];r[i]=(o?t[n[o]+n[a]]:0)^(i+1<e?r[i+1]:0)}a=t[n[a]+1]}return r}const p=[];function m(e){let t=p[e];if(t!==void 0)return t;let n=f(e),{exp:r,log:i}=d,a=new Uint8Array(256*e);for(let t=1;t<256;t++){let o=i[t],s=t*e;for(let t=0;t<e;t++){let e=n[t];e&&(a[s+t]=r[i[e]+o])}}return p[e]={gen:n,mul:a}}function h(e,t,n){let{exp:r,log:i}=d,a=t.length,o=new Uint8Array(a);if(n!==void 0){let t=a-1;for(let r=0;r<e.length;r++){let i=(e[r]^o[0])*a;for(let e=0;e<t;e++)o[e]=o[e+1]^n[i+e];o[t]=n[i+t]}return o}for(let n=0;n<e.length;n++){let s=e[n]^o[0];if(o.copyWithin(0,1),o[a-1]=0,s)for(let e=0;e<a;e++)t[e]&&(o[e]^=r[i[t[e]]+i[s]])}return o}function g(t,i){let a=e[t-1],o=n[i][t-1],s=r[i][t-1],c=Math.floor(a/s)-o;return{words:o,numBlocks:s,shortBlocks:s-a%s,blockLen:c,capacity:(a-o*s)*8}}const _=e=>{throw Error(e)};function v(e){if(typeof e!=`number`)throw TypeError(`"ver" expected number, got type=${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`"ver" expected safe integer, got ${e}`);if(e<1||e>40)throw RangeError(`Invalid version=${e}. Expected number [1..40]`);return e}function y(e){let t=`numeric`;for(let n=0;n<e.length;n++){let r=b[e.charCodeAt(n)];if(!(r>=0))return`byte`;r>9&&(t=`alphanumeric`)}return t}const b=(()=>{let e=new Int8Array(128).fill(-1);for(let t=0;t<45;t++)e[a.charCodeAt(t)]=t;return e})();function x(e,t,n,r,i){let a=g(e,t),o=u[r][Math.floor((e+7)/17)],s=r===`byte`?i.length:n.length;s>=1<<o&&_(`Capacity overflow`);let c=new Uint8Array(a.capacity>>>3),d=0,f=0,p=0,v=(e,t)=>{for(d=d<<t|e,f+=t;f>=8;)c[p++]=d>>>(f-=8)&255};if(v(l[r],4),v(s,o),r===`numeric`)for(let e=0;e<s;e+=3){let t=Math.min(3,s-e);v(Number(n.slice(e,e+t)),[0,4,7,10][t])}else if(r===`alphanumeric`){for(let e=0;e+1<s;e+=2)v(b[n.charCodeAt(e)]*45+b[n.charCodeAt(e+1)],11);s&1&&v(b[n.charCodeAt(s-1)],6)}else for(let e=0;e<i.length;e++)v(i[e],8);let y=p*8+f;y>a.capacity&&_(`Capacity overflow`),f&&(c[p]=d<<8-f&255),y+=Math.min(4,a.capacity-y),y&7&&(y+=8-(y&7));for(let e=y>>>3,t=0;e<c.length;e++,t^=1)c[e]=t?17:236;let{words:x,numBlocks:S,shortBlocks:C,blockLen:w}=a,T=m(x),E=[],D=[];for(let e=0,t=0;e<S;e++){let n=w+(e<C?0:1);E.push(c.subarray(t,t+n)),D.push(h(E[e],T.gen,T.mul)),t+=n}let O=new Uint8Array(c.length+x*S),k=0;for(let e=0;e<=w;e++)for(let t of E)e<t.length&&(O[k++]=t[e]);for(let e=0;e<x;e++)for(let t of D)O[k++]=t[e];return O}function S(e,t){let n=e%2,r=t%2,i=e%3,a=t%3*i%3,o=n&r,s=0;return n===r&&(s|=1),r===0&&(s|=2),i===0&&(s|=4),(e+t)%3==0&&(s|=8),(Math.floor(t/2)+Math.floor(e/3))%2==0&&(s|=16),o+a===0&&(s|=32),(o+a)%2==0&&(s|=64),((n^r)+a)%2==0&&(s|=128),s}const C=(()=>{let e=new Uint8Array(65536);for(let t=1;t<e.length;t++)e[t]=e[t>>>1]+(t&1);return e})(),w=e=>C[e&65535]+C[e>>>16],T=new Uint32Array(32);function E(e){let t=[1431655765,858993459,252645135,16711935,65535];for(let n=0;n<5;n++){let r=t[n]>>>0,i=1<<n;for(let t=0;t<32;t+=i<<1)for(let n=0;n<i;n++){let a=e[t+n]>>>0,o=e[t+n+i]>>>0,s=(a>>>i^o)&r;e[t+n]=(a^s<<i)>>>0,e[t+n+i]=(o^s)>>>0}}}const D=e=>{let t=e+31>>>5;return{size:e,words:t,v:new Uint32Array(t*e)}},O=(e,t,n)=>e.v[n*e.words+(t>>>5)]>>>(t&31)&1,k=(e,t,n,r)=>{let i=n*e.words+(t>>>5),a=1<<(t&31);e.v[i]=r?e.v[i]|a:e.v[i]&~a};function A(e,t){let{size:n,words:r,v:i}=e,a=T;for(let e=0;e<n;e+=32)for(let o=0;o<r;o++){let s=Math.min(32,n-e);for(let t=0;t<s;t++)a[t]=i[(e+t)*r+o];a.fill(0,s),E(a);for(let r=0,i=o*32;r<32&&i<n;r++,i++)t.v[i*t.words+(e>>>5)]=a[r]}}function j(e){let{size:t,words:n,v:r}=e,i=t&31?(1<<(t&31))-1>>>0:4294967295,a=0;for(let e=0;e<n;e++){let o=e===n-1?i:4294967295,s=r[3*n+e],c=4294967295,l=r[e]^r[n+e],u=r[n+e]^r[2*n+e],d=r[2*n+e]^s;for(let i=0,f=4*n+e;i<=t-5;i++,f+=n){let e=r[f],t=s^e,n=~(l|u|d|t)&o;n&&(a+=w(n>>>0)+2*w((n&c)>>>0)),c=l,l=u,u=d,d=t,s=e}}return a}function M(e){let{size:t,words:n,v:r}=e,i=t&31?(1<<(t&31))-1>>>0:4294967295,a=0;for(let e=0;e<n;e++){let o=e===n-1?i:4294967295;for(let i=0;i<=t-11;i++){let t=i*n+e,s=r[t],c=r[t+=n],l=r[t+=n],u=r[t+=n],d=r[t+=n],f=r[t+=n],p=r[t+=n],m=r[t+=n],h=r[t+=n],g=r[t+=n],_=r[t+n],v=o&s&~c&l&u&d&~f&p&~(m|h|g|_),y=o&~(s|c|l|u)&d&~f&p&m&h&~g&_;a+=w(v>>>0)+w(y>>>0)}}return a}function N(e,t,n=1/0){let{size:r,words:i,v:a}=e,o=j(e)+j(t);if(o>=n)return o;let s=(1<<r-32*(i-1)-1)-1>>>0,c=0,l=0;for(let e=0;e<r;e++)for(let t=0;t<i;t++){let n=a[e*i+t];if(l+=w(n>>>0),e===r-1)continue;let o=a[(e+1)*i+t],u=t+1<i?a[e*i+t+1]:0,d=t+1<i?a[(e+1)*i+t+1]:0,f=~(n^o),p=~(n^(n>>>1|u<<31)),m=~(o^(o>>>1|d<<31)),h=f&p&m;t===i-1&&(h&=s),c+=w(h>>>0)}let u=r*r,d=Math.ceil(Math.max(0,Math.abs(l*100-u*50)-u*5)/(u*5)),f=o+3*c+10*d;return f>=n?f:f+40*(M(e)+M(t))}function P(e,t,n,r){let i=e.size,a=s(n,r);for(let t=0;t<15;t++){let n=a>>t&1;t<6?k(e,8,t,n):t<8?k(e,8,t+1,n):t===8?k(e,7,8,n):k(e,14-t,8,n),t<8?k(e,i-1-t,8,n):k(e,8,i-15+t,n)}if(k(e,8,i-8,1),t>=7){let n=c(t);for(let t=0;t<18;t++){let r=n>>t&1,a=i-11+t%3,o=t/3|0;k(e,a,o,r),k(e,o,a,r)}}}let F;function I(e){let t=21+4*(e-1),n=D(t),r=new Uint8Array(t*t),i=(e,i,a)=>{k(n,e,i,a),r[i*t+e]=1};for(let[e,n]of[[0,0],[t-7,0],[0,t-7]])for(let r=-1;r<8;r++)for(let a=-1;a<8;a++){let o=e+a,s=n+r;o<0||s<0||o>=t||s>=t||i(o,s,+(a>=0&&a<7&&r>=0&&r<7&&(a===0||a===6||r===0||r===6||a>1&&a<5&&r>1&&r<5)))}let a=o(e);for(let e of a)for(let n of a)if(!r[e*t+n])for(let t=-2;t<=2;t++)for(let r=-2;r<=2;r++){let a=Math.max(Math.abs(r),Math.abs(t))!==1;i(n+r,e+t,+!!a)}for(let e=0;e<t;e++)r[6*t+e]||i(e,6,+(e%2==0)),r[e*t+6]||i(6,e,+(e%2==0));for(let e=0;e<9;e++)e!==6&&(i(8,e,0),i(e,8,0)),e<8&&(i(t-1-e,8,0),i(8,t-1-e,0));if(e>=7)for(let e=0;e<18;e++){let n=t-11+e%3,r=e/3|0;i(n,r,0),i(r,n,0)}let s=[];for(let e=0;e<8;e++)s.push(D(t));let c=new Uint16Array(t*t),l=0;for(let e=t-1,i=-1,a=t-1;e>0;e-=2,i=-i)for(e===6&&(e=5);;a+=i){for(let i=0;i<2;i++){let o=e-i;if(r[a*t+o])continue;let u=a*n.words+(o>>>5);c[l++]=u<<5|o&31;for(let e=0,t=S(o,a);t;e++,t>>=1)t&1&&(s[e].v[u]|=1<<(o&31))}if(a+i<0||a+i>=t)break}let u=s.map(e=>{let n=D(t);return A(e,n),n.v});return{ver:e,tpl:n.v,pos:c.slice(0,l),planes:s.map(e=>e.v),planesT:u,work:[D(t),D(t),D(t),D(t)]}}function L(e,t,n,r,i=!1){(F===void 0||F.ver!==e)&&(F=I(e));let{tpl:a,pos:o,planes:s,planesT:c,work:l}=F,[u,d,f,p]=l;u.v.set(a);let m=Math.min(8*n.length,o.length);for(let e=0;e<m;e++)if(n[e>>>3]&128>>>(e&7)){let t=o[e];u.v[t>>>5]|=1<<(t&31)}let h=r;if(h===void 0){A(u,d);let e=1/0;for(let t=0;t<8;t++){let n=s[t],r=c[t];for(let e=0;e<f.v.length;e++)f.v[e]=u.v[e]^n[e],p.v[e]=d.v[e]^r[e];let i=N(f,p,e);i<e&&(e=i,h=t)}}let g=s[h];for(let e=0;e<u.v.length;e++)u.v[e]^=g[e];return i||P(u,e,t,h),u}const R=(e,t)=>{if(typeof e!=`number`)throw TypeError(`"${t}" expected number, got type=${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`"${t}" expected safe integer, got ${e}`);return e},z=(e,t)=>{if(typeof e!=`string`)throw TypeError(`"${t}" expected string, got type=${typeof e}`);return e};function B(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<128)t++;else if(r<2048)t+=2;else if(r<55296||r>57343)t+=3;else if(r<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=4,n++):t+=3}else t+=3}return t}function V(e,t){let n=u.byte[Math.floor((e+7)/17)];return Math.min((1<<n)-1,Math.floor((g(e,t).capacity-4-n)/8))}function H(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}const U=(e,t,n)=>e.map[t]>=0&&e.map[n]>=0&&O(e.m,e.map[t],e.map[n])===1,W=[10,27],G=String.fromCharCode(W[0]);function K(e){let t=e.W,n=Array(t);for(let r=0;r<t;r++){let i=Array(t);for(let n=0;n<t;n++)i[n]=U(e,n,r);n[r]=i}return n}function q(e){let t=e.W,n=``;for(let r=0;r<t;r+=2){for(let i=0;i<t;i++){let a=U(e,i,r),o=r+1>=t||U(e,i,r+1);n+=!a&&!o?`█`:!a&&o?`▀`:a&&!o?`▄`:` `}n+=G}return n}function J(e){let t=e.W,n=String.fromCharCode(W[1]),r=n+`[0m`,i=``;for(let a=0;a<t;a++){for(let o=0;o<t;o++)i+=U(e,o,a)?`${n}[40m ${r}`:`${n}[1;47m ${r}`;i+=G}return i}function Y(e,t){let n=e.W,r=`<svg viewBox="0 0 ${n} ${n}" xmlns="http://www.w3.org/2000/svg">`,i=``,a;for(let o=0;o<n;o++)for(let s=0;s<n;s++){if(!U(e,s,o))continue;if(!t){r+=`<rect x="${s}" y="${o}" width="1" height="1" />`;continue}let n=`M${s} ${o}`;if(a){let e=`m${s-a.x} ${o-a.y}`;e.length<=n.length&&(n=e)}i+=`${n}h1v1${s<10?`H${s}`:`h-1`}Z`,a={x:s,y:o}}return t&&(r+=`<path d="${i}"/>`),r+`</svg>`}function X(e){let t=e.W,n=t*t,r=Math.floor(n/126),i=n%126,a=new Uint8Array(408+r*128+2+i+4),o=0,s=e=>{a[o++]=e&255,a[o++]=e>>>8};for(let e of[71,73,70,56,55,97])a[o++]=e;s(t),s(t),a[o++]=246,o+=2,a[o++]=255,a[o++]=255,a[o++]=255,o+=381,a[o++]=44,o+=4,s(t),s(t),a[o++]=0,a[o++]=7;let{m:c,map:l}=e,u=new Uint8Array(t),d=-2;for(let e=0,r=0;e<t;e++){let i=l[e];if(i!==d&&(d=i,u.fill(0),i>=0))for(let e=0;e<t;e++)l[e]>=0&&(u[e]=O(c,l[e],i));for(let e=0;e<t;){if(r%126==0){let e=n-r;a[o++]=(e<126?e:126)+1,a[o++]=128}let i=Math.min(126-r%126,t-e);a.set(u.subarray(e,e+i),o),o+=i,e+=i,r+=i}}return i===0&&(a[o++]=1,a[o++]=128),a[o++]=1,a[o++]=129,a[o++]=0,a[o++]=59,a}function Z(e){let t=e,n;if(typeof t.toBase64==`function`)n=t.toBase64();else{let e=``;for(let n=0;n<t.length;n+=8192)e+=String.fromCharCode(...t.subarray(n,n+8192));n=btoa(e)}return`data:image/gif;base64,`+n}function Q(e,n=`raw`,r={}){if(z(e,`text`),z(n,`output`),typeof r!=`object`||!r||Array.isArray(r))throw TypeError(`"opts" expected object, got type=${typeof r}`);let i=r.version;i!==void 0&&(i=v(i));let o=r.ecc===void 0?`medium`:r.ecc;t.includes(o)||_(`invalid ecc=${o}`);let s=r.encoding===void 0?y(e):r.encoding;if(u[s]||_(`invalid encoding=${s}`),s!==`byte`){let t=s===`numeric`?a.slice(0,10):a;for(let n of e)t.includes(n)||_(`Unknown letter: "${n}". Allowed: ${t}`)}r.mask!==void 0&&(R(r.mask,`opts.mask`)<0||r.mask>7)&&_(`invalid mask=${r.mask}`);let c=r.textEncoder;if(s===`byte`&&c===void 0){let t=V(i===void 0?40:i,o);(e.length>t||B(e)>t)&&_(`Capacity overflow`)}let l=s===`byte`?(c===void 0?e=>new TextEncoder().encode(e):c)(e):void 0;if(l!==void 0&&!H(l))throw TypeError(`"opts.textEncoder" expected Uint8Array, got type=${typeof l}`);let d=s===`byte`?l.length:e.length,f=s===`numeric`?Math.floor(d/3)*10+[0,4,7][d%3]:s===`alphanumeric`?Math.floor(d/2)*11+d%2*6:d*8;if(i===void 0){for(i=1;i<=40;i++){let e=u[s][Math.floor((i+7)/17)];if(d<1<<e&&4+e+f<=g(i,o).capacity)break}i>40&&_(`Capacity overflow`)}else{let e=u[s][Math.floor((i+7)/17)];(d>=1<<e||4+e+f>g(i,o).capacity)&&_(`Capacity overflow`)}let p=x(i,o,e,s,l),m=L(i,o,p,r.mask),h=r.border===void 0?2:R(r.border,`opts.border`);if(h<=0)throw RangeError(`invalid border=${h}`);let b=r.scale===void 0?1:R(r.scale,`opts.scale`);if(b<=0||b>1024)throw RangeError(`invalid scale factor: ${b}`);let S=(m.size+2*h)*b,C=n===`ascii`||n===`gif`||n===`data-url`?4096:1024;if(S>C)throw RangeError(`invalid opts: output is ${S}x${S} (max ${C}), reduce border/scale`);let w=new Int32Array(S);for(let e=0;e<S;e++){let t=Math.floor(e/b)-h;w[e]=t>=0&&t<m.size?t:-1}let T={m,W:S,map:w};return n===`raw`?K(T):n===`ascii`?q(T):n===`term`?J(T):n===`svg`?Y(T,r.optimize===void 0||r.optimize):n===`gif`?X(T):n===`data-url`?Z(X(T)):_(`Unknown output: ${n}`)}export{Q as default,Q as encodeQR};