@frak-labs/components 1.0.0-beta.0cd79998 → 1.0.0-beta.10dada3f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/Banner.UBeCtoRQ.js +162 -0
- package/cdn/ButtonShare.COa5uY94.js +1 -0
- package/cdn/ButtonWallet.BUzysl1S.js +40 -0
- package/cdn/OpenInAppButton.Bmzm2fL9.js +1 -0
- package/cdn/PostPurchase._st1hB42.js +52 -0
- package/cdn/components.js +1 -1
- package/cdn/loader.js +2 -2
- package/cdn/{sprinkles.css.ts.vanilla.BtFkD4B3.js → sprinkles.css.ts.vanilla.Ct795MMK.js} +2 -2
- package/cdn/useGlobalComponents.CLH7id-Y.js +1 -0
- package/cdn/useLightDomStyles.DqYouFn3.js +1 -0
- package/cdn/usePlacement.Di6eZ4ty.js +58 -0
- package/cdn/{useReward.CFLuyrnp.js → useReward.DJwgphI1.js} +1 -1
- package/cdn/{useShareModal.CFGxjQwU.js → useShareModal.UYsKX7L2.js} +1 -1
- package/dist/banner.js +39 -6
- package/dist/buttonShare.js +15 -6
- package/dist/buttonWallet.js +1 -3
- package/dist/openInApp.js +12 -8
- package/dist/postPurchase.js +33 -5
- package/dist/{useLightDomStyles-hgYYZsTy.js → useLightDomStyles-C3lcOwY2.js} +1 -1
- package/dist/{usePlacement-LqYjZLX_.js → usePlacement-V7NrKoub.js} +7 -2
- package/dist/{useShareModal-DgEf5WWG.js → useShareModal-BEVkLrBP.js} +3 -2
- package/package.json +3 -3
- package/cdn/Banner.BgUl0DMr.js +0 -162
- package/cdn/ButtonShare.Cc__fiXP.js +0 -1
- package/cdn/ButtonWallet.B0vExdC3.js +0 -40
- package/cdn/OpenInAppButton.BVOJjDBC.js +0 -1
- package/cdn/PostPurchase.BRVW43vD.js +0 -52
- package/cdn/useGlobalComponents.BRe8dKO7.js +0 -1
- package/cdn/useLightDomStyles.ZFa154u8.js +0 -1
- package/cdn/usePlacement.B7jMsQvP.js +0 -58
package/cdn/loader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function n(e,{strict:t=!0}={}){return!e||typeof e!=`string`?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith(`0x`)}function r(e){return n(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const i=`2.47.16`;let a={getDocsUrl:({docsBaseUrl:e,docsPath:t=``,docsSlug:n})=>t?`${e??`https://viem.sh`}${t}${n?`#${n}`:``}`:void 0,version:`viem@${i}`};var o=class e extends Error{constructor(t,n={}){let r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,o=n.cause instanceof e&&n.cause.docsPath||n.docsPath,s=a.getDocsUrl?.({...n,docsPath:o}),c=[t||`An error occurred.`,``,...n.metaMessages?[...n.metaMessages,``]:[],...s?[`Docs: ${s}`]:[],...r?[`Details: ${r}`]:[],...a.version?[`Version: ${a.version}`]:[]].join(`
|
|
2
|
-
`);super(c,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=o,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=i}walk(e){return s(this,e)}};function s(e,t){return t?.(e)?e:e&&typeof e==`object`&&`cause`in e&&e.cause!==void 0?s(e.cause,t):t?null:e}var c=class extends o{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 l(e,{dir:t,size:n=32}={}){return typeof e==`string`?u(e,{dir:t,size:n}):d(e,{dir:t,size:n})}function u(e,{dir:t,size:n=32}={}){if(n===null)return e;let r=e.replace(`0x`,``);if(r.length>n*2)throw new c({size:Math.ceil(r.length/2),targetSize:n,type:`hex`});return`0x${r[t===`right`?`padEnd`:`padStart`](n*2,`0`)}`}function d(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new c({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 f=class extends o{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`})}},p=class extends o{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:`SizeOverflowError`})}};function m(e,{size:t}){if(r(e)>t)throw new p({givenSize:r(e),maxSize:t})}const ee=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function h(e,t={}){return typeof e==`number`||typeof e==`bigint`?ne(e,t):typeof e==`string`?ie(e,t):typeof e==`boolean`?te(e,t):g(e,t)}function te(e,t={}){let n=`0x${Number(e)}`;return typeof t.size==`number`?(m(n,{size:t.size}),l(n,{size:t.size})):n}function g(e,t={}){let n=``;for(let t=0;t<e.length;t++)n+=ee[e[t]];let r=`0x${n}`;return typeof t.size==`number`?(m(r,{size:t.size}),l(r,{dir:`right`,size:t.size})):r}function ne(e,t={}){let{signed:n,size:r}=t,i=BigInt(e),a;r?a=n?(1n<<BigInt(r)*8n-1n)-1n:2n**(BigInt(r)*8n)-1n:typeof e==`number`&&(a=BigInt(2**53-1));let o=typeof a==`bigint`&&n?-a-1n:0;if(a&&i>a||i<o){let t=typeof e==`bigint`?`n`:``;throw new f({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?l(s,{size:r}):s}const re=new TextEncoder;function ie(e,t={}){return g(re.encode(e),t)}const ae=new TextEncoder;function oe(e,t={}){return typeof e==`number`||typeof e==`bigint`?ue(e,t):typeof e==`boolean`?se(e,t):n(e)?le(e,t):de(e,t)}function se(e,t={}){let n=new Uint8Array(1);return n[0]=Number(e),typeof t.size==`number`?(m(n,{size:t.size}),l(n,{size:t.size})):n}const _={zero:48,nine:57,A:65,F:70,a:97,f:102};function ce(e){if(e>=_.zero&&e<=_.nine)return e-_.zero;if(e>=_.A&&e<=_.F)return e-(_.A-10);if(e>=_.a&&e<=_.f)return e-(_.a-10)}function le(e,t={}){let n=e;t.size&&(m(n,{size:t.size}),n=l(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=ce(r.charCodeAt(t++)),i=ce(r.charCodeAt(t++));if(n===void 0||i===void 0)throw new o(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);a[e]=n*16+i}return a}function ue(e,t){return le(ne(e,t))}function de(e,t={}){let n=ae.encode(e);return typeof t.size==`number`?(m(n,{size:t.size}),l(n,{dir:`right`,size:t.size})):n}const v=BigInt(2**32-1),fe=BigInt(32);function pe(e,t=!1){return t?{h:Number(e&v),l:Number(e>>fe&v)}:{h:Number(e>>fe&v)|0,l:Number(e&v)|0}}function me(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}=pe(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}const he=(e,t,n)=>e<<n|t>>>32-n,ge=(e,t,n)=>t<<n|e>>>32-n,_e=(e,t,n)=>t<<n-32|e>>>64-n,ve=(e,t,n)=>e<<n-32|t>>>64-n;function ye(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function be(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function y(e,...t){if(!ye(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function xe(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function Se(e,t){y(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function Ce(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function we(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const Te=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ee(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function De(e){for(let t=0;t<e.length;t++)e[t]=Ee(e[t]);return e}const Oe=Te?e=>e:De;typeof Uint8Array.from([]).toHex==`function`&&Uint8Array.fromHex;function ke(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function b(e){return typeof e==`string`&&(e=ke(e)),y(e),e}var Ae=class{};function je(e){let t=t=>e().update(b(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Me(e){let t=(t,n)=>e(n).update(b(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}const Ne=BigInt(0),x=BigInt(1),Pe=BigInt(2),Fe=BigInt(7),Ie=BigInt(256),Le=BigInt(113),Re=[],ze=[],Be=[];for(let e=0,t=x,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Re.push(2*(5*r+n)),ze.push((e+1)*(e+2)/2%64);let i=Ne;for(let e=0;e<7;e++)t=(t<<x^(t>>Fe)*Le)%Ie,t&Pe&&(i^=x<<(x<<BigInt(e))-x);Be.push(i)}const Ve=me(Be,!0),He=Ve[0],Ue=Ve[1],We=(e,t,n)=>n>32?_e(e,t,n):he(e,t,n),Ge=(e,t,n)=>n>32?ve(e,t,n):ge(e,t,n);function Ke(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=We(a,o,1)^n[r],c=Ge(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=ze[n],a=We(t,i,r),o=Ge(t,i,r),s=Re[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]^=He[r],e[1]^=Ue[r]}we(n)}var qe=class e extends Ae{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,be(n),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=Ce(this.state)}clone(){return this._cloneInto()}keccak(){Oe(this.state32),Ke(this.state32,this.rounds),Oe(this.state32),this.posOut=0,this.pos=0}update(e){xe(this),e=b(e),y(e);let{blockLen:t,state:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){xe(this,!1),y(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 be(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Se(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,we(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 S=(e,t,n)=>je(()=>new qe(t,e,n));S(6,144,224/8),S(6,136,256/8),S(6,104,384/8),S(6,72,512/8),S(1,144,224/8);const Je=S(1,136,256/8);S(1,104,384/8),S(1,72,512/8);const Ye=(e,t,n)=>Me((r={})=>new qe(t,e,r.dkLen===void 0?n:r.dkLen,!0));Ye(31,168,128/8),Ye(31,136,256/8);function Xe(e,t){let r=t||`hex`,i=Je(n(e,{strict:!1})?oe(e):e);return r===`bytes`?i:h(i)}var Ze=class extends o{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`})}},Qe=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)&&(super.delete(e),super.set(e,t)),t}set(e,t){if(super.has(e)&&super.delete(e),super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=super.keys().next().value;e!==void 0&&super.delete(e)}return this}};const $e=new Qe(8192);function et(e,t){if($e.has(`${e}.${t}`))return $e.get(`${e}.${t}`);let n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=Xe(de(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 $e.set(`${e}.${t}`,a),a}const tt=/^0x[a-fA-F0-9]{40}$/,nt=new Qe(8192);function C(e,t){let{strict:n=!0}=t??{},r=`${e}.${n}`;if(nt.has(r))return nt.get(r);let i=tt.test(e)?e.toLowerCase()===e?!0:n?et(e)===e:!0:!1;return nt.set(r,i),i}function rt(e,t){if(!C(e,{strict:!1}))throw new Ze({address:e});if(!C(t,{strict:!1}))throw new Ze({address:t});return e.toLowerCase()===t.toLowerCase()}let w=256,T;function it(e=11){if(!T||w+e>256*2){T=``,w=0;for(let e=0;e<256;e++)T+=(256+Math.random()*256|0).toString(16).substring(1)}return T.substring(w,w+++e)}const at={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 E=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}}},D=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 ot(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 ee(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}n.addEventListener(`message`,f);function h(e){let t=ee(),n=new D;return o.set(t,e=>{e.error?n.reject(new E(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 te(e,t){let n=ee();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 g(){n.removeEventListener(`message`,f),o.clear()}return{request:h,listen:te,sendLifecycle:m,cleanup:g}}function st(e){return new TextEncoder().encode(JSON.stringify(e))}function ct(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}const lt=`frak-client-id`;function ut(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function O(){if(typeof window>`u`||!window.localStorage)return console.warn(`[Frak SDK] No Window / localStorage available to save the clientId`),ut();let e=localStorage.getItem(lt);return e||(e=ut(),localStorage.setItem(lt,e)),e}function dt({domain:e}={}){return Xe(h((e??window.location.host).replace(`www.`,``)))}function ft(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function k(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 pt(e){return ft(st(e))}function mt(e,t,n,r,i,a){let o=pt(ht({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:a,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:i})),s=new URL(e);return s.pathname=`/sso`,s.searchParams.set(`p`,o),s.toString()}function ht(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const gt=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,_t=`frak-sso`;async function vt(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??mt(i??`https://wallet.frak.id`,t,dt(),n.name,O(),r?.css),o=window.open(a,_t,gt);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 yt=`https://backend.frak.id`;function bt(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function xt(e){return bt(e)?`https://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:yt}function A(e){if(e)return xt(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return xt(e)}return yt}var j=class extends Map{maxSize;constructor(e){super(),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&(super.delete(e),super.set(e,t)),t}set(e,t){if(super.has(e)&&super.delete(e),super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=super.keys().next().value;e!==void 0&&super.delete(e)}return this}};const M=new j(1024),N=new j(1024),St=3e4,P=new j(1024);async function F(e,{cacheKey:t,cacheTime:n=St}){if(n>0){let e=N.get(t);if(e&&Date.now()-e.created<n)return e.data}let r=P.get(t);if(r&&Date.now()-r<1e3)throw Error(`Cache: ${t} recently failed, backing off`);let i=M.get(t);i||(i=e(),M.set(t,i));try{let e=await i;return N.set(t,{data:e,created:Date.now()}),P.delete(t),e}catch(e){throw P.set(t,Date.now()),e}finally{M.delete(t)}}function Ct(e){return{clear:()=>{M.delete(e),N.delete(e)},has:(t=St)=>{let n=N.get(e);return n?Date.now()-n.created<t:!1}}}function I(){M.clear(),N.clear(),P.clear()}function wt(e){return ct(k(e))}function Tt(e){return`r`in e&&!(`v`in e)}function L(e){return`v`in e&&e.v===2}const Et=`fCtx`;function Dt(e){if(e)try{return L(e)?!e.c||!e.m||!e.t?void 0:pt({v:2,c:e.c,m:e.m,t:e.t}):ft(le(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function Ot(e){if(!(!e||e.length===0))try{let t=wt(e);if(t&&typeof t==`object`&&t.v===2)return t.c&&t.m&&t.t?{v:2,c:t.c,m:t.m,t:t.t}:void 0;let n=g(k(e),{size:20});if(C(n))return{r:n}}catch(t){console.error(`Error decompressing Frak context`,{e:t,context:e})}}function kt({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(Et);return t?Ot(t):null}const At=`frak`;function jt(e,t){let n=L(e);return{utm_source:t.utmSource??At,utm_medium:t.utmMedium??`referral`,utm_campaign:t.utmCampaign??(n?e.m:void 0),utm_content:t.utmContent,utm_term:t.utmTerm,via:t.via??At,ref:t.ref??(n?e.c:void 0)}}function Mt(e,t,n){let r=jt(t,n??{});for(let[t,n]of Object.entries(r))n===void 0||n===``||e.searchParams.has(t)||e.searchParams.set(t,n)}function Nt({url:e,context:t,attribution:n}){if(!e)return null;let r=Dt(t);if(!r)return null;let i=new URL(e);return i.searchParams.set(Et,r),Mt(i,t,n),i.toString()}function Pt(e){let t=new URL(e);return t.searchParams.delete(Et),t.toString()}function Ft({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?Pt(n):Nt({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const It={compress:Dt,decompress:Ot,parse:kt,update:Nt,remove:Pt,replaceUrl:Ft},R=`__frakSdkConfig`,Lt=`frak-config-cache`,z=`frak-merchant-id`,B={key:Lt},V=typeof window<`u`;function H(){return{isResolved:!1,merchantId:``}}let U=null;function Rt(){if(!V)return null;try{let e=localStorage.getItem(B.key);if(!e)return null;let t=JSON.parse(e);return t.config?.isResolved?(U=t,t):null}catch{return null}}function zt(){return(U??Rt())?.config}function Bt(){let e=U??Rt();return e?Date.now()-e.timestamp<3e4:!1}function Vt(e){if(!(!V||!e.isResolved))try{let t={config:e,timestamp:Date.now()};localStorage.setItem(B.key,JSON.stringify(t)),U=t}catch{}}function Ht(){if(V){U=null;try{localStorage.removeItem(B.key)}catch{}}}function Ut(){V&&(window[R]||(window[R]=zt()??H()))}Ut();function Wt(){return V?window[R]??H():H()}function Gt(e){V&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function Kt(e){return e??(V?window.location.hostname:``)}async function qt(e,t,n){try{let r=A(t),i=n?`&lang=${encodeURIComponent(n)}`:``,a=await fetch(`${r}/user/merchant/resolve?domain=${encodeURIComponent(e)}${i}`);if(!a.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${e}: ${a.status}`);return}let o=await a.json();if(V)try{sessionStorage.setItem(z,o.merchantId)}catch{}return o}catch(e){console.warn(`[Frak SDK] Failed to fetch merchant config:`,e);return}}const W={getConfig:Wt,get isResolved(){return Wt().isResolved},get isCacheFresh(){return Bt()},setCacheScope(e,t){B.key=`${Lt}:${`${e}:${t??``}`}`,U=null},setConfig(e){if(V&&(window[R]=e),Vt(e),Gt(e),V&&e.merchantId)try{sessionStorage.setItem(z,e.merchantId)}catch{}},reset(){let e=zt()??H();V&&(window[R]=e),Gt(e)},clearCache(){if(Ht(),I(),V)try{sessionStorage.removeItem(z)}catch{}},resolve(e,t,n){let r=Kt(e);return r?F(async()=>{let e=await qt(r,t,n);if(!e)throw Error(`Config resolution returned empty`);return e},{cacheKey:`sdkConfig:${r}:${n??``}`,cacheTime:1/0}).catch(()=>void 0):Promise.resolve(void 0)},getMerchantId(){let e=Wt();if(e.isResolved&&e.merchantId)return e.merchantId;if(V)try{return sessionStorage.getItem(z)??void 0}catch{}},async resolveMerchantId(e,t){return W.getMerchantId()||(await W.resolve(e,t))?.merchantId}};function G(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)}}function Jt(){return()=>{}}var Yt=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)}},Xt=class{constructor(e){this.groups=[],this.queue=[],this.options=e;let t={"openpanel-client-id":e.clientId};e.clientSecret&&(t[`openpanel-client-secret`]=e.clientSecret),t[`openpanel-sdk-name`]=e.sdk||`node`,t[`openpanel-sdk-version`]=e.sdkVersion||`1.3.0`,this.api=new Yt({baseUrl:e.apiUrl||`https://api.openpanel.dev`,defaultHeaders:t})}init(){}ready(){this.options.disabled=!1,this.options.waitForProfile=!1,this.flush()}shouldQueue(e){return!!(this.options.disabled||this.options.waitForProfile&&!this.profileId||e.type===`replay`&&!this.sessionId)}addQueue(e){e.type===`track`&&(e.payload.properties={...e.payload.properties??{},__timestamp:new Date().toISOString()}),this.queue.push(e)}async send(e){if(this.options.filter&&!this.options.filter(e))return Promise.resolve();if(this.shouldQueue(e))return this.addQueue(e),Promise.resolve();let t=await this.api.fetch(`/track`,e,{keepalive:e.type!==`replay`});this.deviceId=t?.deviceId;let n=!!this.sessionId;return this.sessionId=t?.sessionId,!n&&this.sessionId&&this.flush(),t}setGlobalProperties(e){this.global={...this.global,...e}}track(e,t){this.log(`track event`,e,t);let{groups:n,profileId:r,...i}=t??{},a=[...new Set([...this.groups,...n??[]])];return this.send({type:`track`,payload:{name:e,profileId:r??this.profileId,groups:a.length>0?a:void 0,properties:{...this.global??{},...i}}})}identify(e){if(this.log(`identify user`,e),e.profileId&&(this.profileId=e.profileId,this.flush()),Object.keys(e).length>1)return this.send({type:`identify`,payload:{...e,properties:{...this.global,...e.properties}}})}upsertGroup(e){return this.log(`upsert group`,e),this.send({type:`group`,payload:e})}setGroup(e){return this.log(`set group`,e),this.groups.includes(e)||(this.groups=[...this.groups,e]),this.send({type:`assign_group`,payload:{groupIds:[e],profileId:this.profileId}})}setGroups(e){return this.log(`set groups`,e),this.groups=[...new Set([...this.groups,...e])],this.send({type:`assign_group`,payload:{groupIds:e,profileId:this.profileId}})}alias(e){}increment(e){return this.send({type:`increment`,payload:e})}decrement(e){return this.send({type:`decrement`,payload:e})}revenue(e,t){let n=t?.deviceId;return delete t?.deviceId,this.track(`revenue`,{...t??{},...n?{__deviceId:n}:{},__revenue:e})}getDeviceId(){return this.deviceId??``}getSessionId(){return this.sessionId??``}fetchDeviceId(){return Promise.resolve(this.deviceId??``)}clear(){this.profileId=void 0,this.groups=[],this.deviceId=void 0,this.sessionId=void 0}buildFlushPayload(e){if(e.type===`replay`)return e.payload;if(e.type===`track`){let t=`groups`in e.payload?e.payload.groups??[]:[],n=[...new Set([...this.groups,...t])];return{...e.payload,profileId:e.payload.profileId??this.profileId,groups:n.length>0?n:void 0}}return e.type===`identify`||e.type===`increment`||e.type===`decrement`||e.type===`assign_group`?{...e.payload,profileId:e.payload.profileId??this.profileId}:e.payload}flush(){let e=[];for(let t of this.queue){if(this.shouldQueue(t)){e.push(t);continue}let n=this.buildFlushPayload(t);this.send({...t,payload:n})}this.queue=e}log(...e){this.options.debug&&console.log(`[OpenPanel.dev]`,...e)}},Zt=Object.defineProperty,Qt=(e,t)=>()=>(e&&(t=e(e=0)),t),$t=(e,t)=>{for(var n in t)Zt(e,n,{get:t[n],enumerable:!0})};function en(e,t){if(typeof document>`u`||typeof window>`u`)return;K&&K();let n=e.maxEventsPerChunk??200,r=e.flushIntervalMs??1e4,i=e.maxPayloadBytes??1048576,a=[],o=0,s=null;function c(e){if(a.length===0)return;let n=JSON.stringify(a);if(new TextEncoder().encode(n).length>i){if(a.length>1){let t=Math.floor(a.length/2),n=a.slice(0,t),r=a.slice(t),i=e&&n.some(e=>e.type===2);a=n,c(i),a=r,c(!1);return}a=[];return}let r=a[0].timestamp,s=a[a.length-1].timestamp;try{t({chunk_index:o,events_count:a.length,is_full_snapshot:e,started_at:new Date(r).toISOString(),ended_at:new Date(s).toISOString(),payload:n}),o+=1,a=[]}catch(e){throw console.error(`[ReplayRecorder] sendChunk failed`,e),e}}function l(e){let t=e||a.some(e=>e.type===2);a.length>=n?c(t):e&&a.length>0&&c(!0)}let u=e.maskAllText!==!1,d=e.unmaskTextSelector,f=Jt({emit(e,t){a.push(e),l(!!t)},checkoutEveryNms:r,maskAllInputs:e.maskAllInputs??!0,maskTextSelector:u?`*`:`[data-openpanel-replay-mask]`,maskTextFn:u&&d?(e,t)=>t?.closest(d)?e:e.replace(/\S/g,`*`):void 0,blockSelector:e.blockSelector??`[data-openpanel-replay-block]`,blockClass:e.blockClass,ignoreSelector:e.ignoreSelector});s=setInterval(()=>{a.length>0&&c(a.some(e=>e.type===2))},r);function p(){document.visibilityState===`hidden`&&a.length>0&&c(a.some(e=>e.type===2))}function m(){a.length>0&&c(a.some(e=>e.type===2))}document.addEventListener(`visibilitychange`,p),window.addEventListener(`pagehide`,m),K=()=>{a.length>0&&c(a.some(e=>e.type===2)),s&&=(clearInterval(s),null),document.removeEventListener(`visibilitychange`,p),window.removeEventListener(`pagehide`,m),f?.(),K=null}}function tn(){K&&K()}var K,nn=Qt(()=>{K=null}),rn={};$t(rn,{startReplayRecorder:()=>en,stopReplayRecorder:()=>tn});var an=Qt(()=>{nn()}),on=typeof document<`u`?document.currentScript:null;function sn(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var cn=class extends Xt{constructor(e){if(super({sdk:`web`,sdkVersion:`1.3.0`,...e}),this.options=e,this.lastPath=``,this.pendingRevenues=[],!this.isServer()){try{let e=sessionStorage.getItem(`openpanel-pending-revenues`);if(e){let t=JSON.parse(e);Array.isArray(t)&&(this.pendingRevenues=t)}}catch{this.pendingRevenues=[]}if(this.setGlobalProperties({__referrer:document.referrer}),this.options.trackScreenViews&&(this.trackScreenViews(),setTimeout(()=>this.screenView(),0)),this.options.trackOutgoingLinks&&this.trackOutgoingLinks(),this.options.trackAttributes&&this.trackAttributes(),this.options.sessionReplay?.enabled){let e=this.options.sessionReplay.sampleRate??1;Math.random()<e&&this.loadReplayModule().then(e=>{e&&e.startReplayRecorder(this.options.sessionReplay,e=>{this.send({type:`replay`,payload:{...e}})})})}}}async loadReplayModule(){try{if(typeof __OPENPANEL_REPLAY_URL__<`u`){let e=on,t=this.options.sessionReplay?.scriptUrl||e?.src?.replace(`.js`,`-replay.js`)||`https://openpanel.dev/op1-replay.js`;return window.__openpanel_replay?window.__openpanel_replay:new Promise(e=>{let n=document.createElement(`script`);n.src=t,n.onload=()=>{e(window.__openpanel_replay??null)},n.onerror=()=>{console.warn(`[OpenPanel] Failed to load replay script from`,t),e(null)},document.head.appendChild(n)})}return await Promise.resolve().then(()=>(an(),rn))}catch(e){return console.warn(`[OpenPanel] Failed to load replay module`,e),null}}debounce(e,t){clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(e,t)}isServer(){return typeof document>`u`}trackOutgoingLinks(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`a`);if(n&&t){let e=n.getAttribute(`href`);if(e?.startsWith(`http`))try{let r=new URL(e),i=window.location.hostname;r.hostname!==i&&super.track(`link_out`,{href:e,text:n.innerText||n.getAttribute(`title`)||t.getAttribute(`alt`)||t.getAttribute(`title`)})}catch{}}})}trackScreenViews(){if(this.isServer())return;let e=history.pushState;history.pushState=function(...t){let n=e.apply(this,t);return window.dispatchEvent(new Event(`pushstate`)),window.dispatchEvent(new Event(`locationchange`)),n};let t=history.replaceState;history.replaceState=function(...e){let n=t.apply(this,e);return window.dispatchEvent(new Event(`replacestate`)),window.dispatchEvent(new Event(`locationchange`)),n},window.addEventListener(`popstate`,()=>{window.dispatchEvent(new Event(`locationchange`))});let n=()=>this.debounce(()=>this.screenView(),50);this.options.trackHashChanges?window.addEventListener(`hashchange`,n):window.addEventListener(`locationchange`,n)}trackAttributes(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`button`),r=t.closest(`a`),i=n?.getAttribute(`data-track`)?n:r?.getAttribute(`data-track`)?r:null;if(i){let e={};for(let t of i.attributes)t.name.startsWith(`data-`)&&t.name!==`data-track`&&(e[sn(t.name.replace(/^data-/,``))]=t.value);let t=i.getAttribute(`data-track`);t&&super.track(t,e)}})}track(e,t){return super.track(e,{...t,__path:this.lastPath})}screenView(e,t){if(this.isServer())return;let n,r;typeof e==`string`?(n=e,r=t):(n=window.location.href,r=e),this.lastPath!==n&&(this.lastPath=n,super.track(`screen_view`,{...r??{},__path:n,__title:document.title}))}async flushRevenue(){let e=this.pendingRevenues.map(e=>super.revenue(e.amount,e.properties));await Promise.all(e),this.clearRevenue()}clearRevenue(){if(this.pendingRevenues=[],!this.isServer())try{sessionStorage.removeItem(`openpanel-pending-revenues`)}catch{}}pendingRevenue(e,t){if(this.pendingRevenues.push({amount:e,properties:t}),!this.isServer())try{sessionStorage.setItem(`openpanel-pending-revenues`,JSON.stringify(this.pendingRevenues))}catch{}}};const q=`nexus-wallet-backup`,ln=`frakwallet://`;function un(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function dn(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;end`}function fn(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=un()&&J(e)?dn(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function J(e){return e.startsWith(ln)}const Y={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function X(e){return e&&e in Y?e:`eur`}function pn(e){return e?Y[e]??Y.eur:Y.eur}function mn(e,t){let n=pn(t),r=X(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function hn(e){return e?`${e}Amount`:`eurAmount`}const Z={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 gn({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);r.id=Z.id,r.name=Z.name,r.allow=Z.allow,r.style.zIndex=Z.style.zIndex.toString(),_n({iframe:r,isVisible:!1});let i=t?.walletUrl??e??`https://wallet.frak.id`,a=O();return r.src=`${i}/listener?clientId=${encodeURIComponent(a)}`,new Promise(e=>{r.addEventListener(`load`,()=>e(r)),document.body.appendChild(r)})}function _n({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 vn(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 yn(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent;return!!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1)}const bn=yn();function xn(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return e.includes(`instagram`)||e.includes(`fban`)||e.includes(`fbav`)||e.includes(`facebook`)}const Sn=xn();function Cn(e){bn&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:bn&&e.startsWith(`http://`)?window.location.href=`x-safari-http://${e.slice(7)}`:window.location.href=`https://backend.frak.id/common/social?u=${encodeURIComponent(e)}`}function wn({perCall:e,defaults:t,productUtmContent:n}){if(e===null)return;let r=e!==void 0,i=t!==void 0&&Object.keys(t).length>0;if(!r&&!i&&!(n!==void 0&&n!==``))return;let a={...t,...e??{}},o=n??e?.utmContent;return o!==void 0&&o!==``?a.utmContent=o:delete a.utmContent,a}function Tn(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 En=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,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 E?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`
|
|
2
|
+
`);super(c,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=o,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=i}walk(e){return s(this,e)}};function s(e,t){return t?.(e)?e:e&&typeof e==`object`&&`cause`in e&&e.cause!==void 0?s(e.cause,t):t?null:e}var c=class extends o{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 l(e,{dir:t,size:n=32}={}){return typeof e==`string`?u(e,{dir:t,size:n}):d(e,{dir:t,size:n})}function u(e,{dir:t,size:n=32}={}){if(n===null)return e;let r=e.replace(`0x`,``);if(r.length>n*2)throw new c({size:Math.ceil(r.length/2),targetSize:n,type:`hex`});return`0x${r[t===`right`?`padEnd`:`padStart`](n*2,`0`)}`}function d(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new c({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 f=class extends o{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`})}},p=class extends o{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:`SizeOverflowError`})}};function m(e,{size:t}){if(r(e)>t)throw new p({givenSize:r(e),maxSize:t})}const h=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function ee(e,t={}){return typeof e==`number`||typeof e==`bigint`?ne(e,t):typeof e==`string`?ie(e,t):typeof e==`boolean`?te(e,t):g(e,t)}function te(e,t={}){let n=`0x${Number(e)}`;return typeof t.size==`number`?(m(n,{size:t.size}),l(n,{size:t.size})):n}function g(e,t={}){let n=``;for(let t=0;t<e.length;t++)n+=h[e[t]];let r=`0x${n}`;return typeof t.size==`number`?(m(r,{size:t.size}),l(r,{dir:`right`,size:t.size})):r}function ne(e,t={}){let{signed:n,size:r}=t,i=BigInt(e),a;r?a=n?(1n<<BigInt(r)*8n-1n)-1n:2n**(BigInt(r)*8n)-1n:typeof e==`number`&&(a=BigInt(2**53-1));let o=typeof a==`bigint`&&n?-a-1n:0;if(a&&i>a||i<o){let t=typeof e==`bigint`?`n`:``;throw new f({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?l(s,{size:r}):s}const re=new TextEncoder;function ie(e,t={}){return g(re.encode(e),t)}const ae=new TextEncoder;function oe(e,t={}){return typeof e==`number`||typeof e==`bigint`?le(e,t):typeof e==`boolean`?se(e,t):n(e)?v(e,t):ue(e,t)}function se(e,t={}){let n=new Uint8Array(1);return n[0]=Number(e),typeof t.size==`number`?(m(n,{size:t.size}),l(n,{size:t.size})):n}const _={zero:48,nine:57,A:65,F:70,a:97,f:102};function ce(e){if(e>=_.zero&&e<=_.nine)return e-_.zero;if(e>=_.A&&e<=_.F)return e-(_.A-10);if(e>=_.a&&e<=_.f)return e-(_.a-10)}function v(e,t={}){let n=e;t.size&&(m(n,{size:t.size}),n=l(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=ce(r.charCodeAt(t++)),i=ce(r.charCodeAt(t++));if(n===void 0||i===void 0)throw new o(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);a[e]=n*16+i}return a}function le(e,t){return v(ne(e,t))}function ue(e,t={}){let n=ae.encode(e);return typeof t.size==`number`?(m(n,{size:t.size}),l(n,{dir:`right`,size:t.size})):n}const y=BigInt(2**32-1),de=BigInt(32);function fe(e,t=!1){return t?{h:Number(e&y),l:Number(e>>de&y)}:{h:Number(e>>de&y)|0,l:Number(e&y)|0}}function pe(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}=fe(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}const me=(e,t,n)=>e<<n|t>>>32-n,he=(e,t,n)=>t<<n|e>>>32-n,ge=(e,t,n)=>t<<n-32|e>>>64-n,_e=(e,t,n)=>e<<n-32|t>>>64-n;function ve(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function ye(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function b(e,...t){if(!ve(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 be(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 xe(e,t){b(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function Se(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ce(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const we=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Te(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Ee(e){for(let t=0;t<e.length;t++)e[t]=Te(e[t]);return e}const De=we?e=>e:Ee;typeof Uint8Array.from([]).toHex==`function`&&Uint8Array.fromHex;function Oe(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function ke(e){return typeof e==`string`&&(e=Oe(e)),b(e),e}var Ae=class{};function je(e){let t=t=>e().update(ke(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Me(e){let t=(t,n)=>e(n).update(ke(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}const Ne=BigInt(0),x=BigInt(1),Pe=BigInt(2),Fe=BigInt(7),Ie=BigInt(256),Le=BigInt(113),Re=[],ze=[],Be=[];for(let e=0,t=x,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Re.push(2*(5*r+n)),ze.push((e+1)*(e+2)/2%64);let i=Ne;for(let e=0;e<7;e++)t=(t<<x^(t>>Fe)*Le)%Ie,t&Pe&&(i^=x<<(x<<BigInt(e))-x);Be.push(i)}const Ve=pe(Be,!0),He=Ve[0],Ue=Ve[1],We=(e,t,n)=>n>32?ge(e,t,n):me(e,t,n),Ge=(e,t,n)=>n>32?_e(e,t,n):he(e,t,n);function Ke(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=We(a,o,1)^n[r],c=Ge(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=ze[n],a=We(t,i,r),o=Ge(t,i,r),s=Re[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]^=He[r],e[1]^=Ue[r]}Ce(n)}var qe=class e extends Ae{constructor(e,t,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,ye(n),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=Se(this.state)}clone(){return this._cloneInto()}keccak(){De(this.state32),Ke(this.state32,this.rounds),De(this.state32),this.posOut=0,this.pos=0}update(e){be(this),e=ke(e),b(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){be(this,!1),b(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return ye(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(xe(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,Ce(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 S=(e,t,n)=>je(()=>new qe(t,e,n));S(6,144,224/8),S(6,136,256/8),S(6,104,384/8),S(6,72,512/8),S(1,144,224/8);const Je=S(1,136,256/8);S(1,104,384/8),S(1,72,512/8);const Ye=(e,t,n)=>Me((r={})=>new qe(t,e,r.dkLen===void 0?n:r.dkLen,!0));Ye(31,168,128/8),Ye(31,136,256/8);function Xe(e,t){let r=t||`hex`,i=Je(n(e,{strict:!1})?oe(e):e);return r===`bytes`?i:ee(i)}var Ze=class extends o{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`})}},Qe=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)&&(super.delete(e),super.set(e,t)),t}set(e,t){if(super.has(e)&&super.delete(e),super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=super.keys().next().value;e!==void 0&&super.delete(e)}return this}};const $e=new Qe(8192);function et(e,t){if($e.has(`${e}.${t}`))return $e.get(`${e}.${t}`);let n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=Xe(ue(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 $e.set(`${e}.${t}`,a),a}const tt=/^0x[a-fA-F0-9]{40}$/,nt=new Qe(8192);function rt(e,t){let{strict:n=!0}=t??{},r=`${e}.${n}`;if(nt.has(r))return nt.get(r);let i=tt.test(e)?e.toLowerCase()===e?!0:n?et(e)===e:!0:!1;return nt.set(r,i),i}function it(e,t){if(!rt(e,{strict:!1}))throw new Ze({address:e});if(!rt(t,{strict:!1}))throw new Ze({address:t});return e.toLowerCase()===t.toLowerCase()}let C=256,w;function at(e=11){if(!w||C+e>256*2){w=``,C=0;for(let e=0;e<256;e++)w+=(256+Math.random()*256|0).toString(16).substring(1)}return w.substring(C,C+++e)}const T={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 E=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}}},D=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 ot(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 ee(e){let t=h(),n=new D;return o.set(t,e=>{e.error?n.reject(new E(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 te(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 g(){n.removeEventListener(`message`,f),o.clear()}return{request:ee,listen:te,sendLifecycle:m,cleanup:g}}function st(e){return new TextEncoder().encode(JSON.stringify(e))}function ct(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}const lt=`frak-client-id`;function ut(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function O(){if(typeof window>`u`||!window.localStorage)return console.warn(`[Frak SDK] No Window / localStorage available to save the clientId`),ut();let e=localStorage.getItem(lt);return e||(e=ut(),localStorage.setItem(lt,e)),e}function dt({domain:e}={}){return Xe(ee((e??window.location.host).replace(`www.`,``)))}function ft(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function k(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 A(e){return ft(st(e))}function pt(e,t,n,r,i,a){let o=A(mt({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:a,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:i})),s=new URL(e);return s.pathname=`/sso`,s.searchParams.set(`p`,o),s.toString()}function mt(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const ht=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,gt=`frak-sso`;async function _t(e,t){let{metadata:n,customizations:r,walletUrl:i}=e.config;if(t.openInSameWindow??!!t.redirectUrl)return await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]});let a=t.ssoPopupUrl??pt(i??`https://wallet.frak.id`,t,dt(),n.name,O(),r?.css),o=window.open(a,gt,ht);if(!o)throw Error(`Popup was blocked. Please allow popups for this site.`);return o.focus(),await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]})??{}}function j(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)}}const vt=`https://backend.frak.id`;function yt(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function bt(e){return yt(e)?`https://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:vt}function M(e){if(e)return bt(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return bt(e)}return vt}var N=class extends Map{maxSize;constructor(e){super(),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&(super.delete(e),super.set(e,t)),t}set(e,t){if(super.has(e)&&super.delete(e),super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=super.keys().next().value;e!==void 0&&super.delete(e)}return this}};const P=new N(1024),F=new N(1024),xt=3e4,I=new N(1024);async function L(e,{cacheKey:t,cacheTime:n=xt}){if(n>0){let e=F.get(t);if(e&&Date.now()-e.created<n)return e.data}let r=I.get(t);if(r&&Date.now()-r<1e3)throw Error(`Cache: ${t} recently failed, backing off`);let i=P.get(t);i||(i=e(),P.set(t,i));try{let e=await i;return F.set(t,{data:e,created:Date.now()}),I.delete(t),e}catch(e){throw I.set(t,Date.now()),e}finally{P.delete(t)}}function St(e){return{clear:()=>{P.delete(e),F.delete(e)},has:(t=xt)=>{let n=F.get(e);return n?Date.now()-n.created<t:!1}}}function Ct(){P.clear(),F.clear(),I.clear()}function wt(e){return ct(k(e))}function Tt(e){return`r`in e&&!(`v`in e)}function R(e){return`v`in e&&e.v===2}const z=`fCtx`;function Et(e){if(e)try{return R(e)?!e.m||!e.t||!e.c&&!e.w?void 0:A({v:2,m:e.m,t:e.t,...e.c?{c:e.c}:{},...e.w?{w:e.w}:{}}):ft(v(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function Dt(e){if(!(!e||e.length===0))try{let t=wt(e);if(t&&typeof t==`object`&&t.v===2)return!t.m||!t.t||!t.c&&!t.w?void 0:{v:2,m:t.m,t:t.t,...t.c?{c:t.c}:{},...t.w?{w:t.w}:{}};let n=g(k(e),{size:20});if(rt(n))return{r:n}}catch(t){console.error(`Error decompressing Frak context`,{e:t,context:e})}}function Ot({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(z);return t?Dt(t):null}const kt=`frak`;function At(e,t){let n=R(e);return{utm_source:t.utmSource??kt,utm_medium:t.utmMedium??`referral`,utm_campaign:t.utmCampaign??(n?e.m:void 0),utm_content:t.utmContent,utm_term:t.utmTerm,via:t.via??kt,ref:t.ref??(n?e.c:void 0)}}function jt(e,t,n){let r=At(t,n??{});for(let[t,n]of Object.entries(r))n===void 0||n===``||e.searchParams.has(t)||e.searchParams.set(t,n)}function Mt({url:e,context:t,attribution:n}){if(!e)return null;let r=Et(t);if(!r)return null;let i=new URL(e);return i.searchParams.set(z,r),jt(i,t,n),i.toString()}function Nt(e){let t=new URL(e);return t.searchParams.delete(z),t.toString()}function Pt({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?Nt(n):Mt({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const Ft={compress:Et,decompress:Dt,parse:Ot,update:Mt,remove:Nt,replaceUrl:Pt},B=`__frakSdkConfig`,It=`frak-config-cache`,V=`frak-merchant-id`,H={key:It},U=typeof window<`u`;function W(){return{isResolved:!1,merchantId:``}}let G=null;function Lt(){if(!U)return null;try{let e=localStorage.getItem(H.key);if(!e)return null;let t=JSON.parse(e);return t.config?.isResolved?(G=t,t):null}catch{return null}}function Rt(){return(G??Lt())?.config}function zt(){let e=G??Lt();return e?Date.now()-e.timestamp<3e4:!1}function Bt(e){if(!(!U||!e.isResolved))try{let t={config:e,timestamp:Date.now()};localStorage.setItem(H.key,JSON.stringify(t)),G=t}catch{}}function Vt(){if(U){G=null;try{localStorage.removeItem(H.key)}catch{}}}function Ht(){U&&(window[B]||(window[B]=Rt()??W()))}Ht();function Ut(){return U?window[B]??W():W()}function Wt(e){U&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function Gt(e){return e??(U?window.location.hostname:``)}async function Kt(e,t,n){try{let r=M(t),i=n?`&lang=${encodeURIComponent(n)}`:``,a=await fetch(`${r}/user/merchant/resolve?domain=${encodeURIComponent(e)}${i}`);if(!a.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${e}: ${a.status}`);return}let o=await a.json();if(U)try{sessionStorage.setItem(V,o.merchantId)}catch{}return o}catch(e){console.warn(`[Frak SDK] Failed to fetch merchant config:`,e);return}}const K={getConfig:Ut,get isResolved(){return Ut().isResolved},get isCacheFresh(){return zt()},setCacheScope(e,t){H.key=`${It}:${`${e}:${t??``}`}`,G=null},setConfig(e){if(U&&(window[B]=e),Bt(e),Wt(e),U&&e.merchantId)try{sessionStorage.setItem(V,e.merchantId)}catch{}},reset(){let e=Rt()??W();U&&(window[B]=e),Wt(e)},clearCache(){if(Vt(),Ct(),U)try{sessionStorage.removeItem(V)}catch{}},resolve(e,t,n){let r=Gt(e);return r?L(async()=>{let e=await Kt(r,t,n);if(!e)throw Error(`Config resolution returned empty`);return e},{cacheKey:`sdkConfig:${r}:${n??``}`,cacheTime:1/0}).catch(()=>void 0):Promise.resolve(void 0)},getMerchantId(){let e=Ut();if(e.isResolved&&e.merchantId)return e.merchantId;if(U)try{return sessionStorage.getItem(V)??void 0}catch{}},async resolveMerchantId(e,t){return K.getMerchantId()||(await K.resolve(e,t))?.merchantId}};function qt(){return()=>{}}var Jt=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)}},Yt=class{constructor(e){this.groups=[],this.queue=[],this.options=e;let t={"openpanel-client-id":e.clientId};e.clientSecret&&(t[`openpanel-client-secret`]=e.clientSecret),t[`openpanel-sdk-name`]=e.sdk||`node`,t[`openpanel-sdk-version`]=e.sdkVersion||`1.3.0`,this.api=new Jt({baseUrl:e.apiUrl||`https://api.openpanel.dev`,defaultHeaders:t})}init(){}ready(){this.options.disabled=!1,this.options.waitForProfile=!1,this.flush()}shouldQueue(e){return!!(this.options.disabled||this.options.waitForProfile&&!this.profileId||e.type===`replay`&&!this.sessionId)}addQueue(e){e.type===`track`&&(e.payload.properties={...e.payload.properties??{},__timestamp:new Date().toISOString()}),this.queue.push(e)}async send(e){if(this.options.filter&&!this.options.filter(e))return Promise.resolve();if(this.shouldQueue(e))return this.addQueue(e),Promise.resolve();let t=await this.api.fetch(`/track`,e,{keepalive:e.type!==`replay`});this.deviceId=t?.deviceId;let n=!!this.sessionId;return this.sessionId=t?.sessionId,!n&&this.sessionId&&this.flush(),t}setGlobalProperties(e){this.global={...this.global,...e}}track(e,t){this.log(`track event`,e,t);let{groups:n,profileId:r,...i}=t??{},a=[...new Set([...this.groups,...n??[]])];return this.send({type:`track`,payload:{name:e,profileId:r??this.profileId,groups:a.length>0?a:void 0,properties:{...this.global??{},...i}}})}identify(e){if(this.log(`identify user`,e),e.profileId&&(this.profileId=e.profileId,this.flush()),Object.keys(e).length>1)return this.send({type:`identify`,payload:{...e,properties:{...this.global,...e.properties}}})}upsertGroup(e){return this.log(`upsert group`,e),this.send({type:`group`,payload:e})}setGroup(e){return this.log(`set group`,e),this.groups.includes(e)||(this.groups=[...this.groups,e]),this.send({type:`assign_group`,payload:{groupIds:[e],profileId:this.profileId}})}setGroups(e){return this.log(`set groups`,e),this.groups=[...new Set([...this.groups,...e])],this.send({type:`assign_group`,payload:{groupIds:e,profileId:this.profileId}})}alias(e){}increment(e){return this.send({type:`increment`,payload:e})}decrement(e){return this.send({type:`decrement`,payload:e})}revenue(e,t){let n=t?.deviceId;return delete t?.deviceId,this.track(`revenue`,{...t??{},...n?{__deviceId:n}:{},__revenue:e})}getDeviceId(){return this.deviceId??``}getSessionId(){return this.sessionId??``}fetchDeviceId(){return Promise.resolve(this.deviceId??``)}clear(){this.profileId=void 0,this.groups=[],this.deviceId=void 0,this.sessionId=void 0}buildFlushPayload(e){if(e.type===`replay`)return e.payload;if(e.type===`track`){let t=`groups`in e.payload?e.payload.groups??[]:[],n=[...new Set([...this.groups,...t])];return{...e.payload,profileId:e.payload.profileId??this.profileId,groups:n.length>0?n:void 0}}return e.type===`identify`||e.type===`increment`||e.type===`decrement`||e.type===`assign_group`?{...e.payload,profileId:e.payload.profileId??this.profileId}:e.payload}flush(){let e=[];for(let t of this.queue){if(this.shouldQueue(t)){e.push(t);continue}let n=this.buildFlushPayload(t);this.send({...t,payload:n})}this.queue=e}log(...e){this.options.debug&&console.log(`[OpenPanel.dev]`,...e)}},Xt=Object.defineProperty,Zt=(e,t)=>()=>(e&&(t=e(e=0)),t),Qt=(e,t)=>{for(var n in t)Xt(e,n,{get:t[n],enumerable:!0})};function $t(e,t){if(typeof document>`u`||typeof window>`u`)return;q&&q();let n=e.maxEventsPerChunk??200,r=e.flushIntervalMs??1e4,i=e.maxPayloadBytes??1048576,a=[],o=0,s=null;function c(e){if(a.length===0)return;let n=JSON.stringify(a);if(new TextEncoder().encode(n).length>i){if(a.length>1){let t=Math.floor(a.length/2),n=a.slice(0,t),r=a.slice(t),i=e&&n.some(e=>e.type===2);a=n,c(i),a=r,c(!1);return}a=[];return}let r=a[0].timestamp,s=a[a.length-1].timestamp;try{t({chunk_index:o,events_count:a.length,is_full_snapshot:e,started_at:new Date(r).toISOString(),ended_at:new Date(s).toISOString(),payload:n}),o+=1,a=[]}catch(e){throw console.error(`[ReplayRecorder] sendChunk failed`,e),e}}function l(e){let t=e||a.some(e=>e.type===2);a.length>=n?c(t):e&&a.length>0&&c(!0)}let u=e.maskAllText!==!1,d=e.unmaskTextSelector,f=qt({emit(e,t){a.push(e),l(!!t)},checkoutEveryNms:r,maskAllInputs:e.maskAllInputs??!0,maskTextSelector:u?`*`:`[data-openpanel-replay-mask]`,maskTextFn:u&&d?(e,t)=>t?.closest(d)?e:e.replace(/\S/g,`*`):void 0,blockSelector:e.blockSelector??`[data-openpanel-replay-block]`,blockClass:e.blockClass,ignoreSelector:e.ignoreSelector});s=setInterval(()=>{a.length>0&&c(a.some(e=>e.type===2))},r);function p(){document.visibilityState===`hidden`&&a.length>0&&c(a.some(e=>e.type===2))}function m(){a.length>0&&c(a.some(e=>e.type===2))}document.addEventListener(`visibilitychange`,p),window.addEventListener(`pagehide`,m),q=()=>{a.length>0&&c(a.some(e=>e.type===2)),s&&=(clearInterval(s),null),document.removeEventListener(`visibilitychange`,p),window.removeEventListener(`pagehide`,m),f?.(),q=null}}function en(){q&&q()}var q,tn=Zt(()=>{q=null}),nn={};Qt(nn,{startReplayRecorder:()=>$t,stopReplayRecorder:()=>en});var rn=Zt(()=>{tn()}),an=typeof document<`u`?document.currentScript:null;function on(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var sn=class extends Yt{constructor(e){if(super({sdk:`web`,sdkVersion:`1.3.0`,...e}),this.options=e,this.lastPath=``,this.pendingRevenues=[],!this.isServer()){try{let e=sessionStorage.getItem(`openpanel-pending-revenues`);if(e){let t=JSON.parse(e);Array.isArray(t)&&(this.pendingRevenues=t)}}catch{this.pendingRevenues=[]}if(this.setGlobalProperties({__referrer:document.referrer}),this.options.trackScreenViews&&(this.trackScreenViews(),setTimeout(()=>this.screenView(),0)),this.options.trackOutgoingLinks&&this.trackOutgoingLinks(),this.options.trackAttributes&&this.trackAttributes(),this.options.sessionReplay?.enabled){let e=this.options.sessionReplay.sampleRate??1;Math.random()<e&&this.loadReplayModule().then(e=>{e&&e.startReplayRecorder(this.options.sessionReplay,e=>{this.send({type:`replay`,payload:{...e}})})})}}}async loadReplayModule(){try{if(typeof __OPENPANEL_REPLAY_URL__<`u`){let e=an,t=this.options.sessionReplay?.scriptUrl||e?.src?.replace(`.js`,`-replay.js`)||`https://openpanel.dev/op1-replay.js`;return window.__openpanel_replay?window.__openpanel_replay:new Promise(e=>{let n=document.createElement(`script`);n.src=t,n.onload=()=>{e(window.__openpanel_replay??null)},n.onerror=()=>{console.warn(`[OpenPanel] Failed to load replay script from`,t),e(null)},document.head.appendChild(n)})}return await Promise.resolve().then(()=>(rn(),nn))}catch(e){return console.warn(`[OpenPanel] Failed to load replay module`,e),null}}debounce(e,t){clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(e,t)}isServer(){return typeof document>`u`}trackOutgoingLinks(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`a`);if(n&&t){let e=n.getAttribute(`href`);if(e?.startsWith(`http`))try{let r=new URL(e),i=window.location.hostname;r.hostname!==i&&super.track(`link_out`,{href:e,text:n.innerText||n.getAttribute(`title`)||t.getAttribute(`alt`)||t.getAttribute(`title`)})}catch{}}})}trackScreenViews(){if(this.isServer())return;let e=history.pushState;history.pushState=function(...t){let n=e.apply(this,t);return window.dispatchEvent(new Event(`pushstate`)),window.dispatchEvent(new Event(`locationchange`)),n};let t=history.replaceState;history.replaceState=function(...e){let n=t.apply(this,e);return window.dispatchEvent(new Event(`replacestate`)),window.dispatchEvent(new Event(`locationchange`)),n},window.addEventListener(`popstate`,()=>{window.dispatchEvent(new Event(`locationchange`))});let n=()=>this.debounce(()=>this.screenView(),50);this.options.trackHashChanges?window.addEventListener(`hashchange`,n):window.addEventListener(`locationchange`,n)}trackAttributes(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`button`),r=t.closest(`a`),i=n?.getAttribute(`data-track`)?n:r?.getAttribute(`data-track`)?r:null;if(i){let e={};for(let t of i.attributes)t.name.startsWith(`data-`)&&t.name!==`data-track`&&(e[on(t.name.replace(/^data-/,``))]=t.value);let t=i.getAttribute(`data-track`);t&&super.track(t,e)}})}track(e,t){return super.track(e,{...t,__path:this.lastPath})}screenView(e,t){if(this.isServer())return;let n,r;typeof e==`string`?(n=e,r=t):(n=window.location.href,r=e),this.lastPath!==n&&(this.lastPath=n,super.track(`screen_view`,{...r??{},__path:n,__title:document.title}))}async flushRevenue(){let e=this.pendingRevenues.map(e=>super.revenue(e.amount,e.properties));await Promise.all(e),this.clearRevenue()}clearRevenue(){if(this.pendingRevenues=[],!this.isServer())try{sessionStorage.removeItem(`openpanel-pending-revenues`)}catch{}}pendingRevenue(e,t){if(this.pendingRevenues.push({amount:e,properties:t}),!this.isServer())try{sessionStorage.setItem(`openpanel-pending-revenues`,JSON.stringify(this.pendingRevenues))}catch{}}};const J=`nexus-wallet-backup`,cn=`frakwallet://`;function ln(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function un(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;end`}function dn(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=ln()&&fn(e)?un(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function fn(e){return e.startsWith(cn)}const Y={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function X(e){return e&&e in Y?e:`eur`}function pn(e){return e?Y[e]??Y.eur:Y.eur}function mn(e,t){let n=pn(t),r=X(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function hn(e){return e?`${e}Amount`:`eurAmount`}const Z={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 gn({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);r.id=Z.id,r.name=Z.name,r.allow=Z.allow,r.style.zIndex=Z.style.zIndex.toString(),_n({iframe:r,isVisible:!1});let i=t?.walletUrl??e??`https://wallet.frak.id`,a=O();return r.src=`${i}/listener?clientId=${encodeURIComponent(a)}`,new Promise(e=>{r.addEventListener(`load`,()=>e(r)),document.body.appendChild(r)})}function _n({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 vn(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 yn(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent;return!!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1)}const bn=yn();function xn(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return e.includes(`instagram`)||e.includes(`fban`)||e.includes(`fbav`)||e.includes(`facebook`)}const Sn=xn();function Cn(e){bn&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:bn&&e.startsWith(`http://`)?window.location.href=`x-safari-http://${e.slice(7)}`:window.location.href=`https://backend.frak.id/common/social?u=${encodeURIComponent(e)}`}function wn({perCall:e,defaults:t,productUtmContent:n}){if(e===null)return;let r=e!==void 0,i=t!==void 0&&Object.keys(t).length>0;if(!r&&!i&&!(n!==void 0&&n!==``))return;let a={...t,...e??{}},o=n??e?.utmContent;return o!==void 0&&o!==``?a.utmContent=o:delete a.utmContent,a}function Tn(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 En=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,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 E?r=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?r=e.message:typeof e==`string`&&(r=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):`no-config`,navigatorInfo:n?this.base64Encode(n):`no-navigator`,iframeStatus:t?this.base64Encode(t):`not-iframe`,lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):`No Frak request logged`,lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):`No Frak response logged`,clientStatus:this.isSetupDone?`setup`:`not-setup`,error:r}}static empty(){return new e}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
|
|
3
3
|
Debug Information:
|
|
4
4
|
-----------------
|
|
5
5
|
Timestamp: ${t.timestamp}
|
|
@@ -11,4 +11,4 @@ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],en
|
|
|
11
11
|
Last Response: ${t.lastResponse}
|
|
12
12
|
Client Status: ${t.clientStatus}
|
|
13
13
|
Error: ${t.error}
|
|
14
|
-
`.trim()}};const Dn=(()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent;if(!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1))return!1;let t=e.toLowerCase();return t.includes(`instagram`)||t.includes(`fban`)||t.includes(`fbav`)||t.includes(`facebook`)})();function On(e){e?localStorage.setItem(q,e):localStorage.removeItem(q)}function kn(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=Mn(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function An(e){let t=new URL(window.location.href);e&&t.searchParams.set(`fmt`,e);let n=t.protocol===`http:`?`x-safari-http`:`x-safari-https`;window.location.href=`${n}://${t.host}${t.pathname}${t.search}${t.hash}`}function jn(e){return e.includes(`/common/social`)}function Mn(e,t){if(!t)return e;try{let n=new URL(e);return n.searchParams.set(`fmt`,t),n.toString()}catch{return`${e}${e.includes(`?`)?`&`:`?`}fmt=${encodeURIComponent(t)}`}}function Nn(e,t,n,r,i){if(i){let e=kn(t,r);window.open(e,`_blank`);return}if(J(t)){let i=kn(t,r);fn(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(Dn&&jn(t))An(r);else{let e=kn(t,r);window.location.href=e}}function Pn({iframe:e,targetOrigin:t}){let n=new D;return{handleEvent:r=>{if(!(`iframeLifecycle`in r))return;let{iframeLifecycle:i,data:a}=r;switch(i){case`connected`:n.resolve(!0);break;case`do-backup`:On(a.backup);break;case`remove-backup`:localStorage.removeItem(q);break;case`show`:case`hide`:_n({iframe:e,isVisible:i===`show`});break;case`redirect`:Nn(e,a.baseRedirectUrl,t,a.mergeToken,a.openInNewTab);break}},isConnected:n.promise}}function Fn({config:e,iframe:t}){let n=e?.walletUrl??`https://wallet.frak.id`,r=typeof navigator<`u`?navigator.language?.split(`-`)[0]:void 0,i=e.metadata.lang??(r===`en`||r===`fr`?r:void 0),a=e.domain??(typeof window<`u`?window.location.hostname:``);W.setCacheScope(a,i),W.reset();let o=W.isCacheFresh?void 0:W.resolve(e.domain,e.walletUrl,i),s=Pn({iframe:t,targetOrigin:n}),c=new D,l=new En(e,t);if(!t.contentWindow)throw new E(at.configError,`The iframe does not have a content window`);let u=ot({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await s.isConnected)throw new E(at.clientNotConnected,`The iframe provider isn't connected yet`);return await c.promise,t}},{onRequest(e,t){return l.setLastRequest(e),t},onResponse(e,t){return l.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:(e,t)=>{s.handleEvent(e)}}}),d=In(u,s),f=async()=>{d(),u.cleanup(),t.remove(),I(),W.clearCache(),W.reset()},p;console.log(`[Frak SDK] Initializing OpenPanel`),p=new cn({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:`1.0.0`,userAnonymousClientId:O()}),!0)}),p.setGlobalProperties({sdkVersion:`1.0.0`,userAnonymousClientId:O()}),p.init();let m=Ln({config:e,rpcClient:u,lifecycleManager:s,configPromise:o,contextSent:c}).then(()=>l.updateSetupStatus(!0)).catch(e=>{throw c.reject(e),e});return{config:e,debugInfo:l,waitForConnection:s.isConnected,waitForSetup:m,request:u.request,listenerRequest:u.listen,destroy:f,openPanel:p}}function In(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 Ln({config:e,rpcClient:t,lifecycleManager:n,configPromise:r,contextSent:i}){await n.isConnected,Tn(t,n.isConnected);let a=new URL(window.location.href),o=a.searchParams.get(`fmt`)??void 0;o&&(a.searchParams.delete(`fmt`),window.history.replaceState({},``,a.toString()));let s=t=>{let n=t?.merchantId??e.metadata.merchantId??``,r=t?.domain??``,i=t?.allowedDomains??[],a=t?.sdkConfig,o=a?.attribution||e.attribution?{...e.attribution,...a?.attribution}:void 0;W.setConfig(a?{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,hasRawSdkConfig:!0,name:a.name??e.metadata.name,logoUrl:a.logoUrl??e.metadata.logoUrl,homepageLink:a.homepageLink??e.metadata.homepageLink,lang:a.lang??e.metadata.lang,currency:a.currency??e.metadata.currency,hidden:a.hidden,css:a.css,translations:a.translations,placements:a.placements,components:a.components,attribution:o}:{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,name:e.metadata.name,logoUrl:e.metadata.logoUrl,homepageLink:e.metadata.homepageLink,lang:e.metadata.lang,currency:e.metadata.currency,attribution:o})},c=!1,l=e=>{let n=c?void 0:o;c=!0;let r=e.hasRawSdkConfig?{name:e.name,logoUrl:e.logoUrl,homepageLink:e.homepageLink,lang:e.lang,currency:e.currency,hidden:e.hidden,css:e.css,translations:e.translations,placements:e.placements,attribution:e.attribution}:e.attribution?{attribution:e.attribution}:void 0;t.sendLifecycle({clientLifecycle:`resolved-config`,data:{merchantId:e.merchantId,domain:e.domain??``,allowedDomains:e.allowedDomains??[],sourceUrl:window.location.href,...n&&{pendingMergeToken:n},...r&&{sdkConfig:r}}})};W.isResolved&&(l(W.getConfig()),i.resolve()),r&&(s(await r),l(W.getConfig()),i.resolve());async function u(){let n=e.customizations?.css;n&&t.sendLifecycle({clientLifecycle:`modal-css`,data:{cssLink:n}})}async function d(){let n=e.customizations?.i18n;n&&t.sendLifecycle({clientLifecycle:`modal-i18n`,data:{i18n:n}})}async function f(){if(typeof window>`u`)return;let e=window.localStorage.getItem(q);e&&t.sendLifecycle({clientLifecycle:`restore-backup`,data:{backup:e}})}await Promise.allSettled([u(),d(),f()])}async function Rn({config:e}){let t=zn(e),n=await gn({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=Fn({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function zn(e){let t=X(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}var Bn=t({DEEP_LINK_SCHEME:()=>ln,DebugInfoGatherer:()=>En,FrakContextManager:()=>It,base64urlDecode:()=>k,base64urlEncode:()=>ft,baseIframeProps:()=>Z,clearAllCache:()=>I,compressJsonToB64:()=>pt,computeLegacyProductId:()=>dt,createIFrameFrakClient:()=>Fn,createIframe:()=>gn,decompressJsonFromB64:()=>wt,findIframeInOpener:()=>vn,formatAmount:()=>mn,generateSsoUrl:()=>mt,getBackendUrl:()=>A,getCache:()=>Ct,getClientId:()=>O,getCurrencyAmountKey:()=>hn,getSupportedCurrency:()=>X,getSupportedLocale:()=>pn,isChromiumAndroid:()=>un,isFrakDeepLink:()=>J,isIOS:()=>bn,isInAppBrowser:()=>Sn,isV1Context:()=>Tt,isV2Context:()=>L,locales:()=>Y,mergeAttribution:()=>wn,redirectToExternalBrowser:()=>Cn,sdkConfigStore:()=>W,setupClient:()=>Rn,ssoPopupFeatures:()=>gt,ssoPopupName:()=>_t,toAndroidIntentUrl:()=>dn,trackEvent:()=>G,triggerDeepLinkWithFallback:()=>fn,withCache:()=>F});function Vn(){return it(96)}async function Hn(e,t,n){return await e.request({method:`frak_displayEmbeddedWallet`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function Q(e,{steps:t,metadata:n},r){return await e.request({method:`frak_displayModal`,params:r?[t,n,e.config.metadata,r]:[t,n,e.config.metadata]})}async function Un(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function Wn(e){if(typeof window>`u`)return;let t=O();if(!t)return;let n=await W.resolveMerchantId();if(!n)return;let r=`frak-identity-ensured-${n}`;if(!window.sessionStorage.getItem(r))try{let i=A();(await fetch(`${i}/user/identity/ensure`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":e,"x-frak-client-id":t},body:JSON.stringify({merchantId:n})})).ok&&window.sessionStorage.setItem(r,`1`)}catch{}}async function Gn(e,t){return F(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:t?.cacheTime})}async function Kn(e,t){return F(()=>e.request({method:`frak_getMergeToken`}),{cacheKey:`frak_getMergeToken`,cacheTime:t?.cacheTime})}async function qn(e,t){return F(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:t?.cacheTime})}async function Jn(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function Yn(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t,{clientId:O()}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}function Xn(e,t,n){let r=typeof window<`u`?window.location.href:void 0;return L(t)?(G(e,`user_referred_started`,{properties:{referrerClientId:t.c,walletStatus:n?.key}}),Yn(e,{type:`arrival`,referrerClientId:t.c,referrerMerchantId:t.m,referralTimestamp:t.t,landingUrl:r}),!0):Tt(t)?(G(e,`user_referred_started`,{properties:{referrer:t.r,walletStatus:n?.key}}),Yn(e,{type:`arrival`,referrerWallet:t.r,landingUrl:r}),!0):!1}function Zn(e){let t=O();return t?{v:2,c:t,m:e,t:Math.floor(Date.now()/1e3)}:null}function Qn(e,t){return L(e)?O()===e.c:Tt(e)&&t?.wallet?rt(e.r,t.wallet):!1}function $n(e,{walletStatus:t,frakContext:n,options:r}){if(!n)return`no-referrer`;if(Qn(n,t))return`self-referral`;if(!Xn(e,n,t))return`no-referrer`;let i=L(n)?n.m:r?.merchantId,a=r?.alwaysAppendUrl&&i?Zn(i):null;return It.replaceUrl({url:window.location?.href,context:a}),G(e,`user_referred_completed`,{properties:{status:`success`}}),`success`}async function er(e,{options:t}={}){let n=It.parse({url:window.location.href}),r=await ir(e);try{return $n(e,{walletStatus:r,frakContext:n,options:t})}catch(e){console.warn(`Error processing referral`,{error:e})}}const tr=`frak:referral-success`;async function nr(e){try{await er(e)===`success`&&window.dispatchEvent(new Event(tr))}catch(e){console.warn(`[Frak] Referral setup failed`,e)}}async function rr(e){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let t=window.sessionStorage.getItem(`frak-wallet-interaction-token`),n=O();if(!t&&!n){console.warn(`[Frak] No identity found, skipping purchase check`);return}let r=e.merchantId??await W.resolveMerchantId();if(!r){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let i={Accept:`application/json`,"Content-Type":`application/json`};t&&(i[`x-wallet-sdk-auth`]=t),n&&(i[`x-frak-client-id`]=n);let a=A();await fetch(`${a}/user/track/purchase`,{method:`POST`,headers:i,body:JSON.stringify({customerId:e.customerId,orderId:e.orderId,token:e.token,merchantId:r})})}function ir(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(ar(e,t),t));let n=new D,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{ar(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function ar(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),Wn(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function or(e,{metadata:t,login:n}){return $(e,{steps:{login:n??{}},metadata:t})}function $(e,t){function n(n){return $(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return $(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return $(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function a(n,r){return n&&(t.metadata=n(t.metadata??{})),await Q(e,t,r)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function sr(e,{tx:t,metadata:n}){return(await Q(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function cr(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 Q(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??Vn(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var lr=t({REFERRAL_SUCCESS_EVENT:()=>tr,displayEmbeddedWallet:()=>Hn,displayModal:()=>Q,displaySharingPage:()=>Un,ensureIdentity:()=>Wn,getMerchantInformation:()=>Gn,getMergeToken:()=>Kn,getUserReferralStatus:()=>qn,modalBuilder:()=>or,openSso:()=>vt,prepareSso:()=>Jn,processReferral:()=>$n,referralInteraction:()=>er,sendInteraction:()=>Yn,sendTransaction:()=>sr,setupReferral:()=>nr,siweAuthenticate:()=>cr,trackPurchaseStatus:()=>rr,watchWalletStatus:()=>ir});async function ur(e,t){if(!window.FrakSetup?.client){console.error(`Frak client not found`);return}let n=window.FrakSetup?.modalWalletConfig??{};await Hn(window.FrakSetup.client,e?{...n,metadata:{...n.metadata,targetInteraction:e}}:n,t)}function dr(){`vibrate`in navigator?navigator.vibrate(10):console.log(`Vibration not supported`)}function fr(e,t){dr(),ur(e,t)}const pr=`frak:client`;function mr(){let e=new CustomEvent(pr);window.dispatchEvent(e)}function hr(e,t){if(window.FrakSetup?.client&&e===`add`){t();return}(e===`add`?window.addEventListener:window.removeEventListener)(pr,t,!1)}function gr(){return window.FrakSetup.core={...Bn,...lr},window.FrakSetup?.client?Promise.resolve():F(()=>_r(),{cacheKey:`frak-sdk-init`,cacheTime:1/0}).catch(()=>{})}async function _r(){if(!window.FrakSetup?.config)throw Error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`);console.log(`[Frak SDK] Starting initialization`);let e=await Rn({config:window.FrakSetup.config});if(!e)throw Error(`[Frak SDK] Failed to create client`);window.FrakSetup.client=e,console.log(`[Frak SDK] Client initialized successfully`),mr(),nr(e),vr()}function vr(){let e=new URLSearchParams(window.location.search).get(`frakAction`);e&&e===`share`&&(console.log(`[Frak SDK] Auto open query param found`),fr())}function yr(e){document.readyState===`complete`||document.readyState===`interactive`?setTimeout(e,1):document.addEventListener(`DOMContentLoaded`,e)}function br(e,t){let n=document.getElementById(e);if(n){n.textContent!==t&&(n.textContent=t);return}let r=document.createElement(`style`);r.id=e,r.textContent=t,document.head.appendChild(r)}function xr(e,t){br(`frak-base-${e}`,t)}function Sr(e,t,n){br(`frak-placement-${e}-${t}`,n)}const Cr={injectBase:xr,injectPlacement:Sr};Cr.injectBase(`fouce`,`frak-button-share:not(:defined), frak-button-wallet:not(:defined), frak-open-in-app:not(:defined), frak-post-purchase:not(:defined), frak-banner:not(:defined) { display: none !important; }`),yr(gr);const wr={"button-share":()=>import(`./ButtonShare.Cc__fiXP.js`),"button-wallet":()=>import(`./ButtonWallet.B0vExdC3.js`),"open-in-app":()=>import(`./OpenInAppButton.BVOJjDBC.js`),"post-purchase":()=>import(`./PostPurchase.BRVW43vD.js`),banner:()=>import(`./Banner.BgUl0DMr.js`)},Tr=new MutationObserver(e=>{for(let{addedNodes:t}of e)for(let e of Array.from(t))e.nodeType===Node.ELEMENT_NODE&&Er(e)});async function Er(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=>Dr(e)))}async function Dr(e){if(customElements.get(e))return Promise.resolve();try{let t=e.replace(/^frak-/i,``);if(!(t in wr))throw Error(`Component ${e} is not supported.`);await wr[t]()}catch(e){console.error(e)}}Er(document.body),Tr.observe(document.documentElement,{subtree:!0,childList:!0});export{G as C,W as S,E as T,mn as _,fr as a,ln as b,rr as c,Kn as d,Gn as f,Sn as g,Cn as h,hr as i,tr as l,En as m,yr as n,ur as o,Un as p,gr as r,or as s,Cr as t,qn as u,fn as v,at as w,hn as x,X as y};
|
|
14
|
+
`.trim()}};const Dn=(()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent;if(!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1))return!1;let t=e.toLowerCase();return t.includes(`instagram`)||t.includes(`fban`)||t.includes(`fbav`)||t.includes(`facebook`)})();function On(e){e?localStorage.setItem(J,e):localStorage.removeItem(J)}function kn(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=Mn(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function An(e){let t=new URL(window.location.href);e&&t.searchParams.set(`fmt`,e);let n=t.protocol===`http:`?`x-safari-http`:`x-safari-https`;window.location.href=`${n}://${t.host}${t.pathname}${t.search}${t.hash}`}function jn(e){return e.includes(`/common/social`)}function Mn(e,t){if(!t)return e;try{let n=new URL(e);return n.searchParams.set(`fmt`,t),n.toString()}catch{return`${e}${e.includes(`?`)?`&`:`?`}fmt=${encodeURIComponent(t)}`}}function Nn(e,t,n,r,i){if(i){let e=kn(t,r);window.open(e,`_blank`);return}if(fn(t)){let i=kn(t,r);dn(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(Dn&&jn(t))An(r);else{let e=kn(t,r);window.location.href=e}}function Pn({iframe:e,targetOrigin:t}){let n=new D;return{handleEvent:r=>{if(!(`iframeLifecycle`in r))return;let{iframeLifecycle:i,data:a}=r;switch(i){case`connected`:n.resolve(!0);break;case`do-backup`:On(a.backup);break;case`remove-backup`:localStorage.removeItem(J);break;case`show`:case`hide`:_n({iframe:e,isVisible:i===`show`});break;case`redirect`:Nn(e,a.baseRedirectUrl,t,a.mergeToken,a.openInNewTab);break}},isConnected:n.promise}}function Fn({config:e,iframe:t}){let n=e?.walletUrl??`https://wallet.frak.id`,r=typeof navigator<`u`?navigator.language?.split(`-`)[0]:void 0,i=e.metadata.lang??(r===`en`||r===`fr`?r:void 0),a=e.domain??(typeof window<`u`?window.location.hostname:``);K.setCacheScope(a,i),K.reset();let o=K.isCacheFresh?void 0:K.resolve(e.domain,e.walletUrl,i),s=Pn({iframe:t,targetOrigin:n}),c=new D,l=Date.now(),u=new En(e,t);if(!t.contentWindow)throw new E(T.configError,`The iframe does not have a content window`);let d=ot({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await s.isConnected)throw new E(T.clientNotConnected,`The iframe provider isn't connected yet`);return await c.promise,t}},{onRequest(e,t){return u.setLastRequest(e),t},onResponse(e,t){return u.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:(e,t)=>{s.handleEvent(e)}}}),f=In(d,s),p=async()=>{f(),d.cleanup(),t.remove(),Ct(),K.clearCache(),K.reset()},m;{console.log(`[Frak SDK] Initializing OpenPanel`),m=new sn({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:`1.0.0`,userAnonymousClientId:O()}),!0)}),m.setGlobalProperties({sdkVersion:`1.0.0`,userAnonymousClientId:O()}),m.init(),m.track(`sdk_initialized`,{sdkVersion:`1.0.0`});let e=!1,t=setTimeout(()=>{e||(e=!0,m?.track(`sdk_iframe_handshake_failed`,{reason:`timeout`}))},3e4);s.isConnected.then(()=>{e||(e=!0,clearTimeout(t),m?.track(`sdk_iframe_connected`,{handshake_duration_ms:Date.now()-l}))}).catch(()=>{e||(e=!0,clearTimeout(t),m?.track(`sdk_iframe_handshake_failed`,{reason:`unknown`}))})}let h=Ln({config:e,rpcClient:d,lifecycleManager:s,configPromise:o,contextSent:c,openPanel:m}).then(()=>u.updateSetupStatus(!0)).catch(e=>{throw c.reject(e),e});return{config:e,debugInfo:u,waitForConnection:s.isConnected,waitForSetup:h,request:d.request,listenerRequest:d.listen,destroy:p,openPanel:m}}function In(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 Ln({config:e,rpcClient:t,lifecycleManager:n,configPromise:r,contextSent:i,openPanel:a}){await n.isConnected,Tn(t,n.isConnected);let o=new URL(window.location.href),s=o.searchParams.get(`fmt`)??void 0;s&&(o.searchParams.delete(`fmt`),window.history.replaceState({},``,o.toString()));let c=t=>{let n=t?.merchantId??e.metadata.merchantId??``,r=t?.domain??``,i=t?.allowedDomains??[],a=t?.sdkConfig,o=a?.attribution||e.attribution?{...e.attribution,...a?.attribution}:void 0;K.setConfig(a?{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,hasRawSdkConfig:!0,name:a.name??e.metadata.name,logoUrl:a.logoUrl??e.metadata.logoUrl,homepageLink:a.homepageLink??e.metadata.homepageLink,lang:a.lang??e.metadata.lang,currency:a.currency??e.metadata.currency,hidden:a.hidden,css:a.css,translations:a.translations,placements:a.placements,components:a.components,attribution:o}:{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,name:e.metadata.name,logoUrl:e.metadata.logoUrl,homepageLink:e.metadata.homepageLink,lang:e.metadata.lang,currency:e.metadata.currency,attribution:o})},l=!1,u=e=>{let n=l?void 0:s;l=!0;let r=e.hasRawSdkConfig?{name:e.name,logoUrl:e.logoUrl,homepageLink:e.homepageLink,lang:e.lang,currency:e.currency,hidden:e.hidden,css:e.css,translations:e.translations,placements:e.placements,attribution:e.attribution}:e.attribution?{attribution:e.attribution}:void 0,i=O();if(a){let t=a.global??{};a.setGlobalProperties({...t,merchantId:e.merchantId,domain:e.domain??``})}t.sendLifecycle({clientLifecycle:`resolved-config`,data:{merchantId:e.merchantId,domain:e.domain??``,allowedDomains:e.allowedDomains??[],sourceUrl:window.location.href,...i&&{sdkAnonymousId:i},...n&&{pendingMergeToken:n},...r&&{sdkConfig:r}}})};K.isResolved&&(u(K.getConfig()),i.resolve()),r&&(c(await r),u(K.getConfig()),i.resolve());async function d(){let n=e.customizations?.css;n&&t.sendLifecycle({clientLifecycle:`modal-css`,data:{cssLink:n}})}async function f(){let n=e.customizations?.i18n;n&&t.sendLifecycle({clientLifecycle:`modal-i18n`,data:{i18n:n}})}async function p(){if(typeof window>`u`)return;let e=window.localStorage.getItem(J);e&&t.sendLifecycle({clientLifecycle:`restore-backup`,data:{backup:e}})}(await Promise.allSettled([d(),f(),p()])).some(e=>e.status===`rejected`)&&a?.track(`sdk_iframe_handshake_failed`,{reason:`asset_push`})}async function Rn({config:e}){let t=zn(e),n=await gn({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=Fn({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function zn(e){let t=X(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}var Bn=t({DEEP_LINK_SCHEME:()=>cn,DebugInfoGatherer:()=>En,FrakContextManager:()=>Ft,base64urlDecode:()=>k,base64urlEncode:()=>ft,baseIframeProps:()=>Z,clearAllCache:()=>Ct,compressJsonToB64:()=>A,computeLegacyProductId:()=>dt,createIFrameFrakClient:()=>Fn,createIframe:()=>gn,decompressJsonFromB64:()=>wt,findIframeInOpener:()=>vn,formatAmount:()=>mn,generateSsoUrl:()=>pt,getBackendUrl:()=>M,getCache:()=>St,getClientId:()=>O,getCurrencyAmountKey:()=>hn,getSupportedCurrency:()=>X,getSupportedLocale:()=>pn,isChromiumAndroid:()=>ln,isFrakDeepLink:()=>fn,isIOS:()=>bn,isInAppBrowser:()=>Sn,isV1Context:()=>Tt,isV2Context:()=>R,locales:()=>Y,mergeAttribution:()=>wn,redirectToExternalBrowser:()=>Cn,sdkConfigStore:()=>K,setupClient:()=>Rn,ssoPopupFeatures:()=>ht,ssoPopupName:()=>gt,toAndroidIntentUrl:()=>un,trackEvent:()=>j,triggerDeepLinkWithFallback:()=>dn,withCache:()=>L});function Vn(){return at(96)}async function Hn(e,t,n){return await e.request({method:`frak_displayEmbeddedWallet`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function Q(e,{steps:t,metadata:n},r){return await e.request({method:`frak_displayModal`,params:r?[t,n,e.config.metadata,r]:[t,n,e.config.metadata]})}async function Un(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function Wn(e){if(typeof window>`u`)return;let t=O();if(!t)return;let n=await K.resolveMerchantId();if(!n)return;let r=`frak-identity-ensured-${n}`;if(!window.sessionStorage.getItem(r))try{let i=M();(await fetch(`${i}/user/identity/ensure`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":e,"x-frak-client-id":t},body:JSON.stringify({merchantId:n})})).ok&&window.sessionStorage.setItem(r,`1`)}catch{}}async function Gn(e,t){return L(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:t?.cacheTime})}async function Kn(e,t){return L(()=>e.request({method:`frak_getMergeToken`}),{cacheKey:`frak_getMergeToken`,cacheTime:t?.cacheTime})}async function qn(e,t){return L(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:t?.cacheTime})}async function Jn(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function Yn(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t,{clientId:O()}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}function Xn(e,t,n){let r=typeof window<`u`?window.location.href:void 0;return R(t)?(j(e,`user_referred_started`,{referrerClientId:t.c,referrerWallet:t.w,walletStatus:n?.key}),Yn(e,{type:`arrival`,referrerClientId:t.c,referrerMerchantId:t.m,referrerWallet:t.w,referralTimestamp:t.t,landingUrl:r}),!0):Tt(t)?(j(e,`user_referred_started`,{referrer:t.r,walletStatus:n?.key}),Yn(e,{type:`arrival`,referrerWallet:t.r,landingUrl:r}),!0):!1}function Zn(e){let t=O();return t?{v:2,c:t,m:e,t:Math.floor(Date.now()/1e3)}:null}function Qn(e,t){return R(e)?e.w&&t?.wallet?it(e.w,t.wallet):e.c?O()===e.c:!1:Tt(e)&&t?.wallet?it(e.r,t.wallet):!1}function $n(e,{walletStatus:t,frakContext:n,options:r}){if(!n)return`no-referrer`;if(Qn(n,t))return`self-referral`;if(!Xn(e,n,t))return`no-referrer`;let i=R(n)?n.m:r?.merchantId,a=r?.alwaysAppendUrl&&i?Zn(i):null;return Ft.replaceUrl({url:window.location?.href,context:a}),j(e,`user_referred_completed`,{status:`success`}),`success`}async function er(e,{options:t}={}){let n=Ft.parse({url:window.location.href}),r=await ir(e);try{return $n(e,{walletStatus:r,frakContext:n,options:t})}catch(e){console.warn(`Error processing referral`,{error:e})}}const tr=`frak:referral-success`;async function nr(e){try{await er(e)===`success`&&window.dispatchEvent(new Event(tr))}catch(e){console.warn(`[Frak] Referral setup failed`,e)}}async function rr(e){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let t=window.sessionStorage.getItem(`frak-wallet-interaction-token`),n=O();if(!t&&!n){console.warn(`[Frak] No identity found, skipping purchase check`);return}let r=e.merchantId??await K.resolveMerchantId();if(!r){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let i={Accept:`application/json`,"Content-Type":`application/json`};t&&(i[`x-wallet-sdk-auth`]=t),n&&(i[`x-frak-client-id`]=n);let a=M();await fetch(`${a}/user/track/purchase`,{method:`POST`,headers:i,body:JSON.stringify({customerId:e.customerId,orderId:e.orderId,token:e.token,merchantId:r})})}function ir(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(ar(e,t),t));let n=new D,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{ar(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function ar(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),Wn(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function or(e,{metadata:t,login:n}){return $(e,{steps:{login:n??{}},metadata:t})}function $(e,t){function n(n){return $(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return $(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return $(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function a(n,r){return n&&(t.metadata=n(t.metadata??{})),await Q(e,t,r)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function sr(e,{tx:t,metadata:n}){return(await Q(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function cr(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 Q(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??Vn(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var lr=t({REFERRAL_SUCCESS_EVENT:()=>tr,displayEmbeddedWallet:()=>Hn,displayModal:()=>Q,displaySharingPage:()=>Un,ensureIdentity:()=>Wn,getMerchantInformation:()=>Gn,getMergeToken:()=>Kn,getUserReferralStatus:()=>qn,modalBuilder:()=>or,openSso:()=>_t,prepareSso:()=>Jn,processReferral:()=>$n,referralInteraction:()=>er,sendInteraction:()=>Yn,sendTransaction:()=>sr,setupReferral:()=>nr,siweAuthenticate:()=>cr,trackPurchaseStatus:()=>rr,watchWalletStatus:()=>ir});async function ur(e,t){if(!window.FrakSetup?.client){console.error(`Frak client not found`);return}let n=window.FrakSetup?.modalWalletConfig??{};await Hn(window.FrakSetup.client,e?{...n,metadata:{...n.metadata,targetInteraction:e}}:n,t)}function dr(){`vibrate`in navigator?navigator.vibrate(10):console.log(`Vibration not supported`)}function fr(e,t){dr(),ur(e,t)}const pr=`frak:client`;function mr(){let e=new CustomEvent(pr);window.dispatchEvent(e)}function hr(e,t){if(window.FrakSetup?.client&&e===`add`){t();return}(e===`add`?window.addEventListener:window.removeEventListener)(pr,t,!1)}function gr(){return window.FrakSetup.core={...Bn,...lr},window.FrakSetup?.client?Promise.resolve():L(()=>_r(),{cacheKey:`frak-sdk-init`,cacheTime:1/0}).catch(e=>{j(window.FrakSetup?.client,`sdk_init_failed`,{reason:e instanceof Error?e.message:typeof e==`string`?e:`unknown`,config_missing:!window.FrakSetup?.config})})}async function _r(){if(!window.FrakSetup?.config)throw Error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`);console.log(`[Frak SDK] Starting initialization`);let e=await Rn({config:window.FrakSetup.config});if(!e)throw Error(`[Frak SDK] Failed to create client`);window.FrakSetup.client=e,console.log(`[Frak SDK] Client initialized successfully`),mr(),nr(e),vr()}function vr(){let e=new URLSearchParams(window.location.search).get(`frakAction`);e&&e===`share`&&(console.log(`[Frak SDK] Auto open query param found`),fr())}function yr(e){document.readyState===`complete`||document.readyState===`interactive`?setTimeout(e,1):document.addEventListener(`DOMContentLoaded`,e)}function br(e,t){let n=document.getElementById(e);if(n){n.textContent!==t&&(n.textContent=t);return}let r=document.createElement(`style`);r.id=e,r.textContent=t,document.head.appendChild(r)}function xr(e,t){br(`frak-base-${e}`,t)}function Sr(e,t,n){br(`frak-placement-${e}-${t}`,n)}const Cr={injectBase:xr,injectPlacement:Sr};Cr.injectBase(`fouce`,`frak-button-share:not(:defined), frak-button-wallet:not(:defined), frak-open-in-app:not(:defined), frak-post-purchase:not(:defined), frak-banner:not(:defined) { display: none !important; }`),yr(gr);const wr={"button-share":()=>import(`./ButtonShare.COa5uY94.js`),"button-wallet":()=>import(`./ButtonWallet.BUzysl1S.js`),"open-in-app":()=>import(`./OpenInAppButton.Bmzm2fL9.js`),"post-purchase":()=>import(`./PostPurchase._st1hB42.js`),banner:()=>import(`./Banner.UBeCtoRQ.js`)},Tr=new MutationObserver(e=>{for(let{addedNodes:t}of e)for(let e of Array.from(t))e.nodeType===Node.ELEMENT_NODE&&Er(e)});async function Er(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=>Dr(e)))}async function Dr(e){if(customElements.get(e))return Promise.resolve();try{let t=e.replace(/^frak-/i,``);if(!(t in wr))throw Error(`Component ${e} is not supported.`);await wr[t]()}catch(e){console.error(e)}}Er(document.body),Tr.observe(document.documentElement,{subtree:!0,childList:!0});export{j as C,K as S,E as T,mn as _,fr as a,cn as b,rr as c,Kn as d,Gn as f,Sn as g,Cn as h,hr as i,tr as l,En as m,yr as n,ur as o,Un as p,gr as r,or as s,Cr as t,qn as u,dn as v,T as w,hn as x,X as y};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{f as e,g as t,h as n,m as r,p as i,u as a}from"./usePlacement.Di6eZ4ty.js";function o(e,t){for(var n in t)e[n]=t[n];return e}function s(e,t){for(var n in e)if(n!==`__source`&&!(n in t))return!0;for(var r in t)if(r!==`__source`&&e[r]!==t[r])return!0;return!1}function c(e,t){this.props=e,this.context=t}(c.prototype=new t).isPureReactComponent=!0,c.prototype.shouldComponentUpdate=function(e,t){return s(this.props,e)||s(this.state,t)};var l=n.__b;n.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),l&&l(e)},typeof Symbol<`u`&&Symbol.for;var u=n.__e;n.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e??(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}u(e,t,n,r)};var d=n.unmount;function f(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=o({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return f(e,t,n)})),e}function p(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return p(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function m(){this.__u=0,this.o=null,this.__b=null}function h(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function g(){this.i=null,this.l=null}n.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),d&&d(e)},(m.prototype=new t).__c=function(e,t){var n=t.__c,r=this;r.o??=[],r.o.push(n);var i=h(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=p(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},m.prototype.componentWillUnmount=function(){this.o=[]},m.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(`div`),a=this.__v.__k[0].__c;this.__v.__k[0]=f(this.__b,n,a.__O=a.__P)}this.__b=null}var o=t.__a&&i(r,null,e.fallback);return o&&(o.__u&=-33),[i(r,null,t.__a?null:e.children),o]};var _=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==`t`||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};(g.prototype=new t).__a=function(e){var t=this,n=h(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),_(t,e,r)):i()};n?n(a):a()}},g.prototype.render=function(t){this.i=null,this.l=new Map;var n=e(t.children);t.revealOrder&&t.revealOrder[0]===`b`&&n.reverse();for(var r=n.length;r--;)this.l.set(n[r],this.i=[1,0,this.i]);return t.children},g.prototype.componentDidUpdate=g.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){_(e,n,t)})};var v=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,y=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,b=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,x=/[A-Z0-9]/g,S=typeof document<`u`,C=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};t.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(t.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var w=n.event;n.event=function(e){return w&&(e=w(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var T={configurable:!0,get:function(){return this.class}},E=n.vnode;n.vnode=function(t){typeof t.type==`string`&&function(t){var n=t.props,r=t.type,i={},a=r.indexOf(`-`)==-1;for(var o in n){var s=n[o];if(!(o===`value`&&`defaultValue`in n&&s==null||S&&o===`children`&&r===`noscript`||o===`class`||o===`className`)){var c=o.toLowerCase();o===`defaultValue`&&`value`in n&&n.value==null?o=`value`:o===`download`&&!0===s?s=``:c===`translate`&&s===`no`?s=!1:c[0]===`o`&&c[1]===`n`?c===`ondoubleclick`?o=`ondblclick`:c!==`onchange`||r!==`input`&&r!==`textarea`||C(n.type)?c===`onfocus`?o=`onfocusin`:c===`onblur`?o=`onfocusout`:b.test(o)&&(o=c):c=o=`oninput`:a&&y.test(o)?o=o.replace(x,`-$&`).toLowerCase():s===null&&(s=void 0),c===`oninput`&&i[o=c]&&(o=`oninputCapture`),i[o]=s}}r==`select`&&(i.multiple&&Array.isArray(i.value)&&(i.value=e(n.children).forEach(function(e){e.props.selected=i.value.indexOf(e.props.value)!=-1})),i.defaultValue!=null&&(i.value=e(n.children).forEach(function(e){e.props.selected=i.multiple?i.defaultValue.indexOf(e.props.value)!=-1:i.defaultValue==e.props.value}))),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,`className`,T)):n.className&&(i.class=i.className=n.className),t.props=i}(t),t.$$typeof=v,E&&E(t)};var D=n.__r;n.__r=function(e){D&&D(e),e.__c};var O=n.diffed;n.diffed=function(e){O&&O(e);var t=e.props,n=e.__e;n!=null&&e.type===`textarea`&&`value`in t&&t.value!==n.value&&(n.value=t.value==null?``:t.value)};function k(e){return a(`svg`,{width:`15`,height:`15`,viewBox:`0 0 15 15`,fill:`none`,"aria-hidden":`true`,...e,children:a(`path`,{d:`M7.33301 0C11.383 0 14.6668 3.28307 14.667 7.33301C14.667 11.3831 11.3831 14.667 7.33301 14.667C3.28307 14.6668 0 11.383 0 7.33301C0.000175746 3.28318 3.28318 0.000175742 7.33301 0ZM10.3896 4.27734C10.151 4.0388 9.76303 4.03775 9.52441 4.27637L7.33301 6.46777L5.14258 4.27637C4.90397 4.03776 4.51601 4.03882 4.27734 4.27734C4.03869 4.516 4.03771 4.90392 4.27637 5.14258L6.4668 7.33398L4.27637 9.52441C4.03807 9.76306 4.03891 10.1511 4.27734 10.3896C4.51589 10.6282 4.9039 10.629 5.14258 10.3906L7.33301 8.2002L9.52344 10.3906C9.76198 10.629 10.15 10.6279 10.3887 10.3896C10.6273 10.151 10.6283 9.76209 10.3896 9.52344L8.2002 7.33398L10.3906 5.14258C10.6293 4.90392 10.6283 4.516 10.3896 4.27734Z`,fill:`currentColor`})})}function A(e){return a(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":`true`,...e,children:a(`path`,{d:`M5.45508 0C5.75614 0.000209333 6 0.244788 6 0.545898C5.99979 0.846831 5.75601 1.09159 5.45508 1.0918H4.36426C3.05445 1.0918 2.27964 1.35707 1.81836 1.81836C1.35714 2.27966 1.0918 3.05454 1.0918 4.36426V7.63672C1.09186 8.94625 1.35713 9.72139 1.81836 10.1826C2.2797 10.6436 3.05488 10.9092 4.36426 10.9092H7.63672C8.94628 10.9091 9.72135 10.6438 10.1826 10.1826C10.6438 9.72139 10.9091 8.94625 10.9092 7.63672V6.5459C10.9092 6.24466 11.1538 6 11.4551 6C11.7561 6.00028 12 6.24483 12 6.5459V7.63672C11.9999 9.05391 11.72 10.1882 10.9541 10.9541C10.1882 11.7199 9.05394 12 7.63672 12H4.36426C2.94714 12 1.81283 11.7197 1.04688 10.9541C0.280997 10.1882 6.04321e-05 9.05391 0 7.63672V4.36426C0 2.94692 0.28099 1.81283 1.04688 1.04688C1.81284 0.280915 2.94686 0 4.36426 0H5.45508ZM11.4541 0C11.7553 2.20143e-05 11.999 0.244672 11.999 0.545898V3.16406C11.9988 3.46509 11.7552 3.70896 11.4541 3.70898C11.1532 3.70873 10.9084 3.46495 10.9082 3.16406V1.8623L6.93066 5.83984C6.71766 6.05283 6.37218 6.05283 6.15918 5.83984C5.94657 5.62681 5.94632 5.28124 6.15918 5.06836L10.1357 1.0918H8.83594C8.53504 1.09154 8.29025 0.846803 8.29004 0.545898C8.29004 0.244816 8.53491 0.000254588 8.83594 0H11.4541Z`,fill:`currentColor`})})}function j(e){return a(`svg`,{width:`24`,height:`24`,viewBox:`0 0 120 120`,fill:`none`,"aria-hidden":`true`,...e,children:a(`path`,{fill:`currentColor`,d:`M40.9656 92.9592L1.53047 79.6135C0.77971 79.3587 0 79.9184 0 80.7116V105.06C0 105.558 0.316516 105.998 0.78743 106.158L40.2226 119.504C40.9734 119.759 41.7531 119.199 41.7531 118.406V94.0574C41.7531 93.5594 41.4366 93.1194 40.9656 92.9592ZM81.9853 46.2654L42.5405 59.6112C42.0696 59.7714 41.7531 60.2114 41.7531 60.7094V85.0579C41.7531 85.8511 42.5328 86.4108 43.2835 86.1561L82.7283 72.8103C83.1993 72.6501 83.5158 72.2101 83.5158 71.7121V47.3636C83.5158 46.5704 82.738 46.0107 81.9853 46.2654ZM119.027 0.0367608L52.9913 21.3051C52.5127 21.4595 52.1884 21.9053 52.1884 22.409V47.3559C52.1884 47.8519 52.6806 48.2031 53.1592 48.0487L119.195 26.7804C119.674 26.626 120 26.1802 120 25.6765V0.729621C119.998 0.233617 119.506 -0.117637 119.027 0.0367608Z`})})}function M(e){return a(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,...e,children:a(`path`,{d:`M8 0C12.4183 0 16 3.58172 16 8C16 12.4183 12.4183 16 8 16C3.58172 16 0 12.4183 0 8C0 3.58172 3.58172 0 8 0ZM8 1.5C4.41015 1.5 1.5 4.41015 1.5 8C1.5 11.5899 4.41015 14.5 8 14.5C11.5899 14.5 14.5 11.5899 14.5 8C14.5 4.41015 11.5899 1.5 8 1.5ZM8.10352 10.207C8.82025 10.2071 9.23531 10.6346 9.23535 11.3262C9.23535 12.0304 8.82028 12.4579 8.10352 12.458C7.36167 12.4579 6.97168 12.0304 6.97168 11.3262C6.97172 10.6346 7.36171 10.2072 8.10352 10.207ZM8.84766 3.54102C9.01311 3.54121 9.14736 3.67535 9.14746 3.84082V4.74805L8.84375 8.37012C8.83069 8.52552 8.6999 8.64551 8.54395 8.64551H7.62891C7.47133 8.64523 7.34074 8.52251 7.33008 8.36523L7.08496 4.74805V3.84082C7.08507 3.67533 7.2193 3.54119 7.38477 3.54102H8.84766Z`,fill:`currentColor`})})}const N=`:root {
|
|
2
2
|
--text-primary__pbq4ak0: #000000;
|
|
3
3
|
--text-secondary__pbq4ak1: #525252;
|
|
4
4
|
--text-tertiary__pbq4ak2: #a3a3a3;
|
|
@@ -85,7 +85,7 @@ import{d as e,f as t,h as n,l as r,m as i,p as a}from"./usePlacement.B7jMsQvP.js
|
|
|
85
85
|
--icon-error__pbq4ak13: #e31c31;
|
|
86
86
|
--icon-success__pbq4ak14: #09be67;
|
|
87
87
|
--icon-warning__pbq4ak15: #ec7e00;
|
|
88
|
-
}`;function P(e){return
|
|
88
|
+
}`;function P(e){return a(`svg`,{viewBox:`0 0 100 100`,fill:`none`,"aria-hidden":`true`,...e,children:[a(`circle`,{cx:`38`,cy:`28`,r:`23`,fill:`#FFF533`}),a(`path`,{d:`M50 38C30 10 12 30 50 38Z`,stroke:`#222222`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`}),a(`path`,{d:`M50 38C70 10 88 30 50 38Z`,stroke:`#222222`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`}),a(`rect`,{x:`10`,y:`38`,width:`80`,height:`16`,rx:`2`,stroke:`#222222`,"stroke-width":`4`}),a(`path`,{d:`M15 54V89C15 90.6 16.4 92 18 92H82C83.6 92 85 90.6 85 89V54`,stroke:`#222222`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`}),a(`line`,{x1:`50`,y1:`54`,x2:`50`,y2:`92`,stroke:`#222222`,"stroke-width":`4`,"stroke-linecap":`round`})]})}const F=`.reset_base__1831jhd0 {
|
|
89
89
|
margin: 0;
|
|
90
90
|
padding: 0;
|
|
91
91
|
border: 0;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e}from"./loader.js";import{l as t,o as n,s as r}from"./usePlacement.Di6eZ4ty.js";function i(){let[i,a]=r(0);return t(()=>{let e=e=>{a(e=>e+1)};return window.addEventListener(`frak:config`,e),a(e=>e+1),()=>window.removeEventListener(`frak:config`,e)},[]),n(()=>e.getConfig().components,[i])}export{i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./loader.js";import{l as t,r as n}from"./usePlacement.Di6eZ4ty.js";function r(r,i,a,o){t(()=>{e.injectBase(r,o??n)},[r]),t(()=>{!i||!a||e.injectPlacement(r,i,a)},[r,i,a])}export{r as t};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import{S as e,i as t,n,r}from"./loader.js";var i,a,o,s,c,l,u,d,f,p,m,h={},g=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,t){for(var n in t)e[n]=t[n];return e}function b(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function x(e,t,n){var r,a,o,s={};for(o in t)o==`key`?r=t[o]:o==`ref`?a=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?i.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return S(e,s,r,a,null)}function S(e,t,n,r,i){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++o,__i:-1,__u:0};return i==null&&a.vnode!=null&&a.vnode(s),s}function C(e){return e.children}function w(e,t){this.props=e,this.context=t}function T(e,t){if(t==null)return e.__?T(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?T(e):null}function E(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],o=y({},t);o.__v=t.__v+1,a.vnode&&a.vnode(o),F(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??T(t),!!(32&t.__u),i),o.__v=t.__v,o.__.__k[o.__i]=o,re(r,o,i),t.__e=t.__=null,o.__e!=n&&D(o)}}function D(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),D(e)}function O(e){(!e.__d&&(e.__d=!0)&&s.push(e)&&!k.__r++||c!=a.debounceRendering)&&((c=a.debounceRendering)||l)(k)}function k(){try{for(var e,t=1;s.length;)s.length>t&&s.sort(u),e=s.shift(),t=s.length,E(e)}finally{s.length=k.__r=0}}function ee(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,_,v,y,b=r&&r.__k||g,x=t.length;for(c=A(n,t,b,c,x),d=0;d<x;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&b[p.__i]||h,p.__i=d,v=F(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&L(f.ref,null,p),u.push(p.ref,p.__c||m,p)),_==null&&m!=null&&(_=m),(y=!!(4&p.__u))||f.__k===p.__k?c=j(p,c,e,y):typeof p.type==`function`&&v!==void 0?c=v:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=_,c}function A(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=S(null,o,null,null,null):v(o)?o=e.__k[a]=S(C,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=S(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=te(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=T(s)),oe(s,s));return r}function j(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=j(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=T(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function M(e,t){return t||=[],e==null||typeof e==`boolean`||(v(e)?e.some(function(e){M(e,t)}):t.push(e)),t}function te(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ne(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||_.test(t)?n:n+`px`}function N(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ne(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ne(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(d,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n.u=r.u:(n.u=f,e.addEventListener(t,a?m:p,a)):e.removeEventListener(t,a?m:p,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function P(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=f++;else if(t.t<n.u)return;return n(a.event?a.event(t):t)}}}function F(e,t,n,r,i,o,s,c,l,u){var d,f,p,m,h,_,x,S,T,E,D,O,k,A,j,M=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[c=t.__e=n.__e]),(d=a.__b)&&d(t);n:if(typeof M==`function`)try{if(S=t.props,T=M.prototype&&M.prototype.render,E=(d=M.contextType)&&r[d.__c],D=d?E?E.props.value:d.__:r,n.__c?x=(f=t.__c=n.__c).__=f.__E:(T?t.__c=f=new M(S,D):(t.__c=f=new w(S,D),f.constructor=M,f.render=se),E&&E.sub(f),f.state||={},f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),T&&f.__s==null&&(f.__s=f.state),T&&M.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=y({},f.__s)),y(f.__s,M.getDerivedStateFromProps(S,f.__s))),m=f.props,h=f.state,f.__v=t,p)T&&M.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),T&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(T&&M.getDerivedStateFromProps==null&&S!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(S,D),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(S,f.__s,D)){t.__v!=n.__v&&(f.props=S,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),g.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&s.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(S,f.__s,D),T&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,_)})}if(f.context=D,f.props=S,f.__P=e,f.__e=!1,O=a.__r,k=0,T)f.state=f.__s,f.__d=!1,O&&O(t),d=f.render(f.props,f.state,f.context),g.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,O&&O(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++k<25);f.state=f.__s,f.getChildContext!=null&&(r=y(y({},r),f.getChildContext())),T&&!p&&f.getSnapshotBeforeUpdate!=null&&(_=f.getSnapshotBeforeUpdate(m,h)),A=d!=null&&d.type===C&&d.key==null?ie(d.props.children):d,c=ee(e,v(A)?A:[A],t,n,r,i,o,s,c,l,u),f.base=t.__e,t.__u&=-161,f.__h.length&&s.push(f),x&&(f.__E=f.__=null)}catch(e){if(t.__v=null,l||o!=null)if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,t.__e=c}else{for(j=o.length;j--;)b(o[j]);I(t)}else t.__e=n.__e,t.__k=n.__k,e.then||I(t);a.__e(e,t,n)}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=ae(n.__e,t,n,r,i,o,s,l,u);return(d=a.diffed)&&d(t),128&t.__u?void 0:c}function I(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(I))}function re(e,t,n){for(var r=0;r<n.length;r++)L(n[r],n[++r],n[++r]);a.__c&&a.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){a.__e(e,t.__v)}})}function ie(e){return typeof e!=`object`||!e||e.__b>0?e:v(e)?e.map(ie):y({},e)}function ae(e,t,n,r,o,s,c,l,u){var d,f,p,m,g,_,y,x=n.props||h,S=t.props,C=t.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){e=g,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&=(a.__m&&a.__m(t,s),!1),s=null}if(C==null)x===S||l&&e.data==S||(e.data=S);else{if(s&&=i.call(e.childNodes),!l&&s!=null)for(x={},d=0;d<e.attributes.length;d++)x[(g=e.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||N(e,d,null,g,o);for(d in S)g=S[d],d==`children`?m=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?_=g:d==`checked`?y=g:l&&typeof g!=`function`||x[d]===g||N(e,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=``),ee(t.type==`template`?e.content:e,v(m)?m:[m],t,n,r,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:n.__k&&T(n,0),l,u),s!=null)for(d=s.length;d--;)b(s[d]);l||(d=`value`,C==`progress`&&_==null?e.removeAttribute(`value`):_!=null&&(_!==e[d]||C==`progress`&&!_||C==`option`&&_!=x[d])&&N(e,d,_,x[d],o),d=`checked`,y!=null&&y!=e[d]&&N(e,d,y,x[d],o))}return e}function L(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){a.__e(e,n)}}function oe(e,t,n){var r,i;if(a.unmount&&a.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||L(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){a.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&oe(r[i],t,n||typeof e.type!=`function`);n||b(e.__e),e.__c=e.__=e.__e=void 0}function se(e,t,n){return this.constructor(e,n)}function R(e,t,n){var r,o,s,c;t==document&&(t=document.documentElement),a.__&&a.__(e,t),o=(r=typeof n==`function`)?null:n&&n.__k||t.__k,s=[],c=[],F(t,e=(!r&&n||t).__k=x(C,null,[e]),o||h,h,t.namespaceURI,!r&&n?[n]:o?null:t.firstChild?i.call(t.childNodes):null,s,!r&&n?n:o?o.__e:t.firstChild,r,c),re(s,e,c)}function ce(e,t){R(e,t,ce)}function z(e,t,n){var r,a,o,s,c=y({},e.props);for(o in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)o==`key`?r=t[o]:o==`ref`?a=t[o]:c[o]=t[o]===void 0&&s!=null?s[o]:t[o];return arguments.length>2&&(c.children=arguments.length>3?i.call(arguments,2):n),S(e.type,c,r||e.key,a||e.ref,null)}i=g.slice,a={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},o=0,w.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=y({},this.state);typeof e==`function`&&(e=e(y({},n),this.props)),e&&y(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),O(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),O(this))},w.prototype.render=C,s=[],l=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,u=function(e,t){return e.__v.__b-t.__v.__b},k.__r=0,d=/(PointerCapture)$|Capture$/i,f=0,p=P(!1),m=P(!0);function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},B.apply(this,arguments)}function V(e,t){if(e==null)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(i[n]=e[n]);return i}var le=[`context`,`children`],ue=[`useFragment`];function de(e,t,n,r){function i(){var t,n=Reflect.construct(HTMLElement,[],i);return n._vdomComponent=e,r&&r.shadow?(n._root=n.attachShadow({mode:r.mode||`open`,serializable:(t=r.serializable)!=null&&t}),r.adoptedStyleSheets&&(n._root.adoptedStyleSheets=r.adoptedStyleSheets)):n._root=n,n}return(i.prototype=Object.create(HTMLElement.prototype)).constructor=i,i.prototype.connectedCallback=function(){pe.call(this,r)},i.prototype.attributeChangedCallback=me,i.prototype.disconnectedCallback=he,n=n||e.observedAttributes||Object.keys(e.propTypes||{}),i.observedAttributes=n,e.formAssociated&&(i.formAssociated=!0),n.forEach(function(e){Object.defineProperty(i.prototype,e,{get:function(){return this._vdom?this._vdom.props[e]:this._props[e]},set:function(t){this._vdom?this.attributeChangedCallback(e,null,t):(this._props||={},this._props[e]=t);var n=typeof t;t!=null&&n!==`string`&&n!==`boolean`&&n!==`number`||this.setAttribute(e,t)}})}),customElements.define(t||e.tagName||e.displayName||e.name,i),i}function fe(e){this.getChildContext=function(){return e.context};var t=e.children;return z(t,V(e,le))}function pe(e){var t=new CustomEvent(`_preact`,{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(t),this._vdom=x(fe,B({},this._props,{context:t.detail.context}),_e(this,this._vdomComponent,e)),(this.hasAttribute(`hydrate`)?ce:R)(this._vdom,this._root)}function H(e){return e.replace(/-(\w)/g,function(e,t){return t?t.toUpperCase():``})}function me(e,t,n){if(this._vdom){var r={};r[e]=n??=void 0,r[H(e)]=n,this._vdom=z(this._vdom,r),R(this._vdom,this._root)}}function he(){R(this._vdom=null,this._root)}function ge(e,t){var n=this,r=e.useFragment,i=V(e,ue);return x(r?C:`slot`,B({},i,{ref:function(e){e?(n.ref=e,n._listener||(n._listener=function(e){e.stopPropagation(),e.detail.context=t},e.addEventListener(`_preact`,n._listener))):n.ref.removeEventListener(`_preact`,n._listener)}}))}function _e(e,t,n){if(e.nodeType===3)return e.data;if(e.nodeType!==1)return null;var r=[],i={},a=0,o=e.attributes,s=e.childNodes;for(a=o.length;a--;)o[a].name!==`slot`&&(i[o[a].name]=o[a].value,i[H(o[a].name)]=o[a].value);for(a=s.length;a--;){var c=_e(s[a],null,n),l=s[a].slot;l?i[l]=x(ge,{name:l},c):r[a]=c}var u=!(!n||!n.shadow),d=t?x(ge,{useFragment:!u},r):r;return!u&&t&&(e.innerHTML=``),x(t||e.nodeName.toLowerCase(),i,d)}function ve(e,t,i=[],a={shadow:!0}){typeof window<`u`&&(n(r),customElements.get(t)||de(e,t,i,a))}var ye=0;Array.isArray;function be(e,t,n,r,i,o){t||={};var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ye,__i:-1,__u:0,__source:i,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return a.vnode&&a.vnode(u),u}var U,W,G,xe,K=0,Se=[],q=a,Ce=q.__b,we=q.__r,Te=q.diffed,Ee=q.__c,De=q.unmount,Oe=q.__;function J(e,t){q.__h&&q.__h(W,e,K||t),K=0;var n=W.__H||={__:[],__h:[]};return e>=n.__.length&&n.__.push({}),n.__[e]}function Y(e){return K=1,ke(Ie,e)}function ke(e,t,n){var r=J(U++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ie(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.some(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a&&a.call(this,e,t,n)||o};W.__f=!0;var a=W.shouldComponentUpdate,o=W.componentWillUpdate;W.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},W.shouldComponentUpdate=i}return r.__N||r.__}function X(e,t){var n=J(U++,3);!q.__s&&Fe(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function Ae(e){return K=5,Z(function(){return{current:e}},[])}function Z(e,t){var n=J(U++,7);return Fe(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function je(e,t){return K=8,Z(function(){return e},t)}function Me(){for(var e;e=Se.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Q),t.__h.some($),t.__h=[]}catch(n){t.__h=[],q.__e(n,e.__v)}}}q.__b=function(e){W=null,Ce&&Ce(e)},q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Oe&&Oe(e,t)},q.__r=function(e){we&&we(e),U=0;var t=(W=e.__c).__H;t&&(G===W?(t.__h=[],W.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Q),t.__h.some($),t.__h=[],U=0)),G=W},q.diffed=function(e){Te&&Te(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Se.push(t)!==1&&xe===q.requestAnimationFrame||((xe=q.requestAnimationFrame)||Pe)(Me)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),G=W=null},q.__c=function(e,t){t.some(function(e){try{e.__h.some(Q),e.__h=e.__h.filter(function(e){return!e.__||$(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],q.__e(n,e.__v)}}),Ee&&Ee(e,t)},q.unmount=function(e){De&&De(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Q(e)}catch(e){t=e}}),n.__H=void 0,t&&q.__e(t,n.__v))};var Ne=typeof requestAnimationFrame==`function`;function Pe(e){var t,n=function(){clearTimeout(r),Ne&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ne&&(t=requestAnimationFrame(n))}function Q(e){var t=W,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),W=t}function $(e){var t=W;e.__c=e.__(),W=t}function Fe(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ie(e,t){return typeof t==`function`?t(e):t}function Le(){let[n,r]=Y(()=>window.FrakSetup?.config?.waitForBackendConfig===!1?!0:e.isResolved),[i,a]=Y(()=>e.getConfig().hidden??!1),[o,s]=Y(()=>!!window.FrakSetup?.client);return X(()=>{let n=e.getConfig();n.isResolved&&(r(!0),a(n.hidden??!1)),window.FrakSetup?.client&&s(!0);let i=e=>{let t=e.detail;t.isResolved&&r(!0),a(t.hidden??!1)};window.addEventListener(`frak:config`,i);let o=()=>s(!0);return t(`add`,o),()=>{window.removeEventListener(`frak:config`,i),t(`remove`,o)}},[]),{shouldRender:n,isHidden:i,isClientReady:o}}const Re=`
|
|
2
|
+
:host {
|
|
3
|
+
display: contents;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
:host([hidden]) {
|
|
7
|
+
display: none;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.button:disabled {
|
|
11
|
+
opacity: 0.7;
|
|
12
|
+
cursor: default;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.button__fadeIn {
|
|
16
|
+
animation: frak-fadeIn 300ms ease-in;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@keyframes frak-fadeIn {
|
|
20
|
+
from {
|
|
21
|
+
opacity: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
to {
|
|
25
|
+
opacity: 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;function ze(e,t){return t?`${Re}\n${e}\n${t}`:`${Re}\n${e}`}const Be=`
|
|
29
|
+
:where(frak-button-share, frak-open-in-app) {
|
|
30
|
+
display: contents;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:where(frak-button-share .button, frak-open-in-app .button) {
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
gap: 10px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
:where(frak-button-share .button:disabled, frak-open-in-app .button:disabled) {
|
|
41
|
+
opacity: 0.7;
|
|
42
|
+
cursor: default;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:where(frak-button-share .button__fadeIn, frak-open-in-app .button__fadeIn) {
|
|
46
|
+
animation: frak-fadeIn 300ms ease-in;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@keyframes frak-fadeIn {
|
|
50
|
+
from {
|
|
51
|
+
opacity: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
to {
|
|
55
|
+
opacity: 1;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`;function Ve(t){return e.getConfig().placements?.[t]}function He(e){let[t,n]=Y(0);return X(()=>{let e=e=>{n(e=>e+1)};return window.addEventListener(`frak:config`,e),n(e=>e+1),()=>window.removeEventListener(`frak:config`,e)},[]),Z(()=>e?Ve(e):void 0,[e,t])}export{Ae as a,je as c,ve as d,M as f,w as g,a as h,Le as i,X as l,C as m,ze as n,Z as o,x as p,Be as r,Y as s,He as t,be as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,x as t,y as n}from"./loader.js";import{
|
|
1
|
+
import{f as e,x as t,y as n}from"./loader.js";import{l as r,s as i}from"./usePlacement.Di6eZ4ty.js";import{n as a}from"./formatReward.B0iBskOJ.js";function o(e,t){switch(e.payoutType){case`fixed`:return e.amount[t];case`tiered`:return e.tiers.reduce((e,n)=>Math.max(e,n.amount[t]),0);case`percentage`:return 0}}function s({rewards:e},r,i){let s=(i?e.filter(e=>e.interactionTypeKey===i):e).map(e=>e.referrer).filter(e=>e!==void 0);if(s.length===0)return;let c=t(n(r)),l=s[0],u=o(l,c);for(let e=1;e<s.length;e++){let t=o(s[e],c);t>u&&(l=s[e],u=t)}if(u<=0){let e=s.find(e=>e.payoutType===`percentage`);if(!e)return;l=e}return a(l,r)}function c(t,n){let[a,o]=i(void 0);return r(()=>{if(!t)return;let r=window.FrakSetup?.client;r&&e(r).then(e=>{let t=r.config.metadata?.currency,i=s(e,t,n);i&&o(i)}).catch(()=>{})},[t,n]),{reward:a}}export{c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,T as t,m as n,s as r,w as i}from"./loader.js";import{
|
|
1
|
+
import{C as e,T as t,m as n,s as r,w as i}from"./loader.js";import{c as a,s as o}from"./usePlacement.Di6eZ4ty.js";function s(s,c,l){let[u,d]=o(void 0),[f,p]=o(!1);return{handleShare:a(async()=>{if(!window.FrakSetup?.client){console.error(`Frak client not found`),d(n.empty().formatDebugInfo(`Frak client not found`)),p(!0);return}let a=r(window.FrakSetup.client,{});try{await a.sharing(l?{link:l}:{}).display(e=>({...e,targetInteraction:s}),c)}catch(n){if(n instanceof t&&n.code===i.clientAborted){console.debug(`User aborted the modal`);return}let r=window.FrakSetup.client.debugInfo.formatDebugInfo(n);e(window.FrakSetup.client,`share_modal_error`,{placement:c,target_interaction:s,error:n instanceof Object&&`message`in n?n.message:`Unknown error`}),d(r),p(!0),console.error(`Error while opening the modal`,n)}},[s,c,l]),isError:f,debugInfo:u}}export{s as t};
|
package/dist/banner.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as registerWebComponent, i as useClientReady, t as usePlacement } from "./usePlacement-
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, t as usePlacement } from "./usePlacement-V7NrKoub.js";
|
|
2
2
|
import { t as useGlobalComponents } from "./useGlobalComponents-Cmfszr7v.js";
|
|
3
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-
|
|
3
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-C3lcOwY2.js";
|
|
4
4
|
import { t as useReward } from "./useReward-DU3_yP8Q.js";
|
|
5
5
|
import { a as CloseCircleIcon, c as cssSource$5, i as ExternalLinkIcon, n as WarningIcon, o as cssSource$6, s as cssSource$4, t as GiftIcon } from "./GiftIcon-4sr9xXyq.js";
|
|
6
|
-
import { isInAppBrowser, redirectToExternalBrowser } from "@frak-labs/core-sdk";
|
|
6
|
+
import { isInAppBrowser, redirectToExternalBrowser, trackEvent } from "@frak-labs/core-sdk";
|
|
7
7
|
import { REFERRAL_SUCCESS_EVENT, getMergeToken } from "@frak-labs/core-sdk/actions";
|
|
8
|
-
import { useCallback, useEffect, useMemo, useState } from "preact/hooks";
|
|
8
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";
|
|
9
9
|
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
10
10
|
//#region \0ve-inline:../../packages/design-system/src/styles/inAppBanner.css.ts.vanilla.js
|
|
11
11
|
const cssSource$3 = `@keyframes inAppBanner_fadeIn__1ibpiy70 {
|
|
@@ -285,6 +285,7 @@ function Banner({ placement: placementId, classname = "", interaction, referralT
|
|
|
285
285
|
if (isPreview) return resolvedPreviewMode;
|
|
286
286
|
return isInAppBrowser ? "inapp" : null;
|
|
287
287
|
});
|
|
288
|
+
const trackedImpressionModeRef = useRef(null);
|
|
288
289
|
useEffect(() => {
|
|
289
290
|
if (isPreview) setMode(resolvedPreviewMode);
|
|
290
291
|
}, [isPreview, resolvedPreviewMode]);
|
|
@@ -299,6 +300,23 @@ function Banner({ placement: placementId, classname = "", interaction, referralT
|
|
|
299
300
|
isPreview,
|
|
300
301
|
isClientReady
|
|
301
302
|
]);
|
|
303
|
+
useEffect(() => {
|
|
304
|
+
if (isPreview || !mode || dismissed) return;
|
|
305
|
+
if (trackedImpressionModeRef.current === mode) return;
|
|
306
|
+
if (!isClientReady) return;
|
|
307
|
+
trackEvent(window.FrakSetup?.client, "banner_impression", {
|
|
308
|
+
placement: placementId,
|
|
309
|
+
variant: mode,
|
|
310
|
+
has_reward: mode === "referral" ? Boolean(reward) : void 0
|
|
311
|
+
});
|
|
312
|
+
trackedImpressionModeRef.current = mode;
|
|
313
|
+
}, [
|
|
314
|
+
mode,
|
|
315
|
+
dismissed,
|
|
316
|
+
isClientReady,
|
|
317
|
+
isPreview,
|
|
318
|
+
placementId
|
|
319
|
+
]);
|
|
302
320
|
useEffect(() => {
|
|
303
321
|
if (isPreview || mode === "inapp") return;
|
|
304
322
|
const handler = () => setMode("referral");
|
|
@@ -307,6 +325,11 @@ function Banner({ placement: placementId, classname = "", interaction, referralT
|
|
|
307
325
|
}, [isPreview, mode]);
|
|
308
326
|
const handleAction = useCallback(async () => {
|
|
309
327
|
if (isPreview) return;
|
|
328
|
+
trackEvent(window.FrakSetup?.client, "banner_resolved", {
|
|
329
|
+
placement: placementId,
|
|
330
|
+
variant: mode ?? "referral",
|
|
331
|
+
outcome: "clicked"
|
|
332
|
+
});
|
|
310
333
|
if (mode === "referral") {
|
|
311
334
|
setDismissed(true);
|
|
312
335
|
return;
|
|
@@ -325,12 +348,22 @@ function Banner({ placement: placementId, classname = "", interaction, referralT
|
|
|
325
348
|
}, [
|
|
326
349
|
isPreview,
|
|
327
350
|
mode,
|
|
328
|
-
prefetchedMergeToken
|
|
351
|
+
prefetchedMergeToken,
|
|
352
|
+
placementId
|
|
329
353
|
]);
|
|
330
354
|
const handleDismiss = useCallback(() => {
|
|
331
355
|
if (isPreview) return;
|
|
356
|
+
trackEvent(window.FrakSetup?.client, "banner_resolved", {
|
|
357
|
+
placement: placementId,
|
|
358
|
+
variant: mode ?? "referral",
|
|
359
|
+
outcome: "dismissed"
|
|
360
|
+
});
|
|
332
361
|
setDismissed(true);
|
|
333
|
-
}, [
|
|
362
|
+
}, [
|
|
363
|
+
isPreview,
|
|
364
|
+
mode,
|
|
365
|
+
placementId
|
|
366
|
+
]);
|
|
334
367
|
const globalComponents = useGlobalComponents();
|
|
335
368
|
const bannerConfig = placement?.components?.banner ?? globalComponents?.banner;
|
|
336
369
|
const texts = useMemo(() => {
|
package/dist/buttonShare.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as registerWebComponent, i as useClientReady, s as openEmbeddedWallet, t as usePlacement } from "./usePlacement-
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, s as openEmbeddedWallet, t as usePlacement } from "./usePlacement-V7NrKoub.js";
|
|
2
2
|
import { t as useGlobalComponents } from "./useGlobalComponents-Cmfszr7v.js";
|
|
3
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-
|
|
3
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-C3lcOwY2.js";
|
|
4
4
|
import { t as applyRewardPlaceholder } from "./formatReward-Bub6Z6eY.js";
|
|
5
5
|
import { t as useReward } from "./useReward-DU3_yP8Q.js";
|
|
6
|
-
import { t as useShareModal } from "./useShareModal-
|
|
6
|
+
import { t as useShareModal } from "./useShareModal-BEVkLrBP.js";
|
|
7
7
|
import { trackEvent } from "@frak-labs/core-sdk";
|
|
8
8
|
import { displaySharingPage } from "@frak-labs/core-sdk/actions";
|
|
9
9
|
import { useCallback, useMemo, useState } from "preact/hooks";
|
|
@@ -132,6 +132,9 @@ function ToggleMessage({ debugInfo }) {
|
|
|
132
132
|
*/
|
|
133
133
|
function ErrorMessage({ debugInfo }) {
|
|
134
134
|
const { copied, copy } = useCopyToClipboard();
|
|
135
|
+
const handleCopy = () => {
|
|
136
|
+
copy(debugInfo ?? "");
|
|
137
|
+
};
|
|
135
138
|
return /* @__PURE__ */ jsxs("div", {
|
|
136
139
|
style: styles.errorContainer,
|
|
137
140
|
children: [
|
|
@@ -159,7 +162,7 @@ function ErrorMessage({ debugInfo }) {
|
|
|
159
162
|
}),
|
|
160
163
|
/* @__PURE__ */ jsx("button", {
|
|
161
164
|
type: "button",
|
|
162
|
-
onClick:
|
|
165
|
+
onClick: handleCopy,
|
|
163
166
|
style: styles.copyButton,
|
|
164
167
|
children: copied ? "Informations copiées !" : "Copier les informations de débogage"
|
|
165
168
|
}),
|
|
@@ -236,7 +239,12 @@ function ButtonShare({ placement: placementId, text = "Share and earn!", classna
|
|
|
236
239
|
]);
|
|
237
240
|
const onClick = useCallback(async () => {
|
|
238
241
|
if (isPreview) return;
|
|
239
|
-
trackEvent(window.FrakSetup.client, "share_button_clicked"
|
|
242
|
+
trackEvent(window.FrakSetup.client, "share_button_clicked", {
|
|
243
|
+
placement: placementId,
|
|
244
|
+
target_interaction: resolvedTargetInteraction,
|
|
245
|
+
has_reward: Boolean(reward),
|
|
246
|
+
click_action: resolvedClickAction
|
|
247
|
+
});
|
|
240
248
|
if (resolvedClickAction === "embedded-wallet") openEmbeddedWallet(resolvedTargetInteraction, placementId);
|
|
241
249
|
else if (resolvedClickAction === "share-modal") await handleShare();
|
|
242
250
|
else openSharingPage(resolvedTargetInteraction, placementId);
|
|
@@ -245,7 +253,8 @@ function ButtonShare({ placement: placementId, text = "Share and earn!", classna
|
|
|
245
253
|
resolvedClickAction,
|
|
246
254
|
handleShare,
|
|
247
255
|
resolvedTargetInteraction,
|
|
248
|
-
placementId
|
|
256
|
+
placementId,
|
|
257
|
+
reward
|
|
249
258
|
]);
|
|
250
259
|
if (!isPreview && (!shouldRender || isHidden)) return null;
|
|
251
260
|
const buttonClass = [
|
package/dist/buttonWallet.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { a as registerWebComponent, i as useClientReady, n as buildStyleContent, o as openWalletModal, t as usePlacement } from "./usePlacement-
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, n as buildStyleContent, o as openWalletModal, t as usePlacement } from "./usePlacement-V7NrKoub.js";
|
|
2
2
|
import { t as useReward } from "./useReward-DU3_yP8Q.js";
|
|
3
|
-
import { trackEvent } from "@frak-labs/core-sdk";
|
|
4
3
|
import { useEffect, useMemo, useState } from "preact/hooks";
|
|
5
4
|
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
6
5
|
//#region src/components/ButtonWallet/assets/GiftIcon.tsx
|
|
@@ -129,7 +128,6 @@ function ButtonWallet({ placement: placementId, classname = "", useReward: rawUs
|
|
|
129
128
|
disabled: !isClientReady,
|
|
130
129
|
class: buttonClass,
|
|
131
130
|
onClick: () => {
|
|
132
|
-
trackEvent(window.FrakSetup.client, "wallet_button_clicked");
|
|
133
131
|
openWalletModal(resolvedTargetInteraction, placementId);
|
|
134
132
|
},
|
|
135
133
|
children: [/* @__PURE__ */ jsx(GiftIcon, {}), reward && /* @__PURE__ */ jsx("span", {
|