@fruga/sdk 1.0.4 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/dist/connect.d.mts +16 -1
- package/dist/connect.d.ts +16 -1
- package/dist/connect.js +1 -1
- package/dist/connect.mjs +1 -1
- package/dist/index.d.mts +324 -21
- package/dist/index.d.ts +324 -21
- package/dist/index.js +356 -216
- package/dist/index.mjs +337 -210
- package/dist/loader-react.d.mts +140 -25
- package/dist/loader-react.d.ts +140 -25
- package/dist/loader-react.js +1 -1
- package/dist/loader-react.mjs +1 -1
- package/dist/loader.d.mts +168 -6
- package/dist/loader.d.ts +168 -6
- package/dist/loader.global.js +3 -42
- package/dist/loader.js +1 -1
- package/dist/loader.mjs +1 -1
- package/dist/relay.css +1 -1
- package/dist/relay.d.mts +20 -2
- package/dist/relay.d.ts +20 -2
- package/dist/relay.js +1 -1
- package/dist/relay.mjs +1 -1
- package/package.json +21 -10
package/dist/relay.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var rs=Object.defineProperty;var Ho=t=>{throw TypeError(t)};var os=(t,e,r)=>e in t?rs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Wo=(t,e,r)=>os(t,typeof e!="symbol"?e+"":e,r),eo=(t,e,r)=>e.has(t)||Ho("Cannot "+r);var i=(t,e,r)=>(eo(t,e,"read from private field"),r?r.call(t):e.get(t)),f=(t,e,r)=>e.has(t)?Ho("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),m=(t,e,r,o)=>(eo(t,e,"write to private field"),o?o.call(t,r):e.set(t,r),r),y=(t,e,r)=>(eo(t,e,"access private method"),r);var Dt=(t,e,r,o)=>({set _(a){m(t,e,a,r)},get _(){return i(t,e,o)}});import Kn from"react-dom/client";import{useEffect as Jr}from"react";var X=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var $e,Ee,st,jo,as=(jo=class extends X{constructor(){super();f(this,$e);f(this,Ee);f(this,st);m(this,st,e=>{if(typeof window<"u"&&window.addEventListener){let r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){i(this,Ee)||this.setEventListener(i(this,st))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,Ee))==null||e.call(this),m(this,Ee,void 0))}setEventListener(e){var r;m(this,st,e),(r=i(this,Ee))==null||r.call(this),m(this,Ee,e(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus()}))}setFocused(e){i(this,$e)!==e&&(m(this,$e,e),this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){return typeof i(this,$e)=="boolean"?i(this,$e):globalThis.document?.visibilityState!=="hidden"}},$e=new WeakMap,Ee=new WeakMap,st=new WeakMap,jo),nt=new as;var is={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Ie,to,$o,ss=($o=class{constructor(){f(this,Ie,is);f(this,to,!1)}setTimeoutProvider(t){m(this,Ie,t)}setTimeout(t,e){return i(this,Ie).setTimeout(t,e)}clearTimeout(t){i(this,Ie).clearTimeout(t)}setInterval(t,e){return i(this,Ie).setInterval(t,e)}clearInterval(t){i(this,Ie).clearInterval(t)}},Ie=new WeakMap,to=new WeakMap,$o),ne=new ss;function qo(t){setTimeout(t,0)}var oo=typeof window>"u"||"Deno"in globalThis;function E(){}function Vo(t,e){return typeof t=="function"?t(e):t}function Lt(t){return typeof t=="number"&&t>=0&&t!==1/0}function sr(t,e){return Math.max(t+(e||0)-Date.now(),0)}function oe(t,e){return typeof t=="function"?t(e):t}function Q(t,e){return typeof t=="function"?t(e):t}function nr(t,e){let{type:r="all",exact:o,fetchStatus:a,predicate:s,queryKey:n,stale:l}=t;if(n){if(o){if(e.queryHash!==Bt(n,e.options))return!1}else if(!qe(e.queryKey,n))return!1}if(r!=="all"){let c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||a&&a!==e.state.fetchStatus||s&&!s(e))}function lr(t,e){let{exact:r,status:o,predicate:a,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(r){if(le(e.options.mutationKey)!==le(s))return!1}else if(!qe(e.options.mutationKey,s))return!1}return!(o&&e.state.status!==o||a&&!a(e))}function Bt(t,e){return(e?.queryKeyHashFn||le)(t)}function le(t){return JSON.stringify(t,(e,r)=>ro(r)?Object.keys(r).sort().reduce((o,a)=>(o[a]=r[a],o),{}):r)}function qe(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>qe(t[r],e[r])):!1}var ns=Object.prototype.hasOwnProperty;function ao(t,e,r=0){if(t===e)return t;if(r>500)return e;let o=Ko(t)&&Ko(e);if(!o&&!(ro(t)&&ro(e)))return e;let s=(o?t:Object.keys(t)).length,n=o?e:Object.keys(e),l=n.length,c=o?new Array(l):{},d=0;for(let p=0;p<l;p++){let u=o?p:n[p],g=t[u],h=e[u];if(g===h){c[u]=g,(o?p<s:ns.call(t,u))&&d++;continue}if(g===null||h===null||typeof g!="object"||typeof h!="object"){c[u]=h;continue}let v=ao(g,h,r+1);c[u]=v,v===g&&d++}return s===l&&d===s?t:c}function lt(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let r in t)if(t[r]!==e[r])return!1;return!0}function Ko(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function ro(t){if(!Go(t))return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(!Go(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Go(t){return Object.prototype.toString.call(t)==="[object Object]"}function Yo(t){return new Promise(e=>{ne.setTimeout(e,t)})}function _t(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?ao(t,e):e}function Zo(t,e,r=0){let o=[...t,e];return r&&o.length>r?o.slice(1):o}function Jo(t,e,r=0){let o=[e,...t];return r&&o.length>r?o.slice(0,-1):o}var ct=Symbol();function cr(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===ct?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function dt(t,e){return typeof t=="function"?t(...e):!!t}function Xo(t,e,r){let o=!1,a;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(a??(a=e()),o||(o=!0,a.aborted?r():a.addEventListener("abort",r,{once:!0})),a)}),t}var ce=(()=>{let t=()=>oo;return{isServer(){return t()},setIsServer(e){t=e}}})();function Ut(){let t,e,r=new Promise((a,s)=>{t=a,e=s});r.status="pending",r.catch(()=>{});function o(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{o({status:"fulfilled",value:a}),t(a)},r.reject=a=>{o({status:"rejected",reason:a}),e(a)},r}var ea=qo;function ls(){let t=[],e=0,r=l=>{l()},o=l=>{l()},a=ea,s=l=>{e?t.push(l):a(()=>{r(l)})},n=()=>{let l=t;t=[],l.length&&a(()=>{o(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||n()}return c},batchCalls:l=>(...c)=>{s(()=>{l(...c)})},schedule:s,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{o=l},setScheduler:l=>{a=l}}}var T=ls();var pt,Me,ut,ta,cs=(ta=class extends X{constructor(){super();f(this,pt,!0);f(this,Me);f(this,ut);m(this,ut,e=>{if(typeof window<"u"&&window.addEventListener){let r=()=>e(!0),o=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",o,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",o)}}})}onSubscribe(){i(this,Me)||this.setEventListener(i(this,ut))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,Me))==null||e.call(this),m(this,Me,void 0))}setEventListener(e){var r;m(this,ut,e),(r=i(this,Me))==null||r.call(this),m(this,Me,e(this.setOnline.bind(this)))}setOnline(e){i(this,pt)!==e&&(m(this,pt,e),this.listeners.forEach(o=>{o(e)}))}isOnline(){return i(this,pt)}},pt=new WeakMap,Me=new WeakMap,ut=new WeakMap,ta),mt=new cs;function ds(t){return Math.min(1e3*2**t,3e4)}function io(t){return(t??"online")==="online"?mt.isOnline():!0}var dr=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function pr(t){let e=!1,r=0,o,a=Ut(),s=()=>a.status!=="pending",n=w=>{if(!s()){let k=new dr(w);g(k),t.onCancel?.(k)}},l=()=>{e=!0},c=()=>{e=!1},d=()=>nt.isFocused()&&(t.networkMode==="always"||mt.isOnline())&&t.canRun(),p=()=>io(t.networkMode)&&t.canRun(),u=w=>{s()||(o?.(),a.resolve(w))},g=w=>{s()||(o?.(),a.reject(w))},h=()=>new Promise(w=>{o=k=>{(s()||d())&&w(k)},t.onPause?.()}).then(()=>{o=void 0,s()||t.onContinue?.()}),v=()=>{if(s())return;let w,k=r===0?t.initialPromise:void 0;try{w=k??t.fn()}catch(P){w=Promise.reject(P)}Promise.resolve(w).then(u).catch(P=>{if(s())return;let S=t.retry??(ce.isServer()?0:3),O=t.retryDelay??ds,Y=typeof O=="function"?O(r,P):O,Z=S===!0||typeof S=="number"&&r<S||typeof S=="function"&&S(r,P);if(e||!Z){g(P);return}r++,t.onFail?.(r,P),Yo(Y).then(()=>d()?void 0:h()).then(()=>{e?g(P):v()})})};return{promise:a,status:()=>a.status,cancel:n,continue:()=>(o?.(),a),cancelRetry:l,continueRetry:c,canStart:p,start:()=>(p()?v():h().then(v),a)}}var Ke,ra,ur=(ra=class{constructor(){f(this,Ke)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Lt(this.gcTime)&&m(this,Ke,ne.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(ce.isServer()?1/0:300*1e3))}clearGcTimeout(){i(this,Ke)&&(ne.clearTimeout(i(this,Ke)),m(this,Ke,void 0))}},Ke=new WeakMap,ra);var Ge,ht,ee,Ve,L,zt,Ye,q,na,be,ia,sa=(ia=class extends ur{constructor(e){super();f(this,q);f(this,Ge);f(this,ht);f(this,ee);f(this,Ve);f(this,L);f(this,zt);f(this,Ye);m(this,Ye,!1),m(this,zt,e.defaultOptions),this.setOptions(e.options),this.observers=[],m(this,Ve,e.client),m(this,ee,i(this,Ve).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,m(this,Ge,aa(this.options)),this.state=e.state??i(this,Ge),this.scheduleGc()}get meta(){return this.options.meta}get promise(){return i(this,L)?.promise}setOptions(e){if(this.options={...i(this,zt),...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=aa(this.options);r.data!==void 0&&(this.setState(oa(r.data,r.dataUpdatedAt)),m(this,Ge,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&i(this,ee).remove(this)}setData(e,r){let o=_t(this.state.data,e,this.options);return y(this,q,be).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(e,r){y(this,q,be).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){let r=i(this,L)?.promise;return i(this,L)?.cancel(e),r?r.then(E).catch(E):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return i(this,Ge)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Q(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ct||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>oe(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!sr(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),i(this,L)?.continue()}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),i(this,L)?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),i(this,ee).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(i(this,L)&&(i(this,Ye)||y(this,q,na).call(this)?i(this,L).cancel({revert:!0}):i(this,L).cancelRetry()),this.scheduleGc()),i(this,ee).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||y(this,q,be).call(this,{type:"invalidate"})}async fetch(e,r){if(this.state.fetchStatus!=="idle"&&i(this,L)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:!0});else if(i(this,L))return i(this,L).continueRetry(),i(this,L).promise}if(e&&this.setOptions(e),!this.options.queryFn){let c=this.observers.find(d=>d.options.queryFn);c&&this.setOptions(c.options)}let o=new AbortController,a=c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(m(this,Ye,!0),o.signal)})},s=()=>{let c=cr(this.options,r),p=(()=>{let u={client:i(this,Ve),queryKey:this.queryKey,meta:this.meta};return a(u),u})();return m(this,Ye,!1),this.options.persister?this.options.persister(c,p,this):c(p)},l=(()=>{let c={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:i(this,Ve),state:this.state,fetchFn:s};return a(c),c})();this.options.behavior?.onFetch(l,this),m(this,ht,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==l.fetchOptions?.meta)&&y(this,q,be).call(this,{type:"fetch",meta:l.fetchOptions?.meta}),m(this,L,pr({initialPromise:r?.initialPromise,fn:l.fetchFn,onCancel:c=>{c instanceof dr&&c.revert&&this.setState({...i(this,ht),fetchStatus:"idle"}),o.abort()},onFail:(c,d)=>{y(this,q,be).call(this,{type:"failed",failureCount:c,error:d})},onPause:()=>{y(this,q,be).call(this,{type:"pause"})},onContinue:()=>{y(this,q,be).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{let c=await i(this,L).start();if(c===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(c),i(this,ee).config.onSuccess?.(c,this),i(this,ee).config.onSettled?.(c,this.state.error,this),c}catch(c){if(c instanceof dr){if(c.silent)return i(this,L).promise;if(c.revert){if(this.state.data===void 0)throw c;return this.state.data}}throw y(this,q,be).call(this,{type:"error",error:c}),i(this,ee).config.onError?.(c,this),i(this,ee).config.onSettled?.(this.state.data,c,this),c}finally{this.scheduleGc()}}},Ge=new WeakMap,ht=new WeakMap,ee=new WeakMap,Ve=new WeakMap,L=new WeakMap,zt=new WeakMap,Ye=new WeakMap,q=new WeakSet,na=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},be=function(e){let r=o=>{switch(e.type){case"failed":return{...o,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...o,fetchStatus:"paused"};case"continue":return{...o,fetchStatus:"fetching"};case"fetch":return{...o,...so(o.data,this.options),fetchMeta:e.meta??null};case"success":let a={...o,...oa(e.data,e.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return m(this,ht,e.manual?a:void 0),a;case"error":let s=e.error;return{...o,error:s,errorUpdateCount:o.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:o.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...o,isInvalidated:!0};case"setState":return{...o,...e.state}}};this.state=r(this.state),T.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate()}),i(this,ee).notify({query:this,type:"updated",action:e})})},ia);function so(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:io(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function oa(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function aa(t){let e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,o=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var H,x,Ht,z,Ze,ft,ye,De,Wt,gt,vt,Je,Xe,Le,bt,N,Qt,no,lo,co,po,uo,mo,ho,pa,da,jt=(da=class extends X{constructor(e,r){super();f(this,N);f(this,H);f(this,x);f(this,Ht);f(this,z);f(this,Ze);f(this,ft);f(this,ye);f(this,De);f(this,Wt);f(this,gt);f(this,vt);f(this,Je);f(this,Xe);f(this,Le);f(this,bt,new Set);this.options=r,m(this,H,e),m(this,De,null),m(this,ye,Ut()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,x).addObserver(this),la(i(this,x),this.options)?y(this,N,Qt).call(this):this.updateResult(),y(this,N,po).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return fo(i(this,x),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return fo(i(this,x),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,y(this,N,uo).call(this),y(this,N,mo).call(this),i(this,x).removeObserver(this)}setOptions(e){let r=this.options,o=i(this,x);if(this.options=i(this,H).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Q(this.options.enabled,i(this,x))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");y(this,N,ho).call(this),i(this,x).setOptions(this.options),r._defaulted&&!lt(this.options,r)&&i(this,H).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,x),observer:this});let a=this.hasListeners();a&&ca(i(this,x),o,this.options,r)&&y(this,N,Qt).call(this),this.updateResult(),a&&(i(this,x)!==o||Q(this.options.enabled,i(this,x))!==Q(r.enabled,i(this,x))||oe(this.options.staleTime,i(this,x))!==oe(r.staleTime,i(this,x)))&&y(this,N,no).call(this);let s=y(this,N,lo).call(this);a&&(i(this,x)!==o||Q(this.options.enabled,i(this,x))!==Q(r.enabled,i(this,x))||s!==i(this,Le))&&y(this,N,co).call(this,s)}getOptimisticResult(e){let r=i(this,H).getQueryCache().build(i(this,H),e),o=this.createResult(r,e);return us(this,o)&&(m(this,z,o),m(this,ft,this.options),m(this,Ze,i(this,x).state)),o}getCurrentResult(){return i(this,z)}trackResult(e,r){return new Proxy(e,{get:(o,a)=>(this.trackProp(a),r?.(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&i(this,ye).status==="pending"&&i(this,ye).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,a))})}trackProp(e){i(this,bt).add(e)}getCurrentQuery(){return i(this,x)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let r=i(this,H).defaultQueryOptions(e),o=i(this,H).getQueryCache().build(i(this,H),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(e){return y(this,N,Qt).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,z)))}createResult(e,r){let o=i(this,x),a=this.options,s=i(this,z),n=i(this,Ze),l=i(this,ft),d=e!==o?e.state:i(this,Ht),{state:p}=e,u={...p},g=!1,h;if(r._optimisticResults){let J=this.hasListeners(),Mt=!J&&la(e,r),or=J&&ca(e,o,r,a);(Mt||or)&&(u={...u,...so(p.data,e.options)}),r._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:v,errorUpdatedAt:w,status:k}=u;h=u.data;let P=!1;if(r.placeholderData!==void 0&&h===void 0&&k==="pending"){let J;s?.isPlaceholderData&&r.placeholderData===l?.placeholderData?(J=s.data,P=!0):J=typeof r.placeholderData=="function"?r.placeholderData(i(this,vt)?.state.data,i(this,vt)):r.placeholderData,J!==void 0&&(k="success",h=_t(s?.data,J,r),g=!0)}if(r.select&&h!==void 0&&!P)if(s&&h===n?.data&&r.select===i(this,Wt))h=i(this,gt);else try{m(this,Wt,r.select),h=r.select(h),h=_t(s?.data,h,r),m(this,gt,h),m(this,De,null)}catch(J){m(this,De,J)}i(this,De)&&(v=i(this,De),h=i(this,gt),w=Date.now(),k="error");let S=u.fetchStatus==="fetching",O=k==="pending",Y=k==="error",Z=O&&S,Fe=h!==void 0,re={status:k,fetchStatus:u.fetchStatus,isPending:O,isSuccess:k==="success",isError:Y,isInitialLoading:Z,isLoading:Z,data:h,dataUpdatedAt:u.dataUpdatedAt,error:v,errorUpdatedAt:w,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>d.dataUpdateCount||u.errorUpdateCount>d.errorUpdateCount,isFetching:S,isRefetching:S&&!O,isLoadingError:Y&&!Fe,isPaused:u.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:Y&&Fe,isStale:go(e,r),refetch:this.refetch,promise:i(this,ye),isEnabled:Q(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let J=re.data!==void 0,Mt=re.status==="error"&&!J,or=ir=>{Mt?ir.reject(re.error):J&&ir.resolve(re.data)},Qo=()=>{let ir=m(this,ye,re.promise=Ut());or(ir)},ar=i(this,ye);switch(ar.status){case"pending":e.queryHash===o.queryHash&&or(ar);break;case"fulfilled":(Mt||re.data!==ar.value)&&Qo();break;case"rejected":(!Mt||re.error!==ar.reason)&&Qo();break}}return re}updateResult(){let e=i(this,z),r=this.createResult(i(this,x),this.options);if(m(this,Ze,i(this,x).state),m(this,ft,this.options),i(this,Ze).data!==void 0&&m(this,vt,i(this,x)),lt(r,e))return;m(this,z,r);let o=()=>{if(!e)return!0;let{notifyOnChangeProps:a}=this.options,s=typeof a=="function"?a():a;if(s==="all"||!s&&!i(this,bt).size)return!0;let n=new Set(s??i(this,bt));return this.options.throwOnError&&n.add("error"),Object.keys(i(this,z)).some(l=>{let c=l;return i(this,z)[c]!==e[c]&&n.has(c)})};y(this,N,pa).call(this,{listeners:o()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&y(this,N,po).call(this)}},H=new WeakMap,x=new WeakMap,Ht=new WeakMap,z=new WeakMap,Ze=new WeakMap,ft=new WeakMap,ye=new WeakMap,De=new WeakMap,Wt=new WeakMap,gt=new WeakMap,vt=new WeakMap,Je=new WeakMap,Xe=new WeakMap,Le=new WeakMap,bt=new WeakMap,N=new WeakSet,Qt=function(e){y(this,N,ho).call(this);let r=i(this,x).fetch(this.options,e);return e?.throwOnError||(r=r.catch(E)),r},no=function(){y(this,N,uo).call(this);let e=oe(this.options.staleTime,i(this,x));if(ce.isServer()||i(this,z).isStale||!Lt(e))return;let o=sr(i(this,z).dataUpdatedAt,e)+1;m(this,Je,ne.setTimeout(()=>{i(this,z).isStale||this.updateResult()},o))},lo=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,x)):this.options.refetchInterval)??!1},co=function(e){y(this,N,mo).call(this),m(this,Le,e),!(ce.isServer()||Q(this.options.enabled,i(this,x))===!1||!Lt(i(this,Le))||i(this,Le)===0)&&m(this,Xe,ne.setInterval(()=>{(this.options.refetchIntervalInBackground||nt.isFocused())&&y(this,N,Qt).call(this)},i(this,Le)))},po=function(){y(this,N,no).call(this),y(this,N,co).call(this,y(this,N,lo).call(this))},uo=function(){i(this,Je)&&(ne.clearTimeout(i(this,Je)),m(this,Je,void 0))},mo=function(){i(this,Xe)&&(ne.clearInterval(i(this,Xe)),m(this,Xe,void 0))},ho=function(){let e=i(this,H).getQueryCache().build(i(this,H),this.options);if(e===i(this,x))return;let r=i(this,x);m(this,x,e),m(this,Ht,e.state),this.hasListeners()&&(r?.removeObserver(this),e.addObserver(this))},pa=function(e){T.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(i(this,z))}),i(this,H).getQueryCache().notify({query:i(this,x),type:"observerResultsUpdated"})})},da);function ps(t,e){return Q(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function la(t,e){return ps(t,e)||t.state.data!==void 0&&fo(t,e,e.refetchOnMount)}function fo(t,e,r){if(Q(e.enabled,t)!==!1&&oe(e.staleTime,t)!=="static"){let o=typeof r=="function"?r(t):r;return o==="always"||o!==!1&&go(t,e)}return!1}function ca(t,e,r,o){return(t!==e||Q(o.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&go(t,r)}function go(t,e){return Q(e.enabled,t)!==!1&&t.isStaleByTime(oe(e.staleTime,t))}function us(t,e){return!lt(t.getCurrentResult(),e)}function yt(t){return{onFetch:(e,r)=>{let o=e.options,a=e.fetchOptions?.meta?.fetchMore?.direction,s=e.state.data?.pages||[],n=e.state.data?.pageParams||[],l={pages:[],pageParams:[]},c=0,d=async()=>{let p=!1,u=v=>{Xo(v,()=>e.signal,()=>p=!0)},g=cr(e.options,e.fetchOptions),h=async(v,w,k)=>{if(p)return Promise.reject();if(w==null&&v.pages.length)return Promise.resolve(v);let S=(()=>{let Fe={client:e.client,queryKey:e.queryKey,pageParam:w,direction:k?"backward":"forward",meta:e.options.meta};return u(Fe),Fe})(),O=await g(S),{maxPages:Y}=e.options,Z=k?Jo:Zo;return{pages:Z(v.pages,O,Y),pageParams:Z(v.pageParams,w,Y)}};if(a&&s.length){let v=a==="backward",w=v?ua:vo,k={pages:s,pageParams:n},P=w(o,k);l=await h(k,P,v)}else{let v=t??s.length;do{let w=c===0?n[0]??o.initialPageParam:vo(o,l);if(c>0&&w==null)break;l=await h(l,w),c++}while(c<v)}return l};e.options.persister?e.fetchFn=()=>e.options.persister?.(d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r):e.fetchFn=d}}}function vo(t,{pages:e,pageParams:r}){let o=e.length-1;return e.length>0?t.getNextPageParam(e[o],e,r[o],r):void 0}function ua(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}function ma(t,e){return e?vo(t,e)!=null:!1}function ha(t,e){return!e||!t.getPreviousPageParam?!1:ua(t,e)!=null}var bo=class extends jt{constructor(t,e){super(t,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:yt()})}getOptimisticResult(t){return t.behavior=yt(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,e){let{state:r}=t,o=super.createResult(t,e),{isFetching:a,isRefetching:s,isError:n,isRefetchError:l}=o,c=r.fetchMeta?.fetchMore?.direction,d=n&&c==="forward",p=a&&c==="forward",u=n&&c==="backward",g=a&&c==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ma(e,r.data),hasPreviousPage:ha(e,r.data),isFetchNextPageError:d,isFetchingNextPage:p,isFetchPreviousPageError:u,isFetchingPreviousPage:g,isRefetchError:l&&!d&&!u,isRefetching:s&&!p&&!g}}};var $t,de,_,et,pe,Be,fa,ga=(fa=class extends ur{constructor(e){super();f(this,pe);f(this,$t);f(this,de);f(this,_);f(this,et);m(this,$t,e.client),this.mutationId=e.mutationId,m(this,_,e.mutationCache),m(this,de,[]),this.state=e.state||yo(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){i(this,de).includes(e)||(i(this,de).push(e),this.clearGcTimeout(),i(this,_).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){m(this,de,i(this,de).filter(r=>r!==e)),this.scheduleGc(),i(this,_).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){i(this,de).length||(this.state.status==="pending"?this.scheduleGc():i(this,_).remove(this))}continue(){return i(this,et)?.continue()??this.execute(this.state.variables)}async execute(e){let r=()=>{y(this,pe,Be).call(this,{type:"continue"})},o={client:i(this,$t),meta:this.options.meta,mutationKey:this.options.mutationKey};m(this,et,pr({fn:()=>this.options.mutationFn?this.options.mutationFn(e,o):Promise.reject(new Error("No mutationFn found")),onFail:(n,l)=>{y(this,pe,Be).call(this,{type:"failed",failureCount:n,error:l})},onPause:()=>{y(this,pe,Be).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>i(this,_).canRun(this)}));let a=this.state.status==="pending",s=!i(this,et).canStart();try{if(a)r();else{y(this,pe,Be).call(this,{type:"pending",variables:e,isPaused:s}),i(this,_).config.onMutate&&await i(this,_).config.onMutate(e,this,o);let l=await this.options.onMutate?.(e,o);l!==this.state.context&&y(this,pe,Be).call(this,{type:"pending",context:l,variables:e,isPaused:s})}let n=await i(this,et).start();return await i(this,_).config.onSuccess?.(n,e,this.state.context,this,o),await this.options.onSuccess?.(n,e,this.state.context,o),await i(this,_).config.onSettled?.(n,null,this.state.variables,this.state.context,this,o),await this.options.onSettled?.(n,null,e,this.state.context,o),y(this,pe,Be).call(this,{type:"success",data:n}),n}catch(n){try{await i(this,_).config.onError?.(n,e,this.state.context,this,o)}catch(l){Promise.reject(l)}try{await this.options.onError?.(n,e,this.state.context,o)}catch(l){Promise.reject(l)}try{await i(this,_).config.onSettled?.(void 0,n,this.state.variables,this.state.context,this,o)}catch(l){Promise.reject(l)}try{await this.options.onSettled?.(void 0,n,e,this.state.context,o)}catch(l){Promise.reject(l)}throw y(this,pe,Be).call(this,{type:"error",error:n}),n}finally{i(this,_).runNext(this)}}},$t=new WeakMap,de=new WeakMap,_=new WeakMap,et=new WeakMap,pe=new WeakSet,Be=function(e){let r=o=>{switch(e.type){case"failed":return{...o,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...o,isPaused:!0};case"continue":return{...o,isPaused:!1};case"pending":return{...o,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...o,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...o,data:void 0,error:e.error,failureCount:o.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),T.batch(()=>{i(this,de).forEach(o=>{o.onMutationUpdate(e)}),i(this,_).notify({mutation:this,type:"updated",action:e})})},fa);function yo(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var we,ae,qt,va,ba=(va=class extends X{constructor(e={}){super();f(this,we);f(this,ae);f(this,qt);this.config=e,m(this,we,new Set),m(this,ae,new Map),m(this,qt,0)}build(e,r,o){let a=new ga({client:e,mutationCache:this,mutationId:++Dt(this,qt)._,options:e.defaultMutationOptions(r),state:o});return this.add(a),a}add(e){i(this,we).add(e);let r=mr(e);if(typeof r=="string"){let o=i(this,ae).get(r);o?o.push(e):i(this,ae).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(i(this,we).delete(e)){let r=mr(e);if(typeof r=="string"){let o=i(this,ae).get(r);if(o)if(o.length>1){let a=o.indexOf(e);a!==-1&&o.splice(a,1)}else o[0]===e&&i(this,ae).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){let r=mr(e);if(typeof r=="string"){let a=i(this,ae).get(r)?.find(s=>s.state.status==="pending");return!a||a===e}else return!0}runNext(e){let r=mr(e);return typeof r=="string"?i(this,ae).get(r)?.find(a=>a!==e&&a.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){T.batch(()=>{i(this,we).forEach(e=>{this.notify({type:"removed",mutation:e})}),i(this,we).clear(),i(this,ae).clear()})}getAll(){return Array.from(i(this,we))}find(e){let r={exact:!0,...e};return this.getAll().find(o=>lr(r,o))}findAll(e={}){return this.getAll().filter(r=>lr(e,r))}notify(e){T.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){let e=this.getAll().filter(r=>r.state.isPaused);return T.batch(()=>Promise.all(e.map(r=>r.continue().catch(E))))}},we=new WeakMap,ae=new WeakMap,qt=new WeakMap,va);function mr(t){return t.options.scope?.id}var xe,_e,W,ke,Pe,hr,wo,ya,xo=(ya=class extends X{constructor(e,r){super();f(this,Pe);f(this,xe);f(this,_e);f(this,W);f(this,ke);m(this,xe,e),this.setOptions(r),this.bindMethods(),y(this,Pe,hr).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let r=this.options;this.options=i(this,xe).defaultMutationOptions(e),lt(this.options,r)||i(this,xe).getMutationCache().notify({type:"observerOptionsUpdated",mutation:i(this,W),observer:this}),r?.mutationKey&&this.options.mutationKey&&le(r.mutationKey)!==le(this.options.mutationKey)?this.reset():i(this,W)?.state.status==="pending"&&i(this,W).setOptions(this.options)}onUnsubscribe(){this.hasListeners()||i(this,W)?.removeObserver(this)}onMutationUpdate(e){y(this,Pe,hr).call(this),y(this,Pe,wo).call(this,e)}getCurrentResult(){return i(this,_e)}reset(){i(this,W)?.removeObserver(this),m(this,W,void 0),y(this,Pe,hr).call(this),y(this,Pe,wo).call(this)}mutate(e,r){return m(this,ke,r),i(this,W)?.removeObserver(this),m(this,W,i(this,xe).getMutationCache().build(i(this,xe),this.options)),i(this,W).addObserver(this),i(this,W).execute(e)}},xe=new WeakMap,_e=new WeakMap,W=new WeakMap,ke=new WeakMap,Pe=new WeakSet,hr=function(){let e=i(this,W)?.state??yo();m(this,_e,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},wo=function(e){T.batch(()=>{if(i(this,ke)&&this.hasListeners()){let r=i(this,_e).variables,o=i(this,_e).context,a={client:i(this,xe),meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{i(this,ke).onSuccess?.(e.data,r,o,a)}catch(s){Promise.reject(s)}try{i(this,ke).onSettled?.(e.data,null,r,o,a)}catch(s){Promise.reject(s)}}else if(e?.type==="error"){try{i(this,ke).onError?.(e.error,r,o,a)}catch(s){Promise.reject(s)}try{i(this,ke).onSettled?.(void 0,e.error,r,o,a)}catch(s){Promise.reject(s)}}}this.listeners.forEach(r=>{r(i(this,_e))})})},ya);var ue,wa,xa=(wa=class extends X{constructor(e={}){super();f(this,ue);this.config=e,m(this,ue,new Map)}build(e,r,o){let a=r.queryKey,s=r.queryHash??Bt(a,r),n=this.get(s);return n||(n=new sa({client:e,queryKey:a,queryHash:s,options:e.defaultQueryOptions(r),state:o,defaultOptions:e.getQueryDefaults(a)}),this.add(n)),n}add(e){i(this,ue).has(e.queryHash)||(i(this,ue).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let r=i(this,ue).get(e.queryHash);r&&(e.destroy(),r===e&&i(this,ue).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){T.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return i(this,ue).get(e)}getAll(){return[...i(this,ue).values()]}find(e){let r={exact:!0,...e};return this.getAll().find(o=>nr(r,o))}findAll(e={}){let r=this.getAll();return Object.keys(e).length>0?r.filter(o=>nr(e,o)):r}notify(e){T.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){T.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){T.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ue=new WeakMap,wa);var I,Ue,ze,wt,xt,Qe,kt,Pt,ka,ko=(ka=class{constructor(t={}){f(this,I);f(this,Ue);f(this,ze);f(this,wt);f(this,xt);f(this,Qe);f(this,kt);f(this,Pt);m(this,I,t.queryCache||new xa),m(this,Ue,t.mutationCache||new ba),m(this,ze,t.defaultOptions||{}),m(this,wt,new Map),m(this,xt,new Map),m(this,Qe,0)}mount(){Dt(this,Qe)._++,i(this,Qe)===1&&(m(this,kt,nt.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,I).onFocus())})),m(this,Pt,mt.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,I).onOnline())})))}unmount(){var t,e;Dt(this,Qe)._--,i(this,Qe)===0&&((t=i(this,kt))==null||t.call(this),m(this,kt,void 0),(e=i(this,Pt))==null||e.call(this),m(this,Pt,void 0))}isFetching(t){return i(this,I).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return i(this,Ue).findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return i(this,I).get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=i(this,I).build(this,e),o=r.state.data;return o===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(oe(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(o))}getQueriesData(t){return i(this,I).findAll(t).map(({queryKey:e,state:r})=>{let o=r.data;return[e,o]})}setQueryData(t,e,r){let o=this.defaultQueryOptions({queryKey:t}),s=i(this,I).get(o.queryHash)?.state.data,n=Vo(e,s);if(n!==void 0)return i(this,I).build(this,o).setData(n,{...r,manual:!0})}setQueriesData(t,e,r){return T.batch(()=>i(this,I).findAll(t).map(({queryKey:o})=>[o,this.setQueryData(o,e,r)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return i(this,I).get(e.queryHash)?.state}removeQueries(t){let e=i(this,I);T.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){let r=i(this,I);return T.batch(()=>(r.findAll(t).forEach(o=>{o.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){let r={revert:!0,...e},o=T.batch(()=>i(this,I).findAll(t).map(a=>a.cancel(r)));return Promise.all(o).then(E).catch(E)}invalidateQueries(t,e={}){return T.batch(()=>(i(this,I).findAll(t).forEach(r=>{r.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){let r={...e,cancelRefetch:e.cancelRefetch??!0},o=T.batch(()=>i(this,I).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let s=a.fetch(void 0,r);return r.throwOnError||(s=s.catch(E)),a.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(o).then(E)}fetchQuery(t){let e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);let r=i(this,I).build(this,e);return r.isStaleByTime(oe(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(E).catch(E)}fetchInfiniteQuery(t){return t.behavior=yt(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(E).catch(E)}ensureInfiniteQueryData(t){return t.behavior=yt(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return mt.isOnline()?i(this,Ue).resumePausedMutations():Promise.resolve()}getQueryCache(){return i(this,I)}getMutationCache(){return i(this,Ue)}getDefaultOptions(){return i(this,ze)}setDefaultOptions(t){m(this,ze,t)}setQueryDefaults(t,e){i(this,wt).set(le(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...i(this,wt).values()],r={};return e.forEach(o=>{qe(t,o.queryKey)&&Object.assign(r,o.defaultOptions)}),r}setMutationDefaults(t,e){i(this,xt).set(le(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...i(this,xt).values()],r={};return e.forEach(o=>{qe(t,o.mutationKey)&&Object.assign(r,o.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;let e={...i(this,ze).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Bt(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===ct&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...i(this,ze).mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){i(this,I).clear(),i(this,Ue).clear()}},I=new WeakMap,Ue=new WeakMap,ze=new WeakMap,wt=new WeakMap,xt=new WeakMap,Qe=new WeakMap,kt=new WeakMap,Pt=new WeakMap,ka);import*as Nt from"react";import{jsx as ms}from"react/jsx-runtime";var Po=Nt.createContext(void 0),Ne=t=>{let e=Nt.useContext(Po);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},No=({client:t,children:e})=>(Nt.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),ms(Po.Provider,{value:t,children:e}));import*as fr from"react";var Pa=fr.createContext(!1),Na=()=>fr.useContext(Pa),Zc=Pa.Provider;import*as Kt from"react";import{jsx as ed}from"react/jsx-runtime";function hs(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var fs=Kt.createContext(hs()),Ta=()=>Kt.useContext(fs);import*as Sa from"react";var Ca=(t,e,r)=>{let o=r?.state.error&&typeof t.throwOnError=="function"?dt(t.throwOnError,[r.state.error,r]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||o)&&(e.isReset()||(t.retryOnMount=!1))},Ra=t=>{Sa.useEffect(()=>{t.clearReset()},[t])},Aa=({result:t,errorResetBoundary:e,throwOnError:r,query:o,suspense:a})=>t.isError&&!e.isReset()&&!t.isFetching&&o&&(a&&t.data===void 0||dt(r,[t.error,o]));var gr=(t,e)=>e.state.data===void 0,Oa=t=>{if(t.suspense){let r=a=>a==="static"?a:Math.max(a??1e3,1e3),o=t.staleTime;t.staleTime=typeof o=="function"?(...a)=>r(o(...a)):r(o),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Fa=(t,e)=>t.isLoading&&t.isFetching&&!e,Ea=(t,e)=>t?.suspense&&e.isPending,To=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});import*as He from"react";function vr(t,e,r){let o=Na(),a=Ta(),s=Ne(r),n=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(n);let l=s.getQueryCache().get(n.queryHash);n._optimisticResults=o?"isRestoring":"optimistic",Oa(n),Ca(n,a,l),Ra(a);let c=!s.getQueryCache().get(n.queryHash),[d]=He.useState(()=>new e(s,n)),p=d.getOptimisticResult(n),u=!o&&t.subscribed!==!1;if(He.useSyncExternalStore(He.useCallback(g=>{let h=u?d.subscribe(T.batchCalls(g)):E;return d.updateResult(),h},[d,u]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),He.useEffect(()=>{d.setOptions(n)},[n,d]),Ea(n,p))throw To(n,d,a);if(Aa({result:p,errorResetBoundary:a,throwOnError:n.throwOnError,query:l,suspense:n.suspense}))throw p.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(n,p),n.experimental_prefetchInRender&&!ce.isServer()&&Fa(p,o)&&(c?To(n,d,a):l?.promise)?.catch(E).finally(()=>{d.updateResult()}),n.notifyOnChangeProps?p:d.trackResult(p)}function tt(t,e){return vr({...t,enabled:!0,suspense:!0,throwOnError:gr,placeholderData:void 0},jt,e)}function Gt(t,e){return vr({...t,enabled:!0,suspense:!0,throwOnError:gr},bo,e)}import*as Te from"react";function So(t,e){let r=Ne(e),[o]=Te.useState(()=>new xo(r,t));Te.useEffect(()=>{o.setOptions(t)},[o,t]);let a=Te.useSyncExternalStore(Te.useCallback(n=>o.subscribe(T.batchCalls(n)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),s=Te.useCallback((n,l)=>{o.mutate(n,l).catch(E)},[o]);if(a.error&&dt(o.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:s,mutateAsync:a.mutate}}var te={widgetTitle:"Savings Box",launcherLabel:"Insurance Savings",launcherIcon:"arrow",showLauncher:!0,mode:"light",allowUserThemeControl:!1,defaultTheme:"light",uiVersion:"current",primary:"#1E40AF",accent:"#2648C9",accentTextLight:"#FFFFFF",accentTextDark:"#FFFFFF",bg:"#0B1220",panel:"#0F1A2E",panel2:"#111F38",itemBg:"rgba(255,255,255,0.03)",text:"#E6EDF7",muted:"#A7B3C6",border:"rgba(255,255,255,0.08)",success:"#34D399",danger:"#EF4444",warning:"#FBBF24",lightBg:"#F8FAFC",lightPanel:"#FFFFFF",lightPanel2:"#F1F5F9",lightItemBg:"rgba(0,0,0,0.04)",lightText:"#0F172A",lightMuted:"#64748B",lightBorder:"rgba(0,0,0,0.1)"};function br(t){let e=t.mode==="light",r=e?t.textColorLight?.trim()||t.lightText:t.textColorDark?.trim()||t.text;return{...t,bg:e?t.lightBg:t.bg,panel:e?t.lightPanel:t.panel,panel2:e?t.lightPanel2:t.panel2,itemBg:e?t.lightItemBg:t.itemBg,text:r,muted:e?t.lightMuted:t.muted,border:e?t.lightBorder:t.border,subtleBg:e?"rgba(0,0,0,0.02)":"rgba(255,255,255,0.03)",tooltipBg:e?"#FFFFFF":"#0B1220",tooltipBorder:e?"rgba(0,0,0,0.12)":"rgba(255,255,255,0.12)",accentText:e?t.accentTextLight?.trim()||"#0F172A":t.accentTextDark?.trim()||"#FFFFFF",isLight:e,mode:t.mode}}var yr=class{constructor(e,r){this.baseUrl=e;this.token=r}async getWallet(){try{let e=await fetch(`${this.baseUrl}/api/wallet`,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${this.token}`}});if(!e.ok)return console.warn(`[FrugaSDK] Failed to fetch wallet: ${e.status}. Returning zeroed wallet.`),this.getEmptyWallet();let r=await e.json();return{available:r.available??0,pending:r.pending??0,totalBalance:(r.available||0)+(r.pending||0),lifetimeEarned:r.lifetimeEarned??0,lifetimeRedeemed:r.lifetimeRedeemed??0,updatedAt:r.updatedAt??new Date().toISOString(),requiredActions:r.requiredActions??null}}catch(e){return console.warn("[FrugaSDK] Network error fetching wallet. Returning zeroed wallet.",e),this.getEmptyWallet()}}getEmptyWallet(){return{available:0,pending:0,totalBalance:0,lifetimeEarned:0,lifetimeRedeemed:0,updatedAt:new Date().toISOString(),requiredActions:null}}};var Tt=class{constructor(e,r){this.baseUrl=e;this.token=r}async fetchQuery(e,r={}){let o=new URL(`${this.baseUrl}${e}`);return Object.entries(r).forEach(([a,s])=>{s!=null&&(Array.isArray(s)?s.forEach(n=>o.searchParams.append(a,String(n))):o.searchParams.append(a,String(s)))}),fetch(o.toString(),{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${this.token}`}})}};var wr=class extends Tt{constructor(e,r){super(e,r)}async getActivity(e,r){try{let o=await this.fetchQuery("/api/activity",{pageNumber:e,pageSize:r});if(!o.ok)return console.warn(`[FrugaSDK] Failed to fetch activity: ${o.status}. Returning empty activity.`),this.getEmptyActivity();let a=await o.json();return{...a,transactions:a.transactions||[]}}catch(o){return console.warn("[FrugaSDK] Network error fetching activity. Returning empty activity.",o),this.getEmptyActivity()}}getEmptyActivity(){return{actorType:"",partnerId:0,transactions:[]}}};var xr=class extends Tt{constructor(e,r){super(e,r)}async getCategories(){try{let e=await this.fetchQuery("/api/offers/categories");return e.ok?(await e.json()).categories||[]:(console.warn(`[FrugaSDK] Failed to fetch offer categories: ${e.status}. Returning empty list.`),[])}catch(e){return console.warn("[FrugaSDK] Network error fetching offer categories. Returning empty list.",e),[]}}async getOffers(e){try{let r=await this.fetchQuery("/api/offers",{pageNumber:e.pageNumber??0,pageSize:e.pageSize??10,type:e.type,query:e.query,featured:e.featured,categories:e.categories});if(!r.ok)return console.warn(`[FrugaSDK] Failed to fetch offers: ${r.status}. Returning empty response.`),this.getEmptyPaginatedResponse();let o=await r.json();return{...o,content:o.content||[]}}catch(r){return console.warn("[FrugaSDK] Network error fetching offers. Returning empty response.",r),this.getEmptyPaginatedResponse()}}getEmptyPaginatedResponse(){return{content:[],totalElements:0,totalPages:0,number:0,size:0,numberOfElements:0,numberOfPages:0}}};var kr=class{constructor(e,r){this.baseUrl=e;this.token=r}async listMethods(){try{let e=await fetch(`${this.baseUrl}/api/payout-methods`,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${this.token}`}});if(!e.ok)throw new Error(`Failed to list payout methods: ${e.status}`);return(await e.json()).items||[]}catch(e){return console.error("[FrugaSDK] Error listing payout methods:",e),[]}}async addBankMethod(e){let r=await fetch(`${this.baseUrl}/api/payout-methods/bank`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify(e)});if(!r.ok)throw new Error(`Failed to add bank payout method: ${r.status}`);return r.json()}async deleteMethod(e){let r=await fetch(`${this.baseUrl}/api/payout-methods/${e}`,{method:"DELETE",headers:{Accept:"application/json",Authorization:`Bearer ${this.token}`}});if(!r.ok)throw new Error(`Failed to delete payout method: ${r.status}`)}};import{jsx as Yd}from"react/jsx-runtime";import{useState as Ua,useEffect as za,useRef as Qa}from"react";import{Sparkles as gs,CreditCard as vs,MoveUpRight as bs,Gift as ys}from"lucide-react";import{jsx as Pr}from"react/jsx-runtime";function Ia({theme:t}){return t.launcherIcon==="none"?null:t.launcherIcon==="sparkles"?Pr(gs,{size:20}):t.launcherIcon==="credit"?Pr(vs,{size:20}):t.launcherIcon==="arrow"?Pr(bs,{size:20}):Pr(ys,{size:20})}import{useEffect as Ps,useRef as Ns}from"react";var Ma=t=>{let e,r=new Set,o=(d,p)=>{let u=typeof d=="function"?d(e):d;if(!Object.is(u,e)){let g=e;e=p??(typeof u!="object"||u===null)?u:Object.assign({},e,u),r.forEach(h=>h(e,g))}},a=()=>e,l={setState:o,getState:a,getInitialState:()=>c,subscribe:d=>(r.add(d),()=>r.delete(d))},c=e=t(o,a,l);return l},Da=(t=>t?Ma(t):Ma);import Nr from"react";var ws=t=>t;function xs(t,e=ws){let r=Nr.useSyncExternalStore(t.subscribe,Nr.useCallback(()=>e(t.getState()),[t,e]),Nr.useCallback(()=>e(t.getInitialState()),[t,e]));return Nr.useDebugValue(r),r}var La=t=>{let e=Da(t),r=o=>xs(e,o);return Object.assign(r,e),r},Ba=(t=>t?La(t):La);var C=Ba(t=>({isOpen:!1,isFocused:!0,isIdle:!1,available:0,pending:0,mode:"light",token:null,partnerPayout:null,isAddingPayoutFromAlert:!1,showPayoutSuccess:!1,toggle:()=>t(e=>({isOpen:!e.isOpen})),setOpen:e=>t({isOpen:e}),setFocused:e=>t({isFocused:e}),setIdle:e=>t({isIdle:e}),setBalances:(e,r)=>t({available:e,pending:r}),setMode:e=>t({mode:e}),setToken:e=>t({token:e}),setPartnerPayout:e=>t({partnerPayout:e}),setIsAddingPayoutFromAlert:e=>t({isAddingPayoutFromAlert:e}),setShowPayoutSuccess:e=>t({showPayoutSuccess:e})}));function _a(){let{setFocused:t,setIdle:e}=C(),r=Ns(null);Ps(()=>{let o=()=>t(!0),a=()=>t(!1),s=()=>{e(!1),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{e(!0)},6e4)},n=()=>{s()};s(),t(document.hasFocus()),window.addEventListener("focus",o),window.addEventListener("blur",a);let l=["mousemove","keydown","scroll","touchstart","mousedown"];return l.forEach(c=>{window.addEventListener(c,n,c==="scroll"?!0:void 0)}),()=>{window.removeEventListener("focus",o),window.removeEventListener("blur",a),l.forEach(c=>{window.removeEventListener(c,n,c==="scroll"?!0:void 0)}),r.current&&clearTimeout(r.current)}},[t,e])}import{X as Ts}from"lucide-react";import{Fragment as Ss,jsx as St,jsxs as Co}from"react/jsx-runtime";var Ha=({children:t,theme:e,hostHeight:r=800,isMobile:o=!1})=>{_a();let{isOpen:a,toggle:s,mode:n}=C(),l=e||te,[c,d]=Ua(r),[p,u]=Ua(o),g=l.allowUserThemeControl?{...l,mode:n}:{...l,mode:l.mode||"light"},h=br(g),v=Qa(null),w=Qa(null);return za(()=>{let k=P=>{if(P.data?.type==="FRUGA_HOST_RESIZE"&&(d(P.data.hostHeight),u(P.data.isHostMobile)),P.data?.type==="FRUGA_TOKEN_UPDATE"){let{setToken:S}=C.getState();S(P.data.token)}if(P.data?.type==="FRUGA_GET_BALANCE"){let{available:S,pending:O}=C.getState();console.log("FRUGA_GET_BALANCE",S,O),window.parent.postMessage({type:"FRUGA_BALANCE_RESPONSE",requestId:P.data.requestId,available:S,pending:O},"*")}};return window.addEventListener("message",k),()=>window.removeEventListener("message",k)},[]),za(()=>{if(!v.current)return;let k=()=>{if(!v.current)return;let S=a?450:100;!a&&w.current&&(S=w.current.offsetWidth+40);let O=a?Math.max(200,c-100):100;p&&a&&(S=window.innerWidth,O=c),window.parent.postMessage({type:"FRUGA_RESIZE",height:O,width:S,isFullscreen:p&&a},"*")},P=new ResizeObserver(()=>k());return P.observe(v.current),k(),()=>P.disconnect()},[a,c,p]),Co("div",{ref:v,className:h.mode==="dark"?"dark":"",style:{fontFamily:'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',color:h.text,display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"flex-end",padding:p&&a?"0":"20px",boxSizing:"border-box",height:"100%",margin:0,overscrollBehavior:"contain"},children:[a&&St("div",{style:{width:p?"100vw":"410px",minWidth:p?"100vw":"410px",flexShrink:0,maxHeight:p?"100vh":`${Math.max(100,c-100)}px`,height:"100%",marginBottom:p?"0":"20px",backgroundColor:h.accent,borderRadius:p?"0":"16px",boxShadow:p?"none":"0 20px 40px -10px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0,0,0,0.1)",display:"flex",flexDirection:"column",overflow:"hidden",zIndex:9998},children:St("div",{className:"fruga-scrollbar",style:{flex:1,minHeight:0,backgroundColor:h.isLight?"#f9f9f9":"#111",display:"flex",flexDirection:"column",boxShadow:p?"none":"0 20px 40px -10px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0,0,0,0.1)"},children:t})}),Co("button",{ref:w,onClick:s,style:{backgroundColor:h.accent,color:h.accentText,border:"none",cursor:"pointer",boxShadow:"0 12px 30px -5px rgba(0, 0, 0, 0.1), 0 0 1px rgba(0,0,0, 0.1)",display:a?"none":"flex",alignItems:"center",justifyContent:"center",zIndex:9999,flexShrink:0,borderRadius:"20px",padding:"10px 16px",transition:"transform 0.3s ease-in-out"},className:"flex h-15 items-center gap-2 rounded-xl px-4 active:scale-[0.99]","aria-label":a?"Close widget":"Open widget",children:[l.launcherLabel&&!a?Co(Ss,{children:[l.launcherLabel!=="none"&&St("div",{className:"text-sm font-semibold",children:l.launcherLabel}),St("div",{className:"flex h-6 w-5 shrink-0 items-center justify-center",children:St(Ia,{theme:h})})]}):null,a?St(Ts,{}):null]})]})};import{Fragment as Tp,jsx as Sp}from"react/jsx-runtime";import{useEffect as Cs,useState as Rs}from"react";var Wa=(t,e)=>{let[r,o]=Rs(t);return Cs(()=>{let a=setTimeout(()=>{o(t)},e);return()=>{clearTimeout(a)}},[t,e]),r};var ja={BOOTSTRAP_DATA:"fruga_bootstrap",BOOTSTRAP_CONFIG:"fruga_active_config"},Tr=class{static set(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(e,JSON.stringify(r))}catch(o){console.warn(`[FrugaStorage] Failed to save key "${e}":`,o)}}static get(e){if(typeof window>"u")return null;try{let r=window.localStorage.getItem(e);return r?JSON.parse(r):null}catch(r){return console.warn(`[FrugaStorage] Failed to load key "${e}":`,r),null}}static remove(e){typeof window>"u"||window.localStorage.removeItem(e)}static clear(){typeof window>"u"||window.localStorage.clear()}};var As=typeof process<"u"&&process.env.VITE_FRUGA_API_URL||"https://api-dev.fruga.co.uk",$a=t=>t||As;var Ro=t=>{if(!t)return"";try{let e=t.includes("/")&&!t.includes("-")?t.split(" ")[0].split("/").reverse().join("-"):t,r=new Date(e);if(isNaN(r.getTime()))return t;let o=r.getDate().toString().padStart(2,"0"),a=(r.getMonth()+1).toString().padStart(2,"0"),s=r.getFullYear();return`${o}-${a}-${s}`}catch{return t}},qa=t=>{try{let e=t.includes("/")&&!t.includes("-")?t.split(" ")[0].split("/").reverse().join("-"):t,r=new Date(e);return isNaN(r.getTime())?null:r}catch{return null}},Ka=(t,e=30)=>{if(!t)return!1;let r=qa(t);if(!r)return!1;let o=new Date,a=new Date(o.getFullYear(),o.getMonth(),o.getDate()),n=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime()-a.getTime(),l=Math.ceil(n/(1e3*60*60*24));return l>=0&&l<=e},Ga=t=>{if(!t)return null;let e=qa(t);if(!e)return null;let r=new Date,o=new Date(r.getFullYear(),r.getMonth(),r.getDate()),s=new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()-o.getTime(),n=Math.ceil(s/(1e3*60*60*24));return n>=0?n:0};var Va=(t,e=40)=>t?t.length<=e?t:t.slice(0,e)+"...":"";import{forwardRef as Yi,useEffect as Zi,useImperativeHandle as zn,useRef as Qn,useState as It}from"react";import{createContext as Os,useContext as Fs,useMemo as Es}from"react";var Sr=class{constructor(e){this.offerRepository=e}async getOffers(e){return this.offerRepository.getOffers(e)}async getFeaturedOffers(){return(await this.offerRepository.getOffers({featured:!0,pageSize:20})).content}async getOfferDetails(e){return this.offerRepository.getOfferById(e)}async claimOffer(e){return console.log(`[Use Case] Claiming offer: ${e}`),!0}async getOfferCategories(){return this.offerRepository.getCategories()}};var Cr=class{constructor(e){this.accountRepository=e}async getWallet(){return this.accountRepository.getWallet()}async getActivity(e,r){return this.accountRepository.getActivity(e,r)}};var K=t=>{let e=new Date;return e.setDate(e.getDate()+t),e.toISOString().split("T")[0]},j={Travel:{id:2,name:"Travel",rank:2,offerCount:15},Sports:{id:4,name:"Sports",rank:4,offerCount:10},Fashion:{id:3,name:"Fashion",rank:3,offerCount:30},"Food&Bev":{id:1,name:"Food&Bev",rank:1,offerCount:20},Entertainment:{id:5,name:"Entertainment",rank:5,offerCount:5}},Ao=[{id:1,name:"easyJet flight booking",brandName:"easyJet",description:"Save on your next flight",terms:"T&Cs apply.",link:"https://easyjet.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/easyjet.com",cashback:.035,endDate:K(10),featured:!0,categories:[j.Travel]},{id:2,name:"Nike shoes",brandName:"Nike",description:"Just do it",terms:"Online only",link:"https://nike.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/nike.com",cashback:.06,endDate:K(30),featured:!0,categories:[j.Sports]},{id:3,name:"Adidas gear",brandName:"Adidas",description:"Sportswear and shoes",terms:"T&Cs apply.",link:"https://adidas.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/adidas.com",cashback:.05,endDate:K(30),featured:!1,categories:[j.Sports]},{id:4,name:"ASOS fashion",brandName:"ASOS",description:"Latest trends",terms:"T&Cs apply.",link:"https://asos.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/asos.com",cashback:.08,endDate:K(30),featured:!0,categories:[j.Fashion]},{id:5,name:"Morrisons groceries",brandName:"Morrisons",description:"Fresh food",terms:"T&Cs apply.",link:"https://morrisons.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/morrisons.com",cashback:.02,endDate:K(6),featured:!1,categories:[j["Food&Bev"]]},{id:6,name:"Just Eat delivery",brandName:"Just Eat",description:"Food delivery",terms:"T&Cs apply.",link:"https://just-eat.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/just-eat.com",cashback:.04,endDate:K(30),featured:!1,categories:[j["Food&Bev"]]},{id:7,name:"TripAdvisor bookings",brandName:"TripAdvisor",description:"Hotels and more",terms:"T&Cs apply.",link:"https://tripadvisor.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/tripadvisor.com",cashback:.19,endDate:K(30),featured:!0,categories:[j.Travel]},{id:8,name:"Debenhams store",brandName:"Debenhams",description:"Department store",terms:"T&Cs apply.",link:"https://debenhams.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/debenhams.com",cashback:.03,endDate:K(30),featured:!0,categories:[j.Fashion]},{id:9,name:"Booking.com hotel",brandName:"Booking.com",description:"Hotels worldwide",terms:"T&Cs apply.",link:"https://booking.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/booking.com",cashback:.04,endDate:K(30),featured:!1,categories:[j.Travel]},{id:10,name:"Deliveroo orders",brandName:"Deliveroo",description:"Food delivery",terms:"T&Cs apply.",link:"https://deliveroo.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/deliveroo.com",cashback:.05,endDate:K(30),featured:!0,categories:[j["Food&Bev"]]},{id:11,name:"Puma shoes",brandName:"Puma",description:"Sportswear",terms:"T&Cs apply.",link:"https://puma.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/puma.com",cashback:.07,endDate:K(30),featured:!1,categories:[j.Sports]},{id:12,name:"H&M clothing",brandName:"H&M",description:"Fashion",terms:"T&Cs apply.",link:"https://hm.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/hm.com",cashback:.04,endDate:K(30),featured:!1,categories:[j.Fashion]},{id:13,name:"Uber rides",brandName:"Uber",description:"Ride sharing",terms:"T&Cs apply.",link:"https://uber.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/uber.com",cashback:.02,endDate:K(30),featured:!1,categories:[j.Travel]}],Rr=class{async getOffers(e){let r=[...Ao];if(e.featured&&(r=r.filter(d=>d.featured)),e.categories&&e.categories.length>0&&e.categories[0]!=="All"&&(r=r.filter(d=>d.categories?.some(p=>e.categories.includes(p.name)))),e.query){let d=e.query.toLowerCase();r=r.filter(p=>p.brandName.toLowerCase().includes(d)||p.name?.toLowerCase().includes(d))}let o=e.pageNumber??0,a=e.pageSize??10;await new Promise(d=>setTimeout(d,400));let s=r.length,n=Math.ceil(s/a),l=o*a,c=r.slice(l,l+a);return{content:c,totalElements:s,totalPages:n,number:o,size:a,numberOfElements:c.length,numberOfPages:n}}async getFeaturedOffers(){return Ao.filter(e=>e.featured)}async getOfferById(e){let r=Number(e);return Ao.find(o=>o.id===r)||null}async getCategories(){return Object.values(j).sort((e,r)=>e.rank-r.rank)}};var Ar=class{async getWallet(){return{available:241.5,pending:27.99,totalBalance:269.49,lifetimeEarned:396.94,lifetimeRedeemed:127.45,updatedAt:new Date().toISOString(),requiredActions:[{type:"ADD_PAYOUT_METHOD",transactionId:1234}]}}async getActivity(e,r){let o=this.getMockTransactions(),a=e??0,s=r??10;await new Promise(c=>setTimeout(c,400));let n=a*s;return{actorType:"user",partnerId:1,transactions:o.slice(n,n+s)}}getMockTransactions(){let e=[{name:"Adidas",logo:"https://logo.clearbit.com/adidas.com"},{name:"Fruga",logo:""},{name:"Samsung",logo:"https://logo.clearbit.com/samsung.com"},{name:"Booking.com",logo:"https://logo.clearbit.com/booking.com"},{name:"ASOS",logo:"https://logo.clearbit.com/asos.com"},{name:"Nike",logo:"https://logo.clearbit.com/nike.com"},{name:"Amazon",logo:"https://logo.clearbit.com/amazon.com"},{name:"Apple",logo:"https://logo.clearbit.com/apple.com"},{name:"Zara",logo:"https://logo.clearbit.com/zara.com"},{name:"Starbucks",logo:"https://logo.clearbit.com/starbucks.com"},{name:"Uber",logo:"https://logo.clearbit.com/uber.com"},{name:"Netflix",logo:"https://logo.clearbit.com/netflix.com"}],r=["APPROVED","FAILED","CANCELLED","PROCESSING","PENDING_RETAILER","PENDING_BANK","PAID"],o=["AFFILIATE_LINK","PAYOUT","BONUS"],a=[];a.push({id:1234,activityAmount:-120,occuredAt:"23/04/2026 14:30",brandName:"Fruga",status:"PROCESSING",purchaseAmount:0,brandLogo:"",offerName:"",type:"PAYOUT",flow:"PAYOUT",partnerEventId:"p1234",redemptionContext:"OTHER"}),a.push({id:5555,activityAmount:-45,occuredAt:"25/04/2026 11:15",brandName:"Fruga",status:"ACTION_REQUIRED",purchaseAmount:0,brandLogo:"",offerName:"",type:"PAYOUT",flow:"PAYOUT",partnerEventId:"p5555",redemptionContext:"NEW_POLICY"});for(let s=1;s<=50;s++){let n=e[s%e.length],l=r[s%r.length],c=o[s%o.length],d=s*25.5%300,p=d*.1,u="EARN";c==="PAYOUT"&&(d=0,p=-25,u="PAYOUT");let g=new Date(2026,3,15);g.setDate(g.getDate()-s);let h=String(g.getMonth()+1).padStart(2,"0"),v=String(g.getDate()).padStart(2,"0"),w=g.getFullYear();a.push({id:s,activityAmount:p,occuredAt:`${v}/${h}/${w} 10:00`,brandName:n.name,status:l,purchaseAmount:d,brandLogo:n.logo,offerName:c==="PAYOUT"?"":"Cashback Offer",type:c,flow:u,partnerEventId:`e${s}`,redemptionContext:c==="PAYOUT"?"OTHER":""})}return a}};var Or=class{constructor(e,r){this.walletService=e;this.activityService=r}async getWallet(){return this.walletService.getWallet()}async getActivity(e,r){return this.activityService.getActivity(e,r)}};var Fr=class{constructor(e){this.offersService=e}async getOffers(e){return this.offersService.getOffers(e)}async getFeaturedOffers(){return[]}async getOfferById(e){return null}async getCategories(){return this.offersService.getCategories()}};var Er=class{constructor(e){this.repository=e}async getMethod(){return console.log(">>>>>>>>>>>>>>> getMethod"),this.repository.getPaymentMethod()}async addMethod(e){return this.repository.savePaymentMethod(e)}async removeMethod(e){return this.repository.deletePaymentMethod(e)}};var Ir=class{constructor(e=!0){Wo(this,"method",null);e&&(this.method={id:"9007199254740991",methodType:"BANK",isDefault:!0,status:"ACTIVE",bank:{accountHolderName:"John Doe",accountLast4:"5789",sortCodeMasked:"12-34-**"},createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()})}async getPaymentMethod(){return await new Promise(e=>setTimeout(e,500)),this.method}async savePaymentMethod(e){return await new Promise(r=>setTimeout(r,1e3)),this.method={id:Math.random().toString(36).substr(2,9),methodType:"BANK",isDefault:!0,status:"ACTIVE",bank:{accountHolderName:e.accountHolderName,accountLast4:e.accountNumber.slice(-4),sortCodeMasked:e.sortCode.replace(/\d/g,"*")},createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},this.method}async deletePaymentMethod(e){await new Promise(r=>setTimeout(r,500)),this.method&&String(this.method.id)===String(e)&&(this.method=null)}};var Mr=class{constructor(e){this.service=e}async getPaymentMethod(){let e=await this.service.listMethods();return e.find(r=>r.status==="ACTIVE")||e[0]||null}async savePaymentMethod(e){return this.service.addBankMethod(e)}async deletePaymentMethod(e){return this.service.deleteMethod(e)}};import{jsx as Is}from"react/jsx-runtime";var Ya=Os(null),Za=({children:t,baseUrl:e})=>{let{token:r}=C(),o=Es(()=>{let a=$a(e),s,n,l;return r?(s=new Fr(new xr(a,r)),n=new Or(new yr(a,r),new wr(a,r)),l=new Mr(new kr(a,r))):(s=new Rr,n=new Ar,l=new Ir(!1)),{offerUseCases:new Sr(s),accountUseCases:new Cr(n),paymentService:new Er(l)}},[r,e]);return Is(Ya.Provider,{value:o,children:t})};function me(){let t=Fs(Ya);if(!t)throw new Error("useDependencies must be used within a DependencyProvider");return t}import{useState as Yr}from"react";import{Sparkles as Ms,TrendingUp as Ds,ShieldCheck as Ls,Gift as Bs,ChevronRight as _s}from"lucide-react";import{jsx as ie,jsxs as Dr}from"react/jsx-runtime";var Vt=[{title:"Welcome to SavingsBox",description:"Your new way to save while you shop. Earn cashback on every purchase from your favorite brands.",icon:Ms,color:"#8B5CF6",gradient:"linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%)"},{title:"Shop and Earn",description:"Simply browse through our partner brands, shop as usual, and watch your cashback balance grow.",icon:Ds,color:"#3B82F6",gradient:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},{title:"Secure Policy",description:"Use your earned cashback to pay for your insurance policies or withdraw it directly to your bank.",icon:Ls,color:"#10B981",gradient:"linear-gradient(135deg, #10B981 0%, #059669 100%)"},{title:"Bonus Rewards",description:"Get exclusive bonuses and higher cashback rates as you use the platform more.",icon:Bs,color:"#F59E0B",gradient:"linear-gradient(135deg, #F59E0B 0%, #D97706 100%)"}],Ja=({theme:t,onboardingStep:e,setOnboardingStep:r,onFinish:o})=>{let a=Vt[e],s=a.icon,n=()=>{e<Vt.length-1?r(e+1):o()};return Dr("div",{className:"relative flex h-full flex-col items-center justify-center overflow-hidden px-8 text-center transition-all duration-700",children:[ie("div",{className:"absolute -top-24 -left-24 h-64 w-64 rounded-full blur-[80px] opacity-20 transition-all duration-1000",style:{backgroundColor:a.color}}),Dr("div",{className:"relative z-10 flex flex-col items-center w-full max-w-[320px]",children:[ie("div",{className:"group mb-10 flex h-24 w-24 items-center justify-center rounded-[2rem] shadow-2xl transition-all duration-500 hover:scale-110",style:{background:a.gradient,boxShadow:`0 20px 40px -10px ${a.color}66`},children:ie(s,{size:44,className:"text-white drop-shadow-md transition-transform duration-500 group-hover:rotate-12"})}),Dr("div",{className:"space-y-4 animate-in slide-in-from-bottom-4 duration-700 fill-mode-both",children:[ie("h2",{className:"text-3xl font-extrabold tracking-tight sm:text-4xl",style:{color:t.text},children:a.title}),ie("p",{className:"text-lg leading-relaxed opacity-90 font-medium",style:{color:t.muted},children:a.description})]}),ie("div",{className:"mt-12 mb-10 flex gap-2.5",children:Vt.map((l,c)=>ie("div",{className:"h-2 rounded-full transition-all duration-500",style:{width:c===e?"32px":"8px",backgroundColor:c===e?a.color:t.isLight?"rgba(0,0,0,0.1)":"rgba(255,255,255,0.1)",opacity:c===e?1:.4}},c))}),Dr("button",{onClick:n,className:"group relative flex w-full cursor-pointer items-center justify-center gap-2 overflow-hidden rounded-[1.25rem] py-4.5 text-lg font-bold text-white shadow-[0_15px_30px_-5px_rgba(0,0,0,0.3)] transition-all hover:scale-[1.03] active:scale-[0.97]",style:{background:a.gradient},children:[ie("span",{children:e===Vt.length-1?"Start Saving":"Continue"}),ie(_s,{size:20,className:"transition-transform duration-300 group-hover:translate-x-1"})]}),e<Vt.length-1?ie("button",{onClick:o,className:"mt-6 cursor-pointer text-sm font-semibold opacity-60 transition-all hover:opacity-100 hover:translate-y-[-1px]",style:{color:t.text},children:"Skip for now"}):ie("div",{className:"mt-6 h-5"})]})]})};function We(...t){return t.filter(Boolean).join(" ")}import{Tag as Us,UserStar as zs,CircleHelp as Qs}from"lucide-react";import{jsx as Oo,jsxs as Hs}from"react/jsx-runtime";var Xa=({theme:t,activeTab:e,onTabChange:r,onHelpPageReset:o})=>Oo("div",{className:"mx-3 grid grid-cols-3 gap-2 rounded-3xl p-2 shadow-[0_10px_25px_-5px_rgba(0,0,0,0.1),0_8px_10px_-6px_rgba(0,0,0,0.1)]",style:{background:t.panel},children:[{id:"offers",label:"Offers",Icon:Us},{id:"account",label:"Account",Icon:zs},{id:"help",label:"Help",Icon:Qs}].map(a=>{let s=e===a.id,n=a.Icon;return Hs("button",{onClick:()=>{r(a.id),o()},className:"flex flex-col items-center justify-center gap-1 rounded-3xl px-3 py-2.5",style:{background:s?t.isLight?`color-mix(in srgb, ${t.accent} 18%, transparent)`:`color-mix(in srgb, ${t.accent} 25%, transparent)`:"transparent",color:s?t.accent:t.text,cursor:"pointer"},children:[Oo(n,{size:18,strokeWidth:2.2}),Oo("div",{className:"text-[11px] font-semibold leading-none",children:a.label})]},a.id)})});import qs from"react";import{ChevronLeft as ii,Sparkles as Ks,X as Gs,Settings as Vs}from"lucide-react";import{Sun as Ws,Moon as js}from"lucide-react";import{jsx as Fo,jsxs as ei}from"react/jsx-runtime";function ti({isLight:t,onToggle:e,accentColor:r,hoverClass:o="hover:bg-white/5"}){return ei("button",{type:"button",onClick:e,"aria-label":t?"Switch to dark mode":"Switch to light mode",title:t?"Dark mode":"Light mode",className:`group relative flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-all duration-300 cursor-pointer active:scale-90 ${o}`,children:[ei("div",{className:"relative h-5 w-5 flex items-center justify-center",children:[Fo(Ws,{size:18,strokeWidth:2.5,className:`absolute transition-all duration-500 ${t?"rotate-0 scale-100 opacity-100":"rotate-90 scale-0 opacity-0"}`,style:{transitionTimingFunction:"cubic-bezier(0.34, 1.56, 0.64, 1)",color:r}}),Fo(js,{size:18,strokeWidth:2.5,className:`absolute transition-all duration-500 ${t?"-rotate-90 scale-0 opacity-0":"rotate-0 scale-100 opacity-100"}`,style:{transitionTimingFunction:"cubic-bezier(0.34, 1.56, 0.64, 1)",color:r}})]}),Fo("div",{className:`absolute inset-0 rounded-full transition-opacity duration-700 blur-md -z-10 ${t?"bg-amber-400/20 opacity-100":"bg-blue-400/10 opacity-0"}`})]})}import{jsx as U,jsxs as Yt}from"react/jsx-runtime";function R({theme:t,className:e,style:r}){let o=t.isLight?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.06)",a=t.isLight?"rgba(0,0,0,0.12)":"rgba(255,255,255,0.12)";return U("div",{className:We("rounded-2xl",e),style:{background:`linear-gradient(90deg, ${o} 0%, ${a} 20%, ${o} 40%, ${o} 100%)`,backgroundSize:"200% 100%",animation:"shimmer 1.5s ease-in-out infinite",...r}})}function ri({theme:t}){return U("div",{className:"w-full rounded-2xl p-4",style:{background:t.isLight?"#FFFFFF":t.panel,border:t.isLight?"none":"1px solid rgba(255,255,255,0.08)",boxShadow:t.isLight?"0 1px 3px rgba(0,0,0,0.06)":"0 1px 3px rgba(0,0,0,0.2)"},children:Yt("div",{className:"flex items-center gap-3",children:[U(R,{theme:t,className:"h-10 w-16 shrink-0 rounded-lg"}),U("div",{className:"flex-1 space-y-2",children:U(R,{theme:t,className:"h-4 w-24"})}),U("div",{className:"shrink-0 flex flex-col items-end gap-2",children:U(R,{theme:t,className:"h-5 w-20 rounded-xl"})})]})})}function oi({theme:t}){return Yt("div",{className:"flex h-[140px] w-[140px] shrink-0 flex-col items-center justify-start rounded-2xl p-3 pt-4",style:{background:t.isLight?"#FFFFFF":t.panel,border:t.isLight?void 0:"1px solid rgba(255,255,255,0.08)",boxShadow:t.isLight?"0 1px 3px rgba(0,0,0,0.06)":"0 1px 3px rgba(0,0,0,0.2)"},children:[U(R,{theme:t,className:"h-10 w-12 shrink-0 rounded-lg"}),U(R,{theme:t,className:"mt-1.5 h-5 w-20"}),U(R,{theme:t,className:"mt-1 h-6 w-16 rounded-full"})]})}function ai({theme:t}){return U("div",{className:"flex flex-col gap-1 px-4 py-3",children:[1,2,3].map(e=>Yt("div",{className:"flex items-center gap-4 py-3",children:[U(R,{theme:t,className:"h-10 w-10 shrink-0 rounded-full"}),Yt("div",{className:"flex-1 space-y-2",children:[U(R,{theme:t,className:"h-4 w-1/2"}),U(R,{theme:t,className:"h-3 w-1/4 opacity-60"})]}),Yt("div",{className:"text-right space-y-2",children:[U(R,{theme:t,className:"h-4 w-16"}),U(R,{theme:t,className:"h-3 w-12 ml-auto opacity-60"})]})]},e))})}import{Fragment as Ct,jsx as b,jsxs as A}from"react/jsx-runtime";var Zt=[{id:"how-it-works",title:"How it works",body:t=>{let e=t.isLight?{border:"1px solid rgba(0,0,0,0.1)",background:"rgba(0,0,0,0.04)"}:{border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)"};return A(Ct,{children:[A("p",{className:"leading-relaxed",children:["You earn cashback when you shop with partner brands through links in this widget. Cashback appears as ",b("b",{children:"Pending"})," first, then becomes ",b("b",{children:"Available"})," after it's confirmed."]}),A("ul",{className:"mt-3 list-disc space-y-1 pl-5 text-sm opacity-90",children:[b("li",{children:"Pick an offer"}),b("li",{children:"Shop as normal on the brand's site"}),b("li",{children:"We track your purchase and update your credit"})]}),A("div",{className:"mt-4 space-y-3 text-sm opacity-90",children:[A("div",{children:[b("div",{className:"text-xs font-semibold opacity-80",children:"What happens after I click an offer?"}),A("p",{className:"mt-1 leading-relaxed",children:["We open the brand's website in a tracked session. If you complete a purchase, the brand reports it back to us and we add cashback to your account as ",b("b",{children:"Pending"}),"."]})]}),A("div",{children:[b("div",{className:"text-xs font-semibold opacity-80",children:"Why does cashback start as Pending?"}),b("p",{className:"mt-1 leading-relaxed",children:"Brands typically confirm orders after return periods or fraud checks. Once confirmed, Pending cashback becomes Available."})]}),A("div",{children:[b("div",{className:"text-xs font-semibold opacity-80",children:"Quick checklist (to avoid missing cashback)"}),A("ul",{className:"mt-2 list-disc space-y-1 pl-5",children:[b("li",{children:"Allow cookies for the host website and the brand site"}),b("li",{children:"Don't use ad-blockers that strip tracking parameters"}),b("li",{children:"Complete purchase in the same browser session"}),b("li",{children:"Avoid applying promo codes not listed on the offer"}),b("li",{children:"If you switch devices, start the offer again from this widget"})]})]}),A("div",{children:[b("div",{className:"text-xs font-semibold opacity-80",children:"Typical timelines"}),A("ul",{className:"mt-2 list-disc space-y-1 pl-5",children:[b("li",{children:"Pending shows up: within minutes to 48 hours"}),b("li",{children:"Confirmation: 7\u201360 days (varies by brand/category)"}),b("li",{children:"Available \u2192 redeem: depends on the host website's redemption options"})]})]}),A("div",{className:"rounded-2xl p-3",style:e,children:[b("div",{className:"text-xs font-semibold opacity-80",children:"Troubleshooting"}),A("div",{className:"mt-2 space-y-2 text-sm opacity-90",children:[b("div",{children:"\u2022 If you don't see Pending cashback within 48 hours, check you completed the purchase in the same browser session."}),b("div",{children:"\u2022 If you used a promo code not listed on the offer, cashback might be reduced or declined by the retailer."}),b("div",{children:"\u2022 Some categories confirm after returns windows, so Pending can take longer to become Available."}),b("div",{children:"\u2022 If you cancelled or returned an order, cashback is typically reversed."}),b("div",{children:"\u2022 If you used private browsing, tracking may fail. Retry in a normal session."}),b("div",{children:"\u2022 If you switch between tabs/checkout providers, keep cookies enabled."}),b("div",{children:"\u2022 Some retailers exclude gift cards and subscriptions from cashback."}),b("div",{children:"\u2022 If multiple cashback tools are active, retailers may reject tracking."}),b("div",{children:'\u2022 If you used "click & collect", cashback rules vary by retailer.'})]})]}),A("div",{className:"rounded-2xl p-3",style:e,children:[b("div",{className:"text-xs font-semibold opacity-80",children:"Need more help?"}),A("div",{className:"mt-2 space-y-2 text-sm opacity-90",children:[b("div",{children:"\u2022 Check your order history for the exact date/time of purchase."}),b("div",{children:"\u2022 If the retailer confirms the order, cashback will move to Available automatically."}),b("div",{children:"\u2022 In the full product, you can submit a missing cashback claim (prototype not wired)."})]})]})]})]})}},{id:"earn-more",title:"How to earn more credit",body:()=>A(Ct,{children:[b("p",{className:"leading-relaxed",children:"Use the filters to find higher cashback offers, and keep an eye on expiring deals."}),A("div",{className:"mt-3 space-y-2 text-sm opacity-90",children:[A("div",{children:["\u2022 Try ",b("b",{children:"Fashion"})," and ",b("b",{children:"Sports"})," for higher % offers."]}),b("div",{children:"\u2022 Check back weekly \u2014 offers change often."}),b("div",{children:"\u2022 Ensure cookies are enabled so tracking works properly."})]})]})},{id:"redeem",title:"How to redeem my credit",body:t=>{let e=t.isLight?{border:"1px solid rgba(0,0,0,0.1)",background:"rgba(0,0,0,0.04)"}:{border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)"};return A(Ct,{children:[A("p",{className:"leading-relaxed",children:["When your credit is ",b("b",{children:"Available"}),", you can redeem it \u2014 depending on what the host website supports."]}),A("div",{className:"mt-3 rounded-2xl p-3 text-sm",style:e,children:[b("div",{className:"font-medium",children:"Prototype note"}),b("div",{className:"mt-1 opacity-90",children:"In the real SDK, redemption options are configurable per host website."})]})]})}},{id:"credits-work",title:"How do credits work?",body:()=>A(Ct,{children:[A("p",{className:"leading-relaxed",children:["Credits are the cashback you earn from shopping with partner brands. They start as ",b("b",{children:"Pending"})," while the retailer confirms your purchase, then move to ",b("b",{children:"Available"})," once confirmed."]}),b("p",{className:"mt-3 leading-relaxed",children:"You can use Available credit to pay for insurance, add-ons, or other options offered by the host website."})]})},{id:"credits-expire",title:"When do credits expire?",body:()=>A(Ct,{children:[b("p",{className:"leading-relaxed",children:"Pending credits typically become Available within 7\u201360 days, depending on the retailer. Once Available, your credit balance is yours to use."}),b("p",{className:"mt-3 leading-relaxed",children:"Expiry rules vary by host website. In the full product, you can check your account for any expiry dates on your credit."})]})},{id:"contact",title:"Contact us",body:()=>A(Ct,{children:[b("p",{className:"leading-relaxed",children:"Need help with cashback, redemption, or your account? Get in touch through the host website's support channels."}),b("p",{className:"mt-3 leading-relaxed",children:"In the full product, you can submit a missing cashback claim or contact support directly from your account."})]})}];import{useEffect as $s}from"react";function rt(){let{accountUseCases:t}=me(),e=Ne(),{token:r,isOpen:o,isFocused:a,isIdle:s,available:n,pending:l,setBalances:c}=C(),d=o?a?s?3e4:1e4:3e4:!1,{data:p}=tt({queryKey:["wallet",r],queryFn:()=>t.getWallet(),refetchInterval:d});return $s(()=>{p&&(p.available!==n||p.pending!==l)&&(c(p.available,p.pending),e.invalidateQueries({queryKey:["activity"]}))},[p,n,l,e,c]),{wallet:p}}import{jsx as M,jsxs as G}from"react/jsx-runtime";var Ys=()=>{let{wallet:t}=rt(),e=t?.available||0;return G("div",{className:"mt-1 flex items-baseline gap-1",children:[G("span",{className:"text-3xl font-bold tracking-tight",children:["\xA3",e.toFixed(2)]}),M(Ks,{size:20,className:"opacity-80"})]})},Lr=({toggle:t,theme:e,allowUserThemeControl:r,onThemeModeChange:o,isAccentBackground:a=!1})=>{let s=a?e.accentText:e.text,n=a?"hover:bg-white/15":e.isLight?"hover:bg-black/5":"hover:bg-white/10";return G("div",{className:"absolute right-2 top-3 z-[100] flex items-center gap-1",style:{color:s},children:[r&&M(ti,{isLight:e.isLight,onToggle:()=>o?.(e.isLight?"dark":"light"),accentColor:s,hoverClass:n}),M("button",{className:`cursor-pointer rounded-full p-2 transition-all duration-200 active:scale-90 ${n}`,onClick:t,"aria-label":"Close",title:"Close",children:M(Gs,{size:18,strokeWidth:2.5})})]})},si=({tab:t,theme:e,allowUserThemeControl:r,onThemeModeChange:o,helpPage:a,setHelpPage:s,accountView:n,setAccountView:l})=>{let{toggle:c,partnerPayout:d}=C(),p=d==="USER";if(t==="offers")return G("div",{className:"relative px-4 pt-4 pb-6",style:{background:`linear-gradient(135deg, ${e.accent} 0%, color-mix(in srgb, ${e.accent} 75%, black) 100%)`,color:e.accentText},children:[M(Lr,{toggle:c,theme:e,allowUserThemeControl:r,onThemeModeChange:o,isAccentBackground:!0}),G("div",{className:"mt-6 px-1",children:[M("div",{className:"text-sm font-medium opacity-90",children:"Available credit"}),M(qs.Suspense,{fallback:M(R,{theme:e,className:"mt-1 h-9 w-28 rounded-lg",style:{background:"rgba(255,255,255,0.3)"}}),children:M(Ys,{})})]})]});if(t==="account"){if(n!=="transactions"){let u=n==="settings"?"Settings":"Payout Method";return G("div",{className:"relative px-4 pt-6 pb-2",children:[M(Lr,{toggle:c,theme:e,allowUserThemeControl:r,onThemeModeChange:o}),G("div",{className:"flex items-center gap-2",children:[G("button",{className:"inline-flex items-center gap-1 rounded-full cursor-pointer border px-2 py-1 text-xs transition hover:bg-white/10",style:{borderColor:e.border,background:e.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.03)"},onClick:()=>{l?.(n==="payout-method"?"settings":"transactions")},children:[M(ii,{size:14})," Back"]}),M("div",{className:"text-lg font-semibold",children:u})]})]})}return G("div",{className:"relative w-full z-0 px-4 pt-4 pb-12 flex flex-row justify-between items-start",style:{background:`linear-gradient(135deg, ${e.accent} 0%, color-mix(in srgb, ${e.accent} 75%, black) 100%)`,color:e.accentText},children:[G("div",{className:"flex gap-3 items-center",children:[M("div",{className:"mt-2 text-lg font-semibold flex-1",children:"Account"}),p&&M("button",{className:"mt-2 rounded-full p-1.5 cursor-pointer transition hover:bg-white/15",onClick:()=>l?.("settings"),"aria-label":"Settings",children:M(Vs,{size:20})})]}),M(Lr,{toggle:c,theme:e,allowUserThemeControl:r,onThemeModeChange:o,isAccentBackground:!0})]})}return G("div",{className:"relative px-4 pt-6 pb-2",children:[M(Lr,{toggle:c,theme:e,allowUserThemeControl:r,onThemeModeChange:o}),a?G("div",{className:"flex items-center gap-2",children:[G("button",{className:"inline-flex items-center gap-1 rounded-full cursor-pointer border px-2 py-1 text-xs",style:{borderColor:e.border,background:e.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.03)"},onClick:()=>s(null),children:[M(ii,{size:14})," Back"]}),M("div",{className:"truncate text-lg font-semibold",children:Zt.find(u=>u.id===a)?.title})]}):M("div",{className:"text-lg font-semibold",children:"Help"})]})};import{Suspense as sn,useCallback as nn,useEffect as ln,useRef as cn,useState as zr}from"react";import{Search as li,X as Js}from"lucide-react";import{jsx as Zs}from"react/jsx-runtime";function Io({active:t,onClick:e,children:r,theme:o}){return Zs("button",{onClick:e,className:"shrink-0 rounded-lg px-3.5 py-1.5 text-xs font-medium transition cursor-pointer",style:{background:t?o.accent:o.isLight?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.06)",color:t?o.accentText:o.text,border:`1px solid ${t?(o.isLight,"rgba(0,0,0,0.15)"):o.border}`},children:r})}function ni(){let{offerUseCases:t}=me(),{isOpen:e,isFocused:r,isIdle:o}=C(),a=e?r?o?3e4:1e4:3e4:!1,{data:s}=tt({queryKey:["offerCategories"],queryFn:()=>t.getOfferCategories(),refetchInterval:a});return{categories:s}}import{jsx as Se,jsxs as Br}from"react/jsx-runtime";var ci=({theme:t,showSearch:e,setShowSearch:r,searchUI:o,setSearchUI:a,activeCatUI:s,setActiveCatUI:n,searchRef:l})=>{let{categories:c}=ni();return Br("div",{className:"sticky top-0 z-10 mx-3 mt-3 space-y-3 pb-3",style:{background:t.bg},children:[Br("div",{className:"flex items-center justify-between",children:[Se("div",{className:"text-base font-semibold",children:"Offers"}),Se("button",{className:"inline-flex h-9 w-9 items-center justify-center rounded-2xl border transition-opacity active:opacity-70 cursor-pointer",style:{borderColor:t.border,background:t.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},onClick:()=>r(d=>!d),"aria-label":e?"Hide search":"Search offers",children:Se(li,{size:16,className:"opacity-80"})})]}),e&&Br("div",{className:"flex items-center gap-2 rounded-2xl border px-3 py-2",style:{borderColor:t.border,background:t.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},children:[Se(li,{size:16,className:"opacity-80"}),Se("input",{ref:l,value:o,onChange:d=>a(d.target.value),placeholder:"Search offers",className:"w-full bg-transparent text-sm outline-none"}),o&&Se("button",{className:"rounded-xl p-1 cursor-pointer",onClick:()=>a(""),"aria-label":"Clear search",children:Se(Js,{size:16,className:"opacity-70"})})]}),Br("div",{className:"flex gap-2 overflow-x-auto overscroll-contain fruga-scrollbar pb-1",children:[Se(Io,{theme:t,active:s==="All",onClick:()=>n("All"),children:"All"}),c.map(d=>Se(Io,{theme:t,active:s===d.name,onClick:()=>n(d.name),children:d.name},d.id))]})]})};import mi from"react";import{jsx as di}from"react/jsx-runtime";function Mo(t){return t?t.replace(/[^a-zA-Z0-9 ]/g,"").split(" ").filter(Boolean).slice(0,2).map(e=>e[0]?.toUpperCase()).join("").slice(0,2):""}function Xt({brand:t,theme:e,className:r}){return di("div",{className:We("flex h-10 w-16 shrink-0 items-center justify-center overflow-hidden rounded-lg text-xs font-semibold",r),style:{color:e.text},"aria-label":`${t.brandName} logo`,title:t.brandName,children:t.logo?di("img",{src:t.logo,alt:"",className:"h-full w-full object-contain"}):Mo(t.brandName)})}import{jsx as Ce,jsxs as Rt}from"react/jsx-runtime";var _r=t=>Number.isInteger(t)?t.toFixed(0):t.toFixed(1),pi=({offer:t,theme:e,onClick:r})=>Rt("div",{role:"button",tabIndex:0,onClick:()=>r(t),onKeyDown:o=>o.key==="Enter"&&r(t),className:"flex h-[140px] w-[140px] shrink-0 cursor-pointer flex-col items-center justify-start rounded-2xl p-3 pt-4",style:{background:e.isLight?"#FFFFFF":e.panel,border:e.isLight?void 0:"1px solid rgba(255,255,255,0.08)",boxShadow:e.isLight?"0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.05)":"0 4px 12px rgba(0,0,0,0.25)",scrollSnapAlign:"start"},children:[Ce(Xt,{brand:t,theme:e,className:"h-10 w-12 shrink-0"}),Ce("div",{className:"mt-1.5 w-full truncate text-center text-sm font-bold leading-tight",children:t.brandName}),Ce("div",{className:"mt-1 flex shrink-0 justify-center",children:Rt("span",{className:"rounded-full px-2.5 py-1 text-center text-xs font-bold",style:{background:`color-mix(in srgb, ${e.accent} ${e.isLight?"15%":"20%"}, transparent)`,color:e.accent},children:[_r(t.cashback),"% cashback"]})})]}),ui=({offer:t,theme:e,onClick:r})=>Ce("div",{role:"button",tabIndex:0,onClick:()=>r(t),onKeyDown:o=>o.key==="Enter"&&r(t),className:"w-full cursor-pointer rounded-2xl p-4 text-left transition-transform active:scale-[0.98]",style:{background:e.isLight?"#FFFFFF":e.panel,border:e.isLight?void 0:"1px solid rgba(255,255,255,0.08)",boxShadow:e.isLight?"0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.05)":"0 2px 8px rgba(0,0,0,0.25), 0 4px 12px rgba(0,0,0,0.2)"},children:Rt("div",{className:"flex items-center gap-3",children:[Ce(Xt,{brand:t,theme:e}),Ce("div",{className:"flex-1 min-w-0",children:Ce("div",{className:"text-base font-bold truncate",children:t.brandName})}),Rt("div",{className:"shrink-0 flex flex-col items-end",children:[Rt("div",{className:"flex items-center justify-end gap-1 text-lg font-bold",style:{color:e.accent},children:[t.cashback>5&&Ce("span",{className:"inline-block text-base leading-none animate-fire","aria-hidden":!0,children:"\u{1F525}"}),_r(t.cashback),"%"]}),Ce("div",{className:"text-[11px] mt-0.5",style:{color:e.muted},children:"Cashback"}),t.endDate&&Ka(t.endDate,30)&&Rt("div",{className:"mt-2 rounded-full px-2.5 py-1.5 text-xs font-semibold",style:{background:e.isLight?"rgba(245,158,11,0.15)":"rgba(251,191,36,0.2)",color:e.isLight?"#B45309":e.warning,border:`1px solid ${e.isLight?"rgba(245,158,11,0.35)":"rgba(251,191,36,0.35)"}`},children:["Expiring soon \xB7 ",Ga(t.endDate)," days"]})]})]})});import{Fragment as tn,jsx as B,jsxs as At}from"react/jsx-runtime";var hi=({children:t,color:e})=>B("div",{className:"text-[11px] font-semibold uppercase tracking-wide",style:{color:e},children:t}),Xs=({theme:t})=>At("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[B("div",{className:"mb-3 text-3xl","aria-hidden":!0,children:"\u{1F622}"}),B("div",{className:"text-sm font-semibold",children:"No offers found"}),B("div",{className:"mt-1 text-xs",style:{color:t.muted},children:"Try a different search or filter."})]}),en=({theme:t})=>B("div",{className:"flex items-center justify-center py-10",style:{color:t.muted},children:At("div",{className:"flex items-center gap-2 text-sm",children:[B("span",{className:"h-4 w-4 animate-spin rounded-full border-2",style:{borderColor:t.isLight?"rgba(0,0,0,0.2)":"rgba(255,255,255,0.2)",borderTopColor:t.isLight?"rgba(0,0,0,0.7)":"rgba(255,255,255,0.7)"}}),"Updating offers\u2026"]})}),fi=({theme:t,appliedSearch:e,appliedCat:r,featuredOffers:o=[],results:a,handleOfferClick:s,fetchNextPage:n,hasNextPage:l,isFetchingNextPage:c})=>{let d=o.length>0&&r==="All"&&e.trim()==="",p=mi.useRef(null);return mi.useEffect(()=>{let u=new IntersectionObserver(g=>{g[0].isIntersecting&&l&&!c&&n?.()},{threshold:.1});return p.current&&u.observe(p.current),()=>u.disconnect()},[l,c,n]),B("div",{className:"relative flex-1 overflow-auto overscroll-contain fruga-scrollbar px-3 pb-24 pt-3",children:At("div",{className:"space-y-4",children:[d&&At("div",{className:"-mx-3 px-3",children:[At("div",{className:"mb-2 flex items-center gap-1.5",children:[B(hi,{color:t.muted,children:"BEST DEALS"}),B("span",{className:"text-sm",style:{animation:"fire-flicker 1.2s ease-in-out infinite"},"aria-hidden":!0,children:"\u{1F525}"})]}),B("div",{className:"flex gap-3 overflow-x-auto overscroll-contain fruga-scrollbar pb-1",style:{scrollSnapType:"x mandatory"},children:o.map(u=>B(pi,{offer:u,theme:t,onClick:s},`featured-${u.id}`))}),B("div",{className:"mt-3",children:B(hi,{color:t.muted,children:"All"})})]}),a.length===0?B(Xs,{theme:t}):At(tn,{children:[a.map(u=>B(ui,{offer:u,theme:t,onClick:s},u.id)),B("div",{ref:p,className:"h-4 w-full"}),c&&B(en,{theme:t})]})]})})};function gi({category:t,query:e,pageSize:r=10}={}){let{offerUseCases:o}=me(),a=["offers","list",t||"All",e||""],{data:s,fetchNextPage:n,hasNextPage:l,isFetchingNextPage:c}=Gt({queryKey:a,queryFn:({pageParam:h=0})=>o.getOffers({pageNumber:h,pageSize:r,categories:t&&t!=="All"?[t]:[],query:e||void 0}),initialPageParam:0,getNextPageParam:h=>{if(h.number+1<h.totalPages)return h.number+1}}),{data:d}=tt({queryKey:["offers","featured"],queryFn:()=>o.getFeaturedOffers()}),p=So({mutationFn:h=>o.claimOffer(h)}),u=async h=>p.mutateAsync(h);return{offers:s?.pages.flatMap(h=>h.content)||[],featuredOffers:d,claimOffer:u,fetchNextPage:n,hasNextPage:l,isFetchingNextPage:c}}import{X as on}from"lucide-react";import{jsx as rn}from"react/jsx-runtime";var Ot=({onClose:t,className:e=""})=>rn("div",{className:`absolute inset-0 cursor-pointer bg-black/55 transition-opacity animate-in fade-in duration-300 ${e}`,onClick:t,"aria-hidden":"true"});import{jsx as Re,jsxs as Ft}from"react/jsx-runtime";var vi=({theme:t,offer:e,onClose:r})=>Ft("div",{className:"absolute inset-0 z-50 flex items-center justify-center",children:[Re(Ot,{onClose:r}),Ft("div",{className:"relative mx-4 w-full max-w-sm rounded-[24px] border p-4 shadow-2xl",style:{borderColor:t.border,background:t.panel,color:t.text},children:[Ft("div",{className:"flex items-start justify-between gap-3",children:[Ft("div",{className:"flex items-center gap-3",children:[Re(Xt,{brand:e,theme:t}),Ft("div",{children:[Re("div",{className:"text-sm font-semibold",children:e.brandName}),Ft("div",{className:"mt-1 inline-flex items-center gap-1 px-0 py-0 text-base font-bold",children:[e.cashback>5?Re("span",{className:"inline-block text-sm leading-none animate-fire","aria-hidden":!0,children:"\u{1F525}"}):null,_r(e.cashback),"% cashback"]})]})]}),Re("button",{className:"p-2 cursor-pointer",onClick:r,"aria-label":"Close",title:"Close",children:Re(on,{size:18,strokeWidth:2.5})})]}),Re("div",{className:"mt-4 text-sm",style:{color:t.muted},children:"You will now be redirected to the retailer website to complete your transaction."}),e.terms?Re("div",{className:"mt-3 text-[11px] leading-snug",style:{color:t.muted},children:e.terms}):null,Re("button",{className:"mt-4 inline-flex h-11 w-full cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold",style:{background:t.accent,color:t.accentText},onClick:()=>{let o=e.link||`https://www.google.com/search?q=${encodeURIComponent(e.brandName+" cashback")}`;window.open(o,"_blank","noopener,noreferrer"),r()},children:"Shop now"})]})]});import{jsx as V,jsxs as Et}from"react/jsx-runtime";var bi=({theme:t})=>V("div",{className:"space-y-0",children:[1,2,3,4,5].map(e=>Et("div",{className:"flex items-stretch gap-3 px-4 py-3",style:{borderBottom:e<5?`1px solid ${t.border}`:"none"},children:[V(R,{theme:t,className:"h-12 w-16 shrink-0 rounded-lg"}),Et("div",{className:"flex-1 space-y-2",children:[V(R,{theme:t,className:"h-4 w-24"}),V(R,{theme:t,className:"h-3 w-16"})]}),V(R,{theme:t,className:"h-5 w-14 shrink-0"})]},e))}),yi=({theme:t})=>Et("div",{className:"relative flex-1 overflow-hidden flex flex-col min-h-0 pt-0",children:[Et("div",{className:"px-3 pt-4 mb-4",children:[V(R,{theme:t,className:"h-10 w-full rounded-2xl"}),V("div",{className:"mt-4 flex gap-2 overflow-hidden",children:[1,2,3,4].map(e=>V(R,{theme:t,className:"h-8 w-20 rounded-full shrink-0"},e))})]}),Et("div",{className:"flex-1 px-3 space-y-4 overflow-hidden pt-3",children:[Et("div",{className:"-mx-3 px-3",children:[V("div",{className:"text-[11px] font-semibold uppercase tracking-wide mb-2",style:{color:t.muted},children:"BEST DEALS"}),V("div",{className:"flex gap-2 overflow-hidden",children:[1,2,3].map(e=>V(oi,{theme:t},e))})]}),V("div",{className:"text-[11px] font-semibold uppercase tracking-wide mb-2",style:{color:t.muted},children:"ALL"}),[1,2,3].map(e=>V(ri,{theme:t},e))]})]});import{AlertTriangle as an}from"lucide-react";import{jsx as er,jsxs as wi}from"react/jsx-runtime";var xi=({theme:t,onAddPayout:e})=>{let r=t.isLight;return wi("button",{type:"button",onClick:e,className:"flex w-full items-start gap-3 rounded-2xl border-2 px-4 py-3.5 text-left shadow-lg transition hover:brightness-95 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-offset-2 cursor-pointer",style:{borderColor:`${t.danger}${r?"40":"30"}`,background:t.danger,color:"#FFFFFF",boxShadow:`0 10px 20px -5px ${t.danger}40`},"aria-label":"Payout pending. Add a payout method to receive your money.",children:[er("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full",style:{background:"rgba(255, 255, 255, 0.2)"},children:er(an,{className:"h-5 w-5",strokeWidth:2.5,"aria-hidden":!0})}),wi("span",{className:"min-w-0 flex-1",children:[er("span",{className:"block text-sm font-black leading-snug tracking-tight",children:"Payout pending"}),er("span",{className:"mt-0.5 block text-[13px] font-semibold leading-tight opacity-90",children:"Add a payout method now so we can send your money."}),er("span",{className:"mt-2.5 inline-block text-[12px] font-bold underline decoration-2 underline-offset-4 transition-all hover:opacity-80",children:"Add bank details"})]})]})};import{jsx as ki}from"react/jsx-runtime";var Ur=({theme:t,onAddPayout:e,className:r="relative z-10 mt-3 px-3"})=>{let{wallet:o}=rt();return o?.requiredActions?.some(s=>s.type==="ADD_PAYOUT_METHOD")?ki("div",{className:r,children:ki(xi,{theme:t,onAddPayout:e})}):null};import{Fragment as pn,jsx as je,jsxs as Ni}from"react/jsx-runtime";var dn=({theme:t,searchUI:e,activeCatUI:r,handleOfferClick:o,onNavigateToPayoutMethod:a})=>{let{offers:s,featuredOffers:n,fetchNextPage:l,hasNextPage:c,isFetchingNextPage:d}=gi({query:e,category:r,pageSize:10});return Ni("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[je(Ur,{theme:t,onAddPayout:()=>a?.()}),je(fi,{theme:t,appliedSearch:e,appliedCat:r,featuredOffers:n,results:s,handleOfferClick:o,fetchNextPage:l,hasNextPage:c,isFetchingNextPage:d})]})},Pi=({theme:t,onNavigateToPayoutMethod:e})=>{let[r,o]=zr(!1),[a,s]=zr(""),[n,l]=zr("All"),[c,d]=zr(null),p=Wa(a,300),u=cn(null);ln(()=>{if(r){let h=window.setTimeout(()=>u.current?.focus(),0);return()=>window.clearTimeout(h)}},[r]);let g=nn(h=>{d(h)},[]);return Ni(pn,{children:[c&&je(vi,{theme:t,offer:c,onClose:()=>d(null)}),je(ci,{theme:t,showSearch:r,setShowSearch:o,searchUI:a,setSearchUI:s,activeCatUI:n,setActiveCatUI:l,searchRef:u}),je(sn,{fallback:je("div",{className:"px-3",children:je(yi,{theme:t})}),children:je(dn,{theme:t,searchUI:p,activeCatUI:n,handleOfferClick:g,onNavigateToPayoutMethod:e})})]})};import{Suspense as Uo}from"react";function Ti(t=10){let{accountUseCases:e}=me(),{token:r}=C();return Gt({queryKey:["activity",r,t],queryFn:({pageParam:o=0})=>e.getActivity(o,t),initialPageParam:0,getNextPageParam:(o,a)=>{if(o.transactions&&o.transactions.length===t)return a.length},staleTime:1/0,refetchOnWindowFocus:!1,refetchOnReconnect:!1})}import{useEffect as un,useRef as mn,useState as hn}from"react";import{Info as fn}from"lucide-react";import{jsx as Do,jsxs as gn}from"react/jsx-runtime";function Si({theme:t,label:e}){let[r,o]=hn(!1),a=mn(null);return un(()=>{if(!r)return;let s=n=>{a.current&&(a.current.contains(n.target)||o(!1))};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[r]),gn("span",{ref:a,className:"relative inline-flex items-center",children:[Do("button",{type:"button",className:"ml-1 inline-flex h-4 w-4 items-center justify-center rounded-full","aria-label":"More info",onClick:s=>{s.stopPropagation(),o(n=>!n)},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:Do(fn,{size:11,className:"opacity-80"})}),Do("span",{className:We("pointer-events-none absolute bottom-full left-1/2 z-20 mb-2 w-64 -translate-x-1/2 rounded-xl border px-3 py-2 text-[11px] leading-snug shadow-xl transition",r?"opacity-100":"opacity-0"),style:{background:t.tooltipBg,borderColor:t.tooltipBorder,color:t.text},children:e})]})}import{jsx as Ae,jsxs as se}from"react/jsx-runtime";var Ci=({theme:t,accountDataLoading:e,available:r,pending:o,lifetimeSavings:a})=>Ae("div",{className:"relative z-20 px-3 -mt-10",children:se("div",{className:"rounded-3xl border p-4",style:{borderColor:t.border,background:t.isLight?t.panel:t.panel2,boxShadow:t.isLight?"0 4px 12px rgba(0,0,0,0.08)":"0 4px 12px rgba(0,0,0,0.25)"},children:[se("div",{className:"flex items-end justify-between gap-4",children:[se("div",{children:[e?Ae(R,{theme:t,className:"h-9 w-24"}):se("div",{className:"text-3xl font-bold",children:["\xA3",r.toFixed(2)]}),Ae("div",{className:"mt-1 text-xs",style:{color:t.muted},children:"Available Credit"})]}),se("div",{className:"text-right",children:[e?Ae(R,{theme:t,className:"mx-auto h-5 w-14"}):se("div",{className:"text-sm font-semibold",children:["\xA3",o.toFixed(2)]}),se("div",{className:"mt-1 flex items-center justify-end gap-1 text-[11px]",style:{color:t.muted},children:["Pending",Ae(Si,{theme:t,label:"Waiting for retailer confirmation and processing and will be available soon"})]})]}),se("div",{className:"text-right",children:[e?Ae(R,{theme:t,className:"mx-auto h-5 w-14"}):se("div",{className:"text-sm font-semibold",children:["\xA3",(r+o).toFixed(2)]}),Ae("div",{className:"mt-1 text-[11px]",style:{color:t.muted},children:"Total Balance"})]})]}),se("div",{className:"mt-3 flex items-center justify-between border-t pt-3",style:{borderColor:t.border},children:[Ae("div",{className:"text-[11px] uppercase tracking-wider",style:{color:t.muted},children:"Lifetime Insurance Savings"}),e?Ae(R,{theme:t,className:"h-4 w-16"}):se("div",{className:"text-sm font-semibold",style:{color:t.muted},children:["\xA3",a.toFixed(2)]})]})]})});import{useEffect as kn,useRef as Pn}from"react";import{useId as vn}from"react";import{jsx as he,jsxs as Qr}from"react/jsx-runtime";function Ri({accent:t,className:e}){let r=vn().replace(/:/g,""),o=`color-mix(in srgb, ${t} 70%, black)`,a=`color-mix(in srgb, ${t} 45%, black)`;return Qr("svg",{viewBox:"0 0 256 256",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,style:{background:"transparent"},children:[Qr("defs",{children:[Qr("linearGradient",{id:`shieldGrad-${r}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[he("stop",{offset:"0%",stopColor:o}),he("stop",{offset:"100%",stopColor:a})]}),Qr("linearGradient",{id:`glossGrad-${r}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[he("stop",{offset:"0%",stopColor:"white",stopOpacity:"0.35"}),he("stop",{offset:"100%",stopColor:"white",stopOpacity:"0"})]}),he("filter",{id:`shieldDropShadow-${r}`,x:"-10%",y:"-10%",width:"120%",height:"130%",children:he("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodColor:t,floodOpacity:"0.4"})})]}),he("path",{d:"M 40 50 Q 128 30 216 50 C 216 150 160 210 128 236 C 96 210 40 150 40 50 Z",fill:a,filter:`url(#shieldDropShadow-${r})`}),he("path",{d:"M 52 58 Q 128 42 204 58 C 204 144 156 196 128 218 C 100 196 52 144 52 58 Z",fill:`url(#shieldGrad-${r})`,stroke:o,strokeWidth:"3"}),he("path",{d:"M 52 58 Q 128 42 128 42 L 128 218 C 100 196 52 144 52 58 Z",fill:`url(#glossGrad-${r})`}),he("path",{d:"M 60 66 Q 128 52 196 66 Q 128 80 60 66 Z",fill:"white",fillOpacity:"0.1"})]})}import{useId as bn}from"react";import{jsx as fe,jsxs as tr}from"react/jsx-runtime";function Ai({accent:t,className:e}){let r=bn().replace(/:/g,""),o=`color-mix(in srgb, ${t} 70%, black)`,a=`color-mix(in srgb, ${t} 45%, black)`;return tr("svg",{viewBox:"0 0 256 256",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,style:{background:"transparent"},children:[tr("defs",{children:[tr("linearGradient",{id:`giftGrad-${r}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[fe("stop",{offset:"0%",stopColor:o}),fe("stop",{offset:"100%",stopColor:a})]}),fe("filter",{id:`giftDropShadow-${r}`,x:"-20%",y:"-20%",width:"140%",height:"140%",children:fe("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodColor:t,floodOpacity:"0.4"})})]}),tr("g",{filter:`url(#giftDropShadow-${r})`,children:[fe("rect",{x:"36",y:"80",width:"85",height:"36",fill:`url(#giftGrad-${r})`}),fe("rect",{x:"135",y:"80",width:"85",height:"36",fill:`url(#giftGrad-${r})`}),fe("rect",{x:"48",y:"130",width:"73",height:"90",fill:`url(#giftGrad-${r})`}),fe("rect",{x:"135",y:"130",width:"73",height:"90",fill:`url(#giftGrad-${r})`}),tr("g",{stroke:o,strokeWidth:"14",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[fe("path",{d:"M 121 80 C 110 25 55 25 55 55 C 55 75 95 80 121 80 Z"}),fe("path",{d:"M 135 80 C 146 25 201 25 201 55 C 201 75 161 80 135 80 Z"})]})]})]})}import{AlertTriangle as yn}from"lucide-react";import{jsx as Hr,jsxs as wn}from"react/jsx-runtime";var Oi=({theme:t,onAddDetails:e})=>{let{setIsAddingPayoutFromAlert:r}=C(),o=t.isLight,a=()=>{r(!0),e()};return wn("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1.5 rounded-2xl border px-3 py-2.5 text-[11px] leading-tight shadow-sm transition-all",style:{borderColor:`${t.danger}${o?"35":"25"}`,background:o?`${t.danger}08`:`${t.danger}12`,color:t.text},children:[Hr("div",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full",style:{background:`${t.danger}20`},children:Hr(yn,{className:"h-3.5 w-3.5",strokeWidth:2.5,style:{color:t.danger},"aria-hidden":!0})}),Hr("span",{className:"min-w-0 flex-1 font-semibold opacity-90",children:"Bank details required to send this payout."}),Hr("button",{type:"button",className:"ml-auto shrink-0 cursor-pointer text-[12px] font-extrabold underline decoration-2 underline-offset-2 transition-all hover:opacity-80 active:scale-95",style:{color:t.accent},onClick:a,children:"Add details"})]})};import{Fragment as Lo,jsx as F,jsxs as Oe}from"react/jsx-runtime";var xn=({transaction:t,theme:e,isPolicy:r,isPayout:o,isBonus:a})=>F("div",{className:"flex w-16 shrink-0 self-stretch items-center justify-center overflow-hidden rounded-lg text-xs font-semibold",style:{color:e.text},children:r||o?F(Ri,{accent:e.accent,className:"h-[40px] w-[40px] object-contain"}):a?F(Ai,{accent:e.accent,className:"h-[40px] w-[40px] object-contain"}):t.brandName&&t.brandLogo?F("img",{src:t.brandLogo,alt:"",className:"h-full w-full object-contain"}):Mo(t.brandName||t.type)}),Fi=({transaction:t,theme:e,isLast:r,requiredActions:o,onAddPayout:a})=>{let s=t.brandName==="Policy purchase",n=t.type==="BONUS",l=t.flow==="EARN"&&t.type==="AFFILIATE_LINK"&&t.status==="PAID",c=t.flow==="EARN"&&t.type==="AFFILIATE_LINK"&&["APPROVED","PENDING_PROVIDER","PENDING_BANK","PENDING_RETAILER"].includes(t.status),d=t.status==="PROCESSING",p=t.flow==="PAYOUT"&&t.status==="PAID",u=t.flow==="PAYOUT"&&t.status==="FAILED",g=t.flow==="PAYOUT"&&t.status==="CANCELLED",h=t.flow==="PAYOUT"&&t.status==="ACTION_REQUIRED",v=t.flow==="PAYOUT",w=v||d||u||s||t.activityAmount<0,k=l||c||d||u||g||!s&&!n&&!p&&t.purchaseAmount!=null&&t.purchaseAmount>0,P=t.activityAmount||0,S=t.purchaseAmount||0,O=k&&S&&!v?Math.round(P/S*100):null,Y={NEW_POLICY:"New policy purchase",POLICY_ADDON:"Policy add-on purchase",CLAIM_EXCESS:"Claim excess payment",OTHER:"Other"},Z=n||t.flow==="EARN"&&!d?e.success:v||s||d?e.text:P>=0?e.success:e.danger,Fe=Va(s?"Policy purchase":n?"Bonus":p||d||u||g||h?Y[t.redemptionContext]||"Other":l||c?t.brandName||"Payout":O!=null?`${O}% Cashback`:t.brandName||(t.type==="PAYOUT"?"Payout":"Activity"),40),Xr=()=>F(Lo,{children:c?F("span",{className:"text-[11px]",style:{color:e.warning},children:"Pending"}):d?F("span",{className:"text-[11px]",style:{color:e.warning},children:"Processing"}):u?F("span",{className:"text-[11px]",style:{color:e.muted},children:"Payout failed"}):g?F("span",{className:"text-[11px]",style:{color:e.muted},children:"Payout cancelled"}):h?F("span",{className:"text-[11px]",style:{color:e.warning},children:"On hold"}):null});return Oe("div",{className:"flex items-stretch gap-3 px-4 py-3 flex-col",style:{borderBottom:r?"none":`1px solid ${e.border}`},children:[Oe("div",{className:"flex items-stretch gap-3",children:[F(xn,{transaction:t,theme:e,isPolicy:s,isPayout:p||d||u||g||h,isBonus:n}),F("div",{className:"grid min-w-0 flex-1 grid-cols-[1fr_auto] items-baseline gap-x-4 gap-y-0.5",children:k?Oe(Lo,{children:[F("div",{className:"min-w-0 text-sm font-semibold truncate",children:Fe}),Oe("div",{className:"flex items-center justify-end gap-1.5",children:[F(Xr,{}),Oe("span",{className:"text-sm font-bold",style:{color:Z},children:[w?"-":"+","\xA3",Math.abs(P).toFixed(2)]})]}),F("div",{className:"min-w-0 text-[11px] font-bold",style:{color:e.muted},children:l||c||d?t.offerName:O!=null?`${O}% Cashback`:null}),Oe("div",{className:"text-right text-xs",style:{color:e.muted},children:["\xA3",S.toFixed(2)]}),F("div",{className:"text-[11px]",style:{color:e.muted},children:Ro(t.occuredAt)}),F("div",{})]}):Oe(Lo,{children:[F("div",{className:"min-w-0 text-sm font-semibold",style:{color:e.text},children:Fe}),Oe("div",{className:"flex items-center justify-end gap-1.5",children:[F(Xr,{}),Oe("span",{className:"text-sm font-semibold",style:{color:Z},children:[w?"-":"+","\xA3",Math.abs(P).toFixed(2)]})]}),F("div",{className:"text-[11px]",style:{color:e.muted},children:Ro(t.occuredAt)}),F("div",{})]})})]}),(h||o?.some(re=>re.type==="ADD_PAYOUT_METHOD"&&String(re.transactionId)===String(t.id)))&&F("div",{className:"flex gap-3 pl-[4.75rem]",children:F(Oi,{theme:e,onAddDetails:()=>a?.()})})]})};import{Fragment as Nn,jsx as ot,jsxs as Ei}from"react/jsx-runtime";var Ii=({transactions:t,theme:e,fetchNextPage:r,hasNextPage:o,isFetchingNextPage:a,requiredActions:s,onAddPayout:n})=>{let l=Pn(null);return kn(()=>{if(!o||!r||a)return;let c=new IntersectionObserver(d=>{d[0].isIntersecting&&r()},{rootMargin:"100px"});return l.current&&c.observe(l.current),()=>c.disconnect()},[r,o,a]),ot("div",{className:"relative flex-1 flex flex-col overflow-auto overscroll-contain fruga-scrollbar px-3 pb-24 pt-0",children:t.length===0?Ei("div",{className:"flex flex-col items-center justify-center py-12 px-4 text-center",children:[ot("div",{className:"mb-3 text-3xl","aria-hidden":!0,children:"\u{1F6D2}"}),ot("div",{className:"text-sm font-semibold",children:"No transactions yet"}),ot("div",{className:"mt-1 text-xs",style:{color:e.muted},children:"Start shopping through the offers to earn cashback"})]}):Ei(Nn,{children:[t.map((c,d)=>c?ot(Fi,{transaction:c,theme:e,isLast:d===t.length-1,requiredActions:s,onAddPayout:n},c.id):null),ot("div",{ref:l,className:"h-10 flex items-center justify-center -mt-2",children:a&&ot("div",{className:"w-5 h-5 rounded-full animate-spin border-2",style:{borderColor:`${e.muted}40`,borderTopColor:e.text}})})]})})};import{ChevronRight as Tn}from"lucide-react";import{jsx as Wr,jsxs as Sn}from"react/jsx-runtime";var Mi=({theme:t,onNavigateToPayoutMethod:e})=>Wr("div",{className:"pb-24",children:Wr("div",{className:"divide-y",style:{borderColor:t.border},children:Sn("button",{type:"button",className:"flex w-full cursor-pointer items-center justify-between gap-4 py-4 text-left transition hover:opacity-80",onClick:e,children:[Wr("span",{className:"text-sm font-semibold",children:"Payout method"}),Wr(Tn,{size:18,className:"shrink-0",style:{color:t.text},"aria-hidden":!0})]})})});import{useState as Hi}from"react";import{useState as jr,useEffect as Cn}from"react";var Di=t=>{let e=Ne(),{token:r}=C(),[o,a]=jr(null),[s,n]=jr(!0),[l,c]=jr("idle"),[d,p]=jr(null),u=async()=>{n(!0),p(null);try{let v=await t.getMethod();a(v)}catch(v){p(v)}finally{n(!1)}};return Cn(()=>{u()},[]),{paymentMethod:o,loading:s,flow:l,setFlow:c,error:d,setError:p,addMethod:async v=>{n(!0),p(null);try{let w=await t.addMethod(v);a(w),c("success"),e.invalidateQueries({queryKey:["wallet",r]})}catch(w){p(w)}finally{n(!1)}},removeMethod:async()=>{if(o){n(!0),p(null);try{await t.removeMethod(o.id),a(null),c("idle"),e.invalidateQueries({queryKey:["wallet",r]})}catch(v){throw p(v),v}finally{n(!1)}}}}};import{Landmark as Rn,Trash2 as An}from"lucide-react";import{jsx as $r,jsxs as Li}from"react/jsx-runtime";var Bi=({theme:t,paymentMethod:e,onRemove:r})=>Li("div",{className:"flex items-center gap-3 py-2",children:[$r("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-full border",style:{borderColor:t.border,background:t.isLight?"rgba(0,0,0,0.03)":"rgba(255,255,255,0.04)"},"aria-hidden":!0,children:$r(Rn,{size:22,strokeWidth:2,style:{color:t.text}})}),Li("div",{className:"min-w-0 flex-1 text-sm font-semibold",children:["Bank account ending ",e.bank.accountLast4]}),$r("button",{type:"button",className:"inline-flex h-10 w-10 cursor-pointer shrink-0 items-center justify-center rounded-xl transition hover:opacity-80",style:{color:t.muted},onClick:r,"aria-label":"Remove payout method",title:"Remove payout method",children:$r(An,{size:20,strokeWidth:2})})]});import{useMemo as On,useState as Bo}from"react";import{jsx as at,jsxs as qr}from"react/jsx-runtime";var _i=({theme:t,onSubmit:e,isSubmitting:r})=>{let[o,a]=Bo(""),[s,n]=Bo(""),[l,c]=Bo(""),d=On(()=>{let p=o.trim(),u=s.replace(/\s/g,""),g=l.replace(/[^0-9]/g,"");return p.length>0&&u.length>=6&&u.length<=10&&g.length===6},[o,s,l]);return qr("form",{className:"space-y-4 pt-1",onSubmit:p=>{p.preventDefault(),!(!d||r)&&e({accountHolderName:o,accountNumber:s,sortCode:l})},children:[qr("label",{className:"grid gap-1.5",children:[at("span",{className:"text-xs font-medium",style:{color:t.muted},children:"Account name"}),at("input",{value:o,onChange:p=>a(p.target.value.replace(/[^a-zA-Z\s\-']/g,"")),autoComplete:"name",className:"h-11 rounded-2xl border bg-transparent px-3 text-sm outline-none",style:{borderColor:t.border,color:t.text},placeholder:"Account holder name"})]}),qr("label",{className:"grid gap-1.5",children:[at("span",{className:"text-xs font-medium",style:{color:t.muted},children:"Account number"}),at("input",{value:s,onChange:p=>n(p.target.value.replace(/[^\d\s]/g,"")),inputMode:"numeric",autoComplete:"off",className:"h-11 rounded-2xl border bg-transparent px-3 text-sm outline-none",style:{borderColor:t.border,color:t.text},placeholder:"e.g. 12345678",maxLength:10})]}),qr("label",{className:"grid gap-1.5",children:[at("span",{className:"text-xs font-medium",style:{color:t.muted},children:"Sort code"}),at("input",{value:l,onChange:p=>{let u=p.target.value.replace(/\D/g,"").slice(0,6),g=u.length<=2?u:u.length<=4?`${u.slice(0,2)}-${u.slice(2)}`:`${u.slice(0,2)}-${u.slice(2,4)}-${u.slice(4)}`;c(g)},inputMode:"numeric",autoComplete:"off",className:"h-11 rounded-2xl border bg-transparent px-3 text-sm outline-none",style:{borderColor:t.border,color:t.text},placeholder:"12-34-56",maxLength:8})]}),at("button",{type:"submit",disabled:!d||r,className:"mt-2 inline-flex h-11 w-full cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold disabled:cursor-not-allowed disabled:opacity-45",style:{background:t.accent,color:t.accentText},children:r?"Saving...":"Save bank details"})]})};import{CheckCircle2 as Fn}from"lucide-react";import{jsx as Kr,jsxs as En}from"react/jsx-runtime";var Ui=({theme:t,onDone:e})=>En("div",{className:"flex flex-col items-center px-2 py-6 text-center",children:[Kr(Fn,{className:"h-14 w-14 shrink-0",style:{color:t.success},strokeWidth:2,"aria-hidden":!0}),Kr("div",{className:"mt-4 text-base font-semibold",children:"Bank account added"}),Kr("div",{className:"mt-2 max-w-xs text-sm leading-relaxed",style:{color:t.muted},children:"Your bank details have been saved. We will use this account for payouts."}),Kr("button",{type:"button",className:"mt-8 inline-flex h-11 w-full max-w-xs cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold",style:{background:t.accent,color:t.accentText},onClick:e,children:"Done"})]});import{jsx as rr,jsxs as Gr}from"react/jsx-runtime";var zi=({theme:t,isOpen:e,onClose:r,onConfirm:o,isRemoving:a=!1})=>e?Gr("div",{className:"absolute inset-0 z-50 flex items-center justify-center p-4",children:[rr(Ot,{onClose:r}),Gr("div",{className:"relative w-full max-w-[320px] overflow-hidden rounded-[32px] border p-6 shadow-2xl animate-in zoom-in-95 fade-in duration-300",style:{borderColor:t.border,background:t.panel,color:t.text},children:[Gr("div",{className:"text-center pt-2",children:[rr("h3",{className:"text-[19px] font-bold tracking-tight",children:"Remove payout method"}),rr("p",{className:"mt-3 px-2 text-[15px] leading-snug opacity-70",style:{color:t.muted},children:"Are you sure you want to remove this payout method?"})]}),Gr("div",{className:"mt-8 flex gap-3",children:[rr("button",{type:"button",className:"flex-1 rounded-[20px] border py-3 text-[15px] font-bold transition hover:bg-black/5 dark:hover:bg-white/5 cursor-pointer",style:{borderColor:t.border,color:t.text},onClick:r,children:"Cancel"}),rr("button",{type:"button",disabled:a,className:"flex-1 rounded-[20px] py-3 text-[15px] font-bold transition hover:opacity-90 disabled:opacity-50 cursor-pointer shadow-lg",style:{background:t.accent,color:t.accentText,boxShadow:`0 10px 15px -3px ${t.accent}33`},onClick:o,children:a?"Removing...":"Delete"})]})]})]}):null;import{AlertCircle as In}from"lucide-react";import{jsx as it,jsxs as _o}from"react/jsx-runtime";var Qi=({theme:t,isOpen:e,onClose:r,title:o,message:a,confirmLabel:s="Got it"})=>e?_o("div",{className:"absolute inset-0 z-[100] flex items-center justify-center p-4",children:[it(Ot,{onClose:r}),_o("div",{className:"relative w-full max-w-[320px] overflow-hidden rounded-[32px] border p-6 shadow-2xl animate-in zoom-in-95 fade-in duration-300",style:{borderColor:t.border,background:t.panel,color:t.text},children:[_o("div",{className:"flex flex-col items-center text-center",children:[it("div",{className:"flex h-12 w-12 items-center justify-center rounded-full mb-4",style:{background:`${t.isLight?"rgba(220, 38, 38, 0.1)":"rgba(220, 38, 38, 0.2)"}`},children:it(In,{className:"h-6 w-6 text-red-600"})}),it("h3",{className:"text-[19px] font-bold tracking-tight",children:o}),it("p",{className:"mt-2 text-[14px] leading-relaxed opacity-70",style:{color:t.muted},children:a})]}),it("div",{className:"mt-8",children:it("button",{type:"button",className:"w-full rounded-[20px] py-3 text-[15px] font-bold text-white transition hover:opacity-90 cursor-pointer shadow-lg",style:{background:t.accent,color:t.accentText,boxShadow:`0 10px 15px -3px ${t.accent}33`},onClick:r,children:s})})]})]}):null;import{Fragment as Mn,jsx as ge,jsxs as Wi}from"react/jsx-runtime";var ji=({theme:t,service:e,onDone:r})=>{let{paymentMethod:o,loading:a,flow:s,setFlow:n,addMethod:l,removeMethod:c,error:d,setError:p}=Di(e),[u,g]=Hi(!1),[h,v]=Hi(!1),w=async()=>{v(!0);try{await c(),g(!1)}catch{g(!1)}finally{v(!1)}};return a&&s==="idle"?ge("div",{className:"py-8 text-center",children:ge("div",{className:"text-sm animate-pulse",style:{color:t.muted},children:"Loading payment details..."})}):s==="success"?ge(Ui,{theme:t,onDone:()=>{n("idle"),r?.()}}):o&&s==="idle"?Wi(Mn,{children:[ge(Bi,{theme:t,paymentMethod:o,onRemove:()=>g(!0)}),ge("button",{type:"button",className:"mt-8 inline-flex h-11 w-full max-w-xs cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold mx-auto",style:{background:t.accent,color:t.accentText},onClick:r,children:"Done"}),ge(zi,{theme:t,isOpen:u,onClose:()=>g(!1),onConfirm:w,isRemoving:h}),ge(Qi,{theme:t,isOpen:!!d,onClose:()=>p(null),title:typeof d=="string"?"Error":d?.error||"Notice",message:typeof d=="string"?d:d?.message||"An unexpected error occurred. Please try again."})]}):s==="form"?ge(_i,{theme:t,onSubmit:l,isSubmitting:a}):Wi("div",{className:"py-8 text-center",children:[ge("p",{className:"text-sm leading-relaxed",style:{color:t.muted},children:"Add a UK bank account so we can pay your savings when redeemed."}),ge("button",{type:"button",className:"mt-4 inline-flex h-11 w-full max-w-xs cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold",style:{background:t.accent,color:t.accentText},onClick:()=>n("form"),children:"Add payout method"})]})};import{jsx as D,jsxs as $i}from"react/jsx-runtime";var Dn=({theme:t})=>{let{wallet:e}=rt(),r=e?.available||0,o=e?.pending||0,a=e?.lifetimeEarned||0;return D(Ci,{theme:t,accountDataLoading:!1,available:r,pending:o,lifetimeSavings:a})},Ln=({theme:t,onAddPayout:e})=>{let{wallet:r}=rt(),{data:o,fetchNextPage:a,hasNextPage:s,isFetchingNextPage:n}=Ti(10),l=o?.pages.flatMap(c=>c.transactions||[]).filter(Boolean)||[];return D(Ii,{transactions:l,theme:t,fetchNextPage:a,hasNextPage:s,isFetchingNextPage:n,requiredActions:r?.requiredActions,onAddPayout:e})},qi=({theme:t,accountView:e="transactions",setAccountView:r})=>{let{paymentService:o}=me(),{partnerPayout:a,isAddingPayoutFromAlert:s,setShowPayoutSuccess:n,setIsAddingPayoutFromAlert:l}=C(),c=a==="PARTNER"?"transactions":e;if(c==="settings")return D("div",{className:"relative flex-1 flex flex-col min-h-0 px-3 mt-4",children:D(Mi,{theme:t,onNavigateToPayoutMethod:()=>r?.("payout-method")})});let d=()=>{s&&(n(!0),l(!1)),r?.("transactions")};return c==="payout-method"?D("div",{className:"relative flex-1 flex flex-col min-h-0 px-3 mt-4",children:D(ji,{theme:t,service:o,onDone:d})}):$i("div",{className:"relative flex-1 flex flex-col min-h-0",children:[D(Uo,{fallback:D("div",{className:"px-3 -mt-10",children:D("div",{className:"h-32 w-full animate-pulse rounded-3xl bg-gray-100/10"})}),children:D(Dn,{theme:t})}),D(Uo,{fallback:D(ai,{theme:t}),children:D(Ur,{theme:t,onAddPayout:()=>r?.("payout-method")})}),$i("div",{className:"relative z-20 pt-0 flex-1 flex flex-col min-h-0 overflow-hidden",children:[D("div",{className:"mt-10 px-3 pb-2 flex-shrink-0",children:D("div",{className:"mb-3 text-base font-semibold",children:"Transactions"})}),D("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:D(Uo,{fallback:D("div",{className:"px-3",children:D(bi,{theme:t})}),children:D(Ln,{theme:t,onAddPayout:()=>r?.("payout-method")})})})]})]})};import{Search as Bn,X as _n,ChevronRight as Un}from"lucide-react";import{jsx as $,jsxs as Vr}from"react/jsx-runtime";var Ki=({theme:t,helpPage:e,setHelpPage:r,helpSearch:o,setHelpSearch:a})=>$("div",{className:"relative h-full",children:e?$("div",{className:"h-full",children:$("div",{className:"px-3 pb-24 pt-3 text-sm",children:Zt.find(s=>s.id===e)?.body(t)})}):Vr("div",{children:[Vr("div",{className:"mb-4 flex items-center gap-2 rounded-2xl border px-3 py-2",style:{borderColor:t.border,background:t.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},children:[$(Bn,{size:16,className:"shrink-0 opacity-80"}),$("input",{value:o,onChange:s=>a(s.target.value),placeholder:"Search help",className:"w-full bg-transparent text-sm outline-none"}),o?$("button",{className:"shrink-0 rounded-xl p-1 cursor-pointer",onClick:()=>a(""),"aria-label":"Clear search",title:"Clear search",children:$(_n,{size:16,className:"opacity-70"})}):null]}),$("div",{className:"pb-4",children:$("div",{className:"text-sm",style:{color:t.muted},children:"Learn more about cashback and how to use your credit"})}),$("div",{className:"divide-y divide-[#e5e7eb]",children:(()=>{let s=Zt.filter(n=>!o.trim()||n.title.toLowerCase().includes(o.trim().toLowerCase()));return s.length===0?$("div",{className:"py-8 text-center text-sm",style:{color:t.muted},children:"No help topics match your search"}):s.map(n=>{let l=n.id==="how-it-works"||n.id==="redeem";return Vr("button",{className:"flex w-full items-center justify-between gap-4 py-4 text-left cursor-pointer",onClick:()=>r(n.id),children:[Vr("div",{className:"min-w-0 flex-1",children:[$("div",{className:"text-sm font-semibold",children:n.title}),l?$("div",{className:"mt-0.5 text-xs leading-relaxed",style:{color:t.muted},children:"Quick explainer \u2192"}):null]}),$(Un,{size:18,className:"shrink-0",style:{color:t.text},"aria-hidden":!0})]},n.id)})})()})]})});import{jsx as ve,jsxs as Gi}from"react/jsx-runtime";function Vi({theme:t,onboardingOpen:e,onboardingStep:r,setOnboardingStep:o,finishOnboarding:a,allowUserThemeControl:s,onThemeModeChange:n}){let[l,c]=Yr("offers"),[d,p]=Yr("transactions"),[u,g]=Yr(null),[h,v]=Yr("");return e?ve("div",{className:"relative flex h-full w-full min-w-0 flex-col overflow-hidden",style:{background:t.bg,color:t.text},children:ve(Ja,{theme:t,onboardingStep:r,setOnboardingStep:o,onFinish:a})}):Gi("div",{className:"relative flex h-full w-full min-w-0 flex-col overflow-hidden",style:{background:t.bg,color:t.text},children:[ve(si,{tab:l,theme:t,allowUserThemeControl:s,onThemeModeChange:n,helpPage:u,setHelpPage:g,accountView:d,setAccountView:p}),Gi("div",{className:We("relative flex-1 flex flex-col min-h-0","pt-0"),children:[l==="offers"&&ve(Pi,{theme:t,onNavigateToPayoutMethod:()=>{c("account"),p("payout-method")}}),l==="account"&&ve(qi,{theme:t,accountView:d,setAccountView:p}),l==="help"&&ve("div",{className:"relative flex-1 min-h-0 overflow-auto overscroll-contain fruga-scrollbar px-3",children:ve(Ki,{theme:t,helpPage:u,setHelpPage:g,helpSearch:h,setHelpSearch:v})})]}),ve("div",{className:"absolute inset-x-0 bottom-0 pt-10 pb-3 z-30 pointer-events-none",style:{background:`linear-gradient(to top, ${t.bg} 40%, transparent)`},children:ve("div",{className:"pointer-events-auto",children:ve(Xa,{theme:t,activeTab:l,onTabChange:c,onHelpPageReset:()=>g(null)})})})]})}import{jsx as Zr}from"react/jsx-runtime";var Hn=800;function Wn(){let[t,e]=It(()=>{if(typeof window>"u")return{isMobile:!1,hostHeight:0,hostWidth:0};let r=new URLSearchParams(window.location.search);return{isMobile:r.get("isHostMobile")==="true"||window.innerWidth<Hn,hostHeight:Number(r.get("hostHeight"))||window.innerHeight,hostWidth:Number(r.get("hostWidth"))||window.innerWidth}});return Zi(()=>{let r=o=>{o.data?.type==="FRUGA_HOST_RESIZE"&&e({isMobile:o.data.isHostMobile,hostHeight:o.data.hostHeight,hostWidth:o.data.hostWidth})};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[]),t}var jn=Yi(function({theme:e,onThemeModeChange:r},o){let[a,s]=It(!1),[n,l]=It(!1),[c,d]=It(!1),[p,u]=It(0),[g,h]=It(!1),{isMobile:v,hostHeight:w}=Wn(),k=e.allowUserThemeControl?e:{...e,mode:e.defaultTheme},P=br(k),S=Qn(null);S.current=()=>{s(!0),h(!1),n||(l(!0),u(0),d(!0))},zn(o,()=>({open:()=>S.current?.()}),[]);let O=a&&!g;return Zi(()=>{if(!v||!O)return;let Y=document.documentElement.style.overflowX,Z=document.body.style.overflowX;return document.documentElement.style.overflowX="hidden",document.body.style.overflowX="hidden",()=>{document.documentElement.style.overflowX=Y,document.body.style.overflowX=Z}},[v,O]),Zr("div",{className:"h-full w-full overflow-hidden min-w-0",style:{background:P.bg},children:Zr(Vi,{theme:P,onboardingOpen:c,onboardingStep:p,setOnboardingStep:u,finishOnboarding:()=>d(!1),allowUserThemeControl:e.allowUserThemeControl,onThemeModeChange:r,hostHeight:w,isHostMobile:v})})}),$n=Yi((t,e)=>Zr(Za,{baseUrl:t.baseUrl,children:Zr(jn,{...t,ref:e})})),Ji=$n;import{jsx as zo}from"react/jsx-runtime";var Xi=new ko,qn="1E40AF",es=t=>{let{bootstrapConfig:e,isHostMobile:r,hostHeight:o}=t,{mode:a,setMode:s,token:n,setToken:l,setPartnerPayout:c}=C(),d=e?.config.ui.defaultTheme||"dark";Jr(()=>{e?.partnerPayout&&c(e.partnerPayout)},[e?.partnerPayout,c]),Jr(()=>{d&&s(d)},[d,s]),Jr(()=>{t.token&&l(t.token)},[t.token,l]),Jr(()=>{let h=e?.auth?.tokenTtlSeconds;if(!h||h<=0)return;let w=(h-60)*1e3,k=Math.max(1e3,w),P=setTimeout(()=>{window.parent.postMessage({type:"NEED_TOKEN"},"*")},k);return()=>clearTimeout(P)},[e?.auth?.tokenTtlSeconds,n]),e&&Xi.setQueryData(["bootstrapConfig"],e);let p=e?.config.ui.accent??qn,u={...te,defaultTheme:d,mode:a,primary:p,accent:e?.config.ui.accent??te.accent,accentTextLight:e?.config.ui.accentTextLight??te.accentTextLight,accentTextDark:e?.config.ui.accentTextDark??te.accentTextDark,allowUserThemeControl:e?.config.ui.allowUserThemeControl??te.allowUserThemeControl,launcherIcon:e?.config.ui.launcherIcon??te.launcherIcon,showLauncher:e?.config.ui.showLauncher??te.showLauncher,launcherLabel:e?.config.ui.launcherLabel??te.launcherLabel},g=h=>{s(h)};return zo(No,{client:Xi,children:zo(Ha,{theme:u,isMobile:r,hostHeight:o,children:zo(Ji,{theme:u,baseUrl:t.baseUrl,onThemeModeChange:g})})})};import{jsx as Vn}from"react/jsx-runtime";var ts=t=>{let e=Tr.get(ja.BOOTSTRAP_CONFIG),r=e?{config:e}:void 0,o={...t,bootstrapConfig:t.bootstrapConfig||r||void 0},a=document.getElementById(o.containerId);if(a||(console.warn(`FrugaRelay: Container #${o.containerId} not found. Creating a default container.`),a=document.createElement("div"),a.id=o.containerId,document.body.appendChild(a)),a.getAttribute("data-fruga-relay-mounted")==="true"){console.info(`FrugaRelay: SDK already mounted in container #${o.containerId}.`);return}Kn.createRoot(a).render(Vn(es,{...o})),a.setAttribute("data-fruga-relay-mounted","true")},Gn={init:ts};if(typeof window<"u"){let t=new URLSearchParams(window.location.search),e=t.get("partnerKey");if(e){let r=t.get("theme"),o=r==="dark"||r==="light"?r:void 0,a=t.get("primaryColor")||void 0,s=t.get("userId")||void 0,n=t.get("token")||void 0,l=t.get("baseUrl")||void 0,c=t.get("isHostMobile")==="true",d=Number(t.get("hostHeight"))||void 0,p,u=t.get("bootstrapConfig");if(u)try{p=JSON.parse(atob(u))}catch(g){console.warn("FrugaRelay: Failed to parse bootstrapConfig from URL",g)}ts({partnerKey:e,containerId:"root",token:n,baseUrl:l,theme:o,primaryColor:a,userId:s,isHostMobile:c,hostHeight:d,bootstrapConfig:p})}}var wg=Gn;export{wg as default,ts as init};
|
|
1
|
+
var ks=Object.defineProperty;var ea=t=>{throw TypeError(t)};var Ts=(t,e,r)=>e in t?ks(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var H=(t,e,r)=>Ts(t,typeof e!="symbol"?e+"":e,r),po=(t,e,r)=>e.has(t)||ea("Cannot "+r);var i=(t,e,r)=>(po(t,e,"read from private field"),r?r.call(t):e.get(t)),h=(t,e,r)=>e.has(t)?ea("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),m=(t,e,r,o)=>(po(t,e,"write to private field"),o?o.call(t,r):e.set(t,r),r),w=(t,e,r)=>(po(t,e,"access private method"),r);var Qt=(t,e,r,o)=>({set _(a){m(t,e,a,r)},get _(){return i(t,e,o)}});import xs from"react-dom/client";import{useCallback as Sl,useEffect as mr,useRef as Ol}from"react";var oe=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var Ze,Ue,mt,ta,Rs=(ta=class extends oe{constructor(){super();h(this,Ze);h(this,Ue);h(this,mt);m(this,mt,e=>{if(typeof window<"u"&&window.addEventListener){let r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){i(this,Ue)||this.setEventListener(i(this,mt))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,Ue))==null||e.call(this),m(this,Ue,void 0))}setEventListener(e){var r;m(this,mt,e),(r=i(this,Ue))==null||r.call(this),m(this,Ue,e(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus()}))}setFocused(e){i(this,Ze)!==e&&(m(this,Ze,e),this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){return typeof i(this,Ze)=="boolean"?i(this,Ze):globalThis.document?.visibilityState!=="hidden"}},Ze=new WeakMap,Ue=new WeakMap,mt=new WeakMap,ta),ht=new Rs;var Ps={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Be,uo,ra,Ns=(ra=class{constructor(){h(this,Be,Ps);h(this,uo,!1)}setTimeoutProvider(t){m(this,Be,t)}setTimeout(t,e){return i(this,Be).setTimeout(t,e)}clearTimeout(t){i(this,Be).clearTimeout(t)}setInterval(t,e){return i(this,Be).setInterval(t,e)}clearInterval(t){i(this,Be).clearInterval(t)}},Be=new WeakMap,uo=new WeakMap,ra),ue=new Ns;function oa(t){setTimeout(t,0)}var ho=typeof window>"u"||"Deno"in globalThis;function M(){}function sa(t,e){return typeof t=="function"?t(e):t}function Wt(t){return typeof t=="number"&&t>=0&&t!==1/0}function br(t,e){return Math.max(t+(e||0)-Date.now(),0)}function ie(t,e){return typeof t=="function"?t(e):t}function q(t,e){return typeof t=="function"?t(e):t}function yr(t,e){let{type:r="all",exact:o,fetchStatus:a,predicate:s,queryKey:n,stale:l}=t;if(n){if(o){if(e.queryHash!==jt(n,e.options))return!1}else if(!Xe(e.queryKey,n))return!1}if(r!=="all"){let c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||a&&a!==e.state.fetchStatus||s&&!s(e))}function wr(t,e){let{exact:r,status:o,predicate:a,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(r){if(me(e.options.mutationKey)!==me(s))return!1}else if(!Xe(e.options.mutationKey,s))return!1}return!(o&&e.state.status!==o||a&&!a(e))}function jt(t,e){return(e?.queryKeyHashFn||me)(t)}function me(t){return JSON.stringify(t,(e,r)=>mo(r)?Object.keys(r).sort().reduce((o,a)=>(o[a]=r[a],o),{}):r)}function Xe(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>Xe(t[r],e[r])):!1}var Ss=Object.prototype.hasOwnProperty;function fo(t,e,r=0){if(t===e)return t;if(r>500)return e;let o=aa(t)&&aa(e);if(!o&&!(mo(t)&&mo(e)))return e;let s=(o?t:Object.keys(t)).length,n=o?e:Object.keys(e),l=n.length,c=o?new Array(l):{},d=0;for(let u=0;u<l;u++){let p=o?u:n[u],g=t[p],v=e[p];if(g===v){c[p]=g,(o?u<s:Ss.call(t,p))&&d++;continue}if(g===null||v===null||typeof g!="object"||typeof v!="object"){c[p]=v;continue}let f=fo(g,v,r+1);c[p]=f,f===g&&d++}return s===l&&d===s?t:c}function ft(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let r in t)if(t[r]!==e[r])return!1;return!0}function aa(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function mo(t){if(!ia(t))return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(!ia(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function ia(t){return Object.prototype.toString.call(t)==="[object Object]"}function na(t){return new Promise(e=>{ue.setTimeout(e,t)})}function Kt(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?fo(t,e):e}function la(t,e,r=0){let o=[...t,e];return r&&o.length>r?o.slice(1):o}function ca(t,e,r=0){let o=[e,...t];return r&&o.length>r?o.slice(0,-1):o}var gt=Symbol();function xr(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===gt?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function vt(t,e){return typeof t=="function"?t(...e):!!t}function da(t,e,r){let o=!1,a;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(a??(a=e()),o||(o=!0,a.aborted?r():a.addEventListener("abort",r,{once:!0})),a)}),t}var he=(()=>{let t=()=>ho;return{isServer(){return t()},setIsServer(e){t=e}}})();function qt(){let t,e,r=new Promise((a,s)=>{t=a,e=s});r.status="pending",r.catch(()=>{});function o(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{o({status:"fulfilled",value:a}),t(a)},r.reject=a=>{o({status:"rejected",reason:a}),e(a)},r}var pa=oa;function Os(){let t=[],e=0,r=l=>{l()},o=l=>{l()},a=pa,s=l=>{e?t.push(l):a(()=>{r(l)})},n=()=>{let l=t;t=[],l.length&&a(()=>{o(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||n()}return c},batchCalls:l=>(...c)=>{s(()=>{l(...c)})},schedule:s,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{o=l},setScheduler:l=>{a=l}}}var N=Os();var bt,ze,yt,ua,Cs=(ua=class extends oe{constructor(){super();h(this,bt,!0);h(this,ze);h(this,yt);m(this,yt,e=>{if(typeof window<"u"&&window.addEventListener){let r=()=>e(!0),o=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",o,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",o)}}})}onSubscribe(){i(this,ze)||this.setEventListener(i(this,yt))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,ze))==null||e.call(this),m(this,ze,void 0))}setEventListener(e){var r;m(this,yt,e),(r=i(this,ze))==null||r.call(this),m(this,ze,e(this.setOnline.bind(this)))}setOnline(e){i(this,bt)!==e&&(m(this,bt,e),this.listeners.forEach(o=>{o(e)}))}isOnline(){return i(this,bt)}},bt=new WeakMap,ze=new WeakMap,yt=new WeakMap,ua),wt=new Cs;function Es(t){return Math.min(1e3*2**t,3e4)}function go(t){return(t??"online")==="online"?wt.isOnline():!0}var kr=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Tr(t){let e=!1,r=0,o,a=qt(),s=()=>a.status!=="pending",n=y=>{if(!s()){let R=new kr(y);g(R),t.onCancel?.(R)}},l=()=>{e=!0},c=()=>{e=!1},d=()=>ht.isFocused()&&(t.networkMode==="always"||wt.isOnline())&&t.canRun(),u=()=>go(t.networkMode)&&t.canRun(),p=y=>{s()||(o?.(),a.resolve(y))},g=y=>{s()||(o?.(),a.reject(y))},v=()=>new Promise(y=>{o=R=>{(s()||d())&&y(R)},t.onPause?.()}).then(()=>{o=void 0,s()||t.onContinue?.()}),f=()=>{if(s())return;let y,R=r===0?t.initialPromise:void 0;try{y=R??t.fn()}catch(O){y=Promise.reject(O)}Promise.resolve(y).then(p).catch(O=>{if(s())return;let F=t.retry??(he.isServer()?0:3),x=t.retryDelay??Es,C=typeof x=="function"?x(r,O):x,D=F===!0||typeof F=="number"&&r<F||typeof F=="function"&&F(r,O);if(e||!D){g(O);return}r++,t.onFail?.(r,O),na(C).then(()=>d()?void 0:v()).then(()=>{e?g(O):f()})})};return{promise:a,status:()=>a.status,cancel:n,continue:()=>(o?.(),a),cancelRetry:l,continueRetry:c,canStart:u,start:()=>(u()?f():v().then(f),a)}}var Je,ma,Rr=(ma=class{constructor(){h(this,Je)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Wt(this.gcTime)&&m(this,Je,ue.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(he.isServer()?1/0:300*1e3))}clearGcTimeout(){i(this,Je)&&(ue.clearTimeout(i(this,Je)),m(this,Je,void 0))}},Je=new WeakMap,ma);var et,xt,ae,tt,U,Gt,rt,Z,ba,Re,ga,va=(ga=class extends Rr{constructor(e){super();h(this,Z);h(this,et);h(this,xt);h(this,ae);h(this,tt);h(this,U);h(this,Gt);h(this,rt);m(this,rt,!1),m(this,Gt,e.defaultOptions),this.setOptions(e.options),this.observers=[],m(this,tt,e.client),m(this,ae,i(this,tt).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,m(this,et,fa(this.options)),this.state=e.state??i(this,et),this.scheduleGc()}get meta(){return this.options.meta}get promise(){return i(this,U)?.promise}setOptions(e){if(this.options={...i(this,Gt),...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=fa(this.options);r.data!==void 0&&(this.setState(ha(r.data,r.dataUpdatedAt)),m(this,et,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&i(this,ae).remove(this)}setData(e,r){let o=Kt(this.state.data,e,this.options);return w(this,Z,Re).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(e,r){w(this,Z,Re).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){let r=i(this,U)?.promise;return i(this,U)?.cancel(e),r?r.then(M).catch(M):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return i(this,et)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>q(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===gt||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>ie(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!br(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),i(this,U)?.continue()}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),i(this,U)?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),i(this,ae).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(i(this,U)&&(i(this,rt)||w(this,Z,ba).call(this)?i(this,U).cancel({revert:!0}):i(this,U).cancelRetry()),this.scheduleGc()),i(this,ae).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||w(this,Z,Re).call(this,{type:"invalidate"})}async fetch(e,r){if(this.state.fetchStatus!=="idle"&&i(this,U)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:!0});else if(i(this,U))return i(this,U).continueRetry(),i(this,U).promise}if(e&&this.setOptions(e),!this.options.queryFn){let c=this.observers.find(d=>d.options.queryFn);c&&this.setOptions(c.options)}let o=new AbortController,a=c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(m(this,rt,!0),o.signal)})},s=()=>{let c=xr(this.options,r),u=(()=>{let p={client:i(this,tt),queryKey:this.queryKey,meta:this.meta};return a(p),p})();return m(this,rt,!1),this.options.persister?this.options.persister(c,u,this):c(u)},l=(()=>{let c={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:i(this,tt),state:this.state,fetchFn:s};return a(c),c})();this.options.behavior?.onFetch(l,this),m(this,xt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==l.fetchOptions?.meta)&&w(this,Z,Re).call(this,{type:"fetch",meta:l.fetchOptions?.meta}),m(this,U,Tr({initialPromise:r?.initialPromise,fn:l.fetchFn,onCancel:c=>{c instanceof kr&&c.revert&&this.setState({...i(this,xt),fetchStatus:"idle"}),o.abort()},onFail:(c,d)=>{w(this,Z,Re).call(this,{type:"failed",failureCount:c,error:d})},onPause:()=>{w(this,Z,Re).call(this,{type:"pause"})},onContinue:()=>{w(this,Z,Re).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{let c=await i(this,U).start();if(c===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(c),i(this,ae).config.onSuccess?.(c,this),i(this,ae).config.onSettled?.(c,this.state.error,this),c}catch(c){if(c instanceof kr){if(c.silent)return i(this,U).promise;if(c.revert){if(this.state.data===void 0)throw c;return this.state.data}}throw w(this,Z,Re).call(this,{type:"error",error:c}),i(this,ae).config.onError?.(c,this),i(this,ae).config.onSettled?.(this.state.data,c,this),c}finally{this.scheduleGc()}}},et=new WeakMap,xt=new WeakMap,ae=new WeakMap,tt=new WeakMap,U=new WeakMap,Gt=new WeakMap,rt=new WeakMap,Z=new WeakSet,ba=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Re=function(e){let r=o=>{switch(e.type){case"failed":return{...o,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...o,fetchStatus:"paused"};case"continue":return{...o,fetchStatus:"fetching"};case"fetch":return{...o,...vo(o.data,this.options),fetchMeta:e.meta??null};case"success":let a={...o,...ha(e.data,e.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return m(this,xt,e.manual?a:void 0),a;case"error":let s=e.error;return{...o,error:s,errorUpdateCount:o.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:o.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...o,isInvalidated:!0};case"setState":return{...o,...e.state}}};this.state=r(this.state),N.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate()}),i(this,ae).notify({query:this,type:"updated",action:e})})},ga);function vo(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:go(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function ha(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function fa(t){let e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,o=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var G,k,Vt,K,ot,kt,Pe,He,Yt,Tt,Rt,at,it,Qe,Pt,P,$t,bo,yo,wo,xo,ko,To,Ro,ka,xa,Zt=(xa=class extends oe{constructor(e,r){super();h(this,P);h(this,G);h(this,k);h(this,Vt);h(this,K);h(this,ot);h(this,kt);h(this,Pe);h(this,He);h(this,Yt);h(this,Tt);h(this,Rt);h(this,at);h(this,it);h(this,Qe);h(this,Pt,new Set);this.options=r,m(this,G,e),m(this,He,null),m(this,Pe,qt()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,k).addObserver(this),ya(i(this,k),this.options)?w(this,P,$t).call(this):this.updateResult(),w(this,P,xo).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Po(i(this,k),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Po(i(this,k),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,w(this,P,ko).call(this),w(this,P,To).call(this),i(this,k).removeObserver(this)}setOptions(e){let r=this.options,o=i(this,k);if(this.options=i(this,G).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof q(this.options.enabled,i(this,k))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");w(this,P,Ro).call(this),i(this,k).setOptions(this.options),r._defaulted&&!ft(this.options,r)&&i(this,G).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,k),observer:this});let a=this.hasListeners();a&&wa(i(this,k),o,this.options,r)&&w(this,P,$t).call(this),this.updateResult(),a&&(i(this,k)!==o||q(this.options.enabled,i(this,k))!==q(r.enabled,i(this,k))||ie(this.options.staleTime,i(this,k))!==ie(r.staleTime,i(this,k)))&&w(this,P,bo).call(this);let s=w(this,P,yo).call(this);a&&(i(this,k)!==o||q(this.options.enabled,i(this,k))!==q(r.enabled,i(this,k))||s!==i(this,Qe))&&w(this,P,wo).call(this,s)}getOptimisticResult(e){let r=i(this,G).getQueryCache().build(i(this,G),e),o=this.createResult(r,e);return As(this,o)&&(m(this,K,o),m(this,kt,this.options),m(this,ot,i(this,k).state)),o}getCurrentResult(){return i(this,K)}trackResult(e,r){return new Proxy(e,{get:(o,a)=>(this.trackProp(a),r?.(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&i(this,Pe).status==="pending"&&i(this,Pe).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,a))})}trackProp(e){i(this,Pt).add(e)}getCurrentQuery(){return i(this,k)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let r=i(this,G).defaultQueryOptions(e),o=i(this,G).getQueryCache().build(i(this,G),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(e){return w(this,P,$t).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,K)))}createResult(e,r){let o=i(this,k),a=this.options,s=i(this,K),n=i(this,ot),l=i(this,kt),d=e!==o?e.state:i(this,Vt),{state:u}=e,p={...u},g=!1,v;if(r._optimisticResults){let j=this.hasListeners(),Ht=!j&&ya(e,r),fr=j&&wa(e,o,r,a);(Ht||fr)&&(p={...p,...vo(u.data,e.options)}),r._optimisticResults==="isRestoring"&&(p.fetchStatus="idle")}let{error:f,errorUpdatedAt:y,status:R}=p;v=p.data;let O=!1;if(r.placeholderData!==void 0&&v===void 0&&R==="pending"){let j;s?.isPlaceholderData&&r.placeholderData===l?.placeholderData?(j=s.data,O=!0):j=typeof r.placeholderData=="function"?r.placeholderData(i(this,Rt)?.state.data,i(this,Rt)):r.placeholderData,j!==void 0&&(R="success",v=Kt(s?.data,j,r),g=!0)}if(r.select&&v!==void 0&&!O)if(s&&v===n?.data&&r.select===i(this,Yt))v=i(this,Tt);else try{m(this,Yt,r.select),v=r.select(v),v=Kt(s?.data,v,r),m(this,Tt,v),m(this,He,null)}catch(j){m(this,He,j)}i(this,He)&&(f=i(this,He),v=i(this,Tt),y=Date.now(),R="error");let F=p.fetchStatus==="fetching",x=R==="pending",C=R==="error",D=x&&F,z=v!==void 0,Y={status:R,fetchStatus:p.fetchStatus,isPending:x,isSuccess:R==="success",isError:C,isInitialLoading:D,isLoading:D,data:v,dataUpdatedAt:p.dataUpdatedAt,error:f,errorUpdatedAt:y,failureCount:p.fetchFailureCount,failureReason:p.fetchFailureReason,errorUpdateCount:p.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:p.dataUpdateCount>d.dataUpdateCount||p.errorUpdateCount>d.errorUpdateCount,isFetching:F,isRefetching:F&&!x,isLoadingError:C&&!z,isPaused:p.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:C&&z,isStale:No(e,r),refetch:this.refetch,promise:i(this,Pe),isEnabled:q(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let j=Y.data!==void 0,Ht=Y.status==="error"&&!j,fr=vr=>{Ht?vr.reject(Y.error):j&&vr.resolve(Y.data)},Jo=()=>{let vr=m(this,Pe,Y.promise=qt());fr(vr)},gr=i(this,Pe);switch(gr.status){case"pending":e.queryHash===o.queryHash&&fr(gr);break;case"fulfilled":(Ht||Y.data!==gr.value)&&Jo();break;case"rejected":(!Ht||Y.error!==gr.reason)&&Jo();break}}return Y}updateResult(){let e=i(this,K),r=this.createResult(i(this,k),this.options);if(m(this,ot,i(this,k).state),m(this,kt,this.options),i(this,ot).data!==void 0&&m(this,Rt,i(this,k)),ft(r,e))return;m(this,K,r);let o=()=>{if(!e)return!0;let{notifyOnChangeProps:a}=this.options,s=typeof a=="function"?a():a;if(s==="all"||!s&&!i(this,Pt).size)return!0;let n=new Set(s??i(this,Pt));return this.options.throwOnError&&n.add("error"),Object.keys(i(this,K)).some(l=>{let c=l;return i(this,K)[c]!==e[c]&&n.has(c)})};w(this,P,ka).call(this,{listeners:o()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&w(this,P,xo).call(this)}},G=new WeakMap,k=new WeakMap,Vt=new WeakMap,K=new WeakMap,ot=new WeakMap,kt=new WeakMap,Pe=new WeakMap,He=new WeakMap,Yt=new WeakMap,Tt=new WeakMap,Rt=new WeakMap,at=new WeakMap,it=new WeakMap,Qe=new WeakMap,Pt=new WeakMap,P=new WeakSet,$t=function(e){w(this,P,Ro).call(this);let r=i(this,k).fetch(this.options,e);return e?.throwOnError||(r=r.catch(M)),r},bo=function(){w(this,P,ko).call(this);let e=ie(this.options.staleTime,i(this,k));if(he.isServer()||i(this,K).isStale||!Wt(e))return;let o=br(i(this,K).dataUpdatedAt,e)+1;m(this,at,ue.setTimeout(()=>{i(this,K).isStale||this.updateResult()},o))},yo=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,k)):this.options.refetchInterval)??!1},wo=function(e){w(this,P,To).call(this),m(this,Qe,e),!(he.isServer()||q(this.options.enabled,i(this,k))===!1||!Wt(i(this,Qe))||i(this,Qe)===0)&&m(this,it,ue.setInterval(()=>{(this.options.refetchIntervalInBackground||ht.isFocused())&&w(this,P,$t).call(this)},i(this,Qe)))},xo=function(){w(this,P,bo).call(this),w(this,P,wo).call(this,w(this,P,yo).call(this))},ko=function(){i(this,at)&&(ue.clearTimeout(i(this,at)),m(this,at,void 0))},To=function(){i(this,it)&&(ue.clearInterval(i(this,it)),m(this,it,void 0))},Ro=function(){let e=i(this,G).getQueryCache().build(i(this,G),this.options);if(e===i(this,k))return;let r=i(this,k);m(this,k,e),m(this,Vt,e.state),this.hasListeners()&&(r?.removeObserver(this),e.addObserver(this))},ka=function(e){N.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(i(this,K))}),i(this,G).getQueryCache().notify({query:i(this,k),type:"observerResultsUpdated"})})},xa);function Fs(t,e){return q(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function ya(t,e){return Fs(t,e)||t.state.data!==void 0&&Po(t,e,e.refetchOnMount)}function Po(t,e,r){if(q(e.enabled,t)!==!1&&ie(e.staleTime,t)!=="static"){let o=typeof r=="function"?r(t):r;return o==="always"||o!==!1&&No(t,e)}return!1}function wa(t,e,r,o){return(t!==e||q(o.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&No(t,r)}function No(t,e){return q(e.enabled,t)!==!1&&t.isStaleByTime(ie(e.staleTime,t))}function As(t,e){return!ft(t.getCurrentResult(),e)}function Nt(t){return{onFetch:(e,r)=>{let o=e.options,a=e.fetchOptions?.meta?.fetchMore?.direction,s=e.state.data?.pages||[],n=e.state.data?.pageParams||[],l={pages:[],pageParams:[]},c=0,d=async()=>{let u=!1,p=f=>{da(f,()=>e.signal,()=>u=!0)},g=xr(e.options,e.fetchOptions),v=async(f,y,R)=>{if(u)return Promise.reject();if(y==null&&f.pages.length)return Promise.resolve(f);let F=(()=>{let z={client:e.client,queryKey:e.queryKey,pageParam:y,direction:R?"backward":"forward",meta:e.options.meta};return p(z),z})(),x=await g(F),{maxPages:C}=e.options,D=R?ca:la;return{pages:D(f.pages,x,C),pageParams:D(f.pageParams,y,C)}};if(a&&s.length){let f=a==="backward",y=f?Ta:So,R={pages:s,pageParams:n},O=y(o,R);l=await v(R,O,f)}else{let f=t??s.length;do{let y=c===0?n[0]??o.initialPageParam:So(o,l);if(c>0&&y==null)break;l=await v(l,y),c++}while(c<f)}return l};e.options.persister?e.fetchFn=()=>e.options.persister?.(d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r):e.fetchFn=d}}}function So(t,{pages:e,pageParams:r}){let o=e.length-1;return e.length>0?t.getNextPageParam(e[o],e,r[o],r):void 0}function Ta(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}function Ra(t,e){return e?So(t,e)!=null:!1}function Pa(t,e){return!e||!t.getPreviousPageParam?!1:Ta(t,e)!=null}var Oo=class extends Zt{constructor(t,e){super(t,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:Nt()})}getOptimisticResult(t){return t.behavior=Nt(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,e){let{state:r}=t,o=super.createResult(t,e),{isFetching:a,isRefetching:s,isError:n,isRefetchError:l}=o,c=r.fetchMeta?.fetchMore?.direction,d=n&&c==="forward",u=a&&c==="forward",p=n&&c==="backward",g=a&&c==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Ra(e,r.data),hasPreviousPage:Pa(e,r.data),isFetchNextPageError:d,isFetchingNextPage:u,isFetchPreviousPageError:p,isFetchingPreviousPage:g,isRefetchError:l&&!d&&!p,isRefetching:s&&!u&&!g}}};var Xt,fe,Q,st,ge,We,Na,Sa=(Na=class extends Rr{constructor(e){super();h(this,ge);h(this,Xt);h(this,fe);h(this,Q);h(this,st);m(this,Xt,e.client),this.mutationId=e.mutationId,m(this,Q,e.mutationCache),m(this,fe,[]),this.state=e.state||Co(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){i(this,fe).includes(e)||(i(this,fe).push(e),this.clearGcTimeout(),i(this,Q).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){m(this,fe,i(this,fe).filter(r=>r!==e)),this.scheduleGc(),i(this,Q).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){i(this,fe).length||(this.state.status==="pending"?this.scheduleGc():i(this,Q).remove(this))}continue(){return i(this,st)?.continue()??this.execute(this.state.variables)}async execute(e){let r=()=>{w(this,ge,We).call(this,{type:"continue"})},o={client:i(this,Xt),meta:this.options.meta,mutationKey:this.options.mutationKey};m(this,st,Tr({fn:()=>this.options.mutationFn?this.options.mutationFn(e,o):Promise.reject(new Error("No mutationFn found")),onFail:(n,l)=>{w(this,ge,We).call(this,{type:"failed",failureCount:n,error:l})},onPause:()=>{w(this,ge,We).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>i(this,Q).canRun(this)}));let a=this.state.status==="pending",s=!i(this,st).canStart();try{if(a)r();else{w(this,ge,We).call(this,{type:"pending",variables:e,isPaused:s}),i(this,Q).config.onMutate&&await i(this,Q).config.onMutate(e,this,o);let l=await this.options.onMutate?.(e,o);l!==this.state.context&&w(this,ge,We).call(this,{type:"pending",context:l,variables:e,isPaused:s})}let n=await i(this,st).start();return await i(this,Q).config.onSuccess?.(n,e,this.state.context,this,o),await this.options.onSuccess?.(n,e,this.state.context,o),await i(this,Q).config.onSettled?.(n,null,this.state.variables,this.state.context,this,o),await this.options.onSettled?.(n,null,e,this.state.context,o),w(this,ge,We).call(this,{type:"success",data:n}),n}catch(n){try{await i(this,Q).config.onError?.(n,e,this.state.context,this,o)}catch(l){Promise.reject(l)}try{await this.options.onError?.(n,e,this.state.context,o)}catch(l){Promise.reject(l)}try{await i(this,Q).config.onSettled?.(void 0,n,this.state.variables,this.state.context,this,o)}catch(l){Promise.reject(l)}try{await this.options.onSettled?.(void 0,n,e,this.state.context,o)}catch(l){Promise.reject(l)}throw w(this,ge,We).call(this,{type:"error",error:n}),n}finally{i(this,Q).runNext(this)}}},Xt=new WeakMap,fe=new WeakMap,Q=new WeakMap,st=new WeakMap,ge=new WeakSet,We=function(e){let r=o=>{switch(e.type){case"failed":return{...o,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...o,isPaused:!0};case"continue":return{...o,isPaused:!1};case"pending":return{...o,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...o,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...o,data:void 0,error:e.error,failureCount:o.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),N.batch(()=>{i(this,fe).forEach(o=>{o.onMutationUpdate(e)}),i(this,Q).notify({mutation:this,type:"updated",action:e})})},Na);function Co(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ne,se,Jt,Oa,Ca=(Oa=class extends oe{constructor(e={}){super();h(this,Ne);h(this,se);h(this,Jt);this.config=e,m(this,Ne,new Set),m(this,se,new Map),m(this,Jt,0)}build(e,r,o){let a=new Sa({client:e,mutationCache:this,mutationId:++Qt(this,Jt)._,options:e.defaultMutationOptions(r),state:o});return this.add(a),a}add(e){i(this,Ne).add(e);let r=Pr(e);if(typeof r=="string"){let o=i(this,se).get(r);o?o.push(e):i(this,se).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(i(this,Ne).delete(e)){let r=Pr(e);if(typeof r=="string"){let o=i(this,se).get(r);if(o)if(o.length>1){let a=o.indexOf(e);a!==-1&&o.splice(a,1)}else o[0]===e&&i(this,se).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){let r=Pr(e);if(typeof r=="string"){let a=i(this,se).get(r)?.find(s=>s.state.status==="pending");return!a||a===e}else return!0}runNext(e){let r=Pr(e);return typeof r=="string"?i(this,se).get(r)?.find(a=>a!==e&&a.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){N.batch(()=>{i(this,Ne).forEach(e=>{this.notify({type:"removed",mutation:e})}),i(this,Ne).clear(),i(this,se).clear()})}getAll(){return Array.from(i(this,Ne))}find(e){let r={exact:!0,...e};return this.getAll().find(o=>wr(r,o))}findAll(e={}){return this.getAll().filter(r=>wr(e,r))}notify(e){N.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){let e=this.getAll().filter(r=>r.state.isPaused);return N.batch(()=>Promise.all(e.map(r=>r.continue().catch(M))))}},Ne=new WeakMap,se=new WeakMap,Jt=new WeakMap,Oa);function Pr(t){return t.options.scope?.id}var Se,je,$,Oe,Ce,Nr,Eo,Ea,Fo=(Ea=class extends oe{constructor(e,r){super();h(this,Ce);h(this,Se);h(this,je);h(this,$);h(this,Oe);m(this,Se,e),this.setOptions(r),this.bindMethods(),w(this,Ce,Nr).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let r=this.options;this.options=i(this,Se).defaultMutationOptions(e),ft(this.options,r)||i(this,Se).getMutationCache().notify({type:"observerOptionsUpdated",mutation:i(this,$),observer:this}),r?.mutationKey&&this.options.mutationKey&&me(r.mutationKey)!==me(this.options.mutationKey)?this.reset():i(this,$)?.state.status==="pending"&&i(this,$).setOptions(this.options)}onUnsubscribe(){this.hasListeners()||i(this,$)?.removeObserver(this)}onMutationUpdate(e){w(this,Ce,Nr).call(this),w(this,Ce,Eo).call(this,e)}getCurrentResult(){return i(this,je)}reset(){i(this,$)?.removeObserver(this),m(this,$,void 0),w(this,Ce,Nr).call(this),w(this,Ce,Eo).call(this)}mutate(e,r){return m(this,Oe,r),i(this,$)?.removeObserver(this),m(this,$,i(this,Se).getMutationCache().build(i(this,Se),this.options)),i(this,$).addObserver(this),i(this,$).execute(e)}},Se=new WeakMap,je=new WeakMap,$=new WeakMap,Oe=new WeakMap,Ce=new WeakSet,Nr=function(){let e=i(this,$)?.state??Co();m(this,je,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},Eo=function(e){N.batch(()=>{if(i(this,Oe)&&this.hasListeners()){let r=i(this,je).variables,o=i(this,je).context,a={client:i(this,Se),meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{i(this,Oe).onSuccess?.(e.data,r,o,a)}catch(s){Promise.reject(s)}try{i(this,Oe).onSettled?.(e.data,null,r,o,a)}catch(s){Promise.reject(s)}}else if(e?.type==="error"){try{i(this,Oe).onError?.(e.error,r,o,a)}catch(s){Promise.reject(s)}try{i(this,Oe).onSettled?.(void 0,e.error,r,o,a)}catch(s){Promise.reject(s)}}}this.listeners.forEach(r=>{r(i(this,je))})})},Ea);var ve,Fa,Aa=(Fa=class extends oe{constructor(e={}){super();h(this,ve);this.config=e,m(this,ve,new Map)}build(e,r,o){let a=r.queryKey,s=r.queryHash??jt(a,r),n=this.get(s);return n||(n=new va({client:e,queryKey:a,queryHash:s,options:e.defaultQueryOptions(r),state:o,defaultOptions:e.getQueryDefaults(a)}),this.add(n)),n}add(e){i(this,ve).has(e.queryHash)||(i(this,ve).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let r=i(this,ve).get(e.queryHash);r&&(e.destroy(),r===e&&i(this,ve).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){N.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return i(this,ve).get(e)}getAll(){return[...i(this,ve).values()]}find(e){let r={exact:!0,...e};return this.getAll().find(o=>yr(r,o))}findAll(e={}){let r=this.getAll();return Object.keys(e).length>0?r.filter(o=>yr(e,o)):r}notify(e){N.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){N.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){N.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ve=new WeakMap,Fa);var I,Ke,qe,St,Ot,Ge,Ct,Et,Ma,Ao=(Ma=class{constructor(t={}){h(this,I);h(this,Ke);h(this,qe);h(this,St);h(this,Ot);h(this,Ge);h(this,Ct);h(this,Et);m(this,I,t.queryCache||new Aa),m(this,Ke,t.mutationCache||new Ca),m(this,qe,t.defaultOptions||{}),m(this,St,new Map),m(this,Ot,new Map),m(this,Ge,0)}mount(){Qt(this,Ge)._++,i(this,Ge)===1&&(m(this,Ct,ht.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,I).onFocus())})),m(this,Et,wt.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,I).onOnline())})))}unmount(){var t,e;Qt(this,Ge)._--,i(this,Ge)===0&&((t=i(this,Ct))==null||t.call(this),m(this,Ct,void 0),(e=i(this,Et))==null||e.call(this),m(this,Et,void 0))}isFetching(t){return i(this,I).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return i(this,Ke).findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return i(this,I).get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=i(this,I).build(this,e),o=r.state.data;return o===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(ie(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(o))}getQueriesData(t){return i(this,I).findAll(t).map(({queryKey:e,state:r})=>{let o=r.data;return[e,o]})}setQueryData(t,e,r){let o=this.defaultQueryOptions({queryKey:t}),s=i(this,I).get(o.queryHash)?.state.data,n=sa(e,s);if(n!==void 0)return i(this,I).build(this,o).setData(n,{...r,manual:!0})}setQueriesData(t,e,r){return N.batch(()=>i(this,I).findAll(t).map(({queryKey:o})=>[o,this.setQueryData(o,e,r)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return i(this,I).get(e.queryHash)?.state}removeQueries(t){let e=i(this,I);N.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){let r=i(this,I);return N.batch(()=>(r.findAll(t).forEach(o=>{o.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){let r={revert:!0,...e},o=N.batch(()=>i(this,I).findAll(t).map(a=>a.cancel(r)));return Promise.all(o).then(M).catch(M)}invalidateQueries(t,e={}){return N.batch(()=>(i(this,I).findAll(t).forEach(r=>{r.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){let r={...e,cancelRefetch:e.cancelRefetch??!0},o=N.batch(()=>i(this,I).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let s=a.fetch(void 0,r);return r.throwOnError||(s=s.catch(M)),a.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(o).then(M)}fetchQuery(t){let e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);let r=i(this,I).build(this,e);return r.isStaleByTime(ie(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(M).catch(M)}fetchInfiniteQuery(t){return t.behavior=Nt(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(M).catch(M)}ensureInfiniteQueryData(t){return t.behavior=Nt(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return wt.isOnline()?i(this,Ke).resumePausedMutations():Promise.resolve()}getQueryCache(){return i(this,I)}getMutationCache(){return i(this,Ke)}getDefaultOptions(){return i(this,qe)}setDefaultOptions(t){m(this,qe,t)}setQueryDefaults(t,e){i(this,St).set(me(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...i(this,St).values()],r={};return e.forEach(o=>{Xe(t,o.queryKey)&&Object.assign(r,o.defaultOptions)}),r}setMutationDefaults(t,e){i(this,Ot).set(me(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...i(this,Ot).values()],r={};return e.forEach(o=>{Xe(t,o.mutationKey)&&Object.assign(r,o.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;let e={...i(this,qe).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=jt(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===gt&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...i(this,qe).mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){i(this,I).clear(),i(this,Ke).clear()}},I=new WeakMap,Ke=new WeakMap,qe=new WeakMap,St=new WeakMap,Ot=new WeakMap,Ge=new WeakMap,Ct=new WeakMap,Et=new WeakMap,Ma);import*as Ft from"react";import{jsx as Ms}from"react/jsx-runtime";var Mo=Ft.createContext(void 0),Ee=t=>{let e=Ft.useContext(Mo);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Io=({client:t,children:e})=>(Ft.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),Ms(Mo.Provider,{value:t,children:e}));import*as Sr from"react";var Ia=Sr.createContext(!1),Da=()=>Sr.useContext(Ia),Dd=Ia.Provider;import*as er from"react";import{jsx as Ud}from"react/jsx-runtime";function Is(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Ds=er.createContext(Is()),tr=()=>er.useContext(Ds);import*as _a from"react";var La=(t,e,r)=>{let o=r?.state.error&&typeof t.throwOnError=="function"?vt(t.throwOnError,[r.state.error,r]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||o)&&(e.isReset()||(t.retryOnMount=!1))},Ua=t=>{_a.useEffect(()=>{t.clearReset()},[t])},Ba=({result:t,errorResetBoundary:e,throwOnError:r,query:o,suspense:a})=>t.isError&&!e.isReset()&&!t.isFetching&&o&&(a&&t.data===void 0||vt(r,[t.error,o]));var Or=(t,e)=>e.state.data===void 0,za=t=>{if(t.suspense){let r=a=>a==="static"?a:Math.max(a??1e3,1e3),o=t.staleTime;t.staleTime=typeof o=="function"?(...a)=>r(o(...a)):r(o),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Ha=(t,e)=>t.isLoading&&t.isFetching&&!e,Qa=(t,e)=>t?.suspense&&e.isPending,Do=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});import*as $e from"react";function Cr(t,e,r){let o=Da(),a=tr(),s=Ee(r),n=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(n);let l=s.getQueryCache().get(n.queryHash);n._optimisticResults=o?"isRestoring":"optimistic",za(n),La(n,a,l),Ua(a);let c=!s.getQueryCache().get(n.queryHash),[d]=$e.useState(()=>new e(s,n)),u=d.getOptimisticResult(n),p=!o&&t.subscribed!==!1;if($e.useSyncExternalStore($e.useCallback(g=>{let v=p?d.subscribe(N.batchCalls(g)):M;return d.updateResult(),v},[d,p]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),$e.useEffect(()=>{d.setOptions(n)},[n,d]),Qa(n,u))throw Do(n,d,a);if(Ba({result:u,errorResetBoundary:a,throwOnError:n.throwOnError,query:l,suspense:n.suspense}))throw u.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(n,u),n.experimental_prefetchInRender&&!he.isServer()&&Ha(u,o)&&(c?Do(n,d,a):l?.promise)?.catch(M).finally(()=>{d.updateResult()}),n.notifyOnChangeProps?u:d.trackResult(u)}function nt(t,e){return Cr({...t,enabled:!0,suspense:!0,throwOnError:Or,placeholderData:void 0},Zt,e)}function rr(t,e){return Cr({...t,enabled:!0,suspense:!0,throwOnError:Or},Oo,e)}import*as Fe from"react";function _o(t,e){let r=Ee(e),[o]=Fe.useState(()=>new Fo(r,t));Fe.useEffect(()=>{o.setOptions(t)},[o,t]);let a=Fe.useSyncExternalStore(Fe.useCallback(n=>o.subscribe(N.batchCalls(n)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),s=Fe.useCallback((n,l)=>{o.mutate(n,l).catch(M)},[o]);if(a.error&&vt(o.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:s,mutateAsync:a.mutate}}var ne={widgetTitle:"Savings Box",launcherLabel:"Insurance Savings",launcherIcon:"arrow",showLauncher:!0,mode:"light",allowUserThemeControl:!1,defaultTheme:"light",uiVersion:"current",primary:"#1E40AF",accent:"#2648C9",accentTextLight:"#FFFFFF",accentTextDark:"#FFFFFF",bg:"#0B1220",panel:"#0F1A2E",panel2:"#111F38",itemBg:"rgba(255,255,255,0.03)",text:"#E6EDF7",muted:"#A7B3C6",border:"rgba(255,255,255,0.08)",success:"#34D399",danger:"#EF4444",warning:"#FBBF24",lightBg:"#F8FAFC",lightPanel:"#FFFFFF",lightPanel2:"#F1F5F9",lightItemBg:"rgba(0,0,0,0.04)",lightText:"#0F172A",lightMuted:"#64748B",lightBorder:"rgba(0,0,0,0.1)"};function At(t){let e=t.mode==="light",r=e?t.textColorLight?.trim()||t.lightText:t.textColorDark?.trim()||t.text;return{...t,bg:e?t.lightBg:t.bg,panel:e?t.lightPanel:t.panel,panel2:e?t.lightPanel2:t.panel2,itemBg:e?t.lightItemBg:t.itemBg,text:r,muted:e?t.lightMuted:t.muted,border:e?t.lightBorder:t.border,subtleBg:e?"rgba(0,0,0,0.02)":"rgba(255,255,255,0.03)",tooltipBg:e?"#FFFFFF":"#0B1220",tooltipBorder:e?"rgba(0,0,0,0.12)":"rgba(255,255,255,0.12)",accentText:e?t.accentTextLight?.trim()||"#0F172A":t.accentTextDark?.trim()||"#FFFFFF",isLight:e,mode:t.mode}}var _s=["NEED_TOKEN","FRUGA_TOKEN_UPDATE","FRUGA_GET_BALANCE","FRUGA_BALANCE_RESPONSE","FRUGA_RESIZE","FRUGA_HOST_RESIZE","FRUGA_READY","FRUGA_INIT"],Ls=t=>typeof t=="string"&&_s.includes(t),Us=["ttl","unauthorized"],Wa=t=>{if(typeof t!="object"||t===null)return!1;let e=t;if(!Ls(e.type)||e.version!==void 0&&typeof e.version!="string")return!1;if(e.type==="NEED_TOKEN"){let{reason:r}=t;return typeof r=="string"&&Us.includes(r)}return!0};var ja=t=>t==="PARTNER"||t==="USER"?t:null;var or=class extends Error{constructor(r,o){super(o);this.status=r;this.name="HttpError"}},Ae=class extends or{constructor(e="Unauthorized"){super(401,e),this.name="UnauthorizedError"}};var Mt=class{constructor(e,r){this.baseUrl=e;this.token=r}async fetchQuery(e,r={}){let o=new URL(`${this.baseUrl}${e}`);return Object.entries(r).forEach(([a,s])=>{s!=null&&(Array.isArray(s)?s.forEach(n=>o.searchParams.append(a,String(n))):o.searchParams.append(a,String(s)))}),fetch(o.toString(),{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${this.token}`}})}},le=(t,e)=>{if(!t.ok)throw t.status===401?new Ae(`${e}: unauthorized`):new or(t.status,`${e}: ${t.status}`)};var Er=class{constructor(e,r){this.baseUrl=e;this.token=r}async getWallet(){let e=await fetch(`${this.baseUrl}/api/wallet`,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${this.token}`}});le(e,"Failed to fetch wallet");let r=await e.json();return{available:r.available??0,pending:r.pending??0,totalBalance:(r.available||0)+(r.pending||0),lifetimeEarned:r.lifetimeEarned??0,lifetimeRedeemed:r.lifetimeRedeemed??0,updatedAt:r.updatedAt??new Date().toISOString(),requiredActions:r.requiredActions??null}}};var Fr=class extends Mt{constructor(e,r){super(e,r)}async getActivity(e,r){let o=await this.fetchQuery("/api/activity",{pageNumber:e,pageSize:r});le(o,"Failed to fetch activity");let a=await o.json();return{...a,transactions:a.transactions||[]}}};var Ar=class extends Mt{constructor(e,r){super(e,r)}async getCategories(){let e=await this.fetchQuery("/api/offers/categories");return le(e,"Failed to fetch offer categories"),(await e.json()).categories||[]}async getOffers(e){let r=await this.fetchQuery("/api/offers",{pageNumber:e.pageNumber??0,pageSize:e.pageSize??10,type:e.type,query:e.query,featured:e.featured,categories:e.categories});le(r,"Failed to fetch offers");let o=await r.json();return{...o,content:o.content||[]}}};var Mr=class{constructor(e,r){this.baseUrl=e;this.token=r}async listMethods(){let e=await fetch(`${this.baseUrl}/api/payout-methods`,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${this.token}`}});return le(e,"Failed to list payout methods"),(await e.json()).items||[]}async addBankMethod(e){let r=await fetch(`${this.baseUrl}/api/payout-methods/bank`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify(e)});return le(r,"Failed to add bank payout method"),r.json()}async deleteMethod(e){let r=await fetch(`${this.baseUrl}/api/payout-methods/${e}`,{method:"DELETE",headers:{Accept:"application/json",Authorization:`Bearer ${this.token}`}});le(r,"Failed to delete payout method")}};var Bs="*",Ir=class{constructor(e){H(this,"target");H(this,"acceptSource");H(this,"listenOn");H(this,"handlers",new Set);H(this,"pinOriginFrom");H(this,"targetOrigin");H(this,"acceptOrigin");H(this,"pinned",null);H(this,"disposed",!1);H(this,"onMessage",e=>{if(this.disposed||this.acceptSource&&e.source!==this.acceptSource||this.acceptOrigin&&e.origin!==this.acceptOrigin||!Wa(e.data)||!this.admitWhileUnpinned(e.data.type,e.origin))return;let r=typeof e.data.version=="string"&&e.data.version.length>0?e.data:{...e.data,version:"1.0"};for(let o of[...this.handlers])o(r)});let r=e.listenOn??(typeof window<"u"?window:void 0);if(!r)throw new Error("PostMessageTransport: no window to listen on; pass options.listenOn");this.target=e.target,this.targetOrigin=e.targetOrigin,this.acceptSource=e.acceptSource,this.acceptOrigin=e.acceptOrigin,this.pinOriginFrom=e.pinOriginFrom,this.listenOn=r,this.listenOn.addEventListener("message",this.onMessage)}get pinnedOrigin(){return this.pinned}pinOrigin(e){this.targetOrigin=e,this.acceptOrigin=e,this.pinned=e}send(e){if(this.disposed)return;let r=typeof e.version=="string"&&e.version.length>0?e:{...e,version:"1.0"};this.target.postMessage(r,this.targetOrigin)}subscribe(e){if(this.disposed)throw new Error("PostMessageTransport: cannot subscribe after dispose()");return this.handlers.add(e),()=>{this.handlers.delete(e)}}dispose(){this.disposed||(this.disposed=!0,this.handlers.clear(),this.listenOn.removeEventListener("message",this.onMessage))}admitWhileUnpinned(e,r){return!this.pinOriginFrom||this.pinned!==null?!0:e!==this.pinOriginFrom?!1:r&&r!=="null"?(this.pinOrigin(r),!0):(this.pinned=Bs,!0)}};var Dr=t=>{let e=t?.listenOn??(typeof window<"u"?window:void 0);if(!e)throw new Error("createHostTransport: no window available; pass options.listenOn");let r=e.parent!==e;return new Ir({target:e.parent,targetOrigin:"*",pinOriginFrom:"FRUGA_INIT",listenOn:e,...r?{acceptSource:e.parent}:{}})};import{useState as Uo,useEffect as en,useRef as Za}from"react";import{Sparkles as zs,CreditCard as Hs,MoveUpRight as Qs,Gift as Ws}from"lucide-react";import{jsx as _r}from"react/jsx-runtime";function Ka({theme:t}){return t.launcherIcon==="none"?null:t.launcherIcon==="sparkles"?_r(zs,{size:20}):t.launcherIcon==="credit"?_r(Hs,{size:20}):t.launcherIcon==="arrow"?_r(Qs,{size:20}):_r(Ws,{size:20})}import{useEffect as Gs,useRef as $s}from"react";var qa=t=>{let e,r=new Set,o=(d,u)=>{let p=typeof d=="function"?d(e):d;if(!Object.is(p,e)){let g=e;e=u??(typeof p!="object"||p===null)?p:Object.assign({},e,p),r.forEach(v=>v(e,g))}},a=()=>e,l={setState:o,getState:a,getInitialState:()=>c,subscribe:d=>(r.add(d),()=>r.delete(d))},c=e=t(o,a,l);return l},Ga=(t=>t?qa(t):qa);import Lr from"react";var js=t=>t;function Ks(t,e=js){let r=Lr.useSyncExternalStore(t.subscribe,Lr.useCallback(()=>e(t.getState()),[t,e]),Lr.useCallback(()=>e(t.getInitialState()),[t,e]));return Lr.useDebugValue(r),r}var $a=t=>{let e=Ga(t),r=o=>Ks(e,o);return Object.assign(r,e),r},Va=(t=>t?$a(t):$a);var T=Va(t=>({isOpen:!1,isFocused:!0,isIdle:!1,available:0,pending:0,mode:"light",token:null,tokenEpoch:0,authStatus:"pending",partnerPayout:null,isAddingPayoutFromAlert:!1,showPayoutSuccess:!1,toggle:()=>t(e=>({isOpen:!e.isOpen})),setOpen:e=>t({isOpen:e}),setFocused:e=>t({isFocused:e}),setIdle:e=>t({isIdle:e}),setBalances:(e,r)=>t({available:e,pending:r}),setMode:e=>t({mode:e}),setToken:e=>t(r=>({token:e,tokenEpoch:r.token===e?r.tokenEpoch:r.tokenEpoch+1,authStatus:e?"authenticated":"pending"})),setPartnerPayout:e=>t({partnerPayout:ja(e)}),setIsAddingPayoutFromAlert:e=>t({isAddingPayoutFromAlert:e}),setShowPayoutSuccess:e=>t({showPayoutSuccess:e})}));function Ya(){let{setFocused:t,setIdle:e}=T(),r=$s(null);Gs(()=>{let o=()=>t(!0),a=()=>t(!1),s=()=>{e(!1),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{e(!0)},6e4)},n=()=>{s()};s(),t(document.hasFocus()),window.addEventListener("focus",o),window.addEventListener("blur",a);let l=["mousemove","keydown","scroll","touchstart","mousedown"];return l.forEach(c=>{window.addEventListener(c,n,c==="scroll"?!0:void 0)}),()=>{window.removeEventListener("focus",o),window.removeEventListener("blur",a),l.forEach(c=>{window.removeEventListener(c,n,c==="scroll"?!0:void 0)}),r.current&&clearTimeout(r.current)}},[t,e])}import{useContext as Zs,useEffect as Xs,useRef as Js}from"react";import{createContext as Vs}from"react";import{jsx as Ys}from"react/jsx-runtime";var Lo=Vs(null),Ur=({transport:t,children:e})=>Ys(Lo.Provider,{value:t,children:e});var lt=()=>{let t=Zs(Lo);if(!t)throw new Error("useMessageTransport: no transport in context. Wrap the widget tree in <MessageTransportProvider transport={...}>.");return t},be=(t,e)=>{let r=lt(),o=Js(e);o.current=e,Xs(()=>r.subscribe(a=>{a.type===t&&o.current(a)}),[r,t])};import{X as tn}from"lucide-react";import{Fragment as rn,jsx as It,jsxs as Bo}from"react/jsx-runtime";var Xa=({children:t,theme:e,hostHeight:r=800,isMobile:o=!1})=>{Ya();let{isOpen:a,toggle:s,mode:n}=T(),l=e||ne,[c,d]=Uo(r),[u,p]=Uo(o),[g,v]=Uo(void 0),f=l.allowUserThemeControl?{...l,mode:n}:{...l,mode:g??l.mode??"light"},y=At(f),R=Za(null),O=Za(null),F=lt();return be("FRUGA_HOST_RESIZE",x=>{d(x.hostHeight),p(x.isHostMobile)}),be("FRUGA_TOKEN_UPDATE",x=>{T.getState().setToken(x.token)}),be("FRUGA_GET_BALANCE",x=>{let{available:C,pending:D}=T.getState();F.send({type:"FRUGA_BALANCE_RESPONSE",version:"1.0",requestId:x.requestId,available:C,pending:D})}),be("FRUGA_INIT",x=>{d(x.host.height),p(x.host.isMobile),x.token&&T.getState().setToken(x.token),x.overrides?.panelOpen&&T.getState().setOpen(!0);let C=x.overrides?.theme;C&&(v(C),T.getState().setMode(C))}),en(()=>{if(!R.current)return;let x=()=>{if(!R.current)return;let D=a?450:100;!a&&O.current&&(D=O.current.offsetWidth+40);let z=a?Math.max(200,c-100):100;u&&a&&(D=window.innerWidth,z=c),F.send({type:"FRUGA_RESIZE",version:"1.0",height:z,width:D,isFullscreen:u&&a})},C=new ResizeObserver(()=>x());return C.observe(R.current),x(),()=>C.disconnect()},[a,c,u,F]),Bo("div",{ref:R,className:y.mode==="dark"?"dark":"",style:{fontFamily:'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',color:y.text,display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"flex-end",padding:u&&a?"0":"20px",boxSizing:"border-box",height:"100%",margin:0,overscrollBehavior:"contain"},children:[a&&It("div",{style:{width:u?"100vw":"410px",minWidth:u?"100vw":"410px",flexShrink:0,maxHeight:u?"100vh":`${Math.max(100,c-100)}px`,height:"100%",marginBottom:u?"0":"20px",backgroundColor:y.accent,borderRadius:u?"0":"16px",boxShadow:u?"none":"0 20px 40px -10px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0,0,0,0.1)",display:"flex",flexDirection:"column",overflow:"hidden",zIndex:9998},children:It("div",{className:"fruga-scrollbar",style:{flex:1,minHeight:0,backgroundColor:y.isLight?"#f9f9f9":"#111",display:"flex",flexDirection:"column",boxShadow:u?"none":"0 20px 40px -10px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0,0,0,0.1)"},children:t})}),Bo("button",{ref:O,onClick:s,style:{backgroundColor:y.accent,color:y.accentText,border:"none",cursor:"pointer",boxShadow:"0 12px 30px -5px rgba(0, 0, 0, 0.1), 0 0 1px rgba(0,0,0, 0.1)",display:a?"none":"flex",alignItems:"center",justifyContent:"center",zIndex:9999,flexShrink:0,borderRadius:"20px",padding:"10px 16px",transition:"transform 0.3s ease-in-out"},className:"flex h-15 items-center gap-2 rounded-xl px-4 active:scale-[0.99]","aria-label":a?"Close widget":"Open widget",children:[l.launcherLabel&&!a?Bo(rn,{children:[l.launcherLabel!=="none"&&It("div",{className:"text-sm font-semibold",children:l.launcherLabel}),It("div",{className:"flex h-6 w-5 shrink-0 items-center justify-center",children:It(Ka,{theme:y})})]}):null,a?It(tn,{}):null]})]})};import{Fragment as Fu,jsx as Au}from"react/jsx-runtime";import{useEffect as on,useState as an}from"react";var Ja=(t,e)=>{let[r,o]=an(t);return on(()=>{let a=setTimeout(()=>{o(t)},e);return()=>{clearTimeout(a)}},[t,e]),r};var sn="https://api.fruga.co.uk",ei=t=>t||sn,ti=()=>!1;var zo=t=>{if(!t)return"";try{let e=t.includes("/")&&!t.includes("-")?t.split(" ")[0].split("/").reverse().join("-"):t,r=new Date(e);if(isNaN(r.getTime()))return t;let o=r.getDate().toString().padStart(2,"0"),a=(r.getMonth()+1).toString().padStart(2,"0"),s=r.getFullYear();return`${o}-${a}-${s}`}catch{return t}},ri=t=>{try{let e=t.includes("/")&&!t.includes("-")?t.split(" ")[0].split("/").reverse().join("-"):t,r=new Date(e);return isNaN(r.getTime())?null:r}catch{return null}},oi=(t,e=30)=>{if(!t)return!1;let r=ri(t);if(!r)return!1;let o=new Date,a=new Date(o.getFullYear(),o.getMonth(),o.getDate()),n=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime()-a.getTime(),l=Math.ceil(n/(1e3*60*60*24));return l>=0&&l<=e},ai=t=>{if(!t)return null;let e=ri(t);if(!e)return null;let r=new Date,o=new Date(r.getFullYear(),r.getMonth(),r.getDate()),s=new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()-o.getTime(),n=Math.ceil(s/(1e3*60*60*24));return n>=0?n:0};var ii=(t,e=40)=>t?t.length<=e?t:t.slice(0,e)+"...":"";import{forwardRef as ds,useEffect as bl,useImperativeHandle as yl,useRef as wl,useState as ur}from"react";import{createContext as nn,useContext as ln,useMemo as cn}from"react";var Br=class{constructor(e){this.offerRepository=e}async getOffers(e){return this.offerRepository.getOffers(e)}async getFeaturedOffers(){return(await this.offerRepository.getOffers({featured:!0,pageSize:20})).content}async getOfferDetails(e){return this.offerRepository.getOfferById(e)}async claimOffer(e){return!0}async getOfferCategories(){return this.offerRepository.getCategories()}};var zr=class{constructor(e){this.accountRepository=e}async getWallet(){return this.accountRepository.getWallet()}async getActivity(e,r){return this.accountRepository.getActivity(e,r)}};var X=t=>{let e=new Date;return e.setDate(e.getDate()+t),e.toISOString().split("T")[0]},J={Travel:{id:2,name:"Travel",rank:2,offerCount:15},Sports:{id:4,name:"Sports",rank:4,offerCount:10},Fashion:{id:3,name:"Fashion",rank:3,offerCount:30},"Food&Bev":{id:1,name:"Food&Bev",rank:1,offerCount:20},Entertainment:{id:5,name:"Entertainment",rank:5,offerCount:5}},hm=[{id:1,name:"easyJet flight booking",brandName:"easyJet",description:"Save on your next flight",terms:"T&Cs apply.",link:"https://easyjet.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/easyjet.com",cashback:.035,endDate:X(10),featured:!0,categories:[J.Travel]},{id:2,name:"Nike shoes",brandName:"Nike",description:"Just do it",terms:"Online only",link:"https://nike.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/nike.com",cashback:.06,endDate:X(30),featured:!0,categories:[J.Sports]},{id:3,name:"Adidas gear",brandName:"Adidas",description:"Sportswear and shoes",terms:"T&Cs apply.",link:"https://adidas.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/adidas.com",cashback:.05,endDate:X(30),featured:!1,categories:[J.Sports]},{id:4,name:"ASOS fashion",brandName:"ASOS",description:"Latest trends",terms:"T&Cs apply.",link:"https://asos.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/asos.com",cashback:.08,endDate:X(30),featured:!0,categories:[J.Fashion]},{id:5,name:"Morrisons groceries",brandName:"Morrisons",description:"Fresh food",terms:"T&Cs apply.",link:"https://morrisons.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/morrisons.com",cashback:.02,endDate:X(6),featured:!1,categories:[J["Food&Bev"]]},{id:6,name:"Just Eat delivery",brandName:"Just Eat",description:"Food delivery",terms:"T&Cs apply.",link:"https://just-eat.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/just-eat.com",cashback:.04,endDate:X(30),featured:!1,categories:[J["Food&Bev"]]},{id:7,name:"TripAdvisor bookings",brandName:"TripAdvisor",description:"Hotels and more",terms:"T&Cs apply.",link:"https://tripadvisor.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/tripadvisor.com",cashback:.19,endDate:X(30),featured:!0,categories:[J.Travel]},{id:8,name:"Debenhams store",brandName:"Debenhams",description:"Department store",terms:"T&Cs apply.",link:"https://debenhams.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/debenhams.com",cashback:.03,endDate:X(30),featured:!0,categories:[J.Fashion]},{id:9,name:"Booking.com hotel",brandName:"Booking.com",description:"Hotels worldwide",terms:"T&Cs apply.",link:"https://booking.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/booking.com",cashback:.04,endDate:X(30),featured:!1,categories:[J.Travel]},{id:10,name:"Deliveroo orders",brandName:"Deliveroo",description:"Food delivery",terms:"T&Cs apply.",link:"https://deliveroo.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/deliveroo.com",cashback:.05,endDate:X(30),featured:!0,categories:[J["Food&Bev"]]},{id:11,name:"Puma shoes",brandName:"Puma",description:"Sportswear",terms:"T&Cs apply.",link:"https://puma.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/puma.com",cashback:.07,endDate:X(30),featured:!1,categories:[J.Sports]},{id:12,name:"H&M clothing",brandName:"H&M",description:"Fashion",terms:"T&Cs apply.",link:"https://hm.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/hm.com",cashback:.04,endDate:X(30),featured:!1,categories:[J.Fashion]},{id:13,name:"Uber rides",brandName:"Uber",description:"Ride sharing",terms:"T&Cs apply.",link:"https://uber.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/uber.com",cashback:.02,endDate:X(30),featured:!1,categories:[J.Travel]}];var Hr=class{constructor(e,r){this.walletService=e;this.activityService=r}async getWallet(){return this.walletService.getWallet()}async getActivity(e,r){return this.activityService.getActivity(e,r)}};var Qr=class{constructor(e){this.offersService=e}async getOffers(e){return this.offersService.getOffers(e)}async getFeaturedOffers(){return[]}async getOfferById(){return null}async getCategories(){return this.offersService.getCategories()}};var Wr=class{constructor(e){this.repository=e}async getMethod(){return this.repository.getPaymentMethod()}async addMethod(e){return this.repository.savePaymentMethod(e)}async removeMethod(e){return this.repository.deletePaymentMethod(e)}};var jr=class{constructor(e){this.service=e}async getPaymentMethod(){let e=await this.service.listMethods();return e.find(r=>r.status==="ACTIVE")||e[0]||null}async savePaymentMethod(e){return this.service.addBankMethod(e)}async deletePaymentMethod(e){return this.service.deleteMethod(e)}};import{jsx as dn}from"react/jsx-runtime";var ni=nn(null),li=({children:t,baseUrl:e})=>{let{token:r}=T(),o=cn(()=>{let a=ei(e),s,n,l;return s=new Qr(new Ar(a,r??"")),n=new Hr(new Er(a,r??""),new Fr(a,r??"")),l=new jr(new Mr(a,r??"")),{offerUseCases:new Br(s),accountUseCases:new zr(n),paymentService:new Wr(l)}},[r,e]);return dn(ni.Provider,{value:o,children:t})};function ye(){let t=ln(ni);if(!t)throw new Error("useDependencies must be used within a DependencyProvider");return t}import{useState as so}from"react";import{Sparkles as pn,TrendingUp as un,ShieldCheck as mn,Gift as hn,ChevronRight as fn}from"lucide-react";import{jsx as de,jsxs as Kr}from"react/jsx-runtime";var ar=[{title:"Welcome to SavingsBox",description:"Your new way to save while you shop. Earn cashback on every purchase from your favorite brands.",icon:pn,color:"#8B5CF6",gradient:"linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%)"},{title:"Shop and Earn",description:"Simply browse through our partner brands, shop as usual, and watch your cashback balance grow.",icon:un,color:"#3B82F6",gradient:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},{title:"Secure Policy",description:"Use your earned cashback to pay for your insurance policies or withdraw it directly to your bank.",icon:mn,color:"#10B981",gradient:"linear-gradient(135deg, #10B981 0%, #059669 100%)"},{title:"Bonus Rewards",description:"Get exclusive bonuses and higher cashback rates as you use the platform more.",icon:hn,color:"#F59E0B",gradient:"linear-gradient(135deg, #F59E0B 0%, #D97706 100%)"}],ci=({theme:t,onboardingStep:e,setOnboardingStep:r,onFinish:o})=>{let a=ar[e],s=a.icon,n=()=>{e<ar.length-1?r(e+1):o()};return Kr("div",{className:"relative flex h-full flex-col items-center justify-center overflow-hidden px-8 text-center transition-all duration-700",children:[de("div",{className:"absolute -top-24 -left-24 h-64 w-64 rounded-full blur-[80px] opacity-20 transition-all duration-1000",style:{backgroundColor:a.color}}),Kr("div",{className:"relative z-10 flex flex-col items-center w-full max-w-[320px]",children:[de("div",{className:"group mb-10 flex h-24 w-24 items-center justify-center rounded-[2rem] shadow-2xl transition-all duration-500 hover:scale-110",style:{background:a.gradient,boxShadow:`0 20px 40px -10px ${a.color}66`},children:de(s,{size:44,className:"text-white drop-shadow-md transition-transform duration-500 group-hover:rotate-12"})}),Kr("div",{className:"space-y-4 animate-in slide-in-from-bottom-4 duration-700 fill-mode-both",children:[de("h2",{className:"text-3xl font-extrabold tracking-tight sm:text-4xl",style:{color:t.text},children:a.title}),de("p",{className:"text-lg leading-relaxed opacity-90 font-medium",style:{color:t.muted},children:a.description})]}),de("div",{className:"mt-12 mb-10 flex gap-2.5",children:ar.map((l,c)=>de("div",{className:"h-2 rounded-full transition-all duration-500",style:{width:c===e?"32px":"8px",backgroundColor:c===e?a.color:t.isLight?"rgba(0,0,0,0.1)":"rgba(255,255,255,0.1)",opacity:c===e?1:.4}},c))}),Kr("button",{onClick:n,className:"group relative flex w-full cursor-pointer items-center justify-center gap-2 overflow-hidden rounded-[1.25rem] py-4.5 text-lg font-bold text-white shadow-[0_15px_30px_-5px_rgba(0,0,0,0.3)] transition-all hover:scale-[1.03] active:scale-[0.97]",style:{background:a.gradient},children:[de("span",{children:e===ar.length-1?"Start Saving":"Continue"}),de(fn,{size:20,className:"transition-transform duration-300 group-hover:translate-x-1"})]}),e<ar.length-1?de("button",{onClick:o,className:"mt-6 cursor-pointer text-sm font-semibold opacity-60 transition-all hover:opacity-100 hover:translate-y-[-1px]",style:{color:t.text},children:"Skip for now"}):de("div",{className:"mt-6 h-5"})]})]})};function Ve(...t){return t.filter(Boolean).join(" ")}import{Tag as gn,UserStar as vn,CircleHelp as bn}from"lucide-react";import{jsx as Ho,jsxs as yn}from"react/jsx-runtime";var di=({theme:t,activeTab:e,onTabChange:r,onHelpPageReset:o})=>Ho("div",{className:"mx-3 grid grid-cols-3 gap-2 rounded-3xl p-2 shadow-[0_10px_25px_-5px_rgba(0,0,0,0.1),0_8px_10px_-6px_rgba(0,0,0,0.1)]",style:{background:t.panel},children:[{id:"offers",label:"Offers",Icon:gn},{id:"account",label:"Account",Icon:vn},{id:"help",label:"Help",Icon:bn}].map(a=>{let s=e===a.id,n=a.Icon;return yn("button",{onClick:()=>{r(a.id),o()},className:"flex flex-col items-center justify-center gap-1 rounded-3xl px-3 py-2.5",style:{background:s?t.isLight?`color-mix(in srgb, ${t.accent} 18%, transparent)`:`color-mix(in srgb, ${t.accent} 25%, transparent)`:"transparent",color:s?t.accent:t.text,cursor:"pointer"},children:[Ho(n,{size:18,strokeWidth:2.2}),Ho("div",{className:"text-[11px] font-semibold leading-none",children:a.label})]},a.id)})});import Tn from"react";import{ChevronLeft as gi,Sparkles as Rn,X as Pn,Settings as Nn}from"lucide-react";import{Sun as wn,Moon as xn}from"lucide-react";import{jsx as Qo,jsxs as pi}from"react/jsx-runtime";function ui({isLight:t,onToggle:e,accentColor:r,hoverClass:o="hover:bg-white/5"}){return pi("button",{type:"button",onClick:e,"aria-label":t?"Switch to dark mode":"Switch to light mode",title:t?"Dark mode":"Light mode",className:`group relative flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-all duration-300 cursor-pointer active:scale-90 ${o}`,children:[pi("div",{className:"relative h-5 w-5 flex items-center justify-center",children:[Qo(wn,{size:18,strokeWidth:2.5,className:`absolute transition-all duration-500 ${t?"rotate-0 scale-100 opacity-100":"rotate-90 scale-0 opacity-0"}`,style:{transitionTimingFunction:"cubic-bezier(0.34, 1.56, 0.64, 1)",color:r}}),Qo(xn,{size:18,strokeWidth:2.5,className:`absolute transition-all duration-500 ${t?"-rotate-90 scale-0 opacity-0":"rotate-0 scale-100 opacity-100"}`,style:{transitionTimingFunction:"cubic-bezier(0.34, 1.56, 0.64, 1)",color:r}})]}),Qo("div",{className:`absolute inset-0 rounded-full transition-opacity duration-700 blur-md -z-10 ${t?"bg-amber-400/20 opacity-100":"bg-blue-400/10 opacity-0"}`})]})}import{jsx as W,jsxs as ir}from"react/jsx-runtime";function S({theme:t,className:e,style:r}){let o=t.isLight?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.06)",a=t.isLight?"rgba(0,0,0,0.12)":"rgba(255,255,255,0.12)";return W("div",{className:Ve("rounded-2xl",e),style:{background:`linear-gradient(90deg, ${o} 0%, ${a} 20%, ${o} 40%, ${o} 100%)`,backgroundSize:"200% 100%",animation:"shimmer 1.5s ease-in-out infinite",...r}})}function mi({theme:t}){return W("div",{className:"w-full rounded-2xl p-4",style:{background:t.isLight?"#FFFFFF":t.panel,border:t.isLight?"none":"1px solid rgba(255,255,255,0.08)",boxShadow:t.isLight?"0 1px 3px rgba(0,0,0,0.06)":"0 1px 3px rgba(0,0,0,0.2)"},children:ir("div",{className:"flex items-center gap-3",children:[W(S,{theme:t,className:"h-10 w-16 shrink-0 rounded-lg"}),W("div",{className:"flex-1 space-y-2",children:W(S,{theme:t,className:"h-4 w-24"})}),W("div",{className:"shrink-0 flex flex-col items-end gap-2",children:W(S,{theme:t,className:"h-5 w-20 rounded-xl"})})]})})}function hi({theme:t}){return ir("div",{className:"flex h-[140px] w-[140px] shrink-0 flex-col items-center justify-start rounded-2xl p-3 pt-4",style:{background:t.isLight?"#FFFFFF":t.panel,border:t.isLight?void 0:"1px solid rgba(255,255,255,0.08)",boxShadow:t.isLight?"0 1px 3px rgba(0,0,0,0.06)":"0 1px 3px rgba(0,0,0,0.2)"},children:[W(S,{theme:t,className:"h-10 w-12 shrink-0 rounded-lg"}),W(S,{theme:t,className:"mt-1.5 h-5 w-20"}),W(S,{theme:t,className:"mt-1 h-6 w-16 rounded-full"})]})}function fi({theme:t}){return W("div",{className:"flex flex-col gap-1 px-4 py-3",children:[1,2,3].map(e=>ir("div",{className:"flex items-center gap-4 py-3",children:[W(S,{theme:t,className:"h-10 w-10 shrink-0 rounded-full"}),ir("div",{className:"flex-1 space-y-2",children:[W(S,{theme:t,className:"h-4 w-1/2"}),W(S,{theme:t,className:"h-3 w-1/4 opacity-60"})]}),ir("div",{className:"text-right space-y-2",children:[W(S,{theme:t,className:"h-4 w-16"}),W(S,{theme:t,className:"h-3 w-12 ml-auto opacity-60"})]})]},e))})}import{Fragment as Dt,jsx as b,jsxs as E}from"react/jsx-runtime";var sr=[{id:"how-it-works",title:"How it works",body:t=>{let e=t.isLight?{border:"1px solid rgba(0,0,0,0.1)",background:"rgba(0,0,0,0.04)"}:{border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)"};return E(Dt,{children:[E("p",{className:"leading-relaxed",children:["You earn cashback when you shop with partner brands through links in this widget. Cashback appears as ",b("b",{children:"Pending"})," first, then becomes ",b("b",{children:"Available"})," after it's confirmed."]}),E("ul",{className:"mt-3 list-disc space-y-1 pl-5 text-sm opacity-90",children:[b("li",{children:"Pick an offer"}),b("li",{children:"Shop as normal on the brand's site"}),b("li",{children:"We track your purchase and update your credit"})]}),E("div",{className:"mt-4 space-y-3 text-sm opacity-90",children:[E("div",{children:[b("div",{className:"text-xs font-semibold opacity-80",children:"What happens after I click an offer?"}),E("p",{className:"mt-1 leading-relaxed",children:["We open the brand's website in a tracked session. If you complete a purchase, the brand reports it back to us and we add cashback to your account as ",b("b",{children:"Pending"}),"."]})]}),E("div",{children:[b("div",{className:"text-xs font-semibold opacity-80",children:"Why does cashback start as Pending?"}),b("p",{className:"mt-1 leading-relaxed",children:"Brands typically confirm orders after return periods or fraud checks. Once confirmed, Pending cashback becomes Available."})]}),E("div",{children:[b("div",{className:"text-xs font-semibold opacity-80",children:"Quick checklist (to avoid missing cashback)"}),E("ul",{className:"mt-2 list-disc space-y-1 pl-5",children:[b("li",{children:"Allow cookies for the host website and the brand site"}),b("li",{children:"Don't use ad-blockers that strip tracking parameters"}),b("li",{children:"Complete purchase in the same browser session"}),b("li",{children:"Avoid applying promo codes not listed on the offer"}),b("li",{children:"If you switch devices, start the offer again from this widget"})]})]}),E("div",{children:[b("div",{className:"text-xs font-semibold opacity-80",children:"Typical timelines"}),E("ul",{className:"mt-2 list-disc space-y-1 pl-5",children:[b("li",{children:"Pending shows up: within minutes to 48 hours"}),b("li",{children:"Confirmation: 7\u201360 days (varies by brand/category)"}),b("li",{children:"Available \u2192 redeem: depends on the host website's redemption options"})]})]}),E("div",{className:"rounded-2xl p-3",style:e,children:[b("div",{className:"text-xs font-semibold opacity-80",children:"Troubleshooting"}),E("div",{className:"mt-2 space-y-2 text-sm opacity-90",children:[b("div",{children:"\u2022 If you don't see Pending cashback within 48 hours, check you completed the purchase in the same browser session."}),b("div",{children:"\u2022 If you used a promo code not listed on the offer, cashback might be reduced or declined by the retailer."}),b("div",{children:"\u2022 Some categories confirm after returns windows, so Pending can take longer to become Available."}),b("div",{children:"\u2022 If you cancelled or returned an order, cashback is typically reversed."}),b("div",{children:"\u2022 If you used private browsing, tracking may fail. Retry in a normal session."}),b("div",{children:"\u2022 If you switch between tabs/checkout providers, keep cookies enabled."}),b("div",{children:"\u2022 Some retailers exclude gift cards and subscriptions from cashback."}),b("div",{children:"\u2022 If multiple cashback tools are active, retailers may reject tracking."}),b("div",{children:'\u2022 If you used "click & collect", cashback rules vary by retailer.'})]})]}),E("div",{className:"rounded-2xl p-3",style:e,children:[b("div",{className:"text-xs font-semibold opacity-80",children:"Need more help?"}),E("div",{className:"mt-2 space-y-2 text-sm opacity-90",children:[b("div",{children:"\u2022 Check your order history for the exact date/time of purchase."}),b("div",{children:"\u2022 If the retailer confirms the order, cashback will move to Available automatically."}),b("div",{children:"\u2022 In the full product, you can submit a missing cashback claim (prototype not wired)."})]})]})]})]})}},{id:"earn-more",title:"How to earn more credit",body:()=>E(Dt,{children:[b("p",{className:"leading-relaxed",children:"Use the filters to find higher cashback offers, and keep an eye on expiring deals."}),E("div",{className:"mt-3 space-y-2 text-sm opacity-90",children:[E("div",{children:["\u2022 Try ",b("b",{children:"Fashion"})," and ",b("b",{children:"Sports"})," for higher % offers."]}),b("div",{children:"\u2022 Check back weekly \u2014 offers change often."}),b("div",{children:"\u2022 Ensure cookies are enabled so tracking works properly."})]})]})},{id:"redeem",title:"How to redeem my credit",body:t=>{let e=t.isLight?{border:"1px solid rgba(0,0,0,0.1)",background:"rgba(0,0,0,0.04)"}:{border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)"};return E(Dt,{children:[E("p",{className:"leading-relaxed",children:["When your credit is ",b("b",{children:"Available"}),", you can redeem it \u2014 depending on what the host website supports."]}),E("div",{className:"mt-3 rounded-2xl p-3 text-sm",style:e,children:[b("div",{className:"font-medium",children:"Prototype note"}),b("div",{className:"mt-1 opacity-90",children:"In the real SDK, redemption options are configurable per host website."})]})]})}},{id:"credits-work",title:"How do credits work?",body:()=>E(Dt,{children:[E("p",{className:"leading-relaxed",children:["Credits are the cashback you earn from shopping with partner brands. They start as ",b("b",{children:"Pending"})," while the retailer confirms your purchase, then move to ",b("b",{children:"Available"})," once confirmed."]}),b("p",{className:"mt-3 leading-relaxed",children:"You can use Available credit to pay for insurance, add-ons, or other options offered by the host website."})]})},{id:"credits-expire",title:"When do credits expire?",body:()=>E(Dt,{children:[b("p",{className:"leading-relaxed",children:"Pending credits typically become Available within 7\u201360 days, depending on the retailer. Once Available, your credit balance is yours to use."}),b("p",{className:"mt-3 leading-relaxed",children:"Expiry rules vary by host website. In the full product, you can check your account for any expiry dates on your credit."})]})},{id:"contact",title:"Contact us",body:()=>E(Dt,{children:[b("p",{className:"leading-relaxed",children:"Need help with cashback, redemption, or your account? Get in touch through the host website's support channels."}),b("p",{className:"mt-3 leading-relaxed",children:"In the full product, you can submit a missing cashback claim or contact support directly from your account."})]})}];import{useEffect as kn}from"react";function ct(){let{accountUseCases:t}=ye(),e=Ee(),{token:r,tokenEpoch:o,isOpen:a,isFocused:s,isIdle:n,available:l,pending:c,setBalances:d}=T(),u=a?s?n?3e4:1e4:3e4:!1,{data:p}=nt({queryKey:["wallet",r,o],queryFn:()=>t.getWallet(),refetchInterval:u});return kn(()=>{p&&(p.available!==l||p.pending!==c)&&(d(p.available,p.pending),e.invalidateQueries({queryKey:["activity"]}))},[p,l,c,e,d]),{wallet:p}}import{jsx as _,jsxs as ee}from"react/jsx-runtime";var Sn=()=>{let{wallet:t}=ct(),e=t?.available||0;return ee("div",{className:"mt-1 flex items-baseline gap-1",children:[ee("span",{className:"text-3xl font-bold tracking-tight",children:["\xA3",e.toFixed(2)]}),_(Rn,{size:20,className:"opacity-80"})]})},qr=({toggle:t,theme:e,allowUserThemeControl:r,onThemeModeChange:o,isAccentBackground:a=!1})=>{let s=a?e.accentText:e.text,n=a?"hover:bg-white/15":e.isLight?"hover:bg-black/5":"hover:bg-white/10";return ee("div",{className:"absolute right-2 top-3 z-[100] flex items-center gap-1",style:{color:s},children:[r&&_(ui,{isLight:e.isLight,onToggle:()=>o?.(e.isLight?"dark":"light"),accentColor:s,hoverClass:n}),_("button",{className:`cursor-pointer rounded-full p-2 transition-all duration-200 active:scale-90 ${n}`,onClick:t,"aria-label":"Close",title:"Close",children:_(Pn,{size:18,strokeWidth:2.5})})]})},vi=({tab:t,theme:e,allowUserThemeControl:r,onThemeModeChange:o,helpPage:a,setHelpPage:s,accountView:n,setAccountView:l})=>{let{toggle:c,partnerPayout:d}=T(),u=d==="USER";if(t==="offers")return ee("div",{className:"relative px-4 pt-4 pb-6",style:{background:`linear-gradient(135deg, ${e.accent} 0%, color-mix(in srgb, ${e.accent} 75%, black) 100%)`,color:e.accentText},children:[_(qr,{toggle:c,theme:e,allowUserThemeControl:r,onThemeModeChange:o,isAccentBackground:!0}),ee("div",{className:"mt-6 px-1",children:[_("div",{className:"text-sm font-medium opacity-90",children:"Available credit"}),_(Tn.Suspense,{fallback:_(S,{theme:e,className:"mt-1 h-9 w-28 rounded-lg",style:{background:"rgba(255,255,255,0.3)"}}),children:_(Sn,{})})]})]});if(t==="account"){if(n!=="transactions"){let p=n==="settings"?"Settings":"Payout Method";return ee("div",{className:"relative px-4 pt-6 pb-2",children:[_(qr,{toggle:c,theme:e,allowUserThemeControl:r,onThemeModeChange:o}),ee("div",{className:"flex items-center gap-2",children:[ee("button",{className:"inline-flex items-center gap-1 rounded-full cursor-pointer border px-2 py-1 text-xs transition hover:bg-white/10",style:{borderColor:e.border,background:e.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.03)"},onClick:()=>{l?.(n==="payout-method"?"settings":"transactions")},children:[_(gi,{size:14})," Back"]}),_("div",{className:"text-lg font-semibold",children:p})]})]})}return ee("div",{className:"relative w-full z-0 px-4 pt-4 pb-12 flex flex-row justify-between items-start",style:{background:`linear-gradient(135deg, ${e.accent} 0%, color-mix(in srgb, ${e.accent} 75%, black) 100%)`,color:e.accentText},children:[ee("div",{className:"flex gap-3 items-center",children:[_("div",{className:"mt-2 text-lg font-semibold flex-1",children:"Account"}),u&&_("button",{className:"mt-2 rounded-full p-1.5 cursor-pointer transition hover:bg-white/15",onClick:()=>l?.("settings"),"aria-label":"Settings",children:_(Nn,{size:20})})]}),_(qr,{toggle:c,theme:e,allowUserThemeControl:r,onThemeModeChange:o,isAccentBackground:!0})]})}return ee("div",{className:"relative px-4 pt-6 pb-2",children:[_(qr,{toggle:c,theme:e,allowUserThemeControl:r,onThemeModeChange:o}),a?ee("div",{className:"flex items-center gap-2",children:[ee("button",{className:"inline-flex items-center gap-1 rounded-full cursor-pointer border px-2 py-1 text-xs",style:{borderColor:e.border,background:e.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.03)"},onClick:()=>s(null),children:[_(gi,{size:14})," Back"]}),_("div",{className:"truncate text-lg font-semibold",children:sr.find(p=>p.id===a)?.title})]}):_("div",{className:"text-lg font-semibold",children:"Help"})]})};import{Suspense as Ii,useCallback as _n,useEffect as Ln,useRef as Un,useState as Yr}from"react";import{Search as yi,X as Cn}from"lucide-react";import{jsx as On}from"react/jsx-runtime";function jo({active:t,onClick:e,children:r,theme:o}){return On("button",{onClick:e,className:"shrink-0 rounded-lg px-3.5 py-1.5 text-xs font-medium transition cursor-pointer",style:{background:t?o.accent:o.isLight?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.06)",color:t?o.accentText:o.text,border:`1px solid ${t?(o.isLight,"rgba(0,0,0,0.15)"):o.border}`},children:r})}function bi(){let{offerUseCases:t}=ye(),{isOpen:e,isFocused:r,isIdle:o,tokenEpoch:a}=T(),s=e?r?o?3e4:1e4:3e4:!1,{data:n}=nt({queryKey:["offerCategories",a],queryFn:()=>t.getOfferCategories(),refetchInterval:s});return{categories:n}}import{jsx as Me,jsxs as Gr}from"react/jsx-runtime";var wi=({theme:t,showSearch:e,setShowSearch:r,searchUI:o,setSearchUI:a,activeCatUI:s,setActiveCatUI:n,searchRef:l})=>{let{categories:c}=bi();return Gr("div",{className:"sticky top-0 z-10 mx-3 mt-3 space-y-3 pb-3",style:{background:t.bg},children:[Gr("div",{className:"flex items-center justify-between",children:[Me("div",{className:"text-base font-semibold",children:"Offers"}),Me("button",{className:"inline-flex h-9 w-9 items-center justify-center rounded-2xl border transition-opacity active:opacity-70 cursor-pointer",style:{borderColor:t.border,background:t.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},onClick:()=>r(d=>!d),"aria-label":e?"Hide search":"Search offers",children:Me(yi,{size:16,className:"opacity-80"})})]}),e&&Gr("div",{className:"flex items-center gap-2 rounded-2xl border px-3 py-2",style:{borderColor:t.border,background:t.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},children:[Me(yi,{size:16,className:"opacity-80"}),Me("input",{ref:l,value:o,onChange:d=>a(d.target.value),placeholder:"Search offers",className:"w-full bg-transparent text-sm outline-none"}),o&&Me("button",{className:"rounded-xl p-1 cursor-pointer",onClick:()=>a(""),"aria-label":"Clear search",children:Me(Cn,{size:16,className:"opacity-70"})})]}),Gr("div",{className:"flex gap-2 overflow-x-auto overscroll-contain fruga-scrollbar pb-1",children:[Me(jo,{theme:t,active:s==="All",onClick:()=>n("All"),children:"All"}),c.map(d=>Me(jo,{theme:t,active:s===d.name,onClick:()=>n(d.name),children:d.name},d.id))]})]})};import Ri from"react";import{jsx as xi}from"react/jsx-runtime";function Ko(t){return t?t.replace(/[^a-zA-Z0-9 ]/g,"").split(" ").filter(Boolean).slice(0,2).map(e=>e[0]?.toUpperCase()).join("").slice(0,2):""}function lr({brand:t,theme:e,className:r}){return xi("div",{className:Ve("flex h-10 w-16 shrink-0 items-center justify-center overflow-hidden rounded-lg text-xs font-semibold",r),style:{color:e.text},"aria-label":`${t.brandName} logo`,title:t.brandName,children:t.logo?xi("img",{src:t.logo,alt:"",className:"h-full w-full object-contain"}):Ko(t.brandName)})}import{jsx as Ie,jsxs as _t}from"react/jsx-runtime";var $r=t=>Number.isInteger(t)?t.toFixed(0):t.toFixed(1),ki=({offer:t,theme:e,onClick:r})=>_t("div",{role:"button",tabIndex:0,onClick:()=>r(t),onKeyDown:o=>o.key==="Enter"&&r(t),className:"flex h-[140px] w-[140px] shrink-0 cursor-pointer flex-col items-center justify-start rounded-2xl p-3 pt-4",style:{background:e.isLight?"#FFFFFF":e.panel,border:e.isLight?void 0:"1px solid rgba(255,255,255,0.08)",boxShadow:e.isLight?"0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.05)":"0 4px 12px rgba(0,0,0,0.25)",scrollSnapAlign:"start"},children:[Ie(lr,{brand:t,theme:e,className:"h-10 w-12 shrink-0"}),Ie("div",{className:"mt-1.5 w-full truncate text-center text-sm font-bold leading-tight",children:t.brandName}),Ie("div",{className:"mt-1 flex shrink-0 justify-center",children:_t("span",{className:"rounded-full px-2.5 py-1 text-center text-xs font-bold",style:{background:`color-mix(in srgb, ${e.accent} ${e.isLight?"15%":"20%"}, transparent)`,color:e.accent},children:[$r(t.cashback),"% cashback"]})})]}),Ti=({offer:t,theme:e,onClick:r})=>Ie("div",{role:"button",tabIndex:0,onClick:()=>r(t),onKeyDown:o=>o.key==="Enter"&&r(t),className:"w-full cursor-pointer rounded-2xl p-4 text-left transition-transform active:scale-[0.98]",style:{background:e.isLight?"#FFFFFF":e.panel,border:e.isLight?void 0:"1px solid rgba(255,255,255,0.08)",boxShadow:e.isLight?"0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.05)":"0 2px 8px rgba(0,0,0,0.25), 0 4px 12px rgba(0,0,0,0.2)"},children:_t("div",{className:"flex items-center gap-3",children:[Ie(lr,{brand:t,theme:e}),Ie("div",{className:"flex-1 min-w-0",children:Ie("div",{className:"text-base font-bold truncate",children:t.brandName})}),_t("div",{className:"shrink-0 flex flex-col items-end",children:[_t("div",{className:"flex items-center justify-end gap-1 text-lg font-bold",style:{color:e.accent},children:[t.cashback>5&&Ie("span",{className:"inline-block text-base leading-none animate-fire","aria-hidden":!0,children:"\u{1F525}"}),$r(t.cashback),"%"]}),Ie("div",{className:"text-[11px] mt-0.5",style:{color:e.muted},children:"Cashback"}),t.endDate&&oi(t.endDate,30)&&_t("div",{className:"mt-2 rounded-full px-2.5 py-1.5 text-xs font-semibold",style:{background:e.isLight?"rgba(245,158,11,0.15)":"rgba(251,191,36,0.2)",color:e.isLight?"#B45309":e.warning,border:`1px solid ${e.isLight?"rgba(245,158,11,0.35)":"rgba(251,191,36,0.35)"}`},children:["Expiring soon \xB7 ",ai(t.endDate)," days"]})]})]})});import{Fragment as An,jsx as B,jsxs as Lt}from"react/jsx-runtime";var Pi=({children:t,color:e})=>B("div",{className:"text-[11px] font-semibold uppercase tracking-wide",style:{color:e},children:t}),En=({theme:t})=>Lt("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[B("div",{className:"mb-3 text-3xl","aria-hidden":!0,children:"\u{1F622}"}),B("div",{className:"text-sm font-semibold",children:"No offers found"}),B("div",{className:"mt-1 text-xs",style:{color:t.muted},children:"Try a different search or filter."})]}),Fn=({theme:t})=>B("div",{className:"flex items-center justify-center py-10",style:{color:t.muted},children:Lt("div",{className:"flex items-center gap-2 text-sm",children:[B("span",{className:"h-4 w-4 animate-spin rounded-full border-2",style:{borderColor:t.isLight?"rgba(0,0,0,0.2)":"rgba(255,255,255,0.2)",borderTopColor:t.isLight?"rgba(0,0,0,0.7)":"rgba(255,255,255,0.7)"}}),"Updating offers\u2026"]})}),Ni=({theme:t,appliedSearch:e,appliedCat:r,featuredOffers:o=[],results:a,handleOfferClick:s,fetchNextPage:n,hasNextPage:l,isFetchingNextPage:c})=>{let d=o.length>0&&r==="All"&&e.trim()==="",u=Ri.useRef(null);return Ri.useEffect(()=>{let p=new IntersectionObserver(g=>{g[0].isIntersecting&&l&&!c&&n?.()},{threshold:.1});return u.current&&p.observe(u.current),()=>p.disconnect()},[l,c,n]),B("div",{className:"relative flex-1 overflow-auto overscroll-contain fruga-scrollbar px-3 pb-24 pt-3",children:Lt("div",{className:"space-y-4",children:[d&&Lt("div",{className:"-mx-3 px-3",children:[Lt("div",{className:"mb-2 flex items-center gap-1.5",children:[B(Pi,{color:t.muted,children:"BEST DEALS"}),B("span",{className:"text-sm",style:{animation:"fire-flicker 1.2s ease-in-out infinite"},"aria-hidden":!0,children:"\u{1F525}"})]}),B("div",{className:"flex gap-3 overflow-x-auto overscroll-contain fruga-scrollbar pb-1",style:{scrollSnapType:"x mandatory"},children:o.map(p=>B(ki,{offer:p,theme:t,onClick:s},`featured-${p.id}`))}),B("div",{className:"mt-3",children:B(Pi,{color:t.muted,children:"All"})})]}),a.length===0?B(En,{theme:t}):Lt(An,{children:[a.map(p=>B(Ti,{offer:p,theme:t,onClick:s},p.id)),B("div",{ref:u,className:"h-4 w-full"}),c&&B(Fn,{theme:t})]})]})})};function Si({category:t,query:e,pageSize:r=10}={}){let{offerUseCases:o}=ye(),{tokenEpoch:a}=T(),s=["offers","list",t||"All",e||"",a],{data:n,fetchNextPage:l,hasNextPage:c,isFetchingNextPage:d}=rr({queryKey:s,queryFn:({pageParam:f=0})=>o.getOffers({pageNumber:f,pageSize:r,categories:t&&t!=="All"?[t]:[],query:e||void 0}),initialPageParam:0,getNextPageParam:f=>{if(f.number+1<f.totalPages)return f.number+1}}),{data:u}=nt({queryKey:["offers","featured",a],queryFn:()=>o.getFeaturedOffers()}),p=_o({mutationFn:f=>o.claimOffer(f)}),g=async f=>p.mutateAsync(f);return{offers:n?.pages.flatMap(f=>f.content)||[],featuredOffers:u,claimOffer:g,fetchNextPage:l,hasNextPage:c,isFetchingNextPage:d}}import{X as In}from"lucide-react";import{jsx as Mn}from"react/jsx-runtime";var Ut=({onClose:t,className:e=""})=>Mn("div",{className:`absolute inset-0 cursor-pointer bg-black/55 transition-opacity animate-in fade-in duration-300 ${e}`,onClick:t,"aria-hidden":"true"});import{jsx as De,jsxs as Bt}from"react/jsx-runtime";var Oi=({theme:t,offer:e,onClose:r})=>Bt("div",{className:"absolute inset-0 z-50 flex items-center justify-center",children:[De(Ut,{onClose:r}),Bt("div",{className:"relative mx-4 w-full max-w-sm rounded-[24px] border p-4 shadow-2xl",style:{borderColor:t.border,background:t.panel,color:t.text},children:[Bt("div",{className:"flex items-start justify-between gap-3",children:[Bt("div",{className:"flex items-center gap-3",children:[De(lr,{brand:e,theme:t}),Bt("div",{children:[De("div",{className:"text-sm font-semibold",children:e.brandName}),Bt("div",{className:"mt-1 inline-flex items-center gap-1 px-0 py-0 text-base font-bold",children:[e.cashback>5?De("span",{className:"inline-block text-sm leading-none animate-fire","aria-hidden":!0,children:"\u{1F525}"}):null,$r(e.cashback),"% cashback"]})]})]}),De("button",{className:"p-2 cursor-pointer",onClick:r,"aria-label":"Close",title:"Close",children:De(In,{size:18,strokeWidth:2.5})})]}),De("div",{className:"mt-4 text-sm",style:{color:t.muted},children:"You will now be redirected to the retailer website to complete your transaction."}),e.terms?De("div",{className:"mt-3 text-[11px] leading-snug",style:{color:t.muted},children:e.terms}):null,De("button",{className:"mt-4 inline-flex h-11 w-full cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold",style:{background:t.accent,color:t.accentText},onClick:()=>{let o=e.link||`https://www.google.com/search?q=${encodeURIComponent(e.brandName+" cashback")}`;window.open(o,"_blank","noopener,noreferrer"),r()},children:"Shop now"})]})]});import{jsx as te,jsxs as zt}from"react/jsx-runtime";var Ci=({theme:t})=>te("div",{className:"space-y-0",children:[1,2,3,4,5].map(e=>zt("div",{className:"flex items-stretch gap-3 px-4 py-3",style:{borderBottom:e<5?`1px solid ${t.border}`:"none"},children:[te(S,{theme:t,className:"h-12 w-16 shrink-0 rounded-lg"}),zt("div",{className:"flex-1 space-y-2",children:[te(S,{theme:t,className:"h-4 w-24"}),te(S,{theme:t,className:"h-3 w-16"})]}),te(S,{theme:t,className:"h-5 w-14 shrink-0"})]},e))}),Ei=({theme:t})=>zt("div",{className:"relative flex-1 overflow-hidden flex flex-col min-h-0 pt-0",children:[zt("div",{className:"px-3 pt-4 mb-4",children:[te(S,{theme:t,className:"h-10 w-full rounded-2xl"}),te("div",{className:"mt-4 flex gap-2 overflow-hidden",children:[1,2,3,4].map(e=>te(S,{theme:t,className:"h-8 w-20 rounded-full shrink-0"},e))})]}),zt("div",{className:"flex-1 px-3 space-y-4 overflow-hidden pt-3",children:[zt("div",{className:"-mx-3 px-3",children:[te("div",{className:"text-[11px] font-semibold uppercase tracking-wide mb-2",style:{color:t.muted},children:"BEST DEALS"}),te("div",{className:"flex gap-2 overflow-hidden",children:[1,2,3].map(e=>te(hi,{theme:t},e))})]}),te("div",{className:"text-[11px] font-semibold uppercase tracking-wide mb-2",style:{color:t.muted},children:"ALL"}),[1,2,3].map(e=>te(mi,{theme:t},e))]})]});import{AlertTriangle as Dn}from"lucide-react";import{jsx as cr,jsxs as Fi}from"react/jsx-runtime";var Ai=({theme:t,onAddPayout:e})=>{let r=t.isLight;return Fi("button",{type:"button",onClick:e,className:"flex w-full items-start gap-3 rounded-2xl border-2 px-4 py-3.5 text-left shadow-lg transition hover:brightness-95 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-offset-2 cursor-pointer",style:{borderColor:`${t.danger}${r?"40":"30"}`,background:t.danger,color:"#FFFFFF",boxShadow:`0 10px 20px -5px ${t.danger}40`},"aria-label":"Payout pending. Add a payout method to receive your money.",children:[cr("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full",style:{background:"rgba(255, 255, 255, 0.2)"},children:cr(Dn,{className:"h-5 w-5",strokeWidth:2.5,"aria-hidden":!0})}),Fi("span",{className:"min-w-0 flex-1",children:[cr("span",{className:"block text-sm font-black leading-snug tracking-tight",children:"Payout pending"}),cr("span",{className:"mt-0.5 block text-[13px] font-semibold leading-tight opacity-90",children:"Add a payout method now so we can send your money."}),cr("span",{className:"mt-2.5 inline-block text-[12px] font-bold underline decoration-2 underline-offset-4 transition-all hover:opacity-80",children:"Add bank details"})]})]})};import{jsx as Mi}from"react/jsx-runtime";var Vr=({theme:t,onAddPayout:e,className:r="relative z-10 mt-3 px-3"})=>{let{wallet:o}=ct();return o?.requiredActions?.some(s=>s.type==="ADD_PAYOUT_METHOD")?Mi("div",{className:r,children:Mi(Ai,{theme:t,onAddPayout:e})}):null};import{Fragment as Hn,jsx as re,jsxs as _i}from"react/jsx-runtime";var Bn=({theme:t})=>re("div",{className:"flex gap-2 overflow-hidden",children:[1,2,3,4].map(e=>re(S,{theme:t,className:"h-8 w-20 rounded-full shrink-0"},e))}),zn=({theme:t,searchUI:e,activeCatUI:r,handleOfferClick:o,onNavigateToPayoutMethod:a})=>{let{offers:s,featuredOffers:n,fetchNextPage:l,hasNextPage:c,isFetchingNextPage:d}=Si({query:e,category:r,pageSize:10});return _i("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[re(Vr,{theme:t,onAddPayout:()=>a?.()}),re(Ni,{theme:t,appliedSearch:e,appliedCat:r,featuredOffers:n,results:s,handleOfferClick:o,fetchNextPage:l,hasNextPage:c,isFetchingNextPage:d})]})},Di=({theme:t,onNavigateToPayoutMethod:e})=>{let[r,o]=Yr(!1),[a,s]=Yr(""),[n,l]=Yr("All"),[c,d]=Yr(null),u=Ja(a,300),p=Un(null);Ln(()=>{if(r){let v=window.setTimeout(()=>p.current?.focus(),0);return()=>window.clearTimeout(v)}},[r]);let g=_n(v=>{d(v)},[]);return _i(Hn,{children:[c&&re(Oi,{theme:t,offer:c,onClose:()=>d(null)}),re(Ii,{fallback:re("div",{className:"px-3",children:re(Bn,{theme:t})}),children:re(wi,{theme:t,showSearch:r,setShowSearch:o,searchUI:a,setSearchUI:s,activeCatUI:n,setActiveCatUI:l,searchRef:p})}),re(Ii,{fallback:re("div",{className:"px-3",children:re(Ei,{theme:t})}),children:re(zn,{theme:t,searchUI:u,activeCatUI:n,handleOfferClick:g,onNavigateToPayoutMethod:e})})]})};import{Suspense as Yo}from"react";function Li(t=10){let{accountUseCases:e}=ye(),{token:r,tokenEpoch:o}=T();return rr({queryKey:["activity",r,o,t],queryFn:({pageParam:a=0})=>e.getActivity(a,t),initialPageParam:0,getNextPageParam:(a,s)=>{if(a.transactions&&a.transactions.length===t)return s.length},staleTime:1/0,refetchOnWindowFocus:!1,refetchOnReconnect:!1})}import{useEffect as Qn,useRef as Wn,useState as jn}from"react";import{Info as Kn}from"lucide-react";import{jsx as qo,jsxs as qn}from"react/jsx-runtime";function Ui({theme:t,label:e}){let[r,o]=jn(!1),a=Wn(null);return Qn(()=>{if(!r)return;let s=n=>{a.current&&(a.current.contains(n.target)||o(!1))};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[r]),qn("span",{ref:a,className:"relative inline-flex items-center",children:[qo("button",{type:"button",className:"ml-1 inline-flex h-4 w-4 items-center justify-center rounded-full","aria-label":"More info",onClick:s=>{s.stopPropagation(),o(n=>!n)},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:qo(Kn,{size:11,className:"opacity-80"})}),qo("span",{className:Ve("pointer-events-none absolute bottom-full left-1/2 z-20 mb-2 w-64 -translate-x-1/2 rounded-xl border px-3 py-2 text-[11px] leading-snug shadow-xl transition",r?"opacity-100":"opacity-0"),style:{background:t.tooltipBg,borderColor:t.tooltipBorder,color:t.text},children:e})]})}import{jsx as _e,jsxs as pe}from"react/jsx-runtime";var Bi=({theme:t,accountDataLoading:e,available:r,pending:o,lifetimeSavings:a})=>_e("div",{className:"relative z-20 px-3 -mt-10",children:pe("div",{className:"rounded-3xl border p-4",style:{borderColor:t.border,background:t.isLight?t.panel:t.panel2,boxShadow:t.isLight?"0 4px 12px rgba(0,0,0,0.08)":"0 4px 12px rgba(0,0,0,0.25)"},children:[pe("div",{className:"flex items-end justify-between gap-4",children:[pe("div",{children:[e?_e(S,{theme:t,className:"h-9 w-24"}):pe("div",{className:"text-3xl font-bold",children:["\xA3",r.toFixed(2)]}),_e("div",{className:"mt-1 text-xs",style:{color:t.muted},children:"Available Credit"})]}),pe("div",{className:"text-right",children:[e?_e(S,{theme:t,className:"mx-auto h-5 w-14"}):pe("div",{className:"text-sm font-semibold",children:["\xA3",o.toFixed(2)]}),pe("div",{className:"mt-1 flex items-center justify-end gap-1 text-[11px]",style:{color:t.muted},children:["Pending",_e(Ui,{theme:t,label:"Waiting for retailer confirmation and processing and will be available soon"})]})]}),pe("div",{className:"text-right",children:[e?_e(S,{theme:t,className:"mx-auto h-5 w-14"}):pe("div",{className:"text-sm font-semibold",children:["\xA3",(r+o).toFixed(2)]}),_e("div",{className:"mt-1 text-[11px]",style:{color:t.muted},children:"Total Balance"})]})]}),pe("div",{className:"mt-3 flex items-center justify-between border-t pt-3",style:{borderColor:t.border},children:[_e("div",{className:"text-[11px] uppercase tracking-wider",style:{color:t.muted},children:"Lifetime Insurance Savings"}),e?_e(S,{theme:t,className:"h-4 w-16"}):pe("div",{className:"text-sm font-semibold",style:{color:t.muted},children:["\xA3",a.toFixed(2)]})]})]})});import{useEffect as Xn,useRef as Jn}from"react";import{useId as Gn}from"react";import{jsx as we,jsxs as Zr}from"react/jsx-runtime";function zi({accent:t,className:e}){let r=Gn().replace(/:/g,""),o=`color-mix(in srgb, ${t} 70%, black)`,a=`color-mix(in srgb, ${t} 45%, black)`;return Zr("svg",{viewBox:"0 0 256 256",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,style:{background:"transparent"},children:[Zr("defs",{children:[Zr("linearGradient",{id:`shieldGrad-${r}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[we("stop",{offset:"0%",stopColor:o}),we("stop",{offset:"100%",stopColor:a})]}),Zr("linearGradient",{id:`glossGrad-${r}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[we("stop",{offset:"0%",stopColor:"white",stopOpacity:"0.35"}),we("stop",{offset:"100%",stopColor:"white",stopOpacity:"0"})]}),we("filter",{id:`shieldDropShadow-${r}`,x:"-10%",y:"-10%",width:"120%",height:"130%",children:we("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodColor:t,floodOpacity:"0.4"})})]}),we("path",{d:"M 40 50 Q 128 30 216 50 C 216 150 160 210 128 236 C 96 210 40 150 40 50 Z",fill:a,filter:`url(#shieldDropShadow-${r})`}),we("path",{d:"M 52 58 Q 128 42 204 58 C 204 144 156 196 128 218 C 100 196 52 144 52 58 Z",fill:`url(#shieldGrad-${r})`,stroke:o,strokeWidth:"3"}),we("path",{d:"M 52 58 Q 128 42 128 42 L 128 218 C 100 196 52 144 52 58 Z",fill:`url(#glossGrad-${r})`}),we("path",{d:"M 60 66 Q 128 52 196 66 Q 128 80 60 66 Z",fill:"white",fillOpacity:"0.1"})]})}import{useId as $n}from"react";import{jsx as xe,jsxs as dr}from"react/jsx-runtime";function Hi({accent:t,className:e}){let r=$n().replace(/:/g,""),o=`color-mix(in srgb, ${t} 70%, black)`,a=`color-mix(in srgb, ${t} 45%, black)`;return dr("svg",{viewBox:"0 0 256 256",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,style:{background:"transparent"},children:[dr("defs",{children:[dr("linearGradient",{id:`giftGrad-${r}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[xe("stop",{offset:"0%",stopColor:o}),xe("stop",{offset:"100%",stopColor:a})]}),xe("filter",{id:`giftDropShadow-${r}`,x:"-20%",y:"-20%",width:"140%",height:"140%",children:xe("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodColor:t,floodOpacity:"0.4"})})]}),dr("g",{filter:`url(#giftDropShadow-${r})`,children:[xe("rect",{x:"36",y:"80",width:"85",height:"36",fill:`url(#giftGrad-${r})`}),xe("rect",{x:"135",y:"80",width:"85",height:"36",fill:`url(#giftGrad-${r})`}),xe("rect",{x:"48",y:"130",width:"73",height:"90",fill:`url(#giftGrad-${r})`}),xe("rect",{x:"135",y:"130",width:"73",height:"90",fill:`url(#giftGrad-${r})`}),dr("g",{stroke:o,strokeWidth:"14",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[xe("path",{d:"M 121 80 C 110 25 55 25 55 55 C 55 75 95 80 121 80 Z"}),xe("path",{d:"M 135 80 C 146 25 201 25 201 55 C 201 75 161 80 135 80 Z"})]})]})]})}import{AlertTriangle as Vn}from"lucide-react";import{jsx as Xr,jsxs as Yn}from"react/jsx-runtime";var Qi=({theme:t,onAddDetails:e})=>{let{setIsAddingPayoutFromAlert:r}=T(),o=t.isLight,a=()=>{r(!0),e()};return Yn("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1.5 rounded-2xl border px-3 py-2.5 text-[11px] leading-tight shadow-sm transition-all",style:{borderColor:`${t.danger}${o?"35":"25"}`,background:o?`${t.danger}08`:`${t.danger}12`,color:t.text},children:[Xr("div",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full",style:{background:`${t.danger}20`},children:Xr(Vn,{className:"h-3.5 w-3.5",strokeWidth:2.5,style:{color:t.danger},"aria-hidden":!0})}),Xr("span",{className:"min-w-0 flex-1 font-semibold opacity-90",children:"Bank details required to send this payout."}),Xr("button",{type:"button",className:"ml-auto shrink-0 cursor-pointer text-[12px] font-extrabold underline decoration-2 underline-offset-2 transition-all hover:opacity-80 active:scale-95",style:{color:t.accent},onClick:a,children:"Add details"})]})};import{Fragment as Go,jsx as A,jsxs as Le}from"react/jsx-runtime";var Zn=({transaction:t,theme:e,isPolicy:r,isPayout:o,isBonus:a})=>A("div",{className:"flex w-16 shrink-0 self-stretch items-center justify-center overflow-hidden rounded-lg text-xs font-semibold",style:{color:e.text},children:r||o?A(zi,{accent:e.accent,className:"h-[40px] w-[40px] object-contain"}):a?A(Hi,{accent:e.accent,className:"h-[40px] w-[40px] object-contain"}):t.brandName&&t.brandLogo?A("img",{src:t.brandLogo,alt:"",className:"h-full w-full object-contain"}):Ko(t.brandName||t.type)}),Wi=({transaction:t,theme:e,isLast:r,requiredActions:o,onAddPayout:a})=>{let{partnerPayout:s}=T(),n=t.brandName==="Policy purchase",l=t.type==="BONUS",c=t.flow==="EARN"&&t.type==="AFFILIATE_LINK"&&t.status==="PAID",d=t.flow==="EARN"&&t.type==="AFFILIATE_LINK"&&["APPROVED","PENDING_PROVIDER","PENDING_BANK","PENDING_RETAILER"].includes(t.status),u=t.status==="PROCESSING",p=t.flow==="PAYOUT"&&t.status==="PAID",g=t.flow==="PAYOUT"&&t.status==="FAILED",v=t.flow==="PAYOUT"&&t.status==="CANCELLED",f=t.flow==="PAYOUT"&&t.status==="ACTION_REQUIRED",y=t.flow==="PAYOUT",R=y||u||g||n||t.activityAmount<0,O=c||d||u||g||v||!n&&!l&&!p&&t.purchaseAmount!=null&&t.purchaseAmount>0,F=t.activityAmount||0,x=t.purchaseAmount||0,C=O&&x&&!y?Math.round(F/x*100):null,D={NEW_POLICY:"New policy purchase",POLICY_ADDON:"Policy add-on purchase",CLAIM_EXCESS:"Claim excess payment",OTHER:"Other"},z=l||t.flow==="EARN"&&!u?e.success:y||n||u?e.text:F>=0?e.success:e.danger,Ye=ii(n?"Policy purchase":l?"Bonus":p||u||g||v||f?D[t.redemptionContext]||"Other":c||d?t.brandName||"Payout":C!=null?`${C}% Cashback`:t.brandName||(t.type==="PAYOUT"?"Payout":"Activity"),40),Y=()=>A(Go,{children:d?A("span",{className:"text-[11px]",style:{color:e.warning},children:"Pending"}):u?A("span",{className:"text-[11px]",style:{color:e.warning},children:"Processing"}):g?A("span",{className:"text-[11px]",style:{color:e.muted},children:"Payout failed"}):v?A("span",{className:"text-[11px]",style:{color:e.muted},children:"Payout cancelled"}):f?A("span",{className:"text-[11px]",style:{color:e.warning},children:"On hold"}):null});return Le("div",{className:"flex items-stretch gap-3 px-4 py-3 flex-col",style:{borderBottom:r?"none":`1px solid ${e.border}`},children:[Le("div",{className:"flex items-stretch gap-3",children:[A(Zn,{transaction:t,theme:e,isPolicy:n,isPayout:p||u||g||v||f,isBonus:l}),A("div",{className:"grid min-w-0 flex-1 grid-cols-[1fr_auto] items-baseline gap-x-4 gap-y-0.5",children:O?Le(Go,{children:[A("div",{className:"min-w-0 text-sm font-semibold truncate",children:Ye}),Le("div",{className:"flex items-center justify-end gap-1.5",children:[A(Y,{}),Le("span",{className:"text-sm font-bold",style:{color:z},children:[R?"-":"+","\xA3",Math.abs(F).toFixed(2)]})]}),A("div",{className:"min-w-0 text-[11px] font-bold",style:{color:e.muted},children:c||d||u?t.offerName:C!=null?`${C}% Cashback`:null}),Le("div",{className:"text-right text-xs",style:{color:e.muted},children:["\xA3",x.toFixed(2)]}),A("div",{className:"text-[11px]",style:{color:e.muted},children:zo(t.occuredAt)}),A("div",{})]}):Le(Go,{children:[A("div",{className:"min-w-0 text-sm font-semibold",style:{color:e.text},children:Ye}),Le("div",{className:"flex items-center justify-end gap-1.5",children:[A(Y,{}),Le("span",{className:"text-sm font-semibold",style:{color:z},children:[R?"-":"+","\xA3",Math.abs(F).toFixed(2)]})]}),A("div",{className:"text-[11px]",style:{color:e.muted},children:zo(t.occuredAt)}),A("div",{})]})})]}),s==="USER"&&(f||o?.some(j=>j.type==="ADD_PAYOUT_METHOD"&&String(j.transactionId)===String(t.id)))&&A("div",{className:"flex gap-3 pl-[4.75rem]",children:A(Qi,{theme:e,onAddDetails:()=>a?.()})})]})};import{Fragment as el,jsx as dt,jsxs as ji}from"react/jsx-runtime";var Ki=({transactions:t,theme:e,fetchNextPage:r,hasNextPage:o,isFetchingNextPage:a,requiredActions:s,onAddPayout:n})=>{let l=Jn(null);return Xn(()=>{if(!o||!r||a)return;let c=new IntersectionObserver(d=>{d[0].isIntersecting&&r()},{rootMargin:"100px"});return l.current&&c.observe(l.current),()=>c.disconnect()},[r,o,a]),dt("div",{className:"relative flex-1 flex flex-col overflow-auto overscroll-contain fruga-scrollbar px-3 pb-24 pt-0",children:t.length===0?ji("div",{className:"flex flex-col items-center justify-center py-12 px-4 text-center",children:[dt("div",{className:"mb-3 text-3xl","aria-hidden":!0,children:"\u{1F6D2}"}),dt("div",{className:"text-sm font-semibold",children:"No transactions yet"}),dt("div",{className:"mt-1 text-xs",style:{color:e.muted},children:"Start shopping through the offers to earn cashback"})]}):ji(el,{children:[t.map((c,d)=>c?dt(Wi,{transaction:c,theme:e,isLast:d===t.length-1,requiredActions:s,onAddPayout:n},c.id):null),dt("div",{ref:l,className:"h-10 flex items-center justify-center -mt-2",children:a&&dt("div",{className:"w-5 h-5 rounded-full animate-spin border-2",style:{borderColor:`${e.muted}40`,borderTopColor:e.text}})})]})})};import{ChevronRight as tl}from"lucide-react";import{jsx as Jr,jsxs as rl}from"react/jsx-runtime";var qi=({theme:t,onNavigateToPayoutMethod:e})=>Jr("div",{className:"pb-24",children:Jr("div",{className:"divide-y",style:{borderColor:t.border},children:rl("button",{type:"button",className:"flex w-full cursor-pointer items-center justify-between gap-4 py-4 text-left transition hover:opacity-80",onClick:e,children:[Jr("span",{className:"text-sm font-semibold",children:"Payout method"}),Jr(tl,{size:18,className:"shrink-0",style:{color:t.text},"aria-hidden":!0})]})})});import{useState as es}from"react";import{useState as eo,useEffect as ol}from"react";var Gi=t=>{let e=Ee(),{token:r}=T(),[o,a]=eo(null),[s,n]=eo(!0),[l,c]=eo("idle"),[d,u]=eo(null),p=async()=>{n(!0),u(null);try{let f=await t.getMethod();a(f)}catch(f){u(f)}finally{n(!1)}};return ol(()=>{p()},[]),{paymentMethod:o,loading:s,flow:l,setFlow:c,error:d,setError:u,addMethod:async f=>{n(!0),u(null);try{let y=await t.addMethod(f);a(y),c("success"),e.invalidateQueries({queryKey:["wallet",r]})}catch(y){u(y)}finally{n(!1)}},removeMethod:async()=>{if(o){n(!0),u(null);try{await t.removeMethod(o.id),a(null),c("idle"),e.invalidateQueries({queryKey:["wallet",r]})}catch(f){throw u(f),f}finally{n(!1)}}}}};import{Landmark as al,Trash2 as il}from"lucide-react";import{jsx as to,jsxs as $i}from"react/jsx-runtime";var Vi=({theme:t,paymentMethod:e,onRemove:r})=>$i("div",{className:"flex items-center gap-3 py-2",children:[to("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-full border",style:{borderColor:t.border,background:t.isLight?"rgba(0,0,0,0.03)":"rgba(255,255,255,0.04)"},"aria-hidden":!0,children:to(al,{size:22,strokeWidth:2,style:{color:t.text}})}),$i("div",{className:"min-w-0 flex-1 text-sm font-semibold",children:["Bank account ending ",e.bank.accountLast4]}),to("button",{type:"button",className:"inline-flex h-10 w-10 cursor-pointer shrink-0 items-center justify-center rounded-xl transition hover:opacity-80",style:{color:t.muted},onClick:r,"aria-label":"Remove payout method",title:"Remove payout method",children:to(il,{size:20,strokeWidth:2})})]});import{useMemo as sl,useState as $o}from"react";import{jsx as pt,jsxs as ro}from"react/jsx-runtime";var Yi=({theme:t,onSubmit:e,isSubmitting:r})=>{let[o,a]=$o(""),[s,n]=$o(""),[l,c]=$o(""),d=sl(()=>{let u=o.trim(),p=s.replace(/\s/g,""),g=l.replace(/[^0-9]/g,"");return u.length>0&&p.length>=6&&p.length<=10&&g.length===6},[o,s,l]);return ro("form",{className:"space-y-4 pt-1",onSubmit:u=>{u.preventDefault(),!(!d||r)&&e({accountHolderName:o,accountNumber:s,sortCode:l})},children:[ro("label",{className:"grid gap-1.5",children:[pt("span",{className:"text-xs font-medium",style:{color:t.muted},children:"Account name"}),pt("input",{value:o,onChange:u=>a(u.target.value.replace(/[^a-zA-Z\s\-']/g,"")),autoComplete:"name",className:"h-11 rounded-2xl border bg-transparent px-3 text-sm outline-none",style:{borderColor:t.border,color:t.text},placeholder:"Account holder name"})]}),ro("label",{className:"grid gap-1.5",children:[pt("span",{className:"text-xs font-medium",style:{color:t.muted},children:"Account number"}),pt("input",{value:s,onChange:u=>n(u.target.value.replace(/[^\d\s]/g,"")),inputMode:"numeric",autoComplete:"off",className:"h-11 rounded-2xl border bg-transparent px-3 text-sm outline-none",style:{borderColor:t.border,color:t.text},placeholder:"e.g. 12345678",maxLength:10})]}),ro("label",{className:"grid gap-1.5",children:[pt("span",{className:"text-xs font-medium",style:{color:t.muted},children:"Sort code"}),pt("input",{value:l,onChange:u=>{let p=u.target.value.replace(/\D/g,"").slice(0,6),g=p.length<=2?p:p.length<=4?`${p.slice(0,2)}-${p.slice(2)}`:`${p.slice(0,2)}-${p.slice(2,4)}-${p.slice(4)}`;c(g)},inputMode:"numeric",autoComplete:"off",className:"h-11 rounded-2xl border bg-transparent px-3 text-sm outline-none",style:{borderColor:t.border,color:t.text},placeholder:"12-34-56",maxLength:8})]}),pt("button",{type:"submit",disabled:!d||r,className:"mt-2 inline-flex h-11 w-full cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold disabled:cursor-not-allowed disabled:opacity-45",style:{background:t.accent,color:t.accentText},children:r?"Saving...":"Save bank details"})]})};import{CheckCircle2 as nl}from"lucide-react";import{jsx as oo,jsxs as ll}from"react/jsx-runtime";var Zi=({theme:t,onDone:e})=>ll("div",{className:"flex flex-col items-center px-2 py-6 text-center",children:[oo(nl,{className:"h-14 w-14 shrink-0",style:{color:t.success},strokeWidth:2,"aria-hidden":!0}),oo("div",{className:"mt-4 text-base font-semibold",children:"Bank account added"}),oo("div",{className:"mt-2 max-w-xs text-sm leading-relaxed",style:{color:t.muted},children:"Your bank details have been saved. We will use this account for payouts."}),oo("button",{type:"button",className:"mt-8 inline-flex h-11 w-full max-w-xs cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold",style:{background:t.accent,color:t.accentText},onClick:e,children:"Done"})]});import{jsx as pr,jsxs as ao}from"react/jsx-runtime";var Xi=({theme:t,isOpen:e,onClose:r,onConfirm:o,isRemoving:a=!1})=>e?ao("div",{className:"absolute inset-0 z-50 flex items-center justify-center p-4",children:[pr(Ut,{onClose:r}),ao("div",{className:"relative w-full max-w-[320px] overflow-hidden rounded-[32px] border p-6 shadow-2xl animate-in zoom-in-95 fade-in duration-300",style:{borderColor:t.border,background:t.panel,color:t.text},children:[ao("div",{className:"text-center pt-2",children:[pr("h3",{className:"text-[19px] font-bold tracking-tight",children:"Remove payout method"}),pr("p",{className:"mt-3 px-2 text-[15px] leading-snug opacity-70",style:{color:t.muted},children:"Are you sure you want to remove this payout method?"})]}),ao("div",{className:"mt-8 flex gap-3",children:[pr("button",{type:"button",className:"flex-1 rounded-[20px] border py-3 text-[15px] font-bold transition hover:bg-black/5 dark:hover:bg-white/5 cursor-pointer",style:{borderColor:t.border,color:t.text},onClick:r,children:"Cancel"}),pr("button",{type:"button",disabled:a,className:"flex-1 rounded-[20px] py-3 text-[15px] font-bold transition hover:opacity-90 disabled:opacity-50 cursor-pointer shadow-lg",style:{background:t.accent,color:t.accentText,boxShadow:`0 10px 15px -3px ${t.accent}33`},onClick:o,children:a?"Removing...":"Delete"})]})]})]}):null;import{AlertCircle as cl}from"lucide-react";import{jsx as ut,jsxs as Vo}from"react/jsx-runtime";var Ji=({theme:t,isOpen:e,onClose:r,title:o,message:a,confirmLabel:s="Got it"})=>e?Vo("div",{className:"absolute inset-0 z-[100] flex items-center justify-center p-4",children:[ut(Ut,{onClose:r}),Vo("div",{className:"relative w-full max-w-[320px] overflow-hidden rounded-[32px] border p-6 shadow-2xl animate-in zoom-in-95 fade-in duration-300",style:{borderColor:t.border,background:t.panel,color:t.text},children:[Vo("div",{className:"flex flex-col items-center text-center",children:[ut("div",{className:"flex h-12 w-12 items-center justify-center rounded-full mb-4",style:{background:`${t.isLight?"rgba(220, 38, 38, 0.1)":"rgba(220, 38, 38, 0.2)"}`},children:ut(cl,{className:"h-6 w-6 text-red-600"})}),ut("h3",{className:"text-[19px] font-bold tracking-tight",children:o}),ut("p",{className:"mt-2 text-[14px] leading-relaxed opacity-70",style:{color:t.muted},children:a})]}),ut("div",{className:"mt-8",children:ut("button",{type:"button",className:"w-full rounded-[20px] py-3 text-[15px] font-bold text-white transition hover:opacity-90 cursor-pointer shadow-lg",style:{background:t.accent,color:t.accentText,boxShadow:`0 10px 15px -3px ${t.accent}33`},onClick:r,children:s})})]})]}):null;import{Fragment as dl,jsx as ke,jsxs as rs}from"react/jsx-runtime";var ts=t=>typeof t=="object"&&t!==null,os=({theme:t,service:e,onDone:r})=>{let{paymentMethod:o,loading:a,flow:s,setFlow:n,addMethod:l,removeMethod:c,error:d,setError:u}=Gi(e),[p,g]=es(!1),[v,f]=es(!1),y=async()=>{f(!0);try{await c(),g(!1)}catch{g(!1)}finally{f(!1)}};return a&&s==="idle"?ke("div",{className:"py-8 text-center",children:ke("div",{className:"text-sm animate-pulse",style:{color:t.muted},children:"Loading payment details..."})}):s==="success"?ke(Zi,{theme:t,onDone:()=>{n("idle"),r?.()}}):o&&s==="idle"?rs(dl,{children:[ke(Vi,{theme:t,paymentMethod:o,onRemove:()=>g(!0)}),ke("button",{type:"button",className:"mt-8 inline-flex h-11 w-full max-w-xs cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold mx-auto",style:{background:t.accent,color:t.accentText},onClick:r,children:"Done"}),ke(Xi,{theme:t,isOpen:p,onClose:()=>g(!1),onConfirm:y,isRemoving:v}),ke(Ji,{theme:t,isOpen:!!d,onClose:()=>u(null),title:typeof d=="string"?"Error":ts(d)&&d.error||"Notice",message:typeof d=="string"?d:ts(d)&&d.message||"An unexpected error occurred. Please try again."})]}):s==="form"?ke(Yi,{theme:t,onSubmit:l,isSubmitting:a}):rs("div",{className:"py-8 text-center",children:[ke("p",{className:"text-sm leading-relaxed",style:{color:t.muted},children:"Add a UK bank account so we can pay your savings when redeemed."}),ke("button",{type:"button",className:"mt-4 inline-flex h-11 w-full max-w-xs cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold",style:{background:t.accent,color:t.accentText},onClick:()=>n("form"),children:"Add payout method"})]})};import{jsx as L,jsxs as as}from"react/jsx-runtime";var pl=({theme:t})=>{let{wallet:e}=ct(),r=e?.available||0,o=e?.pending||0,a=e?.lifetimeEarned||0;return L(Bi,{theme:t,accountDataLoading:!1,available:r,pending:o,lifetimeSavings:a})},ul=({theme:t,onAddPayout:e})=>{let{wallet:r}=ct(),{data:o,fetchNextPage:a,hasNextPage:s,isFetchingNextPage:n}=Li(10),l=o?.pages.flatMap(c=>c.transactions||[]).filter(Boolean)||[];return L(Ki,{transactions:l,theme:t,fetchNextPage:a,hasNextPage:s,isFetchingNextPage:n,requiredActions:r?.requiredActions,onAddPayout:e})},is=({theme:t,accountView:e="transactions",setAccountView:r})=>{let{paymentService:o}=ye(),{partnerPayout:a,isAddingPayoutFromAlert:s,setShowPayoutSuccess:n,setIsAddingPayoutFromAlert:l}=T(),c=a==="USER"?e:"transactions";if(c==="settings")return L("div",{className:"relative flex-1 flex flex-col min-h-0 px-3 mt-4",children:L(qi,{theme:t,onNavigateToPayoutMethod:()=>r?.("payout-method")})});let d=()=>{s&&(n(!0),l(!1)),r?.("transactions")};return c==="payout-method"?L("div",{className:"relative flex-1 flex flex-col min-h-0 px-3 mt-4",children:L(os,{theme:t,service:o,onDone:d})}):as("div",{className:"relative flex-1 flex flex-col min-h-0",children:[L(Yo,{fallback:L("div",{className:"px-3 -mt-10",children:L("div",{className:"h-32 w-full animate-pulse rounded-3xl bg-gray-100/10"})}),children:L(pl,{theme:t})}),a==="USER"&&L(Yo,{fallback:L(fi,{theme:t}),children:L(Vr,{theme:t,onAddPayout:()=>r?.("payout-method")})}),as("div",{className:"relative z-20 pt-0 flex-1 flex flex-col min-h-0 overflow-hidden",children:[L("div",{className:"mt-10 px-3 pb-2 flex-shrink-0",children:L("div",{className:"mb-3 text-base font-semibold",children:"Transactions"})}),L("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:L(Yo,{fallback:L("div",{className:"px-3",children:L(Ci,{theme:t})}),children:L(ul,{theme:t,onAddPayout:()=>r?.("payout-method")})})})]})]})};import{Search as ml,X as hl,ChevronRight as fl}from"lucide-react";import{jsx as V,jsxs as io}from"react/jsx-runtime";var ss=({theme:t,helpPage:e,setHelpPage:r,helpSearch:o,setHelpSearch:a})=>V("div",{className:"relative h-full",children:e?V("div",{className:"h-full",children:V("div",{className:"px-3 pb-24 pt-3 text-sm",children:sr.find(s=>s.id===e)?.body(t)})}):io("div",{children:[io("div",{className:"mb-4 flex items-center gap-2 rounded-2xl border px-3 py-2",style:{borderColor:t.border,background:t.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},children:[V(ml,{size:16,className:"shrink-0 opacity-80"}),V("input",{value:o,onChange:s=>a(s.target.value),placeholder:"Search help",className:"w-full bg-transparent text-sm outline-none"}),o?V("button",{className:"shrink-0 rounded-xl p-1 cursor-pointer",onClick:()=>a(""),"aria-label":"Clear search",title:"Clear search",children:V(hl,{size:16,className:"opacity-70"})}):null]}),V("div",{className:"pb-4",children:V("div",{className:"text-sm",style:{color:t.muted},children:"Learn more about cashback and how to use your credit"})}),V("div",{className:"divide-y divide-[#e5e7eb]",children:(()=>{let s=sr.filter(n=>!o.trim()||n.title.toLowerCase().includes(o.trim().toLowerCase()));return s.length===0?V("div",{className:"py-8 text-center text-sm",style:{color:t.muted},children:"No help topics match your search"}):s.map(n=>{let l=n.id==="how-it-works"||n.id==="redeem";return io("button",{className:"flex w-full items-center justify-between gap-4 py-4 text-left cursor-pointer",onClick:()=>r(n.id),children:[io("div",{className:"min-w-0 flex-1",children:[V("div",{className:"text-sm font-semibold",children:n.title}),l?V("div",{className:"mt-0.5 text-xs leading-relaxed",style:{color:t.muted},children:"Quick explainer \u2192"}):null]}),V(fl,{size:18,className:"shrink-0",style:{color:t.text},"aria-hidden":!0})]},n.id)})})()})]})});import{jsx as Te,jsxs as ns}from"react/jsx-runtime";function ls({theme:t,onboardingOpen:e,onboardingStep:r,setOnboardingStep:o,finishOnboarding:a,allowUserThemeControl:s,onThemeModeChange:n}){let[l,c]=so("offers"),[d,u]=so("transactions"),[p,g]=so(null),[v,f]=so("");return e?Te("div",{className:"relative flex h-full w-full min-w-0 flex-col overflow-hidden",style:{background:t.bg,color:t.text},children:Te(ci,{theme:t,onboardingStep:r,setOnboardingStep:o,onFinish:a})}):ns("div",{className:"relative flex h-full w-full min-w-0 flex-col overflow-hidden",style:{background:t.bg,color:t.text},children:[Te(vi,{tab:l,theme:t,allowUserThemeControl:s,onThemeModeChange:n,helpPage:p,setHelpPage:g,accountView:d,setAccountView:u}),ns("div",{className:Ve("relative flex-1 flex flex-col min-h-0","pt-0"),children:[l==="offers"&&Te(Di,{theme:t,onNavigateToPayoutMethod:()=>{c("account"),u("payout-method")}}),l==="account"&&Te(is,{theme:t,accountView:d,setAccountView:u}),l==="help"&&Te("div",{className:"relative flex-1 min-h-0 overflow-auto overscroll-contain fruga-scrollbar px-3",children:Te(ss,{theme:t,helpPage:p,setHelpPage:g,helpSearch:v,setHelpSearch:f})})]}),Te("div",{className:"absolute inset-x-0 bottom-0 pt-10 pb-3 z-30 pointer-events-none",style:{background:`linear-gradient(to top, ${t.bg} 40%, transparent)`},children:Te("div",{className:"pointer-events-auto",children:Te(di,{theme:t,activeTab:l,onTabChange:c,onHelpPageReset:()=>g(null)})})})]})}import{useState as gl}from"react";var cs=t=>{let[e,r]=gl(t);return be("FRUGA_HOST_RESIZE",o=>{r({isMobile:o.isHostMobile,hostHeight:o.hostHeight,hostWidth:o.hostWidth})}),be("FRUGA_INIT",o=>{r(a=>({...a,isMobile:o.host.isMobile,hostHeight:o.host.height,hostWidth:o.host.width}))}),e};import{jsx as no}from"react/jsx-runtime";var xl=ds(function({theme:e,onThemeModeChange:r,isHostMobile:o,hostHeight:a,hostWidth:s},n){let[l,c]=ur(!1),[d,u]=ur(!1),[p,g]=ur(!1),[v,f]=ur(0),[y,R]=ur(!1),{isMobile:O,hostHeight:F}=cs({isMobile:o??(typeof window<"u"?window.innerWidth<768:!1),hostHeight:a??(typeof window<"u"?window.innerHeight:800),hostWidth:s??(typeof window<"u"?window.innerWidth:800)}),x=e.allowUserThemeControl?e:{...e,mode:e.defaultTheme},C=At(x),D=wl(null);D.current=()=>{c(!0),R(!1),d||(u(!0),f(0),g(!0))},yl(n,()=>({open:()=>D.current?.()}),[]);let z=l&&!y;return bl(()=>{if(!O||!z)return;let Ye=document.documentElement.style.overflowX,Y=document.body.style.overflowX;return document.documentElement.style.overflowX="hidden",document.body.style.overflowX="hidden",()=>{document.documentElement.style.overflowX=Ye,document.body.style.overflowX=Y}},[O,z]),no("div",{className:"h-full w-full overflow-hidden min-w-0",style:{background:C.bg},children:no(ls,{theme:C,onboardingOpen:p,onboardingStep:v,setOnboardingStep:f,finishOnboarding:()=>g(!1),allowUserThemeControl:e.allowUserThemeControl,onThemeModeChange:r,hostHeight:F,isHostMobile:O})})}),kl=ds(function(e,r){return no(li,{baseUrl:e.baseUrl,children:no(xl,{...e,ref:r})})}),ps=kl;import{Component as Tl}from"react";import{jsx as us,jsxs as Pl}from"react/jsx-runtime";var Rl=8e3,lo=class extends Tl{constructor(){super(...arguments);H(this,"state",{error:null,unauthorizedTimedOut:!1});H(this,"fallbackTimer",null);H(this,"handleRetry",()=>{this.reset()})}static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r){r instanceof Ae&&(this.props.onUnauthorized(),this.clearFallbackTimer(),this.fallbackTimer=setTimeout(()=>{this.setState({unauthorizedTimedOut:!0})},Rl))}componentDidUpdate(r){let o=r.resetKeys.length!==this.props.resetKeys.length||r.resetKeys.some((a,s)=>a!==this.props.resetKeys[s]);this.state.error&&o&&this.reset()}componentWillUnmount(){this.clearFallbackTimer()}clearFallbackTimer(){this.fallbackTimer!==null&&(clearTimeout(this.fallbackTimer),this.fallbackTimer=null)}reset(){this.clearFallbackTimer(),this.props.onReset(),this.setState({error:null,unauthorizedTimedOut:!1})}render(){let{error:r,unauthorizedTimedOut:o}=this.state;return r?r instanceof Ae&&!o?null:Pl("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[us("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Something went wrong."}),us("button",{type:"button",onClick:this.handleRetry,className:"rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700",children:"Retry"})]}):this.props.children}};import{jsx as ms,jsxs as Nl}from"react/jsx-runtime";var hs=({theme:t})=>Nl("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4 px-6 text-center",style:{background:t.bg,color:t.text},children:[ms("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:t.border,borderTopColor:"transparent"},"aria-hidden":"true"}),ms("p",{className:"text-sm font-medium",style:{color:t.muted},children:"Connecting your account\u2026"})]});import{jsx as hr}from"react/jsx-runtime";var fs=new Ao({defaultOptions:{queries:{retry:(t,e)=>!(e instanceof Ae)&&t<1}}}),Cl="1E40AF",co=t=>{let{bootstrapConfig:e,isHostMobile:r,hostHeight:o}=t,a=lt(),{mode:s,setMode:n,token:l,setToken:c,setPartnerPayout:d,authStatus:u}=T(),p=t.theme??e?.config.ui.defaultTheme??"dark";mr(()=>{d(e?.partnerPayout)},[e?.partnerPayout,d]),mr(()=>{p&&n(p)},[p,n]),mr(()=>{t.token&&c(t.token)},[t.token,c]),mr(()=>{e&&fs.setQueryData(["bootstrapConfig"],e)},[e]),mr(()=>{let x=e?.auth?.tokenTtlSeconds;if(!x||x<=0)return;let D=(x-60)*1e3,z=Math.max(1e3,D),Ye=setTimeout(()=>{a.send({type:"NEED_TOKEN",version:"1.0",reason:"ttl"})},z);return()=>clearTimeout(Ye)},[e?.auth?.tokenTtlSeconds,l,a]);let{reset:g}=tr(),v=Ol(void 0),f=Sl(()=>{v.current!==l&&(v.current=l,a.send({type:"NEED_TOKEN",version:"1.0",reason:"unauthorized"}))},[l,a]),y=t.primaryColor??e?.config.ui.accent??Cl,R={...ne,defaultTheme:p,mode:s,primary:y,accent:y,accentTextLight:e?.config.ui.accentTextLight??ne.accentTextLight,accentTextDark:e?.config.ui.accentTextDark??ne.accentTextDark,allowUserThemeControl:e?.config.ui.allowUserThemeControl??ne.allowUserThemeControl,launcherIcon:e?.config.ui.launcherIcon??ne.launcherIcon,showLauncher:e?.config.ui.showLauncher??ne.showLauncher,launcherLabel:e?.config.ui.launcherLabel??ne.launcherLabel},O=x=>{n(x)},F=u==="pending"&&!ti();return hr(Io,{client:fs,children:hr(Xa,{theme:R,isMobile:r,hostHeight:o,children:hr(lo,{resetKeys:[l],onReset:g,onUnauthorized:f,children:F?hr(hs,{theme:At(R)}):hr(ps,{theme:R,baseUrl:t.baseUrl,isHostMobile:r,hostHeight:o,hostWidth:t.hostWidth,onThemeModeChange:O})})})})};import{useEffect as bs,useState as ys}from"react";var gs="1.3.0";var vs=gs;import{jsx as Zo}from"react/jsx-runtime";var Fl=({partnerKey:t})=>{let e=lt(),[r,o]=ys(null);return bs(()=>{e.send({type:"FRUGA_READY",version:"1.0",protocolVersion:"1.0",widgetVersion:vs})},[e]),be("FRUGA_INIT",a=>{T.getState().setToken(a.token??null),a.overrides?.panelOpen&&T.getState().setOpen(!0),o({token:a.token,bootstrap:a.bootstrap,apiBaseUrl:a.apiBaseUrl,host:a.host,overrides:a.overrides})}),r?Zo(co,{partnerKey:t,token:r.token,baseUrl:r.apiBaseUrl,bootstrapConfig:r.bootstrap,isHostMobile:r.host.isMobile,hostHeight:r.host.height,hostWidth:r.host.width,theme:r.overrides?.theme,primaryColor:r.overrides?.primaryColor,userId:r.overrides?.userId}):null},ws=({partnerKey:t})=>{let[e,r]=ys(null);return bs(()=>{let o=Dr();return r(o),()=>o.dispose()},[]),e?Zo(Ur,{transport:e,children:Zo(Fl,{partnerKey:t})}):null};import{jsx as Xo}from"react/jsx-runtime";var Al=t=>{let e=document.getElementById(t.containerId);if(e||(console.warn(`FrugaRelay: Container #${t.containerId} not found. Creating a default container.`),e=document.createElement("div"),e.id=t.containerId,document.body.appendChild(e)),e.getAttribute("data-fruga-relay-mounted")==="true"){console.info(`FrugaRelay: SDK already mounted in container #${t.containerId}.`);return}let r=Dr();xs.createRoot(e).render(Xo(Ur,{transport:r,children:Xo(co,{...t})})),e.setAttribute("data-fruga-relay-mounted","true")},Ml={init:Al};if(typeof window<"u"){let e=new URLSearchParams(window.location.search).get("partnerKey");if(e){let r=document.getElementById("root");r||(r=document.createElement("div"),r.id="root",document.body.appendChild(r)),xs.createRoot(r).render(Xo(ws,{partnerKey:e}))}}var l0=Ml;export{l0 as default,Al as init};
|
|
2
2
|
//# sourceMappingURL=relay.mjs.map
|