@frak-labs/components 0.0.24-beta.d96bc28d → 0.0.24-beta.f2691749
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/cdn/{ButtonShare.gYrcu6m1.js → ButtonShare.DiNDBr-R.js} +1 -1
- package/cdn/{ButtonWallet.intmWVv9.js → ButtonWallet.D-6j1kxo.js} +1 -1
- package/cdn/{OpenInAppButton.CTXBUBhl.js → OpenInAppButton.CJUPoAII.js} +1 -1
- package/cdn/{Spinner.B5ANROAA.js → Spinner.CfUtILTX.js} +1 -1
- package/cdn/components.js +1 -1
- package/cdn/initFrakSdk.JiGHu9H6.js +14 -0
- package/cdn/loader.js +1 -1
- package/cdn/{useClientReady.C76MAbLf.js → useClientReady.DQOFFqXG.js} +1 -1
- package/dist/{Spinner-1CZC_zy6.js → Spinner-J7chVm6X.js} +4 -4
- package/dist/buttonShare.d.ts +5 -1
- package/dist/buttonShare.js +2 -2
- package/dist/buttonWallet.d.ts +5 -1
- package/dist/buttonWallet.js +1 -1
- package/dist/openInApp.d.ts +8 -0
- package/dist/openInApp.js +1 -1
- package/package.json +3 -3
- package/cdn/initFrakSdk.CFKrZv6i.js +0 -14
package/README.md
CHANGED
|
@@ -66,3 +66,25 @@ Button with custom class:
|
|
|
66
66
|
```html
|
|
67
67
|
<frak-button-wallet classname="button button-primary"></frak-button-wallet>
|
|
68
68
|
```
|
|
69
|
+
|
|
70
|
+
## Sample usage for Open In App button
|
|
71
|
+
|
|
72
|
+
Sample code to use open in app button:
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<frak-open-in-app></frak-open-in-app>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Button with custom text:
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<frak-open-in-app text="Get the App"></frak-open-in-app>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Button with custom class:
|
|
85
|
+
|
|
86
|
+
```html
|
|
87
|
+
<frak-open-in-app classname="button button-primary"></frak-open-in-app>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Note:** This component only renders on mobile devices. On desktop, it returns null.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,a as t,b as n,c as r,f as i,h as a,l as o,m as s,n as c,o as l,p as u,s as d}from"./initFrakSdk.
|
|
1
|
+
import{S as e,a as t,b as n,c as r,f as i,h as a,l as o,m as s,n as c,o as l,p as u,s as d}from"./initFrakSdk.JiGHu9H6.js";import{t as f}from"./Spinner.CfUtILTX.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./useClientReady.DQOFFqXG.js";function y(e,t){return!e||e.payoutType!==`fixed`?0:e.amount[t]}function b(e,t){return e.reduce((e,n)=>Math.max(e,y(n.referrer,t)),0)}async function x({targetInteraction:e}){let t=window.FrakSetup?.client;if(!t){console.warn(`Frak client not ready yet`);return}let{rewards:n}=await l(t),i=r(t.config.metadata?.currency),a=b(e?n.filter(t=>t.interactionTypeKey===e):n,i);if(!(a<=0))return d(Math.round(a),t.config.metadata?.currency)}function S(e,t){let[n,r]=_(void 0);return p(()=>{e&&x({targetInteraction:t}).then(e=>{e&&r(e)})},[e,t]),{reward:n}}const C={buttonShare:`nOB7Uq_buttonShare`};C.buttonShare;function w(e={}){let{successDuration:t=2e3}=e,[n,r]=_(!1);return{copy:m(async e=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(e),r(!0);else{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select();try{document.execCommand(`copy`),r(!0)}catch(e){return console.error(`Failed to copy text:`,e),!1}finally{t.remove()}}return setTimeout(()=>{r(!1)},t),!0}catch(e){return console.error(`Failed to copy text:`,e),!1}},[t]),copied:n}}const T={errorContainer:{marginTop:`16px`,padding:`16px`,backgroundColor:`#FEE2E2`,border:`1px solid #FCA5A5`,borderRadius:`4px`,color:`#991B1B`},header:{display:`flex`,alignItems:`center`,gap:`8px`,marginBottom:`12px`},title:{margin:0,fontSize:`16px`,fontWeight:500},message:{fontSize:`14px`,lineHeight:`1.5`,margin:`0 0 12px 0`},link:{color:`#991B1B`,textDecoration:`underline`,textUnderlineOffset:`2px`},copyButton:{display:`inline-flex`,alignItems:`center`,gap:`8px`,marginBottom:`10px`,padding:`8px 12px`,backgroundColor:`white`,border:`1px solid #D1D5DB`,borderRadius:`4px`,color:`black`,fontSize:`14px`,fontWeight:500}};function E({debugInfo:e}){let[t,n]=_(!1);return a(`div`,{children:[a(`button`,{type:`button`,style:T.copyButton,onClick:()=>n(!t),children:`Ouvrir les informations`}),t&&a(`textarea`,{style:{display:`block`,width:`100%`,height:`200px`,fontSize:`12px`},children:e})]})}function D({debugInfo:e}){let{copied:t,copy:n}=w();return a(`div`,{style:T.errorContainer,children:[a(`div`,{style:T.header,children:a(`h3`,{style:T.title,children:`Oups ! Nous avons rencontré un petit problème`})}),a(`p`,{style:T.message,children:[`Impossible d'ouvrir le menu de partage pour le moment. Si le problème persiste, copiez les informations ci-dessous et collez-les dans votre mail à`,` `,a(`a`,{href:`mailto:help@frak-labs.com?subject=Debug`,style:T.link,children:`help@frak-labs.com`}),` `,a(`br`,{}),`Merci pour votre retour, nous traitons votre demande dans les plus brefs délais.`]}),a(`button`,{type:`button`,onClick:()=>n(e??``),style:T.copyButton,children:t?`Informations copiées !`:`Copier les informations de débogage`}),a(E,{debugInfo:e})]})}function O(e){let[t,n]=_(void 0),[r,a]=_(!1);return{handleShare:m(async()=>{if(!window.FrakSetup?.client){console.error(`Frak client not found`),n(o.empty().formatDebugInfo(`Frak client not found`)),a(!0);return}let t=c();if(!t)throw Error(`modalBuilderSteps not found`);try{await t.sharing(window.FrakSetup?.modalShareConfig??{}).display(t=>({...t,targetInteraction:e}))}catch(e){if(e instanceof s&&e.code===u.clientAborted){console.debug(`User aborted the modal`);return}let t=window.FrakSetup.client.debugInfo.formatDebugInfo(e);i(window.FrakSetup.client,`share_modal_error`,{error:e instanceof Object&&`message`in e?e.message:`Unknown error`,debugInfo:t}),n(t),a(!0),console.error(`Error while opening the modal`,e)}},[e]),isError:r,debugInfo:t}}async function k(){if(!window.FrakSetup?.client)throw Error(`Frak client not found`);await t(window.FrakSetup.client,window.FrakSetup?.modalWalletConfig??{})}function A({text:t=`Share and earn!`,classname:r=``,useReward:o,noRewardText:s,targetInteraction:c,showWallet:l}){let u=h(()=>o!==void 0,[o]),d=h(()=>l!==void 0,[l]),{isClientReady:p}=v(),{reward:g}=S(u&&p,c),{handleShare:_,isError:y,debugInfo:b}=O(c),x=h(()=>u?g?t.includes(`{REWARD}`)?t.replace(`{REWARD}`,g):`${t} ${g}`:s??t.replace(`{REWARD}`,``):t,[u,t,s,g]),w=m(async()=>{i(window.FrakSetup.client,`share_button_clicked`),d?await k():await _()},[d,_]);return a(n,{children:[a(`button`,{type:`button`,className:e(C.buttonShare,r,`override`),onClick:w,children:[!p&&a(f,{}),` `,x]}),y&&a(D,{debugInfo:b})]})}g(A,`frak-button-share`,[`text`],{shadow:!1});export{A as ButtonShare,S as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,f as t,h as n,i as r}from"./initFrakSdk.
|
|
1
|
+
import{S as e,f as t,h as n,i as r}from"./initFrakSdk.JiGHu9H6.js";import{a as i,n as a,o,r as s,t as c}from"./useClientReady.DQOFFqXG.js";import{t as l}from"./ButtonShare.DiNDBr-R.js";function u(e){return n(`svg`,{fill:`none`,height:`1em`,viewBox:`0 0 28 28`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n(`title`,{children:`Gift icon`}),n(`path`,{d:`m23.1427 13.9999v11.4285h-18.2857v-11.4285m9.1429 11.4285v-17.14282m0 0h-5.1429c-.75776 0-1.48448-.30102-2.0203-.83684s-.83684-1.26255-.83684-2.02031.30102-1.48448.83684-2.0203 1.26254-.83684 2.0203-.83684c4 0 5.1429 5.71429 5.1429 5.71429zm0 0h5.1428c.7578 0 1.4845-.30102 2.0203-.83684s.8369-1.26255.8369-2.02031-.3011-1.48448-.8369-2.0203-1.2625-.83684-2.0203-.83684c-4 0-5.1428 5.71429-5.1428 5.71429zm-11.42861 0h22.85711v5.71432h-22.85711z`,stroke:`#fff`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]})}const d={reward:`Kl62ia_reward`,button__right:`Kl62ia_button__right`,button__left:`Kl62ia_button__left`,button:`Kl62ia_button`};d.reward,d.button__right,d.button__left,d.button;function f({classname:o=``,useReward:f,targetInteraction:p}){let m=a(()=>f!==void 0,[f]),{isClientReady:h}=c(),{reward:g}=l(m&&h,p),[_,v]=s(`right`);return i(()=>{let e=window.FrakSetup?.modalWalletConfig?.metadata?.position;v(e??`right`)},[]),n(`button`,{type:`button`,"aria-label":`Open wallet`,class:e(d.button,_===`left`?d.button__left:d.button__right,o,`override`),disabled:!h,onClick:()=>{t(window.FrakSetup.client,`wallet_button_clicked`),r()},children:[n(u,{}),g&&n(`span`,{className:d.reward,children:g})]})}o(f,`frak-button-wallet`,[],{shadow:!1});export{f as ButtonWallet};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,d as t,f as n,h as r,u as i}from"./initFrakSdk.
|
|
1
|
+
import{S as e,d as t,f as n,h as r,u as i}from"./initFrakSdk.JiGHu9H6.js";import{t as a}from"./Spinner.CfUtILTX.js";import{n as o,o as s,t as c}from"./useClientReady.DQOFFqXG.js";function l(){return typeof navigator>`u`?!1:!!(/iPhone|iPad|iPod|Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||/Macintosh/i.test(navigator.userAgent)&&navigator.maxTouchPoints>1)}function u(){return{isMobile:o(()=>l(),[])}}function d(e=`wallet`){let r=window.FrakSetup?.client;r&&n(r,`open_in_app_clicked`),i(`${t}${e}`,{onFallback:()=>{r&&n(r,`app_not_installed`)}})}const f={button:`XYfqGq_button`};f.button;function p({text:t=`Open in App`,classname:n=``}){let{isClientReady:i}=c(),{isMobile:o}=u();if(!o)return null;let s=()=>{d()};return r(`button`,{type:`button`,"aria-label":`Open in Frak Wallet app`,className:e(f.button,n,`override`),disabled:!i,onClick:s,children:[!i&&r(a,{}),` `,t]})}s(p,`frak-open-in-app`,[`text`],{shadow:!1});export{p as OpenInAppButton};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,h as t}from"./initFrakSdk.
|
|
1
|
+
import{S as e,h as t}from"./initFrakSdk.JiGHu9H6.js";const n={spinner__leaf:`M4fSKa_spinner__leaf`,spinner:`M4fSKa_spinner`,"rt-spinner-leaf-fade":`M4fSKa_rt-spinner-leaf-fade`};n.spinner__leaf,n.spinner,n[`rt-spinner-leaf-fade`];const r=({ref:r,className:i,...a})=>t(`span`,{...a,ref:r,className:e(n.spinner),children:[t(`span`,{className:n.spinner__leaf}),t(`span`,{className:n.spinner__leaf}),t(`span`,{className:n.spinner__leaf}),t(`span`,{className:n.spinner__leaf}),t(`span`,{className:n.spinner__leaf}),t(`span`,{className:n.spinner__leaf}),t(`span`,{className:n.spinner__leaf}),t(`span`,{className:n.spinner__leaf})]});r.displayName=`Spinner`;export{r as t};
|
package/cdn/components.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import(`https://cdn.jsdelivr.net/npm/@frak-labs/components@
|
|
1
|
+
import(`https://cdn.jsdelivr.net/npm/@frak-labs/components@beta/cdn/loader.js?v=1771932108743`);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function n(e){document.readyState===`complete`||document.readyState===`interactive`?setTimeout(e,1):document.addEventListener?document.addEventListener(`DOMContentLoaded`,e):document.attachEvent(`onreadystatechange`,()=>{document.readyState===`complete`&&e()})}function r(e){var t,n,i=``;if(typeof e==`string`||typeof e==`number`)i+=e;else if(typeof e==`object`)if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=r(e[t]))&&(i&&(i+=` `),i+=n)}else for(n in e)e[n]&&(i&&(i+=` `),i+=n);return i}function i(){for(var e,t,n=0,i=``,a=arguments.length;n<a;n++)(e=arguments[n])&&(t=r(e))&&(i&&(i+=` `),i+=t);return i}const a=i;var o,s,c,l,u,d,f,p,m,h,g,_={},v=[],y=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,b=Array.isArray;function x(e,t){for(var n in t)e[n]=t[n];return e}function ee(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function S(e,t,n){var r,i,a,s={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:s[a]=t[a];if(arguments.length>2&&(s.children=arguments.length>3?o.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)s[a]===void 0&&(s[a]=e.defaultProps[a]);return C(e,s,r,i,null)}function C(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??++c,__i:-1,__u:0};return i==null&&s.vnode!=null&&s.vnode(a),a}function w(e){return e.children}function T(e,t){this.props=e,this.context=t}function E(e,t){if(t==null)return e.__?E(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`?E(e):null}function D(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=x({},t);a.__v=t.__v+1,s.vnode&&s.vnode(a),oe(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??E(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,ce(r,a,i),t.__e=t.__=null,a.__e!=n&&O(a)}}function O(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}),O(e)}function k(e){(!e.__d&&(e.__d=!0)&&l.push(e)&&!A.__r++||u!=s.debounceRendering)&&((u=s.debounceRendering)||d)(A)}function A(){for(var e,t=1;l.length;)l.length>t&&l.sort(f),e=l.shift(),t=l.length,D(e);A.__r=0}function te(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,y,b=r&&r.__k||v,x=t.length;for(c=j(n,t,b,c,x),d=0;d<x;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&b[p.__i]||_,p.__i=d,g=oe(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&de(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),(y=!!(4&p.__u))||f.__k===p.__k?c=ne(p,c,e,y):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function j(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]=C(null,o,null,null,null):b(o)?o=e.__k[a]=C(w,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=C(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=re(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=E(s)),fe(s,s));return r}function ne(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=ne(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=E(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function re(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>(u?1:0)){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 ie(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||y.test(t)?n:n+`px`}function M(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||ie(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ie(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(p,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n.u=r.u:(n.u=m,e.addEventListener(t,a?g:h,a)):e.removeEventListener(t,a?g:h,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 ae(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=m++;else if(t.t<n.u)return;return n(s.event?s.event(t):t)}}}function oe(e,t,n,r,i,a,o,c,l,u){var d,f,p,m,h,g,_,y,S,C,E,D,O,k,A,j=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),a=[c=t.__e=n.__e]),(d=s.__b)&&d(t);n:if(typeof j==`function`)try{if(y=t.props,S=`prototype`in j&&j.prototype.render,C=(d=j.contextType)&&r[d.__c],E=d?C?C.props.value:d.__:r,n.__c?_=(f=t.__c=n.__c).__=f.__E:(S?t.__c=f=new j(y,E):(t.__c=f=new T(y,E),f.constructor=j,f.render=pe),C&&C.sub(f),f.state||={},f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),S&&f.__s==null&&(f.__s=f.state),S&&j.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=x({},f.__s)),x(f.__s,j.getDerivedStateFromProps(y,f.__s))),m=f.props,h=f.state,f.__v=t,p)S&&j.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),S&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(S&&j.getDerivedStateFromProps==null&&y!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(y,E),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(y,f.__s,E)){t.__v!=n.__v&&(f.props=y,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),v.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&o.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(y,f.__s,E),S&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=E,f.props=y,f.__P=e,f.__e=!1,D=s.__r,O=0,S)f.state=f.__s,f.__d=!1,D&&D(t),d=f.render(f.props,f.state,f.context),v.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,D&&D(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++O<25);f.state=f.__s,f.getChildContext!=null&&(r=x(x({},r),f.getChildContext())),S&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),k=d!=null&&d.type===w&&d.key==null?le(d.props.children):d,c=te(e,b(k)?k:[k],t,n,r,i,a,o,c,l,u),f.base=t.__e,t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__E=f.__=null)}catch(e){if(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[a.indexOf(c)]=null,t.__e=c}else{for(A=a.length;A--;)ee(a[A]);se(t)}else t.__e=n.__e,t.__k=n.__k,e.then||se(t);s.__e(e,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=ue(n.__e,t,n,r,i,a,o,l,u);return(d=s.diffed)&&d(t),128&t.__u?void 0:c}function se(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(se))}function ce(e,t,n){for(var r=0;r<n.length;r++)de(n[r],n[++r],n[++r]);s.__c&&s.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){s.__e(e,t.__v)}})}function le(e){return typeof e!=`object`||!e||e.__b>0?e:b(e)?e.map(le):x({},e)}function ue(e,t,n,r,i,a,c,l,u){var d,f,p,m,h,g,v,y=n.props||_,x=t.props,S=t.type;if(S==`svg`?i=`http://www.w3.org/2000/svg`:S==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(d=0;d<a.length;d++)if((h=a[d])&&`setAttribute`in h==!!S&&(S?h.localName==S:h.nodeType==3)){e=h,a[d]=null;break}}if(e==null){if(S==null)return document.createTextNode(x);e=document.createElementNS(i,S,x.is&&x),l&&=(s.__m&&s.__m(t,a),!1),a=null}if(S==null)y===x||l&&e.data==x||(e.data=x);else{if(a&&=o.call(e.childNodes),!l&&a!=null)for(y={},d=0;d<e.attributes.length;d++)y[(h=e.attributes[d]).name]=h.value;for(d in y)h=y[d],d==`dangerouslySetInnerHTML`?p=h:d==`children`||d in x||d==`value`&&`defaultValue`in x||d==`checked`&&`defaultChecked`in x||M(e,d,null,h,i);for(d in x)h=x[d],d==`children`?m=h:d==`dangerouslySetInnerHTML`?f=h:d==`value`?g=h:d==`checked`?v=h:l&&typeof h!=`function`||y[d]===h||M(e,d,h,y[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=``),te(t.type==`template`?e.content:e,b(m)?m:[m],t,n,r,S==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,c,a?a[0]:n.__k&&E(n,0),l,u),a!=null)for(d=a.length;d--;)ee(a[d]);l||(d=`value`,S==`progress`&&g==null?e.removeAttribute(`value`):g!=null&&(g!==e[d]||S==`progress`&&!g||S==`option`&&g!=y[d])&&M(e,d,g,y[d],i),d=`checked`,v!=null&&v!=e[d]&&M(e,d,v,y[d],i))}return e}function de(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){s.__e(e,n)}}function fe(e,t,n){var r,i;if(s.unmount&&s.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||de(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){s.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&fe(r[i],t,n||typeof e.type!=`function`);n||ee(e.__e),e.__c=e.__=e.__e=void 0}function pe(e,t,n){return this.constructor(e,n)}function me(e,t,n){var r,i,a,c;t==document&&(t=document.documentElement),s.__&&s.__(e,t),i=(r=typeof n==`function`)?null:n&&n.__k||t.__k,a=[],c=[],oe(t,e=(!r&&n||t).__k=S(w,null,[e]),i||_,_,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?o.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,c),ce(a,e,c)}function he(e,t){me(e,t,he)}function ge(e,t,n){var r,i,a,s,c=x({},e.props);for(a in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)a==`key`?r=t[a]:a==`ref`?i=t[a]:c[a]=t[a]===void 0&&s!=null?s[a]:t[a];return arguments.length>2&&(c.children=arguments.length>3?o.call(arguments,2):n),C(e.type,c,r||e.key,i||e.ref,null)}o=v.slice,s={__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}},c=0,T.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=x({},this.state);typeof e==`function`&&(e=e(x({},n),this.props)),e&&x(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),k(this))},T.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),k(this))},T.prototype.render=w,l=[],d=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,f=function(e,t){return e.__v.__b-t.__v.__b},A.__r=0,p=/(PointerCapture)$|Capture$/i,m=0,h=ae(!1),g=ae(!0);var _e=0;Array.isArray;function ve(e,t,n,r,i,a){t||={};var o,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?o=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--_e,__i:-1,__u:0,__source:i,__self:a};if(typeof e==`function`&&(o=e.defaultProps))for(c in o)l[c]===void 0&&(l[c]=o[c]);return s.vnode&&s.vnode(u),u}function ye(e,{strict:t=!0}={}){return!e||typeof e!=`string`?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith(`0x`)}function be(e){return ye(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const xe=`2.46.2`;let Se={getDocsUrl:({docsBaseUrl:e,docsPath:t=``,docsSlug:n})=>t?`${e??`https://viem.sh`}${t}${n?`#${n}`:``}`:void 0,version:`viem@${xe}`};var N=class e extends Error{constructor(t,n={}){let r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,i=n.cause instanceof e&&n.cause.docsPath||n.docsPath,a=Se.getDocsUrl?.({...n,docsPath:i}),o=[t||`An error occurred.`,``,...n.metaMessages?[...n.metaMessages,``]:[],...a?[`Docs: ${a}`]:[],...r?[`Details: ${r}`]:[],...Se.version?[`Version: ${Se.version}`]:[]].join(`
|
|
2
|
+
`);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,`details`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`docsPath`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`metaMessages`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`shortMessage`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`version`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`name`,{enumerable:!0,configurable:!0,writable:!0,value:`BaseError`}),this.details=r,this.docsPath=i,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=xe}walk(e){return Ce(this,e)}};function Ce(e,t){return t?.(e)?e:e&&typeof e==`object`&&`cause`in e&&e.cause!==void 0?Ce(e.cause,t):t?null:e}var we=class extends N{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:`SizeExceedsPaddingSizeError`})}};function P(e,{dir:t,size:n=32}={}){return typeof e==`string`?Te(e,{dir:t,size:n}):Ee(e,{dir:t,size:n})}function Te(e,{dir:t,size:n=32}={}){if(n===null)return e;let r=e.replace(`0x`,``);if(r.length>n*2)throw new we({size:Math.ceil(r.length/2),targetSize:n,type:`hex`});return`0x${r[t===`right`?`padEnd`:`padStart`](n*2,`0`)}`}function Ee(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new we({size:e.length,targetSize:n,type:`bytes`});let r=new Uint8Array(n);for(let i=0;i<n;i++){let a=t===`right`;r[a?i:n-i-1]=e[a?i:e.length-i-1]}return r}var De=class extends N{constructor({max:e,min:t,signed:n,size:r,value:i}){super(`Number "${i}" is not in safe ${r?`${r*8}-bit ${n?`signed`:`unsigned`} `:``}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:`IntegerOutOfRangeError`})}},Oe=class extends N{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:`SizeOverflowError`})}};function F(e,{size:t}){if(be(e)>t)throw new Oe({givenSize:be(e),maxSize:t})}const ke=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Ae(e,t={}){return typeof e==`number`||typeof e==`bigint`?Ne(e,t):typeof e==`string`?Fe(e,t):typeof e==`boolean`?je(e,t):Me(e,t)}function je(e,t={}){let n=`0x${Number(e)}`;return typeof t.size==`number`?(F(n,{size:t.size}),P(n,{size:t.size})):n}function Me(e,t={}){let n=``;for(let t=0;t<e.length;t++)n+=ke[e[t]];let r=`0x${n}`;return typeof t.size==`number`?(F(r,{size:t.size}),P(r,{dir:`right`,size:t.size})):r}function Ne(e,t={}){let{signed:n,size:r}=t,i=BigInt(e),a;r?a=n?(1n<<BigInt(r)*8n-1n)-1n:2n**(BigInt(r)*8n)-1n:typeof e==`number`&&(a=BigInt(2**53-1));let o=typeof a==`bigint`&&n?-a-1n:0;if(a&&i>a||i<o){let t=typeof e==`bigint`?`n`:``;throw new De({max:a?`${a}${t}`:void 0,min:`${o}${t}`,signed:n,size:r,value:`${e}${t}`})}let s=`0x${(n&&i<0?(1n<<BigInt(r*8))+BigInt(i):i).toString(16)}`;return r?P(s,{size:r}):s}const Pe=new TextEncoder;function Fe(e,t={}){return Me(Pe.encode(e),t)}const Ie=new TextEncoder;function Le(e,t={}){return typeof e==`number`||typeof e==`bigint`?Ve(e,t):typeof e==`boolean`?Re(e,t):ye(e)?Be(e,t):He(e,t)}function Re(e,t={}){let n=new Uint8Array(1);return n[0]=Number(e),typeof t.size==`number`?(F(n,{size:t.size}),P(n,{size:t.size})):n}const I={zero:48,nine:57,A:65,F:70,a:97,f:102};function ze(e){if(e>=I.zero&&e<=I.nine)return e-I.zero;if(e>=I.A&&e<=I.F)return e-(I.A-10);if(e>=I.a&&e<=I.f)return e-(I.a-10)}function Be(e,t={}){let n=e;t.size&&(F(n,{size:t.size}),n=P(n,{dir:`right`,size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);let i=r.length/2,a=new Uint8Array(i);for(let e=0,t=0;e<i;e++){let n=ze(r.charCodeAt(t++)),i=ze(r.charCodeAt(t++));if(n===void 0||i===void 0)throw new N(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);a[e]=n*16+i}return a}function Ve(e,t){return Be(Ne(e,t))}function He(e,t={}){let n=Ie.encode(e);return typeof t.size==`number`?(F(n,{size:t.size}),P(n,{dir:`right`,size:t.size})):n}const L=BigInt(2**32-1),Ue=BigInt(32);function We(e,t=!1){return t?{h:Number(e&L),l:Number(e>>Ue&L)}:{h:Number(e>>Ue&L)|0,l:Number(e&L)|0}}function Ge(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=We(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}const Ke=(e,t,n)=>e<<n|t>>>32-n,qe=(e,t,n)=>t<<n|e>>>32-n,Je=(e,t,n)=>t<<n-32|e>>>64-n,Ye=(e,t,n)=>e<<n-32|t>>>64-n;function Xe(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function Ze(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function R(e,...t){if(!Xe(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function Qe(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function $e(e,t){R(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function et(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function tt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const nt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function rt(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function it(e){for(let t=0;t<e.length;t++)e[t]=rt(e[t]);return e}const at=nt?e=>e:it;typeof Uint8Array.from([]).toHex==`function`&&Uint8Array.fromHex;function ot(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function st(e){return typeof e==`string`&&(e=ot(e)),R(e),e}var ct=class{};function lt(e){let t=t=>e().update(st(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ut(e){let t=(t,n)=>e(n).update(st(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}const dt=BigInt(0),z=BigInt(1),ft=BigInt(2),pt=BigInt(7),mt=BigInt(256),ht=BigInt(113),gt=[],_t=[],vt=[];for(let e=0,t=z,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],gt.push(2*(5*r+n)),_t.push((e+1)*(e+2)/2%64);let i=dt;for(let e=0;e<7;e++)t=(t<<z^(t>>pt)*ht)%mt,t&ft&&(i^=z<<(z<<BigInt(e))-z);vt.push(i)}const yt=Ge(vt,!0),bt=yt[0],xt=yt[1],St=(e,t,n)=>n>32?Je(e,t,n):Ke(e,t,n),Ct=(e,t,n)=>n>32?Ye(e,t,n):qe(e,t,n);function wt(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=St(a,o,1)^n[r],c=Ct(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=_t[n],a=St(t,i,r),o=Ct(t,i,r),s=gt[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=bt[r],e[1]^=xt[r]}tt(n)}var Tt=class e extends ct{constructor(e,t,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,Ze(n),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=et(this.state)}clone(){return this._cloneInto()}keccak(){at(this.state32),wt(this.state32,this.rounds),at(this.state32),this.posOut=0,this.pos=0}update(e){Qe(this),e=st(e),R(e);let{blockLen:t,state:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Qe(this,!1),R(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return Ze(e),this.xofInto(new Uint8Array(e))}digestInto(e){if($e(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,tt(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}};const B=(e,t,n)=>lt(()=>new Tt(t,e,n));B(6,144,224/8),B(6,136,256/8),B(6,104,384/8),B(6,72,512/8),B(1,144,224/8);const Et=B(1,136,256/8);B(1,104,384/8),B(1,72,512/8);const Dt=(e,t,n)=>ut((r={})=>new Tt(t,e,r.dkLen===void 0?n:r.dkLen,!0));Dt(31,168,128/8),Dt(31,136,256/8);function Ot(e,t){let n=t||`hex`,r=Et(ye(e,{strict:!1})?Le(e):e);return n===`bytes`?r:Ae(r)}var kt=class extends N{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:[`- Address must be a hex value of 20 bytes (40 hex characters).`,`- Address must match its checksum counterpart.`],name:`InvalidAddressError`})}},At=class extends Map{constructor(e){super(),Object.defineProperty(this,`maxSize`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=this.keys().next().value;e&&this.delete(e)}return this}};const jt=new At(8192);function Mt(e,t){if(jt.has(`${e}.${t}`))return jt.get(`${e}.${t}`);let n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=Ot(He(n),`bytes`),i=(t?n.substring(`${t}0x`.length):n).split(``);for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&i[e]&&(i[e]=i[e].toUpperCase()),(r[e>>1]&15)>=8&&i[e+1]&&(i[e+1]=i[e+1].toUpperCase());let a=`0x${i.join(``)}`;return jt.set(`${e}.${t}`,a),a}const Nt=/^0x[a-fA-F0-9]{40}$/,Pt=new At(8192);function Ft(e,t){let{strict:n=!0}=t??{},r=`${e}.${n}`;if(Pt.has(r))return Pt.get(r);let i=Nt.test(e)?e.toLowerCase()===e?!0:n?Mt(e)===e:!0:!1;return Pt.set(r,i),i}function It(e,t){if(!Ft(e,{strict:!1}))throw new kt({address:e});if(!Ft(t,{strict:!1}))throw new kt({address:t});return e.toLowerCase()===t.toLowerCase()}let V=256,H;function Lt(e=11){if(!H||V+e>256*2){H=``,V=0;for(let e=0;e<256;e++)H+=(256+Math.random()*256|0).toString(16).substring(1)}return H.substring(V,V+++e)}const U={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 W=class extends Error{constructor(e,t,n){super(t),this.code=e,this.data=n}toJSON(){return{code:this.code,message:this.message,data:this.data}}},Rt=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 zt(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{let t=new URL(e.origin).origin.toLowerCase(),n=new URL(r).origin.toLowerCase();if(t!==n){console.log(`Not expected origin`,t,n);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=e;try{n=await u(e)}catch(e){throw console.error(`[RPC Client] Middleware error on request:`,e),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 Rt;return o.set(t,e=>{e.error?n.reject(new W(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 Bt(e){return new TextEncoder().encode(JSON.stringify(e))}function Vt(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}function Ht({domain:e}={}){return Ot(Ae((e??window.location.host).replace(`www.`,``)))}const Ut=`frak-client-id`;function Wt(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function Gt(){if(typeof window>`u`||!window.localStorage)return Wt();let e=localStorage.getItem(Ut);return e||(e=Wt(),localStorage.setItem(Ut,e)),e}function Kt(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function qt(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 Jt(e){return Kt(Bt(e))}function Yt(e,t,n,r,i,a){let o=Jt(Xt({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:i,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:a??Gt()})),s=new URL(e);return s.pathname=`/sso`,s.searchParams.set(`p`,o),s.toString()}function Xt(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const Zt=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,Qt=`frak-sso`;async function $t(e,t){let{metadata:n,customizations:r,walletUrl:i}=e.config;if(t.openInSameWindow??!!t.redirectUrl)return await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]});let a=t.ssoPopupUrl??Yt(i??`https://wallet.frak.id`,t,Ht(),n.name,r?.css),o=window.open(a,Qt,Zt);if(!o)throw Error(`Popup was blocked. Please allow popups for this site.`);return o.focus(),await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]})??{}}const en=`https://backend.frak.id`;function tn(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function nn(e){return tn(e)?`http://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:en}function rn(e){if(e)return nn(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return nn(e)}return en}const an=`fCtx`;function on(e){if(e?.r)try{return Kt(Be(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function sn(e){if(!(!e||e.length===0))try{return{r:Me(qt(e),{size:20})}}catch(t){console.error(`Error decompressing Frak context`,{e:t,context:e})}}function cn({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(an);return t?sn(t):null}function ln({url:e,context:t}){if(!e)return null;let n=cn({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let i=on(r);if(!i)return null;let a=new URL(e);return a.searchParams.set(an,i),a.toString()}function un(e){let t=new URL(e);return t.searchParams.delete(an),t.toString()}function dn({url:e,context:t}){if(!window.location?.href||typeof window>`u`){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?un(n):ln({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const G={compress:on,decompress:sn,parse:cn,update:ln,remove:un,replaceUrl:dn};function K(e,t,n={}){if(!e){console.debug(`[Frak] No client provided, skipping event tracking`);return}try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}var fn=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)}},pn=class{constructor(e){this.options=e,this.queue=[];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.0.4`,this.api=new fn({baseUrl:e.apiUrl||`https://api.openpanel.dev`,defaultHeaders:t})}init(){}ready(){this.options.waitForProfile=!1,this.flush()}async send(e){return this.options.disabled||this.options.filter&&!this.options.filter(e)?Promise.resolve():this.options.waitForProfile&&!this.profileId?(this.queue.push(e),Promise.resolve()):this.api.fetch(`/track`,e)}setGlobalProperties(e){this.global={...this.global,...e}}async track(e,t){return this.log(`track event`,e,t),this.send({type:`track`,payload:{name:e,profileId:t?.profileId??this.profileId,properties:{...this.global??{},...t??{}}}})}async identify(e){if(this.log(`identify user`,e),e.profileId&&(this.profileId=e.profileId,this.flush()),Object.keys(e).length>1)return this.send({type:`identify`,payload:{...e,properties:{...this.global,...e.properties}}})}async alias(e){}async increment(e){return this.send({type:`increment`,payload:e})}async decrement(e){return this.send({type:`decrement`,payload:e})}async revenue(e,t){let n=t?.deviceId;return delete t?.deviceId,this.track(`revenue`,{...t??{},...n?{__deviceId:n}:{},__revenue:e})}async fetchDeviceId(){return(await this.api.fetch(`/track/device-id`,void 0,{method:`GET`,keepalive:!1}))?.deviceId??``}clear(){this.profileId=void 0}flush(){this.queue.forEach(e=>{this.send({...e,payload:{...e.payload,profileId:e.payload.profileId??this.profileId}})}),this.queue=[]}log(...e){this.options.debug&&console.log(`[OpenPanel.dev]`,...e)}};function mn(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var hn=class extends pn{constructor(e){if(super({sdk:`web`,sdkVersion:`1.0.7`,...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=[]}this.setGlobalProperties({__referrer:document.referrer}),this.options.trackScreenViews&&(this.trackScreenViews(),setTimeout(()=>this.screenView(),0)),this.options.trackOutgoingLinks&&this.trackOutgoingLinks(),this.options.trackAttributes&&this.trackAttributes()}}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[mn(t.name.replace(/^data-/,``))]=t.value);let t=i.getAttribute(`data-track`);t&&super.track(t,e)}})}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 q=`nexus-wallet-backup`,gn=`frakwallet://`;function _n(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}}),console.log(`[SSO URL Listener] Forwarded compressed SSO data to iframe`)}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()),console.log(`[SSO URL Listener] SSO parameter detected and URL cleaned`))}var vn=class e{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e,t){this.lastResponse={message:e,response:t,timestamp:Date.now()}}setLastRequest(e){this.lastRequest={event:e,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn(`Failed to encode debug data`,e),btoa(`Failed to encode data`)}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute(`loading`),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?this.iframe.contentDocument.readyState===`complete`?1:0:-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let t=this.getIframeStatus(),n=this.getNavigatorInfo(),r=`Unknown`;return e instanceof W?r=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?r=e.message:typeof e==`string`&&(r=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):`no-config`,navigatorInfo:n?this.base64Encode(n):`no-navigator`,iframeStatus:t?this.base64Encode(t):`not-iframe`,lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):`No Frak request logged`,lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):`No Frak response logged`,clientStatus:this.isSetupDone?`setup`:`not-setup`,error:r}}static empty(){return new e}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
|
|
3
|
+
Debug Information:
|
|
4
|
+
-----------------
|
|
5
|
+
Timestamp: ${t.timestamp}
|
|
6
|
+
URL: ${t.encodedUrl}
|
|
7
|
+
Config: ${t.encodedConfig}
|
|
8
|
+
Navigator Info: ${t.navigatorInfo}
|
|
9
|
+
IFrame Status: ${t.iframeStatus}
|
|
10
|
+
Last Request: ${t.lastRequest}
|
|
11
|
+
Last Response: ${t.lastResponse}
|
|
12
|
+
Client Status: ${t.clientStatus}
|
|
13
|
+
Error: ${t.error}
|
|
14
|
+
`.trim()}};function yn(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function bn(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;end`}function xn(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=yn()&&Sn(e)?bn(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function Sn(e){return e.startsWith(gn)}const J={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function Cn({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);return r.id=J.id,r.name=J.name,r.allow=J.allow,r.style.zIndex=J.style.zIndex.toString(),wn({iframe:r,isVisible:!1}),r.src=`${t?.walletUrl??e??`https://wallet.frak.id`}/listener`,new Promise(e=>{r.addEventListener(`load`,()=>e(r)),document.body.appendChild(r)})}function wn({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function Tn(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 En(e){e?localStorage.setItem(q,e):localStorage.removeItem(q)}function Dn(e,t,n,r){let i=new URL(window.location.href),a=i.searchParams.get(`fmt`)??void 0;e.contentWindow?.postMessage({clientLifecycle:`handshake-response`,data:{token:t,currentUrl:window.location.href,clientId:Gt(),pendingMergeToken:a,configDomain:r}},n),a&&(i.searchParams.delete(`fmt`),window.history.replaceState({},``,i.toString()))}function On(e,t){try{let n=new URL(e);return n.searchParams.has(`u`)?(n.searchParams.delete(`u`),n.searchParams.append(`u`,window.location.href),t&&n.searchParams.append(`fmt`,t),n.toString()):e}catch{return e}}function kn(e,t,n,r){let i=On(t,r);Sn(t)?xn(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}}):window.location.href=i}function An({iframe:e,targetOrigin:t,configDomain:n}){let r=new Rt;return{handleEvent:async i=>{if(!(`iframeLifecycle`in i))return;let{iframeLifecycle:a,data:o}=i;switch(a){case`connected`:r.resolve(!0);break;case`do-backup`:En(o.backup);break;case`remove-backup`:localStorage.removeItem(q);break;case`show`:case`hide`:wn({iframe:e,isVisible:a===`show`});break;case`handshake`:Dn(e,o.token,t,n);break;case`redirect`:kn(e,o.baseRedirectUrl,t,o.mergeToken);break}},isConnected:r.promise}}function jn({config:e,iframe:t}){let n=e?.walletUrl??`https://wallet.frak.id`,r=An({iframe:t,targetOrigin:n,configDomain:e.domain}),i=new vn(e,t);if(!t.contentWindow)throw new W(U.configError,`The iframe does not have a content window`);let a=zt({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await r.isConnected)throw new W(U.clientNotConnected,`The iframe provider isn't connected yet`);return t}},{onRequest(e,t){return i.setLastRequest(e),t},onResponse(e,t){return i.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:async(e,t)=>{await r.handleEvent(e)}}}),o=Mn(a,r),s=async()=>{o(),a.cleanup(),t.remove()},c;console.log(`[Frak SDK] Initializing OpenPanel`),c=new hn({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdkVersion`in t.properties||(t.properties={...t.properties,sdkVersion:`0.1.1`}),!0)}),c.setGlobalProperties({sdkVersion:`0.1.1`}),c.init();let l=Nn({config:e,rpcClient:a,lifecycleManager:r}).then(()=>i.updateSetupStatus(!0));return{config:e,debugInfo:i,waitForConnection:r.isConnected,waitForSetup:l,request:a.request,listenerRequest:a.listen,destroy:s,openPanel:c}}function Mn(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,1e3),r=setTimeout(()=>{o(),console.log(`Heartbeat timeout: connection failed`)},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function Nn({config:e,rpcClient:t,lifecycleManager:n}){await n.isConnected,_n(t,n.isConnected);async function r(){let n=e.customizations?.css;if(!n)return;let r={clientLifecycle:`modal-css`,data:{cssLink:n}};t.sendLifecycle(r)}async function i(){let n=e.customizations?.i18n;if(!n)return;let r={clientLifecycle:`modal-i18n`,data:{i18n:n}};t.sendLifecycle(r)}async function a(){if(typeof window>`u`)return;let e=window.localStorage.getItem(q);if(!e)return;let n={clientLifecycle:`restore-backup`,data:{backup:e}};t.sendLifecycle(n)}await Promise.allSettled([r(),i(),a()])}function Pn(e){return Vt(qt(e))}const Y={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function Fn(e){return e&&e in Y?e:`eur`}function In(e){return e?Y[e]??Y.eur:Y.eur}function Ln(e,t){let n=In(t),r=Fn(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function Rn(e){return e?`${e}Amount`:`eurAmount`}let X,Z;async function zn(e,t){if(X)return X;if(Z)return Z;Z=Bn(e,t);let n=await Z;return Z=void 0,n}async function Bn(e,t){let n=e??(typeof window<`u`?window.location.hostname:``);if(n)try{let e=rn(t),r=await fetch(`${e}/user/merchant/resolve?domain=${encodeURIComponent(n)}`);if(!r.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${n}: ${r.status}`);return}return X=(await r.json()).merchantId,X}catch(e){console.warn(`[Frak SDK] Failed to fetch merchantId:`,e);return}}function Vn(){X=void 0,Z=void 0}async function Hn(e,t){return e.metadata?.merchantId?e.metadata.merchantId:zn(void 0,t)}async function Un({config:e}){let t=Wn(e),n=await Cn({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=jn({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function Wn(e){let t=Fn(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}function Gn(){return Lt(96)}async function Q(e,t){return await e.request({method:`frak_displayEmbeddedWallet`,params:[t,e.config.metadata]})}async function $(e,{steps:t,metadata:n}){return await e.request({method:`frak_displayModal`,params:[t,n,e.config.metadata]})}async function Kn(e){return await e.request({method:`frak_getMerchantInformation`})}async function qn(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function Jn(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}async function Yn(e,{walletStatus:t,frakContext:n,modalConfig:r,options:i}){if(!n?.r)return`no-referrer`;K(e,`user_referred_started`,{properties:{referrer:n?.r,walletStatus:t?.key}}),Jn(e,{type:`arrival`,referrerWallet:n.r,landingUrl:typeof window<`u`?window.location.href:void 0});let a=!1;async function o(){if(!a)return a=!0,Zn(e,{modalConfig:{...r,loggedIn:{action:{key:`referred`}}},walletStatus:t})}try{let{status:r,currentWallet:a}=await Xn({initialWalletStatus:t,getFreshWalletStatus:o,frakContext:n});return G.replaceUrl({url:window.location?.href,context:i?.alwaysAppendUrl?{r:a}:null}),K(e,`user_referred_completed`,{properties:{status:r,referrer:n?.r,wallet:a}}),r}catch(r){return console.log(`Error processing referral`,{error:r}),K(e,`user_referred_error`,{properties:{referrer:n?.r,error:r instanceof W?`[${r.code}] ${r.name} - ${r.message}`:r instanceof Error?r.message:`undefined`}}),G.replaceUrl({url:window.location?.href,context:i?.alwaysAppendUrl?{r:t?.wallet}:null}),Qn(r)}}async function Xn({initialWalletStatus:e,getFreshWalletStatus:t,frakContext:n}){let r=e?.wallet;return r||=await t(),r&&It(n.r,r)?{status:`self-referral`,currentWallet:r}:{status:`success`,currentWallet:r}}async function Zn(e,{modalConfig:t,walletStatus:n}){return n?.key===`connected`?n.wallet??void 0:(await Q(e,t??{}))?.wallet??void 0}function Qn(e){if(e instanceof W)switch(e.code){case U.walletNotConnected:return`no-wallet`;default:return`error`}return`error`}async function $n(e,{modalConfig:t,options:n}={}){let r=G.parse({url:window.location.href}),i=await tr(e);try{return await Yn(e,{walletStatus:i,frakContext:r,modalConfig:t,options:n})}catch(e){console.warn(`Error processing referral`,{error:e})}}async function er(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`);if(!t){console.warn(`[Frak] No frak session found, skipping purchase check`);return}let n=rn();await fetch(`${n}/interactions/listenForPurchase`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":t},body:JSON.stringify(e)})}function tr(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(nr(e,t),t));let n=new Rt,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{nr(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function nr(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function rr(e,{metadata:t,login:n}){return ir(e,{steps:{login:n??{}},metadata:t})}function ir(e,t){function n(n){return ir(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return ir(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return ir(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function a(n){return n&&(t.metadata=n(t.metadata??{})),await $(e,t)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function ar(e,{tx:t,metadata:n}){return(await $(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function or(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 $(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??Gn(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var sr=t({DEEP_LINK_SCHEME:()=>gn,DebugInfoGatherer:()=>vn,FrakContextManager:()=>G,base64urlDecode:()=>qt,base64urlEncode:()=>Kt,baseIframeProps:()=>J,clearMerchantIdCache:()=>Vn,compressJsonToB64:()=>Jt,computeLegacyProductId:()=>Ht,createIFrameFrakClient:()=>jn,createIframe:()=>Cn,decompressJsonFromB64:()=>Pn,displayEmbeddedWallet:()=>Q,displayModal:()=>$,fetchMerchantId:()=>zn,findIframeInOpener:()=>Tn,formatAmount:()=>Ln,generateSsoUrl:()=>Yt,getBackendUrl:()=>rn,getClientId:()=>Gt,getCurrencyAmountKey:()=>Rn,getMerchantInformation:()=>Kn,getSupportedCurrency:()=>Fn,getSupportedLocale:()=>In,isChromiumAndroid:()=>yn,isFrakDeepLink:()=>Sn,locales:()=>Y,modalBuilder:()=>rr,openSso:()=>$t,prepareSso:()=>qn,processReferral:()=>Yn,referralInteraction:()=>$n,resolveMerchantId:()=>Hn,sendInteraction:()=>Jn,sendTransaction:()=>ar,setupClient:()=>Un,siweAuthenticate:()=>or,ssoPopupFeatures:()=>Zt,ssoPopupName:()=>Qt,toAndroidIntentUrl:()=>bn,trackEvent:()=>K,trackPurchaseStatus:()=>er,triggerDeepLinkWithFallback:()=>xn,watchWalletStatus:()=>tr});function cr(){`vibrate`in navigator?navigator.vibrate(10):console.log(`Vibration not supported`)}function lr(){if(!window.FrakSetup?.client){console.error(`Frak client not found`);return}cr(),Q(window.FrakSetup.client,window.FrakSetup?.modalWalletConfig??{})}const ur=`frakClientReady`;function dr(){let e=new CustomEvent(ur);window.dispatchEvent(e)}function fr(e,t){if(window.FrakSetup?.client&&e===`add`){t();return}(e===`add`?window.addEventListener:window.removeEventListener)(ur,t,!1)}function pr(e){window.modalBuilderSteps=rr(e,window.FrakSetup?.modalConfig??{})}async function mr(e){let t=await $n(e,{modalConfig:window.FrakSetup?.modalWalletConfig});console.log(`referral`,t)}function hr(){if(!window.modalBuilderSteps)throw Error(`modalBuilderSteps not found`);return window.modalBuilderSteps}async function gr(){if(window.FrakSetup.core=sr,!_r())return;if(console.log(`[Frak SDK] Starting initialization`),!window.FrakSetup.config){console.error(`[Frak SDK] Configuration not found`),window.frakSetupInProgress=!1;return}let e=await Un({config:window.FrakSetup.config});if(!e){console.error(`[Frak SDK] Failed to create client`),window.frakSetupInProgress=!1;return}window.FrakSetup.client=e,console.log(`[Frak SDK] Client initialized successfully`),dr(),pr(e),mr(e),window.frakSetupInProgress=!1,vr()}function _r(){return window.frakSetupInProgress?(console.log(`[Frak SDK] Initialization already in progress`),!1):(window.frakSetupInProgress=!0,window.FrakSetup?.client?(console.log(`[Frak SDK] Client already initialized`),window.frakSetupInProgress=!1,!1):window.FrakSetup?.config?!0:(console.error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`),window.frakSetupInProgress=!1,!1))}function vr(){let e=new URLSearchParams(window.location.search).get(`frakAction`);e&&e===`share`&&(console.log(`[Frak SDK] Auto open query param found`),lr())}export{n as C,a as S,he as _,Q as a,w as b,Rn as c,gn as d,K as f,me as g,ve as h,lr as i,vn as l,W as m,hr as n,Kn as o,U as p,fr as r,Ln as s,gr as t,xn as u,ge as v,s as x,S as y};
|
package/cdn/loader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,t}from"./initFrakSdk.
|
|
1
|
+
import{C as e,t}from"./initFrakSdk.JiGHu9H6.js";import{t as n}from"./Spinner.CfUtILTX.js";function r(){let e=`frak-components-styles`;if(document.getElementById(e))return;let t=import.meta.url,n=t.substring(0,t.lastIndexOf(`/`)),r=document.createElement(`link`);r.id=e,r.rel=`stylesheet`,r.href=`${n}/loader.css`,document.head.appendChild(r)}r(),e(t);const i={"button-share":()=>import(`./ButtonShare.DiNDBr-R.js`),"button-wallet":()=>import(`./ButtonWallet.D-6j1kxo.js`),"open-in-app":()=>import(`./OpenInAppButton.CJUPoAII.js`)},a=new MutationObserver(e=>{for(let{addedNodes:t}of e)for(let e of Array.from(t))e.nodeType===Node.ELEMENT_NODE&&o(e)});async function o(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=>s(e)))}async function s(e){if(customElements.get(e))return Promise.resolve();try{let t=e.replace(/^frak-/i,``);if(!(t in i))throw Error(`Component ${e} is not supported.`);await i[t]()}catch(e){console.error(e)}}o(document.body),a.observe(document.documentElement,{subtree:!0,childList:!0});export{n as Spinner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,_ as t,b as n,g as r,r as i,t as a,v as o,x as s,y as c}from"./initFrakSdk.
|
|
1
|
+
import{C as e,_ as t,b as n,g as r,r as i,t as a,v as o,x as s,y as c}from"./initFrakSdk.JiGHu9H6.js";function l(){return l=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},l.apply(this,arguments)}function u(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 d=[`context`,`children`],f=[`useFragment`];function p(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(){h.call(this,r)},i.prototype.attributeChangedCallback=_,i.prototype.disconnectedCallback=v,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 m(e){this.getChildContext=function(){return e.context};var t=e.children;return o(t,u(e,d))}function h(e){var n=new CustomEvent(`_preact`,{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(n),this._vdom=c(m,l({},this._props,{context:n.detail.context}),b(this,this._vdomComponent,e)),(this.hasAttribute(`hydrate`)?t:r)(this._vdom,this._root)}function g(e){return e.replace(/-(\w)/g,function(e,t){return t?t.toUpperCase():``})}function _(e,t,n){if(this._vdom){var i={};i[e]=n??=void 0,i[g(e)]=n,this._vdom=o(this._vdom,i),r(this._vdom,this._root)}}function v(){r(this._vdom=null,this._root)}function y(e,t){var r=this,i=e.useFragment,a=u(e,f);return c(i?n:`slot`,l({},a,{ref:function(e){e?(r.ref=e,r._listener||(r._listener=function(e){e.stopPropagation(),e.detail.context=t},e.addEventListener(`_preact`,r._listener))):r.ref.removeEventListener(`_preact`,r._listener)}}))}function b(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[g(o[a].name)]=o[a].value);for(a=s.length;a--;){var l=b(s[a],null,n),u=s[a].slot;u?i[u]=c(y,{name:u},l):r[a]=l}var d=!(!n||!n.shadow),f=t?c(y,{useFragment:!d},r):r;return!d&&t&&(e.innerHTML=``),c(t||e.nodeName.toLowerCase(),i,f)}function x(t,n,r=[],i={shadow:!1}){typeof window<`u`&&(e(a),customElements.get(n)||p(t,n,r,i))}var S,C,w,T,E=0,D=[],O=s,k=O.__b,A=O.__r,j=O.diffed,M=O.__c,N=O.unmount,P=O.__;function F(e,t){O.__h&&O.__h(C,e,E||t),E=0;var n=C.__H||={__:[],__h:[]};return e>=n.__.length&&n.__.push({}),n.__[e]}function I(e){return E=1,L(q,e)}function L(e,t,n){var r=F(S++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):q(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=C,!C.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.some(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a&&a.call(this,e,t,n)||o};C.__f=!0;var a=C.shouldComponentUpdate,o=C.componentWillUpdate;C.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)},C.shouldComponentUpdate=i}return r.__N||r.__}function R(e,t){var n=F(S++,3);!O.__s&&K(n.__H,t)&&(n.__=e,n.u=t,C.__H.__h.push(n))}function z(e,t){var n=F(S++,7);return K(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function B(e,t){return E=8,z(function(){return e},t)}function V(){for(var e;e=D.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(W),t.__h.some(G),t.__h=[]}catch(n){t.__h=[],O.__e(n,e.__v)}}}O.__b=function(e){C=null,k&&k(e)},O.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),P&&P(e,t)},O.__r=function(e){A&&A(e),S=0;var t=(C=e.__c).__H;t&&(w===C?(t.__h=[],C.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(W),t.__h.some(G),t.__h=[],S=0)),w=C},O.diffed=function(e){j&&j(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(D.push(t)!==1&&T===O.requestAnimationFrame||((T=O.requestAnimationFrame)||U)(V)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),w=C=null},O.__c=function(e,t){t.some(function(e){try{e.__h.some(W),e.__h=e.__h.filter(function(e){return!e.__||G(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],O.__e(n,e.__v)}}),M&&M(e,t)},O.unmount=function(e){N&&N(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{W(e)}catch(e){t=e}}),n.__H=void 0,t&&O.__e(t,n.__v))};var H=typeof requestAnimationFrame==`function`;function U(e){var t,n=function(){clearTimeout(r),H&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);H&&(t=requestAnimationFrame(n))}function W(e){var t=C,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),C=t}function G(e){var t=C;e.__c=e.__(),C=t}function K(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function q(e,t){return typeof t==`function`?t(e):t}function J(){let[e,t]=I(!0),n=B(()=>{t(!1)},[]);return R(()=>(i(`add`,n),()=>i(`remove`,n)),[n]),{isClientReady:!e}}export{R as a,B as i,z as n,x as o,I as r,J as t};
|
|
@@ -3,13 +3,13 @@ import { jsx, jsxs } from "preact/jsx-runtime";
|
|
|
3
3
|
|
|
4
4
|
//#region src/components/Spinner/index.module.css?css_module
|
|
5
5
|
const classes = {
|
|
6
|
-
"
|
|
6
|
+
"rt-spinner-leaf-fade": "M4fSKa_rt-spinner-leaf-fade",
|
|
7
7
|
"spinner": "M4fSKa_spinner",
|
|
8
|
-
"
|
|
8
|
+
"spinner__leaf": "M4fSKa_spinner__leaf"
|
|
9
9
|
};
|
|
10
|
-
const _spinner__leaf0 = classes["spinner__leaf"];
|
|
11
|
-
const _spinner0 = classes["spinner"];
|
|
12
10
|
const _rt_spinner_leaf_fade0 = classes["rt-spinner-leaf-fade"];
|
|
11
|
+
const _spinner0 = classes["spinner"];
|
|
12
|
+
const _spinner__leaf0 = classes["spinner__leaf"];
|
|
13
13
|
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/components/Spinner/index.tsx
|
package/dist/buttonShare.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ type ButtonShareProps = {
|
|
|
77
77
|
* ```
|
|
78
78
|
*
|
|
79
79
|
* @see {@link @frak-labs/core-sdk!actions.modalBuilder | `modalBuilder()`} for more info about the modal display
|
|
80
|
-
* @see {@link @frak-labs/core-sdk!actions.
|
|
80
|
+
* @see {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} for more info about the estimated reward fetching
|
|
81
81
|
*/
|
|
82
82
|
declare function ButtonShare({
|
|
83
83
|
text,
|
|
@@ -89,6 +89,10 @@ declare function ButtonShare({
|
|
|
89
89
|
}: ButtonShareProps): preact.JSX.Element;
|
|
90
90
|
//#endregion
|
|
91
91
|
//#region src/components/ButtonShare/index.d.ts
|
|
92
|
+
/**
|
|
93
|
+
* Custom element interface for `<frak-button-share>`.
|
|
94
|
+
* Combines standard {@link HTMLElement} with {@link ButtonShareProps}.
|
|
95
|
+
*/
|
|
92
96
|
interface ButtonShareElement extends HTMLElement, ButtonShareProps {}
|
|
93
97
|
declare global {
|
|
94
98
|
interface HTMLElementTagNameMap {
|
package/dist/buttonShare.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as registerWebComponent, r as getModalBuilderSteps, t as useClientReady } from "./useClientReady-iCtUeDsc.js";
|
|
2
|
-
import { t as Spinner } from "./Spinner-
|
|
2
|
+
import { t as Spinner } from "./Spinner-J7chVm6X.js";
|
|
3
3
|
import { t as useReward } from "./useReward-DAkT-7wT.js";
|
|
4
4
|
import { DebugInfoGatherer, trackEvent } from "@frak-labs/core-sdk";
|
|
5
5
|
import { displayEmbeddedWallet } from "@frak-labs/core-sdk/actions";
|
|
@@ -262,7 +262,7 @@ async function modalEmbeddedWallet() {
|
|
|
262
262
|
* ```
|
|
263
263
|
*
|
|
264
264
|
* @see {@link @frak-labs/core-sdk!actions.modalBuilder | `modalBuilder()`} for more info about the modal display
|
|
265
|
-
* @see {@link @frak-labs/core-sdk!actions.
|
|
265
|
+
* @see {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} for more info about the estimated reward fetching
|
|
266
266
|
*/
|
|
267
267
|
function ButtonShare({ text = "Share and earn!", classname = "", useReward: rawUseReward, noRewardText, targetInteraction, showWallet: rawShowWallet }) {
|
|
268
268
|
const shouldUseReward = useMemo(() => rawUseReward !== void 0, [rawUseReward]);
|
package/dist/buttonWallet.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ type ButtonWalletProps = {
|
|
|
56
56
|
* ```
|
|
57
57
|
*
|
|
58
58
|
* @see {@link @frak-labs/core-sdk!actions.modalBuilder | `modalBuilder()`} for more info about the modal display
|
|
59
|
-
* @see {@link @frak-labs/core-sdk!actions.
|
|
59
|
+
* @see {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} for more info about the estimated reward fetching
|
|
60
60
|
*/
|
|
61
61
|
declare function ButtonWallet({
|
|
62
62
|
classname,
|
|
@@ -65,6 +65,10 @@ declare function ButtonWallet({
|
|
|
65
65
|
}: ButtonWalletProps): preact.JSX.Element;
|
|
66
66
|
//#endregion
|
|
67
67
|
//#region src/components/ButtonWallet/index.d.ts
|
|
68
|
+
/**
|
|
69
|
+
* Custom element interface for `<frak-button-wallet>`.
|
|
70
|
+
* Combines standard {@link HTMLElement} with {@link ButtonWalletProps}.
|
|
71
|
+
*/
|
|
68
72
|
interface ButtonWalletElement extends HTMLElement, ButtonWalletProps {}
|
|
69
73
|
declare global {
|
|
70
74
|
interface HTMLElementTagNameMap {
|
package/dist/buttonWallet.js
CHANGED
|
@@ -71,7 +71,7 @@ const _reward0 = classes["reward"];
|
|
|
71
71
|
* ```
|
|
72
72
|
*
|
|
73
73
|
* @see {@link @frak-labs/core-sdk!actions.modalBuilder | `modalBuilder()`} for more info about the modal display
|
|
74
|
-
* @see {@link @frak-labs/core-sdk!actions.
|
|
74
|
+
* @see {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} for more info about the estimated reward fetching
|
|
75
75
|
*/
|
|
76
76
|
function ButtonWallet({ classname = "", useReward: rawUseReward, targetInteraction }) {
|
|
77
77
|
const shouldUseReward = useMemo(() => rawUseReward !== void 0, [rawUseReward]);
|
package/dist/openInApp.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import * as preact from "preact";
|
|
2
2
|
|
|
3
3
|
//#region src/components/OpenInAppButton/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The props type for {@link OpenInAppButton}.
|
|
6
|
+
* @inline
|
|
7
|
+
*/
|
|
4
8
|
type OpenInAppButtonProps = {
|
|
5
9
|
/**
|
|
6
10
|
* Text to display on the button
|
|
@@ -46,6 +50,10 @@ declare function OpenInAppButton({
|
|
|
46
50
|
}: OpenInAppButtonProps): preact.JSX.Element | null;
|
|
47
51
|
//#endregion
|
|
48
52
|
//#region src/components/OpenInAppButton/index.d.ts
|
|
53
|
+
/**
|
|
54
|
+
* Custom element interface for `<frak-open-in-app>`.
|
|
55
|
+
* Combines standard {@link HTMLElement} with {@link OpenInAppButtonProps}.
|
|
56
|
+
*/
|
|
49
57
|
interface OpenInAppButtonElement extends HTMLElement, OpenInAppButtonProps {}
|
|
50
58
|
declare global {
|
|
51
59
|
interface HTMLElementTagNameMap {
|
package/dist/openInApp.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as registerWebComponent, t as useClientReady } from "./useClientReady-iCtUeDsc.js";
|
|
2
|
-
import { t as Spinner } from "./Spinner-
|
|
2
|
+
import { t as Spinner } from "./Spinner-J7chVm6X.js";
|
|
3
3
|
import { DEEP_LINK_SCHEME, trackEvent, triggerDeepLinkWithFallback } from "@frak-labs/core-sdk";
|
|
4
4
|
import { cx } from "class-variance-authority";
|
|
5
5
|
import { useMemo } from "preact/hooks";
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "https://twitter.com/QNivelais"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
|
-
"version": "0.0.24-beta.
|
|
14
|
+
"version": "0.0.24-beta.f2691749",
|
|
15
15
|
"description": "Frak Wallet components, helping any person to interact with the Frak wallet.",
|
|
16
16
|
"repository": {
|
|
17
17
|
"url": "https://github.com/frak-id/wallet",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"publish": "echo 'Publishing components...'"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@frak-labs/frame-connector": "0.1.0-beta.
|
|
80
|
-
"@frak-labs/core-sdk": "0.1.1-beta.
|
|
79
|
+
"@frak-labs/frame-connector": "0.1.0-beta.f2691749",
|
|
80
|
+
"@frak-labs/core-sdk": "0.1.1-beta.f2691749",
|
|
81
81
|
"class-variance-authority": "^0.7.1",
|
|
82
82
|
"preact": "^10.28.3",
|
|
83
83
|
"preact-custom-element": "^4.6.0"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function n(e){document.readyState===`complete`||document.readyState===`interactive`?setTimeout(e,1):document.addEventListener?document.addEventListener(`DOMContentLoaded`,e):document.attachEvent(`onreadystatechange`,()=>{document.readyState===`complete`&&e()})}function r(e){var t,n,i=``;if(typeof e==`string`||typeof e==`number`)i+=e;else if(typeof e==`object`)if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=r(e[t]))&&(i&&(i+=` `),i+=n)}else for(n in e)e[n]&&(i&&(i+=` `),i+=n);return i}function i(){for(var e,t,n=0,i=``,a=arguments.length;n<a;n++)(e=arguments[n])&&(t=r(e))&&(i&&(i+=` `),i+=t);return i}const a=i;var o,s,c,l,u,d,f,p,m,h,g,_={},v=[],y=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,b=Array.isArray;function x(e,t){for(var n in t)e[n]=t[n];return e}function ee(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function S(e,t,n){var r,i,a,s={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:s[a]=t[a];if(arguments.length>2&&(s.children=arguments.length>3?o.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)s[a]===void 0&&(s[a]=e.defaultProps[a]);return C(e,s,r,i,null)}function C(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??++c,__i:-1,__u:0};return i==null&&s.vnode!=null&&s.vnode(a),a}function w(e){return e.children}function T(e,t){this.props=e,this.context=t}function E(e,t){if(t==null)return e.__?E(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`?E(e):null}function D(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return D(e)}}function O(e){(!e.__d&&(e.__d=!0)&&l.push(e)&&!k.__r++||u!=s.debounceRendering)&&((u=s.debounceRendering)||d)(k)}function k(){for(var e,t,n,r,i,a,o,c=1;l.length;)l.length>c&&l.sort(f),e=l.shift(),c=l.length,e.__d&&(n=void 0,r=void 0,i=(r=(t=e).__v).__e,a=[],o=[],t.__P&&((n=x({},r)).__v=r.__v+1,s.vnode&&s.vnode(n),ie(t.__P,n,r,t.__n,t.__P.namespaceURI,32&r.__u?[i]:null,a,i??E(r),!!(32&r.__u),o),n.__v=r.__v,n.__.__k[n.__i]=n,oe(a,n,o),r.__e=r.__=null,n.__e!=i&&D(n)));k.__r=0}function te(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,y,b=r&&r.__k||v,x=t.length;for(c=A(n,t,b,c,x),d=0;d<x;d++)(p=n.__k[d])!=null&&(f=p.__i==-1?_:b[p.__i]||_,p.__i=d,g=ie(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&le(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),(y=!!(4&p.__u))||f.__k===p.__k?c=j(p,c,e,y):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function A(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=C(null,o,null,null,null):b(o)?o=e.__k[a]=C(w,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=C(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=M(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=E(s)),ue(s,s));return r}function j(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=j(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=E(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function M(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>(u?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ne(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||y.test(t)?n:n+`px`}function N(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ne(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ne(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(p,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n.u=r.u:(n.u=m,e.addEventListener(t,a?g:h,a)):e.removeEventListener(t,a?g:h,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 re(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=m++;else if(t.t<n.u)return;return n(s.event?s.event(t):t)}}}function ie(e,t,n,r,i,a,o,c,l,u){var d,f,p,m,h,g,_,v,y,S,C,E,D,O,k,A,j,M=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),a=[c=t.__e=n.__e]),(d=s.__b)&&d(t);n:if(typeof M==`function`)try{if(v=t.props,y=`prototype`in M&&M.prototype.render,S=(d=M.contextType)&&r[d.__c],C=d?S?S.props.value:d.__:r,n.__c?_=(f=t.__c=n.__c).__=f.__E:(y?t.__c=f=new M(v,C):(t.__c=f=new T(v,C),f.constructor=M,f.render=de),S&&S.sub(f),f.state||={},f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&M.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=x({},f.__s)),x(f.__s,M.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&M.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&M.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,C),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,C)){for(t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),E=0;E<f._sb.length;E++)f.__h.push(f._sb[E]);f._sb=[],f.__h.length&&o.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,C),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=C,f.props=v,f.__P=e,f.__e=!1,D=s.__r,O=0,y){for(f.state=f.__s,f.__d=!1,D&&D(t),d=f.render(f.props,f.state,f.context),k=0;k<f._sb.length;k++)f.__h.push(f._sb[k]);f._sb=[]}else do f.__d=!1,D&&D(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++O<25);f.state=f.__s,f.getChildContext!=null&&(r=x(x({},r),f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),A=d,d!=null&&d.type===w&&d.key==null&&(A=se(d.props.children)),c=te(e,b(A)?A:[A],t,n,r,i,a,o,c,l,u),f.base=t.__e,t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__E=f.__=null)}catch(e){if(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[a.indexOf(c)]=null,t.__e=c}else{for(j=a.length;j--;)ee(a[j]);ae(t)}else t.__e=n.__e,t.__k=n.__k,e.then||ae(t);s.__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,o,l,u);return(d=s.diffed)&&d(t),128&t.__u?void 0:c}function ae(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(ae)}function oe(e,t,n){for(var r=0;r<n.length;r++)le(n[r],n[++r],n[++r]);s.__c&&s.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){s.__e(e,t.__v)}})}function se(e){return typeof e!=`object`||!e||e.__b&&e.__b>0?e:b(e)?e.map(se):x({},e)}function ce(e,t,n,r,i,a,c,l,u){var d,f,p,m,h,g,v,y=n.props||_,x=t.props,S=t.type;if(S==`svg`?i=`http://www.w3.org/2000/svg`:S==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(d=0;d<a.length;d++)if((h=a[d])&&`setAttribute`in h==!!S&&(S?h.localName==S:h.nodeType==3)){e=h,a[d]=null;break}}if(e==null){if(S==null)return document.createTextNode(x);e=document.createElementNS(i,S,x.is&&x),l&&=(s.__m&&s.__m(t,a),!1),a=null}if(S==null)y===x||l&&e.data==x||(e.data=x);else{if(a&&=o.call(e.childNodes),!l&&a!=null)for(y={},d=0;d<e.attributes.length;d++)y[(h=e.attributes[d]).name]=h.value;for(d in y)if(h=y[d],d!=`children`){if(d==`dangerouslySetInnerHTML`)p=h;else if(!(d in x)){if(d==`value`&&`defaultValue`in x||d==`checked`&&`defaultChecked`in x)continue;N(e,d,null,h,i)}}for(d in x)h=x[d],d==`children`?m=h:d==`dangerouslySetInnerHTML`?f=h:d==`value`?g=h:d==`checked`?v=h:l&&typeof h!=`function`||y[d]===h||N(e,d,h,y[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=``),te(t.type==`template`?e.content:e,b(m)?m:[m],t,n,r,S==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,c,a?a[0]:n.__k&&E(n,0),l,u),a!=null)for(d=a.length;d--;)ee(a[d]);l||(d=`value`,S==`progress`&&g==null?e.removeAttribute(`value`):g!=null&&(g!==e[d]||S==`progress`&&!g||S==`option`&&g!=y[d])&&N(e,d,g,y[d],i),d=`checked`,v!=null&&v!=e[d]&&N(e,d,v,y[d],i))}return e}function le(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){s.__e(e,n)}}function ue(e,t,n){var r,i;if(s.unmount&&s.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||le(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){s.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&ue(r[i],t,n||typeof e.type!=`function`);n||ee(e.__e),e.__c=e.__=e.__e=void 0}function de(e,t,n){return this.constructor(e,n)}function fe(e,t,n){var r,i,a,c;t==document&&(t=document.documentElement),s.__&&s.__(e,t),i=(r=typeof n==`function`)?null:n&&n.__k||t.__k,a=[],c=[],ie(t,e=(!r&&n||t).__k=S(w,null,[e]),i||_,_,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?o.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,c),oe(a,e,c)}function pe(e,t){fe(e,t,pe)}function me(e,t,n){var r,i,a,s,c=x({},e.props);for(a in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)a==`key`?r=t[a]:a==`ref`?i=t[a]:c[a]=t[a]===void 0&&s!=null?s[a]:t[a];return arguments.length>2&&(c.children=arguments.length>3?o.call(arguments,2):n),C(e.type,c,r||e.key,i||e.ref,null)}o=v.slice,s={__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}},c=0,T.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=x({},this.state);typeof e==`function`&&(e=e(x({},n),this.props)),e&&x(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),O(this))},T.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),O(this))},T.prototype.render=w,l=[],d=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,f=function(e,t){return e.__v.__b-t.__v.__b},k.__r=0,p=/(PointerCapture)$|Capture$/i,m=0,h=re(!1),g=re(!0);var he=0;Array.isArray;function ge(e,t,n,r,i,a){t||={};var o,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?o=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--he,__i:-1,__u:0,__source:i,__self:a};if(typeof e==`function`&&(o=e.defaultProps))for(c in o)l[c]===void 0&&(l[c]=o[c]);return s.vnode&&s.vnode(u),u}function _e(e,{strict:t=!0}={}){return!e||typeof e!=`string`?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith(`0x`)}function ve(e){return _e(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const ye=`2.43.2`;let be={getDocsUrl:({docsBaseUrl:e,docsPath:t=``,docsSlug:n})=>t?`${e??`https://viem.sh`}${t}${n?`#${n}`:``}`:void 0,version:`viem@${ye}`};var P=class e extends Error{constructor(t,n={}){let r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,i=n.cause instanceof e&&n.cause.docsPath||n.docsPath,a=be.getDocsUrl?.({...n,docsPath:i}),o=[t||`An error occurred.`,``,...n.metaMessages?[...n.metaMessages,``]:[],...a?[`Docs: ${a}`]:[],...r?[`Details: ${r}`]:[],...be.version?[`Version: ${be.version}`]:[]].join(`
|
|
2
|
-
`);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,`details`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`docsPath`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`metaMessages`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`shortMessage`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`version`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`name`,{enumerable:!0,configurable:!0,writable:!0,value:`BaseError`}),this.details=r,this.docsPath=i,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=ye}walk(e){return xe(this,e)}};function xe(e,t){return t?.(e)?e:e&&typeof e==`object`&&`cause`in e&&e.cause!==void 0?xe(e.cause,t):t?null:e}var Se=class extends P{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:`SizeExceedsPaddingSizeError`})}};function F(e,{dir:t,size:n=32}={}){return typeof e==`string`?Ce(e,{dir:t,size:n}):we(e,{dir:t,size:n})}function Ce(e,{dir:t,size:n=32}={}){if(n===null)return e;let r=e.replace(`0x`,``);if(r.length>n*2)throw new Se({size:Math.ceil(r.length/2),targetSize:n,type:`hex`});return`0x${r[t===`right`?`padEnd`:`padStart`](n*2,`0`)}`}function we(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new Se({size:e.length,targetSize:n,type:`bytes`});let r=new Uint8Array(n);for(let i=0;i<n;i++){let a=t===`right`;r[a?i:n-i-1]=e[a?i:e.length-i-1]}return r}var Te=class extends P{constructor({max:e,min:t,signed:n,size:r,value:i}){super(`Number "${i}" is not in safe ${r?`${r*8}-bit ${n?`signed`:`unsigned`} `:``}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:`IntegerOutOfRangeError`})}},Ee=class extends P{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:`SizeOverflowError`})}};function I(e,{size:t}){if(ve(e)>t)throw new Ee({givenSize:ve(e),maxSize:t})}const De=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Oe(e,t={}){return typeof e==`number`||typeof e==`bigint`?je(e,t):typeof e==`string`?Ne(e,t):typeof e==`boolean`?ke(e,t):Ae(e,t)}function ke(e,t={}){let n=`0x${Number(e)}`;return typeof t.size==`number`?(I(n,{size:t.size}),F(n,{size:t.size})):n}function Ae(e,t={}){let n=``;for(let t=0;t<e.length;t++)n+=De[e[t]];let r=`0x${n}`;return typeof t.size==`number`?(I(r,{size:t.size}),F(r,{dir:`right`,size:t.size})):r}function je(e,t={}){let{signed:n,size:r}=t,i=BigInt(e),a;r?a=n?(1n<<BigInt(r)*8n-1n)-1n:2n**(BigInt(r)*8n)-1n:typeof e==`number`&&(a=BigInt(2**53-1));let o=typeof a==`bigint`&&n?-a-1n:0;if(a&&i>a||i<o){let t=typeof e==`bigint`?`n`:``;throw new Te({max:a?`${a}${t}`:void 0,min:`${o}${t}`,signed:n,size:r,value:`${e}${t}`})}let s=`0x${(n&&i<0?(1n<<BigInt(r*8))+BigInt(i):i).toString(16)}`;return r?F(s,{size:r}):s}const Me=new TextEncoder;function Ne(e,t={}){return Ae(Me.encode(e),t)}const Pe=new TextEncoder;function Fe(e,t={}){return typeof e==`number`||typeof e==`bigint`?ze(e,t):typeof e==`boolean`?Ie(e,t):_e(e)?Re(e,t):Be(e,t)}function Ie(e,t={}){let n=new Uint8Array(1);return n[0]=Number(e),typeof t.size==`number`?(I(n,{size:t.size}),F(n,{size:t.size})):n}const L={zero:48,nine:57,A:65,F:70,a:97,f:102};function Le(e){if(e>=L.zero&&e<=L.nine)return e-L.zero;if(e>=L.A&&e<=L.F)return e-(L.A-10);if(e>=L.a&&e<=L.f)return e-(L.a-10)}function Re(e,t={}){let n=e;t.size&&(I(n,{size:t.size}),n=F(n,{dir:`right`,size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);let i=r.length/2,a=new Uint8Array(i);for(let e=0,t=0;e<i;e++){let n=Le(r.charCodeAt(t++)),i=Le(r.charCodeAt(t++));if(n===void 0||i===void 0)throw new P(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);a[e]=n*16+i}return a}function ze(e,t){return Re(je(e,t))}function Be(e,t={}){let n=Pe.encode(e);return typeof t.size==`number`?(I(n,{size:t.size}),F(n,{dir:`right`,size:t.size})):n}const R=BigInt(2**32-1),Ve=BigInt(32);function He(e,t=!1){return t?{h:Number(e&R),l:Number(e>>Ve&R)}:{h:Number(e>>Ve&R)|0,l:Number(e&R)|0}}function Ue(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=He(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}const We=(e,t,n)=>e<<n|t>>>32-n,Ge=(e,t,n)=>t<<n|e>>>32-n,Ke=(e,t,n)=>t<<n-32|e>>>64-n,qe=(e,t,n)=>e<<n-32|t>>>64-n;function Je(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function Ye(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function z(e,...t){if(!Je(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function Xe(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function Ze(e,t){z(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function Qe(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function $e(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const et=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function tt(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function nt(e){for(let t=0;t<e.length;t++)e[t]=tt(e[t]);return e}const rt=et?e=>e:nt;typeof Uint8Array.from([]).toHex==`function`&&Uint8Array.fromHex;function it(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function at(e){return typeof e==`string`&&(e=it(e)),z(e),e}var ot=class{};function st(e){let t=t=>e().update(at(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ct(e){let t=(t,n)=>e(n).update(at(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}const lt=BigInt(0),B=BigInt(1),ut=BigInt(2),dt=BigInt(7),ft=BigInt(256),pt=BigInt(113),mt=[],ht=[],gt=[];for(let e=0,t=B,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],mt.push(2*(5*r+n)),ht.push((e+1)*(e+2)/2%64);let i=lt;for(let e=0;e<7;e++)t=(t<<B^(t>>dt)*pt)%ft,t&ut&&(i^=B<<(B<<BigInt(e))-B);gt.push(i)}const _t=Ue(gt,!0),vt=_t[0],yt=_t[1],bt=(e,t,n)=>n>32?Ke(e,t,n):We(e,t,n),xt=(e,t,n)=>n>32?qe(e,t,n):Ge(e,t,n);function St(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=bt(a,o,1)^n[r],c=xt(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=ht[n],a=bt(t,i,r),o=xt(t,i,r),s=mt[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=vt[r],e[1]^=yt[r]}$e(n)}var Ct=class e extends ot{constructor(e,t,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,Ye(n),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=Qe(this.state)}clone(){return this._cloneInto()}keccak(){rt(this.state32),St(this.state32,this.rounds),rt(this.state32),this.posOut=0,this.pos=0}update(e){Xe(this),e=at(e),z(e);let{blockLen:t,state:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Xe(this,!1),z(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return Ye(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ze(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,$e(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}};const V=(e,t,n)=>st(()=>new Ct(t,e,n));V(6,144,224/8),V(6,136,256/8),V(6,104,384/8),V(6,72,512/8),V(1,144,224/8);const wt=V(1,136,256/8);V(1,104,384/8),V(1,72,512/8);const Tt=(e,t,n)=>ct((r={})=>new Ct(t,e,r.dkLen===void 0?n:r.dkLen,!0));Tt(31,168,128/8),Tt(31,136,256/8);function Et(e,t){let n=t||`hex`,r=wt(_e(e,{strict:!1})?Fe(e):e);return n===`bytes`?r:Oe(r)}var Dt=class extends P{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:[`- Address must be a hex value of 20 bytes (40 hex characters).`,`- Address must match its checksum counterpart.`],name:`InvalidAddressError`})}},Ot=class extends Map{constructor(e){super(),Object.defineProperty(this,`maxSize`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=this.keys().next().value;e&&this.delete(e)}return this}};const kt=new Ot(8192);function At(e,t){if(kt.has(`${e}.${t}`))return kt.get(`${e}.${t}`);let n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=Et(Be(n),`bytes`),i=(t?n.substring(`${t}0x`.length):n).split(``);for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&i[e]&&(i[e]=i[e].toUpperCase()),(r[e>>1]&15)>=8&&i[e+1]&&(i[e+1]=i[e+1].toUpperCase());let a=`0x${i.join(``)}`;return kt.set(`${e}.${t}`,a),a}const jt=/^0x[a-fA-F0-9]{40}$/,Mt=new Ot(8192);function Nt(e,t){let{strict:n=!0}=t??{},r=`${e}.${n}`;if(Mt.has(r))return Mt.get(r);let i=jt.test(e)?e.toLowerCase()===e?!0:n?At(e)===e:!0:!1;return Mt.set(r,i),i}function Pt(e,t){if(!Nt(e,{strict:!1}))throw new Dt({address:e});if(!Nt(t,{strict:!1}))throw new Dt({address:t});return e.toLowerCase()===t.toLowerCase()}let H=256,U;function Ft(e=11){if(!U||H+e>256*2){U=``,H=0;for(let e=0;e<256;e++)U+=(256+Math.random()*256|0).toString(16).substring(1)}return U.substring(H,H+++e)}const W={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 G=class extends Error{constructor(e,t,n){super(t),this.code=e,this.data=n}toJSON(){return{code:this.code,message:this.message,data:this.data}}},It=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 Lt(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{let t=new URL(e.origin).origin.toLowerCase(),n=new URL(r).origin.toLowerCase();if(t!==n){console.log(`Not expected origin`,t,n);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=e;try{n=await u(e)}catch(e){throw console.error(`[RPC Client] Middleware error on request:`,e),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 It;return o.set(t,e=>{e.error?n.reject(new G(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 Rt(e){return new TextEncoder().encode(JSON.stringify(e))}function zt(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}function Bt({domain:e}={}){return Et(Oe((e??window.location.host).replace(`www.`,``)))}const Vt=`frak-client-id`;function Ht(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function Ut(){if(typeof window>`u`||!window.localStorage)return Ht();let e=localStorage.getItem(Vt);return e||(e=Ht(),localStorage.setItem(Vt,e)),e}function Wt(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function Gt(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 Kt(e){return Wt(Rt(e))}function qt(e,t,n,r,i,a){let o=Kt(Jt({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:i,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:a??Ut()})),s=new URL(e);return s.pathname=`/sso`,s.searchParams.set(`p`,o),s.toString()}function Jt(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const Yt=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,Xt=`frak-sso`;async function Zt(e,t){let{metadata:n,customizations:r,walletUrl:i}=e.config;if(t.openInSameWindow??!!t.redirectUrl)return await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]});let a=t.ssoPopupUrl??qt(i??`https://wallet.frak.id`,t,Bt(),n.name,r?.css),o=window.open(a,Xt,Yt);if(!o)throw Error(`Popup was blocked. Please allow popups for this site.`);return o.focus(),await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]})??{}}const Qt=`https://backend.frak.id`;function $t(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function en(e){return $t(e)?`http://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:Qt}function tn(e){if(e)return en(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return en(e)}return Qt}const nn=`fCtx`;function rn(e){if(e?.r)try{return Wt(Re(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function an(e){if(!(!e||e.length===0))try{return{r:Ae(Gt(e),{size:20})}}catch(t){console.error(`Error decompressing Frak context`,{e:t,context:e})}}function on({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(nn);return t?an(t):null}function sn({url:e,context:t}){if(!e)return null;let n=on({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let i=rn(r);if(!i)return null;let a=new URL(e);return a.searchParams.set(nn,i),a.toString()}function cn(e){let t=new URL(e);return t.searchParams.delete(nn),t.toString()}function ln({url:e,context:t}){if(!window.location?.href||typeof window>`u`){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?cn(n):sn({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const K={compress:rn,decompress:an,parse:on,update:sn,remove:cn,replaceUrl:ln};function q(e,t,n={}){if(!e){console.debug(`[Frak] No client provided, skipping event tracking`);return}try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}var un=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)}},dn=class{constructor(e){this.options=e,this.queue=[];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.0.4`,this.api=new un({baseUrl:e.apiUrl||`https://api.openpanel.dev`,defaultHeaders:t})}init(){}ready(){this.options.waitForProfile=!1,this.flush()}async send(e){return this.options.disabled||this.options.filter&&!this.options.filter(e)?Promise.resolve():this.options.waitForProfile&&!this.profileId?(this.queue.push(e),Promise.resolve()):this.api.fetch(`/track`,e)}setGlobalProperties(e){this.global={...this.global,...e}}async track(e,t){return this.log(`track event`,e,t),this.send({type:`track`,payload:{name:e,profileId:t?.profileId??this.profileId,properties:{...this.global??{},...t??{}}}})}async identify(e){if(this.log(`identify user`,e),e.profileId&&(this.profileId=e.profileId,this.flush()),Object.keys(e).length>1)return this.send({type:`identify`,payload:{...e,properties:{...this.global,...e.properties}}})}async alias(e){}async increment(e){return this.send({type:`increment`,payload:e})}async decrement(e){return this.send({type:`decrement`,payload:e})}async revenue(e,t){let n=t?.deviceId;return delete t?.deviceId,this.track(`revenue`,{...t??{},...n?{__deviceId:n}:{},__revenue:e})}async fetchDeviceId(){return(await this.api.fetch(`/track/device-id`,void 0,{method:`GET`,keepalive:!1}))?.deviceId??``}clear(){this.profileId=void 0}flush(){this.queue.forEach(e=>{this.send({...e,payload:{...e.payload,profileId:e.payload.profileId??this.profileId}})}),this.queue=[]}log(...e){this.options.debug&&console.log(`[OpenPanel.dev]`,...e)}};function fn(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var pn=class extends dn{constructor(e){if(super({sdk:`web`,sdkVersion:`1.0.7`,...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=[]}this.setGlobalProperties({__referrer:document.referrer}),this.options.trackScreenViews&&(this.trackScreenViews(),setTimeout(()=>this.screenView(),0)),this.options.trackOutgoingLinks&&this.trackOutgoingLinks(),this.options.trackAttributes&&this.trackAttributes()}}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[fn(t.name.replace(/^data-/,``))]=t.value);let t=i.getAttribute(`data-track`);t&&super.track(t,e)}})}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 J=`nexus-wallet-backup`,mn=`frakwallet://`;function hn(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}}),console.log(`[SSO URL Listener] Forwarded compressed SSO data to iframe`)}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()),console.log(`[SSO URL Listener] SSO parameter detected and URL cleaned`))}var gn=class e{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e,t){this.lastResponse={message:e,response:t,timestamp:Date.now()}}setLastRequest(e){this.lastRequest={event:e,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn(`Failed to encode debug data`,e),btoa(`Failed to encode data`)}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute(`loading`),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?this.iframe.contentDocument.readyState===`complete`?1:0:-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let t=this.getIframeStatus(),n=this.getNavigatorInfo(),r=`Unknown`;return e instanceof G?r=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?r=e.message:typeof e==`string`&&(r=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):`no-config`,navigatorInfo:n?this.base64Encode(n):`no-navigator`,iframeStatus:t?this.base64Encode(t):`not-iframe`,lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):`No Frak request logged`,lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):`No Frak response logged`,clientStatus:this.isSetupDone?`setup`:`not-setup`,error:r}}static empty(){return new e}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
|
|
3
|
-
Debug Information:
|
|
4
|
-
-----------------
|
|
5
|
-
Timestamp: ${t.timestamp}
|
|
6
|
-
URL: ${t.encodedUrl}
|
|
7
|
-
Config: ${t.encodedConfig}
|
|
8
|
-
Navigator Info: ${t.navigatorInfo}
|
|
9
|
-
IFrame Status: ${t.iframeStatus}
|
|
10
|
-
Last Request: ${t.lastRequest}
|
|
11
|
-
Last Response: ${t.lastResponse}
|
|
12
|
-
Client Status: ${t.clientStatus}
|
|
13
|
-
Error: ${t.error}
|
|
14
|
-
`.trim()}};function _n(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function vn(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;package=id.frak.wallet;end`}function yn(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=_n()&&bn(e)?vn(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function bn(e){return e.startsWith(mn)}const Y={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function xn({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);return r.id=Y.id,r.name=Y.name,r.allow=Y.allow,r.style.zIndex=Y.style.zIndex.toString(),Sn({iframe:r,isVisible:!1}),r.src=`${t?.walletUrl??e??`https://wallet.frak.id`}/listener`,new Promise(e=>{r.addEventListener(`load`,()=>e(r)),document.body.appendChild(r)})}function Sn({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function Cn(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 wn(e){e?localStorage.setItem(J,e):localStorage.removeItem(J)}function Tn(e,t,n,r){let i=new URL(window.location.href),a=i.searchParams.get(`fmt`)??void 0;e.contentWindow?.postMessage({clientLifecycle:`handshake-response`,data:{token:t,currentUrl:window.location.href,clientId:Ut(),pendingMergeToken:a,configDomain:r}},n),a&&(i.searchParams.delete(`fmt`),window.history.replaceState({},``,i.toString()))}function En(e,t){try{let n=new URL(e);return n.searchParams.has(`u`)?(n.searchParams.delete(`u`),n.searchParams.append(`u`,window.location.href),t&&n.searchParams.append(`fmt`,t),n.toString()):e}catch{return e}}function Dn(e,t,n,r){let i=En(t,r);bn(t)?yn(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}}):window.location.href=i}function On({iframe:e,targetOrigin:t,configDomain:n}){let r=new It;return{handleEvent:async i=>{if(!(`iframeLifecycle`in i))return;let{iframeLifecycle:a,data:o}=i;switch(a){case`connected`:r.resolve(!0);break;case`do-backup`:wn(o.backup);break;case`remove-backup`:localStorage.removeItem(J);break;case`show`:case`hide`:Sn({iframe:e,isVisible:a===`show`});break;case`handshake`:Tn(e,o.token,t,n);break;case`redirect`:Dn(e,o.baseRedirectUrl,t,o.mergeToken);break}},isConnected:r.promise}}function kn({config:e,iframe:t}){let n=e?.walletUrl??`https://wallet.frak.id`,r=On({iframe:t,targetOrigin:n,configDomain:e.domain}),i=new gn(e,t);if(!t.contentWindow)throw new G(W.configError,`The iframe does not have a content window`);let a=Lt({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await r.isConnected)throw new G(W.clientNotConnected,`The iframe provider isn't connected yet`);return t}},{onRequest(e,t){return i.setLastRequest(e),t},onResponse(e,t){return i.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:async(e,t)=>{await r.handleEvent(e)}}}),o=An(a,r),s=async()=>{o(),a.cleanup(),t.remove()},c;console.log(`[Frak SDK] Initializing OpenPanel`),c=new pn({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdkVersion`in t.properties||(t.properties={...t.properties,sdkVersion:`0.1.1`}),!0)}),c.setGlobalProperties({sdkVersion:`0.1.1`}),c.init();let l=jn({config:e,rpcClient:a,lifecycleManager:r}).then(()=>i.updateSetupStatus(!0));return{config:e,debugInfo:i,waitForConnection:r.isConnected,waitForSetup:l,request:a.request,listenerRequest:a.listen,destroy:s,openPanel:c}}function An(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,1e3),r=setTimeout(()=>{o(),console.log(`Heartbeat timeout: connection failed`)},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function jn({config:e,rpcClient:t,lifecycleManager:n}){await n.isConnected,hn(t,n.isConnected);async function r(){let n=e.customizations?.css;if(!n)return;let r={clientLifecycle:`modal-css`,data:{cssLink:n}};t.sendLifecycle(r)}async function i(){let n=e.customizations?.i18n;if(!n)return;let r={clientLifecycle:`modal-i18n`,data:{i18n:n}};t.sendLifecycle(r)}async function a(){if(typeof window>`u`)return;let e=window.localStorage.getItem(J);if(!e)return;let n={clientLifecycle:`restore-backup`,data:{backup:e}};t.sendLifecycle(n)}await Promise.allSettled([r(),i(),a()])}function Mn(e){return zt(Gt(e))}const X={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function Nn(e){return e&&e in X?e:`eur`}function Pn(e){return e?X[e]??X.eur:X.eur}function Fn(e,t){let n=Pn(t),r=Nn(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function In(e){return e?`${e}Amount`:`eurAmount`}let Z,Q;async function Ln(e,t){if(Z)return Z;if(Q)return Q;Q=Rn(e,t);let n=await Q;return Q=void 0,n}async function Rn(e,t){let n=e??(typeof window<`u`?window.location.hostname:``);if(n)try{let e=tn(t),r=await fetch(`${e}/user/merchant/resolve?domain=${encodeURIComponent(n)}`);if(!r.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${n}: ${r.status}`);return}return Z=(await r.json()).merchantId,Z}catch(e){console.warn(`[Frak SDK] Failed to fetch merchantId:`,e);return}}function zn(){Z=void 0,Q=void 0}async function Bn(e,t){return e.metadata?.merchantId?e.metadata.merchantId:Ln(void 0,t)}async function Vn({config:e}){let t=Hn(e),n=await xn({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=kn({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function Hn(e){let t=Nn(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}function Un(){return Ft(96)}async function $(e,t){return await e.request({method:`frak_displayEmbeddedWallet`,params:[t,e.config.metadata]})}async function Wn(e,{steps:t,metadata:n}){return await e.request({method:`frak_displayModal`,params:[t,n,e.config.metadata]})}async function Gn(e){return await e.request({method:`frak_getMerchantInformation`})}async function Kn(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function qn(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}async function Jn(e,{walletStatus:t,frakContext:n,modalConfig:r,options:i}){if(!n?.r)return`no-referrer`;q(e,`user_referred_started`,{properties:{referrer:n?.r,walletStatus:t?.key}}),qn(e,{type:`arrival`,referrerWallet:n.r,landingUrl:typeof window<`u`?window.location.href:void 0});let a=!1;async function o(){if(!a)return a=!0,Xn(e,{modalConfig:{...r,loggedIn:{action:{key:`referred`}}},walletStatus:t})}try{let{status:r,currentWallet:a}=await Yn({initialWalletStatus:t,getFreshWalletStatus:o,frakContext:n});return K.replaceUrl({url:window.location?.href,context:i?.alwaysAppendUrl?{r:a}:null}),q(e,`user_referred_completed`,{properties:{status:r,referrer:n?.r,wallet:a}}),r}catch(r){return console.log(`Error processing referral`,{error:r}),q(e,`user_referred_error`,{properties:{referrer:n?.r,error:r instanceof G?`[${r.code}] ${r.name} - ${r.message}`:r instanceof Error?r.message:`undefined`}}),K.replaceUrl({url:window.location?.href,context:i?.alwaysAppendUrl?{r:t?.wallet}:null}),Zn(r)}}async function Yn({initialWalletStatus:e,getFreshWalletStatus:t,frakContext:n}){let r=e?.wallet;return r||=await t(),r&&Pt(n.r,r)?{status:`self-referral`,currentWallet:r}:{status:`success`,currentWallet:r}}async function Xn(e,{modalConfig:t,walletStatus:n}){return n?.key===`connected`?n.wallet??void 0:(await $(e,t??{}))?.wallet??void 0}function Zn(e){if(e instanceof G)switch(e.code){case W.walletNotConnected:return`no-wallet`;default:return`error`}return`error`}async function Qn(e,{modalConfig:t,options:n}={}){let r=K.parse({url:window.location.href}),i=await er(e);try{return await Jn(e,{walletStatus:i,frakContext:r,modalConfig:t,options:n})}catch(e){console.warn(`Error processing referral`,{error:e})}}async function $n(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`);if(!t){console.warn(`[Frak] No frak session found, skipping purchase check`);return}let n=tn();await fetch(`${n}/interactions/listenForPurchase`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":t},body:JSON.stringify(e)})}function er(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(tr(e,t),t));let n=new It,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{tr(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function tr(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function nr(e,{metadata:t,login:n}){return rr(e,{steps:{login:n??{}},metadata:t})}function rr(e,t){function n(n){return rr(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return rr(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return rr(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function a(n){return n&&(t.metadata=n(t.metadata??{})),await Wn(e,t)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function ir(e,{tx:t,metadata:n}){return(await Wn(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function ar(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 Wn(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??Un(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var or=t({DEEP_LINK_SCHEME:()=>mn,DebugInfoGatherer:()=>gn,FrakContextManager:()=>K,base64urlDecode:()=>Gt,base64urlEncode:()=>Wt,baseIframeProps:()=>Y,clearMerchantIdCache:()=>zn,compressJsonToB64:()=>Kt,computeLegacyProductId:()=>Bt,createIFrameFrakClient:()=>kn,createIframe:()=>xn,decompressJsonFromB64:()=>Mn,displayEmbeddedWallet:()=>$,displayModal:()=>Wn,fetchMerchantId:()=>Ln,findIframeInOpener:()=>Cn,formatAmount:()=>Fn,generateSsoUrl:()=>qt,getBackendUrl:()=>tn,getClientId:()=>Ut,getCurrencyAmountKey:()=>In,getMerchantInformation:()=>Gn,getSupportedCurrency:()=>Nn,getSupportedLocale:()=>Pn,isChromiumAndroid:()=>_n,isFrakDeepLink:()=>bn,locales:()=>X,modalBuilder:()=>nr,openSso:()=>Zt,prepareSso:()=>Kn,processReferral:()=>Jn,referralInteraction:()=>Qn,resolveMerchantId:()=>Bn,sendInteraction:()=>qn,sendTransaction:()=>ir,setupClient:()=>Vn,siweAuthenticate:()=>ar,ssoPopupFeatures:()=>Yt,ssoPopupName:()=>Xt,toAndroidIntentUrl:()=>vn,trackEvent:()=>q,trackPurchaseStatus:()=>$n,triggerDeepLinkWithFallback:()=>yn,watchWalletStatus:()=>er});function sr(){`vibrate`in navigator?navigator.vibrate(10):console.log(`Vibration not supported`)}function cr(){if(!window.FrakSetup?.client){console.error(`Frak client not found`);return}sr(),$(window.FrakSetup.client,window.FrakSetup?.modalWalletConfig??{})}const lr=`frakClientReady`;function ur(){let e=new CustomEvent(lr);window.dispatchEvent(e)}function dr(e,t){if(window.FrakSetup?.client&&e===`add`){t();return}(e===`add`?window.addEventListener:window.removeEventListener)(lr,t,!1)}function fr(e){window.modalBuilderSteps=nr(e,window.FrakSetup?.modalConfig??{})}async function pr(e){let t=await Qn(e,{modalConfig:window.FrakSetup?.modalWalletConfig});console.log(`referral`,t)}function mr(){if(!window.modalBuilderSteps)throw Error(`modalBuilderSteps not found`);return window.modalBuilderSteps}async function hr(){if(window.FrakSetup.core=or,!gr())return;if(console.log(`[Frak SDK] Starting initialization`),!window.FrakSetup.config){console.error(`[Frak SDK] Configuration not found`),window.frakSetupInProgress=!1;return}let e=await Vn({config:window.FrakSetup.config});if(!e){console.error(`[Frak SDK] Failed to create client`),window.frakSetupInProgress=!1;return}window.FrakSetup.client=e,console.log(`[Frak SDK] Client initialized successfully`),ur(),fr(e),pr(e),window.frakSetupInProgress=!1,_r()}function gr(){return window.frakSetupInProgress?(console.log(`[Frak SDK] Initialization already in progress`),!1):(window.frakSetupInProgress=!0,window.FrakSetup?.client?(console.log(`[Frak SDK] Client already initialized`),window.frakSetupInProgress=!1,!1):window.FrakSetup?.config?!0:(console.error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`),window.frakSetupInProgress=!1,!1))}function _r(){let e=new URLSearchParams(window.location.search).get(`frakAction`);e&&e===`share`&&(console.log(`[Frak SDK] Auto open query param found`),cr())}export{n as C,a as S,pe as _,$ as a,w as b,In as c,mn as d,q as f,fe as g,ge as h,cr as i,gn as l,G as m,mr as n,Gn as o,W as p,dr as r,Fn as s,hr as t,yn as u,me as v,s as x,S as y};
|