@gamifyio/react 0.1.4 → 0.1.6

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