@gamifyio/react 0.1.3 → 0.1.5

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/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var react=require('react'),core=require('@gamifyio/core'),jsxRuntime=require('react/jsx-runtime');var K=react.createContext(null);function X(){return typeof window>"u"}function Z({config:r,children:t}){let o=react.useRef(null),a=react.useMemo(()=>{if(X())return null;if(o.current)return o.current;let i=new core.Gamify(r);return o.current=i,i},[r.apiKey,r.endpoint]);react.useEffect(()=>()=>{o.current&&(o.current.shutdown(),o.current=null);},[]);let u=react.useMemo(()=>a?{client:a,track:(i,e)=>a.track(i,e),identify:(i,e)=>a.identify(i,e),reset:()=>a.reset(),getUserId:()=>a.getUserId(),getAnonymousId:()=>a.getAnonymousId()}:null,[a]);return u?jsxRuntime.jsx(K.Provider,{value:u,children:t}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:t})}function w(){return react.useContext(K)}function re(){let r=w();if(!r)throw new Error("useGamify must be used within a GamifyProvider. Make sure your component is wrapped with <GamifyProvider>.");return r}function G(){let r=w();return react.useCallback((t,o)=>{r&&r.track(t,o);},[r])}function te(){let r=w();return react.useCallback((t,o)=>{r&&r.identify(t,o);},[r])}function oe(){let r=w(),[t,o]=react.useState({session:r?.client?.session?.getCachedSession()??null,loading:false,error:null}),a=react.useCallback(async(l,d,R)=>{if(!r?.client){o(S=>({...S,error:"SDK not initialized"}));return}o(S=>({...S,loading:true,error:null}));try{let S=await r.client.updateCart(l,d,R);o({session:S,loading:!1,error:null});}catch(S){let x=S instanceof Error?S.message:"Unknown error";o(P=>({...P,loading:false,error:x}));}},[r]),u=react.useCallback(async l=>{if(!r?.client?.session){o(d=>({...d,error:"SDK not initialized"}));return}o(d=>({...d,loading:true,error:null}));try{let d=await r.client.session.applyCoupon(l);o({session:d,loading:!1,error:null});}catch(d){let R=d instanceof Error?d.message:"Unknown error";o(S=>({...S,loading:false,error:R}));}},[r]),i=react.useCallback(async()=>{if(!r?.client?.session){o(l=>({...l,error:"SDK not initialized"}));return}o(l=>({...l,loading:true,error:null}));try{let l=await r.client.session.complete();o({session:l,loading:!1,error:null});}catch(l){let d=l instanceof Error?l.message:"Unknown error";o(R=>({...R,loading:false,error:d}));}},[r]),e=react.useCallback(()=>{r?.client?.session&&(r.client.session.clearSession(),o({session:null,loading:false,error:null}));},[r]),s=react.useCallback(async()=>{if(r?.client?.session){o(l=>({...l,loading:true,error:null}));try{let l=await r.client.session.getSession();o({session:l,loading:!1,error:null});}catch(l){let d=l instanceof Error?l.message:"Unknown error";o(R=>({...R,loading:false,error:d}));}}},[r]);return {...t,updateCart:a,applyCoupon:u,complete:i,clearSession:e,refresh:s}}function U(r){let t=w(),[o,a]=react.useState({profile:t?.client?.loyalty?.getCachedProfile()??null,history:null,loading:false,error:null}),u=react.useCallback(async()=>{if(!t?.client){a(e=>({...e,error:"SDK not initialized"}));return}a(e=>({...e,loading:true,error:null}));try{let e=await t.client.getLoyaltyProfile();a(s=>({...s,profile:e,loading:!1,error:null}));}catch(e){let s=e instanceof Error?e.message:"Unknown error";a(l=>({...l,loading:false,error:s}));}},[t]),i=react.useCallback(async(e,s)=>{if(!t?.client){a(l=>({...l,error:"SDK not initialized"}));return}a(l=>({...l,loading:true,error:null}));try{let l=await t.client.getLoyaltyHistory(e,s);a(d=>({...d,history:l,loading:!1,error:null}));}catch(l){let d=l instanceof Error?l.message:"Unknown error";a(R=>({...R,loading:false,error:d}));}},[t]);return react.useEffect(()=>{r?.autoRefresh&&t?.client?.getUserId()&&u();},[r?.autoRefresh,t,u]),{...o,refreshProfile:u,refreshHistory:i}}function ae(){let r=w(),[t,o]=react.useState({referrerCode:r?.client?.referral?.getReferrer()??null,hasReferrer:r?.client?.referral?.hasReferrer()??false}),a=react.useCallback(e=>{r?.client?.referral&&(r.client.referral.setReferrer(e),o({referrerCode:e,hasReferrer:true}));},[r]),u=react.useCallback(()=>{r?.client?.referral&&(r.client.referral.clearReferrer(),o({referrerCode:null,hasReferrer:false}));},[r]),i=react.useCallback(()=>{if(r?.client?.referral){let e=r.client.referral.detectReferrerFromUrl();return e&&o({referrerCode:e,hasReferrer:true}),e}return null},[r]);return react.useEffect(()=>{if(r?.client?.referral){let e=r.client.referral.getReferrer();o({referrerCode:e,hasReferrer:e!==null});}},[r]),{...t,setReferrer:a,clearReferrer:u,detectFromUrl:i}}function T(r){let t=w(),[o,a]=react.useState({stats:t?.client?.affiliate?.getCachedStats()??null,loading:false,error:null}),u=react.useCallback(async(i=false)=>{if(!t?.client){a(e=>({...e,error:"SDK not initialized"}));return}a(e=>({...e,loading:true,error:null}));try{let e=await t.client.getAffiliateStats(i);a({stats:e,loading:!1,error:null});}catch(e){let s=e instanceof Error?e.message:"Unknown error";a(l=>({...l,loading:false,error:s}));}},[t]);return react.useEffect(()=>{r?.autoRefresh&&t?.client?.getUserId()&&u();},[r?.autoRefresh,t,u]),{...o,refreshStats:u}}function E(r=10){let t=w(),[o,a]=react.useState({leaderboard:null,loading:false,error:null}),u=react.useCallback(async i=>{if(!t?.client){a(e=>({...e,error:"SDK not initialized"}));return}a(e=>({...e,loading:true,error:null}));try{let e=await t.client.getLeaderboard(i??r);a({leaderboard:e,loading:!1,error:null});}catch(e){let s=e instanceof Error?e.message:"Unknown error";a(l=>({...l,loading:false,error:s}));}},[t,r]);return {...o,refresh:u}}function W(r){let t=w(),[o,a]=react.useState({quests:[],loading:false,error:null}),u=react.useCallback(async()=>{if(!t?.client){a(i=>({...i,error:"SDK not initialized"}));return}a(i=>({...i,loading:true,error:null}));try{let i=await t.client.getQuests();a({quests:i.quests,loading:!1,error:null});}catch(i){let e=i instanceof Error?i.message:"Unknown error";a(s=>({...s,loading:false,error:e}));}},[t]);return react.useEffect(()=>{r?.autoRefresh&&t?.client?.getUserId()&&u();},[r?.autoRefresh,t,u]),{...o,refresh:u}}function F(r){let t=w(),[o,a]=react.useState({streaks:[],stats:null,loading:false,error:null}),u=react.useCallback(async()=>{if(!t?.client){a(e=>({...e,error:"SDK not initialized"}));return}a(e=>({...e,loading:true,error:null}));try{let e=await t.client.getStreaks();a({streaks:e.streaks,stats:e.stats,loading:!1,error:null});}catch(e){let s=e instanceof Error?e.message:"Unknown error";a(l=>({...l,loading:false,error:s}));}},[t]),i=react.useCallback(async e=>{if(!t?.client)return a(s=>({...s,error:"SDK not initialized"})),null;try{let s=await t.client.useStreakFreeze(e);return await u(),s}catch(s){let l=s instanceof Error?s.message:"Unknown error";return a(d=>({...d,error:l})),null}},[t,u]);return react.useEffect(()=>{r?.autoRefresh&&t?.client?.getUserId()&&u();},[r?.autoRefresh,t,u]),{...o,refresh:u,freeze:i}}function D(r){let t=w(),[o,a]=react.useState({badges:[],stats:null,earned:[],locked:[],loading:false,error:null}),u=react.useCallback(async i=>{if(!t?.client){a(e=>({...e,error:"SDK not initialized"}));return}a(e=>({...e,loading:true,error:null}));try{let e=await t.client.getBadges(i??r?.category),s=e.badges.filter(d=>d.isUnlocked),l=e.badges.filter(d=>!d.isUnlocked);a({badges:e.badges,stats:e.stats,earned:s,locked:l,loading:!1,error:null});}catch(e){let s=e instanceof Error?e.message:"Unknown error";a(l=>({...l,loading:false,error:s}));}},[t,r?.category]);return react.useEffect(()=>{r?.autoRefresh&&t?.client?.getUserId()&&u();},[r?.autoRefresh,t,u]),{...o,refresh:u}}function Q(r){let t=w(),[o,a]=react.useState({items:[],userPoints:0,available:[],unavailable:[],loading:false,error:null}),u=react.useCallback(async()=>{if(!t?.client){a(e=>({...e,error:"SDK not initialized"}));return}a(e=>({...e,loading:true,error:null}));try{let e=await t.client.getRewardsStore(),s=e.items.filter(d=>d.isAvailable),l=e.items.filter(d=>!d.isAvailable);a({items:e.items,userPoints:e.userPoints,available:s,unavailable:l,loading:!1,error:null});}catch(e){let s=e instanceof Error?e.message:"Unknown error";a(l=>({...l,loading:false,error:s}));}},[t]),i=react.useCallback(async e=>{if(!t?.client)return a(s=>({...s,error:"SDK not initialized"})),null;a(s=>({...s,loading:true,error:null}));try{let s=await t.client.redeemReward(e);return await u(),s}catch(s){let l=s instanceof Error?s.message:"Unknown error";return a(d=>({...d,loading:false,error:l})),null}},[t,u]);return react.useEffect(()=>{r?.autoRefresh&&t?.client?.getUserId()&&u();},[r?.autoRefresh,t,u]),{...o,refresh:u,redeem:i}}function ne({pageName:r,properties:t,pathname:o}){let a=G(),u=react.useRef(null);return react.useEffect(()=>{if(typeof window>"u")return;if(o!==void 0){if(u.current===o)return;u.current=o;}let i=r??(typeof document<"u"?document.title:null)??(typeof window<"u"?window.location.pathname:"unknown");a("page_view",{page:i,url:typeof window<"u"?window.location.href:void 0,referrer:typeof document<"u"?document.referrer:void 0,...t});},[a,r,o,t]),null}function ie({eventType:r,properties:t,children:o}){let a=G();return react.cloneElement(o,{onClick:i=>{a(r,t),o.props.onClick&&o.props.onClick(i);}})}var k={statsContainer:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:"16px",padding:"16px"},statsCard:{backgroundColor:"#f8f9fa",borderRadius:"8px",padding:"16px",textAlign:"center",border:"1px solid #e9ecef"},statsValue:{fontSize:"24px",fontWeight:"bold",color:"#212529",marginBottom:"4px"},statsLabel:{fontSize:"14px",color:"#6c757d"},leaderboardContainer:{padding:"16px"},leaderboardList:{listStyle:"none",padding:0,margin:0},leaderboardRow:{display:"flex",alignItems:"center",padding:"12px",borderBottom:"1px solid #e9ecef"},leaderboardRowHighlighted:{display:"flex",alignItems:"center",padding:"12px",borderBottom:"1px solid #e9ecef",backgroundColor:"#fff3cd"},leaderboardRank:{fontWeight:"bold",width:"40px",color:"#212529"},leaderboardName:{flex:1,marginLeft:"12px",color:"#212529"},leaderboardStats:{color:"#6c757d",fontSize:"14px"},leaderboardEmpty:{textAlign:"center",padding:"32px",color:"#6c757d"},referralContainer:{display:"flex",gap:"8px",padding:"8px"},referralInput:{flex:1,padding:"10px 12px",border:"1px solid #ced4da",borderRadius:"6px",fontSize:"14px",backgroundColor:"#f8f9fa",color:"#212529"},referralButton:{padding:"10px 16px",border:"none",borderRadius:"6px",backgroundColor:"#0d6efd",color:"white",cursor:"pointer",fontSize:"14px",fontWeight:"500"}};function le({className:r,style:t,theme:o,autoRefresh:a=true,renderLoading:u,renderError:i}){let{stats:e,loading:s,error:l,refreshStats:d}=T({autoRefresh:a});if(react.useEffect(()=>{a&&d();},[a,d]),s)return u?u():jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px"},children:"Loading..."});if(l)return i?i(l):jsxRuntime.jsx("div",{style:{color:"red",padding:"16px"},children:l});if(!e)return null;let R={...k.statsCard,...o?.cardBackground&&{backgroundColor:o.cardBackground},...o?.cardBorder&&{border:`1px solid ${o.cardBorder}`}},S={...k.statsValue,...o?.valueColor&&{color:o.valueColor}},x={...k.statsLabel,...o?.labelColor&&{color:o.labelColor}},P=m=>`$${(m/100).toFixed(2)}`;return jsxRuntime.jsxs("div",{className:r,style:{...k.statsContainer,...t},children:[jsxRuntime.jsxs("div",{style:R,children:[jsxRuntime.jsx("div",{style:S,children:e.referralCount}),jsxRuntime.jsx("div",{style:x,children:"Referrals"})]}),jsxRuntime.jsxs("div",{style:R,children:[jsxRuntime.jsx("div",{style:S,children:e.earnings.transactionCount}),jsxRuntime.jsx("div",{style:x,children:"Commissions"})]}),jsxRuntime.jsxs("div",{style:R,children:[jsxRuntime.jsx("div",{style:S,children:P(e.earnings.totalEarned)}),jsxRuntime.jsx("div",{style:x,children:"Earnings"})]})]})}function de({limit:r=10,className:t,style:o,currentUserId:a,emptyMessage:u="No leaderboard data available yet.",theme:i,renderRow:e,renderLoading:s,renderError:l}){let{leaderboard:d,loading:R,error:S,refresh:x}=E(r);if(react.useEffect(()=>{x();},[x]),R)return s?s():jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px"},children:"Loading..."});if(S)return l?l(S):jsxRuntime.jsx("div",{style:{color:"red",padding:"16px"},children:S});if(!d||d.entries.length===0)return jsxRuntime.jsx("div",{className:t,style:{...k.leaderboardEmpty,...o},children:u});let P=f=>({...f?k.leaderboardRowHighlighted:k.leaderboardRow,...i?.rowBackground&&!f&&{backgroundColor:i.rowBackground},...i?.highlightBackground&&f&&{backgroundColor:i.highlightBackground}}),m=i?.textColor?{color:i.textColor}:{},h=i?.secondaryColor?{...k.leaderboardStats,color:i.secondaryColor}:k.leaderboardStats;return jsxRuntime.jsx("div",{className:t,style:{...k.leaderboardContainer,...o},children:jsxRuntime.jsx("ol",{style:k.leaderboardList,children:d.entries.map(f=>{let b=a===f.userId;return e?jsxRuntime.jsx("li",{children:e(f,b)},f.userId):jsxRuntime.jsxs("li",{style:P(b),children:[jsxRuntime.jsxs("span",{style:{...k.leaderboardRank,...m},children:["#",f.rank]}),jsxRuntime.jsx("span",{style:{...k.leaderboardName,...m},children:f.displayName??`User ${f.userId.slice(0,8)}`}),jsxRuntime.jsxs("span",{style:h,children:[f.referralCount," referrals"]})]},f.userId)})})})}function ce({baseUrl:r,className:t,style:o,copyButtonText:a="Copy",copiedText:u="Copied!",shareButtonText:i="Share",shareTitle:e="Check this out!",shareText:s="Join using my referral link",showShareButton:l=true,theme:d,onCopy:R,onShare:S}){let{stats:x}=T({autoRefresh:true}),[P,m]=react.useState(false),h=x?.referralCode;if(!h)return null;let f=typeof window<"u"?window.location.origin:"",b=`${r??f}?ref=${h}`,g=async()=>{try{await navigator.clipboard.writeText(b),m(!0),R?.(b),setTimeout(()=>m(!1),2e3);}catch(N){console.error("Failed to copy:",N);}},y=async()=>{if(typeof navigator<"u"&&navigator.share)try{await navigator.share({title:e,text:s,url:b}),S?.(b);}catch(N){N.name!=="AbortError"&&console.error("Failed to share:",N);}},v=typeof navigator<"u"&&"share"in navigator,B={...k.referralInput,...d?.inputBackground&&{backgroundColor:d.inputBackground},...d?.inputBorder&&{border:`1px solid ${d.inputBorder}`},...d?.inputColor&&{color:d.inputColor}},z={...k.referralButton,...d?.buttonBackground&&{backgroundColor:d.buttonBackground},...d?.buttonColor&&{color:d.buttonColor}};return jsxRuntime.jsxs("div",{className:t,style:{...k.referralContainer,...o},children:[jsxRuntime.jsx("input",{type:"text",readOnly:true,value:b,style:B,onClick:N=>N.target.select()}),jsxRuntime.jsx("button",{type:"button",onClick:g,style:z,children:P?u:a}),l&&v&&jsxRuntime.jsx("button",{type:"button",onClick:y,style:z,children:i})]})}var c={questContainer:{padding:"16px",backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e9ecef",marginBottom:"12px"},questHeader:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"12px"},questTitle:{fontSize:"16px",fontWeight:"600",color:"#212529",margin:0},questDescription:{fontSize:"14px",color:"#6c757d",margin:"4px 0 0 0"},questBadge:{fontSize:"12px",padding:"4px 8px",borderRadius:"12px",fontWeight:"500"},questProgressBar:{width:"100%",height:"8px",backgroundColor:"#e9ecef",borderRadius:"4px",overflow:"hidden",marginBottom:"12px"},questProgressFill:{height:"100%",backgroundColor:"#0d6efd",borderRadius:"4px",transition:"width 0.3s ease"},questStepList:{listStyle:"none",padding:0,margin:0},questStep:{display:"flex",alignItems:"center",padding:"8px 0",borderBottom:"1px solid #f8f9fa",fontSize:"14px"},questStepIcon:{width:"20px",height:"20px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",marginRight:"12px",fontSize:"12px"},questStepText:{flex:1,color:"#212529"},questStepCount:{fontSize:"12px",color:"#6c757d"},questReward:{display:"flex",alignItems:"center",marginTop:"12px",padding:"8px 12px",backgroundColor:"#fff3cd",borderRadius:"6px",fontSize:"14px",color:"#856404"},streakContainer:{display:"flex",alignItems:"center",padding:"16px",backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e9ecef"},streakFlame:{fontSize:"32px",marginRight:"12px"},streakCount:{fontSize:"28px",fontWeight:"bold",color:"#212529",marginRight:"8px"},streakLabel:{fontSize:"14px",color:"#6c757d"},streakInfo:{flex:1},streakName:{fontSize:"16px",fontWeight:"600",color:"#212529"},streakStatus:{fontSize:"12px",padding:"2px 8px",borderRadius:"10px",marginLeft:"8px"},freezeButton:{padding:"8px 16px",border:"none",borderRadius:"6px",backgroundColor:"#17a2b8",color:"white",cursor:"pointer",fontSize:"14px",display:"flex",alignItems:"center",gap:"6px"},freezeButtonDisabled:{padding:"8px 16px",border:"none",borderRadius:"6px",backgroundColor:"#6c757d",color:"white",cursor:"not-allowed",fontSize:"14px",opacity:.6},badgeGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(120px, 1fr))",gap:"16px",padding:"16px"},badgeCard:{display:"flex",flexDirection:"column",alignItems:"center",padding:"16px",backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e9ecef",cursor:"pointer",transition:"transform 0.2s, box-shadow 0.2s"},badgeCardLocked:{display:"flex",flexDirection:"column",alignItems:"center",padding:"16px",backgroundColor:"#f8f9fa",borderRadius:"8px",border:"1px solid #e9ecef",cursor:"pointer",opacity:.6,filter:"grayscale(100%)"},badgeIcon:{width:"64px",height:"64px",borderRadius:"50%",objectFit:"cover",marginBottom:"8px",backgroundColor:"#e9ecef"},badgeName:{fontSize:"14px",fontWeight:"500",color:"#212529",textAlign:"center",marginBottom:"4px"},badgeRarity:{fontSize:"11px",padding:"2px 8px",borderRadius:"10px",fontWeight:"500",textTransform:"uppercase"},badgeStats:{display:"flex",justifyContent:"center",gap:"16px",padding:"12px",backgroundColor:"#f8f9fa",borderRadius:"8px",marginBottom:"16px"},badgeStat:{textAlign:"center"},badgeStatValue:{fontSize:"20px",fontWeight:"bold",color:"#212529"},badgeStatLabel:{fontSize:"12px",color:"#6c757d"},levelContainer:{padding:"16px",backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e9ecef"},levelHeader:{display:"flex",alignItems:"center",marginBottom:"12px"},levelIcon:{width:"48px",height:"48px",borderRadius:"50%",marginRight:"12px",backgroundColor:"#e9ecef",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"24px"},levelInfo:{flex:1},levelTierName:{fontSize:"18px",fontWeight:"600",color:"#212529"},levelPoints:{fontSize:"14px",color:"#6c757d"},levelProgressContainer:{marginTop:"12px"},levelProgressHeader:{display:"flex",justifyContent:"space-between",marginBottom:"6px",fontSize:"13px"},levelProgressBar:{width:"100%",height:"10px",backgroundColor:"#e9ecef",borderRadius:"5px",overflow:"hidden"},levelProgressFill:{height:"100%",background:"linear-gradient(90deg, #667eea 0%, #764ba2 100%)",borderRadius:"5px",transition:"width 0.3s ease"},levelBenefits:{marginTop:"16px",padding:"12px",backgroundColor:"#f8f9fa",borderRadius:"6px"},levelBenefitsTitle:{fontSize:"14px",fontWeight:"600",color:"#212529",marginBottom:"8px"},levelBenefitsList:{listStyle:"none",padding:0,margin:0,fontSize:"13px",color:"#495057"},levelBenefitItem:{padding:"4px 0",display:"flex",alignItems:"center"},rewardStoreGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"16px",padding:"16px"},rewardCard:{display:"flex",flexDirection:"column",backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e9ecef",overflow:"hidden"},rewardCardUnavailable:{display:"flex",flexDirection:"column",backgroundColor:"#f8f9fa",borderRadius:"8px",border:"1px solid #e9ecef",overflow:"hidden",opacity:.7},rewardImage:{width:"100%",height:"120px",objectFit:"cover",backgroundColor:"#e9ecef"},rewardContent:{padding:"12px",flex:1,display:"flex",flexDirection:"column"},rewardName:{fontSize:"16px",fontWeight:"600",color:"#212529",marginBottom:"4px"},rewardDescription:{fontSize:"13px",color:"#6c757d",marginBottom:"8px",flex:1},rewardCost:{fontSize:"14px",fontWeight:"600",color:"#0d6efd",marginBottom:"8px"},rewardButton:{padding:"10px 16px",border:"none",borderRadius:"6px",backgroundColor:"#0d6efd",color:"white",cursor:"pointer",fontSize:"14px",fontWeight:"500",width:"100%"},rewardButtonDisabled:{padding:"10px 16px",border:"none",borderRadius:"6px",backgroundColor:"#6c757d",color:"white",cursor:"not-allowed",fontSize:"14px",fontWeight:"500",width:"100%"},rewardPointsHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",backgroundColor:"#f8f9fa",borderRadius:"8px",marginBottom:"16px"},rewardPointsLabel:{fontSize:"14px",color:"#6c757d"},rewardPointsValue:{fontSize:"24px",fontWeight:"bold",color:"#212529"}};function $(r){switch(r){case "completed":return {bg:"#d4edda",color:"#155724"};case "in_progress":return {bg:"#cce5ff",color:"#004085"};case "active":return {bg:"#cce5ff",color:"#004085"};case "frozen":return {bg:"#cce5ff",color:"#17a2b8"};case "at_risk":return {bg:"#fff3cd",color:"#856404"};case "broken":return {bg:"#f8d7da",color:"#721c24"};default:return {bg:"#e9ecef",color:"#6c757d"}}}function ue(r){switch(r){case "COMMON":return {bg:"#e9ecef",color:"#495057"};case "RARE":return {bg:"#cce5ff",color:"#004085"};case "EPIC":return {bg:"#e2d5f1",color:"#6f42c1"};case "LEGENDARY":return {bg:"#fff3cd",color:"#856404"};default:return {bg:"#e9ecef",color:"#6c757d"}}}function fe({questId:r,hideCompleted:t=false,className:o,style:a,onComplete:u,theme:i,renderLoading:e,renderError:s,renderQuest:l}){let{quests:d,loading:R,error:S,refresh:x}=W({autoRefresh:true}),P=react.useRef(new Map);if(react.useEffect(()=>{x();},[x]),react.useEffect(()=>{u&&d.forEach(b=>{let g=P.current.get(b.id);g&&g.status!=="completed"&&b.status==="completed"&&u(b);});let f=new Map;d.forEach(b=>f.set(b.id,b)),P.current=f;},[d,u]),R)return e?e():jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px"},children:"Loading..."});if(S)return s?s(S):jsxRuntime.jsx("div",{style:{color:"red",padding:"16px"},children:S});let m=d;if(r&&(m=d.filter(f=>f.id===r)),t&&(m=m.filter(f=>f.status!=="completed")),m.length===0)return jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px",color:"#6c757d"},children:"No quests available"});let h={...c.questContainer,...i?.cardBackground&&{backgroundColor:i.cardBackground},...i?.cardBorder&&{border:`1px solid ${i.cardBorder}`}};return jsxRuntime.jsx("div",{className:o,style:a,children:m.map(f=>{if(l)return jsxRuntime.jsx("div",{children:l(f)},f.id);let b=$(f.status);return jsxRuntime.jsxs("div",{style:h,children:[jsxRuntime.jsxs("div",{style:c.questHeader,children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{style:{...c.questTitle,...i?.textColor&&{color:i.textColor}},children:f.name}),f.description&&jsxRuntime.jsx("p",{style:c.questDescription,children:f.description})]}),jsxRuntime.jsx("span",{style:{...c.questBadge,backgroundColor:b.bg,color:b.color},children:f.status.replace("_"," ")})]}),jsxRuntime.jsx("div",{style:c.questProgressBar,children:jsxRuntime.jsx("div",{style:{...c.questProgressFill,width:`${f.percentComplete}%`,...i?.progressColor&&{backgroundColor:i.progressColor}}})}),jsxRuntime.jsx("ul",{style:c.questStepList,children:f.steps.map(g=>jsxRuntime.jsxs("li",{style:c.questStep,children:[jsxRuntime.jsx("span",{style:{...c.questStepIcon,backgroundColor:g.completed?"#d4edda":"#e9ecef",color:g.completed?"#155724":"#6c757d"},children:g.completed?"\u2713":g.order}),jsxRuntime.jsx("span",{style:{...c.questStepText,textDecoration:g.completed?"line-through":"none",color:g.completed?"#6c757d":"#212529"},children:g.name}),jsxRuntime.jsxs("span",{style:c.questStepCount,children:[g.currentCount,"/",g.requiredCount]})]},g.id))}),f.xpReward>0&&jsxRuntime.jsxs("div",{style:c.questReward,children:[jsxRuntime.jsx("span",{style:{marginRight:"6px"},children:"\u2B50"}),f.xpReward," XP reward",f.badgeReward&&" + Badge"]})]},f.id)})})}function pe({ruleId:r,size:t="md",showFreezeButton:o=true,className:a,style:u,onFreeze:i,theme:e,renderLoading:s,renderError:l}){let{streaks:d,stats:R,loading:S,error:x,freeze:P,refresh:m}=F({autoRefresh:true}),[h,f]=react.useState(false);if(react.useEffect(()=>{m();},[m]),S)return s?s():jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px"},children:"Loading..."});if(x)return l?l(x):jsxRuntime.jsx("div",{style:{color:"red",padding:"16px"},children:x});let b=d;if(r&&(b=d.filter(v=>v.id===r)),b.length===0)return jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px",color:"#6c757d"},children:"No streaks available"});let g={sm:{flame:"24px",count:"20px",container:"12px"},md:{flame:"32px",count:"28px",container:"16px"},lg:{flame:"48px",count:"40px",container:"20px"}},y=async v=>{f(true);try{let B=await P(v);B&&i&&i(v,B.remainingFreezes);}finally{f(false);}};return jsxRuntime.jsx("div",{className:a,style:u,children:b.map(v=>{let B=$(v.status),z=v.freezeInventory>0&&!v.freezeUsedToday;return jsxRuntime.jsxs("div",{style:{...c.streakContainer,padding:g[t].container,...e?.cardBackground&&{backgroundColor:e.cardBackground}},children:[jsxRuntime.jsx("span",{style:{...c.streakFlame,fontSize:g[t].flame,...e?.flameColor&&{color:e.flameColor}},children:"\u{1F525}"}),jsxRuntime.jsx("span",{style:{...c.streakCount,fontSize:g[t].count,...e?.countColor&&{color:e.countColor}},children:v.currentCount}),jsxRuntime.jsxs("div",{style:c.streakInfo,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jsxRuntime.jsx("span",{style:c.streakName,children:v.name}),jsxRuntime.jsx("span",{style:{...c.streakStatus,backgroundColor:B.bg,color:B.color},children:v.status})]}),jsxRuntime.jsxs("span",{style:c.streakLabel,children:["Best: ",v.maxStreak," days"]})]}),o&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{y(v.id);},disabled:!z||h,style:z?c.freezeButton:c.freezeButtonDisabled,children:[jsxRuntime.jsx("span",{children:"\u2744\uFE0F"}),jsxRuntime.jsx("span",{children:v.freezeInventory})]})]},v.id)})})}function ge({showLocked:r=true,category:t,columns:o=4,className:a,style:u,showStats:i=true,onBadgeClick:e,theme:s,renderLoading:l,renderError:d,renderBadge:R}){let{badges:S,stats:x,loading:P,error:m,refresh:h}=D({autoRefresh:true,category:t});if(react.useEffect(()=>{h(t);},[h,t]),P)return l?l():jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px"},children:"Loading..."});if(m)return d?d(m):jsxRuntime.jsx("div",{style:{color:"red",padding:"16px"},children:m});let f=S;r||(f=S.filter(g=>g.isUnlocked));let b={...c.badgeGrid,gridTemplateColumns:`repeat(${o}, 1fr)`};return jsxRuntime.jsxs("div",{className:a,style:u,children:[i&&x&&jsxRuntime.jsxs("div",{style:c.badgeStats,children:[jsxRuntime.jsxs("div",{style:c.badgeStat,children:[jsxRuntime.jsx("div",{style:c.badgeStatValue,children:x.unlocked}),jsxRuntime.jsx("div",{style:c.badgeStatLabel,children:"Unlocked"})]}),jsxRuntime.jsxs("div",{style:c.badgeStat,children:[jsxRuntime.jsx("div",{style:c.badgeStatValue,children:x.total}),jsxRuntime.jsx("div",{style:c.badgeStatLabel,children:"Total"})]}),jsxRuntime.jsxs("div",{style:c.badgeStat,children:[jsxRuntime.jsxs("div",{style:c.badgeStatValue,children:[x.total>0?Math.round(x.unlocked/x.total*100):0,"%"]}),jsxRuntime.jsx("div",{style:c.badgeStatLabel,children:"Progress"})]})]}),jsxRuntime.jsx("div",{style:b,children:f.map(g=>{if(R)return jsxRuntime.jsx("div",{children:R(g)},g.id);let y=ue(g.rarity),v=g.isUnlocked?{...c.badgeCard,...s?.cardBackground&&{backgroundColor:s.cardBackground},...s?.cardBorder&&{border:`1px solid ${s.cardBorder}`}}:c.badgeCardLocked;return jsxRuntime.jsxs("div",{style:v,onClick:()=>e?.(g),onKeyDown:B=>B.key==="Enter"&&e?.(g),role:"button",tabIndex:0,children:[g.iconUrl?jsxRuntime.jsx("img",{src:g.iconUrl,alt:g.name,style:c.badgeIcon}):jsxRuntime.jsx("div",{style:c.badgeIcon,children:g.isUnlocked?"\u{1F3C6}":"\u{1F512}"}),jsxRuntime.jsx("span",{style:c.badgeName,children:g.name}),jsxRuntime.jsx("span",{style:{...c.badgeRarity,backgroundColor:y.bg,color:y.color},children:g.rarity})]},g.id)})})]})}function ye({showNextTier:r=true,showBenefits:t=false,className:o,style:a,theme:u,renderLoading:i,renderError:e}){let{profile:s,loading:l,error:d,refreshProfile:R}=U({autoRefresh:true});if(react.useEffect(()=>{R();},[R]),l)return i?i():jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px"},children:"Loading..."});if(d)return e?e(d):jsxRuntime.jsx("div",{style:{color:"red",padding:"16px"},children:d});if(!s)return null;let S=s.nextTier?Math.min(100,s.points/s.nextTier.minPoints*100):100,x={...c.levelContainer,...u?.cardBackground&&{backgroundColor:u.cardBackground}},P={...c.levelProgressFill,width:`${S}%`,...u?.progressGradient&&{background:u.progressGradient}};return jsxRuntime.jsxs("div",{className:o,style:{...x,...a},children:[jsxRuntime.jsxs("div",{style:c.levelHeader,children:[jsxRuntime.jsx("div",{style:{...c.levelIcon,...s.tier?.color&&{backgroundColor:s.tier.color}},children:s.tier?.iconUrl?jsxRuntime.jsx("img",{src:s.tier.iconUrl,alt:s.tier.name,style:{width:"100%",height:"100%",borderRadius:"50%"}}):"\u2B50"}),jsxRuntime.jsxs("div",{style:c.levelInfo,children:[jsxRuntime.jsx("div",{style:{...c.levelTierName,...u?.textColor&&{color:u.textColor}},children:s.tier?.name??"No Tier"}),jsxRuntime.jsxs("div",{style:c.levelPoints,children:[s.points.toLocaleString()," points"]})]})]}),r&&s.nextTier&&jsxRuntime.jsxs("div",{style:c.levelProgressContainer,children:[jsxRuntime.jsxs("div",{style:c.levelProgressHeader,children:[jsxRuntime.jsxs("span",{style:{color:"#6c757d"},children:["Progress to ",s.nextTier.name]}),jsxRuntime.jsxs("span",{style:{fontWeight:"500"},children:[s.nextTier.pointsNeeded.toLocaleString()," points needed"]})]}),jsxRuntime.jsx("div",{style:c.levelProgressBar,children:jsxRuntime.jsx("div",{style:P})})]}),t&&s.tier?.benefits&&Object.keys(s.tier.benefits).length>0&&jsxRuntime.jsxs("div",{style:c.levelBenefits,children:[jsxRuntime.jsx("div",{style:c.levelBenefitsTitle,children:"Your Benefits"}),jsxRuntime.jsx("ul",{style:c.levelBenefitsList,children:Object.entries(s.tier.benefits).map(([m,h])=>jsxRuntime.jsxs("li",{style:c.levelBenefitItem,children:[jsxRuntime.jsx("span",{style:{marginRight:"8px",color:"#28a745"},children:"\u2713"}),String(h)]},m))})]})]})}function Se({showUnavailable:r=true,className:t,style:o,showPointsHeader:a=true,onRedeem:u,theme:i,renderLoading:e,renderError:s,renderItem:l}){let{items:d,userPoints:R,loading:S,error:x,redeem:P,refresh:m}=Q({autoRefresh:true}),[h,f]=react.useState(null);if(react.useEffect(()=>{m();},[m]),S&&d.length===0)return e?e():jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px"},children:"Loading..."});if(x)return s?s(x):jsxRuntime.jsx("div",{style:{color:"red",padding:"16px"},children:x});let b=d;r||(b=d.filter(y=>y.isAvailable));let g=async y=>{f(y.id);try{let v=await P(y.id);v&&u&&u(y,v);}finally{f(null);}};return jsxRuntime.jsxs("div",{className:t,style:o,children:[a&&jsxRuntime.jsxs("div",{style:c.rewardPointsHeader,children:[jsxRuntime.jsx("span",{style:c.rewardPointsLabel,children:"Your Points"}),jsxRuntime.jsx("span",{style:c.rewardPointsValue,children:R.toLocaleString()})]}),jsxRuntime.jsx("div",{style:c.rewardStoreGrid,children:b.map(y=>{if(l)return jsxRuntime.jsx("div",{children:l(y,()=>{g(y);})},y.id);let v=y.isAvailable?{...c.rewardCard,...i?.cardBackground&&{backgroundColor:i.cardBackground}}:c.rewardCardUnavailable,B=y.isAvailable&&y.canAfford?{...c.rewardButton,...i?.buttonColor&&{backgroundColor:i.buttonColor}}:c.rewardButtonDisabled,z=h===y.id;return jsxRuntime.jsxs("div",{style:v,children:[y.imageUrl?jsxRuntime.jsx("img",{src:y.imageUrl,alt:y.name,style:c.rewardImage}):jsxRuntime.jsx("div",{style:{...c.rewardImage,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"32px"},children:"\u{1F381}"}),jsxRuntime.jsxs("div",{style:c.rewardContent,children:[jsxRuntime.jsx("span",{style:c.rewardName,children:y.name}),y.description&&jsxRuntime.jsx("span",{style:c.rewardDescription,children:y.description}),jsxRuntime.jsxs("span",{style:c.rewardCost,children:[y.pointsCost.toLocaleString()," points"]}),y.requiredBadgeName&&!y.hasBadge&&jsxRuntime.jsxs("span",{style:{fontSize:"12px",color:"#dc3545",marginBottom:"8px"},children:["Requires: ",y.requiredBadgeName]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{g(y);},disabled:!y.isAvailable||!y.canAfford||z,style:B,children:z?"Redeeming...":y.canAfford?"Redeem":`Need ${(y.pointsCost-R).toLocaleString()} more`})]})]},y.id)})})]})}exports.AffiliateStats=le;exports.BadgeGrid=ge;exports.GamifyPageView=ne;exports.GamifyProvider=Z;exports.GamifyTrackClick=ie;exports.Leaderboard=de;exports.LevelProgress=ye;exports.QuestProgress=fe;exports.ReferralLink=ce;exports.RewardStore=Se;exports.StreakFlame=pe;exports.useAffiliateStats=T;exports.useBadges=D;exports.useGamify=re;exports.useIdentify=te;exports.useLeaderboard=E;exports.useLoyalty=U;exports.useQuests=W;exports.useReferral=ae;exports.useRewards=Q;exports.useSession=oe;exports.useStreaks=F;exports.useTrack=G;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var Pe=require('react'),core=require('@gamifyio/core'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Pe__default=/*#__PURE__*/_interopDefault(Pe);var fe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(o,s)=>(typeof require<"u"?require:o)[s]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var de=Pe.createContext(null),O=Pe.createContext(core.defaultTheme);function xe(){return typeof window>"u"}function me({config:e,theme:o,children:s}){let i=Pe.useRef(null),d=Pe.useMemo(()=>o?{...core.defaultTheme,...o}:core.defaultTheme,[o]),p=Pe.useMemo(()=>{if(xe())return null;if(i.current)return i.current;let a=new core.Gamify(e);return i.current=a,a},[e.apiKey,e.endpoint]);Pe.useEffect(()=>()=>{i.current&&(i.current.shutdown(),i.current=null);},[]);let t=Pe.useMemo(()=>p?{client:p,track:(a,n)=>p.track(a,n),identify:(a,n)=>p.identify(a,n),reset:()=>p.reset(),getUserId:()=>p.getUserId(),getAnonymousId:()=>p.getAnonymousId()}:null,[p]);return t?jsxRuntime.jsx(O.Provider,{value:d,children:jsxRuntime.jsx(de.Provider,{value:t,children:s})}):jsxRuntime.jsx(O.Provider,{value:d,children:s})}function N(){return Pe.useContext(de)}function V(){return Pe.useContext(O)}function be(){let e=N();if(!e)throw new Error("useGamify must be used within a GamifyProvider. Make sure your component is wrapped with <GamifyProvider>.");return e}function H(){let e=N();return Pe.useCallback((o,s)=>{e&&e.track(o,s);},[e])}function Ce(){let e=N();return Pe.useCallback((o,s)=>{e&&e.identify(o,s);},[e])}function Re(){let e=N(),[o,s]=Pe.useState({session:e?.client?.session?.getCachedSession()??null,loading:false,error:null}),i=Pe.useCallback(async(n,c,u)=>{if(!e?.client){s(g=>({...g,error:"SDK not initialized"}));return}s(g=>({...g,loading:true,error:null}));try{let g=await e.client.updateCart(n,c,u);s({session:g,loading:!1,error:null});}catch(g){let m=g instanceof Error?g.message:"Unknown error";s(b=>({...b,loading:false,error:m}));}},[e]),d=Pe.useCallback(async n=>{if(!e?.client?.session){s(c=>({...c,error:"SDK not initialized"}));return}s(c=>({...c,loading:true,error:null}));try{let c=await e.client.session.applyCoupon(n);s({session:c,loading:!1,error:null});}catch(c){let u=c instanceof Error?c.message:"Unknown error";s(g=>({...g,loading:false,error:u}));}},[e]),p=Pe.useCallback(async()=>{if(!e?.client?.session){s(n=>({...n,error:"SDK not initialized"}));return}s(n=>({...n,loading:true,error:null}));try{let n=await e.client.session.complete();s({session:n,loading:!1,error:null});}catch(n){let c=n instanceof Error?n.message:"Unknown error";s(u=>({...u,loading:false,error:c}));}},[e]),t=Pe.useCallback(()=>{e?.client?.session&&(e.client.session.clearSession(),s({session:null,loading:false,error:null}));},[e]),a=Pe.useCallback(async()=>{if(e?.client?.session){s(n=>({...n,loading:true,error:null}));try{let n=await e.client.session.getSession();s({session:n,loading:!1,error:null});}catch(n){let c=n instanceof Error?n.message:"Unknown error";s(u=>({...u,loading:false,error:c}));}}},[e]);return {...o,updateCart:i,applyCoupon:d,complete:p,clearSession:t,refresh:a}}function ee(e){let o=N(),[s,i]=Pe.useState({profile:o?.client?.loyalty?.getCachedProfile()??null,history:null,loading:false,error:null}),d=Pe.useCallback(async()=>{if(!o?.client){i(t=>({...t,error:"SDK not initialized"}));return}i(t=>({...t,loading:true,error:null}));try{let t=await o.client.getLoyaltyProfile();i(a=>({...a,profile:t,loading:!1,error:null}));}catch(t){let a=t instanceof Error?t.message:"Unknown error";i(n=>({...n,loading:false,error:a}));}},[o]),p=Pe.useCallback(async(t,a)=>{if(!o?.client){i(n=>({...n,error:"SDK not initialized"}));return}i(n=>({...n,loading:true,error:null}));try{let n=await o.client.getLoyaltyHistory(t,a);i(c=>({...c,history:n,loading:!1,error:null}));}catch(n){let c=n instanceof Error?n.message:"Unknown error";i(u=>({...u,loading:false,error:c}));}},[o]);return Pe.useEffect(()=>{e?.autoRefresh&&o?.client?.getUserId()&&d();},[e?.autoRefresh,o,d]),{...s,refreshProfile:d,refreshHistory:p}}function ve(){let e=N(),[o,s]=Pe.useState({referrerCode:e?.client?.referral?.getReferrer()??null,hasReferrer:e?.client?.referral?.hasReferrer()??false}),i=Pe.useCallback(t=>{e?.client?.referral&&(e.client.referral.setReferrer(t),s({referrerCode:t,hasReferrer:true}));},[e]),d=Pe.useCallback(()=>{e?.client?.referral&&(e.client.referral.clearReferrer(),s({referrerCode:null,hasReferrer:false}));},[e]),p=Pe.useCallback(()=>{if(e?.client?.referral){let t=e.client.referral.detectReferrerFromUrl();return t&&s({referrerCode:t,hasReferrer:true}),t}return null},[e]);return Pe.useEffect(()=>{if(e?.client?.referral){let t=e.client.referral.getReferrer();s({referrerCode:t,hasReferrer:t!==null});}},[e]),{...o,setReferrer:i,clearReferrer:d,detectFromUrl:p}}function K(e){let o=N(),[s,i]=Pe.useState({stats:o?.client?.affiliate?.getCachedStats()??null,loading:false,error:null}),d=Pe.useCallback(async(p=false)=>{if(!o?.client){i(t=>({...t,error:"SDK not initialized"}));return}i(t=>({...t,loading:true,error:null}));try{let t=await o.client.getAffiliateStats(p);i({stats:t,loading:!1,error:null});}catch(t){let a=t instanceof Error?t.message:"Unknown error";i(n=>({...n,loading:false,error:a}));}},[o]);return Pe.useEffect(()=>{e?.autoRefresh&&o?.client?.getUserId()&&d();},[e?.autoRefresh,o,d]),{...s,refreshStats:d}}function re(e=10){let o=N(),[s,i]=Pe.useState({leaderboard:null,loading:false,error:null}),d=Pe.useCallback(async p=>{if(!o?.client){i(t=>({...t,error:"SDK not initialized"}));return}i(t=>({...t,loading:true,error:null}));try{let t=await o.client.getLeaderboard(p??e);i({leaderboard:t,loading:!1,error:null});}catch(t){let a=t instanceof Error?t.message:"Unknown error";i(n=>({...n,loading:false,error:a}));}},[o,e]);return {...s,refresh:d}}function te(e){let o=N(),[s,i]=Pe.useState({quests:[],loading:false,error:null}),d=Pe.useCallback(async()=>{if(!o?.client){i(p=>({...p,error:"SDK not initialized"}));return}i(p=>({...p,loading:true,error:null}));try{let p=await o.client.getQuests();i({quests:p.quests,loading:!1,error:null});}catch(p){let t=p instanceof Error?p.message:"Unknown error";i(a=>({...a,loading:false,error:t}));}},[o]);return Pe.useEffect(()=>{e?.autoRefresh&&o?.client?.getUserId()&&d();},[e?.autoRefresh,o,d]),{...s,refresh:d}}function oe(e){let o=N(),[s,i]=Pe.useState({streaks:[],stats:null,loading:false,error:null}),d=Pe.useCallback(async()=>{if(!o?.client){i(t=>({...t,error:"SDK not initialized"}));return}i(t=>({...t,loading:true,error:null}));try{let t=await o.client.getStreaks();i({streaks:t.streaks,stats:t.stats,loading:!1,error:null});}catch(t){let a=t instanceof Error?t.message:"Unknown error";i(n=>({...n,loading:false,error:a}));}},[o]),p=Pe.useCallback(async t=>{if(!o?.client)return i(a=>({...a,error:"SDK not initialized"})),null;try{let a=await o.client.useStreakFreeze(t);return await d(),a}catch(a){let n=a instanceof Error?a.message:"Unknown error";return i(c=>({...c,error:n})),null}},[o,d]);return Pe.useEffect(()=>{e?.autoRefresh&&o?.client?.getUserId()&&d();},[e?.autoRefresh,o,d]),{...s,refresh:d,freeze:p}}function ne(e){let o=N(),[s,i]=Pe.useState({badges:[],stats:null,earned:[],locked:[],loading:false,error:null}),d=Pe.useCallback(async p=>{if(!o?.client){i(t=>({...t,error:"SDK not initialized"}));return}i(t=>({...t,loading:true,error:null}));try{let t=await o.client.getBadges(p??e?.category),a=t.badges.filter(c=>c.isUnlocked),n=t.badges.filter(c=>!c.isUnlocked);i({badges:t.badges,stats:t.stats,earned:a,locked:n,loading:!1,error:null});}catch(t){let a=t instanceof Error?t.message:"Unknown error";i(n=>({...n,loading:false,error:a}));}},[o,e?.category]);return Pe.useEffect(()=>{e?.autoRefresh&&o?.client?.getUserId()&&d();},[e?.autoRefresh,o,d]),{...s,refresh:d}}function ae(e){let o=N(),[s,i]=Pe.useState({items:[],userPoints:0,available:[],unavailable:[],loading:false,error:null}),d=Pe.useCallback(async()=>{if(!o?.client){i(t=>({...t,error:"SDK not initialized"}));return}i(t=>({...t,loading:true,error:null}));try{let t=await o.client.getRewardsStore(),a=t.items.filter(c=>c.isAvailable),n=t.items.filter(c=>!c.isAvailable);i({items:t.items,userPoints:t.userPoints,available:a,unavailable:n,loading:!1,error:null});}catch(t){let a=t instanceof Error?t.message:"Unknown error";i(n=>({...n,loading:false,error:a}));}},[o]),p=Pe.useCallback(async t=>{if(!o?.client)return i(a=>({...a,error:"SDK not initialized"})),null;i(a=>({...a,loading:true,error:null}));try{let a=await o.client.redeemReward(t);return await d(),a}catch(a){let n=a instanceof Error?a.message:"Unknown error";return i(c=>({...c,loading:false,error:n})),null}},[o,d]);return Pe.useEffect(()=>{e?.autoRefresh&&o?.client?.getUserId()&&d();},[e?.autoRefresh,o,d]),{...s,refresh:d,redeem:p}}var Q="div",Y=({children:e})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:e});try{let e=fe("framer-motion");e?.motion?.div&&(Q=e.motion.div),e?.AnimatePresence&&(Y=e.AnimatePresence);}catch{}var se=class extends Pe__default.default.Component{constructor(o){super(o),this.state={hasError:false,error:null};}static getDerivedStateFromError(o){return {hasError:true,error:o}}render(){return this.state.hasError?this.props.fallback?this.props.fallback:jsxRuntime.jsx("div",{style:{padding:"16px",color:"#6c757d",fontSize:"14px",textAlign:"center"},children:"Unable to load this section. Please try refreshing the page."}):this.props.children}};function D(e,o){let s=i=>jsxRuntime.jsx(se,{fallback:o,children:jsxRuntime.jsx(e,{...i})});return s.displayName=`WithErrorBoundary(${e.displayName||e.name||"Component"})`,s}function he({pageName:e,properties:o,pathname:s}){let i=H(),d=Pe.useRef(null);return Pe.useEffect(()=>{if(typeof window>"u")return;if(s!==void 0){if(d.current===s)return;d.current=s;}let p=e??(typeof document<"u"?document.title:null)??(typeof window<"u"?window.location.pathname:"unknown");i("page_view",{page:p,url:typeof window<"u"?window.location.href:void 0,referrer:typeof document<"u"?document.referrer:void 0,...o});},[i,e,s,o]),null}function we({eventType:e,properties:o,children:s}){let i=H();return Pe.cloneElement(s,{onClick:p=>{i(e,o),s.props.onClick&&s.props.onClick(p);}})}function _(e){return {statsContainer:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:"16px",padding:"16px"},statsCard:{backgroundColor:e.cardBackground??e.background,borderRadius:"8px",padding:"16px",textAlign:"center",border:`1px solid ${e.cardBorder??e.border}`},statsValue:{fontSize:"24px",fontWeight:"bold",color:e.foreground,marginBottom:"4px"},statsLabel:{fontSize:"14px",color:e.foregroundSecondary},leaderboardContainer:{padding:"16px"},leaderboardList:{listStyle:"none",padding:0,margin:0},leaderboardRow:{display:"flex",alignItems:"center",padding:"12px",borderBottom:`1px solid ${e.border}`},leaderboardRowHighlighted:{display:"flex",alignItems:"center",padding:"12px",borderBottom:`1px solid ${e.border}`,backgroundColor:`${e.primary}20`},leaderboardRank:{fontWeight:"bold",width:"40px",color:e.foreground},leaderboardName:{flex:1,marginLeft:"12px",color:e.foreground},leaderboardStats:{color:e.foregroundSecondary,fontSize:"14px"},leaderboardEmpty:{textAlign:"center",padding:"32px",color:e.foregroundSecondary},referralContainer:{display:"flex",gap:"8px",padding:"8px"},referralInput:{flex:1,padding:"10px 12px",border:`1px solid ${e.inputBorder??e.border}`,borderRadius:"6px",fontSize:"14px",backgroundColor:e.inputBackground??e.backgroundSecondary,color:e.foreground},referralButton:{padding:"10px 16px",border:"none",borderRadius:"6px",backgroundColor:e.buttonBackground??e.primary,color:e.buttonForeground??e.primaryForeground,cursor:"pointer",fontSize:"14px",fontWeight:"500"},tierBadge:{display:"flex",alignItems:"center",gap:"8px",padding:"12px",borderRadius:"8px",marginBottom:"12px"},tierBadgeIcon:{width:"20px",height:"20px"},tierBadgeText:{flex:1},tierBadgeName:{fontWeight:"500",fontSize:"14px"},tierBadgeRate:{fontSize:"12px",opacity:.8},referralCodeRow:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px",backgroundColor:e.backgroundSecondary,borderRadius:"8px",marginBottom:"12px"},referralCodeLabel:{fontSize:"12px",color:e.foregroundSecondary,marginBottom:"2px"},referralCodeValue:{fontFamily:"monospace",fontWeight:"500",fontSize:"14px",color:e.foreground},referralCodeCopyButton:{padding:"6px 10px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:e.foregroundSecondary,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},statsGrid2Col:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"12px",marginBottom:"12px"},earningsBreakdown:{borderTop:`1px solid ${e.border}`,paddingTop:"12px",marginTop:"12px"},earningsTitle:{fontSize:"14px",fontWeight:"500",color:e.foreground,marginBottom:"8px"},earningsRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 0"},earningsLabel:{fontSize:"14px",color:e.foregroundSecondary},earningsValue:{fontFamily:"monospace",fontWeight:"500",fontSize:"14px",color:e.foreground},earningsValueGreen:{fontFamily:"monospace",fontWeight:"500",fontSize:"14px",color:e.success},earningsValueYellow:{fontFamily:"monospace",fontWeight:"500",fontSize:"14px",color:e.warning},medalIcon:{width:"24px",height:"24px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"18px"},referrerSection:{borderTop:`1px solid ${e.border}`,paddingTop:"12px",marginTop:"12px"},referrerTitle:{fontSize:"14px",fontWeight:"500",color:e.foreground,marginBottom:"8px"},referrerBadge:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px",backgroundColor:`${e.success}15`,border:`1px solid ${e.success}30`,borderRadius:"8px"},referrerBadgeInfo:{display:"flex",alignItems:"center",gap:"8px",fontSize:"14px",color:e.foreground},referrerBadgeIcon:{color:e.success},referrerClearButton:{padding:"4px 8px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:e.foregroundSecondary,cursor:"pointer"},referrerInputRow:{display:"flex",gap:"8px",marginBottom:"8px"},referrerDetectButton:{width:"100%",padding:"10px 16px",border:`1px solid ${e.border}`,borderRadius:"6px",backgroundColor:e.backgroundSecondary,color:e.foreground,cursor:"pointer",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},filterTabs:{display:"flex",gap:"8px",marginBottom:"16px"},filterTab:{padding:"6px 12px",fontSize:"12px",borderRadius:"9999px",border:"none",cursor:"pointer",backgroundColor:e.backgroundSecondary,color:e.foregroundSecondary,transition:"all 0.2s"},filterTabActive:{padding:"6px 12px",fontSize:"12px",borderRadius:"9999px",border:"none",cursor:"pointer",backgroundColor:e.primary,color:e.primaryForeground},progressSummary:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px",backgroundColor:e.backgroundSecondary,borderRadius:"8px",marginBottom:"16px"},progressSummaryLeft:{display:"flex",alignItems:"center",gap:"12px"},progressSummaryIcon:{width:"40px",height:"40px",borderRadius:"50%",backgroundColor:`${e.primary}20`,display:"flex",alignItems:"center",justifyContent:"center",color:e.primary,fontSize:"18px"},progressSummaryText:{fontWeight:"500",fontSize:"16px",color:e.foreground},progressSummarySubtext:{fontSize:"12px",color:e.foregroundSecondary},progressSummaryBar:{width:"80px",height:"8px",backgroundColor:e.border,borderRadius:"4px",overflow:"hidden"},progressSummaryBarFill:{height:"100%",backgroundColor:e.primary,borderRadius:"4px"},badgeProgressBar:{width:"100%",height:"4px",backgroundColor:e.border,borderRadius:"2px",overflow:"hidden",marginTop:"8px"},badgeProgressFill:{height:"100%",backgroundColor:e.foregroundSecondary,borderRadius:"2px"},badgeProgressText:{fontSize:"10px",color:e.foregroundSecondary,marginTop:"4px"},badgeCheckmark:{position:"absolute",top:"8px",right:"8px",color:e.success}}}function Be({className:e,style:o,theme:s,autoRefresh:i=true,showTierBadge:d=true,showReferralCode:p=true,showEarningsBreakdown:t=true,renderLoading:a,renderError:n}){let c=V(),u=_(c),{stats:g,loading:m,error:b,refreshStats:C}=K({autoRefresh:i}),[B,I]=Pe.useState(false);if(Pe.useEffect(()=>{i&&C();},[i,C]),m)return a?a():jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px",color:c.foregroundSecondary},children:"Loading..."});if(b)return n?n(b):jsxRuntime.jsx("div",{style:{color:c.error,padding:"16px"},children:b});if(!g||!g.earnings)return null;let k={...u.statsCard,...s?.cardBackground&&{backgroundColor:s.cardBackground},...s?.cardBorder&&{border:`1px solid ${s.cardBorder}`}},P={...u.statsValue,...s?.valueColor&&{color:s.valueColor}},x=f=>new Intl.NumberFormat("en-US",{style:"currency",currency:g.earnings?.currency??"USD"}).format(f/100),v=async()=>{if(g.referralCode)try{await navigator.clipboard.writeText(g.referralCode),I(!0),setTimeout(()=>I(!1),2e3);}catch(f){console.error("Failed to copy:",f);}},h=(f=>{if(!f)return "#6c757d";let z=f.toLowerCase();return z.includes("elite")||z.includes("diamond")||z.includes("platinum")||z.includes("gold")||z.includes("vip")?"#FFD700":z.includes("silver")||z.includes("pro")?"#C0C0C0":z.includes("bronze")||z.includes("starter")?"#CD7F32":"#0d6efd"})(g.tier?.name),y={padding:"16px",...s?.cardBackground&&{backgroundColor:s.cardBackground},...s?.cardBorder&&{border:`1px solid ${s.cardBorder}`},...o};return jsxRuntime.jsxs("div",{className:e,style:y,children:[d&&jsxRuntime.jsxs("div",{style:{...u.tierBadge,backgroundColor:g.tier?`${h}20`:c.backgroundSecondary},children:[jsxRuntime.jsx("span",{style:{...u.tierBadgeIcon,color:h},children:"\u{1F451}"}),jsxRuntime.jsxs("div",{style:u.tierBadgeText,children:[jsxRuntime.jsx("div",{style:{...u.tierBadgeName,color:g.tier?h:c.foregroundSecondary},children:g.tier?`${g.tier.name} Affiliate`:"No Tier"}),jsxRuntime.jsx("div",{style:{...u.tierBadgeRate,color:g.tier?h:c.foregroundSecondary},children:g.tier?`${g.tier.value}% commission rate`:"Refer users to unlock affiliate status"})]})]}),p&&g.referralCode&&jsxRuntime.jsxs("div",{style:u.referralCodeRow,children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:u.referralCodeLabel,children:"Your referral code"}),jsxRuntime.jsx("div",{style:u.referralCodeValue,children:g.referralCode})]}),jsxRuntime.jsx("button",{type:"button",onClick:v,style:u.referralCodeCopyButton,"aria-label":"Copy referral code",children:B?"\u2713":"\u{1F4CB}"})]}),jsxRuntime.jsxs("div",{style:u.statsGrid2Col,children:[jsxRuntime.jsxs("div",{style:k,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",color:c.foregroundSecondary,marginBottom:"4px"},children:[jsxRuntime.jsx("span",{children:"\u{1F465}"}),jsxRuntime.jsx("span",{style:{fontSize:"12px"},children:"Referrals"})]}),jsxRuntime.jsx("div",{style:{...P,fontFamily:"monospace"},children:g.referralCount})]}),jsxRuntime.jsxs("div",{style:k,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",color:c.foregroundSecondary,marginBottom:"4px"},children:[jsxRuntime.jsx("span",{children:"\u{1F4B0}"}),jsxRuntime.jsx("span",{style:{fontSize:"12px"},children:"Commissions"})]}),jsxRuntime.jsx("div",{style:{...P,fontFamily:"monospace"},children:g.earnings.transactionCount})]})]}),t&&jsxRuntime.jsxs("div",{style:u.earningsBreakdown,children:[jsxRuntime.jsx("div",{style:u.earningsTitle,children:"Earnings"}),jsxRuntime.jsxs("div",{style:u.earningsRow,children:[jsxRuntime.jsx("span",{style:u.earningsLabel,children:"Total Earned"}),jsxRuntime.jsx("span",{style:u.earningsValueGreen,children:x(g.earnings.totalEarned)})]}),jsxRuntime.jsxs("div",{style:u.earningsRow,children:[jsxRuntime.jsx("span",{style:u.earningsLabel,children:"Pending"}),jsxRuntime.jsx("span",{style:u.earningsValueYellow,children:x(g.earnings.totalPending)})]}),jsxRuntime.jsxs("div",{style:u.earningsRow,children:[jsxRuntime.jsx("span",{style:u.earningsLabel,children:"Paid Out"}),jsxRuntime.jsx("span",{style:{...u.earningsValue,color:c.foregroundSecondary},children:x(g.earnings.totalPaid)})]})]})]})}var Ie=D(Be);function ze({limit:e=10,className:o,style:s,currentUserId:i,emptyMessage:d="No leaderboard data available yet.",showMedals:p=true,showTierInfo:t=true,showEarnings:a=true,theme:n,renderRow:c,renderLoading:u,renderError:g}){let m=V(),b=_(m),{leaderboard:C,loading:B,error:I,refresh:k}=re(e);if(Pe.useEffect(()=>{k();},[k]),B)return u?u():jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px",color:m.foregroundSecondary},children:"Loading..."});if(I)return g?g(I):jsxRuntime.jsx("div",{style:{color:m.error,padding:"16px"},children:I});if(!C||C.entries.length===0)return jsxRuntime.jsx("div",{className:o,style:{...b.leaderboardEmpty,...s},children:d});let P=f=>{if(!p)return null;switch(f){case 1:return m.medalGold;case 2:return m.medalSilver;case 3:return m.medalBronze;default:return null}},x=f=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(f/100),v=f=>({...f?b.leaderboardRowHighlighted:b.leaderboardRow,...n?.rowBackground&&!f&&{backgroundColor:n.rowBackground},...n?.highlightBackground&&f&&{backgroundColor:n.highlightBackground},...f&&{backgroundColor:`${m.primary}15`,border:`1px solid ${m.primary}40`,borderRadius:"8px"}}),A=n?.textColor?{color:n.textColor}:{},h=n?.secondaryColor?{...b.leaderboardStats,color:n.secondaryColor}:b.leaderboardStats,y=i?C.entries.find(f=>f.userId===i)?.rank:null;return jsxRuntime.jsxs("div",{className:o,style:{...b.leaderboardContainer,...s},children:[y&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:"8px"},children:jsxRuntime.jsxs("span",{style:{fontSize:"12px",backgroundColor:`${m.primary}30`,color:m.primary,padding:"4px 8px",borderRadius:"9999px"},children:["Your rank: #",y]})}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:jsxRuntime.jsx(Y,{mode:"popLayout",children:C.entries.map((f,z)=>{let L=i===f.userId,E=P(f.rank);if(c)return jsxRuntime.jsx("div",{children:c(f,L)},f.userId);let w=jsxRuntime.jsxs("div",{style:v(L),children:[jsxRuntime.jsx("div",{style:b.medalIcon,children:E?jsxRuntime.jsx("span",{style:{color:E},children:"\u{1F3C5}"}):jsxRuntime.jsxs("span",{style:{fontSize:"14px",fontFamily:"monospace",color:m.foregroundSecondary},children:["#",f.rank]})}),jsxRuntime.jsxs("div",{style:{flex:1,marginLeft:"12px"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsxRuntime.jsx("span",{style:{...b.leaderboardName,...A,marginLeft:0},children:f.displayName??`User ${f.userId.slice(0,8)}`}),L&&jsxRuntime.jsx("span",{style:{fontSize:"12px",color:m.primary},children:"(You)"})]}),t&&f.tier&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:m.foregroundSecondary},children:[f.tier.name," (",f.tier.value,"%)"]})]}),jsxRuntime.jsxs("div",{style:{textAlign:"right"},children:[jsxRuntime.jsxs("div",{style:{fontFamily:"monospace",fontSize:"14px",fontWeight:"500",color:m.foreground},children:[f.referralCount," referrals"]}),a&&f.totalEarnings!==void 0&&jsxRuntime.jsx("div",{style:{...h,fontFamily:"monospace"},children:x(f.totalEarnings)})]})]});return Q!=="div"?jsxRuntime.jsx(Q,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{delay:z*.05},children:w},f.userId):jsxRuntime.jsx("div",{children:w},f.userId)})})}),jsxRuntime.jsx("p",{style:{fontSize:"12px",color:"#6c757d",textAlign:"center",marginTop:"12px"},children:"Rankings based on total referrals"})]})}var Te=D(ze);function Ae({baseUrl:e,className:o,style:s,copyButtonText:i="Copy",copiedText:d="Copied!",shareButtonText:p="Share",shareTitle:t="Check this out!",shareText:a="Join using my referral link",showShareButton:n=true,showReferrerAttribution:c=true,referrerCode:u,onSetReferrer:g,onDetectFromUrl:m,onClearReferrer:b,theme:C,onCopy:B,onShare:I}){let k=V(),P=_(k),{stats:x}=K({autoRefresh:true}),[v,A]=Pe.useState(false),[h,y]=Pe.useState(""),f=x?.referralCode;if(!f)return null;let z=typeof window<"u"?window.location.origin:"",L=`${e??z}?ref=${f}`,E=async()=>{try{await navigator.clipboard.writeText(L),A(!0),B?.(L),setTimeout(()=>A(!1),2e3);}catch(U){console.error("Failed to copy:",U);}},w=async()=>{if(typeof navigator<"u"&&navigator.share)try{await navigator.share({title:t,text:a,url:L}),I?.(L);}catch(U){U.name!=="AbortError"&&console.error("Failed to share:",U);}},R=()=>{h.trim()&&g&&(g(h.trim()),y(""));},G=typeof navigator<"u"&&"share"in navigator,j={...P.referralInput,...C?.inputBackground&&{backgroundColor:C.inputBackground},...C?.inputBorder&&{border:`1px solid ${C.inputBorder}`},...C?.inputColor&&{color:C.inputColor}},q={...P.referralButton,...C?.buttonBackground&&{backgroundColor:C.buttonBackground},...C?.buttonColor&&{color:C.buttonColor}},ue={padding:"16px",...s};return jsxRuntime.jsxs("div",{className:o,style:ue,children:[jsxRuntime.jsxs("div",{style:{marginBottom:"8px"},children:[jsxRuntime.jsx("p",{style:{fontSize:"14px",color:k.foregroundSecondary,marginBottom:"8px"},children:"Your unique referral link:"}),jsxRuntime.jsxs("div",{style:P.referralContainer,children:[jsxRuntime.jsx("input",{type:"text",readOnly:true,value:L,style:{...j,fontFamily:"monospace",fontSize:"12px"},onClick:U=>U.target.select()}),jsxRuntime.jsx("button",{type:"button",onClick:E,style:q,children:v?"\u2713":"\u{1F4CB}"}),n&&G&&jsxRuntime.jsx("button",{type:"button",onClick:w,style:q,children:p})]}),jsxRuntime.jsxs("p",{style:{fontSize:"12px",color:k.foregroundSecondary,marginTop:"4px"},children:["Code: ",jsxRuntime.jsx("span",{style:{fontFamily:"monospace",fontWeight:"500",color:k.foreground},children:f})]})]}),c&&jsxRuntime.jsxs("div",{style:P.referrerSection,children:[jsxRuntime.jsx("p",{style:P.referrerTitle,children:"Referrer Attribution"}),u?jsxRuntime.jsxs("div",{style:P.referrerBadge,children:[jsxRuntime.jsxs("div",{style:P.referrerBadgeInfo,children:[jsxRuntime.jsx("span",{style:P.referrerBadgeIcon,children:"\u{1F464}"}),jsxRuntime.jsxs("span",{children:["Referred by: ",jsxRuntime.jsx("span",{style:{fontFamily:"monospace",fontWeight:"500"},children:u})]})]}),b&&jsxRuntime.jsx("button",{type:"button",onClick:b,style:P.referrerClearButton,"aria-label":"Clear referrer",children:"\u2715"})]}):jsxRuntime.jsxs("div",{children:[g&&jsxRuntime.jsxs("div",{style:P.referrerInputRow,children:[jsxRuntime.jsx("input",{type:"text",value:h,onChange:U=>y(U.target.value),placeholder:"Enter referrer code...",style:{...j,fontFamily:"monospace",fontSize:"12px"}}),jsxRuntime.jsx("button",{type:"button",onClick:R,disabled:!h.trim(),style:{...q,opacity:h.trim()?1:.5,cursor:h.trim()?"pointer":"not-allowed"},children:"Set"})]}),m&&jsxRuntime.jsxs("button",{type:"button",onClick:m,style:P.referrerDetectButton,children:[jsxRuntime.jsx("span",{children:"\u{1F517}"}),"Detect from URL"]})]})]})]})}var Le=D(Ae),S={questProgressBar:{width:"100%",height:"8px",backgroundColor:"#e9ecef",borderRadius:"4px",overflow:"hidden",marginBottom:"12px"},questProgressFill:{height:"100%",backgroundColor:"#0d6efd",borderRadius:"4px",transition:"width 0.3s ease"},streakContainer:{display:"flex",alignItems:"center",padding:"16px",backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e9ecef"},streakFlame:{fontSize:"32px",marginRight:"12px"},streakCount:{fontSize:"28px",fontWeight:"bold",color:"#212529",marginRight:"8px"},streakLabel:{fontSize:"14px",color:"#6c757d"},streakInfo:{flex:1},streakName:{fontSize:"16px",fontWeight:"600",color:"#212529"},streakStatus:{fontSize:"12px",padding:"2px 8px",borderRadius:"10px",marginLeft:"8px"},freezeButton:{padding:"8px 16px",border:"none",borderRadius:"6px",backgroundColor:"#17a2b8",color:"white",cursor:"pointer",fontSize:"14px",display:"flex",alignItems:"center",gap:"6px"},freezeButtonDisabled:{padding:"8px 16px",border:"none",borderRadius:"6px",backgroundColor:"#6c757d",color:"white",cursor:"not-allowed",fontSize:"14px",opacity:.6},levelContainer:{padding:"16px",backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e9ecef"},levelHeader:{display:"flex",alignItems:"center",marginBottom:"12px"},levelIcon:{width:"48px",height:"48px",borderRadius:"50%",marginRight:"12px",backgroundColor:"#e9ecef",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"24px"},levelInfo:{flex:1},levelTierName:{fontSize:"18px",fontWeight:"600",color:"#212529"},levelPoints:{fontSize:"14px",color:"#6c757d"},levelProgressContainer:{marginTop:"12px"},levelProgressHeader:{display:"flex",justifyContent:"space-between",marginBottom:"6px",fontSize:"13px"},levelProgressBar:{width:"100%",height:"10px",backgroundColor:"#e9ecef",borderRadius:"5px",overflow:"hidden"},levelProgressFill:{height:"100%",background:"linear-gradient(90deg, #667eea 0%, #764ba2 100%)",borderRadius:"5px",transition:"width 0.3s ease"},levelBenefits:{marginTop:"16px",padding:"12px",backgroundColor:"#f8f9fa",borderRadius:"6px"},levelBenefitsTitle:{fontSize:"14px",fontWeight:"600",color:"#212529",marginBottom:"8px"},levelBenefitsList:{listStyle:"none",padding:0,margin:0,fontSize:"13px",color:"#495057"},levelBenefitItem:{padding:"4px 0",display:"flex",alignItems:"center"},rewardStoreGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"16px",padding:"16px"},rewardCard:{display:"flex",flexDirection:"column",backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e9ecef",overflow:"hidden"},rewardCardUnavailable:{display:"flex",flexDirection:"column",backgroundColor:"#f8f9fa",borderRadius:"8px",border:"1px solid #e9ecef",overflow:"hidden",opacity:.7},rewardImage:{width:"100%",height:"120px",objectFit:"cover",backgroundColor:"#e9ecef"},rewardContent:{padding:"12px",flex:1,display:"flex",flexDirection:"column"},rewardName:{fontSize:"16px",fontWeight:"600",color:"#212529",marginBottom:"4px"},rewardDescription:{fontSize:"13px",color:"#6c757d",marginBottom:"8px",flex:1},rewardCost:{fontSize:"14px",fontWeight:"600",color:"#0d6efd",marginBottom:"8px"},rewardButton:{padding:"10px 16px",border:"none",borderRadius:"6px",backgroundColor:"#0d6efd",color:"white",cursor:"pointer",fontSize:"14px",fontWeight:"500",width:"100%"},rewardButtonDisabled:{padding:"10px 16px",border:"none",borderRadius:"6px",backgroundColor:"#6c757d",color:"white",cursor:"not-allowed",fontSize:"14px",fontWeight:"500",width:"100%"},rewardPointsHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",backgroundColor:"#f8f9fa",borderRadius:"8px",marginBottom:"16px"},rewardPointsLabel:{fontSize:"14px",color:"#6c757d"},rewardPointsValue:{fontSize:"24px",fontWeight:"bold",color:"#212529"},questAccordion:{borderRadius:"8px",overflow:"hidden",marginBottom:"8px"},questAccordionHeader:{width:"100%",padding:"12px",display:"flex",alignItems:"center",gap:"12px",border:"none",backgroundColor:"transparent",cursor:"pointer",textAlign:"left"},questAccordionIcon:{width:"40px",height:"40px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"20px",flexShrink:0},questAccordionInfo:{flex:1,minWidth:0},questAccordionTitle:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},questAccordionName:{fontWeight:"500",fontSize:"14px",color:"#212529"},questAccordionStatusBadge:{fontSize:"11px",padding:"2px 8px",borderRadius:"9999px",fontWeight:"500"},questAccordionMeta:{display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:"#6c757d"},questAccordionChevron:{color:"#6c757d",transition:"transform 0.2s",flexShrink:0},questAccordionContent:{padding:"0 12px 12px",overflow:"hidden"}};function Ne(e){switch(e){case "completed":return {bg:"#d4edda",color:"#155724"};case "in_progress":return {bg:"#cce5ff",color:"#004085"};case "active":return {bg:"#cce5ff",color:"#004085"};case "frozen":return {bg:"#cce5ff",color:"#17a2b8"};case "at_risk":return {bg:"#fff3cd",color:"#856404"};case "broken":return {bg:"#f8d7da",color:"#721c24"};default:return {bg:"#e9ecef",color:"#6c757d"}}}function Ee({questId:e,hideCompleted:o=false,className:s,style:i,expandable:d=true,defaultExpandedId:p,showXpReward:t=true,onComplete:a,theme:n,renderLoading:c,renderError:u,renderQuest:g}){let{quests:m,loading:b,error:C,refresh:B}=te({autoRefresh:true}),I=Pe.useRef(new Map),[k,P]=Pe.useState(null);if(Pe.useEffect(()=>{B();},[B]),Pe.useEffect(()=>{a&&m.forEach(f=>{let z=I.current.get(f.id);z&&z.status!=="completed"&&f.status==="completed"&&a(f);});let y=new Map;m.forEach(f=>y.set(f.id,f)),I.current=y;},[m,a]),Pe.useEffect(()=>{if(m.length>0&&k===null)if(p)P(p);else {let y=m.find(f=>f.status==="in_progress");P(y?.id??null);}},[m,p,k]),b)return c?c():jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px"},children:"Loading..."});if(C)return u?u(C):jsxRuntime.jsx("div",{style:{color:"red",padding:"16px"},children:C});let x=m;if(e&&(x=m.filter(y=>y.id===e)),o&&(x=x.filter(y=>y.status!=="completed")),x.length===0)return jsxRuntime.jsxs("div",{style:{textAlign:"center",padding:"24px",color:"#6c757d"},children:[jsxRuntime.jsx("span",{style:{fontSize:"40px",display:"block",marginBottom:"8px",opacity:.5},children:"\u{1F3AF}"}),jsxRuntime.jsx("p",{children:"No quests available"})]});let v=y=>{switch(y){case "completed":return {backgroundColor:"rgba(40, 167, 69, 0.2)",color:"#28a745"};case "in_progress":return {backgroundColor:"rgba(13, 110, 253, 0.2)",color:"#0d6efd"};default:return {backgroundColor:"#f8f9fa",color:"#6c757d"}}},A=y=>{switch(y){case "completed":return {backgroundColor:"rgba(40, 167, 69, 0.05)",borderColor:"rgba(40, 167, 69, 0.2)"};case "in_progress":return {backgroundColor:"rgba(13, 110, 253, 0.05)",borderColor:"rgba(13, 110, 253, 0.2)"};default:return {backgroundColor:"#f8f9fa",borderColor:"#e9ecef"}}},h=y=>{d&&P(k===y?null:y);};return jsxRuntime.jsx("div",{className:s,style:{...i,display:"flex",flexDirection:"column",gap:"12px"},children:jsxRuntime.jsx(Y,{mode:"popLayout",children:x.map(y=>{if(g)return jsxRuntime.jsx("div",{children:g(y)},y.id);let f=!d||k===y.id,z=v(y.status),L=A(y.status),E=jsxRuntime.jsxs("div",{style:{...S.questAccordion,border:"1px solid",...L,...n?.cardBackground&&{backgroundColor:n.cardBackground},...n?.cardBorder&&{borderColor:n.cardBorder}},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>h(y.id),style:{...S.questAccordionHeader,cursor:d?"pointer":"default"},children:[jsxRuntime.jsx("div",{style:{...S.questAccordionIcon,backgroundColor:y.status==="completed"?"rgba(40, 167, 69, 0.2)":"rgba(13, 110, 253, 0.2)"},children:y.status==="completed"?jsxRuntime.jsx("span",{style:{color:"#28a745"},children:"\u2713"}):jsxRuntime.jsx("span",{style:{color:"#0d6efd"},children:"\u{1F3AF}"})}),jsxRuntime.jsxs("div",{style:S.questAccordionInfo,children:[jsxRuntime.jsxs("div",{style:S.questAccordionTitle,children:[jsxRuntime.jsx("span",{style:{...S.questAccordionName,...n?.textColor&&{color:n.textColor}},children:y.name}),jsxRuntime.jsx("span",{style:{...S.questAccordionStatusBadge,...z},children:y.status==="completed"?"Complete":y.status==="in_progress"?`${y.percentComplete}%`:"Not Started"})]}),jsxRuntime.jsxs("div",{style:S.questAccordionMeta,children:[t&&y.xpReward>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:"\u2B50"}),jsxRuntime.jsxs("span",{children:["+",y.xpReward," XP"]}),jsxRuntime.jsx("span",{style:{color:"#e9ecef"},children:"|"})]}),jsxRuntime.jsxs("span",{children:[y.steps.length," steps"]})]})]}),d&&jsxRuntime.jsx("span",{style:{...S.questAccordionChevron,transform:f?"rotate(90deg)":"rotate(0deg)"},children:"\u25B6"})]}),f&&jsxRuntime.jsxs("div",{style:S.questAccordionContent,children:[y.status!=="completed"&&jsxRuntime.jsx("div",{style:{...S.questProgressBar,marginBottom:"12px",height:"6px"},children:jsxRuntime.jsx("div",{style:{...S.questProgressFill,width:`${y.percentComplete}%`,...n?.progressColor&&{backgroundColor:n.progressColor}}})}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:y.steps.map((w,R)=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"8px",borderRadius:"6px",opacity:w.completed?.6:1},children:[jsxRuntime.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"bold",flexShrink:0,backgroundColor:w.completed?"rgba(40, 167, 69, 0.2)":"#f8f9fa",color:w.completed?"#28a745":"#6c757d"},children:w.completed?"\u2713":R+1}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:"14px",fontWeight:"500",textDecoration:w.completed?"line-through":"none",color:w.completed?"#6c757d":"#212529"},children:w.name}),jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6c757d"},children:[w.currentCount,"/",w.requiredCount,w.requiredCount>1&&!w.completed&&jsxRuntime.jsxs("span",{style:{marginLeft:"8px"},children:["(",Math.round(w.currentCount/w.requiredCount*100),"%)"]})]})]})]},w.id))})]})]});return Q!=="div"?jsxRuntime.jsx(Q,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},children:E},y.id):jsxRuntime.jsx("div",{children:E},y.id)})})})}var Fe=D(Ee);function We({ruleId:e,size:o="md",showFreezeButton:s=true,className:i,style:d,onFreeze:p,theme:t,renderLoading:a,renderError:n}){let{streaks:c,stats:u,loading:g,error:m,freeze:b,refresh:C}=oe({autoRefresh:true}),[B,I]=Pe.useState(false);if(Pe.useEffect(()=>{C();},[C]),g)return a?a():jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px"},children:"Loading..."});if(m)return n?n(m):jsxRuntime.jsx("div",{style:{color:"red",padding:"16px"},children:m});let k=c;if(e&&(k=c.filter(v=>v.id===e)),k.length===0)return jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px",color:"#6c757d"},children:"No streaks available"});let P={sm:{flame:"24px",count:"20px",container:"12px"},md:{flame:"32px",count:"28px",container:"16px"},lg:{flame:"48px",count:"40px",container:"20px"}},x=async v=>{I(true);try{let A=await b(v);A&&p&&p(v,A.remainingFreezes);}finally{I(false);}};return jsxRuntime.jsx("div",{className:i,style:d,children:k.map(v=>{let A=Ne(v.status),h=v.freezeInventory>0&&!v.freezeUsedToday;return jsxRuntime.jsxs("div",{style:{...S.streakContainer,padding:P[o].container,...t?.cardBackground&&{backgroundColor:t.cardBackground}},children:[jsxRuntime.jsx("span",{style:{...S.streakFlame,fontSize:P[o].flame,...t?.flameColor&&{color:t.flameColor}},children:"\u{1F525}"}),jsxRuntime.jsx("span",{style:{...S.streakCount,fontSize:P[o].count,...t?.countColor&&{color:t.countColor}},children:v.currentCount}),jsxRuntime.jsxs("div",{style:S.streakInfo,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jsxRuntime.jsx("span",{style:S.streakName,children:v.name}),jsxRuntime.jsx("span",{style:{...S.streakStatus,backgroundColor:A.bg,color:A.color},children:v.status})]}),jsxRuntime.jsxs("span",{style:S.streakLabel,children:["Best: ",v.maxStreak," days"]})]}),s&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{x(v.id);},disabled:!h||B,style:h?S.freezeButton:S.freezeButtonDisabled,children:[jsxRuntime.jsx("span",{children:"\u2744\uFE0F"}),jsxRuntime.jsx("span",{children:v.freezeInventory})]})]},v.id)})})}var Ge=D(We);function Ue({showLocked:e=true,category:o,columns:s=2,className:i,style:d,showProgressSummary:p=true,showFilterTabs:t=true,showStats:a,onBadgeClick:n,theme:c,renderLoading:u,renderError:g,renderBadge:m}){let b=V(),C=_(b),{badges:B,stats:I,loading:k,error:P,refresh:x}=ne({autoRefresh:true,category:o}),[v,A]=Pe.useState("all"),h=p??a??true;if(Pe.useEffect(()=>{x(o);},[x,o]),k)return u?u():jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px",color:b.foregroundSecondary},children:"Loading..."});if(P)return g?g(P):jsxRuntime.jsx("div",{style:{color:b.error,padding:"16px"},children:P});let y=B;v==="unlocked"?y=B.filter(R=>R.isUnlocked):v==="locked"?y=B.filter(R=>!R.isUnlocked):e||(y=B.filter(R=>R.isUnlocked));let f=R=>{switch(R){case "LEGENDARY":return {color:b.rarityLegendary,bg:`${b.rarityLegendary}15`};case "EPIC":return {color:b.rarityEpic,bg:`${b.rarityEpic}15`};case "RARE":return {color:b.rarityRare,bg:`${b.rarityRare}15`};case "COMMON":default:return {color:b.rarityCommon,bg:`${b.rarityCommon}15`}}},z={display:"grid",gridTemplateColumns:`repeat(${s}, 1fr)`,gap:"12px",padding:"0"},L=I?.unlocked??B.filter(R=>R.isUnlocked).length,E=I?.total??B.length,w=E>0?L/E*100:0;return jsxRuntime.jsxs("div",{className:i,style:{...d,padding:"16px"},children:[h&&jsxRuntime.jsxs("div",{style:C.progressSummary,children:[jsxRuntime.jsxs("div",{style:C.progressSummaryLeft,children:[jsxRuntime.jsx("div",{style:C.progressSummaryIcon,children:"\u2728"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{style:C.progressSummaryText,children:[L," / ",E]}),jsxRuntime.jsx("div",{style:C.progressSummarySubtext,children:"Badges Earned"})]})]}),jsxRuntime.jsx("div",{style:C.progressSummaryBar,children:jsxRuntime.jsx("div",{style:{...C.progressSummaryBarFill,width:`${w}%`}})})]}),t&&jsxRuntime.jsx("div",{style:C.filterTabs,children:["all","unlocked","locked"].map(R=>jsxRuntime.jsx("button",{type:"button",onClick:()=>A(R),style:v===R?C.filterTabActive:C.filterTab,children:R==="all"?"All":R==="unlocked"?"Earned":"Locked"},R))}),jsxRuntime.jsx("div",{style:z,children:jsxRuntime.jsx(Y,{mode:"popLayout",children:y.map(R=>{if(m)return jsxRuntime.jsx("div",{children:m(R)},R.id);let G=f(R.rarity),j=jsxRuntime.jsxs("div",{style:{position:"relative",padding:"12px",borderRadius:"8px",border:"1px solid",cursor:n?"pointer":"default",transition:"all 0.2s",...R.isUnlocked?{backgroundColor:G.bg,borderColor:`${G.color}40`,...c?.cardBackground&&{backgroundColor:c.cardBackground},...c?.cardBorder&&{borderColor:c.cardBorder}}:{backgroundColor:b.backgroundSecondary,borderColor:b.border,opacity:.6}},onClick:()=>n?.(R),onKeyDown:q=>q.key==="Enter"&&n?.(R),role:n?"button":void 0,tabIndex:n?0:void 0,children:[R.isUnlocked&&jsxRuntime.jsx("div",{style:C.badgeCheckmark,children:"\u2713"}),jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},children:jsxRuntime.jsx("div",{style:{width:"32px",height:"32px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:R.isUnlocked?`${G.color}20`:b.backgroundSecondary},children:R.iconUrl?jsxRuntime.jsx("img",{src:R.iconUrl,alt:R.name,style:{width:"16px",height:"16px",objectFit:"contain"}}):R.isUnlocked?jsxRuntime.jsx("span",{style:{color:G.color},children:"\u{1F3C5}"}):jsxRuntime.jsx("span",{style:{color:b.foregroundSecondary},children:"\u{1F512}"})})}),jsxRuntime.jsx("h4",{style:{fontSize:"14px",fontWeight:"500",marginBottom:"4px",color:b.foreground},children:R.name}),R.description&&jsxRuntime.jsx("p",{style:{fontSize:"12px",color:b.foregroundSecondary,marginBottom:"8px",lineHeight:1.4},children:R.description}),jsxRuntime.jsx("span",{style:{fontSize:"10px",padding:"2px 6px",borderRadius:"9999px",fontWeight:"500",backgroundColor:`${G.color}20`,color:G.color},children:R.rarity})]});return Q!=="div"?jsxRuntime.jsx(Q,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},children:j},R.id):jsxRuntime.jsx("div",{children:j},R.id)})})}),y.length===0&&jsxRuntime.jsxs("div",{style:{textAlign:"center",padding:"24px",color:"#6c757d"},children:[jsxRuntime.jsx("span",{style:{fontSize:"40px",display:"block",marginBottom:"8px",opacity:.5},children:"\u{1F3C5}"}),jsxRuntime.jsx("p",{children:"No badges found"})]})]})}var De=D(Ue);function Me({showNextTier:e=true,showBenefits:o=false,className:s,style:i,theme:d,renderLoading:p,renderError:t}){let{profile:a,loading:n,error:c,refreshProfile:u}=ee({autoRefresh:true});if(Pe.useEffect(()=>{u();},[u]),n)return p?p():jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px"},children:"Loading..."});if(c)return t?t(c):jsxRuntime.jsx("div",{style:{color:"red",padding:"16px"},children:c});if(!a)return null;let g=a.nextTier?Math.min(100,a.points/a.nextTier.minPoints*100):100,m={...S.levelContainer,...d?.cardBackground&&{backgroundColor:d.cardBackground}},b={...S.levelProgressFill,width:`${g}%`,...d?.progressGradient&&{background:d.progressGradient}};return jsxRuntime.jsxs("div",{className:s,style:{...m,...i},children:[jsxRuntime.jsxs("div",{style:S.levelHeader,children:[jsxRuntime.jsx("div",{style:{...S.levelIcon,...a.tier?.color&&{backgroundColor:a.tier.color}},children:a.tier?.iconUrl?jsxRuntime.jsx("img",{src:a.tier.iconUrl,alt:a.tier.name,style:{width:"100%",height:"100%",borderRadius:"50%"}}):"\u2B50"}),jsxRuntime.jsxs("div",{style:S.levelInfo,children:[jsxRuntime.jsx("div",{style:{...S.levelTierName,...d?.textColor&&{color:d.textColor}},children:a.tier?.name??"No Tier"}),jsxRuntime.jsxs("div",{style:S.levelPoints,children:[a.points.toLocaleString()," points"]})]})]}),e&&a.nextTier&&jsxRuntime.jsxs("div",{style:S.levelProgressContainer,children:[jsxRuntime.jsxs("div",{style:S.levelProgressHeader,children:[jsxRuntime.jsxs("span",{style:{color:"#6c757d"},children:["Progress to ",a.nextTier.name]}),jsxRuntime.jsxs("span",{style:{fontWeight:"500"},children:[a.nextTier.pointsNeeded.toLocaleString()," points needed"]})]}),jsxRuntime.jsx("div",{style:S.levelProgressBar,children:jsxRuntime.jsx("div",{style:b})})]}),o&&a.tier?.benefits&&Object.keys(a.tier.benefits).length>0&&jsxRuntime.jsxs("div",{style:S.levelBenefits,children:[jsxRuntime.jsx("div",{style:S.levelBenefitsTitle,children:"Your Benefits"}),jsxRuntime.jsx("ul",{style:S.levelBenefitsList,children:Object.entries(a.tier.benefits).map(([C,B])=>jsxRuntime.jsxs("li",{style:S.levelBenefitItem,children:[jsxRuntime.jsx("span",{style:{marginRight:"8px",color:"#28a745"},children:"\u2713"}),String(B)]},C))})]})]})}var $e=D(Me);function Qe({showUnavailable:e=true,className:o,style:s,showPointsHeader:i=true,onRedeem:d,theme:p,renderLoading:t,renderError:a,renderItem:n}){let{items:c,userPoints:u,loading:g,error:m,redeem:b,refresh:C}=ae({autoRefresh:true}),[B,I]=Pe.useState(null);if(Pe.useEffect(()=>{C();},[C]),g&&c.length===0)return t?t():jsxRuntime.jsx("div",{style:{textAlign:"center",padding:"16px"},children:"Loading..."});if(m)return a?a(m):jsxRuntime.jsx("div",{style:{color:"red",padding:"16px"},children:m});let k=c;e||(k=c.filter(x=>x.isAvailable));let P=async x=>{I(x.id);try{let v=await b(x.id);v&&d&&d(x,v);}finally{I(null);}};return jsxRuntime.jsxs("div",{className:o,style:s,children:[i&&jsxRuntime.jsxs("div",{style:S.rewardPointsHeader,children:[jsxRuntime.jsx("span",{style:S.rewardPointsLabel,children:"Your Points"}),jsxRuntime.jsx("span",{style:S.rewardPointsValue,children:u.toLocaleString()})]}),jsxRuntime.jsx("div",{style:S.rewardStoreGrid,children:k.map(x=>{if(n)return jsxRuntime.jsx("div",{children:n(x,()=>{P(x);})},x.id);let v=x.isAvailable?{...S.rewardCard,...p?.cardBackground&&{backgroundColor:p.cardBackground}}:S.rewardCardUnavailable,A=x.isAvailable&&x.canAfford?{...S.rewardButton,...p?.buttonColor&&{backgroundColor:p.buttonColor}}:S.rewardButtonDisabled,h=B===x.id;return jsxRuntime.jsxs("div",{style:v,children:[x.imageUrl?jsxRuntime.jsx("img",{src:x.imageUrl,alt:x.name,style:S.rewardImage}):jsxRuntime.jsx("div",{style:{...S.rewardImage,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"32px"},children:"\u{1F381}"}),jsxRuntime.jsxs("div",{style:S.rewardContent,children:[jsxRuntime.jsx("span",{style:S.rewardName,children:x.name}),x.description&&jsxRuntime.jsx("span",{style:S.rewardDescription,children:x.description}),jsxRuntime.jsxs("span",{style:S.rewardCost,children:[x.pointsCost.toLocaleString()," points"]}),x.requiredBadgeName&&!x.hasBadge&&jsxRuntime.jsxs("span",{style:{fontSize:"12px",color:"#dc3545",marginBottom:"8px"},children:["Requires: ",x.requiredBadgeName]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{P(x);},disabled:!x.isAvailable||!x.canAfford||h,style:A,children:h?"Redeeming...":x.canAfford?"Redeem":`Need ${(x.pointsCost-u).toLocaleString()} more`})]})]},x.id)})})]})}var qe=D(Qe);Object.defineProperty(exports,"defaultTheme",{enumerable:true,get:function(){return core.defaultTheme}});exports.AffiliateStats=Ie;exports.BadgeGrid=De;exports.GamifyPageView=he;exports.GamifyProvider=me;exports.GamifyTrackClick=we;exports.Leaderboard=Te;exports.LevelProgress=$e;exports.QuestProgress=Fe;exports.ReferralLink=Le;exports.RewardStore=qe;exports.StreakFlame=Ge;exports.useAffiliateStats=K;exports.useBadges=ne;exports.useGamify=be;exports.useGamifyTheme=V;exports.useIdentify=Ce;exports.useLeaderboard=re;exports.useLoyalty=ee;exports.useQuests=te;exports.useReferral=ve;exports.useRewards=ae;exports.useSession=Re;exports.useStreaks=oe;exports.useTrack=H;//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map