@fruga/sdk 1.0.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/LICENSE +15 -0
- package/README.md +118 -0
- package/connect/package.json +6 -0
- package/core/package.json +6 -0
- package/dist/connect.d.mts +73 -0
- package/dist/connect.d.ts +73 -0
- package/dist/connect.js +26 -0
- package/dist/connect.mjs +26 -0
- package/dist/core/package.json +5 -0
- package/dist/index.d.mts +398 -0
- package/dist/index.d.ts +398 -0
- package/dist/index.js +783 -0
- package/dist/index.mjs +725 -0
- package/dist/loader/package.json +17 -0
- package/dist/loader-react.d.mts +127 -0
- package/dist/loader-react.d.ts +127 -0
- package/dist/loader-react.js +26 -0
- package/dist/loader-react.mjs +26 -0
- package/dist/loader.d.mts +24 -0
- package/dist/loader.d.ts +24 -0
- package/dist/loader.js +2 -0
- package/dist/loader.mjs +2 -0
- package/dist/relay.css +3 -0
- package/dist/relay.d.mts +61 -0
- package/dist/relay.d.ts +61 -0
- package/dist/relay.js +2 -0
- package/dist/relay.mjs +2 -0
- package/loader/package.json +6 -0
- package/package.json +89 -0
- package/relay/package.json +6 -0
package/dist/relay.mjs
ADDED
|
@@ -0,0 +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),h=(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){h(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);h(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),h(this,Ee,void 0))}setEventListener(e){var r;h(this,st,e),(r=i(this,Ee))==null||r.call(this),h(this,Ee,e(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus()}))}setFocused(e){i(this,$e)!==e&&(h(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){h(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],m=e[u];if(g===m){c[u]=g,(o?p<s:ns.call(t,u))&&d++;continue}if(g===null||m===null||typeof g!="object"||typeof m!="object"){c[u]=m;continue}let v=ao(g,m,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);h(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),h(this,Me,void 0))}setEventListener(e){var r;h(this,ut,e),(r=i(this,Me))==null||r.call(this),h(this,Me,e(this.setOnline.bind(this)))}setOnline(e){i(this,pt)!==e&&(h(this,pt,e),this.listeners.forEach(o=>{o(e)}))}isOnline(){return i(this,pt)}},pt=new WeakMap,Me=new WeakMap,ut=new WeakMap,ta),ht=new cs;function ds(t){return Math.min(1e3*2**t,3e4)}function io(t){return(t??"online")==="online"?ht.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"||ht.isOnline())&&t.canRun(),p=()=>io(t.networkMode)&&t.canRun(),u=w=>{s()||(o?.(),a.resolve(w))},g=w=>{s()||(o?.(),a.reject(w))},m=()=>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:m()).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():m().then(v),a)}}var Ke,ra,ur=(ra=class{constructor(){f(this,Ke)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Lt(this.gcTime)&&h(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)),h(this,Ke,void 0))}},Ke=new WeakMap,ra);var Ge,mt,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,mt);f(this,ee);f(this,Ve);f(this,L);f(this,zt);f(this,Ye);h(this,Ye,!1),h(this,zt,e.defaultOptions),this.setOptions(e.options),this.observers=[],h(this,Ve,e.client),h(this,ee,i(this,Ve).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,h(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)),h(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:()=>(h(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 h(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),h(this,mt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==l.fetchOptions?.meta)&&y(this,q,be).call(this,{type:"fetch",meta:l.fetchOptions?.meta}),h(this,L,pr({initialPromise:r?.initialPromise,fn:l.fetchFn,onCancel:c=>{c instanceof dr&&c.revert&&this.setState({...i(this,mt),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,mt=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 h(this,mt,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,ho,mo,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,h(this,H,e),h(this,De,null),h(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,ho).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,mo).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)&&(h(this,z,o),h(this,ft,this.options),h(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,m;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;m=u.data;let P=!1;if(r.placeholderData!==void 0&&m===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",m=_t(s?.data,J,r),g=!0)}if(r.select&&m!==void 0&&!P)if(s&&m===n?.data&&r.select===i(this,Wt))m=i(this,gt);else try{h(this,Wt,r.select),m=r.select(m),m=_t(s?.data,m,r),h(this,gt,m),h(this,De,null)}catch(J){h(this,De,J)}i(this,De)&&(v=i(this,De),m=i(this,gt),w=Date.now(),k="error");let S=u.fetchStatus==="fetching",O=k==="pending",Y=k==="error",Z=O&&S,Fe=m!==void 0,re={status:k,fetchStatus:u.fetchStatus,isPending:O,isSuccess:k==="success",isError:Y,isInitialLoading:Z,isLoading:Z,data:m,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=h(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(h(this,Ze,i(this,x).state),h(this,ft,this.options),i(this,Ze).data!==void 0&&h(this,vt,i(this,x)),lt(r,e))return;h(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,mo).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;h(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,ho).call(this),h(this,Le,e),!(ce.isServer()||Q(this.options.enabled,i(this,x))===!1||!Lt(i(this,Le))||i(this,Le)===0)&&h(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)),h(this,Je,void 0))},ho=function(){i(this,Xe)&&(ne.clearInterval(i(this,Xe)),h(this,Xe,void 0))},mo=function(){let e=i(this,H).getQueryCache().build(i(this,H),this.options);if(e===i(this,x))return;let r=i(this,x);h(this,x,e),h(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),m=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 m(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 m(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 ha(t,e){return e?vo(t,e)!=null:!1}function ma(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:ha(e,r.data),hasPreviousPage:ma(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);h(this,$t,e.client),this.mutationId=e.mutationId,h(this,_,e.mutationCache),h(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){h(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};h(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,h(this,we,new Set),h(this,ae,new Map),h(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=hr(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=hr(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=hr(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=hr(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 hr(t){return t.options.scope?.id}var xe,_e,W,ke,Pe,mr,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);h(this,xe,e),this.setOptions(r),this.bindMethods(),y(this,Pe,mr).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,mr).call(this),y(this,Pe,wo).call(this,e)}getCurrentResult(){return i(this,_e)}reset(){i(this,W)?.removeObserver(this),h(this,W,void 0),y(this,Pe,mr).call(this),y(this,Pe,wo).call(this)}mutate(e,r){return h(this,ke,r),i(this,W)?.removeObserver(this),h(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,mr=function(){let e=i(this,W)?.state??yo();h(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,h(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);h(this,I,t.queryCache||new xa),h(this,Ue,t.mutationCache||new ba),h(this,ze,t.defaultOptions||{}),h(this,wt,new Map),h(this,xt,new Map),h(this,Qe,0)}mount(){Dt(this,Qe)._++,i(this,Qe)===1&&(h(this,kt,nt.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,I).onFocus())})),h(this,Pt,ht.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),h(this,kt,void 0),(e=i(this,Pt))==null||e.call(this),h(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 ht.isOnline()?i(this,Ue).resumePausedMutations():Promise.resolve()}getQueryCache(){return i(this,I)}getMutationCache(){return i(this,Ue)}getDefaultOptions(){return i(this,ze)}setDefaultOptions(t){h(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 hs}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]),hs(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 ms(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var fs=Kt.createContext(ms()),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 m=u?d.subscribe(T.batchCalls(g)):E;return d.updateResult(),m},[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(m=>m(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"},m=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:m.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:m.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:m.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:m.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:m.accent,color:m.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:m})})]}):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 m=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}/${m}/${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 he(){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}=he(),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}=he(),{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 hi 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 mi=({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=hi.useRef(null);return hi.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(mi,{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(mi,{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}=he(),a=["offers","list",t||"All",e||""],{data:s,fetchNextPage:n,hasNextPage:l,isFetchingNextPage:c}=Gt({queryKey:a,queryFn:({pageParam:m=0})=>o.getOffers({pageNumber:m,pageSize:r,categories:t&&t!=="All"?[t]:[],query:e||void 0}),initialPageParam:0,getNextPageParam:m=>{if(m.number+1<m.totalPages)return m.number+1}}),{data:d}=tt({queryKey:["offers","featured"],queryFn:()=>o.getFeaturedOffers()}),p=So({mutationFn:m=>o.claimOffer(m)}),u=async m=>p.mutateAsync(m);return{offers:s?.pages.flatMap(m=>m.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 m=window.setTimeout(()=>u.current?.focus(),0);return()=>window.clearTimeout(m)}},[r]);let g=nn(m=>{d(m)},[]);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}=he(),{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 hn,useState as mn}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]=mn(!1),a=hn(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 me,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:[me("stop",{offset:"0%",stopColor:o}),me("stop",{offset:"100%",stopColor:a})]}),Qr("linearGradient",{id:`glossGrad-${r}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[me("stop",{offset:"0%",stopColor:"white",stopOpacity:"0.35"}),me("stop",{offset:"100%",stopColor:"white",stopOpacity:"0"})]}),me("filter",{id:`shieldDropShadow-${r}`,x:"-10%",y:"-10%",width:"120%",height:"130%",children:me("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodColor:t,floodOpacity:"0.4"})})]}),me("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})`}),me("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"}),me("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})`}),me("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",m=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||m?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"}):m?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||m,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",{})]})})]}),(m||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),[m,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:m}),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}=he(),{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),[m,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:m,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,m]=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),m(!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 m=e?.auth?.tokenTtlSeconds;if(!m||m<=0)return;let w=(m-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=m=>{s(m)};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};
|
|
2
|
+
//# sourceMappingURL=relay.mjs.map
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fruga/sdk",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Fruga SDK",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.mjs",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./loader": {
|
|
16
|
+
"types": "./dist/loader.d.ts",
|
|
17
|
+
"import": "./dist/loader.mjs",
|
|
18
|
+
"require": "./dist/loader.js"
|
|
19
|
+
},
|
|
20
|
+
"./loader/react": {
|
|
21
|
+
"types": "./dist/loader-react.d.ts",
|
|
22
|
+
"import": "./dist/loader-react.mjs",
|
|
23
|
+
"require": "./dist/loader-react.js"
|
|
24
|
+
},
|
|
25
|
+
"./connect": {
|
|
26
|
+
"types": "./dist/connect.d.ts",
|
|
27
|
+
"import": "./dist/connect.mjs",
|
|
28
|
+
"require": "./dist/connect.js"
|
|
29
|
+
},
|
|
30
|
+
"./relay": {
|
|
31
|
+
"types": "./dist/relay.d.ts",
|
|
32
|
+
"import": "./dist/relay.mjs",
|
|
33
|
+
"require": "./dist/relay.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/FrugaInsurance/sdk.git"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public",
|
|
42
|
+
"registry": "https://registry.npmjs.org/"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist",
|
|
46
|
+
"!dist/**/*.map",
|
|
47
|
+
"!dist/relay/**",
|
|
48
|
+
"!dist/connect/**",
|
|
49
|
+
"!dist/*.global.js",
|
|
50
|
+
"loader/package.json",
|
|
51
|
+
"relay/package.json",
|
|
52
|
+
"connect/package.json",
|
|
53
|
+
"core/package.json"
|
|
54
|
+
],
|
|
55
|
+
"scripts": {
|
|
56
|
+
"dev": "pnpm -r --parallel --filter !demo dev",
|
|
57
|
+
"build": "pnpm -r build && tsup && node scripts/prepare-exports.mjs",
|
|
58
|
+
"test": "pnpm -r test",
|
|
59
|
+
"lint": "pnpm -r lint",
|
|
60
|
+
"pack:sdk": "mkdir -p dist-tgz && pnpm -r exec pnpm pack --pack-destination ../../dist-tgz"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@eslint/js": "^10.0.1",
|
|
64
|
+
"@tailwindcss/postcss": "^4.2.1",
|
|
65
|
+
"@types/fs-extra": "^11.0.4",
|
|
66
|
+
"@types/react": "^19.2.14",
|
|
67
|
+
"@types/react-dom": "^19.2.3",
|
|
68
|
+
"@vitest/coverage-v8": "^3.0.5",
|
|
69
|
+
"eslint": "^9.19.0",
|
|
70
|
+
"eslint-plugin-react": "^7.37.4",
|
|
71
|
+
"fs-extra": "^11.3.4",
|
|
72
|
+
"happy-dom": "^20.6.1",
|
|
73
|
+
"postcss": "^8.5.8",
|
|
74
|
+
"react": "^19.2.4",
|
|
75
|
+
"react-dom": "^19.2.4",
|
|
76
|
+
"tailwindcss": "^4.2.1",
|
|
77
|
+
"tsup": "^8.5.1",
|
|
78
|
+
"typescript": "^5.9.3",
|
|
79
|
+
"typescript-eslint": "^8.22.0",
|
|
80
|
+
"vitest": "^3.0.5"
|
|
81
|
+
},
|
|
82
|
+
"peerDependencies": {
|
|
83
|
+
"react": ">=18",
|
|
84
|
+
"react-dom": ">=18"
|
|
85
|
+
},
|
|
86
|
+
"dependencies": {
|
|
87
|
+
"lucide-react": "^1.7.0"
|
|
88
|
+
}
|
|
89
|
+
}
|