1import{b as fe,u as pe,a8 as he,r as a,j as e,m as d,A as Q,d as u,X as ge,s as je}from"./index-CR8jIHGL.js";import{C as N}from"./card-B0UFKqE-.js";import{I as $}from"./input-CBgH9T9i.js";import{L as z}from"./label-BpWQMlqw.js";import{S as Ne}from"./SlideToConfirm-o2rnFqgQ.js";import{v as be}from"./verifyPin-DFbbL5Ko.js";import{B as ye,b as ve,a as W}from"./BankLogo-nLRz9o3k.js";import{u as ke}from"./use-platform-banks-Cy7FgqCc.js";import{B as we}from"./BankListLiveBadge-JhOuTUwo.js";import{u as Ce}from"./use-saved-banks-ixlLBwtw.js";import{M as Be}from"./ModernPinField-Bzea5A33.js";import{P as Se,a as Ae,b as _e}from"./popover-5IaS_A9B.js";import{A as ze,a as De,b as Pe,c as Le,d as Te,e as Me,f as Fe,g as Ee}from"./alert-dialog-CJ5sNd_e.js";import{A as Re}from"./arrow-left-C6UQi8Yb.js";import{L as H}from"./landmark-R__bgf9j.js";import{S as $e}from"./send-D1X2wYJv.js";import{A as He}from"./arrow-down-to-line-DjtGi9iC.js";import{P as Z}from"./plus-ChrXPX9z.js";import{B as I}from"./building-2-eTqWALnI.js";import{T as Ie}from"./trash-2-Cso3Gx0t.js";import{S as Ve}from"./shield-check-JTIKhhRg.js";import{C as Ue}from"./circle-alert-zn_RedqF.js";import{C as ee}from"./circle-check-FO8rVln-.js";import{H as Ke}from"./house-BvFMf5I8.js";import{C as Oe}from"./chevron-down-D2fBW4mO.js";import{S as Ge}from"./search-DJ1zHrUy.js";import{C as Xe}from"./credit-card-CoDepcSc.js";import{U as Ye}from"./user-CLzIiMal.js";import"./haptics-YKMSwVex.js";import"./index-BZMZauxs.js";import"./use-transform-D79JgFKm.js";import"./chevron-right-Ifx_tJr5.js";import"./auth-BUl0x90n.js";import"./index-gTm__Gfr.js";import"./index-DT5oeEbX.js";const w=h=>new Intl.NumberFormat("en-BD").format(h),qe=()=>{const h="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let s="";for(let m=0;m<12;m++)s+=h[Math.floor(Math.random()*36)];return s},Dt=()=>{const h=fe(),{t:s}=pe(),{toast:m}=he(),{accounts:V,save:te,remove:se}=Ce(),[n,ae]=a.useState("send"),[i,f]=a.useState("select"),[r,U]=a.useState(null),[x,D]=a.useState(""),[C,B]=a.useState(""),[K,p]=a.useState(""),[O,P]=a.useState(!1),[b,g]=a.useState(!1),[L,y]=a.useState(!1),[o,T]=a.useState(""),[S,G]=a.useState(""),[A,X]=a.useState(""),[re,M]=a.useState(""),[_,F]=a.useState(""),[ne,Y]=a.useState(!1),[c,E]=a.useState(null),j=0,{banks:v,liveUpdateKey:ie}=ke(!1,"agent"),k=a.useMemo(()=>v.length===0?ye:v.map(t=>({id:t.id,name:t.name,short:t.short_code,color:ve(t.name),logo_url:t.logo_url})),[v]),q=a.useMemo(()=>{if(!_.trim())return k;const t=_.toLowerCase();return k.filter(l=>l.name.toLowerCase().includes(t)||l.short.toLowerCase().includes(t))},[_,k]),R=k.find(t=>t.name===o);a.useEffect(()=>{if(!L||o)return;const t=v.find(l=>l.is_default);t&&(T(t.name),M(t.short_code))},[L,v,o]);const oe=async()=>{var t;if(!o||!S||!A){m({title:"Missing fields",description:"Fill all bank details",variant:"destructive"});return}await te({bank_name:o,account_number:S,account_holder:A,short_code:re||((t=k.find(l=>l.name===o))==null?void 0:t.short)||o.slice(0,3).toUpperCase()}),m({title:"Bank Saved",description:`${o} account added`}),y(!1),T(""),G(""),X(""),M(""),F("")},le=async()=>{c&&(await se(c.id),m({title:"Removed",description:`${c.bank_name} account deleted`}),E(null))},de=async()=>{if(r){g(!0);try{const t=n==="send"?"banktransfer":"addmoney",{error:l}=await je.rpc("record_transaction",{p_type:t,p_amount:Number(x),p_fee:j,p_recipient_name:r.account_holder,p_recipient_phone:r.account_number,p_description:`Bank ${n==="send"?"Send":"Receive"} â ${r.bank_name}`,p_reference:qe()});if(l)throw l;f("done"),m({title:`Bank ${n==="send"?"Transfer":"Deposit"} Successful`,description:`à§³${x} ${n==="send"?"sent to":"received from"} ${r.bank_name}`})}catch(t){throw m({title:"Failed",description:t.message,variant:"destructive"}),t}finally{g(!1)}}},ce=async()=>{if(C.length!==4){p("Enter your 4-digit PIN.");return}g(!0),p("");try{if(!await be(C)){p("Incorrect PIN. Try again."),B(""),g(!1);return}P(!0),g(!1),f("confirm")}catch(t){p(t.message||"Verification failed."),g(!1)}},me=async()=>{if(!(b||!r)){if(!O){m({title:"Verify PIN first",variant:"destructive"}),f("pin");return}await de()}},J=()=>{f("select"),U(null),D(""),B(""),p(""),P(!1)},xe=i==="select"?"15%":i==="form"?"40%":i==="pin"?"70%":i==="confirm"?"92%":"100%";return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsxs(d.header,{initial:{y:-60,opacity:0}
1,animate:{y:0,opacity:1},transition:{type:"spring",stiffness:300,damping:30},className:"gradient-send px-4 pt-3 pb-3 sticky top-0 z-30",children:[e.jsxs("div",{className:"max-w-xl mx-auto flex items-center gap-3",children:[e.jsx("button",{onClick:()=>i==="select"?h("/agent"):J(),className:"tap-target text-primary-foreground/80 hover:text-primary-foreground",children:e.jsx(Re,{size:20})}),e.jsxs("div",{className:"flex items-center gap-2.5 flex-1",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl glass-hero flex items-center justify-center",children:e.jsx(H,{size:16,className:"text-primary-foreground"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-sm font-bold text-primary-foreground",children:s("agBtTitle")}),e.jsx("p",{className:"text-[9px] text-primary-foreground/60",children:s(n==="send"?"agBtSendMode":"agBtReceiveMode")})]})]})]}),e.jsx("div",{className:"max-w-xl mx-auto mt-3",children:e.jsx("div",{className:"h-1.5 bg-primary-foreground/10 rounded-full overflow-hidden",children:e.jsx(d.div,{animate:{width:xe},className:"h-full bg-primary-foreground/40 rounded-full",transition:{duration:.4}})})})]}),e.jsxs("div",{className:"max-w-xl mx-auto px-4 py-5",children:[i==="select"&&e.jsx("div",{className:"grid grid-cols-2 gap-2 mb-5",children:["send","receive"].map(t=>e.jsxs("button",{onClick:()=>ae(t),className:`py-3 rounded-xl text-xs font-bold transition-all flex items-center justify-center gap-2 ${n===t?"bg-primary/10 text-primary ring-1 ring-primary/20":"bg-muted text-muted-foreground"}`,children:[t==="send"?e.jsx($e,{size:14}):e.jsx(He,{size:14}),s(t==="send"?"agBtSendMode":"agBtReceiveMode")]},t))}),e.jsxs(Q,{mode:"wait",children:[i==="select"&&e.jsxs(d.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16},children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"text-sm font-bold text-foreground",children:s("agBtSavedAccounts")}),e.jsxs(u,{size:"sm",variant:"outline",onClick:()=>y(!0),className:"text-xs gap-1.5 rounded-xl h-8",children:[e.jsx(Z,{size:14})," ",s("agBtAddBank")]})]}),V.length===0?e.jsxs(N,{className:"p-8 border-0 shadow-card rounded-2xl text-center space-y-3",children:[e.jsx(H,{size:36,className:"mx-auto text-muted-foreground/40"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("agBtNoAccounts")}),e.jsxs(u,{onClick:()=>y(!0),className:"gradient-primary text-primary-foreground rounded-xl h-10 text-xs font-bold gap-1.5",children:[e.jsx(Z,{size:14})," ",s("agBtAddFirst")]})]}):e.jsx("div",{className:"space-y-2.5",children:V.map((t,l)=>e.jsx(d.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:l*.05},children:e.jsxs(N,{className:"p-4 border-0 shadow-card rounded-2xl flex items-center gap-3 cursor-pointer hover:shadow-elevated transition-shadow press-effect",onClick:()=>{U(t),f("form")},children:[e.jsx("div",{className:"w-11 h-11 rounded-xl bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(I,{size:18,className:"text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[13px] font-bold text-foreground truncate",children:t.bank_name}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:[t.account_holder," · ****",t.account_number.slice(-4)]})]}),e.jsx("button",{onClick:ue=>{ue.stopPropagation(),E(t)},className:"w-8 h-8 rounded-xl bg-destructive/10 flex items-center justify-center text-destructive hover:bg-destructive/20 transition-colors tap-target",children:e.jsx(Ie,{size:14})})]})},t.id))})]},"select"),i==="form"&&r&&e.jsx(d.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16},children:e.jsxs(N,{className:"p-5 border-0 shadow-elevated rounded-2xl space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 bg-muted/50 rounded-xl p-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center",children:e.jsx(I,{size:16,className:"text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[12px] font-bold text-foreground",children:r.bank_name}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[r.account_holder," · ****",r.account_number.slice(-4)]})]})]}),e.jsxs("div",{children:[e.jsxs(z,{className:"text-xs font-semibold",children:[s("agComAmountLbl")," (৳)"]}),e.jsx($,{type:"text",inputMode:"numeric",placeholder:s("agComEnterAmt"),value:x,onChange:t=>D(t.target.value.replace(/\D/g,"")),className:"rounded-xl h-12 mt-1 text-lg font-bold"}),n==="send"&&j>0]}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:[5e3,1e4,25e3,5e4].map(t=>e.jsxs("button",{onClick:()=>D(String(t)),className:"px-3 py-2 rounded-xl text-xs font-bold bg-muted text-muted-foreground press-effect hover:bg-primary/10 hover:text-primary transition-colors",children:["৳",w(t)]},t))}),x&&Number(x)>=10&&e.jsx(u,{onClick:()=>f("pin"),className:"w-full gradient-primary text-primary-foreground rounded-xl h-11 text-sm font-bold animate-fade-in",children:s("agComContinue")})]})},"form"),i==="pin"&&r&&e.jsx(d.div,{initial:{opacity:0,y:16}
1,animate:{opacity:1,y:0},exit:{opacity:0,y:-16},children:e.jsx(N,{className:"p-6 border-0 shadow-elevated rounded-2xl",children:e.jsxs("div",{className:"flex flex-col items-center space-y-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Ve,{size:32,className:"text-primary"})}),e.jsxs("div",{className:"text-center space-y-1",children:[e.jsx("h2",{className:"text-lg font-bold text-foreground",children:s("agBtEnterYourPin")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s(n==="send"?"agBtConfirmTransfer":"agBtConfirmDeposit").replace("{amount}",w(Number(x)+j))})]}),e.jsx(Be,{value:C,onChange:t=>{B(t),p("")}}),K&&e.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1",children:[e.jsx(Ue,{size:12}),K]}),e.jsx(u,{className:"w-full gradient-primary text-primary-foreground rounded-xl h-11 text-sm font-bold",onClick:ce,disabled:b||C.length!==4,children:s(b?"agBtVerifying":"agBtVerifyPin")}),e.jsx(u,{variant:"ghost",onClick:()=>{f("form"),B(""),p(""),P(!1)},className:"w-full text-muted-foreground",children:s("agComBack")})]})})},"pin"),i==="confirm"&&r&&e.jsx(d.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16},children:e.jsxs(N,{className:"p-5 border-0 shadow-elevated rounded-2xl space-y-4",children:[e.jsx("h3",{className:"text-base font-extrabold text-foreground text-center",children:s(n==="send"?"agBtConfirmSend":"agBtConfirmReceive")}),e.jsxs("div",{className:"space-y-2.5 bg-muted/50 rounded-xl p-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:s("agBtBank")}),e.jsx("span",{className:"font-bold text-foreground",children:r.bank_name})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:s("agBtAccount")}),e.jsxs("span",{className:"font-bold text-foreground",children:["****",r.account_number.slice(-4)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:s("agBtHolder")}),e.jsx("span",{className:"font-bold text-foreground",children:r.account_holder})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:s("agComAmountLbl")}),e.jsxs("span",{className:"font-extrabold text-foreground",children:["à§³",w(Number(x))]})]}),j>0,e.jsxs("div",{className:"flex justify-between text-sm font-bold border-t border-border/40 pt-2",children:[e.jsx("span",{className:"text-muted-foreground",children:s("agComTotal")}),e.jsxs("span",{className:"text-foreground",children:["à§³",w(Number(x)+j)]})]})]}),e.jsx(Ne,{onConfirm:me,disabled:b||!O,label:s(b?"agComProcessing":n==="send"?"agBtSlideSend":"agBtSlideReceive"),icon:I}),e.jsx(u,{variant:"ghost",onClick:()=>{f("pin")},className:"w-full text-muted-foreground",children:s("agComBack")})]})},"confirm"),i==="done"&&r&&e.jsx(d.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},children:e.jsxs(N,{className:"p-6 border-0 shadow-elevated rounded-2xl text-center space-y-4",children:[e.jsx(d.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:300,damping:20},className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mx-auto",children:e.jsx(ee,{size:32,className:"text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-extrabold text-foreground",children:s(n==="send"?"agBtTransferSuccess":"agBtDepositSuccess")}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["à§³",w(Number(x))," ",s(n==="send"?"agBtSentTo":"agBtReceivedFrom")," ",r.bank_name]})]}),j>0,e.jsx(u,{onClick:J,className:"w-full gradient-primary text-primary-foreground rounded-xl h-11",children:s("agBtNewTransfer")}),e.jsxs(u,{onClick:()=>h("/agent"),variant:"outline",className:"w-full rounded-xl h-11 text-sm font-bold gap-2",children:[e.jsx(Ke,{size:16})," ",s("agComBackToDash")]})]})},"done")]})]}),e.jsx(Q,{children:L&&e.jsxs(e.Fragment,{children:[e.jsx(d.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[70] bg-black/50 backdrop-blur-sm",onClick:()=>y(!1)},"add-backdrop"),e.jsxs(d.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",stiffness:340,damping:34},className:"fixed bottom-0 left-0 right-0 z-[71] bg-card rounded-t-3xl shadow-float max-h-[85vh] overflow-y-auto",children:[e.jsx("div",{className:"flex justify-center pt-3 pb-1",children:e.jsx("div",{className:"w-10 h-1 rounded-full bg-muted-foreground/25"})}),e.jsxs("div",{className:"px-5 pt-2 pb-8 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-extrabold text-foreground",children:"Add Bank Account"}),e.jsx("button",{onClick:()=>y(!1),className:"w-8 h-8 rounded-xl bg-muted flex items-center justify-center text-muted-foreground",children:e.jsx(ge,{size:15})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(z,{className:"text-xs font-semibold",children:"Bank Name"}),e.jsx(we,{liveUpdateKey:ie,label:"Bank list"})]}),e.jsxs(Se,{open:ne,onOpenChange:Y,children:[e.jsx(Ae,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center gap-3 p-3 mt-1.5 rounded-xl border border-border bg-card hover:border-primary/50 transition-all text-left",children:[R?e.jsxs(e.Fragment,{children:[e.jsx(W,{bank:R,size:32}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-foreground truncate",children:R.name})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-muted flex items-center justify-center shrink-0",children:e.jsx(H,{size:14,className:"text-muted-foreground"})}),e.jsx("span",{className:"flex-1 text-sm text-muted-foreground",children:"Choose a bankâ¦"})]}),e.jsx(Oe,{size:14,className:"text-muted-foreground shrink-0"})]})}),e.jsxs(_e,{className:"w-[var(--radix-popover-trigger-width)] p-0 max-h-60 overflow-hidden",align:"start",children:[e.jsx("div",{className:"p-2 border-b border-border",children:e.jsxs("div",{className:"relative",children:[e.jsx(Ge,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{type:"text",placeholder:"Search banksâ¦",value:_,onChange:t=>F(t.target.value),className:"w-full pl-8 pr-3 py-2 text-sm bg-transparent outline-none placeholder:text-muted-foreground",autoFocus:!0})]})}),e.jsx("div",{className:"overflow-y-auto max-h-48",children:q.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No banks found"}):q.map(t=>e.jsxs("button",{onClick:()=>{T(t.name),M(t.short),Y(!1),F("")},className:`w-full flex items-center gap-3 px-3 py-2.5 text-left hover:bg-muted/50 transition-colors ${o===t.name?"bg-primary/10":""}`,children:[e.jsx(W,{bank:t,size:28,rounded:"rounded-md"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-xs font-medium text-foreground truncate",children:t.name})}),o===t.name&&e.jsx(ee,{size:12,className:"text-primary shrink-0"})]},t.id))})]})]})]}),e.jsxs("div",{children:[e.jsxs(z,{className:"text-xs font-semibold flex items-center gap-1.5",children:[e.jsx(Xe,{size:12})," Account Number"]}),e.jsx($,{type:"text",inputMode:"numeric",placeholder:"Enter account number",value:S,onChange:t=>G(t.target.value.replace(/\D/g,"")),maxLength:20,className:"rounded-xl h-11 mt-1"})]}),e.jsxs("div",{children:[e.jsxs(z,{className:"text-xs font-semibold flex items-center gap-1.5",children:[e.jsx(Ye,{size:12})," Account Holder Name"]}),e.jsx($,{placeholder:"Enter full name",value:A,onChange:t=>X(t.target.value),maxLength:60,className:"rounded-xl h-11 mt-1"})]}),e.jsx(u,{onClick:oe,disabled:!o||!S||!A,className:"w-full gradient-primary text-primary-foreground rounded-xl h-11 text-sm font-bold",children:"Save Bank Account"})]})]},"add-sheet")]})}),e.jsx(ze,{open:!!c,onOpenChange:t=>!t&&E(null),children:e.jsxs(De,{className:"rounded-2xl",children:[e.jsxs(Pe,{children:[e.jsx(Le,{children:"Remove Bank Account?"}),e.jsxs(Te,{children:["This will remove ",e.jsx("span",{className:"font-semibold",children:c==null?void 0:c.bank_name})," (****",c==null?void 0:c.account_number.slice(-4),") from your saved accounts."]})]}),e.jsxs(Me,{children:[e.jsx(Fe,{className:"rounded-xl",children:"Cancel"}),e.jsx(Ee,{onClick:le,className:"bg-destructive text-destructive-foreground rounded-xl",children:"Remove"})]})]})})]})};export{Dt 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.