coinley-checkout 0.7.4 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,5 +13,5 @@ const ba=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
|
|
13
13
|
* @license qrcode.react
|
14
14
|
* Copyright (c) Paul O'Shannessy
|
15
15
|
* SPDX-License-Identifier: ISC
|
16
|
-
*/function wp(t,e=0){const n=[];return t.forEach((function(t,r){let i=null;t.forEach((function(s,a){if(!s&&null!==i)return n.push(`M${i+e} ${r+e}h${a-i}v1H${i+e}z`),void(i=null);if(a!==t.length-1)s&&null===i&&(i=a);else{if(!s)return;null===i?n.push(`M${a+e},${r+e} h1v1H${a+e}z`):n.push(`M${i+e},${r+e} h${a+1-i}v1H${i+e}z`)}}))})),n.join("")}function vp(t,e){return t.slice().map(((t,n)=>n<e.y||n>=e.y+e.h?t:t.map(((t,n)=>(n<e.x||n>=e.x+e.w)&&t))))}function bp({value:t,level:n,minVersion:r,includeMargin:i,marginSize:s,imageSettings:a,size:o,boostLevel:l}){let c=e.useMemo((()=>{const e=(Array.isArray(t)?t:[t]).reduce(((t,e)=>(t.push(...hp.QrSegment.makeSegments(e)),t)),[]);return hp.QrCode.encodeSegments(e,dp[n],r,void 0,void 0,l)}),[t,n,r,l]);const{cells:u,margin:h,numCells:d,calculatedImageSettings:p}=e.useMemo((()=>{let t=c.getModules();const e=function(t,e){return null!=e?Math.max(Math.floor(e),0):t?4:0}(i,s),n=t.length+2*e,r=function(t,e,n,r){if(null==r)return null;const i=t.length+2*n,s=Math.floor(.1*e),a=i/e,o=(r.width||s)*a,l=(r.height||s)*a,c=null==r.x?t.length/2-o/2:r.x*a,u=null==r.y?t.length/2-l/2:r.y*a,h=null==r.opacity?1:r.opacity;let d=null;if(r.excavate){let t=Math.floor(c),e=Math.floor(u);d={x:t,y:e,w:Math.ceil(o+c-t),h:Math.ceil(l+u-e)}}return{x:c,y:u,h:l,w:o,excavation:d,opacity:h,crossOrigin:r.crossOrigin}}(t,o,e,a);return{cells:t,margin:e,numCells:n,calculatedImageSettings:r}}),[c,o,a,i,s]);return{qrcode:c,margin:h,cells:u,numCells:d,calculatedImageSettings:p}}var Ap=function(){try{(new Path2D).addPath(new Path2D)}catch(t){return!1}return!0}();e.forwardRef((function(t,n){const r=t,{value:i,size:s=pp,level:a=fp,bgColor:o=gp,fgColor:l=mp,includeMargin:c=_p,minVersion:u=yp,boostLevel:h,marginSize:d,imageSettings:p}=r,f=up(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:g}=f,m=up(f,["style"]),_=null==p?void 0:p.src,y=e.useRef(null),w=e.useRef(null),v=e.useCallback((t=>{y.current=t,"function"==typeof n?n(t):n&&(n.current=t)}),[n]),[b,A]=e.useState(!1),{margin:E,cells:x,numCells:k,calculatedImageSettings:S}=bp({value:i,level:a,minVersion:u,boostLevel:h,includeMargin:c,marginSize:d,imageSettings:p,size:s});e.useEffect((()=>{if(null!=y.current){const t=y.current,e=t.getContext("2d");if(!e)return;let n=x;const r=w.current,i=null!=S&&null!==r&&r.complete&&0!==r.naturalHeight&&0!==r.naturalWidth;i&&null!=S.excavation&&(n=vp(x,S.excavation));const a=window.devicePixelRatio||1;t.height=t.width=s*a;const c=s/k*a;e.scale(c,c),e.fillStyle=o,e.fillRect(0,0,k,k),e.fillStyle=l,Ap?e.fill(new Path2D(wp(n,E))):x.forEach((function(t,n){t.forEach((function(t,r){t&&e.fillRect(r+E,n+E,1,1)}))})),S&&(e.globalAlpha=S.opacity),i&&e.drawImage(r,S.x+E,S.y+E,S.w,S.h)}})),e.useEffect((()=>{A(!1)}),[_]);const N=cp({height:s,width:s},g);let C=null;return null!=_&&(C=e.createElement("img",{src:_,key:_,style:{display:"none"},onLoad:()=>{A(!0)},ref:w,crossOrigin:null==S?void 0:S.crossOrigin})),e.createElement(e.Fragment,null,e.createElement("canvas",cp({style:N,height:s,width:s,ref:v,role:"img"},m)),C)})).displayName="QRCodeCanvas";var Ep=e.forwardRef((function(t,n){const r=t,{value:i,size:s=pp,level:a=fp,bgColor:o=gp,fgColor:l=mp,includeMargin:c=_p,minVersion:u=yp,boostLevel:h,title:d,marginSize:p,imageSettings:f}=r,g=up(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:m,cells:_,numCells:y,calculatedImageSettings:w}=bp({value:i,level:a,minVersion:u,boostLevel:h,includeMargin:c,marginSize:p,imageSettings:f,size:s});let v=_,b=null;null!=f&&null!=w&&(null!=w.excavation&&(v=vp(_,w.excavation)),b=e.createElement("image",{href:f.src,height:w.h,width:w.w,x:w.x+m,y:w.y+m,preserveAspectRatio:"none",opacity:w.opacity,crossOrigin:w.crossOrigin}));const A=wp(v,m);return e.createElement("svg",cp({height:s,width:s,viewBox:`0 0 ${y} ${y}`,ref:n,role:"img"},g),!!d&&e.createElement("title",null,d),e.createElement("path",{fill:o,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),e.createElement("path",{fill:l,d:A,shapeRendering:"crispEdges"}),b)}));Ep.displayName="QRCodeSVG";const xp=({walletAddress:t,amount:n,currency:r,network:i,theme:s="light",size:a=200})=>{const[o,l]=e.useState(""),[c,u]=e.useState(null);e.useEffect((()=>{if(t&&"No address configured"!==t)try{let e;switch(i){case"tron":e="TRX"===r?`tronlink://transfer?to=${t}&amount=${n}`:t;break;case"algorand":e=`algorand://${t}?amount=${Math.floor(1e6*parseFloat(n))}`;break;case"bsc":if("BNB"===r)e=`ethereum:${t}@56?value=${p(n)}`;else{const i=h(r,"bsc");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${d(n,r)}@56`:t}break;default:if("ETH"===r)e=`ethereum:${t}@1?value=${p(n)}`;else{const i=h(r,"ethereum");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${d(n,r)}`:t}}l(e),u(null)}catch(e){console.error("Error generating QR code:",e),u("Error generating payment QR code")}else u("No wallet address configured for this network")}),[t,n,r,i]);const h=(t,e)=>{var n;return(null==(n={ethereum:{USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},bsc:{USDT:"0x55d398326f99059fF775485246999027B3197955",USDC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},tron:{USDT:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",USDC:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8"}}[e])?void 0:n[t])||""},d=(t,e)=>{const n="USDT"===e||"USDC"===e?6:18;return Math.floor(parseFloat(t)*Math.pow(10,n)).toString()},p=t=>Math.floor(1e18*parseFloat(t)).toString(),f=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t);return Xd.jsxs("div",{className:"flex flex-col items-center",children:[c?Xd.jsxs("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 mx-auto mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Xd.jsx("p",{className:"font-medium",children:c})]}):Xd.jsx("div",{className:"p-4 rounded-lg bg-white mb-3 shadow-sm border",children:o&&Xd.jsx(Ep,{value:o,size:a,bgColor:"dark"===s?"#374151":"#FFFFFF",fgColor:"dark"===s?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),Xd.jsxs("div",{className:"text-center text-sm text-gray-700 mb-4",children:[Xd.jsxs("p",{className:"font-semibold text-gray-800 flex items-center justify-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M12 12h-4.01M12 12V8.01"})}),"Scan to Pay with ",r]}),Xd.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Scan with your ",f(i)," wallet app"]})]}),Xd.jsxs("div",{className:"w-full mb-4 p-3 bg-gray-50 rounded-lg",children:[Xd.jsxs("div",{className:"flex justify-between items-center",children:[Xd.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Amount to Pay:"}),Xd.jsxs("span",{className:"text-lg font-bold text-[#7042D2]",children:[n," ",r]})]}),Xd.jsxs("div",{className:"flex justify-between items-center mt-1",children:[Xd.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),Xd.jsx("span",{className:"text-xs font-medium text-gray-700",children:f(i)})]})]}),Xd.jsx("div",{className:"w-full",children:Xd.jsxs("div",{className:"p-3 rounded bg-blue-50 border border-blue-200",children:[Xd.jsxs("h4",{className:"text-sm font-medium mb-2 text-blue-800 flex items-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Payment Instructions"]}),Xd.jsxs("ol",{className:"text-xs space-y-1 text-blue-700",children:[Xd.jsxs("li",{children:["1. Open your crypto wallet app (",(g=i,{ethereum:["MetaMask","Trust Wallet","Coinbase Wallet"],bsc:["MetaMask","Trust Wallet","SafePal"],tron:["TronLink","Trust Wallet"],algorand:["Pera Wallet","MyAlgo Wallet"]}[g]||["MetaMask","Trust Wallet"]).join(", "),")"]}),Xd.jsx("li",{children:"2. Scan the QR code above or copy the wallet address"}),Xd.jsxs("li",{children:["3. Send exactly ",Xd.jsxs("strong",{children:[n," ",r]})," on ",f(i)," network"]}),Xd.jsx("li",{children:'4. Click "I have sent the payment" button below after sending'})]}),Xd.jsx("div",{className:"mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded",children:Xd.jsxs("p",{className:"text-xs text-yellow-800",children:[Xd.jsx("strong",{children:"Important:"})," Make sure you're sending on the correct network (",f(i),") and using the exact amount shown above."]})})]})})]});var g},kp=({status:t,message:n,theme:r="light",payment:i=null,transactionHash:s=null,selectedPaymentMethod:a=null,merchantName:o="Merchant",onClose:l=null,processingStartTime:c=null,paymentNetwork:u=null,pendingBackendConfirmation:h=!1})=>{const[d,p]=e.useState(!1),[f,g]=e.useState(0),[m,_]=e.useState(!1),[y,w]=e.useState(1);e.useEffect((()=>{let e;return"processing"===t&&c&&(e=setInterval((()=>{const t=Math.floor((Date.now()-c)/1e3);g(t),t>=5&&1===y&&w(2),t>=15&&2===y&&w(3),t>=30&&!m&&_(!0)}),1e3)),()=>clearInterval(e)}),[t,c,y,m]);const v=()=>__async(this,null,(function*(){if(s)try{yield navigator.clipboard.writeText(s),p(!0),setTimeout((()=>p(!1)),2e3)}catch(t){console.error("Failed to copy transaction hash:",t)}})),b=()=>{console.log("Payment success screen close button clicked"),l&&l()},A=()=>{switch(t){case"processing":return Xd.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return Xd.jsx("div",{className:"rounded-full h-16 w-16 bg-green-500 flex items-center justify-center",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-10 w-10 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return Xd.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}},E=()=>{switch(t){case"processing":return"dark"===r?"text-blue-300":"text-blue-600";case"success":return"dark"===r?"text-green-300":"text-green-600";case"error":return"dark"===r?"text-red-300":"text-red-600";default:return"dark"===r?"text-gray-300":"text-gray-600"}};return"success"===t?Xd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Xd.jsx("div",{className:"mb-6",children:A()}),Xd.jsx("h3",{className:"text-2xl font-bold mb-3 "+("dark"===r?"text-white":"text-gray-900"),children:"Payment Successful!"}),i&&a&&Xd.jsxs("p",{className:"text-center max-w-[235px] mb-6 "+("dark"===r?"text-gray-300":"text-gray-600"),children:["Your payment of ",Xd.jsxs("span",{className:"text-[#7042D2] font-semibold",children:[i.totalAmount||i.amount," ",a.currency]})," has been completed."]}),h&&Xd.jsxs("div",{className:"flex items-center justify-center mb-4 text-xs text-gray-500 bg-gray-50 rounded-full px-3 py-1",children:[Xd.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-3 w-3 text-gray-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[Xd.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Xd.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Verifying on blockchain"]}),s&&Xd.jsxs("div",{className:"w-full mb-6",children:[Xd.jsx("p",{className:"text-sm font-medium mb-2 "+("dark"===r?"text-gray-300":"text-gray-700"),children:"Transaction Hash:"}),Xd.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-colors "+("dark"===r?"bg-gray-700 border-gray-600 hover:bg-gray-600":"bg-gray-50 border-gray-200 hover:bg-gray-100"),onClick:v,children:[Xd.jsx("span",{className:"font-mono text-sm "+("dark"===r?"text-gray-300":"text-gray-700"),children:(S=s,S?S.length<=16?S:`${S.slice(0,8)}...${S.slice(-8)}`:"")}),Xd.jsxs("div",{className:"flex items-center",children:[d?Xd.jsx("span",{className:"text-green-500 text-xs font-medium mr-2",children:"Copied!"}):null,Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 "+("dark"===r?"text-gray-400":"text-gray-500"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]})]})]}),Xd.jsx("div",{className:"w-full p-4 rounded-lg border mb-6 "+("dark"===r?"bg-gray-700 border-gray-600":"bg-gray-50 border-gray-200"),children:Xd.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[Xd.jsxs("div",{children:[Xd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===r?"text-gray-400":"text-gray-500"),children:"Merchant ID:"}),Xd.jsx("p",{className:"text-sm font-medium "+("dark"===r?"text-gray-300":"text-gray-700"),children:o})]}),Xd.jsxs("div",{children:[Xd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===r?"text-gray-400":"text-gray-500"),children:"Network:"}),Xd.jsx("p",{className:"text-sm font-medium "+("dark"===r?"text-gray-300":"text-gray-700"),children:a?(k=a.network,{ethereum:"Ethereum",bsc:"BSC",tron:"TRON",algorand:"Algorand"}[k]||k):"N/A"})]}),Xd.jsxs("div",{className:"col-span-2",children:[Xd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===r?"text-gray-400":"text-gray-500"),children:"Recipient:"}),Xd.jsx("p",{className:"text-sm font-mono "+("dark"===r?"text-gray-300":"text-gray-700"),children:(null==i?void 0:i.recipientWallet)?(x=i.recipientWallet,x?x.length<=16?x:`${x.slice(0,6)}...${x.slice(-4)}`:"N/A"):"N/A"})]})]})}),l&&Xd.jsx("button",{onClick:b,className:"w-full py-3 px-4 bg-[#7042D2] text-white font-medium rounded-2xl text-lg shadow-md hover:bg-[#5b34b1] transition-colors",style:{borderRadius:"1.5rem"},children:"Close"})]}):"error"===t?Xd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Xd.jsx("div",{className:"mb-4",children:A()}),Xd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"text-white":"text-gray-900"),children:"Payment Failed"}),Xd.jsx("p",{className:`text-center ${E()}`,children:n}),Xd.jsx("div",{className:"mt-4 p-2 rounded "+("dark"===r?"bg-gray-700":"bg-gray-100"),children:Xd.jsx("p",{className:"text-xs "+("dark"===r?"text-gray-300":"text-gray-600"),children:"Please try again or contact support if the problem persists."})})]}):Xd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Xd.jsx("div",{className:"mb-4",children:A()}),Xd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"text-white":"text-gray-900"),children:(()=>{switch(t){case"processing":return"Processing Payment";case"success":return"Payment Successful!";case"error":return"Payment Failed";default:return"Unknown Status"}})()}),Xd.jsx("p",{className:`text-center ${E()}`,children:n})]});var x,k,S},Sp=({size:t=24})=>Xd.jsxs("svg",{width:t,height:t,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Xd.jsxs("g",{clipPath:"url(#clip0_2786_457)",children:[Xd.jsx("path",{d:"M15.9979 5L15.845 5.52398V20.7287L15.9979 20.8826L22.9958 16.7107L15.9979 5Z",fill:"#343434"}),Xd.jsx("path",{d:"M15.9979 5L9 16.7107L15.9979 20.8826V13.5027V5Z",fill:"#8C8C8C"}),Xd.jsx("path",{d:"M15.9979 22.2186L15.9117 22.3245V27.7408L15.9979 27.9945L23 18.0488L15.9979 22.2186Z",fill:"#3C3C3B"}),Xd.jsx("path",{d:"M15.9979 27.9945V22.2186L9 18.0488L15.9979 27.9945Z",fill:"#8C8C8C"}),Xd.jsx("path",{d:"M15.9979 20.8818L22.9957 16.7099L15.9979 13.502V20.8818Z",fill:"#141414"}),Xd.jsx("path",{d:"M9.00006 16.7099L15.9979 20.8818V13.502L9.00006 16.7099Z",fill:"#393939"})]}),Xd.jsx("defs",{children:Xd.jsx("clipPath",{id:"clip0_2786_457",children:Xd.jsx("rect",{width:"14",height:"23",fill:"white",transform:"translate(9 5)"})})})]}),Np=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.42 8.68534C8.48853 8.61041 8.57583 8.55514 8.67287 8.52525C8.76992 8.49536 8.87319 8.49194 8.972 8.51534L20.875 11.4293C20.947 11.445 21.0146 11.4765 21.073 11.5213L23.495 13.2883C23.6127 13.3751 23.6923 13.5039 23.7173 13.6479C23.7422 13.792 23.7106 13.9401 23.629 14.0613L15.297 26.2523C15.2385 26.3388 15.1571 26.4074 15.0619 26.4503C14.9667 26.4932 14.8614 26.5088 14.7579 26.4953C14.6543 26.4818 14.5566 26.4398 14.4755 26.3739C14.3945 26.308 14.3334 26.2209 14.299 26.1223L8.306 9.25234C8.27276 9.15648 8.2657 9.05348 8.28557 8.95398C8.30543 8.85448 8.3515 8.76209 8.419 8.68634M10.383 11.7293L14.543 23.4413L15.227 17.3723L10.383 11.7293ZM16.341 17.5673L15.646 23.7423L21.529 15.1323L16.341 17.5673ZM22.06 13.6373L18.269 15.4173L20.809 12.7263L22.06 13.6373ZM19.664 12.2943L10.411 10.0303L15.836 16.3483L19.664 12.2943Z",fill:"black"})}),Cp=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M17.2512 9.5H19.7036L20.7785 13.4753H23.3083L21.5804 16.4753L24 25.4973H21.4916L19.8625 19.446L16.3592 25.4987H13.5597L18.9725 16.1313L18.1018 12.8793L10.8022 25.5H8L17.2512 9.5Z",fill:"black"})}),Pp=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.52513 16.0195H20.7032C20.843 16.0195 20.9713 16.0794 21.0762 16.1873L22.8479 18.0574C23.1742 18.4051 22.9411 18.9925 22.4749 18.9925H11.2968C11.157 18.9925 11.0287 18.9326 10.9238 18.8247L9.15214 16.9545C8.82577 16.6069 9.05889 16.0195 9.52513 16.0195ZM9.15214 13.538L10.9238 11.6678C11.0171 11.5599 11.157 11.5 11.2968 11.5H22.4632C22.9295 11.5 23.1626 12.0874 22.8362 12.4351L21.0762 14.3052C20.9829 14.4131 20.843 14.473 20.7032 14.473H9.52513C9.05889 14.473 8.82577 13.8856 9.15214 13.538ZM22.8362 21.462L21.0645 23.3322C20.9596 23.4401 20.8314 23.5 20.6915 23.5H9.52513C9.05889 23.5 8.82577 22.9126 9.15214 22.5649L10.9238 20.6948C11.0171 20.5869 11.157 20.527 11.2968 20.527H22.4632C22.9295 20.527 23.1626 21.1144 22.8362 21.462Z",fill:"black"})}),Tp=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M19.0827 18.7809L20.8947 20.5933L15.9927 25.5L11.0907 20.594L12.902 18.7809L15.9927 21.8905L19.0827 18.7809ZM22.174 15.6873L24 17.4997L22.19 19.3121L20.3787 17.4997L22.174 15.6873ZM15.9927 15.6873L17.8033 17.4837L15.992 19.2967L14.1813 17.4997L15.9927 15.6873ZM9.81067 15.6873L11.6067 17.4997L9.812 19.2961L8 17.4997L9.81067 15.6873ZM15.9933 9.5L20.8933 14.39L19.082 16.2018L15.9933 13.1088L12.9027 16.2184L11.0913 14.406L15.9933 9.5Z",fill:"black"})}),Mp=({size:t=32})=>Xd.jsx("svg",{width:t-4,height:t-4,viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.36266 4.256C8.38876 4.0477 8.48986 3.85605 8.64705 3.7169C8.80423 3.57775 9.00673 3.50064 9.21666 3.5H17.0847C17.9472 3.55674 18.7895 3.78654 19.5613 4.1757C20.3331 4.56486 21.0187 5.10541 21.5772 5.76515C22.1357 6.42489 22.5557 7.19031 22.8121 8.0158C23.0685 8.84129 23.1561 9.70994 23.0697 10.57C22.6847 15.659 18.6737 17.5 16.5807 17.5H13.8367L12.6677 23.786C12.6333 23.987 12.5285 24.1693 12.372 24.3001C12.2156 24.431 12.0176 24.5018 11.8137 24.5H6.61966C6.49561 24.4979 6.3734 24.4696 6.26099 24.4171C6.14859 24.3646 6.04851 24.289 5.96728 24.1952C5.88604 24.1014 5.82548 23.9916 5.78954 23.8728C5.75359 23.7541 5.74307 23.6291 5.75866 23.506L7.05366 14H5.76566C5.65113 13.9998 5.53775 13.9771 5.43205 13.933C5.32635 13.8888 5.23041 13.8243 5.14975 13.743C5.06909 13.6616 5.00529 13.5652 4.96203 13.4591C4.91877 13.3531 4.89689 13.2395 4.89766 13.125C4.89766 12.642 5.28266 12.25 5.76566 12.25H7.29166L7.76066 8.75H5.76566C5.65113 8.74985 5.53775 8.72706 5.43205 8.68295C5.32635 8.63884 5.23041 8.57427 5.14975 8.49296C5.06909 8.41164 5.00529 8.31519 4.96203 8.20914C4.91877 8.10309 4.89689 7.98953 4.89766 7.875C4.89612 7.76084 4.91723 7.64751 4.95978 7.54157C5.00233 7.43563 5.06547 7.33918 5.14554 7.2578C5.22562 7.17643 5.32104 7.11174 5.42628 7.06749C5.53152 7.02324 5.6445 7.0003 5.75866 7H7.99166L8.36266 4.256ZM9.50366 8.75L9.02766 12.25H15.2787C15.51 12.2579 15.7404 12.218 15.9555 12.1326C16.1707 12.0473 16.3659 11.9185 16.5289 11.7541C16.6919 11.5898 16.8191 11.3936 16.9027 11.1778C16.9863 10.962 17.0244 10.7312 17.0147 10.5C17.0244 10.2688 16.9863 10.038 16.9027 9.82219C16.8191 9.60638 16.6919 9.41017 16.5289 9.24586C16.3659 9.08155 16.1707 8.95269 15.9555 8.86736C15.7404 8.78203 15.51 8.74208 15.2787 8.75H9.50366ZM8.79666 14H15.2787C15.738 14.0048 16.1936 13.9173 16.6184 13.7426C17.0433 13.568 17.4287 13.3098 17.7519 12.9833C18.0751 12.6569 18.3294 12.2689 18.4998 11.8423C18.6701 11.4157 18.7531 10.9593 18.7437 10.5C18.7437 8.54 17.2457 7 15.2787 7H9.74166L9.97266 5.25H16.9727C17.6045 5.28987 18.2218 5.45727 18.7872 5.74209C19.3527 6.02692 19.8546 6.42329 20.2627 6.90731C20.6709 7.39132 20.9768 7.95297 21.1621 8.55839C21.3473 9.16381 21.4081 9.80047 21.3407 10.43C21.0397 14.441 17.9457 15.75 16.5807 15.75H13.1157C12.9126 15.7514 12.7163 15.8234 12.5605 15.9537C12.4047 16.084 12.299 16.2644 12.2617 16.464L11.0997 22.75H7.61366L8.79666 14Z",fill:"#3B6FEF"})}),Bp=({size:t=32})=>Xd.jsxs("svg",{width:t-5,height:t-5,viewBox:"0 0 27 27",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Xd.jsx("path",{d:"M13.5 27C20.9558 27 27 20.9558 27 13.5C27 6.04416 20.9558 0 13.5 0C6.04416 0 0 6.04416 0 13.5C0 20.9558 6.04416 27 13.5 27Z",fill:"#398260"}),Xd.jsx("path",{d:"M15.6963 5.83207C17.1627 6.86735 18.6899 6.98294 20.6432 7.34238C22.4201 7.67229 22.7973 9.48719 21.9856 11.7974C21.9365 11.7143 21.8859 11.6322 21.8337 11.551L21.9856 11.7974C23.2234 13.9 23.2141 16.1773 20.5352 17.3425C15.7655 19.4181 15.4811 23.5061 10.973 21.3056C10.3338 20.991 9.75978 20.5585 9.28125 20.0307L9.10575 19.8307L8.9429 19.8029C5.91722 19.2671 3.93103 17.6269 5.76872 13.4419C7.39462 9.74369 5.94253 6.1046 10.9291 6.2666H10.9308C12.3044 4.97819 13.8881 4.55885 15.6954 5.83207H15.6963ZM11.0497 9.57157C8.95894 11.0726 8.27044 13.8679 9.66262 16.0389C9.99149 16.5546 10.4192 17 10.921 17.3496C11.4228 17.6992 11.9889 17.946 12.5866 18.0758C13.1842 18.2056 13.8017 18.2159 14.4033 18.1059C15.0049 17.996 15.5789 17.7681 16.092 17.4353C18.2503 16.0347 18.5456 13.3178 17.4791 10.9663C16.3865 8.55569 13.3869 7.89335 11.0497 9.57157Z",fill:"white"})]}),Rp=({onSelect:t,selected:n,theme:r="light",supportedNetworks:i=[]})=>{var s;const[a,o]=e.useState(md.ETHEREUM),[l,c]=e.useState(null),[u,h]=e.useState({}),[d,p]=e.useState(!1),f=[{id:md.ETHEREUM,name:"Ethereum",icon:Sp},{id:md.TRON,name:"Tron",icon:Np},{id:md.ALGORAND,name:"Algorand",icon:Cp},{id:"solana",name:"Solana",icon:Pp},{id:md.BSC,name:"Binance Smart Chain",icon:Tp}],[g,m]=e.useState(!1),_=e.useRef(null);e.useEffect((()=>{function t(t){_.current&&!_.current.contains(t.target)&&m(!1)}return g?document.addEventListener("mousedown",t):document.removeEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)}),[g]),e.useEffect((()=>{h(Ad())}),[]);const y=(t=>{const e=[];switch(t){case md.ETHEREUM:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.ETHEREUM},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.ETHEREUM},{id:"PYUSD",name:"PYUSD",description:"PayPal USD",logo:Mp,network:md.ETHEREUM},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:md.ETHEREUM},{id:"USDP",name:"USDP",description:"Pax Dollar",logo:Bp,network:md.ETHEREUM},{id:"DAI",name:"DAI",description:"Dai Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4943.png",network:md.ETHEREUM},{id:"ETH",name:"ETH",description:"Ethereum",logo:"/eth.png",network:md.ETHEREUM});break;case md.BSC:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.BSC},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.BSC},{id:"BUSD",name:"BUSD",description:"Binance USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4687.png",network:md.BSC},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:md.BSC},{id:"BNB",name:"BNB",description:"Binance Coin",logo:"/bnb.png",network:md.BSC});break;case md.TRON:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.TRON},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.TRON},{id:"USDJ",name:"USDJ",description:"JUST Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5446.png",network:md.TRON},{id:"TRX",name:"TRX",description:"Tron",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",network:md.TRON});break;case md.ALGORAND:e.push({id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.ALGORAND},{id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.ALGORAND},{id:"ALGO",name:"ALGO",description:"Algorand",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",network:md.ALGORAND})}return e})(a),w=d?y:y.slice(0,4);function v(t){switch(t){case md.ETHEREUM:case md.BSC:return gd.METAMASK;case md.TRON:return gd.TRONLINK;case md.ALGORAND:return gd.LUTE;default:return gd.METAMASK}}return Xd.jsxs("div",{className:"",children:[Xd.jsxs("div",{className:"mb-6",children:[Xd.jsx("label",{className:"block text-sm font-medium mb-2 "+("dark"===r?"text-white":"text-gray-700"),children:"Blockchain Network"}),Xd.jsxs("div",{className:"relative",ref:_,children:[Xd.jsxs("button",{type:"button",className:"w-full flex items-center justify-between py-4 bg-white rounded-2xl shadow border border-gray-200 text-gray-900 text-base font-normal focus:outline-none focus:ring-2 focus:ring-[#7042D2] focus:ring-opacity-50 transition",onClick:()=>m((t=>!t)),style:{minHeight:"56px",padding:"0.5rem"},children:[Xd.jsxs("span",{className:"flex items-center gap-3",children:[(()=>{const t=f.find((t=>t.id===a));return Xd.jsx(t.icon,{size:32})})(),Xd.jsx("span",{className:"text-base font-normal",children:null==(s=f.find((t=>t.id===a)))?void 0:s.name})]}),Xd.jsx("svg",{className:"w-5 h-5 ml-2 transition-transform "+(g?"rotate-180":""),fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),g&&Xd.jsx("div",{className:"absolute left-0 mt-2 px-2 w-full bg-white rounded-2xl shadow-lg border border-gray-100 z-20",style:{minWidth:"100%"},children:f.filter((t=>0===i.length||i.includes(t.id))).map((t=>Xd.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 mt-1 mb-1 px-2 py-2 text-gray-900 text-base font-normal rounded-2xl transition hover:bg-gray-100 "+(a===t.id?"bg-gray-50":""),onClick:()=>{var e;m(!1),e=t.id,o(e),p(!1),c(null)},style:{minHeight:"48px"},children:[Xd.jsx(t.icon,{size:32}),Xd.jsx("span",{children:t.name})]},t.id)))})]})]}),Xd.jsxs("div",{className:"mb-4",children:[Xd.jsx("label",{className:"block text-sm font-medium mb-3 "+("dark"===r?"text-white":"text-gray-700"),children:"Select Stablecoin"}),Xd.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:w.map((t=>{const e=(null==l?void 0:l.currency)===t.id&&(null==l?void 0:l.network)===a;return Xd.jsxs("button",{onClick:()=>(t=>{var e;const n={currency:t.id,network:a,tokenConfig:null==(e=yd[t.id])?void 0:e[a],method:t};c(n)})(t),className:`group flex items-center justify-between w-full px-2 py-2 rounded-2xl border text-left transition-all duration-200 font-medium text-base\n ${e?"bg-[#E9DDFC] border-transparent shadow-none":"bg-white border-gray-200 hover:bg-[#F6F2FF] hover:border-[#E9DDFC]"}\n `,style:{minHeight:"56px",padding:"0.5rem"},children:[Xd.jsxs("span",{className:"flex items-center gap-x-2",children:["function"==typeof t.logo?Xd.jsx(t.logo,{size:24}):Xd.jsx("img",{src:t.logo,alt:t.name,className:"h-4 w-4"}),Xd.jsxs("span",{className:"font-medium text-sm text-gray-900",children:[t.description," (",t.name,")"]})]}),e&&Xd.jsx("span",{className:"ml-2 flex items-center justify-center w-6 h-6 rounded-full bg-[#7042D2]",children:Xd.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M4 8.5L7 11.5L12 6.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},`${t.id}-${t.network}`)}))}),y.length>4&&Xd.jsx("button",{onClick:()=>p(!d),className:"w-full py-2 px-4 rounded-lg text-sm font-medium transition-colors "+("dark"===r?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:d?"Show Less":`Show More (${y.length-4} more)`})]}),Xd.jsx("div",{className:"p-3 rounded-lg text-sm mb-6 "+("dark"===r?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("div",{className:"w-2 h-2 rounded-full mr-2 "+(u[v(a)]?"bg-green-500":"bg-red-500")}),Xd.jsx("span",{className:"text-xs",children:function(t){const e=v(t),n=u[e],r={[gd.METAMASK]:"MetaMask",[gd.TRONLINK]:"TronLink",[gd.TRUST_WALLET]:"Trust Wallet",[gd.LUTE]:"Lute Wallet"};return n?`${r[e]} detected - Ready to pay`:`${r[e]} required - Please install to continue`}(a)})]})}),Xd.jsx("button",{onClick:()=>{l&&t(l)},disabled:!l,className:"w-full py-3 px-4 font-medium rounded-2xl text-lg shadow-md transition-colors "+(l?"bg-[#7042D2] text-white hover:bg-[#5b34b1]":"bg-gray-300 text-gray-500 cursor-not-allowed"),style:{borderRadius:"1.5rem"},children:"Proceed"})]})},Ip=({isOpen:t,onClose:n,payment:r,paymentStatus:i,selectedPaymentMethod:s,onPaymentMethodSelect:a,onPayment:o,onBack:l,error:c,theme:u="light",merchantName:h,transactionHash:d,walletConnection:p,onConnectWallet:f,testMode:g=!1,supportedNetworks:m=[],availableWallets:_={},supportedWallets:y=[],step:w="select-currency",merchantWalletAddresses:v={},debug:b=!1,processingStartTime:A=null,pendingBackendConfirmation:E=!1,paymentNetwork:x=null})=>{const[k,S]=e.useState("wallet"),N=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t),C=t=>({[gd.METAMASK]:"MetaMask",[gd.TRONLINK]:"TronLink",[gd.TRUST_WALLET]:"Trust Wallet",[gd.LUTE]:"Lute Wallet"}[t]||t),P=t=>({[gd.METAMASK]:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",[gd.TRONLINK]:"https://www.tronlink.org/images/logo.png",[gd.TRUST_WALLET]:"https://trustwallet.com/assets/images/trust_logotype.svg",[gd.LUTE]:"https://lute.app/logo.png"}[t]||"");return t?Xd.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:Xd.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:Xd.jsxs("div",{className:"coinley-modal relative py-6 px-2 w-full max-w-md mx-auto shadow-xl bg-gray-100 rounded-3xl",children:[Xd.jsxs("div",{className:"bg-white flex justify-between items-center mb-6 mr-3 ml-3 py-4 px-2 rounded-full",children:[Xd.jsxs("div",{className:"flex-1 flex items-center gap-2 px-4",children:[Xd.jsx("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAbCAYAAABm409WAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMFSURBVHgBpVZBVtswEJXk7JsjmAM0hF13dWDTHeEEhF13MScgOQHmBIQT1Oy6KXFPACEHIDdouux7WNM/kuxIdvJeXpj3iOSR9P9oRjODFHtIevp6y2P21LsO9MlzLFQ0x3SKtdm2s0rsJ0PGS08XaXg6usFvjL+vuw7uS+BE3sDqLs/cOLJ6+rvrRMf/sFdWQ6F1nhUnqw2uXAmiGLMurObbzEQUJYLqHasGDvZ1xkK/P4Y3kGqCn1uAvKWny5taT3rh7bLuIEpqjdYv1fQ6WY75PDYAK4pDAtIz72OC4N47gHyjpr4z5thp1rhtYSyHUaQoMzclWmVFLw8IzEYpC081YpJAL2XXEcVuT16BW6stKYwd8KQd5PL9gtkbJCPopw547YjsqMupid0GHDpxXcWwRYAFy05U+xVgY+eGK0HyzhkyBfjAAEWd+9pyKS7gmll9lIMCv6XGb+ZqeBGSHo3flRrh+9IQz4+PxA5JB4tnQOFseRW8PibA9f848C0iJ9nTZ3ZB19zsAIm+HH3/B6BvO9YTrMts3v8pDhSVPR1n8OURfP4g2EVN0UiyD4hsKtJkmQjlnqAu80NdExDY1OaAynNoEm8dAceT+9XLxYHS8Upu3L4PdLYkHEyg8IZ/CFty28K5oP3ycQgB6d9tYFEIrpj8tlX0jKf8VpXpbcINKT17HW5bq2LABawCWKHUXgapz6LLEzNGUcwxwZkE866b99mQKm9aBL64zM7CG6E2cfngWBEtkNVDZO8MJeSciTl7bbeT3Fozv7UGtYgDDvCJaN/zwTQiEyv5yVvh12faqMknQWx96veSRrEzIN2G9S84PAHw2JLRwpG6/JCXVXzsPibhXmJJGh1N9ENwBBuucTGKjU5LV2WrkQ1C+3RiSHSJkq9HHKdmR8vM02RgLsXz3sBksoo84rKwROUmN5TXPoUp+blrOOtOY4GtOhEt4TYpzY2qcszE6dmysIkYxKXCMvv2+7eFXFxIPAT6usvtSNS9CUw/pju/Uzkrba+uAr9F/gPbu3s2LSnvkAAAAABJRU5ErkJggg==",className:"w-auto h-auto",alt:"Coinley Logo"}),Xd.jsx("span",{className:"text-lg font-semibold text-gray-800",children:"Payment Details"})]}),"success"!==w&&"processing"!==w&&Xd.jsx("button",{onClick:n,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),r&&"success"!==w&&Xd.jsx("div",{className:"mb-6",children:Xd.jsxs("div",{className:"text-center",children:[Xd.jsx("div",{className:"text-sm text-gray-600",children:"Total amount"}),Xd.jsxs("div",{className:"coinley-amount-display text-2xl md:text-4xl lg:text-6xl font-bold text-[#7042D2] mt-2 leading-tight tracking-tight",children:["$",(T=r.totalAmount||r.amount,parseFloat(T).toFixed(2))]}),Xd.jsx("div",{className:"text-sm text-gray-600 mt-4",children:"Payment to:"}),Xd.jsxs("div",{className:"coinley-merchant-name text-base font-semibold mt-1 flex gap-2 items-center",children:[Xd.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M15.3 7.50065L15.8 10.0007H4.2L4.7 7.50065H15.3ZM16.6667 3.33398H3.33333V5.00065H16.6667V3.33398ZM16.6667 5.83398H3.33333L2.5 10.0007V11.6673H3.33333V16.6673H11.6667V11.6673H15V16.6673H16.6667V11.6673H17.5V10.0007L16.6667 5.83398ZM5 15.0007V11.6673H10V15.0007H5Z",fill:"#7042D2"})}),h]})]})}),"select-currency"===w&&Xd.jsx("div",{className:"pb-6 pt-6 px-6 bg-white rounded-t-2xl blockchain-network",children:Xd.jsx(Rp,{onSelect:a,selected:s,theme:u,supportedNetworks:m})}),"confirm"===w&&s&&r&&Xd.jsxs("div",{children:[Xd.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[Xd.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),Xd.jsxs("div",{className:"space-y-2",children:[Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-purple-600 font-semibold",children:"Currency:"}),Xd.jsx("span",{className:"font-medium",children:s.currency})]}),Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-purple-600 font-semibold",children:"Network:"}),Xd.jsx("span",{className:"font-medium",children:N(s.network)})]}),Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-purple-600 font-semibold",children:"Fee:"}),Xd.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),Xd.jsx("div",{className:"mb-4",children:Xd.jsxs("div",{className:"flex border-b border-gray-200",children:[Xd.jsx("button",{onClick:()=>S("wallet"),className:"py-2 px-4 text-sm font-medium "+("wallet"===k?"border-b-2 border-purple-600 text-purple-600":"text-gray-500 hover:text-gray-700"),children:"Connect Wallet"}),Xd.jsx("button",{onClick:()=>S("qrcode"),className:"py-2 px-4 text-sm font-medium "+("qrcode"===k?"border-b-2 border-purple-600 text-purple-600":"text-gray-500 hover:text-gray-700"),children:"QR Code"})]})}),g?Xd.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("div",{className:"bg-purple-600 rounded-full p-2 mr-3",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),Xd.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):"qrcode"===k?Xd.jsx("div",{className:"mb-4",children:Xd.jsx(xp,{walletAddress:(()=>{if(!s)return"No network selected";const t=v[s.network];return t||((null==r?void 0:r.recipientWallet)?r.recipientWallet:"No wallet address configured for this network")})(),amount:r.totalAmount||r.amount,currency:s.currency,network:s.network,theme:u})}):Xd.jsxs("div",{className:"space-y-3 mb-4",children:[0===y.length?Xd.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-yellow-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),Xd.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",N(s.network)," network"]})]})]})}):y.map((t=>Xd.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:Xd.jsxs("div",{className:"flex items-center justify-between",children:[Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("img",{src:P(t),alt:C(t),className:"w-8 h-8 mr-3",onError:t=>{t.target.style.display="none"}}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:C(t)}),Xd.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",C(t)]})]})]}),(null==p?void 0:p.walletType)===t?Xd.jsxs("div",{className:"flex items-center space-x-2",children:[Xd.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),Xd.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):Xd.jsx("button",{onClick:()=>{console.log("Connect wallet button clicked for:",t),f(t)},className:"coinley-button-primary py-2 px-4 font-medium rounded-md text-sm",children:"Connect"})]})},t))),Xd.jsx("div",{className:"space-y-2",children:Object.entries(_).filter((([t,e])=>!e)).map((([t])=>Xd.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:Xd.jsxs("div",{className:"flex items-center justify-between",children:[Xd.jsxs("span",{className:"text-sm text-gray-600",children:[C(t)," not detected"]}),Xd.jsx("a",{href:vd(t),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-purple-600 hover:underline",children:"Install"})]})},t)))})]}),c&&Xd.jsx("div",{className:"p-3 rounded-lg bg-red-50 mb-4 text-red-600 text-sm",children:c}),Xd.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[Xd.jsx("button",{type:"button",onClick:l,className:"w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-purple-600 font-medium rounded-md",children:"Back"}),Xd.jsx("button",{type:"button",onClick:()=>o("qrcode"===k),className:"coinley-button-primary w-full py-2 px-4 font-medium rounded-md",disabled:!g&&"wallet"===k&&!p,children:"qrcode"===k?"I have sent the payment":"Pay Now"})]})]}),"processing"===w&&Xd.jsx(kp,{status:"processing",theme:u,message:"Processing your payment...",processingStartTime:A,paymentNetwork:x||(null==s?void 0:s.network),transactionHash:d}),"success"===w&&Xd.jsx(kp,{status:"success",theme:u,message:"Payment successful!",payment:r,transactionHash:d,selectedPaymentMethod:s,merchantName:h,onClose:()=>{console.log("Success screen close button clicked"),n&&n()},pendingBackendConfirmation:E}),"error"===w&&Xd.jsxs("div",{children:[Xd.jsx(kp,{status:"error",theme:u,message:c||"An error occurred while processing your payment."}),Xd.jsx("button",{type:"button",onClick:l,className:"mt-4 w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",children:"Try Again"})]}),"success"!==w&&Xd.jsxs("div",{className:"text-center text-xs text-gray-500 flex items-center justify-center gap-1 py-6 bg-white rounded-b-[12px] ",children:[Xd.jsxs("p",{children:["Powered by ",Xd.jsx("span",{className:"text-purple-600",children:"Coinley"})," - Secure Cryptocurrency Payments"]}),Xd.jsxs("svg",{className:"inline w-4 h-4 text-green-500 ml-1",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[Xd.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none"}),Xd.jsx("path",{d:"M9 12l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]})})}):null;var T},Gp=e.forwardRef((({apiKey:t,apiSecret:n,apiUrl:r,customerEmail:i,merchantName:s="Merchant",merchantWalletAddresses:a={},onSuccess:o,onError:l,onClose:c,theme:u,autoOpen:h=!1,debug:d=!1,testMode:p=!1,supportedNetworks:f=[],preferredNetwork:g=md.ETHEREUM,preferredWallet:m=gd.METAMASK,confirmations:_=1,fastMode:y=!0},w)=>{const v=ep(),{theme:b}=e.useContext($d),[A,E]=e.useState(h),[x,k]=e.useState(null),[S,N]=e.useState("idle"),[C,P]=e.useState(null),[T,M]=e.useState(null),[B,R]=e.useState(null),[I,G]=e.useState(null),[O,L]=e.useState({}),[F,U]=e.useState("select-currency"),[D,j]=e.useState({}),[H,W]=e.useState(null),[z,Q]=e.useState(null),V=e.useRef(null),[K,J]=e.useState(!1),q=t||(null==v?void 0:v.apiKey),Z=n||(null==v?void 0:v.apiSecret);r||null==v||v.apiUrl;const Y=u||b,X=d||(null==v?void 0:v.debug),$=f.length>0?f:[md.ETHEREUM,md.BSC,md.TRON,md.ALGORAND],tt=(t,e)=>{X&&console.log(`[Coinley SDK] ${t}`,e)};e.useEffect((()=>{q&&Z&&(()=>{__async(this,null,(function*(){try{tt("Fetching merchant wallet addresses from backend...");const t=yield Ud();j(t),tt("Merchant wallets fetched successfully:",t)}catch(t){console.error("Failed to fetch merchant wallets:",t),j(a)}}))})()}),[q,Z,a]),e.useEffect((()=>{if("undefined"!=typeof window){(()=>__async(this,null,(function*(){const t=yield Ed(3,1e3);L(t),tt("Available wallets detected:",t)})))()}}),[X]),e.useEffect((()=>()=>{V.current&&clearTimeout(V.current),z&&clearInterval(z)}),[z]),e.useEffect((()=>{if(B&&K&&"loading"===S){const t=setInterval((()=>__async(this,null,(function*(){try{tt("Checking payment status with backend...");"success"===(yield Hd({paymentId:x.id,transactionHash:B,network:C.network,currency:C.currency,senderAddress:null==I?void 0:I.address,confirmations:_,check:!0})).status&&(tt("Payment confirmed by backend!"),clearInterval(t),Q(null),J(!1),N("success"))}catch(e){tt("Error checking payment status:",e)}}))),1e4);return Q(t),()=>{clearInterval(t)}}}),[B,K,S,x,C,I,_]);const et=()=>__async(this,null,(function*(){if(x&&C&&B)try{tt("Processing payment with backend...");const t=yield Hd({paymentId:x.id,transactionHash:B,network:C.network,currency:C.currency,senderAddress:null==I?void 0:I.address,confirmations:_});tt("Payment processed successfully:",t),J(!1),o&&(tt("Calling onSuccess callback..."),o(x.id,B,{network:C.network,currency:C.currency,amount:x.totalAmount||x.amount}))}catch(t){tt("Payment processing initial attempt failed, will retry in background:",t),J(!0)}}));e.useImperativeHandle(w,(()=>({open:t=>{nt(t)},close:()=>{rt()},getPayment:()=>x,getWalletConnection:()=>I,debugWallets:()=>(()=>{var t;if(console.log("=== WALLET ENVIRONMENT DEBUG ==="),console.log("ethereum:","undefined"!=typeof window?Boolean(window.ethereum):"Not in browser"),console.log("tronWeb:","undefined"!=typeof window?Boolean(window.tronWeb):"Not in browser"),console.log("lute:","undefined"!=typeof window?Boolean(window.lute):"Not in browser"),console.log("algorand:","undefined"!=typeof window?Boolean(window.algorand):"Not in browser"),console.log("AlgoSigner:","undefined"!=typeof window?Boolean(window.AlgoSigner):"Not in browser"),"undefined"!=typeof window&&window.ethereum&&console.log("ethereum details:",{isTrust:window.ethereum.isTrust,isMetaMask:window.ethereum.isMetaMask,chainId:window.ethereum.chainId}),"undefined"!=typeof window&&window.tronWeb&&console.log("tronWeb details:",{ready:window.tronWeb.ready,fullNode:null==(t=window.tronWeb.fullNode)?void 0:t.host,defaultAddress:window.tronWeb.defaultAddress}),"undefined"!=typeof window){console.log("All window wallet properties:");const t=Object.keys(window).filter((t=>t.toLowerCase().includes("lute")||t.toLowerCase().includes("algo")||t.toLowerCase().includes("wallet")));console.log("Potential wallet properties:",t)}const e=Ad();console.log("Detected wallets:",e),console.log("=== END WALLET ENVIRONMENT DEBUG ===")})(),getMerchantWallets:()=>D})));const nt=t=>__async(this,null,(function*(){if(!t||!t.amount)return M("Payment amount is required"),void(l&&l(new Error("Payment amount is required")));N("loading"),E(!0),U("select-currency");try{tt("Creating payment with details:",t);let e=D;0===Object.keys(e).length&&(tt("No wallet addresses found, fetching from backend..."),e=yield Ud(),j(e)),tt("Using wallet addresses:",e);const n=yield jd({amount:t.amount,currency:t.currency||"USDT",network:t.network||g,customerEmail:t.customerEmail||i,callbackUrl:t.callbackUrl,metadata:__spreadProps(__spreadValues({},t.metadata),{merchantWalletAddresses:e}),merchantWalletAddresses:e});tt("Payment created:",n),k(n.payment),N("idle"),M(null),tt("Payment created and state updated")}catch(e){tt("Error creating payment:",e),M(e.message||"Failed to create payment"),N("error"),l&&l(e)}})),rt=()=>{z&&(clearInterval(z),Q(null)),V.current&&(clearTimeout(V.current),V.current=null),E(!1),R(null),G(null),P(null),U("select-currency"),W(null),J(!1),c&&c()};return Xd.jsx(Xd.Fragment,{children:A&&Xd.jsx(Ip,{isOpen:A,onClose:rt,payment:x,paymentStatus:S,selectedPaymentMethod:C,onPaymentMethodSelect:t=>{console.log("=== PAYMENT METHOD SELECTION DEBUG ==="),console.log("1. Payment method selected:",t),console.log("2. Current step before:",F),tt("Payment method selected:",t),P(t),U("confirm"),console.log("3. Step should now be: confirm"),console.log("=== END PAYMENT METHOD SELECTION DEBUG ===")},onPayment:()=>__async(this,null,(function*(){var t,e;if(x&&C)if(I||p){tt("Starting payment process..."),N("loading"),R(null),U("processing"),W(Date.now());try{let n;if(p)tt("Test mode: Generating mock transaction..."),n=`test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`,yield new Promise((t=>setTimeout(t,1e3)));else{let r;if(x.recipientWallet)r=x.recipientWallet;else{if(!D[C.network])throw new Error(`No merchant wallet address found for ${C.network} network`);r=D[C.network]}tt("Using merchant address for payment:",r),tt("Sending transaction through wallet..."),n=yield Md(I,{to:r,amount:x.totalAmount||x.amount,tokenAddress:null==(t=C.tokenConfig)?void 0:t.address,tokenDecimals:null==(e=C.tokenConfig)?void 0:e.decimals,currency:C.currency,network:C.network})}tt("Transaction hash obtained:",n),R(n),U("success"),et()}catch(n){tt("Payment error:",n),M(n.message||"Failed to process payment"),N("error"),U("error"),l&&l(n)}}else M("Please connect your wallet first");else M("Missing payment information")})),onBack:()=>{"confirm"===F?(U("select-currency"),G(null)):"error"===F&&U("confirm")},error:T,theme:Y,merchantName:s,transactionHash:B,walletConnection:I,onConnectWallet:t=>__async(this,null,(function*(){if(console.log("=== WALLET CONNECTION DEBUG ==="),console.log("1. Wallet type requested:",t),console.log("2. Selected payment method:",C),console.log("3. Available wallets:",O),console.log("4. Current step:",F),!C)return console.error("No payment method selected"),void M("Please select a payment method first");try{console.log("5. Attempting to connect wallet..."),M(null),tt("Connecting wallet:",{walletType:t,network:C.network});const e=yield Cd(t,C.network);G(e),M(null),console.log("6. Connection successful:",e),tt("Wallet connected successfully:",e)}catch(e){console.error("7. Connection failed:",e),tt("Wallet connection error:",e),M(e.message||"Failed to connect wallet")}console.log("=== END WALLET CONNECTION DEBUG ===")})),testMode:p,supportedNetworks:$,availableWallets:O,supportedWallets:C?Pd(C.network):[],step:F,merchantWalletAddresses:D,debug:X,processingStartTime:H,pendingBackendConfirmation:K,paymentNetwork:null==C?void 0:C.network})})}));Gp.displayName="CoinleyCheckout";t.CoinleyCheckout=Gp,t.CoinleyModal=Ip,t.CoinleyProvider=({apiKey:t,apiSecret:n,apiUrl:r="https://coinleyserver-production.up.railway.app",merchantWalletAddress:i=null,merchantSolWalletAddress:s=null,debug:a=!1,children:o})=>{const[l,c]=e.useState(!1),[u,h]=e.useState(null),[d,p]=e.useState(null),[f,g]=e.useState({});e.useEffect((()=>{if(!t||!n)return void h("API key and secret are required");(()=>{__async(this,null,(function*(){try{yield Ld({apiKey:t,apiSecret:n,apiUrl:r,debug:a});const e=yield Ud(),o=__spreadValues(__spreadValues(__spreadValues({},e),i&&{ethereum:i}),s&&{solana:s});g(o),c(!0),a&&console.log("Coinley SDK initialized successfully with wallets:",o)}catch(e){h(e.message),a&&console.error("Coinley SDK initialization error:",e)}}))})()}),[t,n,r,i,s,a]);const m={apiKey:t,apiSecret:n,apiUrl:r,merchantWalletAddress:i,merchantSolWalletAddress:s,merchantWallets:f,isInitialized:l,error:u,debug:a,paymentData:d,storePaymentData:t=>(p(t),t),refreshMerchantWallets:()=>__async(this,null,(function*(){try{const t=yield Ud();return g(t),t}catch(t){return console.error("Failed to refresh merchant wallets:",t),f}}))};return Xd.jsx(tp.Provider,{value:m,children:o})},t.DEFAULT_CONFIG={apiUrl:"https://coinleyserver-production.up.railway.app",debug:!1,testMode:!1,theme:"light",supportedNetworks:["ethereum","bsc","tron","algorand"]},t.NETWORK_CONFIG=_d,t.NETWORK_TYPES=md,t.PaymentMethods=Rp,t.PaymentStatus=kp,t.QRCode=xp,t.TOKEN_CONFIG=yd,t.ThemeProvider=({initialTheme:t="light",children:n})=>{const[r,i]=e.useState(t);return e.useEffect((()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(r)}),[r]),Xd.jsx($d.Provider,{value:{theme:r,setTheme:i,toggleTheme:()=>{i((t=>"light"===t?"dark":"light"))}},children:n})},t.WALLET_TYPES=gd,t.connectWallet=Cd,t.createPayment=jd,t.detectWallets=Ad,t.generateMockTransactionHash=(t="ethereum")=>`${{ethereum:"0x",bsc:"0x",tron:"",algorand:""}[t]||"0x"}${Array.from({length:64},(()=>Math.floor(16*Math.random()).toString(16))).join("")}`,t.getMerchantWallets=Ud,t.getPayment=t=>__async(this,null,(function*(){try{if(console.log("Getting payment:",t),!t)throw new Error("Payment ID is required");const n=yield fetch(`${Od.apiUrl}/api/payments/${t}`,{method:"GET",headers:Dd()});if(!n.ok){let t;try{t=yield n.json()}catch(e){throw new Error(`Failed to get payment: ${n.status} ${n.statusText}`)}throw console.error("Error getting payment:",t),new Error(t.error||`Failed to get payment: ${n.status}`)}const r=yield n.json();return console.log("Get payment response:",r),r}catch(n){throw console.error("Get payment error:",n),n}})),t.getSupportedNetworks=()=>__async(this,null,(function*(){try{const e=yield fetch(`${Od.apiUrl}/api/networks`,{method:"GET",headers:Dd()});if(!e.ok){let n;try{n=yield e.json()}catch(t){throw new Error(`Failed to get networks: ${e.status} ${e.statusText}`)}throw new Error(n.error||`Failed to get networks: ${e.status}`)}return yield e.json()}catch(e){throw console.error("Get supported networks error:",e),e}})),t.getSupportedWalletsForNetwork=Pd,t.getWalletInstallUrl=vd,t.processPayment=Hd,t.sendTransaction=Md,t.useCoinley=ep,t.validateWalletAddress=(t,e)=>__async(this,null,(function*(){try{const r=yield fetch(`${Od.apiUrl}/api/wallets/validate`,{method:"POST",headers:Dd(),body:JSON.stringify({address:t,network:e})});if(!r.ok){let t;try{t=yield r.json()}catch(n){throw new Error(`Failed to validate address: ${r.status} ${r.statusText}`)}throw new Error(t.error||`Failed to validate address: ${r.status}`)}return yield r.json()}catch(r){throw console.error("Validate wallet address error:",r),r}})),Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
16
|
+
*/function wp(t,e=0){const n=[];return t.forEach((function(t,r){let i=null;t.forEach((function(s,a){if(!s&&null!==i)return n.push(`M${i+e} ${r+e}h${a-i}v1H${i+e}z`),void(i=null);if(a!==t.length-1)s&&null===i&&(i=a);else{if(!s)return;null===i?n.push(`M${a+e},${r+e} h1v1H${a+e}z`):n.push(`M${i+e},${r+e} h${a+1-i}v1H${i+e}z`)}}))})),n.join("")}function vp(t,e){return t.slice().map(((t,n)=>n<e.y||n>=e.y+e.h?t:t.map(((t,n)=>(n<e.x||n>=e.x+e.w)&&t))))}function bp({value:t,level:n,minVersion:r,includeMargin:i,marginSize:s,imageSettings:a,size:o,boostLevel:l}){let c=e.useMemo((()=>{const e=(Array.isArray(t)?t:[t]).reduce(((t,e)=>(t.push(...hp.QrSegment.makeSegments(e)),t)),[]);return hp.QrCode.encodeSegments(e,dp[n],r,void 0,void 0,l)}),[t,n,r,l]);const{cells:u,margin:h,numCells:d,calculatedImageSettings:p}=e.useMemo((()=>{let t=c.getModules();const e=function(t,e){return null!=e?Math.max(Math.floor(e),0):t?4:0}(i,s),n=t.length+2*e,r=function(t,e,n,r){if(null==r)return null;const i=t.length+2*n,s=Math.floor(.1*e),a=i/e,o=(r.width||s)*a,l=(r.height||s)*a,c=null==r.x?t.length/2-o/2:r.x*a,u=null==r.y?t.length/2-l/2:r.y*a,h=null==r.opacity?1:r.opacity;let d=null;if(r.excavate){let t=Math.floor(c),e=Math.floor(u);d={x:t,y:e,w:Math.ceil(o+c-t),h:Math.ceil(l+u-e)}}return{x:c,y:u,h:l,w:o,excavation:d,opacity:h,crossOrigin:r.crossOrigin}}(t,o,e,a);return{cells:t,margin:e,numCells:n,calculatedImageSettings:r}}),[c,o,a,i,s]);return{qrcode:c,margin:h,cells:u,numCells:d,calculatedImageSettings:p}}var Ap=function(){try{(new Path2D).addPath(new Path2D)}catch(t){return!1}return!0}();e.forwardRef((function(t,n){const r=t,{value:i,size:s=pp,level:a=fp,bgColor:o=gp,fgColor:l=mp,includeMargin:c=_p,minVersion:u=yp,boostLevel:h,marginSize:d,imageSettings:p}=r,f=up(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:g}=f,m=up(f,["style"]),_=null==p?void 0:p.src,y=e.useRef(null),w=e.useRef(null),v=e.useCallback((t=>{y.current=t,"function"==typeof n?n(t):n&&(n.current=t)}),[n]),[b,A]=e.useState(!1),{margin:E,cells:x,numCells:k,calculatedImageSettings:S}=bp({value:i,level:a,minVersion:u,boostLevel:h,includeMargin:c,marginSize:d,imageSettings:p,size:s});e.useEffect((()=>{if(null!=y.current){const t=y.current,e=t.getContext("2d");if(!e)return;let n=x;const r=w.current,i=null!=S&&null!==r&&r.complete&&0!==r.naturalHeight&&0!==r.naturalWidth;i&&null!=S.excavation&&(n=vp(x,S.excavation));const a=window.devicePixelRatio||1;t.height=t.width=s*a;const c=s/k*a;e.scale(c,c),e.fillStyle=o,e.fillRect(0,0,k,k),e.fillStyle=l,Ap?e.fill(new Path2D(wp(n,E))):x.forEach((function(t,n){t.forEach((function(t,r){t&&e.fillRect(r+E,n+E,1,1)}))})),S&&(e.globalAlpha=S.opacity),i&&e.drawImage(r,S.x+E,S.y+E,S.w,S.h)}})),e.useEffect((()=>{A(!1)}),[_]);const N=cp({height:s,width:s},g);let C=null;return null!=_&&(C=e.createElement("img",{src:_,key:_,style:{display:"none"},onLoad:()=>{A(!0)},ref:w,crossOrigin:null==S?void 0:S.crossOrigin})),e.createElement(e.Fragment,null,e.createElement("canvas",cp({style:N,height:s,width:s,ref:v,role:"img"},m)),C)})).displayName="QRCodeCanvas";var Ep=e.forwardRef((function(t,n){const r=t,{value:i,size:s=pp,level:a=fp,bgColor:o=gp,fgColor:l=mp,includeMargin:c=_p,minVersion:u=yp,boostLevel:h,title:d,marginSize:p,imageSettings:f}=r,g=up(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:m,cells:_,numCells:y,calculatedImageSettings:w}=bp({value:i,level:a,minVersion:u,boostLevel:h,includeMargin:c,marginSize:p,imageSettings:f,size:s});let v=_,b=null;null!=f&&null!=w&&(null!=w.excavation&&(v=vp(_,w.excavation)),b=e.createElement("image",{href:f.src,height:w.h,width:w.w,x:w.x+m,y:w.y+m,preserveAspectRatio:"none",opacity:w.opacity,crossOrigin:w.crossOrigin}));const A=wp(v,m);return e.createElement("svg",cp({height:s,width:s,viewBox:`0 0 ${y} ${y}`,ref:n,role:"img"},g),!!d&&e.createElement("title",null,d),e.createElement("path",{fill:o,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),e.createElement("path",{fill:l,d:A,shapeRendering:"crispEdges"}),b)}));Ep.displayName="QRCodeSVG";const xp=({walletAddress:t,amount:n,currency:r,network:i,theme:s="light",size:a=200})=>{const[o,l]=e.useState(""),[c,u]=e.useState(null);e.useEffect((()=>{if(t&&"No address configured"!==t)try{let e;switch(i){case"algorand":if("ALGO"===r){const r=Math.floor(1e6*parseFloat(n));e=`algorand://${t}?amount=${r}¬e=Payment`}else{const i=h(r,"algorand");if(i&&i.assetId){const r=Math.floor(parseFloat(n)*Math.pow(10,i.decimals));e=`algorand://${t}?asset=${i.assetId}&amount=${r}¬e=Payment`}else e=t}break;case"tron":e="TRX"===r?`tronlink://transfer?to=${t}&amount=${n}`:t;break;case"bsc":if("BNB"===r)e=`ethereum:${t}@56?value=${f(n)}`;else{const i=d(r,"bsc");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${p(n,r)}@56`:t}break;default:if("ETH"===r)e=`ethereum:${t}@1?value=${f(n)}`;else{const i=d(r,"ethereum");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${p(n,r)}`:t}}l(e),u(null)}catch(e){console.error("Error generating QR code:",e),u("Error generating payment QR code")}else u("No wallet address configured for this network")}),[t,n,r,i]);const h=(t,e)=>{var n;return null==(n={algorand:{USDC:{assetId:31566704,decimals:6},USDT:{assetId:312769,decimals:6},ALGO:{decimals:6,isNative:!0}}}[e])?void 0:n[t.toUpperCase()]},d=(t,e)=>{var n;return(null==(n={ethereum:{USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},bsc:{USDT:"0x55d398326f99059fF775485246999027B3197955",USDC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},tron:{USDT:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",USDC:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8"}}[e])?void 0:n[t])||""},p=(t,e)=>{const n="USDT"===e||"USDC"===e?6:18;return Math.floor(parseFloat(t)*Math.pow(10,n)).toString()},f=t=>Math.floor(1e18*parseFloat(t)).toString(),g=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t);return Xd.jsxs("div",{className:"flex flex-col items-center",children:[c?Xd.jsxs("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 mx-auto mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Xd.jsx("p",{className:"font-medium",children:c})]}):Xd.jsx("div",{className:"p-4 rounded-lg bg-white mb-3 shadow-sm border",children:o&&Xd.jsx(Ep,{value:o,size:a,bgColor:"dark"===s?"#374151":"#FFFFFF",fgColor:"dark"===s?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),Xd.jsxs("div",{className:"text-center text-sm text-gray-700 mb-4",children:[Xd.jsxs("p",{className:"font-semibold text-gray-800 flex items-center justify-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M12 12h-4.01M12 12V8.01"})}),"Scan to Pay with ",r]}),Xd.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Scan with your ",g(i)," wallet app"]})]}),Xd.jsxs("div",{className:"w-full mb-4 p-3 bg-gray-50 rounded-lg",children:[Xd.jsxs("div",{className:"flex justify-between items-center",children:[Xd.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Amount to Pay:"}),Xd.jsxs("span",{className:"text-lg font-bold text-[#7042D2]",children:[n," ",r]})]}),Xd.jsxs("div",{className:"flex justify-between items-center mt-1",children:[Xd.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),Xd.jsx("span",{className:"text-xs font-medium text-gray-700",children:g(i)})]})]}),Xd.jsx("div",{className:"w-full",children:Xd.jsxs("div",{className:"p-3 rounded bg-blue-50 border border-blue-200",children:[Xd.jsxs("h4",{className:"text-sm font-medium mb-2 text-blue-800 flex items-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Payment Instructions"]}),Xd.jsxs("ol",{className:"text-xs space-y-1 text-blue-700",children:[Xd.jsxs("li",{children:["1. Open your crypto wallet app (",(m=i,{ethereum:["MetaMask","Trust Wallet","Coinbase Wallet"],bsc:["MetaMask","Trust Wallet","SafePal"],tron:["TronLink","Trust Wallet"],algorand:["Pera Wallet","MyAlgo Wallet"]}[m]||["MetaMask","Trust Wallet"]).join(", "),")"]}),Xd.jsx("li",{children:"2. Scan the QR code above or copy the wallet address"}),Xd.jsxs("li",{children:["3. Send exactly ",Xd.jsxs("strong",{children:[n," ",r]})," on ",g(i)," network"]}),Xd.jsx("li",{children:'4. Click "I have sent the payment" button below after sending'})]}),Xd.jsx("div",{className:"mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded",children:Xd.jsxs("p",{className:"text-xs text-yellow-800",children:[Xd.jsx("strong",{children:"Important:"})," Make sure you're sending on the correct network (",g(i),") and using the exact amount shown above."]})})]})})]});var m},kp=({status:t,message:n,theme:r="light",payment:i=null,transactionHash:s=null,selectedPaymentMethod:a=null,merchantName:o="Merchant",onClose:l=null,processingStartTime:c=null,paymentNetwork:u=null,pendingBackendConfirmation:h=!1})=>{const[d,p]=e.useState(!1),[f,g]=e.useState(0),[m,_]=e.useState(!1),[y,w]=e.useState(1);e.useEffect((()=>{let e;return"processing"===t&&c&&(e=setInterval((()=>{const t=Math.floor((Date.now()-c)/1e3);g(t),t>=5&&1===y&&w(2),t>=15&&2===y&&w(3),t>=30&&!m&&_(!0)}),1e3)),()=>clearInterval(e)}),[t,c,y,m]);const v=()=>__async(this,null,(function*(){if(s)try{yield navigator.clipboard.writeText(s),p(!0),setTimeout((()=>p(!1)),2e3)}catch(t){console.error("Failed to copy transaction hash:",t)}})),b=()=>{console.log("Payment success screen close button clicked"),l&&l()},A=()=>{switch(t){case"processing":return Xd.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return Xd.jsx("div",{className:"rounded-full h-16 w-16 bg-green-500 flex items-center justify-center",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-10 w-10 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return Xd.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}},E=()=>{switch(t){case"processing":return"dark"===r?"text-blue-300":"text-blue-600";case"success":return"dark"===r?"text-green-300":"text-green-600";case"error":return"dark"===r?"text-red-300":"text-red-600";default:return"dark"===r?"text-gray-300":"text-gray-600"}};return"success"===t?Xd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Xd.jsx("div",{className:"mb-6",children:A()}),Xd.jsx("h3",{className:"text-2xl font-bold mb-3 "+("dark"===r?"text-white":"text-gray-900"),children:"Payment Successful!"}),i&&a&&Xd.jsxs("p",{className:"text-center max-w-[235px] mb-6 "+("dark"===r?"text-gray-300":"text-gray-600"),children:["Your payment of ",Xd.jsxs("span",{className:"text-[#7042D2] font-semibold",children:[i.totalAmount||i.amount," ",a.currency]})," has been completed."]}),h&&Xd.jsxs("div",{className:"flex items-center justify-center mb-4 text-xs text-gray-500 bg-gray-50 rounded-full px-3 py-1",children:[Xd.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-3 w-3 text-gray-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[Xd.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Xd.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Verifying on blockchain"]}),s&&Xd.jsxs("div",{className:"w-full mb-6",children:[Xd.jsx("p",{className:"text-sm font-medium mb-2 "+("dark"===r?"text-gray-300":"text-gray-700"),children:"Transaction Hash:"}),Xd.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-colors "+("dark"===r?"bg-gray-700 border-gray-600 hover:bg-gray-600":"bg-gray-50 border-gray-200 hover:bg-gray-100"),onClick:v,children:[Xd.jsx("span",{className:"font-mono text-sm "+("dark"===r?"text-gray-300":"text-gray-700"),children:(S=s,S?S.length<=16?S:`${S.slice(0,8)}...${S.slice(-8)}`:"")}),Xd.jsxs("div",{className:"flex items-center",children:[d?Xd.jsx("span",{className:"text-green-500 text-xs font-medium mr-2",children:"Copied!"}):null,Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 "+("dark"===r?"text-gray-400":"text-gray-500"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]})]})]}),Xd.jsx("div",{className:"w-full p-4 rounded-lg border mb-6 "+("dark"===r?"bg-gray-700 border-gray-600":"bg-gray-50 border-gray-200"),children:Xd.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[Xd.jsxs("div",{children:[Xd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===r?"text-gray-400":"text-gray-500"),children:"Merchant ID:"}),Xd.jsx("p",{className:"text-sm font-medium "+("dark"===r?"text-gray-300":"text-gray-700"),children:o})]}),Xd.jsxs("div",{children:[Xd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===r?"text-gray-400":"text-gray-500"),children:"Network:"}),Xd.jsx("p",{className:"text-sm font-medium "+("dark"===r?"text-gray-300":"text-gray-700"),children:a?(k=a.network,{ethereum:"Ethereum",bsc:"BSC",tron:"TRON",algorand:"Algorand"}[k]||k):"N/A"})]}),Xd.jsxs("div",{className:"col-span-2",children:[Xd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===r?"text-gray-400":"text-gray-500"),children:"Recipient:"}),Xd.jsx("p",{className:"text-sm font-mono "+("dark"===r?"text-gray-300":"text-gray-700"),children:(null==i?void 0:i.recipientWallet)?(x=i.recipientWallet,x?x.length<=16?x:`${x.slice(0,6)}...${x.slice(-4)}`:"N/A"):"N/A"})]})]})}),l&&Xd.jsx("button",{onClick:b,className:"w-full py-3 px-4 bg-[#7042D2] text-white font-medium rounded-2xl text-lg shadow-md hover:bg-[#5b34b1] transition-colors",style:{borderRadius:"1.5rem"},children:"Close"})]}):"error"===t?Xd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Xd.jsx("div",{className:"mb-4",children:A()}),Xd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"text-white":"text-gray-900"),children:"Payment Failed"}),Xd.jsx("p",{className:`text-center ${E()}`,children:n}),Xd.jsx("div",{className:"mt-4 p-2 rounded "+("dark"===r?"bg-gray-700":"bg-gray-100"),children:Xd.jsx("p",{className:"text-xs "+("dark"===r?"text-gray-300":"text-gray-600"),children:"Please try again or contact support if the problem persists."})})]}):Xd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Xd.jsx("div",{className:"mb-4",children:A()}),Xd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"text-white":"text-gray-900"),children:(()=>{switch(t){case"processing":return"Processing Payment";case"success":return"Payment Successful!";case"error":return"Payment Failed";default:return"Unknown Status"}})()}),Xd.jsx("p",{className:`text-center ${E()}`,children:n})]});var x,k,S},Sp=({size:t=24})=>Xd.jsxs("svg",{width:t,height:t,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Xd.jsxs("g",{clipPath:"url(#clip0_2786_457)",children:[Xd.jsx("path",{d:"M15.9979 5L15.845 5.52398V20.7287L15.9979 20.8826L22.9958 16.7107L15.9979 5Z",fill:"#343434"}),Xd.jsx("path",{d:"M15.9979 5L9 16.7107L15.9979 20.8826V13.5027V5Z",fill:"#8C8C8C"}),Xd.jsx("path",{d:"M15.9979 22.2186L15.9117 22.3245V27.7408L15.9979 27.9945L23 18.0488L15.9979 22.2186Z",fill:"#3C3C3B"}),Xd.jsx("path",{d:"M15.9979 27.9945V22.2186L9 18.0488L15.9979 27.9945Z",fill:"#8C8C8C"}),Xd.jsx("path",{d:"M15.9979 20.8818L22.9957 16.7099L15.9979 13.502V20.8818Z",fill:"#141414"}),Xd.jsx("path",{d:"M9.00006 16.7099L15.9979 20.8818V13.502L9.00006 16.7099Z",fill:"#393939"})]}),Xd.jsx("defs",{children:Xd.jsx("clipPath",{id:"clip0_2786_457",children:Xd.jsx("rect",{width:"14",height:"23",fill:"white",transform:"translate(9 5)"})})})]}),Np=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.42 8.68534C8.48853 8.61041 8.57583 8.55514 8.67287 8.52525C8.76992 8.49536 8.87319 8.49194 8.972 8.51534L20.875 11.4293C20.947 11.445 21.0146 11.4765 21.073 11.5213L23.495 13.2883C23.6127 13.3751 23.6923 13.5039 23.7173 13.6479C23.7422 13.792 23.7106 13.9401 23.629 14.0613L15.297 26.2523C15.2385 26.3388 15.1571 26.4074 15.0619 26.4503C14.9667 26.4932 14.8614 26.5088 14.7579 26.4953C14.6543 26.4818 14.5566 26.4398 14.4755 26.3739C14.3945 26.308 14.3334 26.2209 14.299 26.1223L8.306 9.25234C8.27276 9.15648 8.2657 9.05348 8.28557 8.95398C8.30543 8.85448 8.3515 8.76209 8.419 8.68634M10.383 11.7293L14.543 23.4413L15.227 17.3723L10.383 11.7293ZM16.341 17.5673L15.646 23.7423L21.529 15.1323L16.341 17.5673ZM22.06 13.6373L18.269 15.4173L20.809 12.7263L22.06 13.6373ZM19.664 12.2943L10.411 10.0303L15.836 16.3483L19.664 12.2943Z",fill:"black"})}),Cp=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M17.2512 9.5H19.7036L20.7785 13.4753H23.3083L21.5804 16.4753L24 25.4973H21.4916L19.8625 19.446L16.3592 25.4987H13.5597L18.9725 16.1313L18.1018 12.8793L10.8022 25.5H8L17.2512 9.5Z",fill:"black"})}),Pp=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.52513 16.0195H20.7032C20.843 16.0195 20.9713 16.0794 21.0762 16.1873L22.8479 18.0574C23.1742 18.4051 22.9411 18.9925 22.4749 18.9925H11.2968C11.157 18.9925 11.0287 18.9326 10.9238 18.8247L9.15214 16.9545C8.82577 16.6069 9.05889 16.0195 9.52513 16.0195ZM9.15214 13.538L10.9238 11.6678C11.0171 11.5599 11.157 11.5 11.2968 11.5H22.4632C22.9295 11.5 23.1626 12.0874 22.8362 12.4351L21.0762 14.3052C20.9829 14.4131 20.843 14.473 20.7032 14.473H9.52513C9.05889 14.473 8.82577 13.8856 9.15214 13.538ZM22.8362 21.462L21.0645 23.3322C20.9596 23.4401 20.8314 23.5 20.6915 23.5H9.52513C9.05889 23.5 8.82577 22.9126 9.15214 22.5649L10.9238 20.6948C11.0171 20.5869 11.157 20.527 11.2968 20.527H22.4632C22.9295 20.527 23.1626 21.1144 22.8362 21.462Z",fill:"black"})}),Tp=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M19.0827 18.7809L20.8947 20.5933L15.9927 25.5L11.0907 20.594L12.902 18.7809L15.9927 21.8905L19.0827 18.7809ZM22.174 15.6873L24 17.4997L22.19 19.3121L20.3787 17.4997L22.174 15.6873ZM15.9927 15.6873L17.8033 17.4837L15.992 19.2967L14.1813 17.4997L15.9927 15.6873ZM9.81067 15.6873L11.6067 17.4997L9.812 19.2961L8 17.4997L9.81067 15.6873ZM15.9933 9.5L20.8933 14.39L19.082 16.2018L15.9933 13.1088L12.9027 16.2184L11.0913 14.406L15.9933 9.5Z",fill:"black"})}),Mp=({size:t=32})=>Xd.jsx("svg",{width:t-4,height:t-4,viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.36266 4.256C8.38876 4.0477 8.48986 3.85605 8.64705 3.7169C8.80423 3.57775 9.00673 3.50064 9.21666 3.5H17.0847C17.9472 3.55674 18.7895 3.78654 19.5613 4.1757C20.3331 4.56486 21.0187 5.10541 21.5772 5.76515C22.1357 6.42489 22.5557 7.19031 22.8121 8.0158C23.0685 8.84129 23.1561 9.70994 23.0697 10.57C22.6847 15.659 18.6737 17.5 16.5807 17.5H13.8367L12.6677 23.786C12.6333 23.987 12.5285 24.1693 12.372 24.3001C12.2156 24.431 12.0176 24.5018 11.8137 24.5H6.61966C6.49561 24.4979 6.3734 24.4696 6.26099 24.4171C6.14859 24.3646 6.04851 24.289 5.96728 24.1952C5.88604 24.1014 5.82548 23.9916 5.78954 23.8728C5.75359 23.7541 5.74307 23.6291 5.75866 23.506L7.05366 14H5.76566C5.65113 13.9998 5.53775 13.9771 5.43205 13.933C5.32635 13.8888 5.23041 13.8243 5.14975 13.743C5.06909 13.6616 5.00529 13.5652 4.96203 13.4591C4.91877 13.3531 4.89689 13.2395 4.89766 13.125C4.89766 12.642 5.28266 12.25 5.76566 12.25H7.29166L7.76066 8.75H5.76566C5.65113 8.74985 5.53775 8.72706 5.43205 8.68295C5.32635 8.63884 5.23041 8.57427 5.14975 8.49296C5.06909 8.41164 5.00529 8.31519 4.96203 8.20914C4.91877 8.10309 4.89689 7.98953 4.89766 7.875C4.89612 7.76084 4.91723 7.64751 4.95978 7.54157C5.00233 7.43563 5.06547 7.33918 5.14554 7.2578C5.22562 7.17643 5.32104 7.11174 5.42628 7.06749C5.53152 7.02324 5.6445 7.0003 5.75866 7H7.99166L8.36266 4.256ZM9.50366 8.75L9.02766 12.25H15.2787C15.51 12.2579 15.7404 12.218 15.9555 12.1326C16.1707 12.0473 16.3659 11.9185 16.5289 11.7541C16.6919 11.5898 16.8191 11.3936 16.9027 11.1778C16.9863 10.962 17.0244 10.7312 17.0147 10.5C17.0244 10.2688 16.9863 10.038 16.9027 9.82219C16.8191 9.60638 16.6919 9.41017 16.5289 9.24586C16.3659 9.08155 16.1707 8.95269 15.9555 8.86736C15.7404 8.78203 15.51 8.74208 15.2787 8.75H9.50366ZM8.79666 14H15.2787C15.738 14.0048 16.1936 13.9173 16.6184 13.7426C17.0433 13.568 17.4287 13.3098 17.7519 12.9833C18.0751 12.6569 18.3294 12.2689 18.4998 11.8423C18.6701 11.4157 18.7531 10.9593 18.7437 10.5C18.7437 8.54 17.2457 7 15.2787 7H9.74166L9.97266 5.25H16.9727C17.6045 5.28987 18.2218 5.45727 18.7872 5.74209C19.3527 6.02692 19.8546 6.42329 20.2627 6.90731C20.6709 7.39132 20.9768 7.95297 21.1621 8.55839C21.3473 9.16381 21.4081 9.80047 21.3407 10.43C21.0397 14.441 17.9457 15.75 16.5807 15.75H13.1157C12.9126 15.7514 12.7163 15.8234 12.5605 15.9537C12.4047 16.084 12.299 16.2644 12.2617 16.464L11.0997 22.75H7.61366L8.79666 14Z",fill:"#3B6FEF"})}),Bp=({size:t=32})=>Xd.jsxs("svg",{width:t-5,height:t-5,viewBox:"0 0 27 27",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Xd.jsx("path",{d:"M13.5 27C20.9558 27 27 20.9558 27 13.5C27 6.04416 20.9558 0 13.5 0C6.04416 0 0 6.04416 0 13.5C0 20.9558 6.04416 27 13.5 27Z",fill:"#398260"}),Xd.jsx("path",{d:"M15.6963 5.83207C17.1627 6.86735 18.6899 6.98294 20.6432 7.34238C22.4201 7.67229 22.7973 9.48719 21.9856 11.7974C21.9365 11.7143 21.8859 11.6322 21.8337 11.551L21.9856 11.7974C23.2234 13.9 23.2141 16.1773 20.5352 17.3425C15.7655 19.4181 15.4811 23.5061 10.973 21.3056C10.3338 20.991 9.75978 20.5585 9.28125 20.0307L9.10575 19.8307L8.9429 19.8029C5.91722 19.2671 3.93103 17.6269 5.76872 13.4419C7.39462 9.74369 5.94253 6.1046 10.9291 6.2666H10.9308C12.3044 4.97819 13.8881 4.55885 15.6954 5.83207H15.6963ZM11.0497 9.57157C8.95894 11.0726 8.27044 13.8679 9.66262 16.0389C9.99149 16.5546 10.4192 17 10.921 17.3496C11.4228 17.6992 11.9889 17.946 12.5866 18.0758C13.1842 18.2056 13.8017 18.2159 14.4033 18.1059C15.0049 17.996 15.5789 17.7681 16.092 17.4353C18.2503 16.0347 18.5456 13.3178 17.4791 10.9663C16.3865 8.55569 13.3869 7.89335 11.0497 9.57157Z",fill:"white"})]}),Rp=({onSelect:t,selected:n,theme:r="light",supportedNetworks:i=[]})=>{var s;const[a,o]=e.useState(md.ETHEREUM),[l,c]=e.useState(null),[u,h]=e.useState({}),[d,p]=e.useState(!1),f=[{id:md.ETHEREUM,name:"Ethereum",icon:Sp},{id:md.TRON,name:"Tron",icon:Np},{id:md.ALGORAND,name:"Algorand",icon:Cp},{id:"solana",name:"Solana",icon:Pp},{id:md.BSC,name:"Binance Smart Chain",icon:Tp}],[g,m]=e.useState(!1),_=e.useRef(null);e.useEffect((()=>{function t(t){_.current&&!_.current.contains(t.target)&&m(!1)}return g?document.addEventListener("mousedown",t):document.removeEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)}),[g]),e.useEffect((()=>{h(Ad())}),[]);const y=(t=>{const e=[];switch(t){case md.ETHEREUM:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.ETHEREUM},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.ETHEREUM},{id:"PYUSD",name:"PYUSD",description:"PayPal USD",logo:Mp,network:md.ETHEREUM},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:md.ETHEREUM},{id:"USDP",name:"USDP",description:"Pax Dollar",logo:Bp,network:md.ETHEREUM},{id:"DAI",name:"DAI",description:"Dai Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4943.png",network:md.ETHEREUM},{id:"ETH",name:"ETH",description:"Ethereum",logo:"/eth.png",network:md.ETHEREUM});break;case md.BSC:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.BSC},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.BSC},{id:"BUSD",name:"BUSD",description:"Binance USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4687.png",network:md.BSC},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:md.BSC},{id:"BNB",name:"BNB",description:"Binance Coin",logo:"/bnb.png",network:md.BSC});break;case md.TRON:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.TRON},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.TRON},{id:"USDJ",name:"USDJ",description:"JUST Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5446.png",network:md.TRON},{id:"TRX",name:"TRX",description:"Tron",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",network:md.TRON});break;case md.ALGORAND:e.push({id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.ALGORAND},{id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.ALGORAND},{id:"ALGO",name:"ALGO",description:"Algorand",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",network:md.ALGORAND})}return e})(a),w=d?y:y.slice(0,4);function v(t){switch(t){case md.ETHEREUM:case md.BSC:return gd.METAMASK;case md.TRON:return gd.TRONLINK;case md.ALGORAND:return gd.LUTE;default:return gd.METAMASK}}return Xd.jsxs("div",{className:"",children:[Xd.jsxs("div",{className:"mb-6",children:[Xd.jsx("label",{className:"block text-sm font-medium mb-2 "+("dark"===r?"text-white":"text-gray-700"),children:"Blockchain Network"}),Xd.jsxs("div",{className:"relative",ref:_,children:[Xd.jsxs("button",{type:"button",className:"w-full flex items-center justify-between py-4 bg-white rounded-2xl shadow border border-gray-200 text-gray-900 text-base font-normal focus:outline-none focus:ring-2 focus:ring-[#7042D2] focus:ring-opacity-50 transition",onClick:()=>m((t=>!t)),style:{minHeight:"56px",padding:"0.5rem"},children:[Xd.jsxs("span",{className:"flex items-center gap-3",children:[(()=>{const t=f.find((t=>t.id===a));return Xd.jsx(t.icon,{size:32})})(),Xd.jsx("span",{className:"text-base font-normal",children:null==(s=f.find((t=>t.id===a)))?void 0:s.name})]}),Xd.jsx("svg",{className:"w-5 h-5 ml-2 transition-transform "+(g?"rotate-180":""),fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),g&&Xd.jsx("div",{className:"absolute left-0 mt-2 px-2 w-full bg-white rounded-2xl shadow-lg border border-gray-100 z-20",style:{minWidth:"100%"},children:f.filter((t=>0===i.length||i.includes(t.id))).map((t=>Xd.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 mt-1 mb-1 px-2 py-2 text-gray-900 text-base font-normal rounded-2xl transition hover:bg-gray-100 "+(a===t.id?"bg-gray-50":""),onClick:()=>{var e;m(!1),e=t.id,o(e),p(!1),c(null)},style:{minHeight:"48px"},children:[Xd.jsx(t.icon,{size:32}),Xd.jsx("span",{children:t.name})]},t.id)))})]})]}),Xd.jsxs("div",{className:"mb-4",children:[Xd.jsx("label",{className:"block text-sm font-medium mb-3 "+("dark"===r?"text-white":"text-gray-700"),children:"Select Stablecoin"}),Xd.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:w.map((t=>{const e=(null==l?void 0:l.currency)===t.id&&(null==l?void 0:l.network)===a;return Xd.jsxs("button",{onClick:()=>(t=>{var e;const n={currency:t.id,network:a,tokenConfig:null==(e=yd[t.id])?void 0:e[a],method:t};c(n)})(t),className:`group flex items-center justify-between w-full px-2 py-2 rounded-2xl border text-left transition-all duration-200 font-medium text-base\n ${e?"bg-[#E9DDFC] border-transparent shadow-none":"bg-white border-gray-200 hover:bg-[#F6F2FF] hover:border-[#E9DDFC]"}\n `,style:{minHeight:"56px",padding:"0.5rem"},children:[Xd.jsxs("span",{className:"flex items-center gap-x-2",children:["function"==typeof t.logo?Xd.jsx(t.logo,{size:24}):Xd.jsx("img",{src:t.logo,alt:t.name,className:"h-4 w-4"}),Xd.jsxs("span",{className:"font-medium text-sm text-gray-900",children:[t.description," (",t.name,")"]})]}),e&&Xd.jsx("span",{className:"ml-2 flex items-center justify-center w-6 h-6 rounded-full bg-[#7042D2]",children:Xd.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M4 8.5L7 11.5L12 6.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},`${t.id}-${t.network}`)}))}),y.length>4&&Xd.jsx("button",{onClick:()=>p(!d),className:"w-full py-2 px-4 rounded-lg text-sm font-medium transition-colors "+("dark"===r?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:d?"Show Less":`Show More (${y.length-4} more)`})]}),Xd.jsx("div",{className:"p-3 rounded-lg text-sm mb-6 "+("dark"===r?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("div",{className:"w-2 h-2 rounded-full mr-2 "+(u[v(a)]?"bg-green-500":"bg-red-500")}),Xd.jsx("span",{className:"text-xs",children:function(t){const e=v(t),n=u[e],r={[gd.METAMASK]:"MetaMask",[gd.TRONLINK]:"TronLink",[gd.TRUST_WALLET]:"Trust Wallet",[gd.LUTE]:"Lute Wallet"};return n?`${r[e]} detected - Ready to pay`:`${r[e]} required - Please install to continue`}(a)})]})}),Xd.jsx("button",{onClick:()=>{l&&t(l)},disabled:!l,className:"w-full py-3 px-4 font-medium rounded-2xl text-lg shadow-md transition-colors "+(l?"bg-[#7042D2] text-white hover:bg-[#5b34b1]":"bg-gray-300 text-gray-500 cursor-not-allowed"),style:{borderRadius:"1.5rem"},children:"Proceed"})]})},Ip=({isOpen:t,onClose:n,payment:r,paymentStatus:i,selectedPaymentMethod:s,onPaymentMethodSelect:a,onPayment:o,onBack:l,error:c,theme:u="light",merchantName:h,transactionHash:d,walletConnection:p,onConnectWallet:f,testMode:g=!1,supportedNetworks:m=[],availableWallets:_={},supportedWallets:y=[],step:w="select-currency",merchantWalletAddresses:v={},debug:b=!1,processingStartTime:A=null,pendingBackendConfirmation:E=!1,paymentNetwork:x=null})=>{const[k,S]=e.useState("wallet"),N=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t),C=t=>({[gd.METAMASK]:"MetaMask",[gd.TRONLINK]:"TronLink",[gd.TRUST_WALLET]:"Trust Wallet",[gd.LUTE]:"Lute Wallet"}[t]||t),P=t=>({[gd.METAMASK]:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",[gd.TRONLINK]:"https://www.tronlink.org/images/logo.png",[gd.TRUST_WALLET]:"https://trustwallet.com/assets/images/trust_logotype.svg",[gd.LUTE]:"https://lute.app/logo.png"}[t]||"");return t?Xd.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:Xd.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:Xd.jsxs("div",{className:"coinley-modal relative py-6 px-2 w-full max-w-md mx-auto shadow-xl bg-gray-100 rounded-3xl",children:[Xd.jsxs("div",{className:"bg-white flex justify-between items-center mb-6 mr-3 ml-3 py-4 px-2 rounded-full",children:[Xd.jsxs("div",{className:"flex-1 flex items-center gap-2 px-4",children:[Xd.jsx("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAbCAYAAABm409WAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMFSURBVHgBpVZBVtswEJXk7JsjmAM0hF13dWDTHeEEhF13MScgOQHmBIQT1Oy6KXFPACEHIDdouux7WNM/kuxIdvJeXpj3iOSR9P9oRjODFHtIevp6y2P21LsO9MlzLFQ0x3SKtdm2s0rsJ0PGS08XaXg6usFvjL+vuw7uS+BE3sDqLs/cOLJ6+rvrRMf/sFdWQ6F1nhUnqw2uXAmiGLMurObbzEQUJYLqHasGDvZ1xkK/P4Y3kGqCn1uAvKWny5taT3rh7bLuIEpqjdYv1fQ6WY75PDYAK4pDAtIz72OC4N47gHyjpr4z5thp1rhtYSyHUaQoMzclWmVFLw8IzEYpC081YpJAL2XXEcVuT16BW6stKYwd8KQd5PL9gtkbJCPopw547YjsqMupid0GHDpxXcWwRYAFy05U+xVgY+eGK0HyzhkyBfjAAEWd+9pyKS7gmll9lIMCv6XGb+ZqeBGSHo3flRrh+9IQz4+PxA5JB4tnQOFseRW8PibA9f848C0iJ9nTZ3ZB19zsAIm+HH3/B6BvO9YTrMts3v8pDhSVPR1n8OURfP4g2EVN0UiyD4hsKtJkmQjlnqAu80NdExDY1OaAynNoEm8dAceT+9XLxYHS8Upu3L4PdLYkHEyg8IZ/CFty28K5oP3ycQgB6d9tYFEIrpj8tlX0jKf8VpXpbcINKT17HW5bq2LABawCWKHUXgapz6LLEzNGUcwxwZkE866b99mQKm9aBL64zM7CG6E2cfngWBEtkNVDZO8MJeSciTl7bbeT3Fozv7UGtYgDDvCJaN/zwTQiEyv5yVvh12faqMknQWx96veSRrEzIN2G9S84PAHw2JLRwpG6/JCXVXzsPibhXmJJGh1N9ENwBBuucTGKjU5LV2WrkQ1C+3RiSHSJkq9HHKdmR8vM02RgLsXz3sBksoo84rKwROUmN5TXPoUp+blrOOtOY4GtOhEt4TYpzY2qcszE6dmysIkYxKXCMvv2+7eFXFxIPAT6usvtSNS9CUw/pju/Uzkrba+uAr9F/gPbu3s2LSnvkAAAAABJRU5ErkJggg==",className:"w-auto h-auto",alt:"Coinley Logo"}),Xd.jsx("span",{className:"text-lg font-semibold text-gray-800",children:"Payment Details"})]}),"success"!==w&&"processing"!==w&&Xd.jsx("button",{onClick:n,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),r&&"success"!==w&&Xd.jsx("div",{className:"mb-6",children:Xd.jsxs("div",{className:"text-center",children:[Xd.jsx("div",{className:"text-sm text-gray-600",children:"Total amount"}),Xd.jsxs("div",{className:"coinley-amount-display text-2xl md:text-4xl lg:text-6xl font-bold text-[#7042D2] mt-2 leading-tight tracking-tight",children:["$",(T=r.totalAmount||r.amount,parseFloat(T).toFixed(2))]}),Xd.jsx("div",{className:"text-sm text-gray-600 mt-4",children:"Payment to:"}),Xd.jsxs("div",{className:"coinley-merchant-name text-base font-semibold mt-1 flex gap-2 items-center",children:[Xd.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M15.3 7.50065L15.8 10.0007H4.2L4.7 7.50065H15.3ZM16.6667 3.33398H3.33333V5.00065H16.6667V3.33398ZM16.6667 5.83398H3.33333L2.5 10.0007V11.6673H3.33333V16.6673H11.6667V11.6673H15V16.6673H16.6667V11.6673H17.5V10.0007L16.6667 5.83398ZM5 15.0007V11.6673H10V15.0007H5Z",fill:"#7042D2"})}),h]})]})}),"select-currency"===w&&Xd.jsx("div",{className:"pb-6 pt-6 px-6 bg-white rounded-t-2xl blockchain-network",children:Xd.jsx(Rp,{onSelect:a,selected:s,theme:u,supportedNetworks:m})}),"confirm"===w&&s&&r&&Xd.jsxs("div",{children:[Xd.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[Xd.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),Xd.jsxs("div",{className:"space-y-2",children:[Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-purple-600 font-semibold",children:"Currency:"}),Xd.jsx("span",{className:"font-medium",children:s.currency})]}),Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-purple-600 font-semibold",children:"Network:"}),Xd.jsx("span",{className:"font-medium",children:N(s.network)})]}),Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-purple-600 font-semibold",children:"Fee:"}),Xd.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),Xd.jsx("div",{className:"mb-4",children:Xd.jsxs("div",{className:"flex border-b border-gray-200",children:[Xd.jsx("button",{onClick:()=>S("wallet"),className:"py-2 px-4 text-sm font-medium "+("wallet"===k?"border-b-2 border-purple-600 text-purple-600":"text-gray-500 hover:text-gray-700"),children:"Connect Wallet"}),Xd.jsx("button",{onClick:()=>S("qrcode"),className:"py-2 px-4 text-sm font-medium "+("qrcode"===k?"border-b-2 border-purple-600 text-purple-600":"text-gray-500 hover:text-gray-700"),children:"QR Code"})]})}),g?Xd.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("div",{className:"bg-purple-600 rounded-full p-2 mr-3",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),Xd.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):"qrcode"===k?Xd.jsx("div",{className:"mb-4",children:Xd.jsx(xp,{walletAddress:(()=>{if(!s)return"No network selected";const t=v[s.network];return t||((null==r?void 0:r.recipientWallet)?r.recipientWallet:"No wallet address configured for this network")})(),amount:r.totalAmount||r.amount,currency:s.currency,network:s.network,theme:u})}):Xd.jsxs("div",{className:"space-y-3 mb-4",children:[0===y.length?Xd.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-yellow-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),Xd.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",N(s.network)," network"]})]})]})}):y.map((t=>Xd.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:Xd.jsxs("div",{className:"flex items-center justify-between",children:[Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("img",{src:P(t),alt:C(t),className:"w-8 h-8 mr-3",onError:t=>{t.target.style.display="none"}}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:C(t)}),Xd.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",C(t)]})]})]}),(null==p?void 0:p.walletType)===t?Xd.jsxs("div",{className:"flex items-center space-x-2",children:[Xd.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),Xd.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):Xd.jsx("button",{onClick:()=>{console.log("Connect wallet button clicked for:",t),f(t)},className:"coinley-button-primary py-2 px-4 font-medium rounded-md text-sm",children:"Connect"})]})},t))),Xd.jsx("div",{className:"space-y-2",children:Object.entries(_).filter((([t,e])=>!e)).map((([t])=>Xd.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:Xd.jsxs("div",{className:"flex items-center justify-between",children:[Xd.jsxs("span",{className:"text-sm text-gray-600",children:[C(t)," not detected"]}),Xd.jsx("a",{href:vd(t),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-purple-600 hover:underline",children:"Install"})]})},t)))})]}),c&&Xd.jsx("div",{className:"p-3 rounded-lg bg-red-50 mb-4 text-red-600 text-sm",children:c}),Xd.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[Xd.jsx("button",{type:"button",onClick:l,className:"w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-purple-600 font-medium rounded-md",children:"Back"}),Xd.jsx("button",{type:"button",onClick:()=>o("qrcode"===k),className:"coinley-button-primary w-full py-2 px-4 font-medium rounded-md",disabled:!g&&"wallet"===k&&!p,children:"qrcode"===k?"I have sent the payment":"Pay Now"})]})]}),"processing"===w&&Xd.jsx(kp,{status:"processing",theme:u,message:"Processing your payment...",processingStartTime:A,paymentNetwork:x||(null==s?void 0:s.network),transactionHash:d}),"success"===w&&Xd.jsx(kp,{status:"success",theme:u,message:"Payment successful!",payment:r,transactionHash:d,selectedPaymentMethod:s,merchantName:h,onClose:()=>{console.log("Success screen close button clicked"),n&&n()},pendingBackendConfirmation:E}),"error"===w&&Xd.jsxs("div",{children:[Xd.jsx(kp,{status:"error",theme:u,message:c||"An error occurred while processing your payment."}),Xd.jsx("button",{type:"button",onClick:l,className:"mt-4 w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",children:"Try Again"})]}),"success"!==w&&Xd.jsxs("div",{className:"text-center text-xs text-gray-500 flex items-center justify-center gap-1 py-6 bg-white rounded-b-[12px] ",children:[Xd.jsxs("p",{children:["Powered by ",Xd.jsx("span",{className:"text-purple-600",children:"Coinley"})," - Secure Cryptocurrency Payments"]}),Xd.jsxs("svg",{className:"inline w-4 h-4 text-green-500 ml-1",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[Xd.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none"}),Xd.jsx("path",{d:"M9 12l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]})})}):null;var T},Gp=e.forwardRef((({apiKey:t,apiSecret:n,apiUrl:r,customerEmail:i,merchantName:s="Merchant",merchantWalletAddresses:a={},onSuccess:o,onError:l,onClose:c,theme:u,autoOpen:h=!1,debug:d=!1,testMode:p=!1,supportedNetworks:f=[],preferredNetwork:g=md.ETHEREUM,preferredWallet:m=gd.METAMASK,confirmations:_=1,fastMode:y=!0},w)=>{const v=ep(),{theme:b}=e.useContext($d),[A,E]=e.useState(h),[x,k]=e.useState(null),[S,N]=e.useState("idle"),[C,P]=e.useState(null),[T,M]=e.useState(null),[B,R]=e.useState(null),[I,G]=e.useState(null),[O,L]=e.useState({}),[F,U]=e.useState("select-currency"),[D,j]=e.useState({}),[H,W]=e.useState(null),[z,Q]=e.useState(null),V=e.useRef(null),[K,J]=e.useState(!1),q=t||(null==v?void 0:v.apiKey),Z=n||(null==v?void 0:v.apiSecret);r||null==v||v.apiUrl;const Y=u||b,X=d||(null==v?void 0:v.debug),$=f.length>0?f:[md.ETHEREUM,md.BSC,md.TRON,md.ALGORAND],tt=(t,e)=>{X&&console.log(`[Coinley SDK] ${t}`,e)};e.useEffect((()=>{q&&Z&&(()=>{__async(this,null,(function*(){try{tt("Fetching merchant wallet addresses from backend...");const t=yield Ud();j(t),tt("Merchant wallets fetched successfully:",t)}catch(t){console.error("Failed to fetch merchant wallets:",t),j(a)}}))})()}),[q,Z,a]),e.useEffect((()=>{if("undefined"!=typeof window){(()=>__async(this,null,(function*(){const t=yield Ed(3,1e3);L(t),tt("Available wallets detected:",t)})))()}}),[X]),e.useEffect((()=>()=>{V.current&&clearTimeout(V.current),z&&clearInterval(z)}),[z]),e.useEffect((()=>{if(B&&K&&"loading"===S){const t=setInterval((()=>__async(this,null,(function*(){try{tt("Checking payment status with backend...");"success"===(yield Hd({paymentId:x.id,transactionHash:B,network:C.network,currency:C.currency,senderAddress:null==I?void 0:I.address,confirmations:_,check:!0})).status&&(tt("Payment confirmed by backend!"),clearInterval(t),Q(null),J(!1),N("success"))}catch(e){tt("Error checking payment status:",e)}}))),1e4);return Q(t),()=>{clearInterval(t)}}}),[B,K,S,x,C,I,_]);const et=()=>__async(this,null,(function*(){if(x&&C&&B)try{tt("Processing payment with backend...");const t=yield Hd({paymentId:x.id,transactionHash:B,network:C.network,currency:C.currency,senderAddress:null==I?void 0:I.address,confirmations:_});tt("Payment processed successfully:",t),J(!1),o&&(tt("Calling onSuccess callback..."),o(x.id,B,{network:C.network,currency:C.currency,amount:x.totalAmount||x.amount}))}catch(t){tt("Payment processing initial attempt failed, will retry in background:",t),J(!0)}}));e.useImperativeHandle(w,(()=>({open:t=>{nt(t)},close:()=>{rt()},getPayment:()=>x,getWalletConnection:()=>I,debugWallets:()=>(()=>{var t;if(console.log("=== WALLET ENVIRONMENT DEBUG ==="),console.log("ethereum:","undefined"!=typeof window?Boolean(window.ethereum):"Not in browser"),console.log("tronWeb:","undefined"!=typeof window?Boolean(window.tronWeb):"Not in browser"),console.log("lute:","undefined"!=typeof window?Boolean(window.lute):"Not in browser"),console.log("algorand:","undefined"!=typeof window?Boolean(window.algorand):"Not in browser"),console.log("AlgoSigner:","undefined"!=typeof window?Boolean(window.AlgoSigner):"Not in browser"),"undefined"!=typeof window&&window.ethereum&&console.log("ethereum details:",{isTrust:window.ethereum.isTrust,isMetaMask:window.ethereum.isMetaMask,chainId:window.ethereum.chainId}),"undefined"!=typeof window&&window.tronWeb&&console.log("tronWeb details:",{ready:window.tronWeb.ready,fullNode:null==(t=window.tronWeb.fullNode)?void 0:t.host,defaultAddress:window.tronWeb.defaultAddress}),"undefined"!=typeof window){console.log("All window wallet properties:");const t=Object.keys(window).filter((t=>t.toLowerCase().includes("lute")||t.toLowerCase().includes("algo")||t.toLowerCase().includes("wallet")));console.log("Potential wallet properties:",t)}const e=Ad();console.log("Detected wallets:",e),console.log("=== END WALLET ENVIRONMENT DEBUG ===")})(),getMerchantWallets:()=>D})));const nt=t=>__async(this,null,(function*(){if(!t||!t.amount)return M("Payment amount is required"),void(l&&l(new Error("Payment amount is required")));N("loading"),E(!0),U("select-currency");try{tt("Creating payment with details:",t);let e=D;0===Object.keys(e).length&&(tt("No wallet addresses found, fetching from backend..."),e=yield Ud(),j(e)),tt("Using wallet addresses:",e);const n=yield jd({amount:t.amount,currency:t.currency||"USDT",network:t.network||g,customerEmail:t.customerEmail||i,callbackUrl:t.callbackUrl,metadata:__spreadProps(__spreadValues({},t.metadata),{merchantWalletAddresses:e}),merchantWalletAddresses:e});tt("Payment created:",n),k(n.payment),N("idle"),M(null),tt("Payment created and state updated")}catch(e){tt("Error creating payment:",e),M(e.message||"Failed to create payment"),N("error"),l&&l(e)}})),rt=()=>{z&&(clearInterval(z),Q(null)),V.current&&(clearTimeout(V.current),V.current=null),E(!1),R(null),G(null),P(null),U("select-currency"),W(null),J(!1),c&&c()};return Xd.jsx(Xd.Fragment,{children:A&&Xd.jsx(Ip,{isOpen:A,onClose:rt,payment:x,paymentStatus:S,selectedPaymentMethod:C,onPaymentMethodSelect:t=>{console.log("=== PAYMENT METHOD SELECTION DEBUG ==="),console.log("1. Payment method selected:",t),console.log("2. Current step before:",F),tt("Payment method selected:",t),P(t),U("confirm"),console.log("3. Step should now be: confirm"),console.log("=== END PAYMENT METHOD SELECTION DEBUG ===")},onPayment:()=>__async(this,null,(function*(){var t,e;if(x&&C)if(I||p){tt("Starting payment process..."),N("loading"),R(null),U("processing"),W(Date.now());try{let n;if(p)tt("Test mode: Generating mock transaction..."),n=`test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`,yield new Promise((t=>setTimeout(t,1e3)));else{let r;if(x.recipientWallet)r=x.recipientWallet;else{if(!D[C.network])throw new Error(`No merchant wallet address found for ${C.network} network`);r=D[C.network]}tt("Using merchant address for payment:",r),tt("Sending transaction through wallet..."),n=yield Md(I,{to:r,amount:x.totalAmount||x.amount,tokenAddress:null==(t=C.tokenConfig)?void 0:t.address,tokenDecimals:null==(e=C.tokenConfig)?void 0:e.decimals,currency:C.currency,network:C.network})}tt("Transaction hash obtained:",n),R(n),U("success"),et()}catch(n){tt("Payment error:",n),M(n.message||"Failed to process payment"),N("error"),U("error"),l&&l(n)}}else M("Please connect your wallet first");else M("Missing payment information")})),onBack:()=>{"confirm"===F?(U("select-currency"),G(null)):"error"===F&&U("confirm")},error:T,theme:Y,merchantName:s,transactionHash:B,walletConnection:I,onConnectWallet:t=>__async(this,null,(function*(){if(console.log("=== WALLET CONNECTION DEBUG ==="),console.log("1. Wallet type requested:",t),console.log("2. Selected payment method:",C),console.log("3. Available wallets:",O),console.log("4. Current step:",F),!C)return console.error("No payment method selected"),void M("Please select a payment method first");try{console.log("5. Attempting to connect wallet..."),M(null),tt("Connecting wallet:",{walletType:t,network:C.network});const e=yield Cd(t,C.network);G(e),M(null),console.log("6. Connection successful:",e),tt("Wallet connected successfully:",e)}catch(e){console.error("7. Connection failed:",e),tt("Wallet connection error:",e),M(e.message||"Failed to connect wallet")}console.log("=== END WALLET CONNECTION DEBUG ===")})),testMode:p,supportedNetworks:$,availableWallets:O,supportedWallets:C?Pd(C.network):[],step:F,merchantWalletAddresses:D,debug:X,processingStartTime:H,pendingBackendConfirmation:K,paymentNetwork:null==C?void 0:C.network})})}));Gp.displayName="CoinleyCheckout";t.CoinleyCheckout=Gp,t.CoinleyModal=Ip,t.CoinleyProvider=({apiKey:t,apiSecret:n,apiUrl:r="https://coinleyserver-production.up.railway.app",merchantWalletAddress:i=null,merchantSolWalletAddress:s=null,debug:a=!1,children:o})=>{const[l,c]=e.useState(!1),[u,h]=e.useState(null),[d,p]=e.useState(null),[f,g]=e.useState({});e.useEffect((()=>{if(!t||!n)return void h("API key and secret are required");(()=>{__async(this,null,(function*(){try{yield Ld({apiKey:t,apiSecret:n,apiUrl:r,debug:a});const e=yield Ud(),o=__spreadValues(__spreadValues(__spreadValues({},e),i&&{ethereum:i}),s&&{solana:s});g(o),c(!0),a&&console.log("Coinley SDK initialized successfully with wallets:",o)}catch(e){h(e.message),a&&console.error("Coinley SDK initialization error:",e)}}))})()}),[t,n,r,i,s,a]);const m={apiKey:t,apiSecret:n,apiUrl:r,merchantWalletAddress:i,merchantSolWalletAddress:s,merchantWallets:f,isInitialized:l,error:u,debug:a,paymentData:d,storePaymentData:t=>(p(t),t),refreshMerchantWallets:()=>__async(this,null,(function*(){try{const t=yield Ud();return g(t),t}catch(t){return console.error("Failed to refresh merchant wallets:",t),f}}))};return Xd.jsx(tp.Provider,{value:m,children:o})},t.DEFAULT_CONFIG={apiUrl:"https://coinleyserver-production.up.railway.app",debug:!1,testMode:!1,theme:"light",supportedNetworks:["ethereum","bsc","tron","algorand"]},t.NETWORK_CONFIG=_d,t.NETWORK_TYPES=md,t.PaymentMethods=Rp,t.PaymentStatus=kp,t.QRCode=xp,t.TOKEN_CONFIG=yd,t.ThemeProvider=({initialTheme:t="light",children:n})=>{const[r,i]=e.useState(t);return e.useEffect((()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(r)}),[r]),Xd.jsx($d.Provider,{value:{theme:r,setTheme:i,toggleTheme:()=>{i((t=>"light"===t?"dark":"light"))}},children:n})},t.WALLET_TYPES=gd,t.connectWallet=Cd,t.createPayment=jd,t.detectWallets=Ad,t.generateMockTransactionHash=(t="ethereum")=>`${{ethereum:"0x",bsc:"0x",tron:"",algorand:""}[t]||"0x"}${Array.from({length:64},(()=>Math.floor(16*Math.random()).toString(16))).join("")}`,t.getMerchantWallets=Ud,t.getPayment=t=>__async(this,null,(function*(){try{if(console.log("Getting payment:",t),!t)throw new Error("Payment ID is required");const n=yield fetch(`${Od.apiUrl}/api/payments/${t}`,{method:"GET",headers:Dd()});if(!n.ok){let t;try{t=yield n.json()}catch(e){throw new Error(`Failed to get payment: ${n.status} ${n.statusText}`)}throw console.error("Error getting payment:",t),new Error(t.error||`Failed to get payment: ${n.status}`)}const r=yield n.json();return console.log("Get payment response:",r),r}catch(n){throw console.error("Get payment error:",n),n}})),t.getSupportedNetworks=()=>__async(this,null,(function*(){try{const e=yield fetch(`${Od.apiUrl}/api/networks`,{method:"GET",headers:Dd()});if(!e.ok){let n;try{n=yield e.json()}catch(t){throw new Error(`Failed to get networks: ${e.status} ${e.statusText}`)}throw new Error(n.error||`Failed to get networks: ${e.status}`)}return yield e.json()}catch(e){throw console.error("Get supported networks error:",e),e}})),t.getSupportedWalletsForNetwork=Pd,t.getWalletInstallUrl=vd,t.processPayment=Hd,t.sendTransaction=Md,t.useCoinley=ep,t.validateWalletAddress=(t,e)=>__async(this,null,(function*(){try{const r=yield fetch(`${Od.apiUrl}/api/wallets/validate`,{method:"POST",headers:Dd(),body:JSON.stringify({address:t,network:e})});if(!r.ok){let t;try{t=yield r.json()}catch(n){throw new Error(`Failed to validate address: ${r.status} ${r.statusText}`)}throw new Error(t.error||`Failed to validate address: ${r.status}`)}return yield r.json()}catch(r){throw console.error("Validate wallet address error:",r),r}})),Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
17
17
|
//# sourceMappingURL=coinley-checkout.umd.js.map
|