@frak-labs/components 0.0.23-beta.278e9605 → 0.0.23-beta.7e126d46

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.
@@ -0,0 +1 @@
1
+ import{a as e,c as t,d as n,f as r,l as i,n as a,o,p as s,r as c,s as l,t as u,u as d}from"./loader.js";var f,p,m,h,g,_,v,y,b,x,S,C={},w=[],T=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,E=Array.isArray;function D(e,t){for(var n in t)e[n]=t[n];return e}function O(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function k(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?f.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return A(e,o,r,i,null)}function A(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??++m,__i:-1,__u:0};return i==null&&p.vnode!=null&&p.vnode(a),a}function j(e){return e.children}function M(e,t){this.props=e,this.context=t}function N(e,t){if(t==null)return e.__?N(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`?N(e):null}function ee(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 ee(e)}}function te(e){(!e.__d&&(e.__d=!0)&&h.push(e)&&!P.__r++||g!=p.debounceRendering)&&((g=p.debounceRendering)||_)(P)}function P(){for(var e,t,n,r,i,a,o,s=1;h.length;)h.length>s&&h.sort(v),e=h.shift(),s=h.length,e.__d&&(n=void 0,r=void 0,i=(r=(t=e).__v).__e,a=[],o=[],t.__P&&((n=D({},r)).__v=r.__v+1,p.vnode&&p.vnode(n),ce(t.__P,n,r,t.__n,t.__P.namespaceURI,32&r.__u?[i]:null,a,i??N(r),!!(32&r.__u),o),n.__v=r.__v,n.__.__k[n.__i]=n,ue(a,n,o),r.__e=r.__=null,n.__e!=i&&ee(n)));P.__r=0}function ne(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v=r&&r.__k||w,y=t.length;for(c=re(n,t,v,c,y),d=0;d<y;d++)(p=n.__k[d])!=null&&(f=p.__i==-1?C:v[p.__i]||C,p.__i=d,g=ce(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&pe(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),(_=!!(4&p.__u))||f.__k===p.__k?c=ie(p,c,e,_):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function re(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]=A(null,o,null,null,null):E(o)?o=e.__k[a]=A(j,{children:o},null,null,null):o.constructor==null&&o.__b>0?o=e.__k[a]=A(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,(l=o.__i=ae(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=N(s)),me(s,s));return r}function ie(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=ie(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=N(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ae(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 oe(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||T.test(t)?n:n+`px`}function F(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||oe(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||oe(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(y,`$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=b,e.addEventListener(t,a?S:x,a)):e.removeEventListener(t,a?S:x,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 se(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=b++;else if(t.t<n.u)return;return n(p.event?p.event(t):t)}}}function ce(e,t,n,r,i,a,o,s,c,l){var u,d,f,m,h,g,_,v,y,b,x,S,C,w,T,k,A,N=t.type;if(t.constructor!=null)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=p.__b)&&u(t);n:if(typeof N==`function`)try{if(v=t.props,y=`prototype`in N&&N.prototype.render,b=(u=N.contextType)&&r[u.__c],x=u?b?b.props.value:u.__:r,n.__c?_=(d=t.__c=n.__c).__=d.__E:(y?t.__c=d=new N(v,x):(t.__c=d=new M(v,x),d.constructor=N,d.render=he),b&&b.sub(d),d.state||={},d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),y&&d.__s==null&&(d.__s=d.state),y&&N.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=D({},d.__s)),D(d.__s,N.getDerivedStateFromProps(v,d.__s))),m=d.props,h=d.state,d.__v=t,f)y&&N.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),y&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(y&&N.getDerivedStateFromProps==null&&v!==m&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(v,x),t.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&!1===d.shouldComponentUpdate(v,d.__s,x)){for(t.__v!=n.__v&&(d.props=v,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),S=0;S<d._sb.length;S++)d.__h.push(d._sb[S]);d._sb=[],d.__h.length&&o.push(d);break n}d.componentWillUpdate!=null&&d.componentWillUpdate(v,d.__s,x),y&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(m,h,g)})}if(d.context=x,d.props=v,d.__P=e,d.__e=!1,C=p.__r,w=0,y){for(d.state=d.__s,d.__d=!1,C&&C(t),u=d.render(d.props,d.state,d.context),T=0;T<d._sb.length;T++)d.__h.push(d._sb[T]);d._sb=[]}else do d.__d=!1,C&&C(t),u=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++w<25);d.state=d.__s,d.getChildContext!=null&&(r=D(D({},r),d.getChildContext())),y&&!f&&d.getSnapshotBeforeUpdate!=null&&(g=d.getSnapshotBeforeUpdate(m,h)),k=u,u!=null&&u.type===j&&u.key==null&&(k=de(u.props.children)),s=ne(e,E(k)?k:[k],t,n,r,i,a,o,s,c,l),d.base=t.__e,t.__u&=-161,d.__h.length&&o.push(d),_&&(d.__E=d.__=null)}catch(e){if(t.__v=null,c||a!=null)if(e.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(A=a.length;A--;)O(a[A]);le(t)}else t.__e=n.__e,t.__k=n.__k,e.then||le(t);p.__e(e,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=fe(n.__e,t,n,r,i,a,o,c,l);return(u=p.diffed)&&u(t),128&t.__u?void 0:s}function le(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(le)}function ue(e,t,n){for(var r=0;r<n.length;r++)pe(n[r],n[++r],n[++r]);p.__c&&p.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){p.__e(e,t.__v)}})}function de(e){return typeof e!=`object`||!e||e.__b&&e.__b>0?e:E(e)?e.map(de):D({},e)}function fe(e,t,n,r,i,a,o,s,c){var l,u,d,m,h,g,_,v=n.props||C,y=t.props,b=t.type;if(b==`svg`?i=`http://www.w3.org/2000/svg`:b==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l<a.length;l++)if((h=a[l])&&`setAttribute`in h==!!b&&(b?h.localName==b:h.nodeType==3)){e=h,a[l]=null;break}}if(e==null){if(b==null)return document.createTextNode(y);e=document.createElementNS(i,b,y.is&&y),s&&=(p.__m&&p.__m(t,a),!1),a=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(a&&=f.call(e.childNodes),!s&&a!=null)for(v={},l=0;l<e.attributes.length;l++)v[(h=e.attributes[l]).name]=h.value;for(l in v)if(h=v[l],l!=`children`){if(l==`dangerouslySetInnerHTML`)d=h;else if(!(l in y)){if(l==`value`&&`defaultValue`in y||l==`checked`&&`defaultChecked`in y)continue;F(e,l,null,h,i)}}for(l in y)h=y[l],l==`children`?m=h:l==`dangerouslySetInnerHTML`?u=h:l==`value`?g=h:l==`checked`?_=h:s&&typeof h!=`function`||v[l]===h||F(e,l,h,v[l],i);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=``),ne(t.type==`template`?e.content:e,E(m)?m:[m],t,n,r,b==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&N(n,0),s,c),a!=null)for(l=a.length;l--;)O(a[l]);s||(l=`value`,b==`progress`&&g==null?e.removeAttribute(`value`):g!=null&&(g!==e[l]||b==`progress`&&!g||b==`option`&&g!=v[l])&&F(e,l,g,v[l],i),l=`checked`,_!=null&&_!=e[l]&&F(e,l,_,v[l],i))}return e}function pe(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){p.__e(e,n)}}function me(e,t,n){var r,i;if(p.unmount&&p.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||pe(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){p.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&me(r[i],t,n||typeof e.type!=`function`);n||O(e.__e),e.__c=e.__=e.__e=void 0}function he(e,t,n){return this.constructor(e,n)}function I(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),p.__&&p.__(e,t),i=(r=typeof n==`function`)?null:n&&n.__k||t.__k,a=[],o=[],ce(t,e=(!r&&n||t).__k=k(j,null,[e]),i||C,C,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?f.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),ue(a,e,o)}function ge(e,t){I(e,t,ge)}function _e(e,t,n){var r,i,a,o,s=D({},e.props);for(a in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)a==`key`?r=t[a]:a==`ref`?i=t[a]:s[a]=t[a]===void 0&&o!=null?o[a]:t[a];return arguments.length>2&&(s.children=arguments.length>3?f.call(arguments,2):n),A(e.type,s,r||e.key,i||e.ref,null)}f=w.slice,p={__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}},m=0,M.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=D({},this.state);typeof e==`function`&&(e=e(D({},n),this.props)),e&&D(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),te(this))},M.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),te(this))},M.prototype.render=j,h=[],_=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,v=function(e,t){return e.__v.__b-t.__v.__b},P.__r=0,y=/(PointerCapture)$|Capture$/i,b=0,x=se(!1),S=se(!0);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 ve(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 ye=[`context`,`children`],be=[`useFragment`];function xe(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(){Ce.call(this,r)},i.prototype.attributeChangedCallback=Te,i.prototype.disconnectedCallback=Ee,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 Se(e){this.getChildContext=function(){return e.context};var t=e.children;return _e(t,ve(e,ye))}function Ce(e){var t=new CustomEvent(`_preact`,{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(t),this._vdom=k(Se,L({},this._props,{context:t.detail.context}),Oe(this,this._vdomComponent,e)),(this.hasAttribute(`hydrate`)?ge:I)(this._vdom,this._root)}function we(e){return e.replace(/-(\w)/g,function(e,t){return t?t.toUpperCase():``})}function Te(e,t,n){if(this._vdom){var r={};r[e]=n??=void 0,r[we(e)]=n,this._vdom=_e(this._vdom,r),I(this._vdom,this._root)}}function Ee(){I(this._vdom=null,this._root)}function De(e,t){var n=this,r=e.useFragment,i=ve(e,be);return k(r?j:`slot`,L({},i,{ref:function(e){e?(n.ref=e,n._listener||(n._listener=function(e){e.stopPropagation(),e.detail.context=t},e.addEventListener(`_preact`,n._listener))):n.ref.removeEventListener(`_preact`,n._listener)}}))}function Oe(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[we(o[a].name)]=o[a].value);for(a=s.length;a--;){var c=Oe(s[a],null,n),l=s[a].slot;l?i[l]=k(De,{name:l},c):r[a]=c}var u=!(!n||!n.shadow),d=t?k(De,{useFragment:!u},r):r;return!u&&t&&(e.innerHTML=``),k(t||e.nodeName.toLowerCase(),i,d)}function ke(e,t,n=[],r={shadow:!1}){typeof window<`u`&&(s(u),customElements.get(t)||xe(e,t,n,r))}function Ae(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Ae(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function je(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Ae(e))&&(r&&(r+=` `),r+=t);return r}const R=je;var z,B,V,Me,H=0,Ne=[],U=p,Pe=U.__b,Fe=U.__r,Ie=U.diffed,Le=U.__c,Re=U.unmount,ze=U.__;function W(e,t){U.__h&&U.__h(B,e,H||t),H=0;var n=B.__H||={__:[],__h:[]};return e>=n.__.length&&n.__.push({}),n.__[e]}function G(e){return H=1,Be(Ke,e)}function Be(e,t,n){var r=W(z++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ke(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=B,!B.__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.forEach(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};B.__f=!0;var a=B.shouldComponentUpdate,o=B.componentWillUpdate;B.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)},B.shouldComponentUpdate=i}return r.__N||r.__}function K(e,t){var n=W(z++,3);!U.__s&&Ge(n.__H,t)&&(n.__=e,n.u=t,B.__H.__h.push(n))}function q(e,t){var n=W(z++,7);return Ge(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function J(e,t){return H=8,q(function(){return e},t)}function Ve(){for(var e;e=Ne.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Y),e.__H.__h.forEach(We),e.__H.__h=[]}catch(t){e.__H.__h=[],U.__e(t,e.__v)}}U.__b=function(e){B=null,Pe&&Pe(e)},U.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ze&&ze(e,t)},U.__r=function(e){Fe&&Fe(e),z=0;var t=(B=e.__c).__H;t&&(V===B?(t.__h=[],B.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(Y),t.__h.forEach(We),t.__h=[],z=0)),V=B},U.diffed=function(e){Ie&&Ie(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ne.push(t)!==1&&Me===U.requestAnimationFrame||((Me=U.requestAnimationFrame)||Ue)(Ve)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),V=B=null},U.__c=function(e,t){t.some(function(e){try{e.__h.forEach(Y),e.__h=e.__h.filter(function(e){return!e.__||We(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],U.__e(n,e.__v)}}),Le&&Le(e,t)},U.unmount=function(e){Re&&Re(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{Y(e)}catch(e){t=e}}),n.__H=void 0,t&&U.__e(t,n.__v))};var He=typeof requestAnimationFrame==`function`;function Ue(e){var t,n=function(){clearTimeout(r),He&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);He&&(t=requestAnimationFrame(n))}function Y(e){var t=B,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),B=t}function We(e){var t=B;e.__c=e.__(),B=t}function Ge(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ke(e,t){return typeof t==`function`?t(e):t}const X={spinner__leaf:`M4fSKa_spinner__leaf`,spinner:`M4fSKa_spinner`,"rt-spinner-leaf-fade":`M4fSKa_rt-spinner-leaf-fade`};var Z=X;X.spinner__leaf,X.spinner,X[`rt-spinner-leaf-fade`];var qe=0;Array.isArray;function Q(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--qe,__i:-1,__u:0,__source:i,__self:a};if(typeof e==`function`&&(o=e.defaultProps))for(s in o)c[s]===void 0&&(c[s]=o[s]);return p.vnode&&p.vnode(l),l}const Je=({ref:e,className:t,...n})=>Q(`span`,{...n,ref:e,className:R(Z.spinner),children:[Q(`span`,{className:Z.spinner__leaf}),Q(`span`,{className:Z.spinner__leaf}),Q(`span`,{className:Z.spinner__leaf}),Q(`span`,{className:Z.spinner__leaf}),Q(`span`,{className:Z.spinner__leaf}),Q(`span`,{className:Z.spinner__leaf}),Q(`span`,{className:Z.spinner__leaf}),Q(`span`,{className:Z.spinner__leaf})]});Je.displayName=`Spinner`;function Ye(){let[e,t]=G(!0),n=J(()=>{t(!1)},[]);return K(()=>(c(`add`,n),()=>c(`remove`,n)),[n]),{isClientReady:!e}}async function Xe({targetInteraction:t}){let n=window.FrakSetup?.client;if(!n){console.warn(`Frak client not ready yet`);return}let{maxReferrer:r,rewards:a}=await e(n);if(!r)return;let o=i(n.config.metadata?.currency),s=Math.round(r[o]);if(t){let e=a.filter(e=>e.interactionTypeKey===t).map(e=>e.referrer[o]).reduce((e,t)=>t>e?t:e,0);e>0&&(s=Math.round(e))}return l(s,n.config.metadata?.currency)}function Ze(e,t){let[n,r]=G(void 0);return K(()=>{e&&Xe({targetInteraction:t}).then(e=>{e&&r(e)})},[e,t]),{reward:n}}const Qe={buttonShare:`nOB7Uq_buttonShare`};var $e=Qe;Qe.buttonShare;function et(e={}){let{successDuration:t=2e3}=e,[n,r]=G(!1);return{copy:J(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 $={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 tt({debugInfo:e}){let[t,n]=G(!1);return Q(`div`,{children:[Q(`button`,{type:`button`,style:$.copyButton,onClick:()=>n(!t),children:`Ouvrir les informations`}),t&&Q(`textarea`,{style:{display:`block`,width:`100%`,height:`200px`,fontSize:`12px`},children:e})]})}function nt({debugInfo:e}){let{copied:t,copy:n}=et();return Q(`div`,{style:$.errorContainer,children:[Q(`div`,{style:$.header,children:Q(`h3`,{style:$.title,children:`Oups ! Nous avons rencontré un petit problème`})}),Q(`p`,{style:$.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 à`,` `,Q(`a`,{href:`mailto:help@frak-labs.com?subject=Debug`,style:$.link,children:`help@frak-labs.com`}),` `,Q(`br`,{}),`Merci pour votre retour, nous traitons votre demande dans les plus brefs délais.`]}),Q(`button`,{type:`button`,onClick:()=>n(e??``),style:$.copyButton,children:t?`Informations copiées !`:`Copier les informations de débogage`}),Q(tt,{debugInfo:e})]})}function rt(e){let[i,o]=G(void 0),[s,c]=G(!1);return{handleShare:J(async()=>{if(!window.FrakSetup?.client){console.error(`Frak client not found`),o(t.empty().formatDebugInfo(`Frak client not found`)),c(!0);return}let i=a();if(!i)throw Error(`modalBuilderSteps not found`);try{await i.sharing(window.FrakSetup?.modalShareConfig??{}).display(t=>({...t,targetInteraction:e}))}catch(e){if(e instanceof n&&e.code===r.clientAborted){console.debug(`User aborted the modal`);return}let t=window.FrakSetup.client.debugInfo.formatDebugInfo(e);d(window.FrakSetup.client,`share_modal_error`,{error:e instanceof Object&&`message`in e?e.message:`Unknown error`,debugInfo:t}),o(t),c(!0),console.error(`Error while opening the modal`,e)}},[e]),isError:s,debugInfo:i}}async function it(){if(!window.FrakSetup?.client)throw Error(`Frak client not found`);await o(window.FrakSetup.client,window.FrakSetup?.modalWalletConfig??{})}function at({text:e=`Share and earn!`,classname:t=``,useReward:n,noRewardText:r,targetInteraction:i,showWallet:a}){let o=q(()=>n!==void 0,[n]),s=q(()=>a!==void 0,[a]),{isClientReady:c}=Ye(),{reward:l}=Ze(o&&c,i),{handleShare:u,isError:f,debugInfo:p}=rt(i),m=q(()=>o?l?e.includes(`{REWARD}`)?e.replace(`{REWARD}`,l):`${e} ${l}`:r??e.replace(`{REWARD}`,``):e,[o,e,r,l]),h=J(async()=>{d(window.FrakSetup.client,`share_button_clicked`),s?await it():await u()},[s,u]);return Q(j,{children:[Q(`button`,{type:`button`,className:R($e.buttonShare,t,`override`),onClick:h,children:[!c&&Q(Je,{}),` `,m]}),f&&Q(nt,{debugInfo:p})]})}ke(at,`frak-button-share`,[`text`],{shadow:!1});export{at as ButtonShare,G as a,ke as c,q as i,Ye as n,K as o,Q as r,R as s,Ze as t};
@@ -0,0 +1 @@
1
+ import{i as e,u as t}from"./loader.js";import{a as n,c as r,i,n as a,o,r as s,s as c,t as l}from"./ButtonShare.D40CBIiu.js";function u(e){return s(`svg`,{fill:`none`,height:`1em`,viewBox:`0 0 28 28`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[s(`title`,{children:`Gift icon`}),s(`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={button:`Kl62ia_button`,reward:`Kl62ia_reward`,button__left:`Kl62ia_button__left`,button__right:`Kl62ia_button__right`};var f=d;d.button,d.reward,d.button__left,d.button__right;function p({classname:r=``,useReward:d,targetInteraction:p}){let m=i(()=>d!==void 0,[d]),{isClientReady:h}=a(),{reward:g}=l(m&&h,p),[_,v]=n(`right`);return o(()=>{let e=window.FrakSetup?.modalWalletConfig?.metadata?.position;v(e??`right`)},[]),s(`button`,{type:`button`,"aria-label":`Open wallet`,class:c(f.button,_===`left`?f.button__left:f.button__right,r,`override`),disabled:!h,onClick:()=>{t(window.FrakSetup.client,`wallet_button_clicked`),e()},children:[s(u,{}),g&&s(`span`,{className:f.reward,children:g})]})}r(p,`frak-button-wallet`,[],{shadow:!1});export{p as ButtonWallet};
@@ -0,0 +1 @@
1
+ import(`https://cdn.jsdelivr.net/npm/@frak-labs/components@latest/cdn/loader.js?v=1767780204364`);
package/cdn/loader.css ADDED
@@ -0,0 +1,7 @@
1
+ /* ButtonShare-DFqabzEZ.css */
2
+ .M4fSKa_spinner{--spinner-opacity:.65;opacity:var(--spinner-opacity);width:16px;height:16px;display:block;position:relative}.M4fSKa_spinner__leaf{--spinner-animation-duration:.8s;width:12.5%;height:100%;animation:M4fSKa_rt-spinner-leaf-fade var(--spinner-animation-duration)linear infinite;position:absolute;top:0;left:43.75%;&:before{content:"";background-color:currentColor;border-radius:3px;width:100%;height:30%;display:block}&:where(:first-child){animation-delay:calc(-8/8*var(--spinner-animation-duration));transform:rotate(0)}&:where(:nth-child(2)){animation-delay:calc(-7/8*var(--spinner-animation-duration));transform:rotate(45deg)}&:where(:nth-child(3)){animation-delay:calc(-6/8*var(--spinner-animation-duration));transform:rotate(90deg)}&:where(:nth-child(4)){animation-delay:calc(-5/8*var(--spinner-animation-duration));transform:rotate(135deg)}&:where(:nth-child(5)){animation-delay:calc(-4/8*var(--spinner-animation-duration));transform:rotate(180deg)}&:where(:nth-child(6)){animation-delay:calc(-3/8*var(--spinner-animation-duration));transform:rotate(225deg)}&:where(:nth-child(7)){animation-delay:calc(-2/8*var(--spinner-animation-duration));transform:rotate(270deg)}&:where(:nth-child(8)){animation-delay:calc(-1/8*var(--spinner-animation-duration));transform:rotate(315deg)}}@keyframes M4fSKa_rt-spinner-leaf-fade{0%{opacity:1}to{opacity:.25}}
3
+ .nOB7Uq_buttonShare{justify-content:center;align-items:center;gap:10px;display:flex}
4
+
5
+
6
+ /* ButtonWallet-B5NeF40U.css */
7
+ .Kl62ia_button{all:unset;z-index:2000000;cursor:pointer;text-align:center;background-color:#3e557e;border-radius:50%;justify-content:center;align-items:center;width:45px;height:45px;font-size:24px;display:flex;position:fixed;bottom:20px}.Kl62ia_button__left{left:20px}.Kl62ia_button__right{right:20px}.Kl62ia_reward{color:#fff;white-space:nowrap;background:#ff3f3f;border-radius:5px;padding:2px 3px;font-size:9px;font-weight:600;line-height:9px;position:absolute;top:-4px;right:27px}
package/cdn/loader.js ADDED
@@ -0,0 +1,18 @@
1
+ var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(e,t)=>()=>(e&&(t=e(e=0)),t),a=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),o=(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},s=(i,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(var c=n(a),l=0,u=c.length,d;l<u;l++)d=c[l],!r.call(i,d)&&d!==o&&e(i,d,{get:(e=>a[e]).bind(null,d),enumerable:!(s=t(a,d))||s.enumerable});return i},c=t=>r.call(t,`module.exports`)?t[`module.exports`]:s(e({},`__esModule`,{value:!0}),t);function l(e){document.readyState===`complete`||document.readyState===`interactive`?setTimeout(e,1):document.addEventListener?document.addEventListener(`DOMContentLoaded`,e):document.attachEvent(`onreadystatechange`,()=>{document.readyState===`complete`&&e()})}function u(e,{strict:t=!0}={}){return!e||typeof e!=`string`?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith(`0x`)}function d(e){return u(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const f=`2.43.2`;let p={getDocsUrl:({docsBaseUrl:e,docsPath:t=``,docsSlug:n})=>t?`${e??`https://viem.sh`}${t}${n?`#${n}`:``}`:void 0,version:`viem@${f}`};var m=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=p.getDocsUrl?.({...n,docsPath:i}),o=[t||`An error occurred.`,``,...n.metaMessages?[...n.metaMessages,``]:[],...a?[`Docs: ${a}`]:[],...r?[`Details: ${r}`]:[],...p.version?[`Version: ${p.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=f}walk(e){return h(this,e)}};function h(e,t){return t?.(e)?e:e&&typeof e==`object`&&`cause`in e&&e.cause!==void 0?h(e.cause,t):t?null:e}var g=class extends m{constructor({expectedLength:e,givenLength:t,type:n}){super([`ABI encoding array length mismatch for type ${n}.`,`Expected length: ${e}`,`Given length: ${t}`].join(`
3
+ `),{name:`AbiEncodingArrayLengthMismatchError`})}},_=class extends m{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${d(t)}) does not match expected size (bytes${e}).`,{name:`AbiEncodingBytesSizeMismatchError`})}},v=class extends m{constructor({expectedLength:e,givenLength:t}){super([`ABI encoding params/values length mismatch.`,`Expected length (params): ${e}`,`Given length (values): ${t}`].join(`
4
+ `),{name:`AbiEncodingLengthMismatchError`})}},ee=class extends m{constructor(e,{docsPath:t}){super([`Type "${e}" is not a valid encoding type.`,`Please provide a valid ABI type.`].join(`
5
+ `),{docsPath:t,name:`InvalidAbiEncodingType`})}},te=class extends m{constructor(e){super([`Value "${e}" is not a valid array.`].join(`
6
+ `),{name:`InvalidArrayError`})}},ne=class extends m{constructor({offset:e,position:t,size:n}){super(`Slice ${t===`start`?`starting`:`ending`} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:`SliceOffsetOutOfBoundsError`})}},re=class extends m{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 y(e,{dir:t,size:n=32}={}){return typeof e==`string`?b(e,{dir:t,size:n}):ie(e,{dir:t,size:n})}function b(e,{dir:t,size:n=32}={}){if(n===null)return e;let r=e.replace(`0x`,``);if(r.length>n*2)throw new re({size:Math.ceil(r.length/2),targetSize:n,type:`hex`});return`0x${r[t===`right`?`padEnd`:`padStart`](n*2,`0`)}`}function ie(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new re({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 ae=class extends m{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 m{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:`SizeOverflowError`})}};function x(e,{size:t}){if(d(e)>t)throw new oe({givenSize:d(e),maxSize:t})}const se=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function S(e,t={}){return typeof e==`number`||typeof e==`bigint`?C(e,t):typeof e==`string`?de(e,t):typeof e==`boolean`?ce(e,t):le(e,t)}function ce(e,t={}){let n=`0x${Number(e)}`;return typeof t.size==`number`?(x(n,{size:t.size}),y(n,{size:t.size})):n}function le(e,t={}){let n=``;for(let t=0;t<e.length;t++)n+=se[e[t]];let r=`0x${n}`;return typeof t.size==`number`?(x(r,{size:t.size}),y(r,{dir:`right`,size:t.size})):r}function C(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 ae({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?y(s,{size:r}):s}const ue=new TextEncoder;function de(e,t={}){return le(ue.encode(e),t)}const fe=new TextEncoder;function pe(e,t={}){return typeof e==`number`||typeof e==`bigint`?_e(e,t):typeof e==`boolean`?me(e,t):u(e)?ge(e,t):ve(e,t)}function me(e,t={}){let n=new Uint8Array(1);return n[0]=Number(e),typeof t.size==`number`?(x(n,{size:t.size}),y(n,{size:t.size})):n}const w={zero:48,nine:57,A:65,F:70,a:97,f:102};function he(e){if(e>=w.zero&&e<=w.nine)return e-w.zero;if(e>=w.A&&e<=w.F)return e-(w.A-10);if(e>=w.a&&e<=w.f)return e-(w.a-10)}function ge(e,t={}){let n=e;t.size&&(x(n,{size:t.size}),n=y(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=he(r.charCodeAt(t++)),i=he(r.charCodeAt(t++));if(n===void 0||i===void 0)throw new m(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);a[e]=n*16+i}return a}function _e(e,t){return ge(C(e,t))}function ve(e,t={}){let n=fe.encode(e);return typeof t.size==`number`?(x(n,{size:t.size}),y(n,{dir:`right`,size:t.size})):n}const T=BigInt(2**32-1),ye=BigInt(32);function be(e,t=!1){return t?{h:Number(e&T),l:Number(e>>ye&T)}:{h:Number(e>>ye&T)|0,l:Number(e&T)|0}}function xe(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}=be(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}const Se=(e,t,n)=>e<<n|t>>>32-n,Ce=(e,t,n)=>t<<n|e>>>32-n,we=(e,t,n)=>t<<n-32|e>>>64-n,Te=(e,t,n)=>e<<n-32|t>>>64-n;function Ee(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function De(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function E(e,...t){if(!Ee(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 D(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 Oe(e,t){E(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function ke(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function O(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ae(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function k(e,t){return e<<32-t|e>>>t}const je=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function Me(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Ne(e){for(let t=0;t<e.length;t++)e[t]=Me(e[t]);return e}const Pe=je?e=>e:Ne;function Fe(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function Ie(e){return typeof e==`string`&&(e=Fe(e)),E(e),e}var Le=class{};function Re(e){let t=t=>e().update(Ie(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const ze=BigInt(0),A=BigInt(1),Be=BigInt(2),Ve=BigInt(7),He=BigInt(256),Ue=BigInt(113),We=[],Ge=[],Ke=[];for(let e=0,t=A,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],We.push(2*(5*r+n)),Ge.push((e+1)*(e+2)/2%64);let i=ze;for(let e=0;e<7;e++)t=(t<<A^(t>>Ve)*Ue)%He,t&Be&&(i^=A<<(A<<BigInt(e))-A);Ke.push(i)}const qe=xe(Ke,!0),Je=qe[0],Ye=qe[1],Xe=(e,t,n)=>n>32?we(e,t,n):Se(e,t,n),Ze=(e,t,n)=>n>32?Te(e,t,n):Ce(e,t,n);function Qe(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=Xe(a,o,1)^n[r],c=Ze(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=Ge[n],a=Xe(t,i,r),o=Ze(t,i,r),s=We[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]^=Je[r],e[1]^=Ye[r]}O(n)}var $e=class e extends Le{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,De(n),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=ke(this.state)}clone(){return this._cloneInto()}keccak(){Pe(this.state32),Qe(this.state32,this.rounds),Pe(this.state32),this.posOut=0,this.pos=0}update(e){D(this),e=Ie(e),E(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){D(this,!1),E(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 De(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Oe(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,O(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 et=(e,t,n)=>Re(()=>new $e(t,e,n)),tt=(()=>et(1,136,256/8))();function nt(e,t){let n=t||`hex`,r=tt(u(e,{strict:!1})?pe(e):e);return n===`bytes`?r:S(r)}var rt=class extends m{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`})}},it=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 at=new it(8192);function ot(e,t){if(at.has(`${e}.${t}`))return at.get(`${e}.${t}`);let n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=nt(ve(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 at.set(`${e}.${t}`,a),a}const st=/^0x[a-fA-F0-9]{40}$/,ct=new it(8192);function lt(e,t){let{strict:n=!0}=t??{},r=`${e}.${n}`;if(ct.has(r))return ct.get(r);let i=(()=>st.test(e)?e.toLowerCase()===e?!0:n?ot(e)===e:!0:!1)();return ct.set(r,i),i}function j(e){return typeof e[0]==`string`?M(e):ut(e)}function ut(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function M(e){return`0x${e.reduce((e,t)=>e+t.replace(`0x`,``),``)}`}function dt(e,t,n,{strict:r}={}){return u(e,{strict:!1})?ht(e,t,n,{strict:r}):mt(e,t,n,{strict:r})}function ft(e,t){if(typeof t==`number`&&t>0&&t>d(e)-1)throw new ne({offset:t,position:`start`,size:d(e)})}function pt(e,t,n){if(typeof t==`number`&&typeof n==`number`&&d(e)!==n-t)throw new ne({offset:n,position:`end`,size:d(e)})}function mt(e,t,n,{strict:r}={}){ft(e,t);let i=e.slice(t,n);return r&&pt(i,t,n),i}function ht(e,t,n,{strict:r}={}){ft(e,t);let i=`0x${e.replace(`0x`,``).slice((t??0)*2,(n??e.length)*2)}`;return r&&pt(i,t,n),i}const gt=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function _t(e,t){if(e.length!==t.length)throw new v({expectedLength:e.length,givenLength:t.length});let n=bt(vt({params:e,values:t}));return n.length===0?`0x`:n}function vt({params:e,values:t}){let n=[];for(let r=0;r<e.length;r++)n.push(yt({param:e[r],value:t[r]}));return n}function yt({param:e,value:t}){let n=Ot(e.type);if(n){let[r,i]=n;return St(t,{length:r,param:{...e,type:i}})}if(e.type===`tuple`)return Dt(t,{param:e});if(e.type===`address`)return xt(t);if(e.type===`bool`)return wt(t);if(e.type.startsWith(`uint`)||e.type.startsWith(`int`)){let n=e.type.startsWith(`int`),[,,r=`256`]=gt.exec(e.type)??[];return Tt(t,{signed:n,size:Number(r)})}if(e.type.startsWith(`bytes`))return Ct(t,{param:e});if(e.type===`string`)return Et(t);throw new ee(e.type,{docsPath:`/docs/contract/encodeAbiParameters`})}function bt(e){let t=0;for(let n=0;n<e.length;n++){let{dynamic:r,encoded:i}=e[n];r?t+=32:t+=d(i)}let n=[],r=[],i=0;for(let a=0;a<e.length;a++){let{dynamic:o,encoded:s}=e[a];o?(n.push(C(t+i,{size:32})),r.push(s),i+=d(s)):n.push(s)}return j([...n,...r])}function xt(e){if(!lt(e))throw new rt({address:e});return{dynamic:!1,encoded:b(e.toLowerCase())}}function St(e,{length:t,param:n}){let r=t===null;if(!Array.isArray(e))throw new te(e);if(!r&&e.length!==t)throw new g({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let i=!1,a=[];for(let t=0;t<e.length;t++){let r=yt({param:n,value:e[t]});r.dynamic&&(i=!0),a.push(r)}if(r||i){let e=bt(a);if(r){let t=C(a.length,{size:32});return{dynamic:!0,encoded:a.length>0?j([t,e]):t}}if(i)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:j(a.map(({encoded:e})=>e))}}function Ct(e,{param:t}){let[,n]=t.type.split(`bytes`),r=d(e);if(!n){let t=e;return r%32!=0&&(t=b(t,{dir:`right`,size:Math.ceil((e.length-2)/2/32)*32})),{dynamic:!0,encoded:j([b(C(r,{size:32})),t])}}if(r!==Number.parseInt(n,10))throw new _({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:b(e,{dir:`right`})}}function wt(e){if(typeof e!=`boolean`)throw new m(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:b(ce(e))}}function Tt(e,{signed:t,size:n=256}){if(typeof n==`number`){let r=2n**(BigInt(n)-(t?1n:0n))-1n,i=t?-r-1n:0n;if(e>r||e<i)throw new ae({max:r.toString(),min:i.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:C(e,{size:32,signed:t})}}function Et(e){let t=de(e),n=Math.ceil(d(t)/32),r=[];for(let e=0;e<n;e++)r.push(b(dt(t,e*32,(e+1)*32),{dir:`right`}));return{dynamic:!0,encoded:j([b(C(d(t),{size:32})),...r])}}function Dt(e,{param:t}){let n=!1,r=[];for(let i=0;i<t.components.length;i++){let a=t.components[i],o=yt({param:a,value:e[Array.isArray(e)?i:a.name]});r.push(o),o.dynamic&&(n=!0)}return{dynamic:n,encoded:n?bt(r):j(r.map(({encoded:e})=>e))}}function Ot(e){let t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function kt(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function At(e,t,n){return e&t^~e&n}function jt(e,t,n){return e&t^e&n^t&n}var Mt=class extends Le{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Ae(this.buffer)}update(e){D(this),e=Ie(e),E(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=Ae(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){D(this),Oe(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,O(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;kt(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=Ae(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}};const N=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Nt=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),P=new Uint32Array(64);var Pt=class extends Mt{constructor(e=32){super(64,e,8,!1),this.A=N[0]|0,this.B=N[1]|0,this.C=N[2]|0,this.D=N[3]|0,this.E=N[4]|0,this.F=N[5]|0,this.G=N[6]|0,this.H=N[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)P[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=P[e-15],n=P[e-2],r=k(t,7)^k(t,18)^t>>>3;P[e]=(k(n,17)^k(n,19)^n>>>10)+P[e-7]+r+P[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=k(o,6)^k(o,11)^k(o,25),u=l+t+At(o,s,c)+Nt[e]+P[e]|0,d=(k(n,2)^k(n,13)^k(n,22))+jt(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){O(P)}destroy(){this.set(0,0,0,0,0,0,0,0),O(this.buffer)}};const Ft=Re(()=>new Pt);function It(e,t){let n=t||`hex`,r=Ft(u(e,{strict:!1})?pe(e):e);return n===`bytes`?r:S(r)}function Lt(e,t){if(!lt(e,{strict:!1}))throw new rt({address:e});if(!lt(t,{strict:!1}))throw new rt({address:t});return e.toLowerCase()===t.toLowerCase()}let Rt=256,F;function zt(e=11){if(!F||Rt+e>256*2){F=``,Rt=0;for(let e=0;e<256;e++)F+=(256+Math.random()*256|0).toString(16).substring(1)}return F.substring(Rt,Rt+++e)}var I=o({__addDisposableResource:()=>fn,__assign:()=>B,__asyncDelegator:()=>rn,__asyncGenerator:()=>nn,__asyncValues:()=>an,__await:()=>R,__awaiter:()=>Yt,__classPrivateFieldGet:()=>ln,__classPrivateFieldIn:()=>dn,__classPrivateFieldSet:()=>un,__createBinding:()=>V,__decorate:()=>Ht,__disposeResources:()=>pn,__esDecorate:()=>Wt,__exportStar:()=>Zt,__extends:()=>Bt,__generator:()=>Xt,__importDefault:()=>cn,__importStar:()=>sn,__makeTemplateObject:()=>on,__metadata:()=>Jt,__param:()=>Ut,__propKey:()=>Kt,__read:()=>Qt,__rest:()=>Vt,__rewriteRelativeImportExtension:()=>mn,__runInitializers:()=>Gt,__setFunctionName:()=>qt,__spread:()=>$t,__spreadArray:()=>tn,__spreadArrays:()=>en,__values:()=>L,default:()=>_n});function Bt(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);z(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Vt(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Ht(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function Ut(e,t){return function(n,r){t(n,r,e)}}function Wt(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else (d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0}function Gt(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0}function Kt(e){return typeof e==`symbol`?e:`${e}`}function qt(e,t,n){return typeof t==`symbol`&&(t=t.description?`[${t.description}]`:``),Object.defineProperty(e,`name`,{configurable:!0,value:n?`${n} ${t}`:t})}function Jt(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function Yt(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function Xt(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function Zt(e,t){for(var n in e)n!==`default`&&!Object.prototype.hasOwnProperty.call(t,n)&&V(t,e,n)}function L(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function Qt(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function $t(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Qt(arguments[t]));return e}function en(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function tn(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function R(e){return this instanceof R?(this.v=e,this):new R(e)}function nn(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof R?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function rn(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:R(e[r](t)),done:!1}:i?i(t):t}:i}}function an(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof L==`function`?L(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function on(e,t){return Object.defineProperty?Object.defineProperty(e,`raw`,{value:t}):e.raw=t,e}function sn(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=H(e),r=0;r<n.length;r++)n[r]!==`default`&&V(t,e,n[r]);return hn(t,e),t}function cn(e){return e&&e.__esModule?e:{default:e}}function ln(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function un(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function dn(e,t){if(t===null||typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Cannot use 'in' operator on non-object`);return typeof e==`function`?t===e:e.has(t)}function fn(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}function pn(e){function t(t){e.error=e.hasError?new gn(t,e.error,`An error was suppressed during disposal.`):t,e.hasError=!0}var n,r=0;function i(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(i);if(n.dispose){var a=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(a).then(i,function(e){return t(e),i()})}else r|=1}catch(e){t(e)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return i()}function mn(e,t){return typeof e==`string`&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,n,r,i,a){return n?t?`.jsx`:`.js`:r&&(!i||!a)?e:r+i+`.`+a.toLowerCase()+`js`}):e}var z,B,V,hn,H,gn,_n,U=i((()=>{z=function(e,t){return z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},z(e,t)},B=function(){return B=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},B.apply(this,arguments)},V=Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),hn=Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t},H=function(e){return H=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},H(e)},gn=typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r},_n={__extends:Bt,__assign:B,__rest:Vt,__decorate:Ht,__param:Ut,__esDecorate:Wt,__runInitializers:Gt,__propKey:Kt,__setFunctionName:qt,__metadata:Jt,__awaiter:Yt,__generator:Xt,__createBinding:V,__exportStar:Zt,__values:L,__read:Qt,__spread:$t,__spreadArrays:en,__spreadArray:tn,__await:R,__asyncGenerator:nn,__asyncDelegator:rn,__asyncValues:an,__makeTemplateObject:on,__importStar:sn,__importDefault:cn,__classPrivateFieldGet:ln,__classPrivateFieldSet:un,__classPrivateFieldIn:dn,__addDisposableResource:fn,__disposeResources:pn,__rewriteRelativeImportExtension:mn}})),vn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),yn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Slice=void 0,e.Slice=class{constructor(e,t,n,r){this.uint8=e,this.view=t,this.start=n,this.end=r}subarray(){return this.uint8.subarray(this.start,this.end)}}})),bn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Writer=void 0;let t=yn(),n=new Uint8Array([]),r=new DataView(n.buffer),i=typeof Buffer==`function`,a=i?Buffer.prototype.utf8Write:null,o=i?Buffer.from:null,s=typeof TextEncoder<`u`?new TextEncoder:null;e.Writer=class{constructor(e=64*1024){this.allocSize=e,this.view=r,this.x0=0,this.x=0,this.uint8=new Uint8Array(e),this.size=e,this.view=new DataView(this.uint8.buffer)}grow(e){let t=this.x0,n=this.x,r=this.uint8,i=new Uint8Array(e),a=new DataView(i.buffer),o=r.subarray(t,n);i.set(o,0),this.x=n-t,this.x0=0,this.uint8=i,this.size=e,this.view=a}ensureCapacity(e){let t=this.size,n=t-this.x;if(n<e){let r=t-this.x0+(e-n);this.grow(r<=this.allocSize?this.allocSize:r*2)}}move(e){this.ensureCapacity(e),this.x+=e}reset(){this.x0=this.x}newBuffer(e){let t=this.uint8=new Uint8Array(e);this.size=e,this.view=new DataView(t.buffer),this.x=this.x0=0}flush(){let e=this.uint8.subarray(this.x0,this.x);return this.x0=this.x,e}flushSlice(){let e=new t.Slice(this.uint8,this.view,this.x0,this.x);return this.x0=this.x,e}u8(e){this.ensureCapacity(1),this.uint8[this.x++]=e}u16(e){this.ensureCapacity(2),this.view.setUint16(this.x,e),this.x+=2}u32(e){this.ensureCapacity(4),this.view.setUint32(this.x,e),this.x+=4}i32(e){this.ensureCapacity(4),this.view.setInt32(this.x,e),this.x+=4}u64(e){this.ensureCapacity(8),this.view.setBigUint64(this.x,BigInt(e)),this.x+=8}f64(e){this.ensureCapacity(8),this.view.setFloat64(this.x,e),this.x+=8}u8u16(e,t){this.ensureCapacity(3);let n=this.x;this.uint8[n++]=e,this.uint8[n++]=t>>>8,this.uint8[n++]=t&255,this.x=n}u8u32(e,t){this.ensureCapacity(5);let n=this.x;this.uint8[n++]=e,this.view.setUint32(n,t),this.x=n+4}u8u64(e,t){this.ensureCapacity(9);let n=this.x;this.uint8[n++]=e,this.view.setBigUint64(n,BigInt(t)),this.x=n+8}u8f32(e,t){this.ensureCapacity(5);let n=this.x;this.uint8[n++]=e,this.view.setFloat32(n,t),this.x=n+4}u8f64(e,t){this.ensureCapacity(9);let n=this.x;this.uint8[n++]=e,this.view.setFloat64(n,t),this.x=n+8}buf(e,t){this.ensureCapacity(t);let n=this.x;this.uint8.set(e,n),this.x=n+t}utf8(e){let t=e.length*4;if(t<168)return this.utf8Native(e);if(a){let n=a.call(this.uint8,e,this.x,t);return this.x+=n,n}else if(o){let n=this.uint8,r=n.byteOffset+this.x,i=o(n.buffer).subarray(r,r+t).write(e,0,t,`utf8`);return this.x+=i,i}else if(t>1024&&s){let n=s.encodeInto(e,this.uint8.subarray(this.x,this.x+t)).written;return this.x+=n,n}return this.utf8Native(e)}utf8Native(e){let t=e.length,n=this.uint8,r=this.x,i=0;for(;i<t;){let a=e.charCodeAt(i++);if(a&4294967168)if(!(a&4294965248))n[r++]=a>>6&31|192;else{if(a>=55296&&a<=56319&&i<t){let t=e.charCodeAt(i);(t&64512)==56320&&(i++,a=((a&1023)<<10)+(t&1023)+65536)}a&4294901760?(n[r++]=a>>18&7|240,n[r++]=a>>12&63|128,n[r++]=a>>6&63|128):(n[r++]=a>>12&15|224,n[r++]=a>>6&63|128)}else{n[r++]=a;continue}n[r++]=a&63|128}let a=r-this.x;return this.x=r,a}ascii(e){let t=e.length;this.ensureCapacity(t);let n=this.uint8,r=this.x,i=0;for(;i<t;)n[r++]=e.charCodeAt(i++);this.x=r}}})),xn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CborEncoderFast=void 0;let t=bn(),n=Number.isSafeInteger;e.CborEncoderFast=class{constructor(e=new t.Writer){this.writer=e}encode(e){return this.writeAny(e),this.writer.flush()}encodeToSlice(e){return this.writeAny(e),this.writer.flushSlice()}writeAny(e){switch(typeof e){case`number`:return this.writeNumber(e);case`string`:return this.writeStr(e);case`boolean`:return this.writer.u8(244+ +e);case`object`:if(!e)return this.writer.u8(246);switch(e.constructor){case Array:return this.writeArr(e);default:return this.writeObj(e)}}}writeCbor(){this.writer.u8u16(217,55799)}writeEnd(){this.writer.u8(255)}writeNull(){this.writer.u8(246)}writeBoolean(e){e?this.writer.u8(245):this.writer.u8(244)}writeNumber(e){n(e)?this.writeInteger(e):typeof e==`bigint`?this.writeBigInt(e):this.writeFloat(e)}writeBigInt(e){e>=0?this.writeBigUint(e):this.writeBigSint(e)}writeBigUint(e){if(e<=2**53-1)return this.writeUInteger(Number(e));this.writer.u8u64(27,e)}writeBigSint(e){if(e>=-(2**53-1))return this.encodeNint(Number(e));let t=-BigInt(1)-e;this.writer.u8u64(59,t)}writeInteger(e){e>=0?this.writeUInteger(e):this.encodeNint(e)}writeUInteger(e){let t=this.writer;t.ensureCapacity(9);let n=t.uint8,r=t.x;e<=23?n[r++]=0+e:e<=255?(n[r++]=24,n[r++]=e):e<=65535?(n[r++]=25,t.view.setUint16(r,e),r+=2):e<=4294967295?(n[r++]=26,t.view.setUint32(r,e),r+=4):(n[r++]=27,t.view.setBigUint64(r,BigInt(e)),r+=8),t.x=r}encodeNumber(e){this.writeNumber(e)}encodeInteger(e){this.writeInteger(e)}encodeUint(e){this.writeUInteger(e)}encodeNint(e){let t=-1-e,n=this.writer;n.ensureCapacity(9);let r=n.uint8,i=n.x;t<24?r[i++]=32+t:t<=255?(r[i++]=56,r[i++]=t):t<=65535?(r[i++]=57,n.view.setUint16(i,t),i+=2):t<=4294967295?(r[i++]=58,n.view.setUint32(i,t),i+=4):(r[i++]=59,n.view.setBigUint64(i,BigInt(t)),i+=8),n.x=i}writeFloat(e){this.writer.u8f64(251,e)}writeBin(e){let t=e.length;this.writeBinHdr(t),this.writer.buf(e,t)}writeBinHdr(e){let t=this.writer;e<=23?t.u8(64+e):e<=255?t.u16(22528+e):e<=65535?t.u8u16(89,e):e<=4294967295?t.u8u32(90,e):t.u8u64(91,e)}writeStr(e){let t=this.writer,n=e.length*4;t.ensureCapacity(5+n);let r=t.uint8,i=t.x;n<=23?t.x++:n<=255?(r[t.x++]=120,i=t.x,t.x++):n<=65535?(r[t.x++]=121,i=t.x,t.x+=2):(r[t.x++]=122,i=t.x,t.x+=4);let a=t.utf8(e);n<=23?r[i]=96+a:n<=255?r[i]=a:n<=65535?t.view.setUint16(i,a):t.view.setUint32(i,a)}writeStrHdr(e){let t=this.writer;e<=23?t.u8(96+e):e<=255?t.u16(30720+e):e<=65535?t.u8u16(121,e):t.u8u32(122,e)}writeAsciiStr(e){this.writeStrHdr(e.length),this.writer.ascii(e)}writeArr(e){let t=e.length;this.writeArrHdr(t);for(let n=0;n<t;n++)this.writeAny(e[n])}writeArrHdr(e){let t=this.writer;e<=23?t.u8(128+e):e<=255?t.u16(38912+e):e<=65535?t.u8u16(153,e):e<=4294967295?t.u8u32(154,e):t.u8u64(155,e)}writeObj(e){let t=Object.keys(e),n=t.length;this.writeObjHdr(n);for(let r=0;r<n;r++){let n=t[r];this.writeStr(n),this.writeAny(e[n])}}writeObjHdr(e){let t=this.writer;e<=23?t.u8(160+e):e<=255?t.u16(47104+e):e<=65535?t.u8u16(185,e):e<=4294967295?t.u8u32(186,e):t.u8u64(187,e)}writeMapHdr(e){this.writeObjHdr(e)}writeStartMap(){this.writer.u8(191)}writeTag(e,t){this.writeTagHdr(e),this.writeAny(t)}writeTagHdr(e){let t=this.writer;e<=23?t.u8(192+e):e<=255?t.u16(55296+e):e<=65535?t.u8u16(217,e):e<=4294967295?t.u8u32(218,e):t.u8u64(219,e)}writeTkn(e){let t=this.writer;e<=23?t.u8(224+e):e<=255&&t.u16(63488+e)}writeStartStr(){this.writer.u8(127)}writeStrChunk(e){throw Error(`Not implemented`)}writeEndStr(){throw Error(`Not implemented`)}writeStartBin(){this.writer.u8(95)}writeBinChunk(e){throw Error(`Not implemented`)}writeEndBin(){throw Error(`Not implemented`)}writeStartArr(){this.writer.u8(159)}writeArrChunk(e){throw Error(`Not implemented`)}writeEndArr(){this.writer.u8(255)}writeStartObj(){this.writer.u8(191)}writeObjChunk(e,t){throw Error(`Not implemented`)}writeEndObj(){this.writer.u8(255)}}})),Sn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isFloat32=void 0;let t=new DataView(new ArrayBuffer(4));e.isFloat32=e=>(t.setFloat32(0,e),e===t.getFloat32(0))})),Cn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.JsonPackExtension=void 0,e.JsonPackExtension=class{constructor(e,t){this.tag=e,this.val=t}}})),wn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.JsonPackValue=void 0,e.JsonPackValue=class{constructor(e){this.val=e}}})),Tn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CborEncoder=void 0;let t=Sn(),n=Cn(),r=xn(),i=wn();e.CborEncoder=class extends r.CborEncoderFast{writeUnknown(e){this.writeNull()}writeAny(e){switch(typeof e){case`number`:return this.writeNumber(e);case`string`:return this.writeStr(e);case`boolean`:return this.writer.u8(244+ +e);case`object`:if(!e)return this.writer.u8(246);switch(e.constructor){case Object:return this.writeObj(e);case Array:return this.writeArr(e);case Uint8Array:return this.writeBin(e);case Map:return this.writeMap(e);case n.JsonPackExtension:return this.writeTag(e.tag,e.val);case i.JsonPackValue:let t=e.val;return this.writer.buf(t,t.length);default:return e instanceof Uint8Array?this.writeBin(e):Array.isArray(e)?this.writeArr(e):e instanceof Map?this.writeMap(e):this.writeUnknown(e)}case`undefined`:return this.writeUndef();case`bigint`:return this.writeBigInt(e);default:return this.writeUnknown(e)}}writeFloat(e){(0,t.isFloat32)(e)?this.writer.u8f32(250,e):this.writer.u8f64(251,e)}writeMap(e){this.writeMapHdr(e.size),e.forEach((e,t)=>{this.writeAny(t),this.writeAny(e)})}writeUndef(){this.writer.u8(247)}}})),En=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.sort=void 0,e.sort=(e,t)=>{let n=e.length;for(let r=1;r<n;r++){let n=e[r],i=r;for(;i!==0&&t(e[i-1],n)>0;)e[i]=e[i-1],i--;e[i]=n}return e}})),Dn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.objKeyCmp=void 0,e.objKeyCmp=(e,t)=>{let n=e.length,r=t.length;return n===r?e>t?1:-1:n-r}})),On=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CborEncoderStable=void 0;let t=Tn(),n=En(),r=Dn(),i=e=>e<=23?1:e<=255?2:e<=65535?3:5;e.CborEncoderStable=class extends t.CborEncoder{writeObj(e){let t=Object.keys(e);(0,n.sort)(t,r.objKeyCmp);let i=t.length;this.writeObjHdr(i);for(let n=0;n<i;n++){let r=t[n];this.writeStr(r),this.writeAny(e[r])}}writeStr(e){let t=this.writer,n=e.length,r=n*4;t.ensureCapacity(5+r);let a=i(n),o=t.x,s=o+a;t.x=s;let c=t.utf8(e),l=t.uint8,u=i(c);if(u!==a){let e=u-a;l.copyWithin(s+e,s,s+c)}switch(u){case 1:l[o]=96+c;break;case 2:l[o]=120,l[o+1]=c;break;case 3:l[o]=121,t.view.setUint16(o+1,c);break;case 5:l[o]=122,t.view.setUint32(o+1,c);break}t.x=o+u+c}writeUndef(){this.writeNull()}}})),kn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CborEncoderDag=void 0;let t=On();e.CborEncoderDag=class extends t.CborEncoderStable{writeUndef(){this.writeNull()}writeFloat(e){if(e!==e||!Number.isFinite(e))return this.writeNull();this.writer.u8f64(251,e)}writeTag(e,t){e===42&&this.writeTagHdr(e),this.writeAny(t)}}})),An=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.decodeF16=void 0;let t=Math.pow;e.decodeF16=e=>{let n=(e&31744)>>10,r=e&1023;return(e>>15?-1:1)*(n?n===31?r?NaN:1/0:t(2,n-15)*(1+r/1024):r/1024*6103515625e-14)}})),jn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.decodeAsciiMax15=e.decodeAscii=void 0;let t=String.fromCharCode;e.decodeAscii=(e,n,r)=>{let i=[];for(let t=0;t<r;t++){let t=e[n++];if(t&128)return;i.push(t)}return t.apply(String,i)},e.decodeAsciiMax15=(e,n,r)=>{if(r<4)if(r<2){if(r===0)return``;{let r=e[n++];if((r&128)>1){--n;return}return t(r)}}else{let i=e[n++],a=e[n++];if((i&128)>0||(a&128)>0){n-=2;return}if(r<3)return t(i,a);let o=e[n++];if((o&128)>0){n-=3;return}return t(i,a,o)}else{let i=e[n++],a=e[n++],o=e[n++],s=e[n++];if((i&128)>0||(a&128)>0||(o&128)>0||(s&128)>0){n-=4;return}if(r<6){if(r===4)return t(i,a,o,s);{let r=e[n++];if((r&128)>0){n-=5;return}return t(i,a,o,s,r)}}else if(r<8){let c=e[n++],l=e[n++];if((c&128)>0||(l&128)>0){n-=6;return}if(r<7)return t(i,a,o,s,c,l);let u=e[n++];if((u&128)>0){n-=7;return}return t(i,a,o,s,c,l,u)}else{let c=e[n++],l=e[n++],u=e[n++],d=e[n++];if((c&128)>0||(l&128)>0||(u&128)>0||(d&128)>0){n-=8;return}if(r<10){if(r===8)return t(i,a,o,s,c,l,u,d);{let r=e[n++];if((r&128)>0){n-=9;return}return t(i,a,o,s,c,l,u,d,r)}}else if(r<12){let f=e[n++],p=e[n++];if((f&128)>0||(p&128)>0){n-=10;return}if(r<11)return t(i,a,o,s,c,l,u,d,f,p);let m=e[n++];if((m&128)>0){n-=11;return}return t(i,a,o,s,c,l,u,d,f,p,m)}else{let f=e[n++],p=e[n++],m=e[n++],h=e[n++];if((f&128)>0||(p&128)>0||(m&128)>0||(h&128)>0){n-=12;return}if(r<14){if(r===12)return t(i,a,o,s,c,l,u,d,f,p,m,h);{let r=e[n++];if((r&128)>0){n-=13;return}return t(i,a,o,s,c,l,u,d,f,p,m,h,r)}}else{let g=e[n++],_=e[n++];if((g&128)>0||(_&128)>0){n-=14;return}if(r<15)return t(i,a,o,s,c,l,u,d,f,p,m,h,g,_);let v=e[n++];if((v&128)>0){n-=15;return}return t(i,a,o,s,c,l,u,d,f,p,m,h,g,_,v)}}}}}})),Mn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=String.fromCharCode;e.default=(e,n,r)=>{let i=n,a=i+r,o=[];for(;i<a;){let t=e[i++];if(t&128){let n=e[i++]&63;if((t&224)==192)t=(t&31)<<6|n;else{let r=e[i++]&63;if((t&240)==224)t=(t&31)<<12|n<<6|r;else if((t&248)==240){let a=e[i++]&63,s=(t&7)<<18|n<<12|r<<6|a;if(s>65535){s-=65536;let e=s>>>10&1023|55296;t=56320|s&1023,o.push(e)}else t=s}}}o.push(t)}return t.apply(String,o)}})),Nn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(U(),c(I)),n=jn(),r=t.__importDefault(Mn()),i=typeof Buffer<`u`,a=i?Buffer.prototype.utf8Slice:null,o=i?Buffer.from:null,s=(e,t,i)=>(0,n.decodeAsciiMax15)(e,t,i)??(0,r.default)(e,t,i),l=(e,t,i)=>(0,n.decodeAscii)(e,t,i)??(0,r.default)(e,t,i),u=a?(e,t,n)=>a.call(e,t,t+n):o?(e,t,n)=>o(e).subarray(t,t+n).toString(`utf8`):r.default;e.default=(e,t,n)=>n<16?s(e,t,n):n<32?l(e,t,n):u(e,t,n)})),Pn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.decodeUtf8=void 0,e.decodeUtf8=(U(),c(I)).__importDefault(Nn()).default})),Fn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Reader=void 0;let t=Pn();e.Reader=class e{constructor(e=new Uint8Array([]),t=new DataView(e.buffer,e.byteOffset,e.length),n=0,r=e.length){this.uint8=e,this.view=t,this.x=n,this.end=r}reset(e){this.x=0,this.uint8=e,this.view=new DataView(e.buffer,e.byteOffset,e.length)}size(){return this.end-this.x}peek(){return this.view.getUint8(this.x)}peak(){return this.peek()}skip(e){this.x+=e}buf(e=this.size()){let t=this.x,n=t+e,r=this.uint8.subarray(t,n);return this.x=n,r}subarray(e=0,t){let n=this.x,r=n+e,i=typeof t==`number`?n+t:this.end;return this.uint8.subarray(r,i)}slice(t=0,n){let r=this.x,i=r+t,a=typeof n==`number`?r+n:this.end;return new e(this.uint8,this.view,i,a)}cut(e=this.size()){let t=this.slice(0,e);return this.skip(e),t}u8(){return this.uint8[this.x++]}i8(){return this.view.getInt8(this.x++)}u16(){let e=this.x,t=(this.uint8[e++]<<8)+this.uint8[e++];return this.x=e,t}i16(){let e=this.view.getInt16(this.x);return this.x+=2,e}u32(){let e=this.view.getUint32(this.x);return this.x+=4,e}i32(){let e=this.view.getInt32(this.x);return this.x+=4,e}u64(){let e=this.view.getBigUint64(this.x);return this.x+=8,e}i64(){let e=this.view.getBigInt64(this.x);return this.x+=8,e}f32(){let e=this.x;return this.x+=4,this.view.getFloat32(e)}f64(){let e=this.x;return this.x+=8,this.view.getFloat64(e)}utf8(e){let n=this.x;return this.x+=e,(0,t.decodeUtf8)(this.uint8,n,e)}ascii(e){let t=this.uint8,n=``,r=this.x+e;for(let e=this.x;e<r;e++)n+=String.fromCharCode(t[e]);return this.x=r,n}}})),In=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=String.fromCharCode;e.default=(e,n,r)=>{let i=n,a=i+r,o=``;for(;i<a;){let n=e[i++];if(!(n&128)){o+=t(n);continue}let r=e[i++]&63;if((n&224)==192){o+=t((n&31)<<6|r);continue}let a=e[i++]&63;if((n&240)==224){o+=t((n&31)<<12|r<<6|a);continue}if((n&248)==240){let s=e[i++]&63,c=(n&7)<<18|r<<12|a<<6|s;if(c>65535){c-=65536;let e=c>>>10&1023|55296;c=56320|c&1023,o+=t(e,c)}else o+=t(c)}else o+=t(n)}return o}})),Ln=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CachedUtf8Decoder=void 0;let t=(U(),c(I)).__importDefault(In()),n=1+Math.round(Math.random()*((-1>>>0)-1));function r(e,t){return n^=n<<13,n^=n>>>17,n^=n<<5,(n>>>0)%(t-e+1)+e}var i=class{constructor(e,t){this.bytes=e,this.value=t}};e.CachedUtf8Decoder=class{constructor(){this.caches=[];for(let e=0;e<31;e++)this.caches.push([])}get(e,t,n){let r=this.caches[n-1],i=r.length;FIND_CHUNK:for(let a=0;a<i;a++){let i=r[a],o=i.bytes;for(let r=0;r<n;r++)if(o[r]!==e[t+r])continue FIND_CHUNK;return i.value}return null}store(e,t){let n=this.caches[e.length-1],a=new i(e,t);n.length>=16?n[r(0,15)]=a:n.push(a)}decode(e,n,r){if(!r)return``;let i=this.get(e,n,r);if(i!==null)return i;let a=(0,t.default)(e,n,r),o=Uint8Array.prototype.slice.call(e,n,n+r);return this.store(o,a),a}}})),Rn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=new(Ln()).CachedUtf8Decoder})),zn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CborDecoderBase=void 0;let t=(U(),c(I)),n=An(),r=Cn(),i=wn(),a=Fn(),o=t.__importDefault(Rn());e.CborDecoderBase=class{constructor(e=new a.Reader,t=o.default){this.reader=e,this.keyDecoder=t}read(e){return this.reader.reset(e),this.readAny()}decode(e){return this.reader.reset(e),this.readAny()}val(){return this.readAny()}readAny(){let e=this.reader.u8(),t=e>>5,n=e&31;return t<4?t<2?t===0?this.readUint(n):this.readNint(n):t===2?this.readBin(n):this.readStr(n):t<6?t===4?this.readArr(n):this.readObj(n):t===6?this.readTag(n):this.readTkn(n)}readAnyRaw(e){let t=e>>5,n=e&31;return t<4?t<2?t===0?this.readUint(n):this.readNint(n):t===2?this.readBin(n):this.readStr(n):t<6?t===4?this.readArr(n):this.readObj(n):t===6?this.readTag(n):this.readTkn(n)}readMinorLen(e){if(e<24)return e;switch(e){case 24:return this.reader.u8();case 25:return this.reader.u16();case 26:return this.reader.u32();case 27:return Number(this.reader.u64());case 31:return-1;default:throw 1}}readUint(e){if(e<25)return e===24?this.reader.u8():e;if(e<27)return e===25?this.reader.u16():this.reader.u32();{let e=this.reader.u64();return e>9007199254740991?e:Number(e)}}readNint(e){if(e<25)return e===24?-this.reader.u8()-1:-e-1;if(e<27)return e===25?-this.reader.u16()-1:-this.reader.u32()-1;{let e=this.reader.u64();return e>9007199254740990?-e-BigInt(1):-Number(e)-1}}readBin(e){let t=this.reader;if(e<=23)return t.buf(e);switch(e){case 24:return t.buf(t.u8());case 25:return t.buf(t.u16());case 26:return t.buf(t.u32());case 27:return t.buf(Number(t.u64()));case 31:{let e=0,t=[];for(;this.reader.peak()!==255;){let n=this.readBinChunk();e+=n.length,t.push(n)}this.reader.x++;let n=new Uint8Array(e),r=0,i=t.length;for(let e=0;e<i;e++){let i=t[e];n.set(i,r),r+=i.length}return n}default:throw 1}}readBinChunk(){let e=this.reader.u8(),t=e>>5,n=e&31;if(t!==2)throw 2;if(n>27)throw 3;return this.readBin(n)}readAsStr(){let e=this.reader.u8(),t=e>>5,n=e&31;if(t!==3)throw 11;return this.readStr(n)}readStr(e){let t=this.reader;if(e<=23)return t.utf8(e);switch(e){case 24:return t.utf8(t.u8());case 25:return t.utf8(t.u16());case 26:return t.utf8(t.u32());case 27:return t.utf8(Number(t.u64()));case 31:{let e=``;for(;t.peak()!==255;)e+=this.readStrChunk();return this.reader.x++,e}default:throw 1}}readStrLen(e){if(e<=23)return e;switch(e){case 24:return this.reader.u8();case 25:return this.reader.u16();case 26:return this.reader.u32();case 27:return Number(this.reader.u64());default:throw 1}}readStrChunk(){let e=this.reader.u8(),t=e>>5,n=e&31;if(t!==3)throw 4;if(n>27)throw 5;return this.readStr(n)}readArr(e){let t=this.readMinorLen(e);return t>=0?this.readArrRaw(t):this.readArrIndef()}readArrRaw(e){let t=[];for(let n=0;n<e;n++)t.push(this.readAny());return t}readArrIndef(){let e=[];for(;this.reader.peak()!==255;)e.push(this.readAny());return this.reader.x++,e}readObj(e){if(e<28){let t=e;switch(e){case 24:t=this.reader.u8();break;case 25:t=this.reader.u16();break;case 26:t=this.reader.u32();break;case 27:t=Number(this.reader.u64());break}let n={};for(let e=0;e<t;e++){let e=this.key();if(e===`__proto__`)throw 6;n[e]=this.readAny()}return n}else if(e===31)return this.readObjIndef();else throw 1}readObjRaw(e){let t={};for(let n=0;n<e;n++){let e=this.key();t[e]=this.readAny()}return t}readObjIndef(){let e={};for(;this.reader.peak()!==255;){let t=this.key();if(this.reader.peak()===255)throw 7;e[t]=this.readAny()}return this.reader.x++,e}key(){let e=this.reader.u8(),t=e>>5,n=e&31;if(t!==3)return String(this.readAnyRaw(e));let r=this.readStrLen(n);if(r>31)return this.reader.utf8(r);let i=this.keyDecoder.decode(this.reader.uint8,this.reader.x,r);return this.reader.skip(r),i}readTag(e){if(e<=23)return this.readTagRaw(e);switch(e){case 24:return this.readTagRaw(this.reader.u8());case 25:return this.readTagRaw(this.reader.u16());case 26:return this.readTagRaw(this.reader.u32());case 27:return this.readTagRaw(Number(this.reader.u64()));default:throw 1}}readTagRaw(e){return new r.JsonPackExtension(e,this.readAny())}readTkn(e){switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;case 24:return new i.JsonPackValue(this.reader.u8());case 25:return this.f16();case 26:return this.reader.f32();case 27:return this.reader.f64()}if(e<=23)return new i.JsonPackValue(e);throw 1}f16(){return(0,n.decodeF16)(this.reader.u16())}}})),Bn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CborDecoder=void 0;let t=zn(),n=wn();e.CborDecoder=class extends t.CborDecoderBase{readAsMap(){let e=this.reader.u8(),t=e>>5,n=e&31;switch(t){case 5:return this.readMap(n);default:throw 0}}readMap(e){let t=this.readMinorLen(e);return t>=0?this.readMapRaw(t):this.readMapIndef()}readMapRaw(e){let t=new Map;for(let n=0;n<e;n++){let e=this.readAny(),n=this.readAny();t.set(e,n)}return t}readMapIndef(){let e=new Map;for(;this.reader.peak()!==255;){let t=this.readAny();if(this.reader.peak()===255)throw 7;let n=this.readAny();e.set(t,n)}return this.reader.x++,e}skipN(e){for(let t=0;t<e;t++)this.skipAny()}skipAny(){this.skipAnyRaw(this.reader.u8())}skipAnyRaw(e){let t=e>>5,n=e&31;switch(t){case 0:case 1:this.skipUNint(n);break;case 2:this.skipBin(n);break;case 3:this.skipStr(n);break;case 4:this.skipArr(n);break;case 5:this.skipObj(n);break;case 7:this.skipTkn(n);break;case 6:this.skipTag(n);break}}skipMinorLen(e){if(e<=23)return e;switch(e){case 24:return this.reader.u8();case 25:return this.reader.u16();case 26:return this.reader.u32();case 27:return Number(this.reader.u64());case 31:return-1;default:throw 1}}skipUNint(e){if(!(e<=23))switch(e){case 24:return this.reader.skip(1);case 25:return this.reader.skip(2);case 26:return this.reader.skip(4);case 27:return this.reader.skip(8);default:throw 1}}skipBin(e){let t=this.skipMinorLen(e);if(t>=0)this.reader.skip(t);else{for(;this.reader.peak()!==255;)this.skipBinChunk();this.reader.x++}}skipBinChunk(){let e=this.reader.u8(),t=e>>5,n=e&31;if(t!==2)throw 2;if(n>27)throw 3;this.skipBin(n)}skipStr(e){let t=this.skipMinorLen(e);if(t>=0)this.reader.skip(t);else{for(;this.reader.peak()!==255;)this.skipStrChunk();this.reader.x++}}skipStrChunk(){let e=this.reader.u8(),t=e>>5,n=e&31;if(t!==3)throw 4;if(n>27)throw 5;this.skipStr(n)}skipArr(e){let t=this.skipMinorLen(e);if(t>=0)this.skipN(t);else{for(;this.reader.peak()!==255;)this.skipAny();this.reader.x++}}skipObj(e){let t=this.readMinorLen(e);if(t>=0)return this.skipN(t*2);for(;this.reader.peak()!==255;){if(this.skipAny(),this.reader.peak()===255)throw 7;this.skipAny()}this.reader.x++}skipTag(e){if(this.skipMinorLen(e)<0)throw 1;this.skipAny()}skipTkn(e){switch(e){case 24:this.reader.skip(1);return;case 25:this.reader.skip(2);return;case 26:this.reader.skip(4);return;case 27:this.reader.skip(8);return}if(!(e<=23))throw 1}validate(e,t=0,n=e.length){this.reader.reset(e),this.reader.x=t;let r=t;if(this.skipAny(),this.reader.x-r!==n)throw 8}decodeLevel(e){return this.reader.reset(e),this.readLevel()}readLevel(){let e=this.reader.u8(),t=e>>5,n=e&31;switch(t){case 4:return this.readArrLevel(n);case 5:return this.readObjLevel(n);default:return super.readAnyRaw(e)}}readPrimitiveOrVal(){switch(this.reader.peak()>>5){case 4:case 5:return this.readAsValue();default:return this.readAny()}}readAsValue(){let e=this.reader,t=e.x;this.skipAny();let r=e.x;return new n.JsonPackValue(e.uint8.subarray(t,r))}readObjLevel(e){let t=this.readMinorLen(e);return t>=0?this.readObjRawLevel(t):this.readObjIndefLevel()}readObjRawLevel(e){let t={};for(let n=0;n<e;n++){let e=this.key();t[e]=this.readPrimitiveOrVal()}return t}readObjIndefLevel(){let e={};for(;this.reader.peak()!==255;){let t=this.key();if(this.reader.peak()===255)throw 7;e[t]=this.readPrimitiveOrVal()}return this.reader.x++,e}readArrLevel(e){let t=this.readMinorLen(e);return t>=0?this.readArrRawLevel(t):this.readArrIndefLevel()}readArrRawLevel(e){let t=[];for(let n=0;n<e;n++)t.push(this.readPrimitiveOrVal());return t}readArrIndefLevel(){let e=[];for(;this.reader.peak()!==255;)e.push(this.readPrimitiveOrVal());return this.reader.x++,e}readHdr(e){let t=this.reader.u8();if(t>>5!==e)throw 0;let n=t&31;if(n<24)return n;switch(n){case 24:return this.reader.u8();case 25:return this.reader.u16();case 26:return this.reader.u32();case 27:return Number(this.reader.u64());case 31:return-1}throw 1}readStrHdr(){return this.readHdr(3)}readObjHdr(){return this.readHdr(5)}readArrHdr(){return this.readHdr(4)}findKey(e){let t=this.readObjHdr();for(let n=0;n<t;n++){if(this.key()===e)return this;this.skipAny()}throw 9}findIndex(e){if(e>=this.readArrHdr())throw 10;for(let t=0;t<e;t++)this.skipAny();return this}find(e){for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`?this.findKey(n):this.findIndex(n)}return this}}})),Vn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CborDecoderDag=void 0;let t=Cn(),n=Bn();e.CborDecoderDag=class extends n.CborDecoder{readTagRaw(e){let n=this.readAny();return e===42?new t.JsonPackExtension(e,n):n}}})),Hn=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(U(),c(I));t.__exportStar(vn(),e),t.__exportStar(xn(),e),t.__exportStar(Tn(),e),t.__exportStar(On(),e),t.__exportStar(kn(),e),t.__exportStar(zn(),e),t.__exportStar(Bn(),e),t.__exportStar(Vn(),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}}};const Un=new Hn.CborEncoder,Wn=new Hn.CborDecoder;function Gn(e){let t={...e,validationHash:Yn(e??{})};return Un.encode(t)}function Kn(e){if(!e.length)throw new G(W.corruptedResponse,`Missing compressed data`);let t=Jn(e);if(!t)throw new G(W.corruptedResponse,`Invalid compressed data`);if(!t?.validationHash)throw new G(W.corruptedResponse,`Missing validation hash`);let{validationHash:n,...r}=t,i=Yn(r);if(i!==t.validationHash)throw console.warn(`Validation error`,{validationHash:n,rawResultData:r,parsedData:t,expectedValidationHashes:i,recomputedHash:Yn(void 0)}),new G(W.corruptedResponse,`Invalid validation hash`);return t}function qn(e){return Un.encode(e)}function Jn(e){try{return Wn.decode(e)}catch(t){return console.error(`Invalid compressed data`,{e:t,data:e}),null}}function Yn(e){return It(Un.encode(e))}const Xn=()=>({onRequest:(e,t)=>{if(e.data instanceof Uint8Array||ArrayBuffer.isView(e.data))return t;try{e.data=Gn(e.data)}catch(e){console.error(`[Compression Middleware] Failed to compress request`,e)}return t},onResponse:(e,t,n)=>{if(t.error||!(t.result instanceof Uint8Array||ArrayBuffer.isView(t.result)))return t;try{let{validationHash:e,...n}=Kn(t.result);typeof n==`object`&&n&&`result`in n?t.result=n.result:t.result=n}catch(e){console.error(`[Compression Middleware] Failed to decompress response`,e)}return t}});var Zn=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 Qn(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 Zn;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 $n({domain:e}={}){return nt(S((e??window.location.host).replace(`www.`,``)))}function er(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function tr(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 nr(e){return er(qn(e))}function rr(e,t,n,r,i){let a=nr(ir({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,productId:n,metadata:{name:r,css:i,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink}})),o=new URL(e);return o.pathname=`/sso`,o.searchParams.set(`p`,a),o.toString()}function ir(e){return{r:e.redirectUrl,d:e.directExit,l:e.lang,p:e.productId,m:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const ar=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,or=`frak-sso`;async function sr(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??rr(i??`https://wallet.frak.id`,t,$n(),n.name,r?.css),o=window.open(a,or,ar);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 cr=`fCtx`;function lr(e){if(e?.r)try{return er(ge(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function ur(e){if(!(!e||e.length===0))try{return{r:le(tr(e),{size:20})}}catch(t){console.error(`Error decompressing Frak context`,{e:t,context:e})}}function dr({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(cr);return t?ur(t):null}function fr({url:e,context:t}){if(!e)return null;let n=dr({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let i=lr(r);if(!i)return null;let a=new URL(e);return a.searchParams.set(cr,i),a.toString()}function pr(e){let t=new URL(e);return t.searchParams.delete(cr),t.toString()}function mr({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?pr(n):fr({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const K={compress:lr,decompress:ur,parse:dr,update:fr,remove:pr,replaceUrl:mr};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 hr=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)}},gr=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.3`,this.api=new hr({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 _r(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var vr=class extends gr{constructor(e){if(super({sdk:`web`,sdkVersion:`1.0.6`,...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[_r(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`;function yr(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 br=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`
7
+ Debug Information:
8
+ -----------------
9
+ Timestamp: ${t.timestamp}
10
+ URL: ${t.encodedUrl}
11
+ Config: ${t.encodedConfig}
12
+ Navigator Info: ${t.navigatorInfo}
13
+ IFrame Status: ${t.iframeStatus}
14
+ Last Request: ${t.lastRequest}
15
+ Last Response: ${t.lastResponse}
16
+ Client Status: ${t.clientStatus}
17
+ Error: ${t.error}
18
+ `.trim()}};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 xr({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(),Sr({iframe:r,isVisible:!1}),document.body.appendChild(r),new Promise(n=>{r?.addEventListener(`load`,()=>n(r)),r.src=`${t?.walletUrl??e??`https://wallet.frak.id`}/listener`})}function Sr({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 Cr(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 wr({iframe:e}){let t=new Zn;return{handleEvent:async n=>{if(!(`iframeLifecycle`in n))return;let{iframeLifecycle:r,data:i}=n;switch(r){case`connected`:t.resolve(!0);break;case`do-backup`:i.backup?localStorage.setItem(J,i.backup):localStorage.removeItem(J);break;case`remove-backup`:localStorage.removeItem(J);break;case`show`:case`hide`:Sr({iframe:e,isVisible:r===`show`});break;case`handshake`:e.contentWindow?.postMessage({clientLifecycle:`handshake-response`,data:{token:i.token,currentUrl:window.location.href}},`*`);break;case`redirect`:{let e=new URL(i.baseRedirectUrl);e.searchParams.has(`u`)?(e.searchParams.delete(`u`),e.searchParams.append(`u`,window.location.href),window.location.href=e.toString()):window.location.href=i.baseRedirectUrl;break}}},isConnected:t.promise}}function Tr({config:e,iframe:t}){let n=e?.walletUrl??`https://wallet.frak.id`,r=wr({iframe:t}),i=new br(e,t);if(!t.contentWindow)throw new G(W.configError,`The iframe does not have a content window`);let a=Qn({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}},Xn(),{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=Er(a,r),s=async()=>{o(),a.cleanup(),t.remove()},c;console.log(`[Frak SDK] Initializing OpenPanel`),c=new vr({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.0`}),!0)}),c.setGlobalProperties({sdkVersion:`0.1.0`}),c.init();let l=Dr({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 Er(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 Dr({config:e,rpcClient:t,lifecycleManager:n}){await n.isConnected,yr(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 Or(e){return Jn(tr(e))}const X={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function kr(e){return e&&e in X?e:`eur`}function Ar(e){return e?X[e]??X.eur:X.eur}function jr(e,t){let n=Ar(t),r=kr(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function Mr(e){return e?`${e}Amount`:`eurAmount`}async function Nr({config:e}){let t=Pr(e),n=await xr({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=Tr({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function Pr(e){let t=kr(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}const Z={press:{openArticle:`0xc0a24ffb`,readArticle:`0xd5bd0fbe`},dapp:{proofVerifiableStorageUpdate:`0x2ab2aeef`,callableVerifiableStorageUpdate:`0xa07da986`},webshop:{open:`0xb311798f`},referral:{referred:`0x010cc3b9`,createLink:`0xb2c0f17c`},purchase:{started:`0xd87e90c3`,completed:`0x8403aeb4`,unsafeCompleted:`0x4d5b14e0`},retail:{customerMeeting:`0x74489004`}},Q={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},Fr=Object.entries(Q).reduce((e,[t,n])=>(e[t]=BigInt(1)<<BigInt(n),e),{}),Ir={openArticle({articleId:e}){let t=M([Z.press.openArticle,y(e,{size:32})]);return{handlerTypeDenominator:S(Q.press),interactionData:t}},readArticle({articleId:e}){let t=M([Z.press.readArticle,y(e,{size:32})]);return{handlerTypeDenominator:S(Q.press),interactionData:t}}},Lr={startPurchase({purchaseId:e}){let t=M([Z.purchase.started,y(e,{size:32})]);return{handlerTypeDenominator:S(Q.purchase),interactionData:t}},completedPurchase({purchaseId:e,proof:t}){let n=_t([{type:`uint256`},{type:`bytes32[]`}],[BigInt(e),t]),r=M([Z.purchase.completed,n]);return{handlerTypeDenominator:S(Q.purchase),interactionData:r}},unsafeCompletedPurchase({purchaseId:e}){let t=M([Z.purchase.unsafeCompleted,y(e,{size:32})]);return{handlerTypeDenominator:S(Q.purchase),interactionData:t}}},Rr={createLink(){return{handlerTypeDenominator:S(Q.referral),interactionData:Z.referral.createLink}},referred({referrer:e}){let t=M([Z.referral.referred,y(e,{size:32})]);return{handlerTypeDenominator:S(Q.referral),interactionData:t}}},zr={customerMeeting({agencyId:e}){let t=M([Z.retail.customerMeeting,y(e,{size:32})]);return{handlerTypeDenominator:S(Q.retail),interactionData:t}}},Br={open(){return{handlerTypeDenominator:S(Q.webshop),interactionData:Z.webshop.open}}};function Vr(){return zt(96)}async function Hr(e,t){return await e.request({method:`frak_displayEmbeddedWallet`,params:[t,e.config.metadata]})}async function Ur(e,{steps:t,metadata:n}){return await e.request({method:`frak_displayModal`,params:[t,n,e.config.metadata]})}async function Wr(e){return await e.request({method:`frak_getProductInformation`})}async function Gr(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function Kr(e,{walletStatus:t,frakContext:n,modalConfig:r,productId:i,options:a}){if(!n?.r)return`no-referrer`;q(e,`user_referred_started`,{properties:{referrer:n?.r,walletStatus:t?.key}});let o=!1;async function s(){if(!o)return o=!0,Jr(e,{modalConfig:{...r,loggedIn:{action:{key:`referred`}}},walletStatus:t})}async function c(t){await Zr(e,{productId:i,interaction:Rr.referred({referrer:t})})}try{let{status:r,currentWallet:i}=await qr({initialWalletStatus:t,getFreshWalletStatus:s,pushReferralInteraction:c,frakContext:n});return K.replaceUrl({url:window.location?.href,context:a?.alwaysAppendUrl?{r:i}:null}),q(e,`user_referred_completed`,{properties:{status:r,referrer:n?.r,wallet:i}}),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:a?.alwaysAppendUrl?{r:t?.wallet}:null}),Yr(r)}}async function qr({initialWalletStatus:e,getFreshWalletStatus:t,pushReferralInteraction:n,frakContext:r}){let i=e?.wallet;return i||=await t(),i&&Lt(r.r,i)?{status:`self-referral`,currentWallet:i}:(e?.interactionSession||(i=await t()),await n(r.r),{status:`success`,currentWallet:i})}async function Jr(e,{modalConfig:t,walletStatus:n}){return n?.interactionSession?n.wallet??void 0:(await Hr(e,t??{}))?.wallet??void 0}function Yr(e){if(e instanceof G)switch(e.code){case W.walletNotConnected:return`no-wallet`;case W.serverErrorForInteractionDelegation:return`no-session`;default:return`error`}return`error`}async function Xr(e,{productId:t,modalConfig:n,options:r}={}){let i=K.parse({url:window.location.href}),a=await $r(e);try{return await Kr(e,{walletStatus:a,frakContext:i,modalConfig:n,productId:t,options:r})}catch(e){console.warn(`Error processing referral`,{error:e})}}async function Zr(e,{productId:t,interaction:n,validation:r}){let i=t??$n(e.config);return await e.request({method:`frak_sendInteraction`,params:[i,n,r]})}async function Qr(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}await fetch(`https://backend.frak.id/interactions/listenForPurchase`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":t},body:JSON.stringify(e)})}function $r(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(ei(e,t),t));let n=new Zn,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{ei(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function ei(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 ti(e,{metadata:t,login:n,openSession:r}){return $(e,{steps:{login:n??{},openSession:r??{}},metadata:t})}function $(e,t){function n(n){return $(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return $(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return $(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function a(n){return n&&(t.metadata=n(t.metadata??{})),await Ur(e,t)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function ni(e,{tx:t,metadata:n}){return(await Ur(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function ri(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 Ur(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??Vr(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var ii=o({DebugInfoGatherer:()=>br,FrakContextManager:()=>K,PressInteractionEncoder:()=>Ir,PurchaseInteractionEncoder:()=>Lr,ReferralInteractionEncoder:()=>Rr,RetailInteractionEncoder:()=>zr,WebShopInteractionEncoder:()=>Br,base64urlDecode:()=>tr,base64urlEncode:()=>er,baseIframeProps:()=>Y,compressJsonToB64:()=>nr,createIFrameFrakClient:()=>Tr,createIframe:()=>xr,decompressJsonFromB64:()=>Or,displayEmbeddedWallet:()=>Hr,displayModal:()=>Ur,findIframeInOpener:()=>Cr,formatAmount:()=>jr,generateSsoUrl:()=>rr,getCurrencyAmountKey:()=>Mr,getProductInformation:()=>Wr,getSupportedCurrency:()=>kr,getSupportedLocale:()=>Ar,interactionTypes:()=>Z,locales:()=>X,modalBuilder:()=>ti,openSso:()=>sr,prepareSso:()=>Gr,processReferral:()=>Kr,productTypes:()=>Q,productTypesMask:()=>Fr,referralInteraction:()=>Xr,sendInteraction:()=>Zr,sendTransaction:()=>ni,setupClient:()=>Nr,siweAuthenticate:()=>ri,ssoPopupFeatures:()=>ar,ssoPopupName:()=>or,trackEvent:()=>q,trackPurchaseStatus:()=>Qr,watchWalletStatus:()=>$r});function ai(){`vibrate`in navigator?navigator.vibrate(10):console.log(`Vibration not supported`)}function oi(){if(!window.FrakSetup?.client){console.error(`Frak client not found`);return}ai(),Hr(window.FrakSetup.client,window.FrakSetup?.modalWalletConfig??{})}const si=`frakClientReady`;function ci(){let e=new CustomEvent(si);window.dispatchEvent(e)}function li(e,t){if(window.FrakSetup?.client&&e===`add`){t();return}(e===`add`?window.addEventListener:window.removeEventListener)(si,t,!1)}function ui(e){window.modalBuilderSteps=ti(e,window.FrakSetup?.modalConfig??{})}async function di(e){let t=await Xr(e,{modalConfig:window.FrakSetup?.modalWalletConfig});console.log(`referral`,t)}function fi(){if(!window.modalBuilderSteps)throw Error(`modalBuilderSteps not found`);return window.modalBuilderSteps}async function pi(){if(window.FrakSetup.core=ii,!mi())return;if(console.log(`[Frak SDK] Starting initialization`),window.frakSetupInProgress=!0,!window.FrakSetup.config){console.error(`[Frak SDK] Configuration not found`),window.frakSetupInProgress=!1;return}let e=await Nr({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`),ci(),ui(e),di(e),window.frakSetupInProgress=!1,hi()}function mi(){return window.frakSetupInProgress?(console.log(`[Frak SDK] Initialization already in progress`),!1):window.FrakSetup?.client?(console.log(`[Frak SDK] Client already initialized`),!1):window.FrakSetup?.config?!0:(console.error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`),!1)}function hi(){let e=new URLSearchParams(window.location.search).get(`frakAction`);e&&e===`share`&&(console.log(`[Frak SDK] Auto open query param found`),oi())}function gi(){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)}gi(),l(pi);const _i={"button-share":()=>import(`./ButtonShare.D40CBIiu.js`),"button-wallet":()=>import(`./ButtonWallet.B2TEJXzT.js`)},vi=new MutationObserver(e=>{for(let{addedNodes:t}of e)for(let e of Array.from(t))e.nodeType===Node.ELEMENT_NODE&&yi(e)});async function yi(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=>bi(e)))}async function bi(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)}}yi(document.body),vi.observe(document.documentElement,{subtree:!0,childList:!0});export{Wr as a,br as c,G as d,W as f,oi as i,Mr as l,fi as n,Hr as o,l as p,li as r,jr as s,pi as t,q as u};
@@ -0,0 +1,2 @@
1
+ .M4fSKa_spinner{--spinner-opacity:.65;opacity:var(--spinner-opacity);width:16px;height:16px;display:block;position:relative}.M4fSKa_spinner__leaf{--spinner-animation-duration:.8s;width:12.5%;height:100%;animation:M4fSKa_rt-spinner-leaf-fade var(--spinner-animation-duration)linear infinite;position:absolute;top:0;left:43.75%;&:before{content:"";background-color:currentColor;border-radius:3px;width:100%;height:30%;display:block}&:where(:first-child){animation-delay:calc(-8/8*var(--spinner-animation-duration));transform:rotate(0)}&:where(:nth-child(2)){animation-delay:calc(-7/8*var(--spinner-animation-duration));transform:rotate(45deg)}&:where(:nth-child(3)){animation-delay:calc(-6/8*var(--spinner-animation-duration));transform:rotate(90deg)}&:where(:nth-child(4)){animation-delay:calc(-5/8*var(--spinner-animation-duration));transform:rotate(135deg)}&:where(:nth-child(5)){animation-delay:calc(-4/8*var(--spinner-animation-duration));transform:rotate(180deg)}&:where(:nth-child(6)){animation-delay:calc(-3/8*var(--spinner-animation-duration));transform:rotate(225deg)}&:where(:nth-child(7)){animation-delay:calc(-2/8*var(--spinner-animation-duration));transform:rotate(270deg)}&:where(:nth-child(8)){animation-delay:calc(-1/8*var(--spinner-animation-duration));transform:rotate(315deg)}}@keyframes M4fSKa_rt-spinner-leaf-fade{0%{opacity:1}to{opacity:.25}}
2
+ .nOB7Uq_buttonShare{justify-content:center;align-items:center;gap:10px;display:flex}
@@ -0,0 +1,100 @@
1
+ import { FullInteractionTypesKey } from "@frak-labs/core-sdk";
2
+ import * as preact0 from "preact";
3
+
4
+ //#region src/components/ButtonShare/types.d.ts
5
+
6
+ /**
7
+ * The props type for {@link ButtonShare}.
8
+ * @inline
9
+ */
10
+ type ButtonShareProps = {
11
+ /**
12
+ * Text to display on the button
13
+ * - To specify where the reward should be displayed, use the placeholder `{REWARD}`, e.g. `Share and earn up to \{REWARD\}!`
14
+ * @defaultValue `"Share and earn!"`
15
+ */
16
+ text?: string;
17
+ /**
18
+ * Classname to apply to the button
19
+ */
20
+ classname?: string;
21
+ /**
22
+ * Do we display the reward on the share modal?
23
+ * @defaultValue `false`
24
+ */
25
+ useReward?: boolean;
26
+ /**
27
+ * Fallback text if the reward isn't found
28
+ */
29
+ noRewardText?: string;
30
+ /**
31
+ * Target interaction behind this sharing action (will be used to get the right reward to display)
32
+ */
33
+ targetInteraction?: FullInteractionTypesKey;
34
+ /**
35
+ * Do we display the wallet modal instead of the share modal?
36
+ * @defaultValue `false`
37
+ */
38
+ showWallet?: boolean;
39
+ };
40
+ //#endregion
41
+ //#region src/components/ButtonShare/ButtonShare.d.ts
42
+ /**
43
+ * Button to share the current page
44
+ *
45
+ * @param args
46
+ * @returns The share button with `<button>` tag
47
+ *
48
+ * @group components
49
+ *
50
+ * @example
51
+ * Basic usage:
52
+ * ```html
53
+ * <frak-button-share></frak-button-share>
54
+ * ```
55
+ *
56
+ * @example
57
+ * Using a custom text:
58
+ * ```html
59
+ * <frak-button-share text="Share and earn!"></frak-button-share>
60
+ * ```
61
+ *
62
+ * @example
63
+ * Using a custom class:
64
+ * ```html
65
+ * <frak-button-share classname="button button-primary"></frak-button-share>
66
+ * ```
67
+ *
68
+ * @example
69
+ * Using reward information and fallback text:
70
+ * ```html
71
+ * <frak-button-share use-reward text="Share and earn up to {REWARD}!" no-reward-text="Share and earn!"></frak-button-share>
72
+ * ```
73
+ *
74
+ * @example
75
+ * Using reward information for specific reward and fallback text:
76
+ * ```html
77
+ * <frak-button-share use-reward text="Share and earn up to {REWARD}!" no-reward-text="Share and earn!" target-interaction="retail.customerMeeting"></frak-button-share>
78
+ * ```
79
+ *
80
+ * @see {@link @frak-labs/core-sdk!actions.modalBuilder | `modalBuilder()`} for more info about the modal display
81
+ * @see {@link @frak-labs/core-sdk!actions.getProductInformation | `getProductInformation()`} for more info about the estimated reward fetching
82
+ */
83
+ declare function ButtonShare({
84
+ text,
85
+ classname,
86
+ useReward: rawUseReward,
87
+ noRewardText,
88
+ targetInteraction,
89
+ showWallet: rawShowWallet
90
+ }: ButtonShareProps): preact0.JSX.Element;
91
+ //#endregion
92
+ //#region src/components/ButtonShare/index.d.ts
93
+ interface ButtonShareElement extends HTMLElement, ButtonShareProps {}
94
+ declare global {
95
+ interface HTMLElementTagNameMap {
96
+ "frak-button-share": ButtonShareElement;
97
+ }
98
+ }
99
+ //#endregion
100
+ export { ButtonShare, ButtonShareElement };
@@ -0,0 +1,343 @@
1
+ import { i as getModalBuilderSteps, n as useClientReady, r as registerWebComponent, t as useReward } from "./useReward-1io3tiHR.js";
2
+ import { DebugInfoGatherer, trackEvent } from "@frak-labs/core-sdk";
3
+ import { displayEmbeddedWallet } from "@frak-labs/core-sdk/actions";
4
+ import { cx } from "class-variance-authority";
5
+ import { useCallback, useMemo, useState } from "preact/hooks";
6
+ import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
7
+ import { FrakRpcError, RpcErrorCodes } from "@frak-labs/frame-connector";
8
+
9
+ //#region src/components/Spinner/index.module.css?css_module
10
+ const classes$1 = {
11
+ "rt-spinner-leaf-fade": "M4fSKa_rt-spinner-leaf-fade",
12
+ "spinner": "M4fSKa_spinner",
13
+ "spinner__leaf": "M4fSKa_spinner__leaf"
14
+ };
15
+ var index_module_default = classes$1;
16
+ const _rt_spinner_leaf_fade0 = classes$1["rt-spinner-leaf-fade"];
17
+ const _spinner0 = classes$1["spinner"];
18
+ const _spinner__leaf0 = classes$1["spinner__leaf"];
19
+
20
+ //#endregion
21
+ //#region src/components/Spinner/index.tsx
22
+ const Spinner = ({ ref, className, ...props }) => {
23
+ return /* @__PURE__ */ jsxs("span", {
24
+ ...props,
25
+ ref,
26
+ className: cx(index_module_default.spinner),
27
+ children: [
28
+ /* @__PURE__ */ jsx("span", { className: index_module_default.spinner__leaf }),
29
+ /* @__PURE__ */ jsx("span", { className: index_module_default.spinner__leaf }),
30
+ /* @__PURE__ */ jsx("span", { className: index_module_default.spinner__leaf }),
31
+ /* @__PURE__ */ jsx("span", { className: index_module_default.spinner__leaf }),
32
+ /* @__PURE__ */ jsx("span", { className: index_module_default.spinner__leaf }),
33
+ /* @__PURE__ */ jsx("span", { className: index_module_default.spinner__leaf }),
34
+ /* @__PURE__ */ jsx("span", { className: index_module_default.spinner__leaf }),
35
+ /* @__PURE__ */ jsx("span", { className: index_module_default.spinner__leaf })
36
+ ]
37
+ });
38
+ };
39
+ Spinner.displayName = "Spinner";
40
+
41
+ //#endregion
42
+ //#region src/components/ButtonShare/ButtonShare.module.css?css_module
43
+ const classes = { "buttonShare": "nOB7Uq_buttonShare" };
44
+ var ButtonShare_module_default = classes;
45
+ const _buttonShare0 = classes["buttonShare"];
46
+
47
+ //#endregion
48
+ //#region src/hooks/useCopyToClipboard.ts
49
+ function useCopyToClipboard(options = {}) {
50
+ const { successDuration = 2e3 } = options;
51
+ const [copied, setCopied] = useState(false);
52
+ return {
53
+ copy: useCallback(async (text) => {
54
+ try {
55
+ if (navigator.clipboard && window.isSecureContext) {
56
+ await navigator.clipboard.writeText(text);
57
+ setCopied(true);
58
+ } else {
59
+ const textArea = document.createElement("textarea");
60
+ textArea.value = text;
61
+ textArea.style.position = "fixed";
62
+ textArea.style.opacity = "0";
63
+ document.body.appendChild(textArea);
64
+ textArea.focus();
65
+ textArea.select();
66
+ try {
67
+ document.execCommand("copy");
68
+ setCopied(true);
69
+ } catch (err) {
70
+ console.error("Failed to copy text:", err);
71
+ return false;
72
+ } finally {
73
+ textArea.remove();
74
+ }
75
+ }
76
+ setTimeout(() => {
77
+ setCopied(false);
78
+ }, successDuration);
79
+ return true;
80
+ } catch (err) {
81
+ console.error("Failed to copy text:", err);
82
+ return false;
83
+ }
84
+ }, [successDuration]),
85
+ copied
86
+ };
87
+ }
88
+
89
+ //#endregion
90
+ //#region src/components/ButtonShare/components/ErrorMessage.tsx
91
+ const styles = {
92
+ errorContainer: {
93
+ marginTop: "16px",
94
+ padding: "16px",
95
+ backgroundColor: "#FEE2E2",
96
+ border: "1px solid #FCA5A5",
97
+ borderRadius: "4px",
98
+ color: "#991B1B"
99
+ },
100
+ header: {
101
+ display: "flex",
102
+ alignItems: "center",
103
+ gap: "8px",
104
+ marginBottom: "12px"
105
+ },
106
+ title: {
107
+ margin: 0,
108
+ fontSize: "16px",
109
+ fontWeight: 500
110
+ },
111
+ message: {
112
+ fontSize: "14px",
113
+ lineHeight: "1.5",
114
+ margin: "0 0 12px 0"
115
+ },
116
+ link: {
117
+ color: "#991B1B",
118
+ textDecoration: "underline",
119
+ textUnderlineOffset: "2px"
120
+ },
121
+ copyButton: {
122
+ display: "inline-flex",
123
+ alignItems: "center",
124
+ gap: "8px",
125
+ marginBottom: "10px",
126
+ padding: "8px 12px",
127
+ backgroundColor: "white",
128
+ border: "1px solid #D1D5DB",
129
+ borderRadius: "4px",
130
+ color: "black",
131
+ fontSize: "14px",
132
+ fontWeight: 500
133
+ }
134
+ };
135
+ /**
136
+ * Renders a toggleable debug information section
137
+ * @param {Object} props - Component props
138
+ * @param {string} [props.debugInfo] - Debug information to display in textarea
139
+ */
140
+ function ToggleMessage({ debugInfo }) {
141
+ const [showInfo, setShowInfo] = useState(false);
142
+ return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("button", {
143
+ type: "button",
144
+ style: styles.copyButton,
145
+ onClick: () => setShowInfo(!showInfo),
146
+ children: "Ouvrir les informations"
147
+ }), showInfo && /* @__PURE__ */ jsx("textarea", {
148
+ style: {
149
+ display: "block",
150
+ width: "100%",
151
+ height: "200px",
152
+ fontSize: "12px"
153
+ },
154
+ children: debugInfo
155
+ })] });
156
+ }
157
+ /**
158
+ * Displays an error message with debug information and copy functionality
159
+ * @param {Object} props - Component props
160
+ * @param {string} [props.debugInfo] - Debug information that can be copied or displayed
161
+ */
162
+ function ErrorMessage({ debugInfo }) {
163
+ const { copied, copy } = useCopyToClipboard();
164
+ return /* @__PURE__ */ jsxs("div", {
165
+ style: styles.errorContainer,
166
+ children: [
167
+ /* @__PURE__ */ jsx("div", {
168
+ style: styles.header,
169
+ children: /* @__PURE__ */ jsx("h3", {
170
+ style: styles.title,
171
+ children: "Oups ! Nous avons rencontré un petit problème"
172
+ })
173
+ }),
174
+ /* @__PURE__ */ jsxs("p", {
175
+ style: styles.message,
176
+ children: [
177
+ "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 à",
178
+ " ",
179
+ /* @__PURE__ */ jsx("a", {
180
+ href: "mailto:help@frak-labs.com?subject=Debug",
181
+ style: styles.link,
182
+ children: "help@frak-labs.com"
183
+ }),
184
+ " ",
185
+ /* @__PURE__ */ jsx("br", {}),
186
+ "Merci pour votre retour, nous traitons votre demande dans les plus brefs délais."
187
+ ]
188
+ }),
189
+ /* @__PURE__ */ jsx("button", {
190
+ type: "button",
191
+ onClick: () => copy(debugInfo ?? ""),
192
+ style: styles.copyButton,
193
+ children: copied ? "Informations copiées !" : "Copier les informations de débogage"
194
+ }),
195
+ /* @__PURE__ */ jsx(ToggleMessage, { debugInfo })
196
+ ]
197
+ });
198
+ }
199
+
200
+ //#endregion
201
+ //#region src/components/ButtonShare/hooks/useShareModal.ts
202
+ /**
203
+ * Open the share modal
204
+ *
205
+ * @description
206
+ * This function will open the share modal with the configuration provided in the `window.FrakSetup.modalShareConfig` object.
207
+ */
208
+ function useShareModal(targetInteraction) {
209
+ const [debugInfo, setDebugInfo] = useState(void 0);
210
+ const [isError, setIsError] = useState(false);
211
+ return {
212
+ handleShare: useCallback(async () => {
213
+ if (!window.FrakSetup?.client) {
214
+ console.error("Frak client not found");
215
+ setDebugInfo(DebugInfoGatherer.empty().formatDebugInfo("Frak client not found"));
216
+ setIsError(true);
217
+ return;
218
+ }
219
+ const modalBuilderSteps = getModalBuilderSteps();
220
+ if (!modalBuilderSteps) throw new Error("modalBuilderSteps not found");
221
+ try {
222
+ await modalBuilderSteps.sharing(window.FrakSetup?.modalShareConfig ?? {}).display((metadata) => ({
223
+ ...metadata,
224
+ targetInteraction
225
+ }));
226
+ } catch (e) {
227
+ if (e instanceof FrakRpcError && e.code === RpcErrorCodes.clientAborted) {
228
+ console.debug("User aborted the modal");
229
+ return;
230
+ }
231
+ const debugInfo$1 = window.FrakSetup.client.debugInfo.formatDebugInfo(e);
232
+ trackEvent(window.FrakSetup.client, "share_modal_error", {
233
+ error: e instanceof Object && "message" in e ? e.message : "Unknown error",
234
+ debugInfo: debugInfo$1
235
+ });
236
+ setDebugInfo(debugInfo$1);
237
+ setIsError(true);
238
+ console.error("Error while opening the modal", e);
239
+ }
240
+ }, [targetInteraction]),
241
+ isError,
242
+ debugInfo
243
+ };
244
+ }
245
+
246
+ //#endregion
247
+ //#region src/components/ButtonShare/ButtonShare.tsx
248
+ /**
249
+ * Open the embedded wallet modal
250
+ *
251
+ * @description
252
+ * This function will open the wallet modal with the configuration provided in the `window.FrakSetup.modalWalletConfig` object.
253
+ */
254
+ async function modalEmbeddedWallet() {
255
+ if (!window.FrakSetup?.client) throw new Error("Frak client not found");
256
+ await displayEmbeddedWallet(window.FrakSetup.client, window.FrakSetup?.modalWalletConfig ?? {});
257
+ }
258
+ /**
259
+ * Button to share the current page
260
+ *
261
+ * @param args
262
+ * @returns The share button with `<button>` tag
263
+ *
264
+ * @group components
265
+ *
266
+ * @example
267
+ * Basic usage:
268
+ * ```html
269
+ * <frak-button-share></frak-button-share>
270
+ * ```
271
+ *
272
+ * @example
273
+ * Using a custom text:
274
+ * ```html
275
+ * <frak-button-share text="Share and earn!"></frak-button-share>
276
+ * ```
277
+ *
278
+ * @example
279
+ * Using a custom class:
280
+ * ```html
281
+ * <frak-button-share classname="button button-primary"></frak-button-share>
282
+ * ```
283
+ *
284
+ * @example
285
+ * Using reward information and fallback text:
286
+ * ```html
287
+ * <frak-button-share use-reward text="Share and earn up to {REWARD}!" no-reward-text="Share and earn!"></frak-button-share>
288
+ * ```
289
+ *
290
+ * @example
291
+ * Using reward information for specific reward and fallback text:
292
+ * ```html
293
+ * <frak-button-share use-reward text="Share and earn up to {REWARD}!" no-reward-text="Share and earn!" target-interaction="retail.customerMeeting"></frak-button-share>
294
+ * ```
295
+ *
296
+ * @see {@link @frak-labs/core-sdk!actions.modalBuilder | `modalBuilder()`} for more info about the modal display
297
+ * @see {@link @frak-labs/core-sdk!actions.getProductInformation | `getProductInformation()`} for more info about the estimated reward fetching
298
+ */
299
+ function ButtonShare({ text = "Share and earn!", classname = "", useReward: rawUseReward, noRewardText, targetInteraction, showWallet: rawShowWallet }) {
300
+ const shouldUseReward = useMemo(() => rawUseReward !== void 0, [rawUseReward]);
301
+ const showWallet = useMemo(() => rawShowWallet !== void 0, [rawShowWallet]);
302
+ const { isClientReady } = useClientReady();
303
+ const { reward } = useReward(shouldUseReward && isClientReady, targetInteraction);
304
+ const { handleShare, isError, debugInfo } = useShareModal(targetInteraction);
305
+ /**
306
+ * Compute the text we will display
307
+ */
308
+ const btnText = useMemo(() => {
309
+ if (!shouldUseReward) return text;
310
+ if (!reward) return noRewardText ?? text.replace("{REWARD}", "");
311
+ return text.includes("{REWARD}") ? text.replace("{REWARD}", reward) : `${text} ${reward}`;
312
+ }, [
313
+ shouldUseReward,
314
+ text,
315
+ noRewardText,
316
+ reward
317
+ ]);
318
+ /**
319
+ * The action when the button is clicked
320
+ */
321
+ const onClick = useCallback(async () => {
322
+ trackEvent(window.FrakSetup.client, "share_button_clicked");
323
+ if (showWallet) await modalEmbeddedWallet();
324
+ else await handleShare();
325
+ }, [showWallet, handleShare]);
326
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("button", {
327
+ type: "button",
328
+ className: cx(ButtonShare_module_default.buttonShare, classname, "override"),
329
+ onClick,
330
+ children: [
331
+ !isClientReady && /* @__PURE__ */ jsx(Spinner, {}),
332
+ " ",
333
+ btnText
334
+ ]
335
+ }), isError && /* @__PURE__ */ jsx(ErrorMessage, { debugInfo })] });
336
+ }
337
+
338
+ //#endregion
339
+ //#region src/components/ButtonShare/index.ts
340
+ registerWebComponent(ButtonShare, "frak-button-share", ["text"], { shadow: false });
341
+
342
+ //#endregion
343
+ export { ButtonShare };
@@ -0,0 +1 @@
1
+ .Kl62ia_button{all:unset;z-index:2000000;cursor:pointer;text-align:center;background-color:#3e557e;border-radius:50%;justify-content:center;align-items:center;width:45px;height:45px;font-size:24px;display:flex;position:fixed;bottom:20px}.Kl62ia_button__left{left:20px}.Kl62ia_button__right{right:20px}.Kl62ia_reward{color:#fff;white-space:nowrap;background:#ff3f3f;border-radius:5px;padding:2px 3px;font-size:9px;font-weight:600;line-height:9px;position:absolute;top:-4px;right:27px}
@@ -0,0 +1,76 @@
1
+ import { FullInteractionTypesKey } from "@frak-labs/core-sdk";
2
+ import * as preact0 from "preact";
3
+
4
+ //#region src/components/ButtonWallet/types.d.ts
5
+
6
+ /**
7
+ * The props type for {@link ButtonWallet}.
8
+ * @inline
9
+ */
10
+ type ButtonWalletProps = {
11
+ /**
12
+ * Classname to apply to the button
13
+ */
14
+ classname?: string;
15
+ /**
16
+ * Do we display the reward on the button?
17
+ * @defaultValue `false`
18
+ */
19
+ useReward?: boolean;
20
+ /**
21
+ * Target interaction behind this sharing action (will be used to get the right reward to display)
22
+ */
23
+ targetInteraction?: FullInteractionTypesKey;
24
+ };
25
+ //#endregion
26
+ //#region src/components/ButtonWallet/ButtonWallet.d.ts
27
+ /**
28
+ * Button to open wallet modal
29
+ *
30
+ * @param args
31
+ * @returns The wallet button with `<button>` tag
32
+ *
33
+ * @group components
34
+ *
35
+ * @example
36
+ * Basic usage:
37
+ * ```html
38
+ * <frak-button-wallet></frak-button-wallet>
39
+ * ```
40
+ *
41
+ * @example
42
+ * Using a custom class:
43
+ * ```html
44
+ * <frak-button-wallet classname="button button-primary"></frak-button-wallet>
45
+ * ```
46
+ *
47
+ * @example
48
+ * Using reward information:
49
+ * ```html
50
+ * <frak-button-wallet use-reward></frak-button-wallet>
51
+ * ```
52
+ *
53
+ * @example
54
+ * Using reward information for specific reward:
55
+ * ```html
56
+ * <frak-button-wallet use-reward target-interaction="retail.customerMeeting"></frak-button-wallet>
57
+ * ```
58
+ *
59
+ * @see {@link @frak-labs/core-sdk!actions.modalBuilder | `modalBuilder()`} for more info about the modal display
60
+ * @see {@link @frak-labs/core-sdk!actions.getProductInformation | `getProductInformation()`} for more info about the estimated reward fetching
61
+ */
62
+ declare function ButtonWallet({
63
+ classname,
64
+ useReward: rawUseReward,
65
+ targetInteraction
66
+ }: ButtonWalletProps): preact0.JSX.Element;
67
+ //#endregion
68
+ //#region src/components/ButtonWallet/index.d.ts
69
+ interface ButtonWalletElement extends HTMLElement, ButtonWalletProps {}
70
+ declare global {
71
+ interface HTMLElementTagNameMap {
72
+ "frak-button-wallet": ButtonWalletElement;
73
+ }
74
+ }
75
+ //#endregion
76
+ export { ButtonWallet, ButtonWalletElement };
@@ -0,0 +1,109 @@
1
+ import { a as openWalletModal, n as useClientReady, r as registerWebComponent, t as useReward } from "./useReward-1io3tiHR.js";
2
+ import { trackEvent } from "@frak-labs/core-sdk";
3
+ import { cx } from "class-variance-authority";
4
+ import { useEffect, useMemo, useState } from "preact/hooks";
5
+ import { jsx, jsxs } from "preact/jsx-runtime";
6
+
7
+ //#region src/components/ButtonWallet/assets/GiftIcon.tsx
8
+ function GiftIcon(props) {
9
+ return /* @__PURE__ */ jsxs("svg", {
10
+ fill: "none",
11
+ height: "1em",
12
+ viewBox: "0 0 28 28",
13
+ width: "1em",
14
+ xmlns: "http://www.w3.org/2000/svg",
15
+ ...props,
16
+ children: [/* @__PURE__ */ jsx("title", { children: "Gift icon" }), /* @__PURE__ */ jsx("path", {
17
+ 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",
18
+ stroke: "#fff",
19
+ "stroke-linecap": "round",
20
+ "stroke-linejoin": "round"
21
+ })]
22
+ });
23
+ }
24
+
25
+ //#endregion
26
+ //#region src/components/ButtonWallet/ButtonWallet.module.css?css_module
27
+ const classes = {
28
+ "reward": "Kl62ia_reward",
29
+ "button": "Kl62ia_button",
30
+ "button__left": "Kl62ia_button__left",
31
+ "button__right": "Kl62ia_button__right"
32
+ };
33
+ var ButtonWallet_module_default = classes;
34
+ const _reward0 = classes["reward"];
35
+ const _button0 = classes["button"];
36
+ const _button__left0 = classes["button__left"];
37
+ const _button__right0 = classes["button__right"];
38
+
39
+ //#endregion
40
+ //#region src/components/ButtonWallet/ButtonWallet.tsx
41
+ /**
42
+ * Button to open wallet modal
43
+ *
44
+ * @param args
45
+ * @returns The wallet button with `<button>` tag
46
+ *
47
+ * @group components
48
+ *
49
+ * @example
50
+ * Basic usage:
51
+ * ```html
52
+ * <frak-button-wallet></frak-button-wallet>
53
+ * ```
54
+ *
55
+ * @example
56
+ * Using a custom class:
57
+ * ```html
58
+ * <frak-button-wallet classname="button button-primary"></frak-button-wallet>
59
+ * ```
60
+ *
61
+ * @example
62
+ * Using reward information:
63
+ * ```html
64
+ * <frak-button-wallet use-reward></frak-button-wallet>
65
+ * ```
66
+ *
67
+ * @example
68
+ * Using reward information for specific reward:
69
+ * ```html
70
+ * <frak-button-wallet use-reward target-interaction="retail.customerMeeting"></frak-button-wallet>
71
+ * ```
72
+ *
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.getProductInformation | `getProductInformation()`} for more info about the estimated reward fetching
75
+ */
76
+ function ButtonWallet({ classname = "", useReward: rawUseReward, targetInteraction }) {
77
+ const shouldUseReward = useMemo(() => rawUseReward !== void 0, [rawUseReward]);
78
+ const { isClientReady } = useClientReady();
79
+ const { reward } = useReward(shouldUseReward && isClientReady, targetInteraction);
80
+ const [position, setPosition] = useState("right");
81
+ /**
82
+ * Setup the position of the button
83
+ */
84
+ useEffect(() => {
85
+ const position$1 = window.FrakSetup?.modalWalletConfig?.metadata?.position;
86
+ setPosition(position$1 ?? "right");
87
+ }, []);
88
+ return /* @__PURE__ */ jsxs("button", {
89
+ type: "button",
90
+ "aria-label": "Open wallet",
91
+ class: cx(ButtonWallet_module_default.button, position === "left" ? ButtonWallet_module_default.button__left : ButtonWallet_module_default.button__right, classname, "override"),
92
+ disabled: !isClientReady,
93
+ onClick: () => {
94
+ trackEvent(window.FrakSetup.client, "wallet_button_clicked");
95
+ openWalletModal();
96
+ },
97
+ children: [/* @__PURE__ */ jsx(GiftIcon, {}), reward && /* @__PURE__ */ jsx("span", {
98
+ className: ButtonWallet_module_default.reward,
99
+ children: reward
100
+ })]
101
+ });
102
+ }
103
+
104
+ //#endregion
105
+ //#region src/components/ButtonWallet/index.ts
106
+ registerWebComponent(ButtonWallet, "frak-button-wallet", [], { shadow: false });
107
+
108
+ //#endregion
109
+ export { ButtonWallet };
@@ -0,0 +1,239 @@
1
+ import register from "preact-custom-element";
2
+ import { formatAmount, getCurrencyAmountKey, setupClient } from "@frak-labs/core-sdk";
3
+ import * as coreSdk from "@frak-labs/core-sdk/bundle";
4
+ import { displayEmbeddedWallet, getProductInformation, modalBuilder, referralInteraction } from "@frak-labs/core-sdk/actions";
5
+ import { useCallback, useEffect, useState } from "preact/hooks";
6
+
7
+ //#region ../../packages/ui/utils/onDocumentReady.ts
8
+ /**
9
+ * When the document is ready, run the callback
10
+ * @param callback
11
+ */
12
+ function onDocumentReady(callback) {
13
+ if (document.readyState === "complete" || document.readyState === "interactive") setTimeout(callback, 1);
14
+ else if (document.addEventListener) document.addEventListener("DOMContentLoaded", callback);
15
+ else document.attachEvent("onreadystatechange", () => {
16
+ if (document.readyState === "complete") callback();
17
+ });
18
+ }
19
+
20
+ //#endregion
21
+ //#region src/utils/safeVibrate.ts
22
+ /**
23
+ * Attempt to vibrate the device
24
+ */
25
+ function safeVibrate() {
26
+ if ("vibrate" in navigator) navigator.vibrate(10);
27
+ else console.log("Vibration not supported");
28
+ }
29
+
30
+ //#endregion
31
+ //#region src/components/ButtonWallet/utils.ts
32
+ /**
33
+ * Open the wallet modal
34
+ *
35
+ * @description
36
+ * This function will open the wallet modal with the configuration provided in the `window.FrakSetup.modalWalletConfig` object.
37
+ */
38
+ function openWalletModal() {
39
+ if (!window.FrakSetup?.client) {
40
+ console.error("Frak client not found");
41
+ return;
42
+ }
43
+ safeVibrate();
44
+ displayEmbeddedWallet(window.FrakSetup.client, window.FrakSetup?.modalWalletConfig ?? {});
45
+ }
46
+
47
+ //#endregion
48
+ //#region src/utils/clientReady.ts
49
+ const CUSTOM_EVENT_NAME = "frakClientReady";
50
+ /**
51
+ * Dispatch a custom event when the Frak client is ready
52
+ */
53
+ function dispatchClientReadyEvent() {
54
+ const event = new CustomEvent(CUSTOM_EVENT_NAME);
55
+ window.dispatchEvent(event);
56
+ }
57
+ /**
58
+ * Add or remove an event listener for when the Frak client is ready
59
+ * @param action
60
+ * @param callback
61
+ */
62
+ function onClientReady(action, callback) {
63
+ if (window.FrakSetup?.client && action === "add") {
64
+ callback();
65
+ return;
66
+ }
67
+ (action === "add" ? window.addEventListener : window.removeEventListener)(CUSTOM_EVENT_NAME, callback, false);
68
+ }
69
+
70
+ //#endregion
71
+ //#region src/utils/setup.ts
72
+ /**
73
+ * Setup the modal config
74
+ * @param client
75
+ */
76
+ function setupModalConfig(client) {
77
+ window.modalBuilderSteps = modalBuilder(client, window.FrakSetup?.modalConfig ?? {});
78
+ }
79
+ /**
80
+ * Setup the referral
81
+ * @param client
82
+ */
83
+ async function setupReferral(client) {
84
+ const referral = await referralInteraction(client, { modalConfig: window.FrakSetup?.modalWalletConfig });
85
+ console.log("referral", referral);
86
+ }
87
+ /**
88
+ * Return the modal builder steps
89
+ */
90
+ function getModalBuilderSteps() {
91
+ if (!window.modalBuilderSteps) throw new Error("modalBuilderSteps not found");
92
+ return window.modalBuilderSteps;
93
+ }
94
+
95
+ //#endregion
96
+ //#region src/utils/initFrakSdk.ts
97
+ /**
98
+ * Initializes the Frak SDK client and sets up necessary configurations.
99
+ * This function handles the one-time setup of the Frak client and related features.
100
+ *
101
+ * @returns {Promise<void>}
102
+ */
103
+ async function initFrakSdk() {
104
+ window.FrakSetup.core = coreSdk;
105
+ if (!preChecks()) return;
106
+ console.log("[Frak SDK] Starting initialization");
107
+ window.frakSetupInProgress = true;
108
+ if (!window.FrakSetup.config) {
109
+ console.error("[Frak SDK] Configuration not found");
110
+ window.frakSetupInProgress = false;
111
+ return;
112
+ }
113
+ const client = await setupClient({ config: window.FrakSetup.config });
114
+ if (!client) {
115
+ console.error("[Frak SDK] Failed to create client");
116
+ window.frakSetupInProgress = false;
117
+ return;
118
+ }
119
+ window.FrakSetup.client = client;
120
+ console.log("[Frak SDK] Client initialized successfully");
121
+ dispatchClientReadyEvent();
122
+ setupModalConfig(client);
123
+ setupReferral(client);
124
+ window.frakSetupInProgress = false;
125
+ handleActionQueryParam();
126
+ }
127
+ /**
128
+ * Pre-checks for the Frak SDK initialization
129
+ */
130
+ function preChecks() {
131
+ if (window.frakSetupInProgress) {
132
+ console.log("[Frak SDK] Initialization already in progress");
133
+ return false;
134
+ }
135
+ if (window.FrakSetup?.client) {
136
+ console.log("[Frak SDK] Client already initialized");
137
+ return false;
138
+ }
139
+ if (!window.FrakSetup?.config) {
140
+ console.error("[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.");
141
+ return false;
142
+ }
143
+ return true;
144
+ }
145
+ /**
146
+ * Check the query param contain params for an auto opening of the frak modal
147
+ */
148
+ function handleActionQueryParam() {
149
+ const frakAction = new URLSearchParams(window.location.search).get("frakAction");
150
+ if (!frakAction) return;
151
+ if (frakAction === "share") {
152
+ console.log("[Frak SDK] Auto open query param found");
153
+ openWalletModal();
154
+ }
155
+ }
156
+
157
+ //#endregion
158
+ //#region src/utils/registerWebComponent.ts
159
+ /**
160
+ * Registers a Preact component as a custom web component
161
+ *
162
+ * @param component - The Preact component to register
163
+ * @param tagName - The custom element tag name (e.g., "frak-button-wallet")
164
+ * @param observedAttributes - Array of attribute names to observe for changes
165
+ * @param options - Registration options (e.g., { shadow: false })
166
+ */
167
+ function registerWebComponent(component, tagName, observedAttributes = [], options = { shadow: false }) {
168
+ if (typeof window !== "undefined") {
169
+ onDocumentReady(initFrakSdk);
170
+ if (!customElements.get(tagName)) register(component, tagName, observedAttributes, options);
171
+ }
172
+ }
173
+
174
+ //#endregion
175
+ //#region src/hooks/useClientReady.ts
176
+ /**
177
+ * Hook to manage client readiness state for the wallet button
178
+ * Handles subscription to client ready events and manages readiness state
179
+ * @returns Object containing the readiness state of the client
180
+ */
181
+ function useClientReady() {
182
+ const [disabled, setDisabled] = useState(true);
183
+ const handleClientReady = useCallback(() => {
184
+ setDisabled(false);
185
+ }, []);
186
+ useEffect(() => {
187
+ onClientReady("add", handleClientReady);
188
+ return () => onClientReady("remove", handleClientReady);
189
+ }, [handleClientReady]);
190
+ return { isClientReady: !disabled };
191
+ }
192
+
193
+ //#endregion
194
+ //#region src/utils/getCurrentReward.ts
195
+ /**
196
+ * Find the estimated reward
197
+ * @param targetInteraction
198
+ * @returns
199
+ */
200
+ async function getCurrentReward({ targetInteraction }) {
201
+ const client = window.FrakSetup?.client;
202
+ if (!client) {
203
+ console.warn("Frak client not ready yet");
204
+ return;
205
+ }
206
+ const { maxReferrer, rewards } = await getProductInformation(client);
207
+ if (!maxReferrer) return;
208
+ const currencyAmountKey = getCurrencyAmountKey(client.config.metadata?.currency);
209
+ let currentReward = Math.round(maxReferrer[currencyAmountKey]);
210
+ if (targetInteraction) {
211
+ const targetReward = rewards.filter((reward) => reward.interactionTypeKey === targetInteraction).map((reward) => reward.referrer[currencyAmountKey]).reduce((acc, reward) => reward > acc ? reward : acc, 0);
212
+ if (targetReward > 0) currentReward = Math.round(targetReward);
213
+ }
214
+ return formatAmount(currentReward, client.config.metadata?.currency);
215
+ }
216
+
217
+ //#endregion
218
+ //#region src/hooks/useReward.ts
219
+ /**
220
+ * Hook to fetch and format the current reward value for a given interaction
221
+ * @param shouldUseReward - Flag to determine if reward should be fetched
222
+ * @param targetInteraction - Optional interaction type to get specific reward for
223
+ * @param currency - The currency to use for the reward (default is "eur")
224
+ * @returns Object containing the formatted reward value in euros
225
+ */
226
+ function useReward(shouldUseReward, targetInteraction) {
227
+ const [reward, setReward] = useState(void 0);
228
+ useEffect(() => {
229
+ if (!shouldUseReward) return;
230
+ getCurrentReward({ targetInteraction }).then((reward$1) => {
231
+ if (!reward$1) return;
232
+ setReward(reward$1);
233
+ });
234
+ }, [shouldUseReward, targetInteraction]);
235
+ return { reward };
236
+ }
237
+
238
+ //#endregion
239
+ export { openWalletModal as a, getModalBuilderSteps as i, useClientReady as n, registerWebComponent as r, useReward as t };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": "https://twitter.com/QNivelais"
12
12
  }
13
13
  ],
14
- "version": "0.0.23-beta.278e9605",
14
+ "version": "0.0.23-beta.7e126d46",
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",
@@ -74,12 +74,13 @@
74
74
  "@frak-labs/frame-connector": "0.1.0",
75
75
  "@frak-labs/core-sdk": "0.1.0",
76
76
  "class-variance-authority": "^0.7.1",
77
- "preact": "^10.27.2",
77
+ "preact": "^10.28.0",
78
78
  "preact-custom-element": "^4.6.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@bosh-code/tsdown-plugin-inject-css": "^2.0.0",
82
82
  "@frak-labs/dev-tooling": "0.0.0",
83
+ "@frak-labs/test-foundation": "0.1.0",
83
84
  "@frak-labs/ui": "0.0.0",
84
85
  "@preact/preset-vite": "^2.10.2",
85
86
  "@rolldown/plugin-node-polyfills": "^1.0.0",
@@ -87,15 +88,15 @@
87
88
  "@testing-library/preact": "^3.2.4",
88
89
  "@testing-library/user-event": "^14.6.1",
89
90
  "@types/jsdom": "^27.0.0",
90
- "@types/node": "^24.10.0",
91
+ "@types/node": "^24.10.4",
91
92
  "@types/preact-custom-element": "^4.0.4",
92
- "@vitest/coverage-v8": "^4.0.8",
93
- "@vitest/ui": "^4.0.8",
94
- "jsdom": "^27.1.0",
95
- "tsdown": "^0.16.1",
93
+ "@vitest/coverage-v8": "^4.0.16",
94
+ "@vitest/ui": "^4.0.16",
95
+ "jsdom": "^27.3.0",
96
+ "tsdown": "^0.18.2",
96
97
  "typescript": "^5",
97
- "unplugin-lightningcss": "^0.4.3",
98
- "vite-tsconfig-paths": "^5.1.4",
99
- "vitest": "^4.0.8"
98
+ "unplugin-lightningcss": "^0.4.4",
99
+ "vite-tsconfig-paths": "^6.0.3",
100
+ "vitest": "^4.0.16"
100
101
  }
101
102
  }