1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CR8jIHGL.js","assets/index-UrNtwQ3U.css"])))=>i.map(i=>d[i]); 2import{j as e,u as lt,r as o,m as j,A as dt,d as _,s as L,_ as mt}from"./index-CR8jIHGL.js";import{v as ut}from"./recipientValidation-D21b1IsT.js";import{A as $e,w as ze,W as xt,v as pt}from"./walletId-DNSBuUjj.js";import{p as ft}from"./cashoutQrPayload-CxCPsq4N.js";import{u as ht}from"./use-fee-config-DsXIF0nu.js";import{b as gt}from"./permissions-CQjybjgl.js";import{haptics as P}from"./haptics-YKMSwVex.js";import{fireSuccessConfetti as bt}from"./confetti-zcttjeaJ.js";import{g as jt,t as yt}from"./balanceStore-MOHZ5Zc2.js";import{v as Nt}from"./verifyPin-DFbbL5Ko.js";import{D as vt,c as wt}from"./DailyLimitBadge-CcOp0vV_.js";import{u as St,a as Ct,s as At}from"./Index-Dhox3xuJ.js";import{g as Ft,c as Me,a as Ve,r as _t}from"./couponStore-DPu18nem.js";import{S as Lt}from"./SlideToConfirm-o2rnFqgQ.js";import{T as It}from"./textarea-zwKlMF9-.js";import{S as kt}from"./ShareReceiptSheet-CAF-XW8N.js";import{A as Et}from"./AvailableBalanceBadge-BCF-JYuD.js";import{I as Ue}from"./input-CBgH9T9i.js";import Tt from"./QrScannerModal-Bd3DbmSy.js";import{F as Rt}from"./FeatureGuard-DXb_Akz0.js";import{F as Pt}from"./FeatureLockedOverlay-vL4jAso9.js";import{C as Ot,a as Ge}from"./CouponSummaryLine-DzzGWVkZ.js";import{C as We}from"./chevron-left-DZq2ZXKa.js";import{H as Dt}from"./hash-ZdgtTrYN.js";import{Q as Bt}from"./qr-code-C63N5yIq.js";import{C as se}from"./circle-alert-zn_RedqF.js";import{M as ue}from"./map-pin-BnxY2z23.js";import{S as $t}from"./search-DJ1zHrUy.js";import{U as zt}from"./users-DCvaygis.js";import{S as xe}from"./star-CavHq7AB.js";import{S as pe}from"./store-BOAr6QMl.js";import{L as Mt}from"./landmark-R__bgf9j.js";import{C as Vt}from"./circle-check-FO8rVln-.js";import"./qrParser-yVSsZLBI.js";import"./auth-BUl0x90n.js";import"./trending-up-nG-rI339.js";import"./Seo-Bvm9iGRd.js";import"./inboxStore-Dnh7ajfl.js";import"./layout-dashboard-C8dNY4wG.js";import"./scan-line-Bcnz1Fq_.js";import"./message-circle-BFV6bADS.js";import"./QuickActionIcons-Bfdxm-Ke.js";import"./zap-DXS-ko3H.js";import"./shield-KEBAwAUq.js";import"./wifi-Bp8qGX8q.js";import"./download-BS5NsxsA.js";import"./smartphone-c2wtxeoU.js";import"./use-kyc-status-C_EIRkSt.js";import"./use-future-features-DxzIzt2r.js";import"./use-global-toggles-DRkl9geA.js";import"./check-check-DPiogBoc.js";import"./trash-2-Cso3Gx0t.js";import"./truck-BY32-zuT.js";import"./moon-DXOQ7ZN4.js";import"./formatDistanceToNow-CY-m9BAl.js";import"./constructNow-Ce5XvxA3.js";import"./format-CZost_lC.js";import"./differenceInCalendarMonths-CoHaFYIE.js";import"./endOfDay-DATwVblq.js";import"./endOfMonth-DxzTWKNN.js";import"./coins-DezmEdR3.js";import"./gift-BiP0Sbiv.js";import"./copy-CBCwGpHF.js";import"./external-link-B3Et6MzL.js";import"./tag-DLAqt58P.js";import"./arrow-up-right-D1gM8AWu.js";import"./sun-B8cobErW.js";import"./UserQrModal-AtMK0CgU.js";import"./browser-JP79f-a9.js";import"./use-profile-C88j7IAK.js";import"./share-2-k_mGH8kF.js";import"./printer-CePELZYh.js";import"./index-BZMZauxs.js";import"./eye-off-HKMF2PNY.js";import"./eye-DgDkV2gx.js";import"./TransactionStatusTimeline-BMbr3wZd.js";import"./rotate-ccw-Dw05o2mg.js";import"./clock-BRuMITIk.js";import"./circle-x-tD4ABO1B.js";import"./send-D1X2wYJv.js";import"./circle-dot-D-m8Z08O.js";import"./use-customization-BHtAxjNj.js";import"./chevron-up-CRjmFfp2.js";import"./sparkles-_ewb4KdX.js";import"./lock-CZskgewM.js";import"./use-transactions-V5K-KOwA.js";import"./txnReceiptPdf-DJjxgQiQ.js";import"./jspdf.es.min-DYJrId12.js";import"./jspdf.plugin.autotable-CyVc7Jkq.js";import"./chevron-right-Ifx_tJr5.js";import"./file-text-DZsJjycF.js";import"./user-CLzIiMal.js";import"./phone-BsHJWvjh.js";import"./shield-check-JTIKhhRg.js";import"./use-transform-D79JgFKm.js";import"./wallet-BVSZjyQE.js";import"./scan-text-CC690L1J.js";import"./ticket-pf0k8qei.js";const Ut=[500,1e3,2e3,5e3,1e4,2e4],R=["agent","amount","review","pin"],Gt={enter:h=>({x:h>0?"100%":"-100%",opacity:0}
2),center:{x:0,opacity:1},exit:h=>({x:h<0?"100%":"-100%",opacity:0})},Wt=({pin:h,onChange:O,error:s})=>e.jsxs("div",{className:"relative space-y-5",children:[e.jsx("div",{className:"flex justify-center gap-4",children:[0,1,2,3].map(N=>e.jsx(j.div,{animate:{scale:h.length>N?1.15:1},transition:{type:"spring",stiffness:400,damping:20},className:`w-5 h-5 rounded-full border-2 transition-colors ${h.length>N?"gradient-cashout border-transparent shadow-md":"border-muted-foreground/40 bg-transparent"}`},N))}),s&&e.jsxs("p",{className:"text-xs text-destructive flex items-center justify-center gap-1",children:[e.jsx(se,{size:12})," ",s]}),e.jsx("input",{type:"password",inputMode:"numeric",pattern:"[0-9]*",maxLength:4,value:h,onChange:N=>{const D=N.target.value.replace(/\D/g,"").slice(0,4);D.length>h.length&&P.light(),O(D)},autoFocus:!0,className:"absolute inset-0 w-full h-full opacity-0 cursor-text",placeholder:"â¢â¢â¢â¢"})]}),Qt=({onClose:h,prefilledAgentId:O})=>{const{t:s,lang:N}=lt(),D=N==="bn"?"bn-BD":"en-GB",fe=N==="bn"?"bn-BD":"en-US",{isLocked:Qe}=St(),{calcCashOutFee:he,getFeeLabel:qe,getAgentCommission:He}=ht(),ae=Qe("cash_out"),[g,ge]=o.useState("agent"),[be,je]=o.useState(1),[a,B]=o.useState(null),[$,I]=o.useState(O??""),[re,Ke]=o.useState(""),[l,ye]=o.useState(""),[z,Q]=o.useState(""),[k,d]=o.useState(""),[p]=o.useState(()=>Ft("cash_out")),[Ze,Ne]=o.useState(!1),[Je,ve]=o.useState(!1),[ne,Xe]=o.useState([]),[ie,we]=o.useState([]),[Se,Ce]=o.useState(!1),[Ae,E]=o.useState(!0),[M,Ye]=o.useState(0),[Fe,et]=o.useState(""),[_e,tt]=o.useState(!1),[Le,Ie]=o.useState(!1),V=o.useRef(new Date),ke=()=>{const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let n="";for(let c=0;c<12;c++)n+=t[Math.floor(Math.random()*36)];return n},A=o.useRef(ke());o.useEffect(()=>{g==="success"&&(bt(),Ct(),A.current=ke())},[g]);const T=["gradient-cashout","gradient-payment","gradient-addmoney","gradient-send","gradient-accent"];o.useEffect(()=>{let t=!1;const n=async(r,u)=>{const{data:b}=await L.rpc("get_nearby_agents",{p_lat:r,p_lng:u,p_radius_km:10});if(t||!b)return;const m=b.map((x,f)=>({id:x.agent_id,name:x.business_name||"Agent",agentId:x.territory_code||x.agent_id.slice(0,8),address:x.address||"",distance:`${x.distance_km} km`,initials:(x.business_name||"AG").slice(0,2).toUpperCase(),gradient:T[f%T.length],rating:Number(x.avg_rating)||0}));we(m),E(!1)},c=async()=>{const{data:{session:r}}=await L.auth.getSession();if(!(r!=null&&r.user)||t){E(!1);return}const{data:u}=await L.from("transactions").select("*").eq("user_id",r.user.id).eq("type","cashout").order("created_at",{ascending:!1});if(!u||t){E(!1);return}const b=new Set,m=[];for(const x of u){const f=x.recipient_phone;if(!f||b.has(f))continue;b.add(f);const i=x.recipient_name||"Agent";if(m.push({id:x.id,name:i,agentId:f,address:"",distance:"",initials:i.slice(0,2).toUpperCase(),gradient:T[m.length%T.length],rating:0}),m.length>=5)break}Xe(m),E(!1)};return navigator.geolocation?navigator.geolocation.getCurrentPosition(r=>{t||(Ce(!0),n(r.coords.latitude,r.coords.longitude),c())},()=>{c()},{enableHighAccuracy:!0,timeout:5e3}):c(),()=>{t=!0}},[]);const oe=R.indexOf(g),S=t=>{P.medium(),je(R.indexOf(t)>R.indexOf(g)?1:-1),ge(t),d("")},st=()=>{if(P.medium(),g==="agent"){h();return}if(g==="amount"){S("agent");return}if(g==="review"){S("amount");return}if(g==="pin"){Q(""),S("review");return}},ce=ie.length>0?ie:ne,at=ce.filter(t=>t.name.toLowerCase().includes(re.toLowerCase())||t.agentId.toLowerCase().includes(re.toLowerCase())),rt=t=>{B(t),I(t.agentId),S("amount")},[qt,q]=o.useState(!1),[U,Ee]=o.useState(""),H=t=>{const n=(t||"").trim();return $e.test(n.toUpperCase())?n.toUpperCase():n},Te=async t=>{const{data:n,error:c}=await L.rpc("resolve_transfer_recipient",{p_identifier:t,p_flow:"cashout"});if(c)return{exists:!1};const r=typeof n=="string"?JSON.parse(n):n;return r!=null&&r.found?{exists:!0,name:r.recipient_name||void 0,phone:r.recipient_phone,walletId:r.recipient_wallet_id||void 0,matchedBy:r.matched_by||void 0}:{exists:!1}},le=t=>{const n=(t||"").trim().toUpperCase();return xt.test(n)?pt(n,"agent").ok?null:ze("agent",N):null},K=t=>ft(t,s),nt=async t=>{const{value:n,candidates:c,error:r,name:u}=K(t);if(I(n),r){d(r);return}if(!n){d(s("coQrUnreadable"));return}q(!0),d("");
2const b=Array.from(new Set([n,...c||[]].map(H).filter(Boolean)));let m=null,x=n,f=null;for(const w of b){if(f=le(w),f)continue;const G=await Te(w);if(G.exists){m=G,x=w;break}}if(q(!1),!(m!=null&&m.exists)){if(f&&b.length===1){d(f);return}d(s("coAgentNotFound"));return}Ee(m.phone||"");const i=m.walletId||H(x),F=ne.find(w=>w.agentId.toLowerCase()===i.toLowerCase());B(F||{id:"qr",name:m.name||u||"Agent",agentId:i,address:"",distance:"",initials:"AG",gradient:"gradient-cashout",rating:0}),S("amount")},Re=async t=>{const n=t??$,{value:c,candidates:r,error:u,name:b}=K(n);c!==$.trim()&&I(c);const m=(n||"").trim(),x=!/^[{\[]/.test(m)&&!/^[a-z]+:\/\//i.test(m);if(u&&!x){d(u);return}if(c.length<5){d(s("coEnterValidAgentId"));return}q(!0),d("");const f=Array.from(new Set([c,...r||[]].map(H).filter(Boolean)));let i=null,F=c,w=null;for(const W of f){if(w=le(W),w)continue;const Be=await Te(W);if(Be.exists){i=Be,F=W;break}}if(q(!1),!(i!=null&&i.exists)){if(w&&f.length===1){d(w);return}d(s("coAgentNotFound"));return}Ee(i.phone||"");const G=i.walletId||H(F),De=ne.find(W=>W.agentId.toLowerCase()===G.toLowerCase());B(De||{id:"custom",name:i.name||b||"Agent",agentId:G,address:"",distance:"",initials:"AG",gradient:"gradient-primary",rating:0}),S("amount")},Pe=o.useRef(void 0);o.useEffect(()=>{const t=(O||"").trim();!t||Pe.current===t||(Pe.current=t,Re(t))},[O]);const it=()=>{const t=parseFloat(l);if(!l||isNaN(t)||t<=0){d(s("coEnterValidAmount"));return}if(t<30){d(s("coMinCashOut"));return}if(t>5e4){d(s("coMaxCashOut"));return}S("review")},ot=()=>S("pin"),[Oe,Z]=o.useState(!1),ct=async()=>{if(z.length<4){d(s("coEnterPin"));return}if(Oe)return;const t=(a==null?void 0:a.agentId)||$||"",n=le(t);if(n){d(n);return}if(Z(!0),!await Nt(z)){d(s("coIncorrectPin")),Q(""),Z(!1);return}const r=parseFloat(l)||0,u=await wt("cashout",r);if(!u.allowed){d(s("coDailyLimitUsed").replace("{used}",u.used.toLocaleString()).replace("{limit}",u.limit.toLocaleString())),Z(!1);return}gt().catch(()=>{}),P.success(),V.current=new Date;const b=he(r),m=p?Me(p,r):0,x=Math.max(0,r-m),f=He("cashout",r);try{const i=$e.test(((a==null?void 0:a.agentId)||"").trim().toUpperCase())?a.agentId:void 0;await yt({recipientPhone:(U||(a==null?void 0:a.agentId))??"",amount:x,fee:b,type:"cashout",recipientName:a==null?void 0:a.name,description:`Cash Out at ${a==null?void 0:a.name}`+(p?` [Coupon: ${p.code}]`:""),reference:A.current,recipientType:"cashin",commission:f,recipientWalletId:i,expectedWalletRole:i?"agent":void 0})}catch(i){(i==null?void 0:i.code)==="bad_format"||(i==null?void 0:i.code)==="role_mismatch"?d(ze("agent",N)):d(i.message||s("coCashOutFailed")),Q(""),Z(!1);return}p&&(await _t({code:p.code,flow:"cash_out",txnId:A.current,discount:m}),Ve()),At({type:s("coToastType"),amount:`à§³${r.toLocaleString("en-BD",{minimumFractionDigits:2})}`,gradient:"gradient-cashout"}),je(1),ge("success"),mt(async()=>{const{activityTracker:i}=await import("./index-CR8jIHGL.js").then(F=>F.bl);return{activityTracker:i}},__vite__mapDeps([0,1])).then(({activityTracker:i})=>i.transaction("cashout_success",{amount:r,fee:y,txn_id:A.current}))},de=qe("cashout"),J=jt(),y=parseFloat(l)>0?he(parseFloat(l)):0,v=p?Me(p,parseFloat(l)||0):0,X=y.toFixed(2),C=Math.min(y,J),me=parseFloat((y-C).toFixed(2)),Y=parseFloat(l)>0?Math.max(0,parseFloat(l)-v):0,ee=Y>0?(Y-me).toFixed(2):"0.00",te=Y>0?parseFloat((Y+C).toFixed(2)):0;return ae.locked?e.jsx(Pt,{featureName:s("flowCashOut"),reason:ae.reason,expiresAt:ae.expiresAt,onClose:h}):e.jsxs(j.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",stiffness:500,damping:40},className:"fixed inset-0 z-50 bg-background flex flex-col max-w-md sm:max-w-xl mx-auto",role:"dialog","aria-modal":"true",children:[g!=="success"&&e.jsxs(j.div,{className:"gradient-send px-4 pt-3 pb-3 text-primary-foreground",initial:{y:-60,opacity:0},animate:{y:0,opacity:1},transition:{type:"spring",stiffness:300,damping:28,duration:.4},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("button",{type:"button",onClick:st,"aria-label":s("coGoBack"),className:"w-10 h-10 rounded-full bg-white/20 ring-1 ring-white/30 backdrop-blur-sm flex items-center justify-center active:scale-95 transition-transform shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white",children:e.jsx(We,{size:20,"aria-hidden":"true"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h1",{className:"text-xl font-extrabold tracking-tight",children:s("flowCashOut")}),e.jsx("p",{className:"text-xs text-white/70 mt-0.5",children:s("flowWithdrawAgent")})]})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-white/20 overflow-hidden",role:"progressbar","aria-valuemin":0,"aria-valuemax":R.length,"aria-valuenow":oe+1,"aria-label":s("coStepOf").replace("{n}",String(oe+1)).replace("{total}",String(R.length)),children:e.jsx(j.div,{className:"h-full bg-white rounded-full shadow-[0_0_8px_2px_rgba(255,255,255,0.55)]",animate:{width:`${(oe+1)/R.length*100}%`},transition:{type:"spring",stiffness:200,damping:28}})})]}),e.jsx("div",{className:"flex-1 overflow-hidden relative",children:e.jsx(dt,{custom:be,mode:"wait",children:e.jsxs(j.div,{custom:be,variants:Gt,initial:"enter",animate:"center",exit:"exit",transition:{type:"spring",stiffness:320,damping:32},className:"absolute inset-0 overflow-y-auto scrollbar-none",children:[g==="agent"&&e.jsxs("div",{className:"px-4 pt-6 pb-32 space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-semibold text-foreground",children:s("agentIdLabel")}),e.jsxs("div",{className:"relative",children:[e.jsx(Dt,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}
2),e.jsx(Ue,{type:"text",placeholder:s("coAgentIdPlaceholder"),value:$,onChange:t=>{const n=t.target.value,c=n.trim();if(c.startsWith("{")||/^https?:\/\//i.test(c)){const{value:u,error:b}=K(n),m=/^01[3-9]\d{8}$/.test(u)||/^EZP-[A-Z]{4,5}-[A-Z]{4}$/i.test(u);I(m?u:n),d(b||"")}else I(n),d("")},onPaste:t=>{const n=t.clipboardData.getData("text"),c=(n||"").trim();if(c.startsWith("{")||/^https?:\/\//i.test(c)){t.preventDefault();const{value:r,error:u}=K(n);I(r),d(u||"")}},className:"pl-9 pr-12 h-12 text-base bg-card border-border uppercase"}),e.jsx("button",{onClick:()=>Ne(!0),className:"absolute right-3 top-1/2 -translate-y-1/2 w-7 h-7 rounded-lg bg-muted flex items-center justify-center hover:bg-muted/80 transition-colors",children:e.jsx(Bt,{size:16,className:"text-muted-foreground"})})]}),k&&e.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1",children:[e.jsx(se,{size:12})," ",k]}),(()=>{const t=ut("agentId",$);return e.jsxs(e.Fragment,{children:[!k&&t.errorMessage&&e.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1 animate-fade-in",children:[e.jsx(se,{size:12})," ",t.errorMessage]}),t.isValid&&e.jsx(_,{className:"w-full h-11 gradient-cashout border-0 text-white font-semibold animate-fade-in",onClick:()=>Re(),children:s("continue")})]})})()]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 h-px bg-border"}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ue,{size:11}),Se&&ie.length>0?s("nearbyAgents"):s("coRecentAgents")]}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),!Se&&!Ae&&e.jsxs("button",{onClick:()=>{var t;(t=navigator.geolocation)==null||t.getCurrentPosition(n=>{Ce(!0),E(!0),L.rpc("get_nearby_agents",{p_lat:n.coords.latitude,p_lng:n.coords.longitude,p_radius_km:10}).then(({data:c})=>{c&&we(c.map((r,u)=>({id:r.agent_id,name:r.business_name||"Agent",agentId:r.territory_code||r.agent_id.slice(0,8),address:r.address||"",distance:`${r.distance_km} km`,initials:(r.business_name||"AG").slice(0,2).toUpperCase(),gradient:T[u%T.length],rating:Number(r.avg_rating)||0}))),E(!1)})},()=>{},{enableHighAccuracy:!0,timeout:5e3})},className:"w-full flex items-center gap-2 p-2.5 rounded-xl bg-primary/5 border border-primary/20 text-xs text-primary font-medium",children:[e.jsx(ue,{size:14})," ",s("coEnableLocation")]}),ce.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx($t,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx(Ue,{placeholder:s("coSearchPlaceholder"),value:re,onChange:t=>Ke(t.target.value),className:"pl-9 bg-card border-border"})]}),e.jsx("div",{className:"space-y-2",children:Ae?e.jsxs("div",{className:"flex flex-col items-center py-8",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin mb-3"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("coFindingNearby")})]}):ce.length===0?e.jsxs(j.div,{initial:{opacity:0,scale:.9,y:12},animate:{opacity:1,scale:1,y:0},transition:{duration:.5,ease:"easeOut"},className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(j.div,{animate:{y:[0,-4,0]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},className:"w-14 h-14 bg-muted rounded-full flex items-center justify-center mb-3",children:e.jsx(zt,{className:"w-7 h-7 text-muted-foreground"})}),e.jsx("p",{className:"text-sm font-semibold text-foreground",children:s("coNoAgentsFound")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("coEnterAgentAbove")})]}):at.map(t=>e.jsxs("button",{onClick:()=>rt(t),className:"w-full flex items-center gap-3 p-3 rounded-2xl bg-card border border-border shadow-card hover:shadow-elevated active:scale-[0.98] transition-all text-left",children:[e.jsx("div",{className:`${t.gradient} w-11 h-11 rounded-xl flex items-center justify-center text-white font-bold text-sm shrink-0`,children:t.initials}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:t.name}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[t.rating>0&&e.jsxs("span",{className:"text-[10px] font-semibold text-amber-600 bg-amber-50 dark:bg-amber-900/20 px-1.5 py-0.5 rounded-full flex items-center gap-0.5",children:[e.jsx(xe,{size:9,className:"fill-amber-500 text-amber-500"})," ",t.rating.toFixed(1)]}),t.distance&&e.jsxs("span",{className:"text-[10px] font-medium text-primary bg-primary/10 px-1.5 py-0.5 rounded-full whitespace-nowrap flex items-center gap-0.5",children:[e.jsx(ue,{size:9})," ",t.distance]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.agentId}),t.address&&e.jsx("p",{className:"text-[10px] text-muted-foreground
2/70 truncate",children:t.address})]}),e.jsx(We,{size:16,className:"text-muted-foreground rotate-180 shrink-0"})]},t.id))})]}),g==="amount"&&e.jsxs("div",{className:"px-4 pt-6 pb-32 space-y-6",children:[p&&e.jsx(Ot,{coupon:p,discount:v,onRemove:()=>{Ve(),window.location.reload()}}),a&&e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-2xl bg-card border border-border shadow-card",children:[e.jsx("div",{className:`${a.gradient} w-11 h-11 rounded-xl flex items-center justify-center text-white font-bold text-sm shrink-0`,children:e.jsx(pe,{size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cashingOutAt")}),e.jsx("p",{className:"text-sm font-bold text-foreground truncate",children:a.name}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[a.agentId,a.address?` · ${a.address}`:""]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm font-semibold text-foreground",children:s("enterAmount")}),e.jsxs("div",{className:"flex flex-col items-end gap-0.5",children:[e.jsx(Et,{}),e.jsx(vt,{txnType:"cashout"})]})]}),e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("span",{className:"absolute left-4 text-2xl font-bold text-muted-foreground",children:"à§³"}),e.jsx("input",{type:"text",inputMode:"decimal",placeholder:"0",value:l,onChange:t=>{const n=t.target.value;(n===""||/^\d*\.?\d*$/.test(n))&&(ye(n),d(""))},onKeyDown:t=>{t.key==="Enter"&&t.target.blur()},className:"w-full pl-10 pr-4 h-16 text-3xl font-bold text-foreground bg-card border border-border rounded-2xl focus:outline-none focus:ring-2 focus:ring-primary placeholder:text-muted-foreground/40 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"})]}),k&&e.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1",children:[e.jsx(se,{size:12})," ",k]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:s("quickSelect")}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Ut.map(t=>e.jsxs("button",{onClick:()=>ye(String(t)),className:`py-2.5 rounded-xl text-sm font-semibold border transition-all active:scale-95 ${l===String(t)?"gradient-cashout text-white border-transparent shadow-card":"bg-card border-border text-foreground hover:border-primary/50"}`,children:["à§³",t.toLocaleString()]},t))})]}),parseFloat(l)>0&&te>J&&e.jsx("p",{className:"text-center text-sm text-destructive font-medium",children:s("coInsufficientBalance")}),parseFloat(l)>0&&te<=J&&parseFloat(l)>35e3&&e.jsx("p",{className:"text-center text-sm text-destructive font-medium",children:s("coExceedsDailyLimit")}),parseFloat(l)>0&&te<=J&&parseFloat(l)<=35e3&&e.jsx(j.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},children:e.jsx(_,{className:"w-full h-12 gradient-cashout border-0 text-white font-semibold text-base",onClick:it,children:s("coReviewCashOut")})})]}),g==="review"&&e.jsxs("div",{className:"px-4 pt-6 pb-32 space-y-5",children:[e.jsxs("div",{className:"text-center space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cashingOut")}),e.jsxs("p",{className:"text-4xl font-extrabold text-foreground",children:["à§³",parseFloat(l).toLocaleString()]})]}),e.jsxs("div",{className:"rounded-2xl bg-card border border-border shadow-card p-4 flex items-center gap-3",children:[e.jsx("div",{className:`${a==null?void 0:a.gradient} w-11 h-11 rounded-xl flex items-center justify-center text-white shrink-0`,children:e.jsx(pe,{size:18})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-bold text-foreground text-sm truncate",children:a==null?void 0:a.name}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[a==null?void 0:a.agentId,a!=null&&a.address?` · ${a.address}`:""]}),U&&e.jsxs("p",{className:"text-xs font-semibold text-primary mt-0.5 tabular-nums",children:["ð ",U]})]})]}),U&&e.jsxs("div",{className:"rounded-2xl border border-primary/30 bg-primary/5 p-3 text-center",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground font-semibold",children:s("coConfirmAgentNumber")}),e.jsx("p",{className:"text-lg font-extrabold text-foreground tabular-nums mt-0.5",children:U}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:s("coConfirmAgentNumberHelp")})]}),e.jsxs("div",{className:"rounded-2xl bg-card border border-border p-4 space-y-2.5 text-sm",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s("coTransactionSummary")}
2),e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsx("span",{children:s("cashOutAmount")}),e.jsxs("span",{className:"text-foreground font-medium",children:["à§³",parseFloat(l).toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsxs("span",{children:[s("coFee")," (",de,")"]}),e.jsxs("span",{className:"text-destructive font-medium",children:["â à§³",X]})]}),v>0&&p&&e.jsx(Ge,{code:p.code,discount:v}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground/70",children:[e.jsx("span",{children:s("coFeeSource")}),e.jsx("span",{className:"text-primary font-medium",children:C>=y?s("coFeeFromBalance"):C>0?s("coFeeBalancePlusAmount").replace("{bal}",C.toFixed(2)).replace("{amt}",String(me)):s("coFeeDeductedFromAmount")})]}),e.jsx("div",{className:"h-px bg-border"}),e.jsxs("div",{className:"flex justify-between font-bold text-foreground",children:[e.jsx("span",{children:s("youReceive")}),e.jsxs("span",{className:"text-primary",children:["à§³",parseFloat(ee).toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground/70",children:[e.jsx("span",{children:s("coTotalFromBalance")}),e.jsxs("span",{children:["à§³",te.toLocaleString()]})]})]}),e.jsx(_,{className:"w-full h-12 gradient-cashout border-0 text-white font-semibold text-base rounded-xl",onClick:ot,children:s("coConfirmEnterPin")}),e.jsx(_,{variant:"ghost",className:"w-full",onClick:()=>S("amount"),children:s("coEditAmount")})]}),g==="pin"&&e.jsxs("div",{className:"px-4 pt-6 pb-32 space-y-6",children:[e.jsxs("div",{className:"text-center space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cashingOut")}),e.jsxs("p",{className:"text-4xl font-extrabold text-foreground",children:["à§³",parseFloat(l).toLocaleString()]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s("coAt")," ",e.jsx("span",{className:"font-semibold text-foreground",children:a==null?void 0:a.name})]})]}),e.jsxs("div",{className:"rounded-2xl bg-card border border-border shadow-card p-4 flex items-center gap-3",children:[e.jsx("div",{className:`${a==null?void 0:a.gradient} w-11 h-11 rounded-xl flex items-center justify-center text-white shrink-0`,children:e.jsx(pe,{size:18})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-foreground text-sm",children:a==null?void 0:a.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a==null?void 0:a.agentId," · ",a==null?void 0:a.address]})]})]}),e.jsxs("div",{className:"rounded-2xl bg-muted/40 border border-border p-3 space-y-1.5 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:s("youReceive")}),e.jsxs("span",{className:"font-bold text-primary",children:["à§³",parseFloat(ee).toLocaleString()]})]}),y>0&&e.jsxs("p",{className:"text-[11px] text-muted-foreground text-right",children:["à§³",parseFloat(l).toLocaleString()," + à§³",X," ",s("coFee").toLowerCase()," (",C>=y?s("coFromBalanceShort"):C>0?s("coBalancePlusAmountShort"):s("coFromAmountShort"),")"]})]}),e.jsx(Wt,{pin:z,onChange:t=>{Q(t),d("")},error:k}),e.jsx(Lt,{onConfirm:ct,label:s("slideToCashOut"),gradient:"gradient-cashout",disabled:z.length<4||Oe,pinComplete:z.length===4,icon:Mt})]}),g==="success"&&e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-full px-6 py-16 text-center space-y-6",children:[e.jsx(j.div,{initial:{scale:0,rotate:-15},animate:{scale:1,rotate:0},transition:{type:"spring",stiffness:260,damping:20,delay:.1},className:"w-24 h-24 gradient-cashout rounded-full flex items-center justify-center shadow-glow",children:e.jsx(Vt,{size:52,className:"text-white"})}),e.jsxs(j.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.3},className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-extrabold text-foreground",children:s("cashOutSuccessful")}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:[s("coCashedOutAt").replace("{amt}
2",`à§³${parseFloat(l).toLocaleString()}`)," ",e.jsx("span",{className:"font-semibold text-foreground",children:a==null?void 0:a.name})]})]}),e.jsxs(j.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.45},className:"w-full rounded-2xl bg-card border border-border shadow-elevated p-4 text-sm space-y-3",children:[e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsx("span",{children:s("agent")}),e.jsx("span",{className:"text-foreground font-medium",children:a==null?void 0:a.name})]}),e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsx("span",{children:s("coAgentId")}),e.jsx("span",{className:"text-foreground font-medium",children:a==null?void 0:a.agentId})]}),e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsx("span",{children:s("coAmount")}),e.jsxs("span",{className:"text-foreground font-medium",children:["à§³",parseFloat(l).toLocaleString()]})]}),v>0&&p&&e.jsx(Ge,{code:p.code,discount:v}),e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsxs("span",{children:[s("coFee")," (",de,")"]}),e.jsxs("span",{className:"text-foreground font-medium",children:["à§³",X]})]}),y>0&&e.jsxs("p",{className:"text-[11px] text-muted-foreground text-right",children:["à§³",parseFloat(l).toLocaleString()," + à§³",X," ",s("coFee").toLowerCase()," (",C>=y?s("coFromBalanceShort"):C>0?s("coBalancePlusAmountShort"):s("coFromAmountShort"),")"]}),me>0&&e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsx("span",{children:s("youReceived")}),e.jsxs("span",{className:"font-semibold text-primary",children:["à§³",parseFloat(ee).toLocaleString()]})]}),v>0&&e.jsxs("div",{className:"flex justify-between font-bold text-foreground",children:[e.jsx("span",{children:s("coTotalDeducted")}),e.jsxs("span",{children:["à§³",(Math.max(0,parseFloat(l)-v)+y).toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsx("span",{children:s("coDate")}),e.jsx("span",{className:"text-foreground font-medium",children:V.current.toLocaleDateString(D,{day:"2-digit",month:"short",year:"numeric"})})]}),e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsx("span",{children:s("coTime")}),e.jsx("span",{className:"text-foreground font-medium",children:V.current.toLocaleTimeString(fe,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0})})]}),e.jsx("div",{className:"h-px bg-border"}),e.jsxs("div",{className:"flex justify-between font-bold text-foreground",children:[e.jsx("span",{children:s("coTransactionId")}),e.jsx("span",{className:"text-primary",children:A.current})]})]}),e.jsxs(j.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.55},className:"w-full rounded-2xl bg-card border border-border shadow-card p-4 space-y-3",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground text-center",children:s(_e?"coThanksFeedback":"coRateAgent")}),_e?e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(t=>e.jsx(xe,{size:20,className:t<=M?"fill-amber-400 text-amber-400":"text-muted-foreground/20"},t))})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex justify-center gap-2",children:[1,2,3,4,5].map(t=>e.jsx("button",{onClick:()=>{P.light(),Ye(t)},className:"p-1 active:scale-90 transition-transform",children:e.jsx(xe,{size:28,className:`transition-colors ${t<=M?"fill-amber-400 text-amber-400":"text-muted-foreground/30"}`})},t))}),M>0&&e.jsx(It,{placeholder:s("coExperiencePlaceholder"),value:Fe,onChange:t=>et(t.target.value),className:"text-sm resize-none h-16",maxLength:200}),M>0&&e.jsx(_,{size:"sm",className:"w-full gradient-cashout border-0 text-white",disabled:Le,onClick:async()=>{Ie(!0);const{data:{session:t}}=await L.auth.getSession();t!=null&&t.user&&a&&await L.from("agent_ratings").insert({agent_id:a.id,user_id:t.user.id,rating:M,comment:Fe.trim(),transaction_id:A.current}),tt(!0),Ie(!1),P.success()},children:s(Le?"coSubmittingRating":"coSubmitRating")})]})]}),e.jsxs(j.div,{initial:{opacity:0}
2,animate:{opacity:1},transition:{delay:.7},className:"w-full space-y-3",children:[e.jsx(_,{className:"w-full h-12 gradient-cashout border-0 text-white font-semibold",onClick:h,children:s("backToHome")}),e.jsx(_,{variant:"outline",className:"w-full h-11",onClick:()=>ve(!0),children:s("shareReceipt")})]})]})]},g)})}),e.jsx(Tt,{open:Ze,onClose:()=>Ne(!1),onScan:nt,title:s("scanAgentQr")}),e.jsx(kt,{open:Je,onClose:()=>ve(!1),receipt:{title:s("coCashOutSuccessTitle"),amount:`à§³${parseFloat(l||"0").toLocaleString()}`,gradient:"gradient-cashout",txnId:A.current,rows:[{label:s("agent"),value:(a==null?void 0:a.name)??""},{label:s("coAgentId"),value:(a==null?void 0:a.agentId)??""},{label:s("coAmount"),value:`à§³${parseFloat(l||"0").toLocaleString()}`},...v>0?[{label:`ðï¸ ${s("coCouponLabel")} (${p==null?void 0:p.code})`,value:`-à§³${v.toFixed(2)}`}]:[],{label:`${s("coFee")} (${de})`,value:`à§³${y.toFixed(2)}`},{label:s("youReceived"),value:`à§³${parseFloat(ee).toLocaleString()}`},{label:s("coDate"),value:V.current.toLocaleDateString(D,{day:"2-digit",month:"short",year:"numeric"})},{label:s("coTime"),value:V.current.toLocaleTimeString(fe,{hour:"2-digit",minute:"2-digit",hour12:!0})}]}})]})},Ba=h=>e.jsx(Rt,{featureKey:"cash_out",onClose:h.onClose,children:e.jsx(Qt,{...h})});export{Ba 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.