coinley-checkout 0.3.4 → 0.3.5

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.
@@ -1,7 +1,7 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CoinleyCheckout={},e.React)}(this,(function(e,t){"use strict";var r=Object.defineProperty,n=Object.defineProperties,s=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,i=(e,t,n)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c=(e,t)=>{for(var r in t||(t={}))a.call(t,r)&&i(e,r,t[r]);if(o)for(var r of o(t))l.call(t,r)&&i(e,r,t[r]);return e},d=(e,t,r)=>new Promise(((n,s)=>{var o=e=>{try{l(r.next(e))}catch(t){s(t)}},a=e=>{try{l(r.throw(e))}catch(t){s(t)}},l=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,a);l((r=r.apply(e,t)).next())}));const u={ETHEREUM:"ethereum",BSC:"bsc",TRON:"tron",ALGORAND:"algorand"},h={METAMASK:"metamask",TRONLINK:"tronlink",TRUST_WALLET:"trust_wallet",LUTE:"lute"},m={[u.ETHEREUM]:{chainId:"0x1",chainName:"Ethereum Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:["https://mainnet.infura.io/v3/"],blockExplorerUrls:["https://etherscan.io/"],supportedWallets:[h.METAMASK,h.TRUST_WALLET]},[u.BSC]:{chainId:"0x38",chainName:"BNB Smart Chain",nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18},rpcUrls:["https://bsc-dataseed.binance.org/"],blockExplorerUrls:["https://bscscan.com/"],supportedWallets:[h.METAMASK,h.TRUST_WALLET]},[u.TRON]:{fullHost:"https://api.trongrid.io",explorerUrl:"https://tronscan.org",supportedWallets:[h.TRONLINK]},[u.ALGORAND]:{network:"mainnet",explorerUrl:"https://algoexplorer.io",supportedWallets:[h.LUTE]}},g={USDT:{[u.ETHEREUM]:{address:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6},[u.BSC]:{address:"0x55d398326f99059fF775485246999027B3197955",decimals:18},[u.TRON]:{address:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",decimals:6},[u.ALGORAND]:{address:"312769",decimals:6}},USDC:{[u.ETHEREUM]:{address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",decimals:6},[u.BSC]:{address:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",decimals:18},[u.TRON]:{address:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",decimals:6},[u.ALGORAND]:{address:"31566704",decimals:6}},PYUSD:{[u.ETHEREUM]:{address:"0x6c3ea9036406852006290770BEdFcAbA0e23A0e8",decimals:6}},FRAX:{[u.ETHEREUM]:{address:"0x853d955aCEf822Db058eb8505911ED77F175b99e",decimals:18},[u.BSC]:{address:"0x90C97F71E18723b0Cf0dfa30ee176Ab653E89F40",decimals:18}},USDP:{[u.ETHEREUM]:{address:"0x8E870D67F660D95d5be530380D0eC0bd388289E1",decimals:18}},DAI:{[u.ETHEREUM]:{address:"0x6B175474E89094C44Da98b954EedeAC495271d0F",decimals:18}},BUSD:{[u.BSC]:{address:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",decimals:18}},USDJ:{[u.TRON]:{address:"TMwFHYXLJaRUPeW6421aqXL4ZEzPRFGkGT",decimals:18}},ALGO:{[u.ALGORAND]:{address:"native",decimals:6}}};let p=null;const w=()=>d(this,null,(function*(){if(p)return p;try{if("undefined"!=typeof window&&window.Web3)return p=window.Web3,p;const e=yield import("web3");return p=e.default||e.Web3||e,p}catch(e){throw console.error("Failed to load Web3:",e),new Error("Web3 is required for blockchain transactions. Please ensure web3 is installed: npm install web3")}})),f=()=>{const e={[h.METAMASK]:!1,[h.TRUST_WALLET]:!1,[h.TRONLINK]:!1,[h.LUTE]:!1};if("undefined"==typeof window)return e;try{e[h.METAMASK]=!(!window.ethereum||!window.ethereum.isMetaMask),e[h.TRONLINK]=!!window.tronWeb,e[h.TRUST_WALLET]=!(!window.ethereum||!window.ethereum.isTrust),e[h.LUTE]=!(!window.algorand||!window.algorand.isLute)}catch(t){console.warn("Error detecting wallets:",t)}return e},y=e=>{const t=m[e];if(!t)return[];const r=f();return t.supportedWallets.filter((e=>r[e]))},x=(e,t)=>d(this,null,(function*(){switch(e){case h.METAMASK:return yield b(t);case h.TRONLINK:return yield N();case h.TRUST_WALLET:return yield E(t);case h.LUTE:return yield k();default:throw new Error(`Unsupported wallet type: ${e}`)}})),b=e=>d(this,null,(function*(){if("undefined"==typeof window||!window.ethereum||!window.ethereum.isMetaMask)throw new Error("MetaMask is not installed. Please install MetaMask extension.");try{const t=yield window.ethereum.request({method:"eth_requestAccounts"});if(!t||0===t.length)throw new Error("No accounts found. Please unlock MetaMask.");const r=m[e];return r&&r.chainId&&(yield v(r)),{address:t[0],network:e,walletType:h.METAMASK}}catch(t){if(4001===t.code)throw new Error("User rejected the connection request");throw new Error(`Failed to connect MetaMask: ${t.message}`)}})),N=()=>d(this,null,(function*(){var e;if("undefined"==typeof window||!window.tronWeb)throw new Error("TronLink is not installed. Please install TronLink extension.");let t=0;for(;!window.tronWeb.ready&&t<10;)yield new Promise((e=>setTimeout(e,1e3))),t++;if(!window.tronWeb.ready)throw new Error("TronLink is not ready. Please unlock your TronLink wallet and try again.");const r=null==(e=window.tronWeb.defaultAddress)?void 0:e.base58;if(!r)throw new Error("No account found in TronLink. Please make sure you have an account set up.");return{address:r,network:u.TRON,walletType:h.TRONLINK}})),E=e=>d(this,null,(function*(){if("undefined"==typeof window||!window.ethereum||!window.ethereum.isTrust)throw new Error("Trust Wallet is not installed. Please install Trust Wallet extension.");try{const t=yield window.ethereum.request({method:"eth_requestAccounts"});if(!t||0===t.length)throw new Error("No accounts found. Please unlock Trust Wallet.");const r=m[e];return r&&r.chainId&&(yield v(r)),{address:t[0],network:e,walletType:h.TRUST_WALLET}}catch(t){if(4001===t.code)throw new Error("User rejected the connection request");throw new Error(`Failed to connect Trust Wallet: ${t.message}`)}})),k=()=>d(this,null,(function*(){if("undefined"==typeof window||!window.algorand||!window.algorand.isLute)throw new Error("Lute wallet is not installed. Please install Lute wallet extension.");try{const e=yield window.algorand.connect();if(!e||0===e.length)throw new Error("No accounts found. Please unlock Lute wallet.");return{address:e[0],network:u.ALGORAND,walletType:h.LUTE}}catch(e){throw new Error(`Failed to connect Lute wallet: ${e.message}`)}})),v=e=>d(this,null,(function*(){if("undefined"==typeof window||!window.ethereum)throw new Error("Ethereum provider not found");try{yield window.ethereum.request({method:"wallet_switchEthereumChain",params:[{chainId:e.chainId}]})}catch(t){if(4902!==t.code)throw 4001===t.code?new Error("User rejected network switch request"):new Error(`Failed to switch to ${e.chainName}: ${t.message}`);try{yield window.ethereum.request({method:"wallet_addEthereumChain",params:[e]})}catch(r){throw new Error(`Failed to add ${e.chainName} to wallet: ${r.message}`)}}})),A=(e,t)=>d(this,null,(function*(){const{walletType:r,network:n,address:s}=e,{to:o,amount:a,tokenAddress:l,tokenDecimals:i}=t;switch(r){case h.METAMASK:case h.TRUST_WALLET:return yield S(s,o,a,l,i);case h.TRONLINK:return yield T(o,a,l,i);case h.LUTE:return yield C(s,o,a);default:throw new Error(`Unsupported wallet type: ${r}`)}})),S=(e,t,r,n,s)=>d(this,null,(function*(){if("undefined"==typeof window||!window.ethereum)throw new Error("Ethereum provider not found");try{const o=new(yield w())(window.ethereum),a=o.utils.toBN(Math.floor(parseFloat(r)*Math.pow(10,s||18)));if(n&&"native"!==n){const r=[{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],s=new o.eth.Contract(r,n);return(yield s.methods.transfer(t,a).send({from:e})).transactionHash}return(yield o.eth.sendTransaction({from:e,to:t,value:a})).transactionHash}catch(o){if(4001===o.code)throw new Error("Transaction was rejected by user");throw new Error(`Transaction failed: ${o.message}`)}})),T=(e,t,r,n)=>d(this,null,(function*(){if("undefined"==typeof window||!window.tronWeb||!window.tronWeb.ready)throw new Error("TronLink is not ready");try{const s=Math.floor(parseFloat(t)*Math.pow(10,n||6));if(r&&"native"!==r){const t=yield window.tronWeb.contract().at(r);return yield t.transfer(e,s).send({feeLimit:1e8,callValue:0})}return(yield window.tronWeb.trx.sendTransaction(e,s)).txid}catch(s){throw new Error(`TRON transaction failed: ${s.message}`)}})),C=(e,t,r)=>d(this,null,(function*(){if("undefined"==typeof window||!window.algorand)throw new Error("Algorand wallet is not available");try{const n=Math.floor(1e6*parseFloat(r)),s={from:e,to:t,amount:n,type:"pay"},o=yield window.algorand.signTransaction(s);return(yield window.algorand.sendTransaction(o)).txId}catch(n){throw new Error(`Algorand transaction failed: ${n.message}`)}})),j=e=>({[h.METAMASK]:"https://metamask.io/",[h.TRONLINK]:"https://www.tronlink.org/",[h.TRUST_WALLET]:"https://trustwallet.com/",[h.LUTE]:"https://lute.app/"}[e]||"");let M={apiKey:null,apiSecret:null,apiUrl:"http://localhost:9000",merchantWalletAddresses:{}};const R=()=>({"Content-Type":"application/json","x-api-key":M.apiKey,"x-api-secret":M.apiSecret}),L=e=>d(this,null,(function*(){try{console.log("Creating payment with data:",e),console.log("API URL:",`${M.apiUrl}/api/payments/create`);const o=(t=c({},e),r={merchantWalletAddresses:c(c({},M.merchantWalletAddresses),e.merchantWalletAddresses)},n(t,s(r))),a=yield fetch(`${M.apiUrl}/api/payments/create`,{method:"POST",headers:R(),body:JSON.stringify(o)});if(console.log("Create payment response status:",a.status),!a.ok){const e=yield a.json();throw console.error("Error creating payment:",e),new Error(e.error||`Failed to create payment: ${a.status}`)}const l=yield a.json();return console.log("Create payment response data:",l),l}catch(o){throw console.error("Create payment error:",o),o}var t,r})),D=e=>d(this,null,(function*(){try{console.log("Processing payment with data:",e),console.log("API URL:",`${M.apiUrl}/api/payments/process`);const t=yield fetch(`${M.apiUrl}/api/payments/process`,{method:"POST",headers:R(),body:JSON.stringify(e)});if(console.log("Process payment response status:",t.status),!t.ok){const e=yield t.json();throw console.error("Error processing payment:",e),new Error(e.error||`Failed to process payment: ${t.status}`)}const r=yield t.json();return console.log("Process payment response data:",r),r}catch(t){throw console.error("Process payment error:",t),t}}));var U={exports:{}},P={},O=t,F=Symbol.for("react.element"),W=Symbol.for("react.fragment"),B=Object.prototype.hasOwnProperty,I=O.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,z={key:!0,ref:!0,__self:!0,__source:!0};function H(e,t,r){var n,s={},o=null,a=null;for(n in void 0!==r&&(o=""+r),void 0!==t.key&&(o=""+t.key),void 0!==t.ref&&(a=t.ref),t)B.call(t,n)&&!z.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:F,type:e,key:o,ref:a,props:s,_owner:I.current}}P.Fragment=W,P.jsx=H,P.jsxs=H,U.exports=P;var Q=U.exports;const q=t.createContext(),G=t.createContext(),K=()=>t.useContext(G);var _,V,J=Object.defineProperty,$=Object.getOwnPropertySymbols,Y=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,Z=(e,t,r)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ee=(e,t)=>{for(var r in t||(t={}))Y.call(t,r)&&Z(e,r,t[r]);if($)for(var r of $(t))X.call(t,r)&&Z(e,r,t[r]);return e},te=(e,t)=>{var r={};for(var n in e)Y.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&$)for(var n of $(e))t.indexOf(n)<0&&X.call(e,n)&&(r[n]=e[n]);return r};(e=>{const t=class t{constructor(e,r,n,o){if(this.version=e,this.errorCorrectionLevel=r,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version value out of range");if(o<-1||o>7)throw new RangeError("Mask value out of range");this.size=4*e+17;let a=[];for(let t=0;t<this.size;t++)a.push(!1);for(let t=0;t<this.size;t++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();const l=this.addEccAndInterleave(n);if(this.drawCodewords(l),-1==o){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);const r=this.getPenaltyScore();r<e&&(o=t,e=r),this.applyMask(t)}}s(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(r,n){const s=e.QrSegment.makeSegments(r);return t.encodeSegments(s,n)}static encodeBinary(r,n){const s=e.QrSegment.makeBytes(r);return t.encodeSegments([s],n)}static encodeSegments(e,n,o=1,l=40,i=-1,c=!0){if(!(t.MIN_VERSION<=o&&o<=l&&l<=t.MAX_VERSION)||i<-1||i>7)throw new RangeError("Invalid value");let d,u;for(d=o;;d++){const r=8*t.getNumDataCodewords(d,n),s=a.getTotalBits(e,d);if(s<=r){u=s;break}if(d>=l)throw new RangeError("Data too long")}for(const r of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])c&&u<=8*t.getNumDataCodewords(d,r)&&(n=r);let h=[];for(const t of e){r(t.mode.modeBits,4,h),r(t.numChars,t.mode.numCharCountBits(d),h);for(const e of t.getData())h.push(e)}s(h.length==u);const m=8*t.getNumDataCodewords(d,n);s(h.length<=m),r(0,Math.min(4,m-h.length),h),r(0,(8-h.length%8)%8,h),s(h.length%8==0);for(let t=236;h.length<m;t^=253)r(t,8,h);let g=[];for(;8*g.length<h.length;)g.push(0);return h.forEach(((e,t)=>g[t>>>3]|=e<<7-(7&t))),new t(d,n,g,i)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let r=0;r<this.size;r++)this.setFunctionModule(6,r,r%2==0),this.setFunctionModule(r,6,r%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),t=e.length;for(let r=0;r<t;r++)for(let n=0;n<t;n++)0==r&&0==n||0==r&&n==t-1||r==t-1&&0==n||this.drawAlignmentPattern(e[r],e[n]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const t=this.errorCorrectionLevel.formatBits<<3|e;let r=t;for(let n=0;n<10;n++)r=r<<1^1335*(r>>>9);const o=21522^(t<<10|r);s(o>>>15==0);for(let s=0;s<=5;s++)this.setFunctionModule(8,s,n(o,s));this.setFunctionModule(8,7,n(o,6)),this.setFunctionModule(8,8,n(o,7)),this.setFunctionModule(7,8,n(o,8));for(let s=9;s<15;s++)this.setFunctionModule(14-s,8,n(o,s));for(let s=0;s<8;s++)this.setFunctionModule(this.size-1-s,8,n(o,s));for(let s=8;s<15;s++)this.setFunctionModule(8,this.size-15+s,n(o,s));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let r=0;r<12;r++)e=e<<1^7973*(e>>>11);const t=this.version<<12|e;s(t>>>18==0);for(let r=0;r<18;r++){const e=n(t,r),s=this.size-11+r%3,o=Math.floor(r/3);this.setFunctionModule(s,o,e),this.setFunctionModule(o,s,e)}}drawFinderPattern(e,t){for(let r=-4;r<=4;r++)for(let n=-4;n<=4;n++){const s=Math.max(Math.abs(n),Math.abs(r)),o=e+n,a=t+r;0<=o&&o<this.size&&0<=a&&a<this.size&&this.setFunctionModule(o,a,2!=s&&4!=s)}}drawAlignmentPattern(e,t){for(let r=-2;r<=2;r++)for(let n=-2;n<=2;n++)this.setFunctionModule(e+n,t+r,1!=Math.max(Math.abs(n),Math.abs(r)))}setFunctionModule(e,t,r){this.modules[t][e]=r,this.isFunction[t][e]=!0}addEccAndInterleave(e){const r=this.version,n=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(r,n))throw new RangeError("Invalid argument");const o=t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][r],a=t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][r],l=Math.floor(t.getNumRawDataModules(r)/8),i=o-l%o,c=Math.floor(l/o);let d=[];const u=t.reedSolomonComputeDivisor(a);for(let s=0,m=0;s<o;s++){let r=e.slice(m,m+c-a+(s<i?0:1));m+=r.length;const n=t.reedSolomonComputeRemainder(r,u);s<i&&r.push(0),d.push(r.concat(n))}let h=[];for(let t=0;t<d[0].length;t++)d.forEach(((e,r)=>{(t!=c-a||r>=i)&&h.push(e[t])}));return s(h.length==l),h}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let r=0;for(let t=this.size-1;t>=1;t-=2){6==t&&(t=5);for(let s=0;s<this.size;s++)for(let o=0;o<2;o++){const a=t-o,l=!(t+1&2)?this.size-1-s:s;!this.isFunction[l][a]&&r<8*e.length&&(this.modules[l][a]=n(e[r>>>3],7-(7&r)),r++)}}s(r==8*e.length)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let t=0;t<this.size;t++)for(let r=0;r<this.size;r++){let n;switch(e){case 0:n=(r+t)%2==0;break;case 1:n=t%2==0;break;case 2:n=r%3==0;break;case 3:n=(r+t)%3==0;break;case 4:n=(Math.floor(r/3)+Math.floor(t/2))%2==0;break;case 5:n=r*t%2+r*t%3==0;break;case 6:n=(r*t%2+r*t%3)%2==0;break;case 7:n=((r+t)%2+r*t%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[t][r]&&n&&(this.modules[t][r]=!this.modules[t][r])}}getPenaltyScore(){let e=0;for(let s=0;s<this.size;s++){let r=!1,n=0,o=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[s][a]==r?(n++,5==n?e+=t.PENALTY_N1:n>5&&e++):(this.finderPenaltyAddHistory(n,o),r||(e+=this.finderPenaltyCountPatterns(o)*t.PENALTY_N3),r=this.modules[s][a],n=1);e+=this.finderPenaltyTerminateAndCount(r,n,o)*t.PENALTY_N3}for(let s=0;s<this.size;s++){let r=!1,n=0,o=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][s]==r?(n++,5==n?e+=t.PENALTY_N1:n>5&&e++):(this.finderPenaltyAddHistory(n,o),r||(e+=this.finderPenaltyCountPatterns(o)*t.PENALTY_N3),r=this.modules[a][s],n=1);e+=this.finderPenaltyTerminateAndCount(r,n,o)*t.PENALTY_N3}for(let s=0;s<this.size-1;s++)for(let r=0;r<this.size-1;r++){const n=this.modules[s][r];n==this.modules[s][r+1]&&n==this.modules[s+1][r]&&n==this.modules[s+1][r+1]&&(e+=t.PENALTY_N2)}let r=0;for(const t of this.modules)r=t.reduce(((e,t)=>e+(t?1:0)),r);const n=this.size*this.size,o=Math.ceil(Math.abs(20*r-10*n)/n)-1;return s(0<=o&&o<=9),e+=o*t.PENALTY_N4,s(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(1==this.version)return[];{const e=Math.floor(this.version/7)+2,t=32==this.version?26:2*Math.ceil((4*this.version+4)/(2*e-2));let r=[6];for(let n=this.size-7;r.length<e;n-=t)r.splice(1,0,n);return r}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version number out of range");let r=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;r-=(25*t-10)*t-55,e>=7&&(r-=36)}return s(208<=r&&r<=29648),r}static getNumDataCodewords(e,r){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let r=[];for(let t=0;t<e-1;t++)r.push(0);r.push(1);let n=1;for(let s=0;s<e;s++){for(let e=0;e<r.length;e++)r[e]=t.reedSolomonMultiply(r[e],n),e+1<r.length&&(r[e]^=r[e+1]);n=t.reedSolomonMultiply(n,2)}return r}static reedSolomonComputeRemainder(e,r){let n=r.map((e=>0));for(const s of e){const e=s^n.shift();n.push(0),r.forEach(((r,s)=>n[s]^=t.reedSolomonMultiply(r,e)))}return n}static reedSolomonMultiply(e,t){if(e>>>8!=0||t>>>8!=0)throw new RangeError("Byte out of range");let r=0;for(let n=7;n>=0;n--)r=r<<1^285*(r>>>7),r^=(t>>>n&1)*e;return s(r>>>8==0),r}finderPenaltyCountPatterns(e){const t=e[1];s(t<=3*this.size);const r=t>0&&e[2]==t&&e[3]==3*t&&e[4]==t&&e[5]==t;return(r&&e[0]>=4*t&&e[6]>=t?1:0)+(r&&e[6]>=4*t&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,r){return e&&(this.finderPenaltyAddHistory(t,r),t=0),t+=this.size,this.finderPenaltyAddHistory(t,r),this.finderPenaltyCountPatterns(r)}finderPenaltyAddHistory(e,t){0==t[0]&&(e+=this.size),t.pop(),t.unshift(e)}};function r(e,t,r){if(t<0||t>31||e>>>t!=0)throw new RangeError("Value out of range");for(let n=t-1;n>=0;n--)r.push(e>>>n&1)}function n(e,t){return!!(e>>>t&1)}function s(e){if(!e)throw new Error("Assertion error")}t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;const o=class e{constructor(e,t,r){if(this.mode=e,this.numChars=t,this.bitData=r,t<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}static makeBytes(t){let n=[];for(const e of t)r(e,8,n);return new e(e.Mode.BYTE,t.length,n)}static makeNumeric(t){if(!e.isNumeric(t))throw new RangeError("String contains non-numeric characters");let n=[];for(let e=0;e<t.length;){const s=Math.min(t.length-e,3);r(parseInt(t.substring(e,e+s),10),3*s+1,n),e+=s}return new e(e.Mode.NUMERIC,t.length,n)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n,s=[];for(n=0;n+2<=t.length;n+=2){let o=45*e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n));o+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n+1)),r(o,11,s)}return n<t.length&&r(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n)),6,s),new e(e.Mode.ALPHANUMERIC,t.length,s)}static makeSegments(t){return""==t?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let n=[];if(t<0)throw new RangeError("ECI assignment value out of range");if(t<128)r(t,8,n);else if(t<16384)r(2,2,n),r(t,14,n);else{if(!(t<1e6))throw new RangeError("ECI assignment value out of range");r(6,3,n),r(t,21,n)}return new e(e.Mode.ECI,0,n)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let r=0;for(const n of e){const e=n.mode.numCharCountBits(t);if(n.numChars>=1<<e)return 1/0;r+=4+e+n.bitData.length}return r}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let r=0;r<e.length;r++)"%"!=e.charAt(r)?t.push(e.charCodeAt(r)):(t.push(parseInt(e.substring(r+1,r+3),16)),r+=2);return t}};o.NUMERIC_REGEX=/^[0-9]*$/,o.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,o.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let a=o;e.QrSegment=o})(_||(_={})),(e=>{const t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})((V=_||(_={})).QrCode||(V.QrCode={})),(e=>{(e=>{const t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||(e.QrSegment={}))})(_||(_={}));var re=_,ne={L:re.QrCode.Ecc.LOW,M:re.QrCode.Ecc.MEDIUM,Q:re.QrCode.Ecc.QUARTILE,H:re.QrCode.Ecc.HIGH},se=128,oe="L",ae="#FFFFFF",le="#000000",ie=!1,ce=1;
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CoinleyCheckout={},e.React)}(this,(function(e,t){"use strict";var r=Object.defineProperty,n=Object.defineProperties,s=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,i=(e,t,n)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c=(e,t)=>{for(var r in t||(t={}))a.call(t,r)&&i(e,r,t[r]);if(o)for(var r of o(t))l.call(t,r)&&i(e,r,t[r]);return e},d=(e,t,r)=>new Promise(((n,s)=>{var o=e=>{try{l(r.next(e))}catch(t){s(t)}},a=e=>{try{l(r.throw(e))}catch(t){s(t)}},l=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,a);l((r=r.apply(e,t)).next())}));const u={ETHEREUM:"ethereum",BSC:"bsc",TRON:"tron",ALGORAND:"algorand"},h={METAMASK:"metamask",TRONLINK:"tronlink",TRUST_WALLET:"trust_wallet",LUTE:"lute"},m={[u.ETHEREUM]:{chainId:"0x1",chainName:"Ethereum Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:["https://mainnet.infura.io/v3/"],blockExplorerUrls:["https://etherscan.io/"],supportedWallets:[h.METAMASK,h.TRUST_WALLET]},[u.BSC]:{chainId:"0x38",chainName:"BNB Smart Chain",nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18},rpcUrls:["https://bsc-dataseed.binance.org/"],blockExplorerUrls:["https://bscscan.com/"],supportedWallets:[h.METAMASK,h.TRUST_WALLET]},[u.TRON]:{fullHost:"https://api.trongrid.io",explorerUrl:"https://tronscan.org",supportedWallets:[h.TRONLINK]},[u.ALGORAND]:{network:"mainnet",explorerUrl:"https://algoexplorer.io",supportedWallets:[h.LUTE]}},g={USDT:{[u.ETHEREUM]:{address:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6},[u.BSC]:{address:"0x55d398326f99059fF775485246999027B3197955",decimals:18},[u.TRON]:{address:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",decimals:6},[u.ALGORAND]:{address:"312769",decimals:6}},USDC:{[u.ETHEREUM]:{address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",decimals:6},[u.BSC]:{address:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",decimals:18},[u.TRON]:{address:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",decimals:6},[u.ALGORAND]:{address:"31566704",decimals:6}},PYUSD:{[u.ETHEREUM]:{address:"0x6c3ea9036406852006290770BEdFcAbA0e23A0e8",decimals:6}},FRAX:{[u.ETHEREUM]:{address:"0x853d955aCEf822Db058eb8505911ED77F175b99e",decimals:18},[u.BSC]:{address:"0x90C97F71E18723b0Cf0dfa30ee176Ab653E89F40",decimals:18}},USDP:{[u.ETHEREUM]:{address:"0x8E870D67F660D95d5be530380D0eC0bd388289E1",decimals:18}},DAI:{[u.ETHEREUM]:{address:"0x6B175474E89094C44Da98b954EedeAC495271d0F",decimals:18}},BUSD:{[u.BSC]:{address:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",decimals:18}},USDJ:{[u.TRON]:{address:"TMwFHYXLJaRUPeW6421aqXL4ZEzPRFGkGT",decimals:18}},ALGO:{[u.ALGORAND]:{address:"native",decimals:6}}},p=()=>d(this,null,(function*(){try{if("undefined"!=typeof window&&window.ethereum){const e=yield import("web3");return new(e.default||e.Web3||e)(window.ethereum)}throw new Error("No ethereum provider found")}catch(e){throw console.error("Failed to load Web3:",e),new Error("Web3 is required for blockchain transactions. Please install MetaMask or another Web3 wallet.")}})),w=()=>{const e={[h.METAMASK]:!1,[h.TRUST_WALLET]:!1,[h.TRONLINK]:!1,[h.LUTE]:!1};if("undefined"==typeof window)return e;try{e[h.METAMASK]=!(!window.ethereum||!window.ethereum.isMetaMask),e[h.TRONLINK]=!!window.tronWeb,e[h.TRUST_WALLET]=!(!window.ethereum||!window.ethereum.isTrust),e[h.LUTE]=!(!window.algorand||!window.algorand.isLute)}catch(t){console.warn("Error detecting wallets:",t)}return e},f=e=>{const t=m[e];if(!t)return[];const r=w();return t.supportedWallets.filter((e=>r[e]))},y=(e,t)=>d(this,null,(function*(){switch(console.log("connectWallet called with:",{walletType:e,network:t}),e){case h.METAMASK:return yield x(t);case h.TRONLINK:return yield b();case h.TRUST_WALLET:return yield N(t);case h.LUTE:return yield E();default:throw new Error(`Unsupported wallet type: ${e}`)}})),x=e=>d(this,null,(function*(){if(console.log("Attempting to connect MetaMask for network:",e),"undefined"==typeof window||!window.ethereum)throw new Error("MetaMask is not installed. Please install MetaMask extension.");window.ethereum.isMetaMask||console.warn("MetaMask not detected as primary provider");try{console.log("Requesting accounts from MetaMask...");const t=yield window.ethereum.request({method:"eth_requestAccounts"});if(console.log("Accounts received:",t),!t||0===t.length)throw new Error("No accounts found. Please unlock MetaMask and ensure you have at least one account.");const r=m[e];r&&r.chainId&&(console.log("Switching to network:",r.chainName),yield k(r));const n={address:t[0],network:e,walletType:h.METAMASK};return console.log("MetaMask connected successfully:",n),n}catch(t){if(console.error("MetaMask connection error:",t),4001===t.code)throw new Error("Connection rejected by user. Please accept the connection request in MetaMask.");if(-32002===t.code)throw new Error("Connection request already pending. Please check MetaMask.");throw new Error(`Failed to connect MetaMask: ${t.message}`)}})),b=()=>d(this,null,(function*(){var e;if("undefined"==typeof window||!window.tronWeb)throw new Error("TronLink is not installed. Please install TronLink extension.");let t=0;for(;!window.tronWeb.ready&&t<10;)yield new Promise((e=>setTimeout(e,1e3))),t++;if(!window.tronWeb.ready)throw new Error("TronLink is not ready. Please unlock your TronLink wallet and try again.");const r=null==(e=window.tronWeb.defaultAddress)?void 0:e.base58;if(!r)throw new Error("No account found in TronLink. Please make sure you have an account set up.");return{address:r,network:u.TRON,walletType:h.TRONLINK}})),N=e=>d(this,null,(function*(){if("undefined"==typeof window||!window.ethereum||!window.ethereum.isTrust)throw new Error("Trust Wallet is not installed. Please install Trust Wallet extension.");try{const t=yield window.ethereum.request({method:"eth_requestAccounts"});if(!t||0===t.length)throw new Error("No accounts found. Please unlock Trust Wallet.");const r=m[e];return r&&r.chainId&&(yield k(r)),{address:t[0],network:e,walletType:h.TRUST_WALLET}}catch(t){if(4001===t.code)throw new Error("User rejected the connection request");throw new Error(`Failed to connect Trust Wallet: ${t.message}`)}})),E=()=>d(this,null,(function*(){if("undefined"==typeof window||!window.algorand||!window.algorand.isLute)throw new Error("Lute wallet is not installed. Please install Lute wallet extension.");try{const e=yield window.algorand.connect();if(!e||0===e.length)throw new Error("No accounts found. Please unlock Lute wallet.");return{address:e[0],network:u.ALGORAND,walletType:h.LUTE}}catch(e){throw new Error(`Failed to connect Lute wallet: ${e.message}`)}})),k=e=>d(this,null,(function*(){if("undefined"==typeof window||!window.ethereum)throw new Error("Ethereum provider not found");try{console.log("Attempting to switch to:",e.chainName),yield window.ethereum.request({method:"wallet_switchEthereumChain",params:[{chainId:e.chainId}]}),console.log("Network switched successfully")}catch(t){if(console.error("Network switch error:",t),4902!==t.code)throw 4001===t.code?new Error("User rejected network switch request. Please switch network manually in MetaMask."):new Error(`Failed to switch to ${e.chainName}. Please switch manually in MetaMask.`);console.log("Network not found, attempting to add:",e.chainName);try{yield window.ethereum.request({method:"wallet_addEthereumChain",params:[e]}),console.log("Network added successfully")}catch(r){throw console.error("Failed to add network:",r),new Error(`Failed to add ${e.chainName} to wallet. Please add it manually.`)}}})),A=(e,t)=>d(this,null,(function*(){const{walletType:r,network:n,address:s}=e,{to:o,amount:a,tokenAddress:l,tokenDecimals:i}=t;switch(r){case h.METAMASK:case h.TRUST_WALLET:return yield v(s,o,a,l,i);case h.TRONLINK:return yield T(o,a,l,i);case h.LUTE:return yield S(s,o,a);default:throw new Error(`Unsupported wallet type: ${r}`)}})),v=(e,t,r,n,s)=>d(this,null,(function*(){if("undefined"==typeof window||!window.ethereum)throw new Error("Ethereum provider not found");try{const o=new(yield p())(window.ethereum),a=o.utils.toBN(Math.floor(parseFloat(r)*Math.pow(10,s||18)));if(n&&"native"!==n){const r=[{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],s=new o.eth.Contract(r,n);return(yield s.methods.transfer(t,a).send({from:e})).transactionHash}return(yield o.eth.sendTransaction({from:e,to:t,value:a})).transactionHash}catch(o){if(4001===o.code)throw new Error("Transaction was rejected by user");throw new Error(`Transaction failed: ${o.message}`)}})),T=(e,t,r,n)=>d(this,null,(function*(){if("undefined"==typeof window||!window.tronWeb||!window.tronWeb.ready)throw new Error("TronLink is not ready");try{const s=Math.floor(parseFloat(t)*Math.pow(10,n||6));if(r&&"native"!==r){const t=yield window.tronWeb.contract().at(r);return yield t.transfer(e,s).send({feeLimit:1e8,callValue:0})}return(yield window.tronWeb.trx.sendTransaction(e,s)).txid}catch(s){throw new Error(`TRON transaction failed: ${s.message}`)}})),S=(e,t,r)=>d(this,null,(function*(){if("undefined"==typeof window||!window.algorand)throw new Error("Algorand wallet is not available");try{const n=Math.floor(1e6*parseFloat(r)),s={from:e,to:t,amount:n,type:"pay"},o=yield window.algorand.signTransaction(s);return(yield window.algorand.sendTransaction(o)).txId}catch(n){throw new Error(`Algorand transaction failed: ${n.message}`)}})),M=e=>({[h.METAMASK]:"https://metamask.io/",[h.TRONLINK]:"https://www.tronlink.org/",[h.TRUST_WALLET]:"https://trustwallet.com/",[h.LUTE]:"https://lute.app/"}[e]||"");let C={apiKey:null,apiSecret:null,apiUrl:"http://localhost:9000",merchantWalletAddresses:{}};const j=()=>({"Content-Type":"application/json","x-api-key":C.apiKey,"x-api-secret":C.apiSecret}),R=e=>d(this,null,(function*(){try{console.log("Creating payment with data:",e),console.log("API URL:",`${C.apiUrl}/api/payments/create`);const o=(t=c({},e),r={merchantWalletAddresses:c(c({},C.merchantWalletAddresses),e.merchantWalletAddresses)},n(t,s(r))),a=yield fetch(`${C.apiUrl}/api/payments/create`,{method:"POST",headers:j(),body:JSON.stringify(o)});if(console.log("Create payment response status:",a.status),!a.ok){const e=yield a.json();throw console.error("Error creating payment:",e),new Error(e.error||`Failed to create payment: ${a.status}`)}const l=yield a.json();return console.log("Create payment response data:",l),l}catch(o){throw console.error("Create payment error:",o),o}var t,r})),L=e=>d(this,null,(function*(){try{console.log("Processing payment with data:",e),console.log("API URL:",`${C.apiUrl}/api/payments/process`);const t=yield fetch(`${C.apiUrl}/api/payments/process`,{method:"POST",headers:j(),body:JSON.stringify(e)});if(console.log("Process payment response status:",t.status),!t.ok){const e=yield t.json();throw console.error("Error processing payment:",e),new Error(e.error||`Failed to process payment: ${t.status}`)}const r=yield t.json();return console.log("Process payment response data:",r),r}catch(t){throw console.error("Process payment error:",t),t}}));var D={exports:{}},P={},U=t,O=Symbol.for("react.element"),F=Symbol.for("react.fragment"),W=Object.prototype.hasOwnProperty,B=U.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,I={key:!0,ref:!0,__self:!0,__source:!0};function z(e,t,r){var n,s={},o=null,a=null;for(n in void 0!==r&&(o=""+r),void 0!==t.key&&(o=""+t.key),void 0!==t.ref&&(a=t.ref),t)W.call(t,n)&&!I.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:O,type:e,key:o,ref:a,props:s,_owner:B.current}}P.Fragment=F,P.jsx=z,P.jsxs=z,D.exports=P;var H=D.exports;const q=t.createContext(),Q=t.createContext(),G=()=>t.useContext(Q);var K,_,V=Object.defineProperty,J=Object.getOwnPropertySymbols,$=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable,X=(e,t,r)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Z=(e,t)=>{for(var r in t||(t={}))$.call(t,r)&&X(e,r,t[r]);if(J)for(var r of J(t))Y.call(t,r)&&X(e,r,t[r]);return e},ee=(e,t)=>{var r={};for(var n in e)$.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&J)for(var n of J(e))t.indexOf(n)<0&&Y.call(e,n)&&(r[n]=e[n]);return r};(e=>{const t=class t{constructor(e,r,n,o){if(this.version=e,this.errorCorrectionLevel=r,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version value out of range");if(o<-1||o>7)throw new RangeError("Mask value out of range");this.size=4*e+17;let a=[];for(let t=0;t<this.size;t++)a.push(!1);for(let t=0;t<this.size;t++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();const l=this.addEccAndInterleave(n);if(this.drawCodewords(l),-1==o){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);const r=this.getPenaltyScore();r<e&&(o=t,e=r),this.applyMask(t)}}s(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(r,n){const s=e.QrSegment.makeSegments(r);return t.encodeSegments(s,n)}static encodeBinary(r,n){const s=e.QrSegment.makeBytes(r);return t.encodeSegments([s],n)}static encodeSegments(e,n,o=1,l=40,i=-1,c=!0){if(!(t.MIN_VERSION<=o&&o<=l&&l<=t.MAX_VERSION)||i<-1||i>7)throw new RangeError("Invalid value");let d,u;for(d=o;;d++){const r=8*t.getNumDataCodewords(d,n),s=a.getTotalBits(e,d);if(s<=r){u=s;break}if(d>=l)throw new RangeError("Data too long")}for(const r of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])c&&u<=8*t.getNumDataCodewords(d,r)&&(n=r);let h=[];for(const t of e){r(t.mode.modeBits,4,h),r(t.numChars,t.mode.numCharCountBits(d),h);for(const e of t.getData())h.push(e)}s(h.length==u);const m=8*t.getNumDataCodewords(d,n);s(h.length<=m),r(0,Math.min(4,m-h.length),h),r(0,(8-h.length%8)%8,h),s(h.length%8==0);for(let t=236;h.length<m;t^=253)r(t,8,h);let g=[];for(;8*g.length<h.length;)g.push(0);return h.forEach(((e,t)=>g[t>>>3]|=e<<7-(7&t))),new t(d,n,g,i)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let r=0;r<this.size;r++)this.setFunctionModule(6,r,r%2==0),this.setFunctionModule(r,6,r%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),t=e.length;for(let r=0;r<t;r++)for(let n=0;n<t;n++)0==r&&0==n||0==r&&n==t-1||r==t-1&&0==n||this.drawAlignmentPattern(e[r],e[n]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const t=this.errorCorrectionLevel.formatBits<<3|e;let r=t;for(let n=0;n<10;n++)r=r<<1^1335*(r>>>9);const o=21522^(t<<10|r);s(o>>>15==0);for(let s=0;s<=5;s++)this.setFunctionModule(8,s,n(o,s));this.setFunctionModule(8,7,n(o,6)),this.setFunctionModule(8,8,n(o,7)),this.setFunctionModule(7,8,n(o,8));for(let s=9;s<15;s++)this.setFunctionModule(14-s,8,n(o,s));for(let s=0;s<8;s++)this.setFunctionModule(this.size-1-s,8,n(o,s));for(let s=8;s<15;s++)this.setFunctionModule(8,this.size-15+s,n(o,s));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let r=0;r<12;r++)e=e<<1^7973*(e>>>11);const t=this.version<<12|e;s(t>>>18==0);for(let r=0;r<18;r++){const e=n(t,r),s=this.size-11+r%3,o=Math.floor(r/3);this.setFunctionModule(s,o,e),this.setFunctionModule(o,s,e)}}drawFinderPattern(e,t){for(let r=-4;r<=4;r++)for(let n=-4;n<=4;n++){const s=Math.max(Math.abs(n),Math.abs(r)),o=e+n,a=t+r;0<=o&&o<this.size&&0<=a&&a<this.size&&this.setFunctionModule(o,a,2!=s&&4!=s)}}drawAlignmentPattern(e,t){for(let r=-2;r<=2;r++)for(let n=-2;n<=2;n++)this.setFunctionModule(e+n,t+r,1!=Math.max(Math.abs(n),Math.abs(r)))}setFunctionModule(e,t,r){this.modules[t][e]=r,this.isFunction[t][e]=!0}addEccAndInterleave(e){const r=this.version,n=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(r,n))throw new RangeError("Invalid argument");const o=t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][r],a=t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][r],l=Math.floor(t.getNumRawDataModules(r)/8),i=o-l%o,c=Math.floor(l/o);let d=[];const u=t.reedSolomonComputeDivisor(a);for(let s=0,m=0;s<o;s++){let r=e.slice(m,m+c-a+(s<i?0:1));m+=r.length;const n=t.reedSolomonComputeRemainder(r,u);s<i&&r.push(0),d.push(r.concat(n))}let h=[];for(let t=0;t<d[0].length;t++)d.forEach(((e,r)=>{(t!=c-a||r>=i)&&h.push(e[t])}));return s(h.length==l),h}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let r=0;for(let t=this.size-1;t>=1;t-=2){6==t&&(t=5);for(let s=0;s<this.size;s++)for(let o=0;o<2;o++){const a=t-o,l=!(t+1&2)?this.size-1-s:s;!this.isFunction[l][a]&&r<8*e.length&&(this.modules[l][a]=n(e[r>>>3],7-(7&r)),r++)}}s(r==8*e.length)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let t=0;t<this.size;t++)for(let r=0;r<this.size;r++){let n;switch(e){case 0:n=(r+t)%2==0;break;case 1:n=t%2==0;break;case 2:n=r%3==0;break;case 3:n=(r+t)%3==0;break;case 4:n=(Math.floor(r/3)+Math.floor(t/2))%2==0;break;case 5:n=r*t%2+r*t%3==0;break;case 6:n=(r*t%2+r*t%3)%2==0;break;case 7:n=((r+t)%2+r*t%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[t][r]&&n&&(this.modules[t][r]=!this.modules[t][r])}}getPenaltyScore(){let e=0;for(let s=0;s<this.size;s++){let r=!1,n=0,o=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[s][a]==r?(n++,5==n?e+=t.PENALTY_N1:n>5&&e++):(this.finderPenaltyAddHistory(n,o),r||(e+=this.finderPenaltyCountPatterns(o)*t.PENALTY_N3),r=this.modules[s][a],n=1);e+=this.finderPenaltyTerminateAndCount(r,n,o)*t.PENALTY_N3}for(let s=0;s<this.size;s++){let r=!1,n=0,o=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][s]==r?(n++,5==n?e+=t.PENALTY_N1:n>5&&e++):(this.finderPenaltyAddHistory(n,o),r||(e+=this.finderPenaltyCountPatterns(o)*t.PENALTY_N3),r=this.modules[a][s],n=1);e+=this.finderPenaltyTerminateAndCount(r,n,o)*t.PENALTY_N3}for(let s=0;s<this.size-1;s++)for(let r=0;r<this.size-1;r++){const n=this.modules[s][r];n==this.modules[s][r+1]&&n==this.modules[s+1][r]&&n==this.modules[s+1][r+1]&&(e+=t.PENALTY_N2)}let r=0;for(const t of this.modules)r=t.reduce(((e,t)=>e+(t?1:0)),r);const n=this.size*this.size,o=Math.ceil(Math.abs(20*r-10*n)/n)-1;return s(0<=o&&o<=9),e+=o*t.PENALTY_N4,s(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(1==this.version)return[];{const e=Math.floor(this.version/7)+2,t=32==this.version?26:2*Math.ceil((4*this.version+4)/(2*e-2));let r=[6];for(let n=this.size-7;r.length<e;n-=t)r.splice(1,0,n);return r}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version number out of range");let r=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;r-=(25*t-10)*t-55,e>=7&&(r-=36)}return s(208<=r&&r<=29648),r}static getNumDataCodewords(e,r){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let r=[];for(let t=0;t<e-1;t++)r.push(0);r.push(1);let n=1;for(let s=0;s<e;s++){for(let e=0;e<r.length;e++)r[e]=t.reedSolomonMultiply(r[e],n),e+1<r.length&&(r[e]^=r[e+1]);n=t.reedSolomonMultiply(n,2)}return r}static reedSolomonComputeRemainder(e,r){let n=r.map((e=>0));for(const s of e){const e=s^n.shift();n.push(0),r.forEach(((r,s)=>n[s]^=t.reedSolomonMultiply(r,e)))}return n}static reedSolomonMultiply(e,t){if(e>>>8!=0||t>>>8!=0)throw new RangeError("Byte out of range");let r=0;for(let n=7;n>=0;n--)r=r<<1^285*(r>>>7),r^=(t>>>n&1)*e;return s(r>>>8==0),r}finderPenaltyCountPatterns(e){const t=e[1];s(t<=3*this.size);const r=t>0&&e[2]==t&&e[3]==3*t&&e[4]==t&&e[5]==t;return(r&&e[0]>=4*t&&e[6]>=t?1:0)+(r&&e[6]>=4*t&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,r){return e&&(this.finderPenaltyAddHistory(t,r),t=0),t+=this.size,this.finderPenaltyAddHistory(t,r),this.finderPenaltyCountPatterns(r)}finderPenaltyAddHistory(e,t){0==t[0]&&(e+=this.size),t.pop(),t.unshift(e)}};function r(e,t,r){if(t<0||t>31||e>>>t!=0)throw new RangeError("Value out of range");for(let n=t-1;n>=0;n--)r.push(e>>>n&1)}function n(e,t){return!!(e>>>t&1)}function s(e){if(!e)throw new Error("Assertion error")}t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;const o=class e{constructor(e,t,r){if(this.mode=e,this.numChars=t,this.bitData=r,t<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}static makeBytes(t){let n=[];for(const e of t)r(e,8,n);return new e(e.Mode.BYTE,t.length,n)}static makeNumeric(t){if(!e.isNumeric(t))throw new RangeError("String contains non-numeric characters");let n=[];for(let e=0;e<t.length;){const s=Math.min(t.length-e,3);r(parseInt(t.substring(e,e+s),10),3*s+1,n),e+=s}return new e(e.Mode.NUMERIC,t.length,n)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n,s=[];for(n=0;n+2<=t.length;n+=2){let o=45*e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n));o+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n+1)),r(o,11,s)}return n<t.length&&r(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n)),6,s),new e(e.Mode.ALPHANUMERIC,t.length,s)}static makeSegments(t){return""==t?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let n=[];if(t<0)throw new RangeError("ECI assignment value out of range");if(t<128)r(t,8,n);else if(t<16384)r(2,2,n),r(t,14,n);else{if(!(t<1e6))throw new RangeError("ECI assignment value out of range");r(6,3,n),r(t,21,n)}return new e(e.Mode.ECI,0,n)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let r=0;for(const n of e){const e=n.mode.numCharCountBits(t);if(n.numChars>=1<<e)return 1/0;r+=4+e+n.bitData.length}return r}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let r=0;r<e.length;r++)"%"!=e.charAt(r)?t.push(e.charCodeAt(r)):(t.push(parseInt(e.substring(r+1,r+3),16)),r+=2);return t}};o.NUMERIC_REGEX=/^[0-9]*$/,o.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,o.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let a=o;e.QrSegment=o})(K||(K={})),(e=>{const t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})((_=K||(K={})).QrCode||(_.QrCode={})),(e=>{(e=>{const t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||(e.QrSegment={}))})(K||(K={}));var te=K,re={L:te.QrCode.Ecc.LOW,M:te.QrCode.Ecc.MEDIUM,Q:te.QrCode.Ecc.QUARTILE,H:te.QrCode.Ecc.HIGH},ne=128,se="L",oe="#FFFFFF",ae="#000000",le=!1,ie=1;
2
2
  /**
3
3
  * @license qrcode.react
4
4
  * Copyright (c) Paul O'Shannessy
5
5
  * SPDX-License-Identifier: ISC
6
- */function de(e,t=0){const r=[];return e.forEach((function(e,n){let s=null;e.forEach((function(o,a){if(!o&&null!==s)return r.push(`M${s+t} ${n+t}h${a-s}v1H${s+t}z`),void(s=null);if(a!==e.length-1)o&&null===s&&(s=a);else{if(!o)return;null===s?r.push(`M${a+t},${n+t} h1v1H${a+t}z`):r.push(`M${s+t},${n+t} h${a+1-s}v1H${s+t}z`)}}))})),r.join("")}function ue(e,t){return e.slice().map(((e,r)=>r<t.y||r>=t.y+t.h?e:e.map(((e,r)=>(r<t.x||r>=t.x+t.w)&&e))))}function he({value:e,level:r,minVersion:n,includeMargin:s,marginSize:o,imageSettings:a,size:l,boostLevel:i}){let c=t.useMemo((()=>{const t=(Array.isArray(e)?e:[e]).reduce(((e,t)=>(e.push(...re.QrSegment.makeSegments(t)),e)),[]);return re.QrCode.encodeSegments(t,ne[r],n,void 0,void 0,i)}),[e,r,n,i]);const{cells:d,margin:u,numCells:h,calculatedImageSettings:m}=t.useMemo((()=>{let e=c.getModules();const t=function(e,t){return null!=t?Math.max(Math.floor(t),0):e?4:0}(s,o),r=e.length+2*t,n=function(e,t,r,n){if(null==n)return null;const s=e.length+2*r,o=Math.floor(.1*t),a=s/t,l=(n.width||o)*a,i=(n.height||o)*a,c=null==n.x?e.length/2-l/2:n.x*a,d=null==n.y?e.length/2-i/2:n.y*a,u=null==n.opacity?1:n.opacity;let h=null;if(n.excavate){let e=Math.floor(c),t=Math.floor(d);h={x:e,y:t,w:Math.ceil(l+c-e),h:Math.ceil(i+d-t)}}return{x:c,y:d,h:i,w:l,excavation:h,opacity:u,crossOrigin:n.crossOrigin}}(e,l,t,a);return{cells:e,margin:t,numCells:r,calculatedImageSettings:n}}),[c,l,a,s,o]);return{qrcode:c,margin:u,cells:d,numCells:h,calculatedImageSettings:m}}var me=function(){try{(new Path2D).addPath(new Path2D)}catch(e){return!1}return!0}();t.forwardRef((function(e,r){const n=e,{value:s,size:o=se,level:a=oe,bgColor:l=ae,fgColor:i=le,includeMargin:c=ie,minVersion:d=ce,boostLevel:u,marginSize:h,imageSettings:m}=n,g=te(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:p}=g,w=te(g,["style"]),f=null==m?void 0:m.src,y=t.useRef(null),x=t.useRef(null),b=t.useCallback((e=>{y.current=e,"function"==typeof r?r(e):r&&(r.current=e)}),[r]),[N,E]=t.useState(!1),{margin:k,cells:v,numCells:A,calculatedImageSettings:S}=he({value:s,level:a,minVersion:d,boostLevel:u,includeMargin:c,marginSize:h,imageSettings:m,size:o});t.useEffect((()=>{if(null!=y.current){const e=y.current,t=e.getContext("2d");if(!t)return;let r=v;const n=x.current,s=null!=S&&null!==n&&n.complete&&0!==n.naturalHeight&&0!==n.naturalWidth;s&&null!=S.excavation&&(r=ue(v,S.excavation));const a=window.devicePixelRatio||1;e.height=e.width=o*a;const c=o/A*a;t.scale(c,c),t.fillStyle=l,t.fillRect(0,0,A,A),t.fillStyle=i,me?t.fill(new Path2D(de(r,k))):v.forEach((function(e,r){e.forEach((function(e,n){e&&t.fillRect(n+k,r+k,1,1)}))})),S&&(t.globalAlpha=S.opacity),s&&t.drawImage(n,S.x+k,S.y+k,S.w,S.h)}})),t.useEffect((()=>{E(!1)}),[f]);const T=ee({height:o,width:o},p);let C=null;return null!=f&&(C=t.createElement("img",{src:f,key:f,style:{display:"none"},onLoad:()=>{E(!0)},ref:x,crossOrigin:null==S?void 0:S.crossOrigin})),t.createElement(t.Fragment,null,t.createElement("canvas",ee({style:T,height:o,width:o,ref:b,role:"img"},w)),C)})).displayName="QRCodeCanvas";var ge=t.forwardRef((function(e,r){const n=e,{value:s,size:o=se,level:a=oe,bgColor:l=ae,fgColor:i=le,includeMargin:c=ie,minVersion:d=ce,boostLevel:u,title:h,marginSize:m,imageSettings:g}=n,p=te(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:w,cells:f,numCells:y,calculatedImageSettings:x}=he({value:s,level:a,minVersion:d,boostLevel:u,includeMargin:c,marginSize:m,imageSettings:g,size:o});let b=f,N=null;null!=g&&null!=x&&(null!=x.excavation&&(b=ue(f,x.excavation)),N=t.createElement("image",{href:g.src,height:x.h,width:x.w,x:x.x+w,y:x.y+w,preserveAspectRatio:"none",opacity:x.opacity,crossOrigin:x.crossOrigin}));const E=de(b,w);return t.createElement("svg",ee({height:o,width:o,viewBox:`0 0 ${y} ${y}`,ref:r,role:"img"},p),!!h&&t.createElement("title",null,h),t.createElement("path",{fill:l,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),t.createElement("path",{fill:i,d:E,shapeRendering:"crispEdges"}),N)}));ge.displayName="QRCodeSVG";const pe=({walletAddress:e,amount:r,currency:n,network:s,theme:o="light",size:a=200})=>{const[l,i]=t.useState(""),[c,d]=t.useState(null);t.useEffect((()=>{if(e&&"No address configured"!==e)try{let t;switch(s){case"tron":t="TRX"===n?`tronlink://transfer?to=${e}&amount=${r}`:e;break;case"algorand":t=`algorand://${e}?amount=${Math.floor(1e6*parseFloat(r))}`;break;case"bsc":if("BNB"===n)t=`ethereum:${e}@56?value=${m(r)}`;else{const s=u(n,"bsc");t=s?`ethereum:${s}/transfer?address=${e}&uint256=${h(r,n)}@56`:e}break;default:if("ETH"===n)t=`ethereum:${e}@1?value=${m(r)}`;else{const s=u(n,"ethereum");t=s?`ethereum:${s}/transfer?address=${e}&uint256=${h(r,n)}`:e}}i(t),d(null)}catch(t){console.error("Error generating QR code:",t),d("Error generating payment QR code")}else d("No wallet address configured for this network")}),[e,r,n,s]);const u=(e,t)=>{var r;return(null==(r={ethereum:{USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},bsc:{USDT:"0x55d398326f99059fF775485246999027B3197955",USDC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},tron:{USDT:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",USDC:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8"}}[t])?void 0:r[e])||""},h=(e,t)=>{const r="USDT"===t||"USDC"===t?6:18;return Math.floor(parseFloat(e)*Math.pow(10,r)).toString()},m=e=>Math.floor(1e18*parseFloat(e)).toString(),g=e=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[e]||e);return Q.jsxs("div",{className:"flex flex-col items-center",children:[c?Q.jsxs("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center",children:[Q.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:Q.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"})}),Q.jsx("p",{className:"font-medium",children:c})]}):Q.jsx("div",{className:"p-4 rounded-lg bg-white mb-3 shadow-sm border",children:l&&Q.jsx(ge,{value:l,size:a,bgColor:"dark"===o?"#374151":"#FFFFFF",fgColor:"dark"===o?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),Q.jsxs("div",{className:"text-center text-sm text-gray-700 mb-4",children:[Q.jsxs("p",{className:"font-semibold text-gray-800 flex items-center justify-center",children:[Q.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:Q.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 ",n]}),Q.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Scan with your ",g(s)," wallet app"]})]}),Q.jsxs("div",{className:"w-full mb-4 p-3 bg-gray-50 rounded-lg",children:[Q.jsxs("div",{className:"flex justify-between items-center",children:[Q.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Amount to Pay:"}),Q.jsxs("span",{className:"text-lg font-bold text-[#7042D2]",children:[r," ",n]})]}),Q.jsxs("div",{className:"flex justify-between items-center mt-1",children:[Q.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),Q.jsx("span",{className:"text-xs font-medium text-gray-700",children:g(s)})]})]}),!c&&Q.jsxs("div",{className:"w-full mb-4",children:[Q.jsx("p",{className:"text-xs text-gray-500 mb-1 text-center",children:"Or copy wallet address:"}),Q.jsx("div",{className:"text-xs font-mono p-2 rounded bg-gray-100 text-gray-700 break-all text-center select-all cursor-pointer border",onClick:()=>{var t;return null==(t=navigator.clipboard)?void 0:t.writeText(e)},title:"Click to copy",children:e})]}),Q.jsx("div",{className:"w-full",children:Q.jsxs("div",{className:"p-3 rounded bg-blue-50 border border-blue-200",children:[Q.jsxs("h4",{className:"text-sm font-medium mb-2 text-blue-800 flex items-center",children:[Q.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:Q.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"]}),Q.jsxs("ol",{className:"text-xs space-y-1 text-blue-700",children:[Q.jsxs("li",{children:["1. Open your crypto wallet app (",(p=s,{ethereum:["MetaMask","Trust Wallet","Coinbase Wallet"],bsc:["MetaMask","Trust Wallet","SafePal"],tron:["TronLink","Trust Wallet"],algorand:["Pera Wallet","MyAlgo Wallet"]}[p]||["MetaMask","Trust Wallet"]).join(", "),")"]}),Q.jsx("li",{children:"2. Scan the QR code above or copy the wallet address"}),Q.jsxs("li",{children:["3. Send exactly ",Q.jsxs("strong",{children:[r," ",n]})," on ",g(s)," network"]}),Q.jsx("li",{children:'4. Click "I have sent the payment" button below after sending'})]}),Q.jsx("div",{className:"mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded",children:Q.jsxs("p",{className:"text-xs text-yellow-800",children:[Q.jsx("strong",{children:"Important:"})," Make sure you're sending on the correct network (",g(s),") and using the exact amount shown above."]})})]})})]});var p},we=({status:e,message:t,theme:r="light"})=>Q.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Q.jsx("div",{className:"mb-4",children:(()=>{switch(e){case"processing":return Q.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return Q.jsx("div",{className:"rounded-full h-12 w-12 bg-green-100 flex items-center justify-center",children:Q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Q.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return Q.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:Q.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:Q.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}})()}),Q.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"text-white":"text-gray-900"),children:(()=>{switch(e){case"processing":return"Processing Payment";case"success":return"Payment Successful";case"error":return"Payment Failed";default:return"Unknown Status"}})()}),Q.jsx("p",{className:`text-center ${(()=>{switch(e){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"}})()}`,children:t}),"processing"===e&&Q.jsx("div",{className:"mt-4 text-xs "+("dark"===r?"text-gray-400":"text-gray-500"),children:"This may take a few moments. Please do not close this window."}),"success"===e&&Q.jsx("div",{className:"mt-4 p-2 rounded "+("dark"===r?"bg-gray-700":"bg-gray-100"),children:Q.jsx("p",{className:"text-xs "+("dark"===r?"text-gray-300":"text-gray-600"),children:"Your payment has been successfully processed. You will receive a confirmation shortly."})})]}),fe=({onSelect:e,selected:r,theme:n="light",supportedNetworks:s=[]})=>{const[o,a]=t.useState(u.ETHEREUM),[l,i]=t.useState({}),[c,d]=t.useState(!1);t.useEffect((()=>{i(f())}),[]);const h=[{id:u.ETHEREUM,name:"Ethereum",description:"ERC-20 tokens"},{id:u.BSC,name:"BSC (Binance Smart Chain)",description:"BEP-20 tokens"},{id:u.TRON,name:"Tron",description:"TRC-20 tokens"},{id:u.ALGORAND,name:"Algorand",description:"ASA tokens"}],m=(e=>{const t=[];switch(e){case u.ETHEREUM:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:u.ETHEREUM},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:u.ETHEREUM},{id:"PYUSD",name:"PYUSD",description:"PayPal USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/28492.png",network:u.ETHEREUM},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:u.ETHEREUM},{id:"USDP",name:"USDP",description:"Pax Dollar",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6662.png",network:u.ETHEREUM},{id:"DAI",name:"DAI",description:"Dai Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4943.png",network:u.ETHEREUM},{id:"ETH",name:"ETH",description:"Ethereum",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcyJyRKN0dRJWVZqoLzYgkRHdJsxKGq8nHUw&s",network:u.ETHEREUM});break;case u.BSC:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:u.BSC},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:u.BSC},{id:"BUSD",name:"BUSD",description:"Binance USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4687.png",network:u.BSC},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:u.BSC},{id:"BNB",name:"BNB",description:"Binance Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s",network:u.BSC});break;case u.TRON:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:u.TRON},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:u.TRON},{id:"USDJ",name:"USDJ",description:"JUST Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5446.png",network:u.TRON},{id:"TRX",name:"TRX",description:"Tron",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",network:u.TRON});break;case u.ALGORAND:t.push({id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:u.ALGORAND},{id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:u.ALGORAND},{id:"ALGO",name:"ALGO",description:"Algorand",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",network:u.ALGORAND})}return t})(o),p=c?m:m.slice(0,4);return Q.jsxs("div",{children:[Q.jsx("h3",{className:"text-lg font-medium mb-4 "+("dark"===n?"text-white":"text-gray-800"),children:"Select Payment Method"}),Q.jsxs("div",{className:"mb-6",children:[Q.jsx("label",{className:"block text-sm font-medium mb-2 "+("dark"===n?"text-white":"text-gray-700"),children:"Blockchain Network"}),Q.jsx("select",{value:o,onChange:t=>{return n=t.target.value,a(n),d(!1),void((null==r?void 0:r.network)!==n&&e(null));var n},className:`w-full p-3 rounded-lg border transition-colors ${"dark"===n?"bg-gray-700 border-gray-600 text-white focus:border-[#7042D2]":"bg-white border-gray-300 text-gray-900 focus:border-[#7042D2]"} focus:outline-none focus:ring-2 focus:ring-[#7042D2] focus:ring-opacity-50`,children:h.filter((e=>0===s.length||s.includes(e.id))).map((e=>Q.jsxs("option",{value:e.id,children:[e.name," - ",e.description]},e.id)))})]}),Q.jsxs("div",{className:"mb-4",children:[Q.jsx("label",{className:"block text-sm font-medium mb-3 "+("dark"===n?"text-white":"text-gray-700"),children:"Choose Cryptocurrency"}),Q.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:p.map((t=>Q.jsx("button",{onClick:()=>(t=>{var r;e({currency:t.id,network:o,tokenConfig:null==(r=g[t.id])?void 0:r[o],method:t})})(t),className:"p-4 rounded-lg transition-all duration-200 border-2 "+((null==r?void 0:r.currency)===t.id&&(null==r?void 0:r.network)===o?"dark"===n?"bg-blue-900/30 border-[#7042D2] ring-2 ring-[#7042D2] ring-opacity-50":"bg-blue-50 border-[#7042D2] ring-2 ring-[#7042D2] ring-opacity-50":"dark"===n?"bg-gray-700 hover:bg-gray-600 border-gray-600 hover:border-gray-500":"bg-white hover:bg-gray-50 border-gray-200 hover:border-gray-300"),children:Q.jsxs("div",{className:"flex flex-col items-center text-center",children:[Q.jsx("div",{className:"flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mb-2 shadow-sm",children:Q.jsx("img",{src:t.logo,alt:t.name,className:"h-6 w-6"})}),Q.jsxs("div",{children:[Q.jsx("h4",{className:"font-medium text-sm "+("dark"===n?"text-white":"text-gray-900"),children:t.name}),Q.jsx("p",{className:"text-xs "+("dark"===n?"text-gray-300":"text-gray-500"),children:t.description})]}),(null==r?void 0:r.currency)===t.id&&(null==r?void 0:r.network)===o&&Q.jsx("div",{className:"mt-2",children:Q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-[#7042D2]",viewBox:"0 0 20 20",fill:"currentColor",children:Q.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})})]})},`${t.id}-${t.network}`)))}),m.length>4&&Q.jsx("button",{onClick:()=>d(!c),className:"w-full py-2 px-4 rounded-lg text-sm font-medium transition-colors "+("dark"===n?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:c?"Show Less":`Show More (${m.length-4} more)`})]}),Q.jsx("div",{className:"p-3 rounded-lg text-sm "+("dark"===n?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:Q.jsxs("div",{className:"flex items-center",children:[Q.jsx("div",{className:"w-2 h-2 rounded-full mr-2 "+(l[w(o)]?"bg-green-500":"bg-red-500")}),Q.jsx("span",{className:"text-xs",children:function(e){const t=w(e),r=l[t],n={metamask:"MetaMask",tronlink:"TronLink",lute:"Lute Wallet"};return r?`${n[t]} detected - Ready to pay`:`${n[t]} required - Please install to continue`}(o)})]})})]});function w(e){switch(e){case u.ETHEREUM:case u.BSC:return"metamask";case u.TRON:return"tronlink";case u.ALGORAND:return"lute";default:return"metamask"}}},ye=({isOpen:e,onClose:r,payment:n,paymentStatus:s,selectedPaymentMethod:o,onPaymentMethodSelect:a,onPayment:l,onBack:i,error:c,theme:d="light",merchantName:u,transactionHash:m,walletConnection:g,onConnectWallet:p,testMode:w=!1,supportedNetworks:f=[],availableWallets:y={},supportedWallets:x=[],step:b="select-currency",merchantWalletAddresses:N={}})=>{const[E,k]=t.useState("wallet"),v=e=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[e]||e),A=e=>({[h.METAMASK]:"MetaMask",[h.TRONLINK]:"TronLink",[h.TRUST_WALLET]:"Trust Wallet",[h.LUTE]:"Lute Wallet"}[e]||e),S=e=>({[h.METAMASK]:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",[h.TRONLINK]:"https://www.tronlink.org/images/logo.png",[h.TRUST_WALLET]:"https://trustwallet.com/assets/images/trust_logotype.svg",[h.LUTE]:"https://lute.app/logo.png"}[e]||"");return e?Q.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-black/50",children:Q.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:Q.jsxs("div",{className:"relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl bg-white text-gray-800",children:[Q.jsxs("div",{className:"flex justify-between items-center mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[Q.jsx("div",{className:"flex items-center",children:Q.jsx("h2",{className:"text-xl font-bold text-gray-900",children:Q.jsx("img",{src:"data:image/png;base64,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",className:"w-32",alt:"Coinley Logo"})})}),Q.jsx("button",{onClick:r,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:Q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Q.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),Q.jsxs("div",{className:"mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[n&&Q.jsxs("div",{className:"mb-6 p-4 rounded-lg",children:[Q.jsxs("p",{className:"text-lg text-gray-800 font-semibold",children:["PAY: ",u]}),Q.jsxs("div",{className:"flex justify-between items-center mt-2 bg-gray-100 px-3 rounded-lg",children:[Q.jsx("span",{className:"font-medium text-gray-700",children:"Amount:"}),Q.jsxs("span",{className:"font-bold text-xl text-[#7042D2]",children:["$",(C=n.totalAmount||n.amount,parseFloat(C).toFixed(2))]})]}),Q.jsx("div",{className:"text-xs mt-1 text-right",children:Q.jsxs("span",{className:"text-gray-500",children:["Payment ID: ",n.id?n.id.slice(0,8):"","..."]})})]}),"select-currency"===b&&Q.jsxs("div",{children:[Q.jsx(fe,{onSelect:a,selected:o,theme:d,supportedNetworks:f}),o&&Q.jsx("div",{className:"mt-6",children:Q.jsxs("button",{onClick:()=>a(o),className:"w-full py-3 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-lg transition-colors",children:["Proceed with ",o.currency," on ",v(o.network)]})})]}),"confirm"===b&&o&&n&&Q.jsxs("div",{children:[Q.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[Q.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),Q.jsxs("div",{className:"space-y-2",children:[Q.jsxs("div",{className:"flex justify-between",children:[Q.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Currency:"}),Q.jsx("span",{className:"font-medium",children:o.currency})]}),Q.jsxs("div",{className:"flex justify-between",children:[Q.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Network:"}),Q.jsx("span",{className:"font-medium",children:v(o.network)})]}),Q.jsxs("div",{className:"flex justify-between",children:[Q.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Fee:"}),Q.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),Q.jsx("div",{className:"mb-4",children:Q.jsxs("div",{className:"flex border-b border-gray-200",children:[Q.jsx("button",{onClick:()=>k("wallet"),className:"py-2 px-4 text-sm font-medium "+("wallet"===E?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),children:"Connect Wallet"}),Q.jsx("button",{onClick:()=>k("qrcode"),className:"py-2 px-4 text-sm font-medium "+("qrcode"===E?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),children:"QR Code"})]})}),w?Q.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:Q.jsxs("div",{className:"flex items-center",children:[Q.jsx("div",{className:"bg-[#7042D2] rounded-full p-2 mr-3",children:Q.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:Q.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),Q.jsxs("div",{children:[Q.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),Q.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):"qrcode"===E?Q.jsx("div",{className:"mb-4",children:Q.jsx(pe,{walletAddress:(()=>{if(!o)return"No network selected";const e=N[o.network];return e||((null==n?void 0:n.recipientWallet)?n.recipientWallet:"No wallet address configured for this network")})(),amount:n.totalAmount||n.amount,currency:o.currency,network:o.network,theme:d})}):Q.jsxs("div",{className:"space-y-3 mb-4",children:[0===x.length?Q.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:Q.jsxs("div",{className:"flex items-center",children:[Q.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:Q.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"})}),Q.jsxs("div",{children:[Q.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),Q.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",v(o.network)," network"]})]})]})}):x.map((e=>Q.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:Q.jsxs("div",{className:"flex items-center justify-between",children:[Q.jsxs("div",{className:"flex items-center",children:[Q.jsx("img",{src:S(e),alt:A(e),className:"w-8 h-8 mr-3",onError:e=>{e.target.style.display="none"}}),Q.jsxs("div",{children:[Q.jsx("h3",{className:"font-medium text-gray-800",children:A(e)}),Q.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",A(e)]})]})]}),(null==g?void 0:g.walletType)===e?Q.jsxs("div",{className:"flex items-center space-x-2",children:[Q.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),Q.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):Q.jsx("button",{onClick:()=>p(e),className:"py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md text-sm",children:"Connect"})]})},e))),Q.jsx("div",{className:"space-y-2",children:Object.entries(y).filter((([e,t])=>!t)).map((([e])=>Q.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:Q.jsxs("div",{className:"flex items-center justify-between",children:[Q.jsxs("span",{className:"text-sm text-gray-600",children:[A(e)," not detected"]}),Q.jsx("a",{href:j(e),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#7042D2] hover:underline",children:"Install"})]})},e)))})]}),Q.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[Q.jsx("button",{type:"button",onClick:i,className:"w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-medium rounded-md",children:"Back"}),Q.jsx("button",{type:"button",onClick:()=>l("qrcode"===E),className:"w-full py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",disabled:!w&&"wallet"===E&&!g,children:"qrcode"===E?"I have sent the payment":"Pay Now"})]})]}),"processing"===b&&Q.jsx(we,{status:"processing",theme:d,message:"Processing your payment..."}),"success"===b&&Q.jsxs("div",{children:[Q.jsx(we,{status:"success",theme:d,message:"Payment successful!"}),m&&Q.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-gray-100",children:[Q.jsx("p",{className:"text-xs text-gray-600 mb-1",children:"Transaction Hash:"}),Q.jsx("p",{className:"text-sm font-mono break-all text-gray-800",children:(T=m,T?T.length<=14?T:`${T.slice(0,8)}...${T.slice(-6)}`:"")}),o&&Q.jsx("a",{href:`${xe(o.network)}/${be(o.network)}/${m}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#7042D2] mt-2 inline-block",children:"View on Explorer →"})]})]}),"error"===b&&Q.jsxs("div",{children:[Q.jsx(we,{status:"error",theme:d,message:c||"An error occurred while processing your payment."}),Q.jsx("button",{type:"button",onClick:i,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"})]})]}),Q.jsx("div",{className:"text-center text-xs text-gray-500",children:Q.jsxs("p",{children:["Powered by ",Q.jsx("span",{className:"text-[#7042D2]",children:"Coinley"})," - Secure Cryptocurrency Payments"]})})]})})}):null;var T,C},xe=e=>({ethereum:"https://etherscan.io",bsc:"https://bscscan.com",tron:"https://tronscan.org",algorand:"https://algoexplorer.io"}[e]||"https://etherscan.io"),be=e=>({ethereum:"tx",bsc:"tx",tron:"transaction",algorand:"tx"}[e]||"tx"),Ne=t.forwardRef((({apiKey:e,apiSecret:r,apiUrl:n,customerEmail:s,merchantName:o="Merchant",merchantWalletAddresses:a={},onSuccess:l,onError:i,onClose:m,theme:g,autoOpen:p=!1,debug:w=!1,testMode:b=!1,supportedNetworks:N=[],preferredNetwork:E=u.ETHEREUM,preferredWallet:k=h.METAMASK},v)=>{const S=K(),{theme:T}=t.useContext(q),[C,j]=t.useState(p),[M,R]=t.useState(null),[U,P]=t.useState("idle"),[O,F]=t.useState(null),[W,B]=t.useState(null),[I,z]=t.useState(null),[H,G]=t.useState(null),[_,V]=t.useState({}),[J,$]=t.useState("select-currency");e||null==S||S.apiKey,r||null==S||S.apiSecret,n||null==S||S.apiUrl;const Y=g||T,X=w||(null==S?void 0:S.debug),Z=N.length>0?N:[u.ETHEREUM,u.BSC,u.TRON,u.ALGORAND];t.useImperativeHandle(v,(()=>({open:e=>{te(e)},close:()=>{re()},getPayment:()=>M,getWalletConnection:()=>H})));const ee=(e,t)=>{X&&console.log(`[Coinley SDK] ${e}`,t)};t.useEffect((()=>{if("undefined"!=typeof window){const e=f();V(e),ee("Available wallets detected:",e)}}),[X]);const te=e=>d(this,null,(function*(){if(!e||!e.amount)return B("Payment amount is required"),void(i&&i(new Error("Payment amount is required")));P("loading"),j(!0),$("select-currency");try{ee("Creating payment with details:",e);const t=yield L({amount:e.amount,currency:e.currency||"USDT",network:e.network||E,customerEmail:e.customerEmail||s,callbackUrl:e.callbackUrl,metadata:e.metadata||{},merchantWalletAddresses:c(c({},a),e.merchantWalletAddresses)});ee("Payment created:",t),R(t.payment),P("idle"),B(null),ee("Payment created and state updated")}catch(t){ee("Error creating payment:",t),B(t.message||"Failed to create payment"),P("error"),i&&i(t)}})),re=()=>{j(!1),z(null),G(null),F(null),$("select-currency"),m&&m()};return Q.jsx(Q.Fragment,{children:C&&Q.jsx(ye,{isOpen:C,onClose:re,payment:M,paymentStatus:U,selectedPaymentMethod:O,onPaymentMethodSelect:e=>{ee("Payment method selected:",e),F(e),$("confirm")},onPayment:()=>d(this,null,(function*(){var e,t;if(M&&O)if(H||b){ee("Starting payment process..."),P("loading"),z(null);try{let r;if(b)ee("Test mode: Generating mock transaction..."),r=`test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`;else{const n=a[O.network];if(!n)throw new Error(`No merchant wallet address configured for ${O.network}`);ee("Sending transaction through wallet..."),r=yield A(H,{to:n,amount:M.amount,tokenAddress:null==(e=O.tokenConfig)?void 0:e.address,tokenDecimals:null==(t=O.tokenConfig)?void 0:t.decimals})}ee("Transaction hash:",r),z(r),ee("Processing payment with backend...");const n=yield D({paymentId:M.id,transactionHash:r,network:O.network,currency:O.currency,senderAddress:null==H?void 0:H.address});ee("Payment processed successfully:",n),P("success"),$("success"),l&&(ee("Calling onSuccess callback..."),l(M.id,r,{network:O.network,currency:O.currency,amount:M.amount}))}catch(r){ee("Payment error:",r),B(r.message||"Failed to process payment"),P("error"),$("error"),i&&i(r)}}else B("Please connect your wallet first");else B("Missing payment information")})),onBack:()=>{"confirm"===J&&($("select-currency"),G(null))},error:W,theme:Y,merchantName:o,transactionHash:I,walletConnection:H,onConnectWallet:e=>d(this,null,(function*(){if(O)try{ee("Connecting wallet:",{walletType:e,network:O.network});const t=yield x(e,O.network);G(t),B(null),ee("Wallet connected successfully:",t)}catch(t){ee("Wallet connection error:",t),B(t.message||"Failed to connect wallet")}else B("Please select a payment method first")})),testMode:b,supportedNetworks:Z,availableWallets:_,supportedWallets:O?y(O.network):[],step:J,merchantWalletAddresses:a})})}));Ne.displayName="CoinleyCheckout";e.CoinleyCheckout=Ne,e.CoinleyModal=ye,e.CoinleyProvider=({apiKey:e,apiSecret:r,apiUrl:n="http://localhost:9000",merchantWalletAddress:s=null,merchantSolWalletAddress:o=null,debug:a=!1,children:l})=>{const[i,d]=t.useState(!1),[u,h]=t.useState(null),[m,g]=t.useState(null);t.useEffect((()=>{var t;if(e&&r)try{t={apiKey:e,apiSecret:r,apiUrl:n,merchantWalletAddress:s,merchantSolWalletAddress:o},M=c(c({},M),t),console.log("API initialized with:",{apiUrl:M.apiUrl,apiKey:M.apiKey?`${M.apiKey.substring(0,6)}...`:null,hasWalletAddresses:Object.keys(M.merchantWalletAddresses||{}).length>0}),d(!0),a&&console.log("Coinley SDK initialized with:",{apiKey:e,apiUrl:n,merchantWalletAddress:s?`${s.substring(0,6)}...${s.substring(s.length-4)}`:"Not provided",merchantSolWalletAddress:o?`${o.substring(0,6)}...${o.substring(o.length-4)}`:"Not provided"})}catch(l){h(l.message),a&&console.error("Coinley SDK initialization error:",l)}else h("API key and secret are required")}),[e,r,n,s,o,a]);const p={apiKey:e,apiSecret:r,apiUrl:n,merchantWalletAddress:s,merchantSolWalletAddress:o,isInitialized:i,error:u,debug:a,paymentData:m,storePaymentData:e=>(g(e),e)};return Q.jsx(G.Provider,{value:p,children:l})},e.DEFAULT_CONFIG={apiUrl:"http://localhost:9000",debug:!1,testMode:!1,theme:"light",supportedNetworks:["ethereum","bsc","tron","algorand"]},e.NETWORK_CONFIG=m,e.NETWORK_TYPES=u,e.PaymentMethods=fe,e.PaymentStatus=we,e.QRCode=pe,e.TOKEN_CONFIG=g,e.ThemeProvider=({initialTheme:e="light",children:r})=>{const[n,s]=t.useState(e);return t.useEffect((()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(n)}),[n]),Q.jsx(q.Provider,{value:{theme:n,setTheme:s,toggleTheme:()=>{s((e=>"light"===e?"dark":"light"))}},children:r})},e.WALLET_TYPES=h,e.connectWallet=x,e.createPayment=L,e.detectWallets=f,e.generateMockTransactionHash=(e="ethereum")=>`${{ethereum:"0x",bsc:"0x",tron:"",algorand:""}[e]||"0x"}${Array.from({length:64},(()=>Math.floor(16*Math.random()).toString(16))).join("")}`,e.getMerchantProfile=()=>d(this,null,(function*(){try{const e=yield fetch(`${M.apiUrl}/api/merchants/profile`,{method:"GET",headers:R()});if(!e.ok){const t=yield e.json();throw new Error(t.error||`Failed to get merchant profile: ${e.status}`)}const t=yield e.json();return t.merchant&&t.merchant.walletAddresses&&(M.merchantWalletAddresses=c(c({},M.merchantWalletAddresses),t.merchant.walletAddresses)),t}catch(e){throw console.error("Get merchant profile error:",e),e}})),e.getPayment=e=>d(this,null,(function*(){try{console.log("Getting payment:",e);const t=yield fetch(`${M.apiUrl}/api/payments/${e}`,{method:"GET",headers:R()});if(!t.ok){const e=yield t.json();throw console.error("Error getting payment:",e),new Error(e.error||`Failed to get payment: ${t.status}`)}const r=yield t.json();return console.log("Get payment response:",r),r}catch(t){throw console.error("Get payment error:",t),t}})),e.getSupportedNetworks=()=>d(this,null,(function*(){try{const e=yield fetch(`${M.apiUrl}/api/networks`,{method:"GET",headers:R()});if(!e.ok){const t=yield e.json();throw new Error(t.error||`Failed to get networks: ${e.status}`)}return yield e.json()}catch(e){throw console.error("Get supported networks error:",e),e}})),e.getSupportedWalletsForNetwork=y,e.getWalletInstallUrl=j,e.processPayment=D,e.sendTransaction=A,e.useCoinley=K,e.validateWalletAddress=(e,t)=>d(this,null,(function*(){try{const r=yield fetch(`${M.apiUrl}/api/wallets/validate`,{method:"POST",headers:R(),body:JSON.stringify({address:e,network:t})});if(!r.ok){const e=yield r.json();throw new Error(e.error||`Failed to validate address: ${r.status}`)}return yield r.json()}catch(r){throw console.error("Validate wallet address error:",r),r}})),Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
6
+ */function ce(e,t=0){const r=[];return e.forEach((function(e,n){let s=null;e.forEach((function(o,a){if(!o&&null!==s)return r.push(`M${s+t} ${n+t}h${a-s}v1H${s+t}z`),void(s=null);if(a!==e.length-1)o&&null===s&&(s=a);else{if(!o)return;null===s?r.push(`M${a+t},${n+t} h1v1H${a+t}z`):r.push(`M${s+t},${n+t} h${a+1-s}v1H${s+t}z`)}}))})),r.join("")}function de(e,t){return e.slice().map(((e,r)=>r<t.y||r>=t.y+t.h?e:e.map(((e,r)=>(r<t.x||r>=t.x+t.w)&&e))))}function ue({value:e,level:r,minVersion:n,includeMargin:s,marginSize:o,imageSettings:a,size:l,boostLevel:i}){let c=t.useMemo((()=>{const t=(Array.isArray(e)?e:[e]).reduce(((e,t)=>(e.push(...te.QrSegment.makeSegments(t)),e)),[]);return te.QrCode.encodeSegments(t,re[r],n,void 0,void 0,i)}),[e,r,n,i]);const{cells:d,margin:u,numCells:h,calculatedImageSettings:m}=t.useMemo((()=>{let e=c.getModules();const t=function(e,t){return null!=t?Math.max(Math.floor(t),0):e?4:0}(s,o),r=e.length+2*t,n=function(e,t,r,n){if(null==n)return null;const s=e.length+2*r,o=Math.floor(.1*t),a=s/t,l=(n.width||o)*a,i=(n.height||o)*a,c=null==n.x?e.length/2-l/2:n.x*a,d=null==n.y?e.length/2-i/2:n.y*a,u=null==n.opacity?1:n.opacity;let h=null;if(n.excavate){let e=Math.floor(c),t=Math.floor(d);h={x:e,y:t,w:Math.ceil(l+c-e),h:Math.ceil(i+d-t)}}return{x:c,y:d,h:i,w:l,excavation:h,opacity:u,crossOrigin:n.crossOrigin}}(e,l,t,a);return{cells:e,margin:t,numCells:r,calculatedImageSettings:n}}),[c,l,a,s,o]);return{qrcode:c,margin:u,cells:d,numCells:h,calculatedImageSettings:m}}var he=function(){try{(new Path2D).addPath(new Path2D)}catch(e){return!1}return!0}();t.forwardRef((function(e,r){const n=e,{value:s,size:o=ne,level:a=se,bgColor:l=oe,fgColor:i=ae,includeMargin:c=le,minVersion:d=ie,boostLevel:u,marginSize:h,imageSettings:m}=n,g=ee(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:p}=g,w=ee(g,["style"]),f=null==m?void 0:m.src,y=t.useRef(null),x=t.useRef(null),b=t.useCallback((e=>{y.current=e,"function"==typeof r?r(e):r&&(r.current=e)}),[r]),[N,E]=t.useState(!1),{margin:k,cells:A,numCells:v,calculatedImageSettings:T}=ue({value:s,level:a,minVersion:d,boostLevel:u,includeMargin:c,marginSize:h,imageSettings:m,size:o});t.useEffect((()=>{if(null!=y.current){const e=y.current,t=e.getContext("2d");if(!t)return;let r=A;const n=x.current,s=null!=T&&null!==n&&n.complete&&0!==n.naturalHeight&&0!==n.naturalWidth;s&&null!=T.excavation&&(r=de(A,T.excavation));const a=window.devicePixelRatio||1;e.height=e.width=o*a;const c=o/v*a;t.scale(c,c),t.fillStyle=l,t.fillRect(0,0,v,v),t.fillStyle=i,he?t.fill(new Path2D(ce(r,k))):A.forEach((function(e,r){e.forEach((function(e,n){e&&t.fillRect(n+k,r+k,1,1)}))})),T&&(t.globalAlpha=T.opacity),s&&t.drawImage(n,T.x+k,T.y+k,T.w,T.h)}})),t.useEffect((()=>{E(!1)}),[f]);const S=Z({height:o,width:o},p);let M=null;return null!=f&&(M=t.createElement("img",{src:f,key:f,style:{display:"none"},onLoad:()=>{E(!0)},ref:x,crossOrigin:null==T?void 0:T.crossOrigin})),t.createElement(t.Fragment,null,t.createElement("canvas",Z({style:S,height:o,width:o,ref:b,role:"img"},w)),M)})).displayName="QRCodeCanvas";var me=t.forwardRef((function(e,r){const n=e,{value:s,size:o=ne,level:a=se,bgColor:l=oe,fgColor:i=ae,includeMargin:c=le,minVersion:d=ie,boostLevel:u,title:h,marginSize:m,imageSettings:g}=n,p=ee(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:w,cells:f,numCells:y,calculatedImageSettings:x}=ue({value:s,level:a,minVersion:d,boostLevel:u,includeMargin:c,marginSize:m,imageSettings:g,size:o});let b=f,N=null;null!=g&&null!=x&&(null!=x.excavation&&(b=de(f,x.excavation)),N=t.createElement("image",{href:g.src,height:x.h,width:x.w,x:x.x+w,y:x.y+w,preserveAspectRatio:"none",opacity:x.opacity,crossOrigin:x.crossOrigin}));const E=ce(b,w);return t.createElement("svg",Z({height:o,width:o,viewBox:`0 0 ${y} ${y}`,ref:r,role:"img"},p),!!h&&t.createElement("title",null,h),t.createElement("path",{fill:l,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),t.createElement("path",{fill:i,d:E,shapeRendering:"crispEdges"}),N)}));me.displayName="QRCodeSVG";const ge=({walletAddress:e,amount:r,currency:n,network:s,theme:o="light",size:a=200})=>{const[l,i]=t.useState(""),[c,d]=t.useState(null);t.useEffect((()=>{if(e&&"No address configured"!==e)try{let t;switch(s){case"tron":t="TRX"===n?`tronlink://transfer?to=${e}&amount=${r}`:e;break;case"algorand":t=`algorand://${e}?amount=${Math.floor(1e6*parseFloat(r))}`;break;case"bsc":if("BNB"===n)t=`ethereum:${e}@56?value=${m(r)}`;else{const s=u(n,"bsc");t=s?`ethereum:${s}/transfer?address=${e}&uint256=${h(r,n)}@56`:e}break;default:if("ETH"===n)t=`ethereum:${e}@1?value=${m(r)}`;else{const s=u(n,"ethereum");t=s?`ethereum:${s}/transfer?address=${e}&uint256=${h(r,n)}`:e}}i(t),d(null)}catch(t){console.error("Error generating QR code:",t),d("Error generating payment QR code")}else d("No wallet address configured for this network")}),[e,r,n,s]);const u=(e,t)=>{var r;return(null==(r={ethereum:{USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},bsc:{USDT:"0x55d398326f99059fF775485246999027B3197955",USDC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},tron:{USDT:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",USDC:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8"}}[t])?void 0:r[e])||""},h=(e,t)=>{const r="USDT"===t||"USDC"===t?6:18;return Math.floor(parseFloat(e)*Math.pow(10,r)).toString()},m=e=>Math.floor(1e18*parseFloat(e)).toString(),g=e=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[e]||e);return H.jsxs("div",{className:"flex flex-col items-center",children:[c?H.jsxs("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center",children:[H.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:H.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"})}),H.jsx("p",{className:"font-medium",children:c})]}):H.jsx("div",{className:"p-4 rounded-lg bg-white mb-3 shadow-sm border",children:l&&H.jsx(me,{value:l,size:a,bgColor:"dark"===o?"#374151":"#FFFFFF",fgColor:"dark"===o?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),H.jsxs("div",{className:"text-center text-sm text-gray-700 mb-4",children:[H.jsxs("p",{className:"font-semibold text-gray-800 flex items-center justify-center",children:[H.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:H.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 ",n]}),H.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Scan with your ",g(s)," wallet app"]})]}),H.jsxs("div",{className:"w-full mb-4 p-3 bg-gray-50 rounded-lg",children:[H.jsxs("div",{className:"flex justify-between items-center",children:[H.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Amount to Pay:"}),H.jsxs("span",{className:"text-lg font-bold text-[#7042D2]",children:[r," ",n]})]}),H.jsxs("div",{className:"flex justify-between items-center mt-1",children:[H.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),H.jsx("span",{className:"text-xs font-medium text-gray-700",children:g(s)})]})]}),!c&&H.jsxs("div",{className:"w-full mb-4",children:[H.jsx("p",{className:"text-xs text-gray-500 mb-1 text-center",children:"Or copy wallet address:"}),H.jsx("div",{className:"text-xs font-mono p-2 rounded bg-gray-100 text-gray-700 break-all text-center select-all cursor-pointer border",onClick:()=>{var t;return null==(t=navigator.clipboard)?void 0:t.writeText(e)},title:"Click to copy",children:e})]}),H.jsx("div",{className:"w-full",children:H.jsxs("div",{className:"p-3 rounded bg-blue-50 border border-blue-200",children:[H.jsxs("h4",{className:"text-sm font-medium mb-2 text-blue-800 flex items-center",children:[H.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:H.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"]}),H.jsxs("ol",{className:"text-xs space-y-1 text-blue-700",children:[H.jsxs("li",{children:["1. Open your crypto wallet app (",(p=s,{ethereum:["MetaMask","Trust Wallet","Coinbase Wallet"],bsc:["MetaMask","Trust Wallet","SafePal"],tron:["TronLink","Trust Wallet"],algorand:["Pera Wallet","MyAlgo Wallet"]}[p]||["MetaMask","Trust Wallet"]).join(", "),")"]}),H.jsx("li",{children:"2. Scan the QR code above or copy the wallet address"}),H.jsxs("li",{children:["3. Send exactly ",H.jsxs("strong",{children:[r," ",n]})," on ",g(s)," network"]}),H.jsx("li",{children:'4. Click "I have sent the payment" button below after sending'})]}),H.jsx("div",{className:"mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded",children:H.jsxs("p",{className:"text-xs text-yellow-800",children:[H.jsx("strong",{children:"Important:"})," Make sure you're sending on the correct network (",g(s),") and using the exact amount shown above."]})})]})})]});var p},pe=({status:e,message:t,theme:r="light"})=>H.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[H.jsx("div",{className:"mb-4",children:(()=>{switch(e){case"processing":return H.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return H.jsx("div",{className:"rounded-full h-12 w-12 bg-green-100 flex items-center justify-center",children:H.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:H.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return H.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:H.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:H.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}})()}),H.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"text-white":"text-gray-900"),children:(()=>{switch(e){case"processing":return"Processing Payment";case"success":return"Payment Successful";case"error":return"Payment Failed";default:return"Unknown Status"}})()}),H.jsx("p",{className:`text-center ${(()=>{switch(e){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"}})()}`,children:t}),"processing"===e&&H.jsx("div",{className:"mt-4 text-xs "+("dark"===r?"text-gray-400":"text-gray-500"),children:"This may take a few moments. Please do not close this window."}),"success"===e&&H.jsx("div",{className:"mt-4 p-2 rounded "+("dark"===r?"bg-gray-700":"bg-gray-100"),children:H.jsx("p",{className:"text-xs "+("dark"===r?"text-gray-300":"text-gray-600"),children:"Your payment has been successfully processed. You will receive a confirmation shortly."})})]}),we=({onSelect:e,selected:r,theme:n="light",supportedNetworks:s=[]})=>{const[o,a]=t.useState(u.ETHEREUM),[l,i]=t.useState({}),[c,d]=t.useState(!1);t.useEffect((()=>{i(w())}),[]);const m=[{id:u.ETHEREUM,name:"Ethereum",description:"ERC-20 tokens"},{id:u.BSC,name:"BSC (Binance Smart Chain)",description:"BEP-20 tokens"},{id:u.TRON,name:"Tron",description:"TRC-20 tokens"},{id:u.ALGORAND,name:"Algorand",description:"ASA tokens"}],p=(e=>{const t=[];switch(e){case u.ETHEREUM:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:u.ETHEREUM},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:u.ETHEREUM},{id:"PYUSD",name:"PYUSD",description:"PayPal USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/28492.png",network:u.ETHEREUM},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:u.ETHEREUM},{id:"USDP",name:"USDP",description:"Pax Dollar",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6662.png",network:u.ETHEREUM},{id:"DAI",name:"DAI",description:"Dai Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4943.png",network:u.ETHEREUM},{id:"ETH",name:"ETH",description:"Ethereum",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcyJyRKN0dRJWVZqoLzYgkRHdJsxKGq8nHUw&s",network:u.ETHEREUM});break;case u.BSC:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:u.BSC},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:u.BSC},{id:"BUSD",name:"BUSD",description:"Binance USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4687.png",network:u.BSC},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:u.BSC},{id:"BNB",name:"BNB",description:"Binance Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s",network:u.BSC});break;case u.TRON:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:u.TRON},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:u.TRON},{id:"USDJ",name:"USDJ",description:"JUST Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5446.png",network:u.TRON},{id:"TRX",name:"TRX",description:"Tron",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",network:u.TRON});break;case u.ALGORAND:t.push({id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:u.ALGORAND},{id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:u.ALGORAND},{id:"ALGO",name:"ALGO",description:"Algorand",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",network:u.ALGORAND})}return t})(o),f=c?p:p.slice(0,4);function y(e){switch(e){case u.ETHEREUM:case u.BSC:return h.METAMASK;case u.TRON:return h.TRONLINK;case u.ALGORAND:return h.LUTE;default:return h.METAMASK}}return H.jsxs("div",{children:[H.jsx("h3",{className:"text-lg font-medium mb-4 "+("dark"===n?"text-white":"text-gray-800"),children:"Select Payment Method"}),H.jsxs("div",{className:"mb-6",children:[H.jsx("label",{className:"block text-sm font-medium mb-2 "+("dark"===n?"text-white":"text-gray-700"),children:"Blockchain Network"}),H.jsx("select",{value:o,onChange:t=>{return n=t.target.value,a(n),d(!1),void((null==r?void 0:r.network)!==n&&e(null));var n},className:`w-full p-3 rounded-lg border transition-colors ${"dark"===n?"bg-gray-700 border-gray-600 text-white focus:border-[#7042D2]":"bg-white border-gray-300 text-gray-900 focus:border-[#7042D2]"} focus:outline-none focus:ring-2 focus:ring-[#7042D2] focus:ring-opacity-50`,children:m.filter((e=>0===s.length||s.includes(e.id))).map((e=>H.jsxs("option",{value:e.id,children:[e.name," - ",e.description]},e.id)))})]}),H.jsxs("div",{className:"mb-4",children:[H.jsx("label",{className:"block text-sm font-medium mb-3 "+("dark"===n?"text-white":"text-gray-700"),children:"Choose Cryptocurrency"}),H.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:f.map((t=>H.jsx("button",{onClick:()=>(t=>{var r;e({currency:t.id,network:o,tokenConfig:null==(r=g[t.id])?void 0:r[o],method:t})})(t),className:"p-4 rounded-lg transition-all duration-200 border-2 "+((null==r?void 0:r.currency)===t.id&&(null==r?void 0:r.network)===o?"dark"===n?"bg-blue-900/30 border-[#7042D2] ring-2 ring-[#7042D2] ring-opacity-50":"bg-blue-50 border-[#7042D2] ring-2 ring-[#7042D2] ring-opacity-50":"dark"===n?"bg-gray-700 hover:bg-gray-600 border-gray-600 hover:border-gray-500":"bg-white hover:bg-gray-50 border-gray-200 hover:border-gray-300"),children:H.jsxs("div",{className:"flex flex-col items-center text-center",children:[H.jsx("div",{className:"flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mb-2 shadow-sm",children:H.jsx("img",{src:t.logo,alt:t.name,className:"h-6 w-6"})}),H.jsxs("div",{children:[H.jsx("h4",{className:"font-medium text-sm "+("dark"===n?"text-white":"text-gray-900"),children:t.name}),H.jsx("p",{className:"text-xs "+("dark"===n?"text-gray-300":"text-gray-500"),children:t.description})]}),(null==r?void 0:r.currency)===t.id&&(null==r?void 0:r.network)===o&&H.jsx("div",{className:"mt-2",children:H.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-[#7042D2]",viewBox:"0 0 20 20",fill:"currentColor",children:H.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})})]})},`${t.id}-${t.network}`)))}),p.length>4&&H.jsx("button",{onClick:()=>d(!c),className:"w-full py-2 px-4 rounded-lg text-sm font-medium transition-colors "+("dark"===n?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:c?"Show Less":`Show More (${p.length-4} more)`})]}),H.jsx("div",{className:"p-3 rounded-lg text-sm "+("dark"===n?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:H.jsxs("div",{className:"flex items-center",children:[H.jsx("div",{className:"w-2 h-2 rounded-full mr-2 "+(l[y(o)]?"bg-green-500":"bg-red-500")}),H.jsx("span",{className:"text-xs",children:function(e){const t=y(e),r=l[t],n={[h.METAMASK]:"MetaMask",[h.TRONLINK]:"TronLink",[h.LUTE]:"Lute Wallet"};return r?`${n[t]} detected - Ready to pay`:`${n[t]} required - Please install to continue`}(o)})]})})]})},fe=({isOpen:e,onClose:r,payment:n,paymentStatus:s,selectedPaymentMethod:o,onPaymentMethodSelect:a,onPayment:l,onBack:i,error:c,theme:d="light",merchantName:u,transactionHash:m,walletConnection:g,onConnectWallet:p,testMode:w=!1,supportedNetworks:f=[],availableWallets:y={},supportedWallets:x=[],step:b="select-currency",merchantWalletAddresses:N={}})=>{const[E,k]=t.useState("wallet"),A=e=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[e]||e),v=e=>({[h.METAMASK]:"MetaMask",[h.TRONLINK]:"TronLink",[h.TRUST_WALLET]:"Trust Wallet",[h.LUTE]:"Lute Wallet"}[e]||e),T=e=>({[h.METAMASK]:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",[h.TRONLINK]:"https://www.tronlink.org/images/logo.png",[h.TRUST_WALLET]:"https://trustwallet.com/assets/images/trust_logotype.svg",[h.LUTE]:"https://lute.app/logo.png"}[e]||"");return e?H.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-black/50",children:H.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:H.jsxs("div",{className:"relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl bg-white text-gray-800",children:[H.jsxs("div",{className:"flex justify-between items-center mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[H.jsx("div",{className:"flex items-center",children:H.jsx("h2",{className:"text-xl font-bold text-gray-900",children:H.jsx("img",{src:"data:image/png;base64,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",className:"w-32",alt:"Coinley Logo"})})}),H.jsx("button",{onClick:r,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:H.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:H.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),H.jsxs("div",{className:"mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[n&&H.jsxs("div",{className:"mb-6 p-4 rounded-lg",children:[H.jsxs("p",{className:"text-lg text-gray-800 font-semibold",children:["PAY: ",u]}),H.jsxs("div",{className:"flex justify-between items-center mt-2 bg-gray-100 px-3 rounded-lg",children:[H.jsx("span",{className:"font-medium text-gray-700",children:"Amount:"}),H.jsxs("span",{className:"font-bold text-xl text-[#7042D2]",children:["$",(C=n.totalAmount||n.amount,parseFloat(C).toFixed(2))]})]}),H.jsx("div",{className:"text-xs mt-1 text-right",children:H.jsxs("span",{className:"text-gray-500",children:["Payment ID: ",n.id?n.id.slice(0,8):"","..."]})})]}),"select-currency"===b&&H.jsxs("div",{children:[H.jsx(we,{onSelect:a,selected:o,theme:d,supportedNetworks:f}),o&&H.jsx("div",{className:"mt-6",children:H.jsxs("button",{onClick:()=>{console.log("Proceed button clicked, calling onPaymentMethodSelect"),a(o)},className:"w-full py-3 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-lg transition-colors",disabled:!o,children:["Proceed with ",o.currency," on ",A(o.network)]})})]}),"confirm"===b&&o&&n&&H.jsxs("div",{children:[H.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[H.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),H.jsxs("div",{className:"space-y-2",children:[H.jsxs("div",{className:"flex justify-between",children:[H.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Currency:"}),H.jsx("span",{className:"font-medium",children:o.currency})]}),H.jsxs("div",{className:"flex justify-between",children:[H.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Network:"}),H.jsx("span",{className:"font-medium",children:A(o.network)})]}),H.jsxs("div",{className:"flex justify-between",children:[H.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Fee:"}),H.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),H.jsx("div",{className:"mb-4",children:H.jsxs("div",{className:"flex border-b border-gray-200",children:[H.jsx("button",{onClick:()=>k("wallet"),className:"py-2 px-4 text-sm font-medium "+("wallet"===E?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),children:"Connect Wallet"}),H.jsx("button",{onClick:()=>k("qrcode"),className:"py-2 px-4 text-sm font-medium "+("qrcode"===E?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),children:"QR Code"})]})}),w?H.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:H.jsxs("div",{className:"flex items-center",children:[H.jsx("div",{className:"bg-[#7042D2] rounded-full p-2 mr-3",children:H.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:H.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),H.jsxs("div",{children:[H.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),H.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):"qrcode"===E?H.jsx("div",{className:"mb-4",children:H.jsx(ge,{walletAddress:(()=>{if(!o)return"No network selected";const e=N[o.network];return e||((null==n?void 0:n.recipientWallet)?n.recipientWallet:"No wallet address configured for this network")})(),amount:n.totalAmount||n.amount,currency:o.currency,network:o.network,theme:d})}):H.jsxs("div",{className:"space-y-3 mb-4",children:[0===x.length?H.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:H.jsxs("div",{className:"flex items-center",children:[H.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:H.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"})}),H.jsxs("div",{children:[H.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),H.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",A(o.network)," network"]})]})]})}):x.map((e=>H.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:H.jsxs("div",{className:"flex items-center justify-between",children:[H.jsxs("div",{className:"flex items-center",children:[H.jsx("img",{src:T(e),alt:v(e),className:"w-8 h-8 mr-3",onError:e=>{e.target.style.display="none"}}),H.jsxs("div",{children:[H.jsx("h3",{className:"font-medium text-gray-800",children:v(e)}),H.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",v(e)]})]})]}),(null==g?void 0:g.walletType)===e?H.jsxs("div",{className:"flex items-center space-x-2",children:[H.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),H.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):H.jsx("button",{onClick:()=>{console.log("Connect wallet button clicked for:",e),p(e)},className:"py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md text-sm",children:"Connect"})]})},e))),H.jsx("div",{className:"space-y-2",children:Object.entries(y).filter((([e,t])=>!t)).map((([e])=>H.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:H.jsxs("div",{className:"flex items-center justify-between",children:[H.jsxs("span",{className:"text-sm text-gray-600",children:[v(e)," not detected"]}),H.jsx("a",{href:M(e),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#7042D2] hover:underline",children:"Install"})]})},e)))})]}),H.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[H.jsx("button",{type:"button",onClick:i,className:"w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-medium rounded-md",children:"Back"}),H.jsx("button",{type:"button",onClick:()=>l("qrcode"===E),className:"w-full py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",disabled:!w&&"wallet"===E&&!g,children:"qrcode"===E?"I have sent the payment":"Pay Now"})]})]}),"processing"===b&&H.jsx(pe,{status:"processing",theme:d,message:"Processing your payment..."}),"success"===b&&H.jsxs("div",{children:[H.jsx(pe,{status:"success",theme:d,message:"Payment successful!"}),m&&H.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-gray-100",children:[H.jsx("p",{className:"text-xs text-gray-600 mb-1",children:"Transaction Hash:"}),H.jsx("p",{className:"text-sm font-mono break-all text-gray-800",children:(S=m,S?S.length<=14?S:`${S.slice(0,8)}...${S.slice(-6)}`:"")}),o&&H.jsx("a",{href:`${ye(o.network)}/${xe(o.network)}/${m}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#7042D2] mt-2 inline-block",children:"View on Explorer →"})]})]}),"error"===b&&H.jsxs("div",{children:[H.jsx(pe,{status:"error",theme:d,message:c||"An error occurred while processing your payment."}),H.jsx("button",{type:"button",onClick:i,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"})]})]}),H.jsx("div",{className:"text-center text-xs text-gray-500",children:H.jsxs("p",{children:["Powered by ",H.jsx("span",{className:"text-[#7042D2]",children:"Coinley"})," - Secure Cryptocurrency Payments"]})})]})})}):null;var S,C},ye=e=>({ethereum:"https://etherscan.io",bsc:"https://bscscan.com",tron:"https://tronscan.org",algorand:"https://algoexplorer.io"}[e]||"https://etherscan.io"),xe=e=>({ethereum:"tx",bsc:"tx",tron:"transaction",algorand:"tx"}[e]||"tx"),be=t.forwardRef((({apiKey:e,apiSecret:r,apiUrl:n,customerEmail:s,merchantName:o="Merchant",merchantWalletAddresses:a={},onSuccess:l,onError:i,onClose:m,theme:g,autoOpen:p=!1,debug:x=!1,testMode:b=!1,supportedNetworks:N=[],preferredNetwork:E=u.ETHEREUM,preferredWallet:k=h.METAMASK},v)=>{const T=G(),{theme:S}=t.useContext(q),[M,C]=t.useState(p),[j,D]=t.useState(null),[P,U]=t.useState("idle"),[O,F]=t.useState(null),[W,B]=t.useState(null),[I,z]=t.useState(null),[Q,K]=t.useState(null),[_,V]=t.useState({}),[J,$]=t.useState("select-currency");e||null==T||T.apiKey,r||null==T||T.apiSecret,n||null==T||T.apiUrl;const Y=g||S,X=x||(null==T?void 0:T.debug),Z=N.length>0?N:[u.ETHEREUM,u.BSC,u.TRON,u.ALGORAND];t.useImperativeHandle(v,(()=>({open:e=>{te(e)},close:()=>{re()},getPayment:()=>j,getWalletConnection:()=>Q})));const ee=(e,t)=>{X&&console.log(`[Coinley SDK] ${e}`,t)};t.useEffect((()=>{if("undefined"!=typeof window){const e=w();V(e),ee("Available wallets detected:",e)}}),[X]);const te=e=>d(this,null,(function*(){if(!e||!e.amount)return B("Payment amount is required"),void(i&&i(new Error("Payment amount is required")));U("loading"),C(!0),$("select-currency");try{ee("Creating payment with details:",e);const t=yield R({amount:e.amount,currency:e.currency||"USDT",network:e.network||E,customerEmail:e.customerEmail||s,callbackUrl:e.callbackUrl,metadata:e.metadata||{},merchantWalletAddresses:c(c({},a),e.merchantWalletAddresses)});ee("Payment created:",t),D(t.payment),U("idle"),B(null),ee("Payment created and state updated")}catch(t){ee("Error creating payment:",t),B(t.message||"Failed to create payment"),U("error"),i&&i(t)}})),re=()=>{C(!1),z(null),K(null),F(null),$("select-currency"),m&&m()};return H.jsx(H.Fragment,{children:M&&H.jsx(fe,{isOpen:M,onClose:re,payment:j,paymentStatus:P,selectedPaymentMethod:O,onPaymentMethodSelect:e=>{console.log("=== PAYMENT METHOD SELECTION DEBUG ==="),console.log("1. Payment method selected:",e),console.log("2. Current step before:",J),ee("Payment method selected:",e),F(e),$("confirm"),console.log("3. Step should now be: confirm"),console.log("=== END PAYMENT METHOD SELECTION DEBUG ===")},onPayment:()=>d(this,null,(function*(){var e,t;if(j&&O)if(Q||b){ee("Starting payment process..."),U("loading"),z(null);try{let r;if(b)ee("Test mode: Generating mock transaction..."),r=`test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`;else{const n=a[O.network];if(!n)throw new Error(`No merchant wallet address configured for ${O.network}`);ee("Sending transaction through wallet..."),r=yield A(Q,{to:n,amount:j.amount,tokenAddress:null==(e=O.tokenConfig)?void 0:e.address,tokenDecimals:null==(t=O.tokenConfig)?void 0:t.decimals})}ee("Transaction hash:",r),z(r),ee("Processing payment with backend...");const n=yield L({paymentId:j.id,transactionHash:r,network:O.network,currency:O.currency,senderAddress:null==Q?void 0:Q.address});ee("Payment processed successfully:",n),U("success"),$("success"),l&&(ee("Calling onSuccess callback..."),l(j.id,r,{network:O.network,currency:O.currency,amount:j.amount}))}catch(r){ee("Payment error:",r),B(r.message||"Failed to process payment"),U("error"),$("error"),i&&i(r)}}else B("Please connect your wallet first");else B("Missing payment information")})),onBack:()=>{"confirm"===J&&($("select-currency"),K(null))},error:W,theme:Y,merchantName:o,transactionHash:I,walletConnection:Q,onConnectWallet:e=>d(this,null,(function*(){if(console.log("=== WALLET CONNECTION DEBUG ==="),console.log("1. Wallet type requested:",e),console.log("2. Selected payment method:",O),console.log("3. Available wallets:",_),console.log("4. Current step:",J),!O)return console.error("No payment method selected"),void B("Please select a payment method first");try{console.log("5. Attempting to connect wallet..."),B(null),ee("Connecting wallet:",{walletType:e,network:O.network});const t=yield y(e,O.network);K(t),B(null),console.log("6. Connection successful:",t),ee("Wallet connected successfully:",t)}catch(t){console.error("7. Connection failed:",t),ee("Wallet connection error:",t),B(t.message||"Failed to connect wallet")}console.log("=== END WALLET CONNECTION DEBUG ===")})),testMode:b,supportedNetworks:Z,availableWallets:_,supportedWallets:O?f(O.network):[],step:J,merchantWalletAddresses:a})})}));be.displayName="CoinleyCheckout";e.CoinleyCheckout=be,e.CoinleyModal=fe,e.CoinleyProvider=({apiKey:e,apiSecret:r,apiUrl:n="http://localhost:9000",merchantWalletAddress:s=null,merchantSolWalletAddress:o=null,debug:a=!1,children:l})=>{const[i,d]=t.useState(!1),[u,h]=t.useState(null),[m,g]=t.useState(null);t.useEffect((()=>{var t;if(e&&r)try{t={apiKey:e,apiSecret:r,apiUrl:n,merchantWalletAddress:s,merchantSolWalletAddress:o},C=c(c({},C),t),console.log("API initialized with:",{apiUrl:C.apiUrl,apiKey:C.apiKey?`${C.apiKey.substring(0,6)}...`:null,hasWalletAddresses:Object.keys(C.merchantWalletAddresses||{}).length>0}),d(!0),a&&console.log("Coinley SDK initialized with:",{apiKey:e,apiUrl:n,merchantWalletAddress:s?`${s.substring(0,6)}...${s.substring(s.length-4)}`:"Not provided",merchantSolWalletAddress:o?`${o.substring(0,6)}...${o.substring(o.length-4)}`:"Not provided"})}catch(l){h(l.message),a&&console.error("Coinley SDK initialization error:",l)}else h("API key and secret are required")}),[e,r,n,s,o,a]);const p={apiKey:e,apiSecret:r,apiUrl:n,merchantWalletAddress:s,merchantSolWalletAddress:o,isInitialized:i,error:u,debug:a,paymentData:m,storePaymentData:e=>(g(e),e)};return H.jsx(Q.Provider,{value:p,children:l})},e.DEFAULT_CONFIG={apiUrl:"http://localhost:9000",debug:!1,testMode:!1,theme:"light",supportedNetworks:["ethereum","bsc","tron","algorand"]},e.NETWORK_CONFIG=m,e.NETWORK_TYPES=u,e.PaymentMethods=we,e.PaymentStatus=pe,e.QRCode=ge,e.TOKEN_CONFIG=g,e.ThemeProvider=({initialTheme:e="light",children:r})=>{const[n,s]=t.useState(e);return t.useEffect((()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(n)}),[n]),H.jsx(q.Provider,{value:{theme:n,setTheme:s,toggleTheme:()=>{s((e=>"light"===e?"dark":"light"))}},children:r})},e.WALLET_TYPES=h,e.connectWallet=y,e.createPayment=R,e.detectWallets=w,e.generateMockTransactionHash=(e="ethereum")=>`${{ethereum:"0x",bsc:"0x",tron:"",algorand:""}[e]||"0x"}${Array.from({length:64},(()=>Math.floor(16*Math.random()).toString(16))).join("")}`,e.getMerchantProfile=()=>d(this,null,(function*(){try{const e=yield fetch(`${C.apiUrl}/api/merchants/profile`,{method:"GET",headers:j()});if(!e.ok){const t=yield e.json();throw new Error(t.error||`Failed to get merchant profile: ${e.status}`)}const t=yield e.json();return t.merchant&&t.merchant.walletAddresses&&(C.merchantWalletAddresses=c(c({},C.merchantWalletAddresses),t.merchant.walletAddresses)),t}catch(e){throw console.error("Get merchant profile error:",e),e}})),e.getPayment=e=>d(this,null,(function*(){try{console.log("Getting payment:",e);const t=yield fetch(`${C.apiUrl}/api/payments/${e}`,{method:"GET",headers:j()});if(!t.ok){const e=yield t.json();throw console.error("Error getting payment:",e),new Error(e.error||`Failed to get payment: ${t.status}`)}const r=yield t.json();return console.log("Get payment response:",r),r}catch(t){throw console.error("Get payment error:",t),t}})),e.getSupportedNetworks=()=>d(this,null,(function*(){try{const e=yield fetch(`${C.apiUrl}/api/networks`,{method:"GET",headers:j()});if(!e.ok){const t=yield e.json();throw new Error(t.error||`Failed to get networks: ${e.status}`)}return yield e.json()}catch(e){throw console.error("Get supported networks error:",e),e}})),e.getSupportedWalletsForNetwork=f,e.getWalletInstallUrl=M,e.processPayment=L,e.sendTransaction=A,e.useCoinley=G,e.validateWalletAddress=(e,t)=>d(this,null,(function*(){try{const r=yield fetch(`${C.apiUrl}/api/wallets/validate`,{method:"POST",headers:j(),body:JSON.stringify({address:e,network:t})});if(!r.ok){const e=yield r.json();throw new Error(e.error||`Failed to validate address: ${r.status}`)}return yield r.json()}catch(r){throw console.error("Validate wallet address error:",r),r}})),Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
7
7
  //# sourceMappingURL=coinley-checkout.umd.js.map