1import{j as e,r as t,p as y,a0 as F,w as S,I as k,t as V,q as B,d as W,N as J,O as E,X as O}from"./index-CfXbMZ_V.js";import{T as Y}from"./trophy-_S3qT1ih.js";import{S as G,a as X,b as K,c as Q,d as _}from"./select-BB6bDIs2.js";import{C as M}from"./circle-check-big-9H_erV8K.js";import{U}from"./user-check-CrV4BRs2.js";import{S as Z}from"./send-D6RIih1c.js";import{C as ee}from"./clock-DmU1_sat.js";import{c as z}from"./confetti.module-oQXWb4Lk.js";import"./index-BU0D2mz3.js";function se(a,s=800){const[n,d]=t.useState(0),x=t.useRef(0);return t.useEffect(()=>{const m=x.current,i=performance.now();let u;const o=b=>{const h=Math.min(1,(b-i)/s),g=1-Math.pow(1-h,3);d(Math.round(m+(a-m)*g)),h<1?u=requestAnimationFrame(o):x.current=a};return u=requestAnimationFrame(o),()=>cancelAnimationFrame(u)},[a,s]),n}function te({balance:a}){const s=se(a||0);return e.jsxs("div",{className:"bg-gradient-to-br from-blue-600 to-cyan-500 rounded-3xl p-6 text-white shadow-lg shadow-blue-200/50",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 rounded-2xl flex items-center justify-center",children:e.jsx(Y,{size:26,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-blue-100 text-sm font-medium",children:"Your Rewards"}),e.jsx("h2",{className:"text-lg font-bold",children:"Current Balance"})]})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("span",{className:"text-5xl font-extrabold tabular-nums leading-none",children:s.toLocaleString()}),e.jsx("span",{className:"text-lg font-semibold text-blue-100 mb-1",children:"Points"})]}),e.jsx("p",{className:"text-blue-100 text-xs mt-5 leading-relaxed",children:"Earn points by inviting your friends to TaxEase360. Your points can be redeemed as Reward Value on eligible accounting services with participating accountants."})]})}function ae({balance:a,onClaimed:s}){const[n,d]=t.useState(null),[x,m]=t.useState("Individual Tax Return"),[i,u]=t.useState(""),[o,b]=t.useState(!1),[h,g]=t.useState(!1),[v,l]=t.useState(""),[r,f]=t.useState(null),[p,c]=t.useState(""),[R,$]=t.useState("");t.useEffect(()=>{(async()=>{const j=await y.entities.RewardConfig.list("-created_date",1);d(j[0]||{points_per_dollar:20,max_reward_per_transaction:20});try{const C=await y.auth.me(),w=(await y.entities.Client.filter({user_id:C.id}))[0];f(!!(w!=null&&w.franchisee_id||w!=null&&w.assigned_accountant))}catch{f(!1)}})()},[]);const D=(n==null?void 0:n.points_per_dollar)||20,A=(n==null?void 0:n.max_reward_per_transaction)||20,T=Math.round((Number(i)||0)*D),q=r||p.trim()&&R.trim(),I=Number(i)>0&&T<=a&&Number(i)<=A&&q,H=async()=>{var j,C;if(!I){l("Check the amount, your points balance, and accountant details");return}b(!0),l("");try{await y.functions.invoke("createRedemptionClaim",{service_type:x,reward_value_applied:Number(i),accountant_name:r?"":p.trim(),accountant_email:r?"":R.trim()}),g(!0),u(""),s==null||s()}catch(N){l(((C=(j=N==null?void 0:N.response)==null?void 0:j.data)==null?void 0:C.error)||(N==null?void 0:N.message)||"Could not submit claim")}finally{b(!1)}},L=()=>{g(!1),l("")};return e.jsxs("div",{className:"bg-white rounded-3xl border border-gray-100 shadow-sm p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-emerald-600 rounded-2xl flex items-center justify-center",children:e.jsx(F,{size:20,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-bold text-gray-800",children:"Claim Reward Value"}),e.jsx("p",{className:"text-xs text-gray-400 font-medium",children:"Use your points as a discount on eligible services"})]})]}),h?e.jsxs("div",{className:"flex items-center gap-2 bg-green-50 rounded-2xl p-3 text-sm text-green-700",children:[e.jsx(M,{size:18,className:"shrink-0"}),e.jsx("span",{className:"flex-1",children:"Claim submitted! Your accountant will review and approve it."}),e.jsx("button",{onClick:L,className:"text-emerald-600 font-semibold text-xs shrink-0",children:"New claim"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{children:"Service"}),e.jsxs(G,{value:x,onValueChange:m,children:[e.jsx(X,{children:e.jsx(K,{})}),e.jsxs(Q,{children:[e.jsx(_,{value:"Individual Tax Return",children:"Discount on Tax Return"}),e.jsx(_,{value:"Business Tax Return",children:"Business Tax Return"}),e.jsx(_,{value:"BAS",children:"BAS"}),e.jsx(_,{value:"Bookkeeping",children:"Bookkeeping"}
1),e.jsx(_,{value:"Advisory",children:"Advisory"})]})]})]}),r===!1&&e.jsxs("div",{className:"space-y-2 bg-amber-50 border border-amber-200 rounded-2xl p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-700",children:[e.jsx(U,{size:15}),e.jsx("p",{className:"text-xs font-semibold",children:"No accountant linked yet"})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"Enter your accountant's details so we can send them your Reward Value."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{children:"Accountant Name"}),e.jsx(k,{value:p,onChange:j=>c(j.target.value),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{children:"Accountant Email"}),e.jsx(k,{type:"email",value:R,onChange:j=>$(j.target.value),placeholder:"[email protected]"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{children:"Reward Value to Use ($)"}),e.jsx(k,{type:"number",value:i,onChange:j=>u(j.target.value),placeholder:"5"}),e.jsxs("p",{className:"text-xs text-gray-400",children:["Max $",A," per claim · ",T," points needed · you have ",a," points"]})]}),v&&e.jsx("p",{className:"text-sm text-red-600",children:v}),e.jsx(V,{onClick:H,disabled:o||!I,className:"w-full bg-emerald-600 hover:bg-emerald-700",children:o?e.jsxs(e.Fragment,{children:[e.jsx(B,{size:16,className:"animate-spin mr-2"}),"Submittingâ¦"]}):"Submit Claim"})]})]})}function ne({onReferred:a}){const[s,n]=t.useState(""),[d,x]=t.useState(""),[m,i]=t.useState(!1),[u,o]=t.useState(""),[b,h]=t.useState(!1),g=async()=>{var f,p;const l=s.trim(),r=d.trim();if(!l){o("Enter your friend's name");return}if(!r||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r)){o("Enter a valid email");return}i(!0),o("");try{await y.functions.invoke("submitReferral",{friend_name:l,friend_email:r}),h(!0),a==null||a()}catch(c){o(((p=(f=c==null?void 0:c.response)==null?void 0:f.data)==null?void 0:p.error)||(c==null?void 0:c.message)||"Could not send invitation")}finally{i(!1)}},v=()=>{h(!1),n(""),x(""),o("")};return e.jsxs("div",{className:"bg-white rounded-3xl border border-gray-100 shadow-sm p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-600 rounded-2xl flex items-center justify-center",children:e.jsx(F,{size:20,className:"text-cyan-300"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-bold text-gray-800",children:"Refer a Friend"}),e.jsx("p",{className:"text-xs text-gray-400 font-medium",children:"Earn 100 Points"})]})]}),e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed",children:"Invite your friends to join TaxEase360. When your friend successfully creates a TaxEase360 account using your invitation, you'll automatically receive:"}),e.jsxs("div",{className:"bg-blue-50 rounded-2xl p-3 flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl font-extrabold text-blue-700",children:"+100"}),e.jsxs("span",{className:"text-sm text-gray-600",children:["Points = ",e.jsx("strong",{className:"text-gray-800",children:"$5 Reward Value"})]})]}),e.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Your Reward Value can be redeemed on eligible accounting services with participating accountants."}),b?e.jsxs("div",{className:"flex items-center gap-2 bg-green-50 rounded-2xl p-3 text-sm text-green-700",children:[e.jsx(M,{size:18,className:"shrink-0"}),e.jsxs("span",{className:"flex-1",children:["Invitation sent to ",e.jsx("strong",{children:d})]}),e.jsx("button",{onClick:v,className:"text-blue-600 font-semibold text-xs shrink-0",children:"Refer another"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{children:"Friend's Name"}),e.jsx(k,{value:s,onChange:l=>n(l.target.value),placeholder:"Jane Doe"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{children:"Friend's Email Address"}),e.jsx(k,{type:"email",value:d,onChange:l=>x(l.target.value),placeholder:"[email protected]"})]}),u&&e.jsx("p",{className:"text-sm text-red-600",children:u}),e.jsx(V,{onClick:g,disabled:m,className:"w-full bg-blue-600 hover:bg-blue-700",children:m?e.jsxs(e.Fragment,{children:[e.jsx(B,{size:16,className:"animate-spin mr-2"})," Sendingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{size:16,className:"mr-2"})," Send Invitation"]})})]})]})}
1const P={pending:{label:"Pending",dot:"bg-amber-400",text:"text-amber-600",Icon:ee},joined:{label:"Joined",dot:"bg-blue-500",text:"text-blue-600",Icon:U},reward_earned:{label:"Reward Earned",dot:"bg-green-500",text:"text-green-600",Icon:Y}};function re({referrals:a}){return e.jsxs("div",{className:"bg-white rounded-3xl border border-gray-100 shadow-sm p-5",children:[e.jsx("h3",{className:"text-base font-bold text-gray-800 mb-3",children:"Your Referrals"}),a.length===0?e.jsx("p",{className:"text-sm text-gray-400 text-center py-6",children:"No referrals yet. Invite your first friend above."}):e.jsx("div",{className:"space-y-2",children:a.map(s=>{const n=P[s.referral_status]||P.pending;return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 rounded-2xl",children:[e.jsx("div",{className:"w-10 h-10 bg-white rounded-full flex items-center justify-center shrink-0 shadow-sm",children:e.jsx(n.Icon,{size:18,className:n.text})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-800 truncate",children:s.friend_name||s.friend_email}),e.jsx("p",{className:"text-xs text-gray-400 truncate",children:s.friend_email})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs font-semibold ${n.text}`,children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${n.dot}`}),n.label]}),s.referral_status==="reward_earned"&&e.jsxs("p",{className:"text-xs text-green-600 font-bold mt-0.5",children:["+",s.points," Points"]})]})]},s.id)})})]})}const ie=["Invite your friends to join TaxEase360.","When your friend successfully creates a TaxEase360 account, you'll receive 100 points.","100 Points = $5 Reward Value.","Redeem your Reward Value on eligible accounting services with participating accountants.","More ways to earn and redeem points will be added in future updates."];function le(){return e.jsxs("div",{className:"bg-white rounded-3xl border border-gray-100 shadow-sm p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-cyan-100 rounded-2xl flex items-center justify-center",children:e.jsx(W,{size:20,className:"text-cyan-600"})}),e.jsx("h3",{className:"text-base font-bold text-gray-800",children:"How It Works"})]}),e.jsx("ol",{className:"space-y-3",children:ie.map((a,s)=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"w-6 h-6 rounded-full bg-blue-600 text-white text-xs font-bold flex items-center justify-center shrink-0 mt-0.5",children:s+1}),e.jsx("span",{className:"text-sm text-gray-600 leading-relaxed",children:a})]},s))})]})}function ce({open:a,points:s,onClose:n}){return t.useEffect(()=>{if(!a)return;const x=Date.now()+1800,m=["#2563eb","#06b6d4","#22c55e"],i=()=>{z({particleCount:4,angle:60,spread:70,origin:{x:0},colors:m}),z({particleCount:4,angle:120,spread:70,origin:{x:1},colors:m}),Date.now()<x&&requestAnimationFrame(i)};i()},[a]),e.jsx(J,{children:a&&e.jsx(E.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},onClick:n,className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-6",children:e.jsxs(E.div,{initial:{scale:.85,y:20,opacity:0},animate:{scale:1,y:0,opacity:1},exit:{scale:.85,y:20,opacity:0},transition:{type:"spring",stiffness:260,damping:20},onClick:d=>d.stopPropagation(),className:"relative bg-white rounded-3xl p-8 max-w-sm w-full text-center shadow-2xl",children:[e.jsx("button",{onClick:n,className:"absolute top-3 right-3 text-gray-400 hover:text-gray-600","aria-label":"Close",children:e.jsx(O,{size:20})}),e.jsx(E.div,{initial:{scale:0,rotate:-20},animate:{scale:1,rotate:0},transition:{delay:.1,type:"spring",stiffness:200},className:"text-5xl mb-3",children:"ð"}),e.jsx("h2",{className:"text-xl font-bold text-gray-900",children:"Congratulations!"}),e.jsxs("p",{className:"text-sm text-gray-600 mt-1",children:["You've earned ",e.jsxs("strong",{className:"text-blue-600",children:[s," Points"]}),"!"]}),e.jsx("p",{className:"text-xs text-gray-400 mt-2 leading-relaxed",children:"Your friend joined TaxEase360. Your reward has been added to your balance."}),e.jsx("button",{onClick:n,className:"mt-5 w-full bg-blue-600 hover:bg-blue-700 text-white rounded-xl py-3 text-sm font-semibold",children:"Awesome!"})]})})})}function ge(){const[a,s]=t.useState(null),[n,d]=t.useState([]),[x,m]=t.useState(!0),[i,u]=t.useState(!1),[o,b]=t.useState(0),h=t.useCallback(async r=>y.entities.Reward.filter({owner_user_id:r},"-created_date",500),[]);t.useEffect(()=>{(async()=>{const r=await y.auth.me();s(r);let f=await h(r.id);try{const p=await y.functions.invoke("syncReferralRewards",{}),c=(p==null?void 0:p.data)??p;(c==null?void 0:c.newlyEarned)>0&&(b(c.newlyEarned*(c.pointsEach||100)),u(!0),f=await h(r.id))}catch{}d(f),m(!1)})()},[h]);const g=n.reduce((r,f)=>r+(f.points||0),0),v=n.filter(r=>r.activity_type==="referral"),l=async()=>{a&&d(await h(a.id))};return x?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"w-8 h-8 border-4 border-blue-200 border-t-blue-600 rounded-full animate-spin"})}):e.jsxs("div",{className:"space-y-5 pb-8",children:[e.jsx(ce,{open:i,points:o,onClose:()=>u(!1)}),e.jsx(te,{balance:g}),e.jsx(ae,{balance:g,onClaimed:l}),e.jsx(ne,{onReferred:l}),e.jsx(re,{referrals:v}),e.jsx(le,{})]})}export{ge as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.