1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2455],{2455:(e,t,i)=>{i.d(t,{A:()=>f});var a=i(95155),o=i(12115),l=i(99620),n=i(66766),d=i(62177),r=i(69021),s=i(94355),u=i(29911),c=i(70918),m=i(27043),v=i(33171),h=i(12108),p=i(28902),y=i(47908),b=i(96834),g=i(90984);function f(){let e=(0,m.useTranslations)(),{location:t}=(0,c.A)(),{setDisabled:i,setOpenedModal:f}=(0,r.h)(),{setCurrentPaymentMethod:w,setCurrentPaymentId:x}=(0,p.u)(),{subscribeToPayment:k}=(0,y.e)(),[N,_]=(0,o.useState)(!1),[P,j]=(0,o.useState)(""),{data:B,status:I}=(0,h.useSession)(),[T,S]=(0,o.useState)(""),[C,M]=(0,o.useState)(!1),[W,F]=(0,o.useState)(""),[L,E]=(0,o.useState)(!1),[D,O]=(0,o.useState)(null),{register:A,handleSubmit:q,formState:{errors:z}}=(0,d.mN)(),R=async()=>{var e,t,i,a,o,l,n,d,r,u,c,m,v,h,p,y,b,N,_,P,j,B;if(!D||!W.trim()){S("Please enter OTP");return}try{let j;E(!0);let B={...D.payload,otp:W.trim()};if("teleBirr"===D.method?j=await s.M.buyTicketWithTeleBirrLotteryDetail(B):"awash"===D.method?j=await s.M.buyTicketWithAwashLotteryDetail(B):"cbeBirr"===D.method?j=await s.M.buyTicketWithCbeBirrLotteryDetail(B):"coop"===D.method?(g.p.isSocketConnected()?g.p.joinPhoneNumberRoom(B.phoneNumber):await g.p.connect(void 0,B.phoneNumber),s.M.buyTicketWithCoopLotteryDetail(B).then(e=>{var t,i;let a=e.paymentId||(null===(i=e.data)||void 0===i?void 0:null===(t=i.createPayment)||void 0===t?void 0:t._id);a&&(x(a),k(a))}).catch(e=>{S(e.message||"Error initiating Coop payment"),E(!1)})):"bunnaBank"===D.method?j=await s.M.buyTicketWithBunnaBankLotteryDetail(B):"tsehay"===D.method&&(j=await s.M.buyTicketWithTsehayBankLotteryDetail(B)),localStorage.setItem("phone",D.payload.phoneNumber),M(!1),F(""),O(null),E(!1),"teleBirr"===D.method){let o=null===(t=j.data)||void 0===t?void 0:null===(e=t.createPayment)||void 0===e?void 0:e.checkout_url;o&&"string"==typeof o&&o.trim()&&o.startsWith("http")?window.location.replace(o):(x(j.paymentId||(null===(a=j.data)||void 0===a?void 0:null===(i=a.createPayment)||void 0===i?void 0:i._id)),w("teleBirr"),f("teleBirrProcessing"))}else if("awash"===D.method){let e=null===(l=j.data)||void 0===l?void 0:null===(o=l.createPayment)||void 0===o?void 0:o.checkout_url;e&&"string"==typeof e&&e.trim()&&e.startsWith("http")?window.location.replace(e):(x(j.paymentId||(null===(d=j.data)||void 0===d?void 0:null===(n=d.createPayment)||void 0===n?void 0:n._id)),w("awash"),f("awashProcessing"))}else if("cbeBirr"===D.method){let e=null===(u=j.data)||void 0===u?void 0:null===(r=u.createPayment)||void 0===r?void 0:r.checkout_url;e&&"string"==typeof e&&e.trim()&&e.startsWith("http")?window.location.replace(e):(x(j.paymentId||(null===(m=j.data)||void 0===m?void 0:null===(c=m.createPayment)||void 0===c?void 0:c._id)),w("cbeBirr"),f("cbeBirrProcessing"))}else if("coop"===D.method)w("coop"),f("coopProcessing");else if("bunnaBank"===D.method){let e=null===(h=j.data)||void 0===h?void 0:null===(v=h.createPayment)||void 0===v?void 0:v.checkout_url;if(e&&"string"==typeof e&&e.trim()&&e.startsWith("http"))window.location.replace(e);else{let e=j.paymentId||(null===(y=j.data)||void 0===y?void 0:null===(p=y.createPayment)||void 0===p?void 0:p._id);x(e),w("bunnaBank"),k(e),f("bunnaBankProcessing")}}else if("tsehay"===D.method){let e=null===(N=j.data)||void 0===N?void 0:null===(b=N.createPayment)||void 0===b?void 0:b.checkout_url;if(e&&"string"==typeof e&&e.trim()&&e.startsWith("http"))window.location.replace(e);else{let e=j.paymentId||(null===(P=j.data)||void 0===P?void 0:null===(_=P.createPayment)||void 0===_?void 0:_._id);x(e),w("tsehay"),k(e),f("tsehayBankProcessing")}}}catch(e){E(!1),S((null==e?void 0:null===(B=e.response)||void 0===B?void 0:null===(j=B.data)||void 0===j?void 0:j.message)||(null==e?void 0:e.message)||"Payment failed")}},J=async a=>{i(!0),_(!0),S("");let o=JSON.parse(localStorage.getItem("cart"));try{var l,n,d,r,u,c,m,h,p,y,N,j,T,C,W,F,L,D,A,q,z,R,J,K,Q,V,Z,$,G,H,U,X,Y,ee,et,ei,ea,eo,el,en,ed,er,es,eu,ec;if(!P){S(e("Please select a payment method."));return}let em=v.b.find(e=>P===e._id);if((null==em?void 0:em._id)==="67f61c6b59240a16be2f15da"){localStorage.setItem("kachaTicket",JSON.stringify({lotteryId:o._id,phoneNumber:"authenticated"===I?null==B?void 0:null===(h=B.user)||void 0===h?void 0:h.phoneNumber:a.phoneNumber,tickets:o.selectedTickets,paymentMethod:{id:null==em?void 0:em._id,name:null==em?void 0:em.name},location:t||{latitude:0,longitude:0}})),localStorage.setItem("transactionType","purchase"),f("confirmKacha");return}let ev=localStorage.getItem("affiliate");if((null==em?void 0:null===(l=em.name)||void 0===l?void 0:l.toLowerCase())==="tele"){if("unauthenticated"===I)try{E(!0),await b.o.post("/otp/sendTeleOtp",{phoneNumber:a.phoneNumber}),O({method:"teleBirr",payload:{lotteryId:o._id,phoneNumber:a.phoneNumber,tickets:o.selectedTickets,paymentMethod:{id:null==em?void 0:em._id,name:null==em?void 0:em.name},location:t||{latitude:0,longitude:0},...ev&&{affiliateId:ev}},response:null}),M(!0),E(!1);return}catch(e){E(!1),S((null==e?void 0:null===(y=e.response)||void 0===y?void 0:null===(p=y.data)||void 0===p?void 0:p.message)||"Failed to send OTP");return}else{let e=await s.M.buyTicketWithTeleBirrLotteryDetail({lotteryId:o._id,phoneNumber:null==B?void 0:null===(N=B.user)||void 0===N?void 0:N.phoneNumber,paymentMethod:{id:null==em?void 0:em._id,name:null==em?void 0:em.name},location:t||{latitude:0,longitude:0},tickets:o.selectedTickets,...ev&&{affiliateId:ev}});localStorage.setItem("phone",null==B?void 0:null===(j=B.user)||void 0===j?void 0:j.phoneNumber);let i=null===(C=e.data)||void 0===C?void 0:null===(T=C.createPayment)||void 0===T?void 0:T.checkout_url;i&&"string"==typeof i&&i.trim()&&i.startsWith("http")?window.location.replace(i):(x(e.paymentId||(null===(F=e.data)||void 0===F?void 0:null===(W=F.createPayment)||void 0===W?void 0:W._id)),w("teleBirr"),f("teleBirrProcessing"));return}}if((null==em?void 0:null===(n=em.name)||void 0===n?void 0:n.toLowerCase())==="awash"){if("unauthenticated"===I)try{E(!0),await b.o.post("/otp/sendTeleOtp",{phoneNumber:a.phoneNumber}),O({method:"awash",payload:{lotteryId:o._id,phoneNumber:a.phoneNumber,tickets:o.selectedTickets,paymentMethod:{id:null==em?void 0:em._id,name:null==em?void 0:em.name},location:t||{latitude:0,longitude:0},...ev&&{affiliateId:ev}},response:null}),M(!0),E(!1);return}catch(e){E(!1),S((null==e?void 0:null===(D=e.response)||void 0===D?void 0:null===(L=D.data)||void 0===L?void 0:L.message)||"Failed to send OTP");return}else{let e=await s.M.buyTicketWithAwashLotteryDetail({lotteryId:o._id,phoneNumber:null==B?void 0:null===(A=B.user)||void 0===A?void 0:A.phoneNumber,paymentMethod:{id:null==em?void 0:em._id,name:null==em?void 0:em.name},location:t||{latitude:0,longitude:0},tickets:o.selectedTickets,...ev&&{affiliateId:ev}});localStorage.setItem("phone",null==B?void 0:null===(q=B.user)||void 0===q?void 0:q.phoneNumber);let i=null===(R=e.data)||void 0===R?void 0:null===(z=R.createPayment)||void 0===z?void 0:z.checkout_url;i&&"string"==typeof i&&i.trim()&&i.startsWith("http")?window.location.replace(i):(x(e.paymentId||(null===(K=e.data)||void 0===K?void 0:null===(J=K.createPayment)||void 0===J?void 0:J._id)),w("awash"),f("awashProcessing"));return}}if((null==em?void 0:null===(d=em.name)||void 0===d?void 0:d.toLowerCase())==="coop"){if("unauthenticated"===I)try{E(!0),await b.o.post("/otp/sendTeleOtp",{phoneNumber:a.phoneNumber}),O({method:"coop",payload:{lotteryId:o._id,phoneNumber:a.phoneNumber,tickets:o.selectedTickets,paymentMethod:{id:null==em?void 0:em._id,name:null==em?void 0:em.name},location:t||{latitude:0,longitude:0},...ev&&{affiliateId:ev}},response:null}),M(!0),E(!1);return}catch(e){E(!1),S((null==e?void 0:null===(V=e.response)||void 0===V?void 0:null===(Q=V.data)||void 0===Q?void 0:Q.message)||"Failed to send OTP");return}else{let e=null==B?void 0:null===(Z=B.user)||void 0===Z?void 0:Z.phoneNumber;g.p.isSocketConnected()?g.p.joinPhoneNumberRoom(e):await g.p.connect(void 0,e),s.M.buyTicketWithCoopLotteryDetail({lotteryId:o._id,phoneNumber:e,paymentMethod:{id:null==em?void 0:em._id,name:null==em?void 0:em.name},location:t||{latitude:0,longitude:0},tickets:o.selectedTickets,...ev&&{affiliateId:ev}}).then(e=>{var t,i;let a=e.paymentId||(null===(i=e.data)||void 0===i?void 0:null===(t=i.createPayment)||void 0===t?void 0:t._id);a&&(x(a),k(a))}).catch(e=>{S(e.message||"Error initiating Coop payment"),_(!1),i(!1)}),localStorage.setItem("phone",e),w("coop"),f("coopProcessing");return}}if((null==em?void 0:null===(r=em.name)||void 0===r?void 0:r.toLowerCase())==="bunnabank"){if("unauthenticated"===I)try{E(!0),await b.o.post("/otp/sendTeleOtp",{phoneNumber:a.phoneNumber}),O({method:"bunnaBank",payload:{lotteryId:o._id,phoneNumber:a.phoneNumber,tickets:o.selectedTickets,paymentMethod:{id:null==em?void 0:em._id,name:null==em?void 0:em.name},location:t||{latitude:0,longitude:0},...ev&&{affiliateId:ev}},response:null}),M(!0),E(!1);return}catch(e){E(!1),S((null==e?void 0:null===(G=e.response)||void 0===G?void 0:null===($=G.data)||void 0===$?void 0:$.message)||"Failed to send OTP");return}else{let e=await s.M.buyTicketWithBunnaBankLotteryDetail({lotteryId:o._id,phoneNumber:null==B?void 0:null===(H=B.user)||void 0===H?void 0:H.phoneNumber,paymentMethod:{id:null==em?void 0:em._id,name:null==em?void 0:em.name},location:t||{latitude:0,longitude:0},tickets:o.selectedTickets,...ev&&{affiliateId:ev}});localStorage.setItem("phone",null==B?void 0:null===(U=B.user)||void 0===U?void 0:U.phoneNumber);let i=null===(Y=e.data)||void 0===Y?void 0:null===(X=Y.createPayment)||void 0===X?void 0:X.checkout_url;i&&"string"==typeof i&&i.trim()&&i.startsWith("http")?window.location.replace(i):(x(e.paymentId||(null===(et=e.data)||void 0===et?void 0:null===(ee=et.createPayment)||void 0===ee?void 0:ee._id)),w("bunnaBank"),k(e.paymentId||(null===(ea=e.data)||void 0===ea?void 0:null===(ei=ea.createPayment)||void 0===ei?void 0:ei._id)),f("bunnaBankProcessing"));return}}if((null==em?void 0:null===(u=em.name)||void 0===u?void 0:u.toLowerCase())==="tsehay"){if("unauthenticated"===I)try{E(!0),await b.o.post("/otp/sendTeleOtp",{phoneNumber:a.phoneNumber}),O({method:"tsehay",payload:{lotteryId:o._id,phoneNumber:a.phoneNumber,tickets:o.selectedTickets,paymentMethod:{id:null==em?void 0:em._id,name:null==em?void 0:em.name},location:t||{latitude:0,longitude:0},...ev&&{affiliateId:ev}},response:null}),M(!0),E(!1);return}catch(e){E(!1),S((null==e?void 0:null===(el=e.response)||void 0===el?void 0:null===(eo=el.data)||void 0===eo?void 0:eo.message)||"Failed to send OTP");return}else{let e=await s.M.buyTicketWithTsehayBankLotteryDetail({lotteryId:o._id,phoneNumber:null==B?void 0:null===(en=B.user)||void 0===en?void 0:en.phoneNumber,paymentMethod:{id:null==em?void 0:em._id,name:null==em?void 0:em.name},location:t||{latitude:0,longitude:0},tickets:o.selectedTickets,...ev&&{affiliateId:ev}});localStorage.setItem("phone",null==B?void 0:null===(ed=B.user)||void 0===ed?void 0:ed.phoneNumber);let i=null===(es=e.data)||void 0===es?void 0:null===(er=es.createPayment)||void 0===er?void 0:er.checkout_url;if(i&&"string"==typeof i&&i.trim()&&i.startsWith("http"))window.location.replace(i);else{let t=e.paymentId||(null===(ec=e.data)||void 0===ec?void 0:null===(eu=ec.createPayment)||void 0===eu?void 0:eu._id);x(t),w("tsehay"),k(t),f("tsehayBankProcessing")}return}}let eh=await s.M.buyTicketLoggedOut({lotteryId:o._id,phoneNumber:"authenticated"===I?null==B?void 0:null===(c=B.user)||void 0===c?void 0:c.phoneNumber:a.phoneNumber,tickets:o.selectedTickets,paymentMethod:{id:null==em?void 0:em._id,name:null==em?void 0:em.name},location:t||{latitude:0,longitude:0},...ev&&{affiliateId:ev}});localStorage.setItem("phone","authenticated"===I?null==B?void 0:null===(m=B.user)||void 0===m?void 0:m.ph
1oneNumber:a.phoneNumber),window.location.replace(eh.checkout_url);return}catch(t){S(e(t.message))}finally{_(!1),i(!1)}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("form",{onSubmit:q(J),className:"bg-white w-full max-w-lg p-6 rounded-xl shadow-xl relative",children:[(0,a.jsx)("button",{className:"absolute top-4 right-4 text-gray-600 hover:text-black",onClick:()=>f(""),children:(0,a.jsx)(u.QCr,{size:18})}),(0,a.jsx)("div",{className:"mb-4 text-center",children:(0,a.jsx)("h2",{className:"text-2xl font-semibold text-[#001F5B]",children:e("Checkout")})}),"unauthenticated"===I&&(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-[#001F5B]",children:e("Phone number")}),(0,a.jsx)("input",{type:"tel",...A("phoneNumber",{required:e("Phone number is required"),pattern:{value:/^09[0-9]{8}$/,message:e("Invalid phone number format")}}),placeholder:e("09xxxxxxxx"),className:"w-full mt-2 p-3 text-sm border rounded-lg focus:outline-none ".concat(z.phoneNumber?"border-red-500":"border-gray-300")}),z.phoneNumber&&(0,a.jsx)("p",{className:"mt-1 text-sm text-red-600",children:e(z.phoneNumber.message)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium text-[#001F5B] mb-2",children:e("Payment Methods")}),(0,a.jsx)("div",{className:"mb-4",children:v.b.filter(e=>e.name.toLowerCase().includes("tele")).map(e=>(0,a.jsx)("div",{onClick:()=>!N&&j(e._id),className:"border rounded-lg p-2 cursor-pointer transition hover:shadow-md ".concat(P===e._id?"border-[#B87D06] bg-[#FFF7E6]":"border-gray-200 bg-white"),children:(0,a.jsx)(n.default,{src:e.image,alt:e.name,width:90,height:60,className:"w-full h-14 object-contain"})},e._id))}),(0,a.jsx)("div",{className:"mb-4",children:v.b.filter(e=>"tele birr"===e.name.trim().toLowerCase()).map(e=>(0,a.jsx)("div",{onClick:()=>!N&&j(e._id),className:"border rounded-lg p-2 cursor-pointer transition hover:shadow-md ".concat(P===e._id?"border-[#B87D06] bg-[#FFF7E6]":"border-gray-200 bg-white"),children:(0,a.jsx)(n.default,{src:e.image,alt:e.name,width:90,height:60,className:"w-full h-14 object-contain"})},e._id))}),(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"grid grid-cols-3 md:grid-cols-5 gap-2",children:v.b.filter(e=>"tele"!==e.name.trim().toLowerCase()).map(e=>(0,a.jsx)("div",{onClick:()=>!N&&j(e._id),className:"border rounded-lg p-2 cursor-pointer transition hover:shadow-md ".concat(P===e._id?"border-[#B87D06] bg-[#FFF7E6]":"border-gray-200 bg-white"),children:(0,a.jsx)(n.default,{src:e.image,alt:e.name,width:90,height:60,className:"w-full h-14 object-contain"})},e._id))})})]}),T&&(0,a.jsx)("p",{className:"text-sm text-red-600 text-center",children:e(T)}),(0,a.jsx)("div",{children:(0,a.jsx)("button",{type:"submit",disabled:N,className:"w-full py-3 text-white rounded-lg text-lg font-semibold shadow-sm transition hover:opacity-90",style:{backgroundColor:"#B87D06"},children:N?(0,a.jsx)("div",{className:"flex justify-center",children:(0,a.jsx)(l.R,{color:"#fff",height:20,width:20})}):e("Buy Ticket")})})]}),C&&(0,a.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:(0,a.jsxs)("div",{className:"bg-white rounded-lg p-6 w-96 max-w-md",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold mb-4 text-center",children:e("Enter your otp")}),(0,a.jsx)("div",{className:"mb-4",children:(0,a.jsx)("input",{type:"text",value:W,onChange:e=>F(e.target.value),placeholder:e("Enter OTP"),className:"w-full p-3 border border-gray-300 rounded-lg focus:outline-none focus:border-[#B87D06]",maxLength:6})}),T&&(0,a.jsx)("p",{className:"text-sm text-red-600 mb-4 text-center",children:T}),(0,a.jsxs)("div",{className:"flex space-x-3",children:[(0,a.jsx)("button",{onClick:()=>{M(!1),F(""),O(null),S("")},className:"flex-1 py-2 px-4 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50",children:e("Cancel")}),(0,a.jsx)("button",{onClick:R,disabled:L||!W.trim(),className:"flex-1 py-2 px-4 bg-[#B87D06] text-white rounded-lg hover:opacity-90 disabled:opacity-50",children:L?(0,a.jsx)("div",{className:"flex justify-center",children:(0,a.jsx)(l.R,{color:"#fff",height:16,width:16})}):e("Verify")})]})]})})]})}},28902:(e,t,i)=>{i.d(t,{PaymentProvider:()=>d,u:()=>n});var a=i(95155),o=i(12115);let l=(0,o.createContext)(void 0),n=()=>{let e=(0,o.useContext)(l);if(void 0===e)throw Error("usePayment must be used within a PaymentProvider");return e},d=e=>{let{children:t}=e,[i,n]=(0,o.useState)(null),[d,r]=(0,o.useState)(null),[s,u]=(0,o.useState)(null),[c,m]=(0,o.useState)(null);return(0,a.jsx)(l.Provider,{value:{currentPaymentId:i,setCurrentPaymentId:n,currentPaymentMethod:d,setCurrentPaymentMethod:r,paymentAmount:s,setPaymentAmount:u,depositResultData:c,setDepositResultData:m,clearPaymentData:()=>{n(null),r(null),u(null),m(null)}},children:t})}},33171:(e,t,i)=>{i.d(t,{A:()=>p,b:()=>h});var a=i(95155),o=i(12115),l=i(62177),n=i(66766),d=i(99620),r=i(27043),s=i(94355),u=i(64315),c=i(69021),m=i(47908),v=i(28902);let h=[{_id:"6723e4332ebbf9b3878a28bc",name:"cbebirr",status:"active",__v:0,image:"https://res.cloudinary.com/dz0p3pvey/image/upload/v1739626676/ykqrgzwgps4pdyitgs2b.png"},{_id:"679c712f99d7f57b2596ca31",name:"tele",image:"https://res.cloudinary.com/dz0p3pvey/image/upload/v1739620801/q1b2qfuehmzqudqtwhwm.png",status:"active",__v:0},{_id:"68541824d00a1793e41c8aca",name:"awash",image:"/logo/Awash-bank-logo.svg",status:"active",__v:0},{_id:"689b280fbaef7bf5cf955876",name:"coop",image:"/logo/Coopay Ebirr.png",status:"active",__v:0}];function p(){let e=(0,r.useTranslations)(""),{setOpenedModal:t}=(0,c.h)(),{setCurrentPaymentId:i,setCurrentPaymentMethod:p,setPaymentAmount:y}=(0,v.u)(),{subscribeToPayment:b,paymentError:g,clearPaymentError:f}=(0,m.e)(),[w,x]=(0,o.useState)(""),[k,N]=(0,o.useState)(""),[_,P]=(0,o.useState)(!1),[j,B]=(0,o.useState)(!1),[I,T]=(0,o.useState)(!1),[S,C]=(0,o.useState)(!1),[M,W]=(0,o.useState)(!1),[F,L]=(0,o.useState)(!1),{register:E,handleSubmit:D,setFocus:O,formState:{errors:A,isSubmitting:q}}=(0,l.mN)(),z=async a=>{if(!w){N(e("Please select a payment method"));return}let o=h.find(e=>w===e._id);try{var l,n,d,r,u,c,m,v,g,x,k,_,j,I,S,M,F,E,D,O,A,q,z,R,J,K,Q,V,Z,$,G,H,U,X,Y,ee,et,ei,ea,eo,el,en;if(N(""),f(),y(a.amount),(null==o?void 0:null===(l=o.name)||void 0===l?void 0:l.toLowerCase())==="tele"){P(!0);try{let e=await s.M.depositWithTeleBirr({amount:a.amount}),o=null===(v=e.data)||void 0===v?void 0:null===(m=v.createPayment)||void 0===m?void 0:m.checkout_url;o&&"string"==typeof o&&o.trim()&&o.startsWith("http")?window.location.replace(o):(i(e.paymentId||(null===(x=e.data)||void 0===x?void 0:null===(g=x.createPayment)||void 0===g?void 0:g._id)),p("teleBirr"),b(e.paymentId||(null===(_=e.data)||void 0===_?void 0:null===(k=_.createPayment)||void 0===k?void 0:k._id)),t("teleBirrProcessing"))}
1catch(t){N(e((null==t?void 0:t.message)||"Error initiating TeleBirr payment")),P(!1)}return}if((null==o?void 0:null===(n=o.name)||void 0===n?void 0:n.toLowerCase())==="awash"){B(!0);try{let e=await s.M.depositWithAwash({amount:a.amount}),o=null===(I=e.data)||void 0===I?void 0:null===(j=I.createPayment)||void 0===j?void 0:j.checkout_url;o&&"string"==typeof o&&o.trim()&&o.startsWith("http")?window.location.replace(o):(i(e.paymentId||(null===(M=e.data)||void 0===M?void 0:null===(S=M.createPayment)||void 0===S?void 0:S._id)),p("awash"),b(e.paymentId||(null===(E=e.data)||void 0===E?void 0:null===(F=E.createPayment)||void 0===F?void 0:F._id)),t("awashProcessing"))}catch(t){N(e((null==t?void 0:t.message)||"Error initiating Awash Bank payment")),B(!1)}return}if((null==o?void 0:null===(d=o.name)||void 0===d?void 0:d.toLowerCase())==="coop"){T(!0);try{let e=await s.M.depositWithCoop({amount:a.amount}),o=null===(O=e.data)||void 0===O?void 0:null===(D=O.createPayment)||void 0===D?void 0:D.checkout_url;o&&"string"==typeof o&&o.trim()&&o.startsWith("http")?window.location.replace(o):(i(e.paymentId||(null===(q=e.data)||void 0===q?void 0:null===(A=q.createPayment)||void 0===A?void 0:A._id)),p("coop"),b(e.paymentId||(null===(R=e.data)||void 0===R?void 0:null===(z=R.createPayment)||void 0===z?void 0:z._id)),t("coopProcessing"))}catch(t){N(e((null==t?void 0:t.message)||"Error initiating Coop payment")),T(!1)}return}if((null==o?void 0:null===(r=o.name)||void 0===r?void 0:r.toLowerCase())==="cbebirr"){C(!0);try{let e=await s.M.depositWithCbeBirr({amount:a.amount}),o=null===(K=e.data)||void 0===K?void 0:null===(J=K.createPayment)||void 0===J?void 0:J.checkout_url;o&&"string"==typeof o&&o.trim()&&o.startsWith("http")?window.location.replace(o):(i(e.paymentId||(null===(V=e.data)||void 0===V?void 0:null===(Q=V.createPayment)||void 0===Q?void 0:Q._id)),p("cbeBirr"),b(e.paymentId||(null===($=e.data)||void 0===$?void 0:null===(Z=$.createPayment)||void 0===Z?void 0:Z._id)),t("cbeBirrProcessing"))}catch(t){N(e((null==t?void 0:t.message)||"Error initiating CBE Birr payment")),C(!1)}return}if((null==o?void 0:null===(u=o.name)||void 0===u?void 0:u.toLowerCase())==="bunnabank"){W(!0);try{let e=await s.M.depositWithBunnaBank({amount:a.amount}),o=null===(H=e.data)||void 0===H?void 0:null===(G=H.createPayment)||void 0===G?void 0:G.checkout_url;o&&"string"==typeof o&&o.trim()&&o.startsWith("http")?window.location.replace(o):(i(e.paymentId||(null===(X=e.data)||void 0===X?void 0:null===(U=X.createPayment)||void 0===U?void 0:U._id)),p("bunnaBank"),b(e.paymentId||(null===(ee=e.data)||void 0===ee?void 0:null===(Y=ee.createPayment)||void 0===Y?void 0:Y._id)),t("bunnaBankProcessing"))}catch(t){N(e((null==t?void 0:t.message)||"Error initiating Bunna Bank payment")),W(!1)}return}if((null==o?void 0:null===(c=o.name)||void 0===c?void 0:c.toLowerCase())==="tsehay"){L(!0);try{let e=await s.M.depositWithTsehayBank({amount:a.amount}),o=null===(ei=e.data)||void 0===ei?void 0:null===(et=ei.createPayment)||void 0===et?void 0:et.checkout_url;o&&"string"==typeof o&&o.trim()&&o.startsWith("http")?window.location.replace(o):(i(e.paymentId||(null===(eo=e.data)||void 0===eo?void 0:null===(ea=eo.createPayment)||void 0===ea?void 0:ea._id)),p("tsehay"),b(e.paymentId||(null===(en=e.data)||void 0===en?void 0:null===(el=en.createPayment)||void 0===el?void 0:el._id)),t("tsehayBankProcessing"))}catch(t){N(e((null==t?void 0:t.message)||"Error initiating Tsehay Bank payment")),L(!1)}return}if((null==o?void 0:o._id)==="67f61c6b59240a16be2f15da"){localStorage.setItem("kacha",a.amount),localStorage.setItem("transactionType","deposit"),t("confirmKacha");return}let h=await s.M.deposit({amount:a.amount,paymentMethod:{id:null==o?void 0:o._id,name:null==o?void 0:o.name}});window.location.href=h.checkout_url}catch(t){N(e((null==t?void 0:t.message)?t.message:"Error adding balance"))}};return(0,o.useEffect)(()=>{O("amount")},[O]),(0,a.jsx)("div",{className:"fixed inset-0 z-50 bg-black bg-opacity-60 flex items-center justify-center",children:(0,a.jsxs)("form",{onSubmit:D(z),className:"bg-white w-full max-w-lg p-6 rounded-xl shadow-xl relative",children:[(0,a.jsx)("div",{className:"absolute left-4 top-4 text-gray-600 cursor-pointer",onClick:()=>t(""),children:(0,a.jsx)(u.QVr,{size:20})}),(0,a.jsx)("h1",{className:"text-xl font-bold text-center mb-6 text-[#001F5B]",children:e("Deposit")}),(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsx)("label",{htmlFor:"amount",className:"block text-sm font-medium text-gray-700 2",children:e("Amount")}),(0,a.jsx)("input",{id:"amount",type:"number",placeholder:e("Enter amount"),className:"w-full mt-2 p-3 text-sm border rounded-lg focus:outline-none",...E("amount",{required:"Amount is required",min:{value:10,message:"Amount cannot be less than 10"},max:{value:1e3,message:"Deposit of 1000 Birr or less is allowed"}})}),A.amount&&(0,a.jsx)("p",{className:"text-red-500 text-sm mt-1",children:e(A.amount.message)})]}),(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:e("Payment Methods")}),(0,a.jsxs)("div",{className:"rounded-lg mb-2",children:[h.filter(e=>"tele"===e.name.trim().toLowerCase()).map(e=>(0,a.jsx)("div",{onClick:()=>x(e._id),className:"mb-3 border rounded-lg p-2 cursor-pointer transition hover:shadow-md ".concat(w===e._id?"border-[#B87D06] bg-[#FFF7E6]":"border-gray-200 bg-white"),children:(0,a.jsx)(n.default,{src:e.image,alt:e.name,width:90,height:60,className:"w-full h-14 object-contain"})},e._id)),(0,a.jsx)("div",{className:"grid grid-cols-3 md:grid-cols-5 ga
1p-2",children:h.filter(e=>"tele"!==e.name.trim().toLowerCase()).map(e=>"bunnabank"===e.name.trim().toLowerCase()?null:(0,a.jsx)("div",{onClick:()=>x(e._id),className:"border rounded-lg p-2 cursor-pointer transition hover:shadow-md ".concat(w===e._id?"border-[#B87D06] bg-[#FFF7E6]":"border-gray-200 bg-white"),children:(0,a.jsx)(n.default,{src:e.image,alt:e.name,width:90,height:60,className:"w-full h-14 object-contain"})},e._id))})]}),k&&(0,a.jsx)("p",{className:"text-center text-red-600 text-sm mb-4",children:e(k)}),g&&(0,a.jsx)("p",{className:"text-center text-red-600 text-sm mb-4",children:e(g)}),(0,a.jsx)("button",{type:"submit",disabled:q||_||j||I||S||M||F,className:"w-full py-3 flex items-center justify-center text-white font-semibold rounded-lg transition duration-200 disabled:opacity-50",style:{backgroundColor:"#B87D06"},children:q||_||j||I||S||M||F?(0,a.jsx)(d.R,{color:"white",height:20,width:20}):(0,a.jsxs)(a.Fragment,{children:[e("Deposit")," ",(0,a.jsx)(u.Z0P,{className:"ml-2"})]})})]})})}},47908:(e,t,i)=>{i.d(t,{PaymentStatusProvider:()=>s,e:()=>r});var a=i(95155),o=i(12115),l=i(12108),n=i(90984);let d=(0,o.createContext)(void 0),r=()=>{let e=(0,o.useContext)(d);if(!e)throw Error("usePaymentStatus must be used within a PaymentStatusProvider");return e},s=e=>{let{children:t}=e,{data:i}=(0,l.useSession)(),[r,s]=(0,o.useState)(null),[u,c]=(0,o.useState)(null),[m,v]=(0,o.useState)(null),h=async e=>{try{await n.p.connect(e),v(null)}catch(e){console.error("Failed to connect WebSocket:",e),v(e.message||"Failed to connect to payment service")}},p=()=>{n.p.disconnect(),s(null),c(null)};return(0,o.useEffect)(()=>{var e;let t=null==i?void 0:null===(e=i.user)||void 0===e?void 0:e.id;return t&&h(t),()=>{p()}},[i]),(0,a.jsx)(d.Provider,{value:{currentPaymentStatus:r,currentPaymentId:u,connectWebSocket:h,disconnectWebSocket:p,subscribeToPayment:e=>{c(e),s("pending"),n.p.subscribeToPaymentStatus(e,e=>{s(e.status),"success"===e.status||"failed"===e.status&&v(e.message||"Payment failed")})},unsubscribeFromPayment:e=>{n.p.unsubscribeFromPaymentStatus(e),s(null),c(null)},paymentError:m,clearPaymentError:()=>{v(null)}},children:t})}}}]);
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.