coinley-checkout 0.1.3 → 0.1.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.
- package/dist/coinley-checkout.es.js +1641 -1115
- package/dist/coinley-checkout.es.js.map +1 -0
- package/dist/coinley-checkout.umd.js +1993 -32
- package/dist/coinley-checkout.umd.js.map +1 -0
- package/dist/style.css +1336 -1
- package/package.json +1 -1
@@ -1,32 +1,1993 @@
|
|
1
|
-
(function(
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
<%s key={someKey} {...props} />`,Te,q,Ht,q),Ke[q+Te]=!0}}return e===c?Qt(C):_t(C),C}}function Gt(e,r,s){return et(e,r,s,!0)}function Wt(e,r,s){return et(e,r,s,!1)}var Bt=Wt,Zt=Gt;oe.Fragment=c,oe.jsx=Bt,oe.jsxs=Zt}()),oe}process.env.NODE_ENV==="production"?he.exports=tt():he.exports=rt();var t=he.exports;const Ie=g.createContext(),at=()=>g.useContext(Ie),nt=({initialTheme:a="light",children:n})=>{const[i,c]=g.useState(a),j=()=>{c(d=>d==="light"?"dark":"light")};return g.useEffect(()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(i)},[i]),t.jsx(Ie.Provider,{value:{theme:i,setTheme:c,toggleTheme:j},children:n})};let P={apiKey:null,apiSecret:null,apiUrl:"https://coinleyserver-production.up.railway.app"};const st=a=>{P={...P,...a},console.log("API initialized with:",P)},$=()=>({"Content-Type":"application/json","x-api-key":P.apiKey,"x-api-secret":P.apiSecret}),Ee=async a=>{try{console.log("Creating payment with data:",a),console.log("API URL:",`${P.apiUrl}/api/payments/create`);const n=await fetch(`${P.apiUrl}/api/payments/create`,{method:"POST",headers:$(),body:JSON.stringify(a)});if(console.log("Create payment response status:",n.status),!n.ok){const c=await n.json();throw console.error("Error creating payment:",c),new Error(c.error||`Failed to create payment: ${n.status}`)}const i=await n.json();return console.log("Create payment response data:",i),i}catch(n){throw console.error("Create payment error:",n),n}},ot=async a=>{try{console.log("Getting payment:",a);const n=await fetch(`${P.apiUrl}/api/payments/${a}`,{method:"GET",headers:$()});if(!n.ok){const c=await n.json();throw console.error("Error getting payment:",c),new Error(c.error||`Failed to get payment: ${n.status}`)}const i=await n.json();return console.log("Get payment response:",i),i}catch(n){throw console.error("Get payment error:",n),n}},ke=async a=>{try{console.log("Processing payment with data:",a),console.log("API URL:",`${P.apiUrl}/api/payments/process`);const n=await fetch(`${P.apiUrl}/api/payments/process`,{method:"POST",headers:$(),body:JSON.stringify(a)});if(console.log("Process payment response status:",n.status),!n.ok){const c=await n.json();throw console.error("Error processing payment:",c),new Error(c.error||`Failed to process payment: ${n.status}`)}const i=await n.json();return console.log("Process payment response data:",i),i}catch(n){throw console.error("Process payment error:",n),n}},it=async(a={})=>{try{const{page:n=1,limit:i=10,status:c,currency:j,startDate:d,endDate:N,search:L}=a,o=new URLSearchParams;o.append("page",n),o.append("limit",i),c&&o.append("status",c),j&&o.append("currency",j),d&&o.append("startDate",d),N&&o.append("endDate",N),L&&o.append("search",L);const T=`${P.apiUrl}/api/payments/merchant/list?${o.toString()}`,x=await fetch(T,{method:"GET",headers:$()});if(!x.ok){const A=await x.json();throw new Error(A.error||`Failed to get payments: ${x.status}`)}return await x.json()}catch(n){throw console.error("Get merchant payments error:",n),n}},ct=async()=>{try{const a=await fetch(`${P.apiUrl}/api/payments/merchant/stats`,{method:"GET",headers:$()});if(!a.ok){const n=await a.json();throw new Error(n.error||`Failed to get payment stats: ${a.status}`)}return await a.json()}catch(a){throw console.error("Get merchant payment stats error:",a),a}},lt=async()=>{try{const a=await fetch(`${P.apiUrl}/api/payments/currencies`,{method:"GET",headers:$()});if(!a.ok){const n=await a.json();throw new Error(n.error||`Failed to get currencies: ${a.status}`)}return await a.json()}catch(a){return console.error("Get supported currencies error:",a),{currencies:[{id:"USDT",name:"Tether USD",network:"ethereum"},{id:"USDC",name:"USD Coin",network:"ethereum"},{id:"BNB",name:"Binance Coin",network:"binance"},{id:"SOL",name:"Solana",network:"solana"},{id:"USDC_SOL",name:"USD Coin (Solana)",network:"solana"}]}}},Oe=g.createContext(),ut=()=>g.useContext(Oe),dt=({apiKey:a,apiSecret:n,apiUrl:i="https://coinleyserver-production.up.railway.app",debug:c=!1,children:j})=>{const[d,N]=g.useState(!1),[L,o]=g.useState(null);g.useEffect(()=>{if(!a||!n){o("API key and secret are required");return}try{st({apiKey:a,apiSecret:n,apiUrl:i}),N(!0),c&&console.log("Coinley SDK initialized with:",{apiKey:a,apiUrl:i})}catch(x){o(x.message),c&&console.error("Coinley SDK initialization error:",x)}},[a,n,i,c]);const T={apiKey:a,apiSecret:n,apiUrl:i,isInitialized:d,error:L,debug:c};return t.jsx(Oe.Provider,{value:T,children:j})},Pe=({walletAddress:a,amount:n,currency:i,theme:c="light"})=>t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx("div",{className:`p-4 rounded-lg ${c==="dark"?"bg-gray-700":"bg-white"} mb-3`,children:t.jsxs("div",{style:{width:"200px",height:"200px",backgroundColor:"#f0f0f0",display:"flex",alignItems:"center",justifyContent:"center"},children:["QR Code: ",i]})}),t.jsx("div",{className:"text-center text-sm",children:"Scan with your wallet app to pay"}),a&&t.jsxs("div",{className:"mt-3 w-full",children:[t.jsxs("p",{className:"text-xs mb-1",children:["Send ",n," ",i," to:"]}),t.jsx("div",{className:"text-xs font-mono p-2 rounded overflow-auto break-all bg-gray-100",children:a})]})]}),ft=Object.freeze(Object.defineProperty({__proto__:null,default:Pe},Symbol.toStringTag,{value:"Module"})),gt=({onSelect:a,selected:n,theme:i="light"})=>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RjLjE0LjAyLjMuMTguMy4xOHoiIGZpbGw9IiNmZmYiLz48L2c+PC9zdmc+"},{id:"USDC_SOL",name:"USDC (Solana)",description:"USD Coin on Solana",logo:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48Y2lyY2xlIGN4PSIxNiIgY3k9IjE2IiByPSIxNiIgZmlsbD0iIzJCNzVFRCIvPjxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik0yMS4yMDkgOS43MzlsLTIuOTQxIDIuOTQxYTMuMTMyIDMuMTMyIDAgMDAtNC41MzYgMGwtMi45NDItMi45NDFhNy42MjMgNy42MjMgMCAwMTEwLjQxOSAwek0xMC43OTEgMjIuMjYxbDIuOTQxLTIuOTQxYTMuMTMyIDMuMTMyIDAgMDA0LjUzNiAwbDIuOTQyIDIuOTQxYTcuNjIzIDcuNjIzIDAgMDEtMTAuNDE5IDB6bTExLjU3NS00LjI2MWgtNC4xNTNhMy4xMzMgMy4xMzMgMCAwMDAtNC41MzdoNC4xNTNhNy42MjEgNy42MjEgMCAwMTAgNC41Mzd6bS0xMy43OTMtNC41MzdoNC4xNTNhMy4xMzMgMy4xMzMgMCAwMDAgNC41MzdIOS42ODZhNy42MjEgNy42MjEgMCAwMTAtNC41Mzd6Ii8+PC9nPjwvc3ZnPg=="}],j=d=>{console.log("Method selected:",d),a(d)};return t.jsxs("div",{children:[t.jsx("h3",{className:`text-lg font-medium mb-3 ${i==="dark"?"text-white":"text-gray-800"}`,children:"Select Payment Method"}),t.jsx("div",{className:"space-y-2",children:c.map(d=>t.jsxs("button",{onClick:()=>j(d.id),className:`w-full flex items-center p-3 rounded-lg transition-colors ${n===d.id?i==="dark"?"bg-blue-900/30 border border-blue-500":"bg-blue-50 border border-blue-500":i==="dark"?"bg-gray-700 hover:bg-gray-600 border border-gray-700":"bg-white hover:bg-gray-50 border border-gray-200"}`,children:[t.jsx("div",{className:"flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mr-3",children:t.jsx("img",{src:d.logo,alt:d.name,className:"h-6 w-6"})}),t.jsxs("div",{className:"flex-1 text-left",children:[t.jsx("h4",{className:`font-medium ${i==="dark"?"text-white":"text-gray-900"}`,children:d.name}),t.jsx("p",{className:`text-sm ${i==="dark"?"text-gray-300":"text-gray-500"}`,children:d.description})]}),n===d.id&&t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-blue-500",viewBox:"0 0 20 20",fill:"currentColor",children:t.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"})})]},d.id))})]})},xe=({status:a,theme:n="light",message:i})=>{console.log("PaymentStatus render:",{status:a,message:i});const c=()=>{switch(a){case"processing":return t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return t.jsx("div",{className:"rounded-full h-12 w-12 bg-green-100 flex items-center justify-center",children:t.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:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return t.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:t.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:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}},j=()=>{switch(a){case"processing":return"Processing Payment";case"success":return"Payment Successful";case"error":return"Payment Failed";default:return"Unknown Status"}},d=()=>{switch(a){case"processing":return n==="dark"?"text-blue-300":"text-blue-600";case"success":return n==="dark"?"text-green-300":"text-green-600";case"error":return n==="dark"?"text-red-300":"text-red-600";default:return n==="dark"?"text-gray-300":"text-gray-600"}};return t.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[t.jsx("div",{className:"mb-4",children:c()}),t.jsx("h3",{className:`text-xl font-bold mb-2 ${n==="dark"?"text-white":"text-gray-900"}`,children:j()}),t.jsx("p",{className:`text-center ${d()}`,children:i}),a==="processing"&&t.jsx("div",{className:`mt-4 text-xs ${n==="dark"?"text-gray-400":"text-gray-500"}`,children:"This may take a few moments. Please do not close this window."}),a==="success"&&t.jsx("div",{className:`mt-4 p-2 rounded ${n==="dark"?"bg-gray-700":"bg-gray-100"}`,children:t.jsx("p",{className:`text-xs ${n==="dark"?"text-gray-300":"text-gray-600"}`,children:"Your payment has been successfully processed. You will receive a confirmation shortly."})})]})},Q=()=>typeof window<"u"&&typeof window.ethereum<"u",Re=async()=>{if(!Q())throw new Error("MetaMask is not installed");try{return await window.ethereum.request({method:"eth_requestAccounts"})}catch(a){throw console.error("Error connecting to wallet:",a),a}},ze=async()=>{if(!Q())throw new Error("MetaMask is not installed");try{return await window.ethereum.request({method:"eth_accounts"})}catch(a){throw console.error("Error getting accounts:",a),a}},yt=async()=>{if(!Q())throw new Error("MetaMask is not installed");try{return await window.ethereum.request({method:"eth_chainId"})}catch(a){throw console.error("Error getting chain ID:",a),a}},Ue=async a=>{if(!Q())throw new Error("MetaMask is not installed");try{return await window.ethereum.request({method:"eth_sendTransaction",params:[a]})}catch(n){throw console.error("Error sending transaction:",n),n}},mt=async(a,n,i)=>{if(!Q())throw new Error("MetaMask is not installed");try{const j=(await window.ethereum.request({method:"eth_requestAccounts"}))[0],d="0xa9059cbb",N=n.slice(2).padStart(64,"0"),L=i.toString(16).padStart(64,"0"),o=`${d}${N}${L}`,T={from:j,to:a,data:o};return await window.ethereum.request({method:"eth_sendTransaction",params:[T]})}catch(c){throw console.error("Error sending token:",c),c}},Mt=async()=>{try{return(await ze()).length>0}catch{return!1}},ht=a=>({"0x1":"Ethereum Mainnet","0x3":"Ropsten Testnet","0x4":"Rinkeby Testnet","0x5":"Goerli Testnet","0x2a":"Kovan Testnet","0x38":"Binance Smart Chain","0x89":"Polygon","0xa86a":"Avalanche"})[a]||`Unknown Network (${a})`,xt=async(a,n)=>{if(!Q())throw new Error("MetaMask is not installed");try{const i="0x70a08231",c=n.slice(2).padStart(64,"0"),j=`${i}${c}`,d=await window.ethereum.request({method:"eth_call",params:[{to:a,data:j},"latest"]});return parseInt(d,16).toString()}catch(i){throw console.error("Error getting token balance:",i),i}},jt={USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",DAI:"0x6B175474E89094C44Da98b954EedeAC495271d0F",WETH:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",WBTC:"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599"},wt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAAcCAYAAACqAXueAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAiaSURBVHgB7VrdddNIFL4zNuDAw2orQDQATgUoUABQAU4FOGcLiF0BpoI4FcQ0QLQVxAHOvqLtwDyQOBBr9rszI2n058jeBEhOvnNkS6M7o7m6c39HRA3Qf/bxLR+l9uDIR/sXHD26trjTJeoMiO6/pEuCEBuHOBQfZuxfB9mQjpnv958d9/O9W2/w6+N4StcSHV+INoQhdoVQB7ju0Q1DUwFbiN1Cw6Wt+l+EHg4vu5TXdKHWIydgmFyv//xjWWhCzOyZB5pA0xo63zSrf0vjQNvZhNPvjTB/Gf9NNwx5DZZyQIoOSn5VOYxLaRaAUkHaFotpcgqhdmG6j7Aq4LNbXfqtMQ+VUts4xkrRDq7HdM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xc5Ew2zOyh/d6Xe8SYDf+VBZo/VXh/jATa5jhd/JqVK+0UHm6gJzPea2qL3NB0NXEBwD6JmwtE+yx6cVzfdR/5V4JhBgt/YM/O9GzbkM2fubfk2KlLl94MV+XmRW2Ga77B83RQnKyX7TAcC5WBhzKesyaDXO1HWfIe0MjSDYaGNmkEzGdG1QTGaP7m4S2GDxsYJURVlQcDxAIHUQ+1z48V+Jhzp+OSFEWy8mECwdgXlfbYNsh6tF1Xfoh7GslnN9Z0btZay8MmOFkw5YpR2MKW3BCNLO0O0HZqP78QfVYP/jx2mW5TAmcbZYTHxsYFYVNer2XfRyobjxWh1cT607T7d4qejPsrO0EzAgv0u/HH4OBeGaxPO94Q6plv8FECovJc8uTjKNvgPcUpIo0ZgmzUAAAAASUVORK5CYII=",pt=g.lazy(()=>Promise.resolve().then(()=>ft)),Ye=({isOpen:a,onClose:n,payment:i,paymentStatus:c,selectedCurrency:j,onCurrencySelect:d,onPayment:N,error:L,theme:o="light",merchantName:T,transactionHash:x,walletConnected:A,onConnectWallet:U,testMode:S=!1})=>{const[Y,F]=g.useState("select-currency"),[B,D]=g.useState(!1),[v,ie]=g.useState("wallet");g.useEffect(()=>{typeof window<"u"&&D(Q())},[]),g.useEffect(()=>{c==="loading"?F("processing"):c==="success"?F("success"):c==="error"?F("error"):c==="idle"&&i&&F("select-currency")},[c,i]);const G=I=>{d(I),F("confirm")},Z=()=>{N(v==="qrcode")},K=()=>{Y==="confirm"&&F("select-currency")},ce=()=>{n()},_=I=>parseFloat(I).toFixed(2),ee=I=>I?I.length<=14?I:`${I.slice(0,8)}...${I.slice(-6)}`:"",H=I=>{ie(I)},te=`fixed inset-0 z-50 overflow-y-auto ${o==="dark"?"bg-gray-900/75":"bg-black/50"}`,W=`relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl ${o==="dark"?"bg-gray-800 text-white":"bg-white text-gray-800"}`,k=`text-xl font-bold mb-4 ${o==="dark"?"text-white":"text-gray-900"}`,R=`w-full py-2 px-4 rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 ${o==="dark"?"bg-blue-600 hover:bg-blue-700 text-white focus:ring-blue-500":"bg-blue-500 hover:bg-blue-600 text-white focus:ring-blue-500"}`,p=`w-full py-2 px-4 rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 ${o==="dark"?"bg-gray-700 hover:bg-gray-600 text-white focus:ring-gray-500":"bg-gray-200 hover:bg-gray-300 text-gray-800 focus:ring-gray-500"}`,X="py-2 px-4 text-sm font-medium focus:outline-none transition-colors",V=`${o==="dark"?"bg-gray-700 text-white":"bg-gray-100 text-gray-800"} rounded-t-md`,J=`${o==="dark"?"text-gray-400 hover:text-gray-300":"text-gray-500 hover:text-gray-700"}`;return a?t.jsx("div",{className:te,children:t.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:t.jsxs("div",{className:W,children:[t.jsxs("div",{className:"flex justify-between items-center mb-6",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("img",{src:wt,alt:"Coinley Logo",className:"h-8 mr-2"}),t.jsx("h2",{className:k,children:"Coinley Pay"})]}),t.jsx("button",{onClick:ce,className:`text-gray-500 hover:text-gray-700 focus:outline-none ${o==="dark"?"text-gray-400 hover:text-gray-300":""}`,children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("div",{className:"mb-6",children:[i&&t.jsxs("div",{className:`mb-6 p-4 rounded-lg ${o==="dark"?"bg-gray-700":"bg-gray-100"}`,children:[t.jsx("p",{className:`text-sm ${o==="dark"?"text-gray-300":"text-gray-600"}`,children:T}),t.jsxs("div",{className:"flex justify-between items-center mt-2",children:[t.jsx("span",{className:`font-medium ${o==="dark"?"text-gray-300":"text-gray-700"}`,children:"Amount:"}),t.jsxs("span",{className:"font-bold text-xl",children:["$",_(i.totalAmount||i.amount)]})]}),t.jsx("div",{className:"text-xs mt-1 text-right",children:t.jsxs("span",{className:`${o==="dark"?"text-gray-400":"text-gray-500"}`,children:["Payment ID: ",i.id.slice(0,8),"..."]})})]}),Y==="select-currency"&&t.jsx(gt,{onSelect:G,selected:j,theme:o}),Y==="confirm"&&i&&t.jsxs("div",{children:[t.jsxs("div",{className:`p-4 rounded-lg mb-4 ${o==="dark"?"bg-gray-700":"bg-gray-100"}`,children:[t.jsx("h3",{className:`text-lg font-medium mb-2 ${o==="dark"?"text-white":"text-gray-800"}`,children:"Payment Details"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:o==="dark"?"text-gray-300":"text-gray-600",children:"Currency:"}),t.jsx("span",{className:"font-medium",children:j})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:o==="dark"?"text-gray-300":"text-gray-600",children:"Network:"}),t.jsx("span",{className:"font-medium",children:j==="SOL"||j==="USDC_SOL"?"Solana":"Ethereum"})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:o==="dark"?"text-gray-300":"text-gray-600",children:"Fee:"}),t.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"flex border-b border-gray-200",children:[t.jsx("button",{onClick:()=>H("wallet"),className:`${X} ${v==="wallet"?V:J}`,children:"Connect Wallet"}),t.jsx("button",{onClick:()=>H("qrcode"),className:`${X} ${v==="qrcode"?V:J}`,children:"QR Code"})]})}),S?t.jsx("div",{className:`p-4 rounded-lg mb-4 ${o==="dark"?"bg-blue-900/20":"bg-blue-50"}`,children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"bg-blue-500 rounded-full p-2 mr-3",children:t.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:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),t.jsxs("div",{children:[t.jsx("h3",{className:`font-medium ${o==="dark"?"text-white":"text-gray-800"}`,children:"Test Mode Payment"}),t.jsx("p",{className:`text-sm ${o==="dark"?"text-gray-300":"text-gray-600"}`,children:'Click "Pay Now" to simulate a successful payment'})]})]})}):v==="qrcode"?t.jsx("div",{className:`p-4 rounded-lg mb-4 ${o==="dark"?"bg-blue-900/20":"bg-blue-50"}`,children:t.jsx(pt,{walletAddress:i.walletAddress||"0x742d35Cc6634C0532925a3b844Bc454e4438f44e",amount:i.totalAmount||i.amount,currency:j,theme:o})}):B?t.jsxs("div",{className:`p-4 rounded-lg mb-4 ${o==="dark"?"bg-blue-900/20":"bg-blue-50"}`,children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("img",{src:"https://metamask.io/images/metamask-fox.svg",alt:"MetaMask",className:"w-8 h-8 mr-2"}),t.jsxs("div",{children:[t.jsx("h3",{className:`font-medium ${o==="dark"?"text-white":"text-gray-800"}`,children:"Pay with MetaMask"}),t.jsx("p",{className:`text-sm ${o==="dark"?"text-gray-300":"text-gray-600"}`,children:A?"Your wallet is connected. Click 'Pay Now' to proceed.":"Click 'Connect Wallet' to proceed with payment."})]})]}),!A&&t.jsx("button",{onClick:U,className:`mt-3 ${R}`,children:"Connect Wallet"})]}):t.jsxs("div",{className:`p-4 rounded-lg mb-4 ${o==="dark"?"bg-yellow-900/20":"bg-yellow-50"}`,children:[t.jsxs("div",{className:"flex items-center",children:[t.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:t.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"})}),t.jsxs("div",{children:[t.jsx("h3",{className:`font-medium ${o==="dark"?"text-white":"text-gray-800"}`,children:"MetaMask Not Detected"}),t.jsx("p",{className:`text-sm ${o==="dark"?"text-gray-300":"text-gray-600"}`,children:"Please install MetaMask extension to make payments"})]})]}),t.jsx("a",{href:"https://metamask.io/download/",target:"_blank",rel:"noopener noreferrer",className:`block mt-3 text-center ${R}`,children:"Install MetaMask"})]}),t.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-3",children:[t.jsx("button",{type:"button",onClick:K,className:p,children:"Back"}),t.jsx("button",{type:"button",onClick:Z,className:R,disabled:!S&&v==="wallet"&&B&&!A,children:"Pay Now"})]})]}),Y==="processing"&&t.jsx(xe,{status:"processing",theme:o,message:"Processing your payment..."}),Y==="success"&&t.jsxs("div",{children:[t.jsx(xe,{status:"success",theme:o,message:"Payment successful!"}),x&&t.jsxs("div",{className:`mt-4 p-3 rounded-lg ${o==="dark"?"bg-gray-700":"bg-gray-100"}`,children:[t.jsx("p",{className:`text-xs ${o==="dark"?"text-gray-300":"text-gray-600"} mb-1`,children:"Transaction Hash:"}),t.jsx("p",{className:`text-sm font-mono break-all ${o==="dark"?"text-white":"text-gray-800"}`,children:ee(x)}),t.jsx("a",{href:`https://etherscan.io/tx/${x}`,target:"_blank",rel:"noopener noreferrer",className:`text-xs ${o==="dark"?"text-blue-400":"text-blue-600"} mt-2 inline-block`,children:"View on Etherscan →"})]})]}),Y==="error"&&t.jsxs("div",{children:[t.jsx(xe,{status:"error",theme:o,message:L||"An error occurred while processing your payment."}),t.jsx("button",{type:"button",onClick:K,className:`mt-4 ${p}`,children:"Try Again"})]})]}),t.jsx("div",{className:`text-center text-xs ${o==="dark"?"text-gray-400":"text-gray-500"}`,children:t.jsx("p",{children:"Powered by Coinley - Secure Cryptocurrency Payments"})})]})})}):null},Fe=g.forwardRef(({apiKey:a,apiSecret:n,apiUrl:i,customerEmail:c,merchantName:j="Merchant",onSuccess:d,onError:N,onClose:L,theme:o,autoOpen:T=!1,debug:x=!1,testMode:A=!1},U)=>{const S=ut(),{theme:Y}=at(),[F,B]=g.useState(T),[D,v]=g.useState(null),[ie,G]=g.useState("idle"),[Z,K]=g.useState("USDT"),[ce,_]=g.useState(null),[ee,H]=g.useState(null),[te,W]=g.useState(!1);a||(S==null||S.apiKey),n||(S==null||S.apiSecret),i||(S==null||S.apiUrl);const k=o||Y,R=x||(S==null?void 0:S.debug);g.useImperativeHandle(U,()=>({open:y=>{X(y)},close:()=>{V()},getPayment:()=>D}));const p=(y,m)=>{R&&console.log(`[Coinley SDK] ${y}`,m)};g.useEffect(()=>{(async()=>{if(Q())try{const m=await window.ethereum.request({method:"eth_accounts"});W(m&&m.length>0)}catch(m){p("Error checking wallet connection:",m),W(!1)}else W(!1)})()},[]),g.useEffect(()=>{const y=m=>{W(m.length>0)};return typeof window<"u"&&window.ethereum&&window.ethereum.on("accountsChanged",y),()=>{typeof window<"u"&&window.ethereum&&window.ethereum.removeListener("accountsChanged",y)}},[]);const X=async y=>{if(!y||!y.amount){_("Payment amount is required"),N&&N(new Error("Payment amount is required"));return}G("loading"),B(!0);try{p("Creating payment with details:",y);const m=await Ee({amount:y.amount,currency:y.currency||"USDT",customerEmail:y.customerEmail||c,callbackUrl:y.callbackUrl,metadata:y.metadata||{}});p("Payment created:",m),v(m.payment),G("idle"),_(null),p("Payment created and state updated:",{payment:m.payment,status:"idle"})}catch(m){p("Error creating payment:",m),_(m.message||"Failed to create payment"),G("error"),N&&N(m)}},V=()=>{B(!1),H(null),L&&L()},J=y=>{p("Currency selected:",y),K(y)},I=async()=>{if(!Q())return _("MetaMask is not installed. Please install MetaMask to make payments."),!1;try{const y=await Re();return W(y.length>0),y.length>0}catch(y){return p("Error connecting to wallet:",y),_(y.message||"Failed to connect to wallet"),!1}},de=async(y=!1)=>{if(!D){_("No active payment to process");return}p("Starting payment process...",{isQrCodeMode:y}),G("loading"),H(null);try{p("Processing payment:",{paymentId:D.id,currency:Z,isQrCodeMode:y});let m;if(A)p("Test mode: Generating mock transaction..."),m=`0x${Array.from({length:64},()=>Math.floor(Math.random()*16).toString(16)).join("")}`;else if(y)p("QR code payment: User confirms payment was sent"),m=`qrcode_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`;else{if(!te&&!await I())throw new Error("Please connect your wallet to proceed with payment");const je=D.walletAddress||"0x742d35Cc6634C0532925a3b844Bc454e4438f44e",we={from:await window.ethereum.request({method:"eth_requestAccounts"}).then(re=>re[0]),to:je,value:"0x0",data:"0x"};p("Sending transaction to wallet for approval..."),m=await Ue(we)}p("Transaction hash:",m),H(m),p("Sending process payment request to API...");const fe=await ke({paymentId:D.id,transactionHash:m,network:Z==="SOL"||Z==="USDC_SOL"?"solana":"ethereum"});p("Payment processed successfully:",fe),G("success"),d&&(p("Calling onSuccess callback..."),d(D.id,m))}catch(m){p("Payment error:",m),_(m.message||"Failed to process payment"),G("error"),N&&N(m)}};return g.useEffect(()=>{T&&D&&B(!0)},[T,D]),t.jsx(t.Fragment,{children:F&&t.jsx(Ye,{isOpen:F,onClose:V,payment:D,paymentStatus:ie,selectedCurrency:Z,onCurrencySelect:J,onPayment:de,error:ce,theme:k,merchantName:j,transactionHash:ee,walletConnected:te,onConnectWallet:I,testMode:A})})});Fe.displayName="CoinleyCheckout";const vt={apiUrl:"https://coinleyserver-production.up.railway.app",debug:!1,testMode:!1,theme:"light"},Nt="1.0.2";h.CoinleyCheckout=Fe,h.CoinleyModal=Ye,h.CoinleyProvider=dt,h.DEFAULT_CONFIG=vt,h.QRCode=Pe,h.TOKEN_ADDRESSES=jt,h.ThemeProvider=nt,h.VERSION=Nt,h.connectWallet=Re,h.createPayment=Ee,h.getAccounts=ze,h.getChainId=yt,h.getMerchantPaymentStats=ct,h.getMerchantPayments=it,h.getNetworkName=ht,h.getPayment=ot,h.getSupportedCurrencies=lt,h.getTokenBalance=xt,h.isMetaMaskInstalled=Q,h.isWalletConnected=Mt,h.processPayment=ke,h.sendToken=mt,h.sendTransaction=Ue,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
1
|
+
(function(global, factory) {
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react")) : typeof define === "function" && define.amd ? define(["exports", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.CoinleyCheckout = {}, global.React));
|
3
|
+
})(this, function(exports2, require$$0) {
|
4
|
+
"use strict";
|
5
|
+
var jsxRuntime = { exports: {} };
|
6
|
+
var reactJsxRuntime_production_min = {};
|
7
|
+
/**
|
8
|
+
* @license React
|
9
|
+
* react-jsx-runtime.production.min.js
|
10
|
+
*
|
11
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
12
|
+
*
|
13
|
+
* This source code is licensed under the MIT license found in the
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
15
|
+
*/
|
16
|
+
var hasRequiredReactJsxRuntime_production_min;
|
17
|
+
function requireReactJsxRuntime_production_min() {
|
18
|
+
if (hasRequiredReactJsxRuntime_production_min)
|
19
|
+
return reactJsxRuntime_production_min;
|
20
|
+
hasRequiredReactJsxRuntime_production_min = 1;
|
21
|
+
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
|
22
|
+
function q(c, a, g) {
|
23
|
+
var b, d = {}, e = null, h = null;
|
24
|
+
void 0 !== g && (e = "" + g);
|
25
|
+
void 0 !== a.key && (e = "" + a.key);
|
26
|
+
void 0 !== a.ref && (h = a.ref);
|
27
|
+
for (b in a)
|
28
|
+
m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
29
|
+
if (c && c.defaultProps)
|
30
|
+
for (b in a = c.defaultProps, a)
|
31
|
+
void 0 === d[b] && (d[b] = a[b]);
|
32
|
+
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
33
|
+
}
|
34
|
+
reactJsxRuntime_production_min.Fragment = l;
|
35
|
+
reactJsxRuntime_production_min.jsx = q;
|
36
|
+
reactJsxRuntime_production_min.jsxs = q;
|
37
|
+
return reactJsxRuntime_production_min;
|
38
|
+
}
|
39
|
+
var reactJsxRuntime_development = {};
|
40
|
+
/**
|
41
|
+
* @license React
|
42
|
+
* react-jsx-runtime.development.js
|
43
|
+
*
|
44
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
45
|
+
*
|
46
|
+
* This source code is licensed under the MIT license found in the
|
47
|
+
* LICENSE file in the root directory of this source tree.
|
48
|
+
*/
|
49
|
+
var hasRequiredReactJsxRuntime_development;
|
50
|
+
function requireReactJsxRuntime_development() {
|
51
|
+
if (hasRequiredReactJsxRuntime_development)
|
52
|
+
return reactJsxRuntime_development;
|
53
|
+
hasRequiredReactJsxRuntime_development = 1;
|
54
|
+
if (process.env.NODE_ENV !== "production") {
|
55
|
+
(function() {
|
56
|
+
var React = require$$0;
|
57
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.element");
|
58
|
+
var REACT_PORTAL_TYPE = Symbol.for("react.portal");
|
59
|
+
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
60
|
+
var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
|
61
|
+
var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
62
|
+
var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
|
63
|
+
var REACT_CONTEXT_TYPE = Symbol.for("react.context");
|
64
|
+
var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
|
65
|
+
var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
|
66
|
+
var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
|
67
|
+
var REACT_MEMO_TYPE = Symbol.for("react.memo");
|
68
|
+
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
69
|
+
var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
|
70
|
+
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
71
|
+
var FAUX_ITERATOR_SYMBOL = "@@iterator";
|
72
|
+
function getIteratorFn(maybeIterable) {
|
73
|
+
if (maybeIterable === null || typeof maybeIterable !== "object") {
|
74
|
+
return null;
|
75
|
+
}
|
76
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
77
|
+
if (typeof maybeIterator === "function") {
|
78
|
+
return maybeIterator;
|
79
|
+
}
|
80
|
+
return null;
|
81
|
+
}
|
82
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
83
|
+
function error(format) {
|
84
|
+
{
|
85
|
+
{
|
86
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
87
|
+
args[_key2 - 1] = arguments[_key2];
|
88
|
+
}
|
89
|
+
printWarning("error", format, args);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
function printWarning(level, format, args) {
|
94
|
+
{
|
95
|
+
var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
|
96
|
+
var stack = ReactDebugCurrentFrame2.getStackAddendum();
|
97
|
+
if (stack !== "") {
|
98
|
+
format += "%s";
|
99
|
+
args = args.concat([stack]);
|
100
|
+
}
|
101
|
+
var argsWithFormat = args.map(function(item) {
|
102
|
+
return String(item);
|
103
|
+
});
|
104
|
+
argsWithFormat.unshift("Warning: " + format);
|
105
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
var enableScopeAPI = false;
|
109
|
+
var enableCacheElement = false;
|
110
|
+
var enableTransitionTracing = false;
|
111
|
+
var enableLegacyHidden = false;
|
112
|
+
var enableDebugTracing = false;
|
113
|
+
var REACT_MODULE_REFERENCE;
|
114
|
+
{
|
115
|
+
REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
|
116
|
+
}
|
117
|
+
function isValidElementType(type) {
|
118
|
+
if (typeof type === "string" || typeof type === "function") {
|
119
|
+
return true;
|
120
|
+
}
|
121
|
+
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
|
122
|
+
return true;
|
123
|
+
}
|
124
|
+
if (typeof type === "object" && type !== null) {
|
125
|
+
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
|
126
|
+
// types supported by any Flight configuration anywhere since
|
127
|
+
// we don't know which Flight build this will end up being used
|
128
|
+
// with.
|
129
|
+
type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) {
|
130
|
+
return true;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
return false;
|
134
|
+
}
|
135
|
+
function getWrappedName(outerType, innerType, wrapperName) {
|
136
|
+
var displayName = outerType.displayName;
|
137
|
+
if (displayName) {
|
138
|
+
return displayName;
|
139
|
+
}
|
140
|
+
var functionName = innerType.displayName || innerType.name || "";
|
141
|
+
return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
|
142
|
+
}
|
143
|
+
function getContextName(type) {
|
144
|
+
return type.displayName || "Context";
|
145
|
+
}
|
146
|
+
function getComponentNameFromType(type) {
|
147
|
+
if (type == null) {
|
148
|
+
return null;
|
149
|
+
}
|
150
|
+
{
|
151
|
+
if (typeof type.tag === "number") {
|
152
|
+
error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
|
153
|
+
}
|
154
|
+
}
|
155
|
+
if (typeof type === "function") {
|
156
|
+
return type.displayName || type.name || null;
|
157
|
+
}
|
158
|
+
if (typeof type === "string") {
|
159
|
+
return type;
|
160
|
+
}
|
161
|
+
switch (type) {
|
162
|
+
case REACT_FRAGMENT_TYPE:
|
163
|
+
return "Fragment";
|
164
|
+
case REACT_PORTAL_TYPE:
|
165
|
+
return "Portal";
|
166
|
+
case REACT_PROFILER_TYPE:
|
167
|
+
return "Profiler";
|
168
|
+
case REACT_STRICT_MODE_TYPE:
|
169
|
+
return "StrictMode";
|
170
|
+
case REACT_SUSPENSE_TYPE:
|
171
|
+
return "Suspense";
|
172
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
173
|
+
return "SuspenseList";
|
174
|
+
}
|
175
|
+
if (typeof type === "object") {
|
176
|
+
switch (type.$$typeof) {
|
177
|
+
case REACT_CONTEXT_TYPE:
|
178
|
+
var context = type;
|
179
|
+
return getContextName(context) + ".Consumer";
|
180
|
+
case REACT_PROVIDER_TYPE:
|
181
|
+
var provider = type;
|
182
|
+
return getContextName(provider._context) + ".Provider";
|
183
|
+
case REACT_FORWARD_REF_TYPE:
|
184
|
+
return getWrappedName(type, type.render, "ForwardRef");
|
185
|
+
case REACT_MEMO_TYPE:
|
186
|
+
var outerName = type.displayName || null;
|
187
|
+
if (outerName !== null) {
|
188
|
+
return outerName;
|
189
|
+
}
|
190
|
+
return getComponentNameFromType(type.type) || "Memo";
|
191
|
+
case REACT_LAZY_TYPE: {
|
192
|
+
var lazyComponent = type;
|
193
|
+
var payload = lazyComponent._payload;
|
194
|
+
var init = lazyComponent._init;
|
195
|
+
try {
|
196
|
+
return getComponentNameFromType(init(payload));
|
197
|
+
} catch (x) {
|
198
|
+
return null;
|
199
|
+
}
|
200
|
+
}
|
201
|
+
}
|
202
|
+
}
|
203
|
+
return null;
|
204
|
+
}
|
205
|
+
var assign = Object.assign;
|
206
|
+
var disabledDepth = 0;
|
207
|
+
var prevLog;
|
208
|
+
var prevInfo;
|
209
|
+
var prevWarn;
|
210
|
+
var prevError;
|
211
|
+
var prevGroup;
|
212
|
+
var prevGroupCollapsed;
|
213
|
+
var prevGroupEnd;
|
214
|
+
function disabledLog() {
|
215
|
+
}
|
216
|
+
disabledLog.__reactDisabledLog = true;
|
217
|
+
function disableLogs() {
|
218
|
+
{
|
219
|
+
if (disabledDepth === 0) {
|
220
|
+
prevLog = console.log;
|
221
|
+
prevInfo = console.info;
|
222
|
+
prevWarn = console.warn;
|
223
|
+
prevError = console.error;
|
224
|
+
prevGroup = console.group;
|
225
|
+
prevGroupCollapsed = console.groupCollapsed;
|
226
|
+
prevGroupEnd = console.groupEnd;
|
227
|
+
var props = {
|
228
|
+
configurable: true,
|
229
|
+
enumerable: true,
|
230
|
+
value: disabledLog,
|
231
|
+
writable: true
|
232
|
+
};
|
233
|
+
Object.defineProperties(console, {
|
234
|
+
info: props,
|
235
|
+
log: props,
|
236
|
+
warn: props,
|
237
|
+
error: props,
|
238
|
+
group: props,
|
239
|
+
groupCollapsed: props,
|
240
|
+
groupEnd: props
|
241
|
+
});
|
242
|
+
}
|
243
|
+
disabledDepth++;
|
244
|
+
}
|
245
|
+
}
|
246
|
+
function reenableLogs() {
|
247
|
+
{
|
248
|
+
disabledDepth--;
|
249
|
+
if (disabledDepth === 0) {
|
250
|
+
var props = {
|
251
|
+
configurable: true,
|
252
|
+
enumerable: true,
|
253
|
+
writable: true
|
254
|
+
};
|
255
|
+
Object.defineProperties(console, {
|
256
|
+
log: assign({}, props, {
|
257
|
+
value: prevLog
|
258
|
+
}),
|
259
|
+
info: assign({}, props, {
|
260
|
+
value: prevInfo
|
261
|
+
}),
|
262
|
+
warn: assign({}, props, {
|
263
|
+
value: prevWarn
|
264
|
+
}),
|
265
|
+
error: assign({}, props, {
|
266
|
+
value: prevError
|
267
|
+
}),
|
268
|
+
group: assign({}, props, {
|
269
|
+
value: prevGroup
|
270
|
+
}),
|
271
|
+
groupCollapsed: assign({}, props, {
|
272
|
+
value: prevGroupCollapsed
|
273
|
+
}),
|
274
|
+
groupEnd: assign({}, props, {
|
275
|
+
value: prevGroupEnd
|
276
|
+
})
|
277
|
+
});
|
278
|
+
}
|
279
|
+
if (disabledDepth < 0) {
|
280
|
+
error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
281
|
+
}
|
282
|
+
}
|
283
|
+
}
|
284
|
+
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
285
|
+
var prefix;
|
286
|
+
function describeBuiltInComponentFrame(name, source, ownerFn) {
|
287
|
+
{
|
288
|
+
if (prefix === void 0) {
|
289
|
+
try {
|
290
|
+
throw Error();
|
291
|
+
} catch (x) {
|
292
|
+
var match = x.stack.trim().match(/\n( *(at )?)/);
|
293
|
+
prefix = match && match[1] || "";
|
294
|
+
}
|
295
|
+
}
|
296
|
+
return "\n" + prefix + name;
|
297
|
+
}
|
298
|
+
}
|
299
|
+
var reentry = false;
|
300
|
+
var componentFrameCache;
|
301
|
+
{
|
302
|
+
var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
|
303
|
+
componentFrameCache = new PossiblyWeakMap();
|
304
|
+
}
|
305
|
+
function describeNativeComponentFrame(fn, construct) {
|
306
|
+
if (!fn || reentry) {
|
307
|
+
return "";
|
308
|
+
}
|
309
|
+
{
|
310
|
+
var frame = componentFrameCache.get(fn);
|
311
|
+
if (frame !== void 0) {
|
312
|
+
return frame;
|
313
|
+
}
|
314
|
+
}
|
315
|
+
var control;
|
316
|
+
reentry = true;
|
317
|
+
var previousPrepareStackTrace = Error.prepareStackTrace;
|
318
|
+
Error.prepareStackTrace = void 0;
|
319
|
+
var previousDispatcher;
|
320
|
+
{
|
321
|
+
previousDispatcher = ReactCurrentDispatcher.current;
|
322
|
+
ReactCurrentDispatcher.current = null;
|
323
|
+
disableLogs();
|
324
|
+
}
|
325
|
+
try {
|
326
|
+
if (construct) {
|
327
|
+
var Fake = function() {
|
328
|
+
throw Error();
|
329
|
+
};
|
330
|
+
Object.defineProperty(Fake.prototype, "props", {
|
331
|
+
set: function() {
|
332
|
+
throw Error();
|
333
|
+
}
|
334
|
+
});
|
335
|
+
if (typeof Reflect === "object" && Reflect.construct) {
|
336
|
+
try {
|
337
|
+
Reflect.construct(Fake, []);
|
338
|
+
} catch (x) {
|
339
|
+
control = x;
|
340
|
+
}
|
341
|
+
Reflect.construct(fn, [], Fake);
|
342
|
+
} else {
|
343
|
+
try {
|
344
|
+
Fake.call();
|
345
|
+
} catch (x) {
|
346
|
+
control = x;
|
347
|
+
}
|
348
|
+
fn.call(Fake.prototype);
|
349
|
+
}
|
350
|
+
} else {
|
351
|
+
try {
|
352
|
+
throw Error();
|
353
|
+
} catch (x) {
|
354
|
+
control = x;
|
355
|
+
}
|
356
|
+
fn();
|
357
|
+
}
|
358
|
+
} catch (sample) {
|
359
|
+
if (sample && control && typeof sample.stack === "string") {
|
360
|
+
var sampleLines = sample.stack.split("\n");
|
361
|
+
var controlLines = control.stack.split("\n");
|
362
|
+
var s = sampleLines.length - 1;
|
363
|
+
var c = controlLines.length - 1;
|
364
|
+
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
|
365
|
+
c--;
|
366
|
+
}
|
367
|
+
for (; s >= 1 && c >= 0; s--, c--) {
|
368
|
+
if (sampleLines[s] !== controlLines[c]) {
|
369
|
+
if (s !== 1 || c !== 1) {
|
370
|
+
do {
|
371
|
+
s--;
|
372
|
+
c--;
|
373
|
+
if (c < 0 || sampleLines[s] !== controlLines[c]) {
|
374
|
+
var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
|
375
|
+
if (fn.displayName && _frame.includes("<anonymous>")) {
|
376
|
+
_frame = _frame.replace("<anonymous>", fn.displayName);
|
377
|
+
}
|
378
|
+
{
|
379
|
+
if (typeof fn === "function") {
|
380
|
+
componentFrameCache.set(fn, _frame);
|
381
|
+
}
|
382
|
+
}
|
383
|
+
return _frame;
|
384
|
+
}
|
385
|
+
} while (s >= 1 && c >= 0);
|
386
|
+
}
|
387
|
+
break;
|
388
|
+
}
|
389
|
+
}
|
390
|
+
}
|
391
|
+
} finally {
|
392
|
+
reentry = false;
|
393
|
+
{
|
394
|
+
ReactCurrentDispatcher.current = previousDispatcher;
|
395
|
+
reenableLogs();
|
396
|
+
}
|
397
|
+
Error.prepareStackTrace = previousPrepareStackTrace;
|
398
|
+
}
|
399
|
+
var name = fn ? fn.displayName || fn.name : "";
|
400
|
+
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
|
401
|
+
{
|
402
|
+
if (typeof fn === "function") {
|
403
|
+
componentFrameCache.set(fn, syntheticFrame);
|
404
|
+
}
|
405
|
+
}
|
406
|
+
return syntheticFrame;
|
407
|
+
}
|
408
|
+
function describeFunctionComponentFrame(fn, source, ownerFn) {
|
409
|
+
{
|
410
|
+
return describeNativeComponentFrame(fn, false);
|
411
|
+
}
|
412
|
+
}
|
413
|
+
function shouldConstruct(Component) {
|
414
|
+
var prototype = Component.prototype;
|
415
|
+
return !!(prototype && prototype.isReactComponent);
|
416
|
+
}
|
417
|
+
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
418
|
+
if (type == null) {
|
419
|
+
return "";
|
420
|
+
}
|
421
|
+
if (typeof type === "function") {
|
422
|
+
{
|
423
|
+
return describeNativeComponentFrame(type, shouldConstruct(type));
|
424
|
+
}
|
425
|
+
}
|
426
|
+
if (typeof type === "string") {
|
427
|
+
return describeBuiltInComponentFrame(type);
|
428
|
+
}
|
429
|
+
switch (type) {
|
430
|
+
case REACT_SUSPENSE_TYPE:
|
431
|
+
return describeBuiltInComponentFrame("Suspense");
|
432
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
433
|
+
return describeBuiltInComponentFrame("SuspenseList");
|
434
|
+
}
|
435
|
+
if (typeof type === "object") {
|
436
|
+
switch (type.$$typeof) {
|
437
|
+
case REACT_FORWARD_REF_TYPE:
|
438
|
+
return describeFunctionComponentFrame(type.render);
|
439
|
+
case REACT_MEMO_TYPE:
|
440
|
+
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
|
441
|
+
case REACT_LAZY_TYPE: {
|
442
|
+
var lazyComponent = type;
|
443
|
+
var payload = lazyComponent._payload;
|
444
|
+
var init = lazyComponent._init;
|
445
|
+
try {
|
446
|
+
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
|
447
|
+
} catch (x) {
|
448
|
+
}
|
449
|
+
}
|
450
|
+
}
|
451
|
+
}
|
452
|
+
return "";
|
453
|
+
}
|
454
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
455
|
+
var loggedTypeFailures = {};
|
456
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
457
|
+
function setCurrentlyValidatingElement(element) {
|
458
|
+
{
|
459
|
+
if (element) {
|
460
|
+
var owner = element._owner;
|
461
|
+
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
462
|
+
ReactDebugCurrentFrame.setExtraStackFrame(stack);
|
463
|
+
} else {
|
464
|
+
ReactDebugCurrentFrame.setExtraStackFrame(null);
|
465
|
+
}
|
466
|
+
}
|
467
|
+
}
|
468
|
+
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
469
|
+
{
|
470
|
+
var has = Function.call.bind(hasOwnProperty);
|
471
|
+
for (var typeSpecName in typeSpecs) {
|
472
|
+
if (has(typeSpecs, typeSpecName)) {
|
473
|
+
var error$1 = void 0;
|
474
|
+
try {
|
475
|
+
if (typeof typeSpecs[typeSpecName] !== "function") {
|
476
|
+
var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
477
|
+
err.name = "Invariant Violation";
|
478
|
+
throw err;
|
479
|
+
}
|
480
|
+
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
481
|
+
} catch (ex) {
|
482
|
+
error$1 = ex;
|
483
|
+
}
|
484
|
+
if (error$1 && !(error$1 instanceof Error)) {
|
485
|
+
setCurrentlyValidatingElement(element);
|
486
|
+
error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
|
487
|
+
setCurrentlyValidatingElement(null);
|
488
|
+
}
|
489
|
+
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
490
|
+
loggedTypeFailures[error$1.message] = true;
|
491
|
+
setCurrentlyValidatingElement(element);
|
492
|
+
error("Failed %s type: %s", location, error$1.message);
|
493
|
+
setCurrentlyValidatingElement(null);
|
494
|
+
}
|
495
|
+
}
|
496
|
+
}
|
497
|
+
}
|
498
|
+
}
|
499
|
+
var isArrayImpl = Array.isArray;
|
500
|
+
function isArray(a) {
|
501
|
+
return isArrayImpl(a);
|
502
|
+
}
|
503
|
+
function typeName(value) {
|
504
|
+
{
|
505
|
+
var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
|
506
|
+
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
507
|
+
return type;
|
508
|
+
}
|
509
|
+
}
|
510
|
+
function willCoercionThrow(value) {
|
511
|
+
{
|
512
|
+
try {
|
513
|
+
testStringCoercion(value);
|
514
|
+
return false;
|
515
|
+
} catch (e) {
|
516
|
+
return true;
|
517
|
+
}
|
518
|
+
}
|
519
|
+
}
|
520
|
+
function testStringCoercion(value) {
|
521
|
+
return "" + value;
|
522
|
+
}
|
523
|
+
function checkKeyStringCoercion(value) {
|
524
|
+
{
|
525
|
+
if (willCoercionThrow(value)) {
|
526
|
+
error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
|
527
|
+
return testStringCoercion(value);
|
528
|
+
}
|
529
|
+
}
|
530
|
+
}
|
531
|
+
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
532
|
+
var RESERVED_PROPS = {
|
533
|
+
key: true,
|
534
|
+
ref: true,
|
535
|
+
__self: true,
|
536
|
+
__source: true
|
537
|
+
};
|
538
|
+
var specialPropKeyWarningShown;
|
539
|
+
var specialPropRefWarningShown;
|
540
|
+
var didWarnAboutStringRefs;
|
541
|
+
{
|
542
|
+
didWarnAboutStringRefs = {};
|
543
|
+
}
|
544
|
+
function hasValidRef(config) {
|
545
|
+
{
|
546
|
+
if (hasOwnProperty.call(config, "ref")) {
|
547
|
+
var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
|
548
|
+
if (getter && getter.isReactWarning) {
|
549
|
+
return false;
|
550
|
+
}
|
551
|
+
}
|
552
|
+
}
|
553
|
+
return config.ref !== void 0;
|
554
|
+
}
|
555
|
+
function hasValidKey(config) {
|
556
|
+
{
|
557
|
+
if (hasOwnProperty.call(config, "key")) {
|
558
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
559
|
+
if (getter && getter.isReactWarning) {
|
560
|
+
return false;
|
561
|
+
}
|
562
|
+
}
|
563
|
+
}
|
564
|
+
return config.key !== void 0;
|
565
|
+
}
|
566
|
+
function warnIfStringRefCannotBeAutoConverted(config, self2) {
|
567
|
+
{
|
568
|
+
if (typeof config.ref === "string" && ReactCurrentOwner.current && self2 && ReactCurrentOwner.current.stateNode !== self2) {
|
569
|
+
var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
|
570
|
+
if (!didWarnAboutStringRefs[componentName]) {
|
571
|
+
error('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
|
572
|
+
didWarnAboutStringRefs[componentName] = true;
|
573
|
+
}
|
574
|
+
}
|
575
|
+
}
|
576
|
+
}
|
577
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
578
|
+
{
|
579
|
+
var warnAboutAccessingKey = function() {
|
580
|
+
if (!specialPropKeyWarningShown) {
|
581
|
+
specialPropKeyWarningShown = true;
|
582
|
+
error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
|
583
|
+
}
|
584
|
+
};
|
585
|
+
warnAboutAccessingKey.isReactWarning = true;
|
586
|
+
Object.defineProperty(props, "key", {
|
587
|
+
get: warnAboutAccessingKey,
|
588
|
+
configurable: true
|
589
|
+
});
|
590
|
+
}
|
591
|
+
}
|
592
|
+
function defineRefPropWarningGetter(props, displayName) {
|
593
|
+
{
|
594
|
+
var warnAboutAccessingRef = function() {
|
595
|
+
if (!specialPropRefWarningShown) {
|
596
|
+
specialPropRefWarningShown = true;
|
597
|
+
error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
|
598
|
+
}
|
599
|
+
};
|
600
|
+
warnAboutAccessingRef.isReactWarning = true;
|
601
|
+
Object.defineProperty(props, "ref", {
|
602
|
+
get: warnAboutAccessingRef,
|
603
|
+
configurable: true
|
604
|
+
});
|
605
|
+
}
|
606
|
+
}
|
607
|
+
var ReactElement = function(type, key, ref, self2, source, owner, props) {
|
608
|
+
var element = {
|
609
|
+
// This tag allows us to uniquely identify this as a React Element
|
610
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
611
|
+
// Built-in properties that belong on the element
|
612
|
+
type,
|
613
|
+
key,
|
614
|
+
ref,
|
615
|
+
props,
|
616
|
+
// Record the component responsible for creating this element.
|
617
|
+
_owner: owner
|
618
|
+
};
|
619
|
+
{
|
620
|
+
element._store = {};
|
621
|
+
Object.defineProperty(element._store, "validated", {
|
622
|
+
configurable: false,
|
623
|
+
enumerable: false,
|
624
|
+
writable: true,
|
625
|
+
value: false
|
626
|
+
});
|
627
|
+
Object.defineProperty(element, "_self", {
|
628
|
+
configurable: false,
|
629
|
+
enumerable: false,
|
630
|
+
writable: false,
|
631
|
+
value: self2
|
632
|
+
});
|
633
|
+
Object.defineProperty(element, "_source", {
|
634
|
+
configurable: false,
|
635
|
+
enumerable: false,
|
636
|
+
writable: false,
|
637
|
+
value: source
|
638
|
+
});
|
639
|
+
if (Object.freeze) {
|
640
|
+
Object.freeze(element.props);
|
641
|
+
Object.freeze(element);
|
642
|
+
}
|
643
|
+
}
|
644
|
+
return element;
|
645
|
+
};
|
646
|
+
function jsxDEV(type, config, maybeKey, source, self2) {
|
647
|
+
{
|
648
|
+
var propName;
|
649
|
+
var props = {};
|
650
|
+
var key = null;
|
651
|
+
var ref = null;
|
652
|
+
if (maybeKey !== void 0) {
|
653
|
+
{
|
654
|
+
checkKeyStringCoercion(maybeKey);
|
655
|
+
}
|
656
|
+
key = "" + maybeKey;
|
657
|
+
}
|
658
|
+
if (hasValidKey(config)) {
|
659
|
+
{
|
660
|
+
checkKeyStringCoercion(config.key);
|
661
|
+
}
|
662
|
+
key = "" + config.key;
|
663
|
+
}
|
664
|
+
if (hasValidRef(config)) {
|
665
|
+
ref = config.ref;
|
666
|
+
warnIfStringRefCannotBeAutoConverted(config, self2);
|
667
|
+
}
|
668
|
+
for (propName in config) {
|
669
|
+
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
670
|
+
props[propName] = config[propName];
|
671
|
+
}
|
672
|
+
}
|
673
|
+
if (type && type.defaultProps) {
|
674
|
+
var defaultProps = type.defaultProps;
|
675
|
+
for (propName in defaultProps) {
|
676
|
+
if (props[propName] === void 0) {
|
677
|
+
props[propName] = defaultProps[propName];
|
678
|
+
}
|
679
|
+
}
|
680
|
+
}
|
681
|
+
if (key || ref) {
|
682
|
+
var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
|
683
|
+
if (key) {
|
684
|
+
defineKeyPropWarningGetter(props, displayName);
|
685
|
+
}
|
686
|
+
if (ref) {
|
687
|
+
defineRefPropWarningGetter(props, displayName);
|
688
|
+
}
|
689
|
+
}
|
690
|
+
return ReactElement(type, key, ref, self2, source, ReactCurrentOwner.current, props);
|
691
|
+
}
|
692
|
+
}
|
693
|
+
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
694
|
+
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
695
|
+
function setCurrentlyValidatingElement$1(element) {
|
696
|
+
{
|
697
|
+
if (element) {
|
698
|
+
var owner = element._owner;
|
699
|
+
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
700
|
+
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
|
701
|
+
} else {
|
702
|
+
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
|
703
|
+
}
|
704
|
+
}
|
705
|
+
}
|
706
|
+
var propTypesMisspellWarningShown;
|
707
|
+
{
|
708
|
+
propTypesMisspellWarningShown = false;
|
709
|
+
}
|
710
|
+
function isValidElement(object) {
|
711
|
+
{
|
712
|
+
return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
713
|
+
}
|
714
|
+
}
|
715
|
+
function getDeclarationErrorAddendum() {
|
716
|
+
{
|
717
|
+
if (ReactCurrentOwner$1.current) {
|
718
|
+
var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
|
719
|
+
if (name) {
|
720
|
+
return "\n\nCheck the render method of `" + name + "`.";
|
721
|
+
}
|
722
|
+
}
|
723
|
+
return "";
|
724
|
+
}
|
725
|
+
}
|
726
|
+
function getSourceInfoErrorAddendum(source) {
|
727
|
+
{
|
728
|
+
if (source !== void 0) {
|
729
|
+
var fileName = source.fileName.replace(/^.*[\\\/]/, "");
|
730
|
+
var lineNumber = source.lineNumber;
|
731
|
+
return "\n\nCheck your code at " + fileName + ":" + lineNumber + ".";
|
732
|
+
}
|
733
|
+
return "";
|
734
|
+
}
|
735
|
+
}
|
736
|
+
var ownerHasKeyUseWarning = {};
|
737
|
+
function getCurrentComponentErrorInfo(parentType) {
|
738
|
+
{
|
739
|
+
var info = getDeclarationErrorAddendum();
|
740
|
+
if (!info) {
|
741
|
+
var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
|
742
|
+
if (parentName) {
|
743
|
+
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
744
|
+
}
|
745
|
+
}
|
746
|
+
return info;
|
747
|
+
}
|
748
|
+
}
|
749
|
+
function validateExplicitKey(element, parentType) {
|
750
|
+
{
|
751
|
+
if (!element._store || element._store.validated || element.key != null) {
|
752
|
+
return;
|
753
|
+
}
|
754
|
+
element._store.validated = true;
|
755
|
+
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
756
|
+
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
757
|
+
return;
|
758
|
+
}
|
759
|
+
ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
760
|
+
var childOwner = "";
|
761
|
+
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
762
|
+
childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
|
763
|
+
}
|
764
|
+
setCurrentlyValidatingElement$1(element);
|
765
|
+
error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
766
|
+
setCurrentlyValidatingElement$1(null);
|
767
|
+
}
|
768
|
+
}
|
769
|
+
function validateChildKeys(node, parentType) {
|
770
|
+
{
|
771
|
+
if (typeof node !== "object") {
|
772
|
+
return;
|
773
|
+
}
|
774
|
+
if (isArray(node)) {
|
775
|
+
for (var i = 0; i < node.length; i++) {
|
776
|
+
var child = node[i];
|
777
|
+
if (isValidElement(child)) {
|
778
|
+
validateExplicitKey(child, parentType);
|
779
|
+
}
|
780
|
+
}
|
781
|
+
} else if (isValidElement(node)) {
|
782
|
+
if (node._store) {
|
783
|
+
node._store.validated = true;
|
784
|
+
}
|
785
|
+
} else if (node) {
|
786
|
+
var iteratorFn = getIteratorFn(node);
|
787
|
+
if (typeof iteratorFn === "function") {
|
788
|
+
if (iteratorFn !== node.entries) {
|
789
|
+
var iterator = iteratorFn.call(node);
|
790
|
+
var step;
|
791
|
+
while (!(step = iterator.next()).done) {
|
792
|
+
if (isValidElement(step.value)) {
|
793
|
+
validateExplicitKey(step.value, parentType);
|
794
|
+
}
|
795
|
+
}
|
796
|
+
}
|
797
|
+
}
|
798
|
+
}
|
799
|
+
}
|
800
|
+
}
|
801
|
+
function validatePropTypes(element) {
|
802
|
+
{
|
803
|
+
var type = element.type;
|
804
|
+
if (type === null || type === void 0 || typeof type === "string") {
|
805
|
+
return;
|
806
|
+
}
|
807
|
+
var propTypes;
|
808
|
+
if (typeof type === "function") {
|
809
|
+
propTypes = type.propTypes;
|
810
|
+
} else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
811
|
+
// Inner props are checked in the reconciler.
|
812
|
+
type.$$typeof === REACT_MEMO_TYPE)) {
|
813
|
+
propTypes = type.propTypes;
|
814
|
+
} else {
|
815
|
+
return;
|
816
|
+
}
|
817
|
+
if (propTypes) {
|
818
|
+
var name = getComponentNameFromType(type);
|
819
|
+
checkPropTypes(propTypes, element.props, "prop", name, element);
|
820
|
+
} else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
|
821
|
+
propTypesMisspellWarningShown = true;
|
822
|
+
var _name = getComponentNameFromType(type);
|
823
|
+
error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
|
824
|
+
}
|
825
|
+
if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
|
826
|
+
error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
827
|
+
}
|
828
|
+
}
|
829
|
+
}
|
830
|
+
function validateFragmentProps(fragment) {
|
831
|
+
{
|
832
|
+
var keys = Object.keys(fragment.props);
|
833
|
+
for (var i = 0; i < keys.length; i++) {
|
834
|
+
var key = keys[i];
|
835
|
+
if (key !== "children" && key !== "key") {
|
836
|
+
setCurrentlyValidatingElement$1(fragment);
|
837
|
+
error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
|
838
|
+
setCurrentlyValidatingElement$1(null);
|
839
|
+
break;
|
840
|
+
}
|
841
|
+
}
|
842
|
+
if (fragment.ref !== null) {
|
843
|
+
setCurrentlyValidatingElement$1(fragment);
|
844
|
+
error("Invalid attribute `ref` supplied to `React.Fragment`.");
|
845
|
+
setCurrentlyValidatingElement$1(null);
|
846
|
+
}
|
847
|
+
}
|
848
|
+
}
|
849
|
+
var didWarnAboutKeySpread = {};
|
850
|
+
function jsxWithValidation(type, props, key, isStaticChildren, source, self2) {
|
851
|
+
{
|
852
|
+
var validType = isValidElementType(type);
|
853
|
+
if (!validType) {
|
854
|
+
var info = "";
|
855
|
+
if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
|
856
|
+
info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
|
857
|
+
}
|
858
|
+
var sourceInfo = getSourceInfoErrorAddendum(source);
|
859
|
+
if (sourceInfo) {
|
860
|
+
info += sourceInfo;
|
861
|
+
} else {
|
862
|
+
info += getDeclarationErrorAddendum();
|
863
|
+
}
|
864
|
+
var typeString;
|
865
|
+
if (type === null) {
|
866
|
+
typeString = "null";
|
867
|
+
} else if (isArray(type)) {
|
868
|
+
typeString = "array";
|
869
|
+
} else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
|
870
|
+
typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
|
871
|
+
info = " Did you accidentally export a JSX literal instead of a component?";
|
872
|
+
} else {
|
873
|
+
typeString = typeof type;
|
874
|
+
}
|
875
|
+
error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
|
876
|
+
}
|
877
|
+
var element = jsxDEV(type, props, key, source, self2);
|
878
|
+
if (element == null) {
|
879
|
+
return element;
|
880
|
+
}
|
881
|
+
if (validType) {
|
882
|
+
var children = props.children;
|
883
|
+
if (children !== void 0) {
|
884
|
+
if (isStaticChildren) {
|
885
|
+
if (isArray(children)) {
|
886
|
+
for (var i = 0; i < children.length; i++) {
|
887
|
+
validateChildKeys(children[i], type);
|
888
|
+
}
|
889
|
+
if (Object.freeze) {
|
890
|
+
Object.freeze(children);
|
891
|
+
}
|
892
|
+
} else {
|
893
|
+
error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
894
|
+
}
|
895
|
+
} else {
|
896
|
+
validateChildKeys(children, type);
|
897
|
+
}
|
898
|
+
}
|
899
|
+
}
|
900
|
+
{
|
901
|
+
if (hasOwnProperty.call(props, "key")) {
|
902
|
+
var componentName = getComponentNameFromType(type);
|
903
|
+
var keys = Object.keys(props).filter(function(k) {
|
904
|
+
return k !== "key";
|
905
|
+
});
|
906
|
+
var beforeExample = keys.length > 0 ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
|
907
|
+
if (!didWarnAboutKeySpread[componentName + beforeExample]) {
|
908
|
+
var afterExample = keys.length > 0 ? "{" + keys.join(": ..., ") + ": ...}" : "{}";
|
909
|
+
error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
|
910
|
+
didWarnAboutKeySpread[componentName + beforeExample] = true;
|
911
|
+
}
|
912
|
+
}
|
913
|
+
}
|
914
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
915
|
+
validateFragmentProps(element);
|
916
|
+
} else {
|
917
|
+
validatePropTypes(element);
|
918
|
+
}
|
919
|
+
return element;
|
920
|
+
}
|
921
|
+
}
|
922
|
+
function jsxWithValidationStatic(type, props, key) {
|
923
|
+
{
|
924
|
+
return jsxWithValidation(type, props, key, true);
|
925
|
+
}
|
926
|
+
}
|
927
|
+
function jsxWithValidationDynamic(type, props, key) {
|
928
|
+
{
|
929
|
+
return jsxWithValidation(type, props, key, false);
|
930
|
+
}
|
931
|
+
}
|
932
|
+
var jsx = jsxWithValidationDynamic;
|
933
|
+
var jsxs = jsxWithValidationStatic;
|
934
|
+
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
935
|
+
reactJsxRuntime_development.jsx = jsx;
|
936
|
+
reactJsxRuntime_development.jsxs = jsxs;
|
937
|
+
})();
|
938
|
+
}
|
939
|
+
return reactJsxRuntime_development;
|
940
|
+
}
|
941
|
+
if (process.env.NODE_ENV === "production") {
|
942
|
+
jsxRuntime.exports = requireReactJsxRuntime_production_min();
|
943
|
+
} else {
|
944
|
+
jsxRuntime.exports = requireReactJsxRuntime_development();
|
945
|
+
}
|
946
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
947
|
+
const ThemeContext = require$$0.createContext();
|
948
|
+
const useTheme = () => require$$0.useContext(ThemeContext);
|
949
|
+
const ThemeProvider = ({ initialTheme = "light", children }) => {
|
950
|
+
const [theme, setTheme] = require$$0.useState(initialTheme);
|
951
|
+
const toggleTheme = () => {
|
952
|
+
setTheme((prevTheme) => prevTheme === "light" ? "dark" : "light");
|
953
|
+
};
|
954
|
+
require$$0.useEffect(() => {
|
955
|
+
document.documentElement.classList.remove("light", "dark");
|
956
|
+
document.documentElement.classList.add(theme);
|
957
|
+
}, [theme]);
|
958
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(ThemeContext.Provider, { value: { theme, setTheme, toggleTheme }, children });
|
959
|
+
};
|
960
|
+
let apiConfig = {
|
961
|
+
apiKey: null,
|
962
|
+
apiSecret: null,
|
963
|
+
apiUrl: "https://coinleyserver-production.up.railway.app"
|
964
|
+
};
|
965
|
+
const initializeApi = (config) => {
|
966
|
+
apiConfig = { ...apiConfig, ...config };
|
967
|
+
console.log("API initialized with:", apiConfig);
|
968
|
+
};
|
969
|
+
const getHeaders = () => {
|
970
|
+
return {
|
971
|
+
"Content-Type": "application/json",
|
972
|
+
"x-api-key": apiConfig.apiKey,
|
973
|
+
"x-api-secret": apiConfig.apiSecret
|
974
|
+
};
|
975
|
+
};
|
976
|
+
const createPayment = async (paymentData) => {
|
977
|
+
try {
|
978
|
+
console.log("Creating payment with data:", paymentData);
|
979
|
+
console.log("API URL:", `${apiConfig.apiUrl}/api/payments/create`);
|
980
|
+
const response = await fetch(`${apiConfig.apiUrl}/api/payments/create`, {
|
981
|
+
method: "POST",
|
982
|
+
headers: getHeaders(),
|
983
|
+
body: JSON.stringify(paymentData)
|
984
|
+
});
|
985
|
+
console.log("Create payment response status:", response.status);
|
986
|
+
if (!response.ok) {
|
987
|
+
const errorData = await response.json();
|
988
|
+
console.error("Error creating payment:", errorData);
|
989
|
+
throw new Error(errorData.error || `Failed to create payment: ${response.status}`);
|
990
|
+
}
|
991
|
+
const data = await response.json();
|
992
|
+
console.log("Create payment response data:", data);
|
993
|
+
return data;
|
994
|
+
} catch (error) {
|
995
|
+
console.error("Create payment error:", error);
|
996
|
+
throw error;
|
997
|
+
}
|
998
|
+
};
|
999
|
+
const getPayment = async (paymentId) => {
|
1000
|
+
try {
|
1001
|
+
console.log("Getting payment:", paymentId);
|
1002
|
+
const response = await fetch(`${apiConfig.apiUrl}/api/payments/${paymentId}`, {
|
1003
|
+
method: "GET",
|
1004
|
+
headers: getHeaders()
|
1005
|
+
});
|
1006
|
+
if (!response.ok) {
|
1007
|
+
const errorData = await response.json();
|
1008
|
+
console.error("Error getting payment:", errorData);
|
1009
|
+
throw new Error(errorData.error || `Failed to get payment: ${response.status}`);
|
1010
|
+
}
|
1011
|
+
const data = await response.json();
|
1012
|
+
console.log("Get payment response:", data);
|
1013
|
+
return data;
|
1014
|
+
} catch (error) {
|
1015
|
+
console.error("Get payment error:", error);
|
1016
|
+
throw error;
|
1017
|
+
}
|
1018
|
+
};
|
1019
|
+
const processPayment = async (processData) => {
|
1020
|
+
try {
|
1021
|
+
console.log("Processing payment with data:", processData);
|
1022
|
+
console.log("API URL:", `${apiConfig.apiUrl}/api/payments/process`);
|
1023
|
+
const response = await fetch(`${apiConfig.apiUrl}/api/payments/process`, {
|
1024
|
+
method: "POST",
|
1025
|
+
headers: getHeaders(),
|
1026
|
+
body: JSON.stringify(processData)
|
1027
|
+
});
|
1028
|
+
console.log("Process payment response status:", response.status);
|
1029
|
+
if (!response.ok) {
|
1030
|
+
const errorData = await response.json();
|
1031
|
+
console.error("Error processing payment:", errorData);
|
1032
|
+
throw new Error(errorData.error || `Failed to process payment: ${response.status}`);
|
1033
|
+
}
|
1034
|
+
const data = await response.json();
|
1035
|
+
console.log("Process payment response data:", data);
|
1036
|
+
return data;
|
1037
|
+
} catch (error) {
|
1038
|
+
console.error("Process payment error:", error);
|
1039
|
+
throw error;
|
1040
|
+
}
|
1041
|
+
};
|
1042
|
+
const getMerchantPayments = async (options = {}) => {
|
1043
|
+
try {
|
1044
|
+
const { page = 1, limit = 10, status, currency, startDate, endDate, search } = options;
|
1045
|
+
const queryParams = new URLSearchParams();
|
1046
|
+
queryParams.append("page", page);
|
1047
|
+
queryParams.append("limit", limit);
|
1048
|
+
if (status)
|
1049
|
+
queryParams.append("status", status);
|
1050
|
+
if (currency)
|
1051
|
+
queryParams.append("currency", currency);
|
1052
|
+
if (startDate)
|
1053
|
+
queryParams.append("startDate", startDate);
|
1054
|
+
if (endDate)
|
1055
|
+
queryParams.append("endDate", endDate);
|
1056
|
+
if (search)
|
1057
|
+
queryParams.append("search", search);
|
1058
|
+
const url = `${apiConfig.apiUrl}/api/payments/merchant/list?${queryParams.toString()}`;
|
1059
|
+
const response = await fetch(url, {
|
1060
|
+
method: "GET",
|
1061
|
+
headers: getHeaders()
|
1062
|
+
});
|
1063
|
+
if (!response.ok) {
|
1064
|
+
const errorData = await response.json();
|
1065
|
+
throw new Error(errorData.error || `Failed to get payments: ${response.status}`);
|
1066
|
+
}
|
1067
|
+
return await response.json();
|
1068
|
+
} catch (error) {
|
1069
|
+
console.error("Get merchant payments error:", error);
|
1070
|
+
throw error;
|
1071
|
+
}
|
1072
|
+
};
|
1073
|
+
const getMerchantPaymentStats = async () => {
|
1074
|
+
try {
|
1075
|
+
const response = await fetch(`${apiConfig.apiUrl}/api/payments/merchant/stats`, {
|
1076
|
+
method: "GET",
|
1077
|
+
headers: getHeaders()
|
1078
|
+
});
|
1079
|
+
if (!response.ok) {
|
1080
|
+
const errorData = await response.json();
|
1081
|
+
throw new Error(errorData.error || `Failed to get payment stats: ${response.status}`);
|
1082
|
+
}
|
1083
|
+
return await response.json();
|
1084
|
+
} catch (error) {
|
1085
|
+
console.error("Get merchant payment stats error:", error);
|
1086
|
+
throw error;
|
1087
|
+
}
|
1088
|
+
};
|
1089
|
+
const getSupportedCurrencies = async () => {
|
1090
|
+
try {
|
1091
|
+
const response = await fetch(`${apiConfig.apiUrl}/api/payments/currencies`, {
|
1092
|
+
method: "GET",
|
1093
|
+
headers: getHeaders()
|
1094
|
+
});
|
1095
|
+
if (!response.ok) {
|
1096
|
+
const errorData = await response.json();
|
1097
|
+
throw new Error(errorData.error || `Failed to get currencies: ${response.status}`);
|
1098
|
+
}
|
1099
|
+
return await response.json();
|
1100
|
+
} catch (error) {
|
1101
|
+
console.error("Get supported currencies error:", error);
|
1102
|
+
return {
|
1103
|
+
currencies: [
|
1104
|
+
{ id: "USDT", name: "Tether USD", network: "ethereum" },
|
1105
|
+
{ id: "USDC", name: "USD Coin", network: "ethereum" },
|
1106
|
+
{ id: "BNB", name: "Binance Coin", network: "binance" },
|
1107
|
+
{ id: "SOL", name: "Solana", network: "solana" },
|
1108
|
+
{ id: "USDC_SOL", name: "USD Coin (Solana)", network: "solana" }
|
1109
|
+
]
|
1110
|
+
};
|
1111
|
+
}
|
1112
|
+
};
|
1113
|
+
const CoinleyContext = require$$0.createContext();
|
1114
|
+
const useCoinley = () => require$$0.useContext(CoinleyContext);
|
1115
|
+
const CoinleyProvider = ({
|
1116
|
+
apiKey,
|
1117
|
+
apiSecret,
|
1118
|
+
apiUrl = "https://coinleyserver-production.up.railway.app",
|
1119
|
+
debug = false,
|
1120
|
+
children
|
1121
|
+
}) => {
|
1122
|
+
const [isInitialized, setIsInitialized] = require$$0.useState(false);
|
1123
|
+
const [error, setError] = require$$0.useState(null);
|
1124
|
+
require$$0.useEffect(() => {
|
1125
|
+
if (!apiKey || !apiSecret) {
|
1126
|
+
setError("API key and secret are required");
|
1127
|
+
return;
|
1128
|
+
}
|
1129
|
+
try {
|
1130
|
+
initializeApi({ apiKey, apiSecret, apiUrl });
|
1131
|
+
setIsInitialized(true);
|
1132
|
+
if (debug) {
|
1133
|
+
console.log("Coinley SDK initialized with:", { apiKey, apiUrl });
|
1134
|
+
}
|
1135
|
+
} catch (err) {
|
1136
|
+
setError(err.message);
|
1137
|
+
if (debug) {
|
1138
|
+
console.error("Coinley SDK initialization error:", err);
|
1139
|
+
}
|
1140
|
+
}
|
1141
|
+
}, [apiKey, apiSecret, apiUrl, debug]);
|
1142
|
+
const value = {
|
1143
|
+
apiKey,
|
1144
|
+
apiSecret,
|
1145
|
+
apiUrl,
|
1146
|
+
isInitialized,
|
1147
|
+
error,
|
1148
|
+
debug
|
1149
|
+
};
|
1150
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(CoinleyContext.Provider, { value, children });
|
1151
|
+
};
|
1152
|
+
const isMetaMaskInstalled = () => {
|
1153
|
+
return typeof window !== "undefined" && typeof window.ethereum !== "undefined";
|
1154
|
+
};
|
1155
|
+
const connectWallet = async () => {
|
1156
|
+
if (!isMetaMaskInstalled()) {
|
1157
|
+
throw new Error("MetaMask is not installed");
|
1158
|
+
}
|
1159
|
+
try {
|
1160
|
+
const accounts = await window.ethereum.request({ method: "eth_requestAccounts" });
|
1161
|
+
return accounts;
|
1162
|
+
} catch (error) {
|
1163
|
+
console.error("Error connecting to wallet:", error);
|
1164
|
+
throw error;
|
1165
|
+
}
|
1166
|
+
};
|
1167
|
+
const getAccounts = async () => {
|
1168
|
+
if (!isMetaMaskInstalled()) {
|
1169
|
+
throw new Error("MetaMask is not installed");
|
1170
|
+
}
|
1171
|
+
try {
|
1172
|
+
const accounts = await window.ethereum.request({ method: "eth_accounts" });
|
1173
|
+
return accounts;
|
1174
|
+
} catch (error) {
|
1175
|
+
console.error("Error getting accounts:", error);
|
1176
|
+
throw error;
|
1177
|
+
}
|
1178
|
+
};
|
1179
|
+
const getChainId = async () => {
|
1180
|
+
if (!isMetaMaskInstalled()) {
|
1181
|
+
throw new Error("MetaMask is not installed");
|
1182
|
+
}
|
1183
|
+
try {
|
1184
|
+
const chainId = await window.ethereum.request({ method: "eth_chainId" });
|
1185
|
+
return chainId;
|
1186
|
+
} catch (error) {
|
1187
|
+
console.error("Error getting chain ID:", error);
|
1188
|
+
throw error;
|
1189
|
+
}
|
1190
|
+
};
|
1191
|
+
const sendTransaction = async (txParams) => {
|
1192
|
+
if (!isMetaMaskInstalled()) {
|
1193
|
+
throw new Error("MetaMask is not installed");
|
1194
|
+
}
|
1195
|
+
try {
|
1196
|
+
const txHash = await window.ethereum.request({
|
1197
|
+
method: "eth_sendTransaction",
|
1198
|
+
params: [txParams]
|
1199
|
+
});
|
1200
|
+
return txHash;
|
1201
|
+
} catch (error) {
|
1202
|
+
console.error("Error sending transaction:", error);
|
1203
|
+
throw error;
|
1204
|
+
}
|
1205
|
+
};
|
1206
|
+
const sendToken = async (tokenAddress, toAddress, amount) => {
|
1207
|
+
if (!isMetaMaskInstalled()) {
|
1208
|
+
throw new Error("MetaMask is not installed");
|
1209
|
+
}
|
1210
|
+
try {
|
1211
|
+
const accounts = await window.ethereum.request({ method: "eth_requestAccounts" });
|
1212
|
+
const fromAddress = accounts[0];
|
1213
|
+
const transferFunctionSignature = "0xa9059cbb";
|
1214
|
+
const paddedToAddress = toAddress.slice(2).padStart(64, "0");
|
1215
|
+
const paddedAmount = amount.toString(16).padStart(64, "0");
|
1216
|
+
const data = `${transferFunctionSignature}${paddedToAddress}${paddedAmount}`;
|
1217
|
+
const txParams = {
|
1218
|
+
from: fromAddress,
|
1219
|
+
to: tokenAddress,
|
1220
|
+
data
|
1221
|
+
};
|
1222
|
+
const txHash = await window.ethereum.request({
|
1223
|
+
method: "eth_sendTransaction",
|
1224
|
+
params: [txParams]
|
1225
|
+
});
|
1226
|
+
return txHash;
|
1227
|
+
} catch (error) {
|
1228
|
+
console.error("Error sending token:", error);
|
1229
|
+
throw error;
|
1230
|
+
}
|
1231
|
+
};
|
1232
|
+
const isWalletConnected = async () => {
|
1233
|
+
try {
|
1234
|
+
const accounts = await getAccounts();
|
1235
|
+
return accounts.length > 0;
|
1236
|
+
} catch (error) {
|
1237
|
+
return false;
|
1238
|
+
}
|
1239
|
+
};
|
1240
|
+
const getNetworkName = (chainId) => {
|
1241
|
+
const networks = {
|
1242
|
+
"0x1": "Ethereum Mainnet",
|
1243
|
+
"0x3": "Ropsten Testnet",
|
1244
|
+
"0x4": "Rinkeby Testnet",
|
1245
|
+
"0x5": "Goerli Testnet",
|
1246
|
+
"0x2a": "Kovan Testnet",
|
1247
|
+
"0x38": "Binance Smart Chain",
|
1248
|
+
"0x89": "Polygon",
|
1249
|
+
"0xa86a": "Avalanche"
|
1250
|
+
};
|
1251
|
+
return networks[chainId] || `Unknown Network (${chainId})`;
|
1252
|
+
};
|
1253
|
+
const getTokenBalance = async (tokenAddress, userAddress) => {
|
1254
|
+
if (!isMetaMaskInstalled()) {
|
1255
|
+
throw new Error("MetaMask is not installed");
|
1256
|
+
}
|
1257
|
+
try {
|
1258
|
+
const balanceOfSignature = "0x70a08231";
|
1259
|
+
const paddedAddress = userAddress.slice(2).padStart(64, "0");
|
1260
|
+
const data = `${balanceOfSignature}${paddedAddress}`;
|
1261
|
+
const balance = await window.ethereum.request({
|
1262
|
+
method: "eth_call",
|
1263
|
+
params: [
|
1264
|
+
{
|
1265
|
+
to: tokenAddress,
|
1266
|
+
data
|
1267
|
+
},
|
1268
|
+
"latest"
|
1269
|
+
]
|
1270
|
+
});
|
1271
|
+
return parseInt(balance, 16).toString();
|
1272
|
+
} catch (error) {
|
1273
|
+
console.error("Error getting token balance:", error);
|
1274
|
+
throw error;
|
1275
|
+
}
|
1276
|
+
};
|
1277
|
+
const TOKEN_ADDRESSES = {
|
1278
|
+
USDT: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
1279
|
+
USDC: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
1280
|
+
DAI: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
|
1281
|
+
WETH: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
1282
|
+
WBTC: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599"
|
1283
|
+
};
|
1284
|
+
const QRCode$1 = ({ walletAddress, amount, currency, theme = "light" }) => {
|
1285
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center", children: [
|
1286
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `p-4 rounded-lg ${theme === "dark" ? "bg-gray-700" : "bg-white"} mb-3`, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { width: "200px", height: "200px", backgroundColor: "#f0f0f0", display: "flex", alignItems: "center", justifyContent: "center" }, children: [
|
1287
|
+
"QR Code: ",
|
1288
|
+
currency
|
1289
|
+
] }) }),
|
1290
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center text-sm", children: "Scan with your wallet app to pay" }),
|
1291
|
+
walletAddress && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3 w-full", children: [
|
1292
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs mb-1", children: [
|
1293
|
+
"Send ",
|
1294
|
+
amount,
|
1295
|
+
" ",
|
1296
|
+
currency,
|
1297
|
+
" to:"
|
1298
|
+
] }),
|
1299
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs font-mono p-2 rounded overflow-auto break-all bg-gray-100", children: walletAddress })
|
1300
|
+
] })
|
1301
|
+
] });
|
1302
|
+
};
|
1303
|
+
const QRCode$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
1304
|
+
__proto__: null,
|
1305
|
+
default: QRCode$1
|
1306
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
1307
|
+
const PaymentStatus = ({ status, theme = "light", message }) => {
|
1308
|
+
console.log("PaymentStatus render:", { status, message });
|
1309
|
+
const renderIcon = () => {
|
1310
|
+
switch (status) {
|
1311
|
+
case "processing":
|
1312
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20" });
|
1313
|
+
case "success":
|
1314
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-full h-12 w-12 bg-green-100 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1315
|
+
"svg",
|
1316
|
+
{
|
1317
|
+
xmlns: "http://www.w3.org/2000/svg",
|
1318
|
+
className: "h-8 w-8 text-green-500",
|
1319
|
+
fill: "none",
|
1320
|
+
viewBox: "0 0 24 24",
|
1321
|
+
stroke: "currentColor",
|
1322
|
+
strokeWidth: 2,
|
1323
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
|
1324
|
+
}
|
1325
|
+
) });
|
1326
|
+
case "error":
|
1327
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-full h-12 w-12 bg-red-100 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1328
|
+
"svg",
|
1329
|
+
{
|
1330
|
+
xmlns: "http://www.w3.org/2000/svg",
|
1331
|
+
className: "h-8 w-8 text-red-500",
|
1332
|
+
fill: "none",
|
1333
|
+
viewBox: "0 0 24 24",
|
1334
|
+
stroke: "currentColor",
|
1335
|
+
strokeWidth: 2,
|
1336
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
1337
|
+
}
|
1338
|
+
) });
|
1339
|
+
default:
|
1340
|
+
return null;
|
1341
|
+
}
|
1342
|
+
};
|
1343
|
+
const getStatusTitle = () => {
|
1344
|
+
switch (status) {
|
1345
|
+
case "processing":
|
1346
|
+
return "Processing Payment";
|
1347
|
+
case "success":
|
1348
|
+
return "Payment Successful";
|
1349
|
+
case "error":
|
1350
|
+
return "Payment Failed";
|
1351
|
+
default:
|
1352
|
+
return "Unknown Status";
|
1353
|
+
}
|
1354
|
+
};
|
1355
|
+
const getMessageClasses = () => {
|
1356
|
+
switch (status) {
|
1357
|
+
case "processing":
|
1358
|
+
return theme === "dark" ? "text-blue-300" : "text-blue-600";
|
1359
|
+
case "success":
|
1360
|
+
return theme === "dark" ? "text-green-300" : "text-green-600";
|
1361
|
+
case "error":
|
1362
|
+
return theme === "dark" ? "text-red-300" : "text-red-600";
|
1363
|
+
default:
|
1364
|
+
return theme === "dark" ? "text-gray-300" : "text-gray-600";
|
1365
|
+
}
|
1366
|
+
};
|
1367
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center justify-center py-6", children: [
|
1368
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: renderIcon() }),
|
1369
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `text-xl font-bold mb-2 ${theme === "dark" ? "text-white" : "text-gray-900"}`, children: getStatusTitle() }),
|
1370
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-center ${getMessageClasses()}`, children: message }),
|
1371
|
+
status === "processing" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `mt-4 text-xs ${theme === "dark" ? "text-gray-400" : "text-gray-500"}`, children: "This may take a few moments. Please do not close this window." }),
|
1372
|
+
status === "success" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `mt-4 p-2 rounded ${theme === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-xs ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: "Your payment has been successfully processed. You will receive a confirmation shortly." }) })
|
1373
|
+
] });
|
1374
|
+
};
|
1375
|
+
const PaymentMethods = ({ onSelect, selected, theme = "light" }) => {
|
1376
|
+
console.log("PaymentMethods render:", { selected });
|
1377
|
+
const paymentMethods = [
|
1378
|
+
{
|
1379
|
+
id: "USDT",
|
1380
|
+
name: "USDT",
|
1381
|
+
description: "Tether USD",
|
1382
|
+
logo: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48Y2lyY2xlIGN4PSIxNiIgY3k9IjE2IiByPSIxNiIgZmlsbD0iIzI2QTE3QiIvPjxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik0xNy45MjIgMTcuMzgzdi0uMDAyYy0uMTEuMDA4LS42NzcuMDQyLTEuOTQyLjA0Mi0xLjAxIDAtMS43MjEtLjAzLTEuOTcxLS4wNDJ2LjAwM2MtMy44ODgtLjE3MS02Ljc5LS44NDgtNi43OS0xLjY1OCAwLS44MDkgMi45MDItMS40ODYgNi43OS0xLjY2di4wNDdjLjI1NC4wMTguOTgyLjA0NSAxLjk4OC4wNDUgMS4yMDcgMCAxLjgxMi0uMDM2IDEuOTI1LS4wNDZ2LS4wNDRjMy44OC4xNzQgNi43NzUuODUxIDYuNzc1IDEuNjU4IDAgLjgwNy0yLjg5NSAxLjQ4N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IDAgMDAtNC41MzYgMGwtMi45NDItMi45NDFhNy42MjMgNy42MjMgMCAwMTEwLjQxOSAwek0xMC43OTEgMjIuMjYxbDIuOTQxLTIuOTQxYTMuMTMyIDMuMTMyIDAgMDA0LjUzNiAwbDIuOTQyIDIuOTQxYTcuNjIzIDcuNjIzIDAgMDEtMTAuNDE5IDB6bTExLjU3NS00LjI2MWgtNC4xNTNhMy4xMzMgMy4xMzMgMCAwMDAtNC41MzdoNC4xNTNhNy42MjEgNy42MjEgMCAwMTAgNC41Mzd6bS0xMy43OTMtNC41MzdoNC4xNTNhMy4xMzMgMy4xMzMgMCAwMDAgNC41MzdIOS42ODZhNy42MjEgNy42MjEgMCAwMTAtNC41Mzd6Ii8+PC9nPjwvc3ZnPg=="
|
1407
|
+
}
|
1408
|
+
];
|
1409
|
+
const handleSelectPaymentMethod = (id) => {
|
1410
|
+
console.log("Method selected:", id);
|
1411
|
+
onSelect(id);
|
1412
|
+
};
|
1413
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
1414
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `text-lg font-medium mb-3 ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "Select Payment Method" }),
|
1415
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: paymentMethods.map((method) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
1416
|
+
"button",
|
1417
|
+
{
|
1418
|
+
onClick: () => handleSelectPaymentMethod(method.id),
|
1419
|
+
className: `w-full flex items-center p-3 rounded-lg transition-colors ${selected === method.id ? theme === "dark" ? "bg-blue-900/30 border border-blue-500" : "bg-blue-50 border border-blue-500" : theme === "dark" ? "bg-gray-700 hover:bg-gray-600 border border-gray-700" : "bg-white hover:bg-gray-50 border border-gray-200"}`,
|
1420
|
+
children: [
|
1421
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mr-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: method.logo, alt: method.name, className: "h-6 w-6" }) }),
|
1422
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 text-left", children: [
|
1423
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: `font-medium ${theme === "dark" ? "text-white" : "text-gray-900"}`, children: method.name }),
|
1424
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-500"}`, children: method.description })
|
1425
|
+
] }),
|
1426
|
+
selected === method.id && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1427
|
+
"svg",
|
1428
|
+
{
|
1429
|
+
xmlns: "http://www.w3.org/2000/svg",
|
1430
|
+
className: "h-5 w-5 text-blue-500",
|
1431
|
+
viewBox: "0 0 20 20",
|
1432
|
+
fill: "currentColor",
|
1433
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1434
|
+
"path",
|
1435
|
+
{
|
1436
|
+
fillRule: "evenodd",
|
1437
|
+
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",
|
1438
|
+
clipRule: "evenodd"
|
1439
|
+
}
|
1440
|
+
)
|
1441
|
+
}
|
1442
|
+
)
|
1443
|
+
]
|
1444
|
+
},
|
1445
|
+
method.id
|
1446
|
+
)) })
|
1447
|
+
] });
|
1448
|
+
};
|
1449
|
+
const Logo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAAcCAYAAACqAXueAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAiaSURBVHgB7VrdddNIFL4zNuDAw2orQDQATgUoUABQAU4FOGcLiF0BpoI4FcQ0QLQVxAHOvqLtwDyQOBBr9rszI2n058jeBEh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YF+F8YPns2Zp2kUdU5ATz5FOpKuf2T6DNMtcovDztAnx9z2UGpVq0/vaqKFwdUetS5AC7RMbe6wqXTq8CnWpx4s4TRGVsdU3Wyf0rKke5PpWFG5liiFmpqPL0KjTSsxrr59ngYsG9pfny1WJu951z8HG85PozNRIug1OmUu0iKgqXUfyiw+e/IhFv/dkNhTKEabebFK/0hFvtNYR8wrsym27FpgBmaqjUvc1yznvaNxv3VJmzcrutRvVWqEFfEU5HXIlbwifZat1WtXATaJPv9MlyXxc5Ew2zOyh/d6Xe8SYDf+VBZo/VXh/jATa5jhd/JqVK+0UHm6gJzPea2qL3NB0NXEBwD6JmwtE+yx6cVzfdR/5V4JhBgt/YM/O9GzbkM2fubfk2KlLl94MV+XmRW2Ga77B83RQnKyX7TAcC5WBhzKesyaDXO1HWfIe0MjSDYaGNmkEzGdG1QTGaP7m4S2GDxsYJURVlQcDxAIHUQ+1z48V+Jhzp+OSFEWy8mECwdgXlfbYNsh6tF1Xfoh7GslnN9Z0btZay8MmOFkw5YpR2MKW3BCNLO0O0HZqP78QfVYP/jx2mW5TAmcbZYTHxsYFYVNer2XfRyobjxWh1cT607T7d4qejPsrO0EzAgv0u/HH4OBeGaxPO94Q6plv8FECovJc8uTjKNvgPcUpIo0ZgmzUAAAAASUVORK5CYII=";
|
1450
|
+
const QRCode = require$$0.lazy(() => Promise.resolve().then(() => QRCode$2));
|
1451
|
+
const CoinleyModal = ({
|
1452
|
+
isOpen,
|
1453
|
+
onClose,
|
1454
|
+
payment,
|
1455
|
+
paymentStatus,
|
1456
|
+
selectedCurrency,
|
1457
|
+
onCurrencySelect,
|
1458
|
+
onPayment,
|
1459
|
+
error,
|
1460
|
+
theme = "light",
|
1461
|
+
merchantName,
|
1462
|
+
transactionHash,
|
1463
|
+
walletConnected,
|
1464
|
+
onConnectWallet,
|
1465
|
+
testMode = false
|
1466
|
+
}) => {
|
1467
|
+
const [step, setStep] = require$$0.useState("select-currency");
|
1468
|
+
const [isMetaMaskAvailable, setIsMetaMaskAvailable] = require$$0.useState(false);
|
1469
|
+
const [paymentMethod, setPaymentMethod] = require$$0.useState("wallet");
|
1470
|
+
require$$0.useEffect(() => {
|
1471
|
+
if (typeof window !== "undefined") {
|
1472
|
+
setIsMetaMaskAvailable(isMetaMaskInstalled());
|
1473
|
+
}
|
1474
|
+
}, []);
|
1475
|
+
require$$0.useEffect(() => {
|
1476
|
+
if (paymentStatus === "loading") {
|
1477
|
+
setStep("processing");
|
1478
|
+
} else if (paymentStatus === "success") {
|
1479
|
+
setStep("success");
|
1480
|
+
} else if (paymentStatus === "error") {
|
1481
|
+
setStep("error");
|
1482
|
+
} else if (paymentStatus === "idle" && payment) {
|
1483
|
+
setStep("select-currency");
|
1484
|
+
}
|
1485
|
+
}, [paymentStatus, payment]);
|
1486
|
+
const handleCurrencySelect = (currency) => {
|
1487
|
+
onCurrencySelect(currency);
|
1488
|
+
setStep("confirm");
|
1489
|
+
};
|
1490
|
+
const handlePaymentConfirm = () => {
|
1491
|
+
onPayment(paymentMethod === "qrcode");
|
1492
|
+
};
|
1493
|
+
const handleBack = () => {
|
1494
|
+
if (step === "confirm") {
|
1495
|
+
setStep("select-currency");
|
1496
|
+
}
|
1497
|
+
};
|
1498
|
+
const handleClose = () => {
|
1499
|
+
onClose();
|
1500
|
+
};
|
1501
|
+
const formatAmount = (amount) => {
|
1502
|
+
return parseFloat(amount).toFixed(2);
|
1503
|
+
};
|
1504
|
+
const formatTransactionHash = (hash) => {
|
1505
|
+
if (!hash)
|
1506
|
+
return "";
|
1507
|
+
if (hash.length <= 14)
|
1508
|
+
return hash;
|
1509
|
+
return `${hash.slice(0, 8)}...${hash.slice(-6)}`;
|
1510
|
+
};
|
1511
|
+
const togglePaymentMethod = (method) => {
|
1512
|
+
setPaymentMethod(method);
|
1513
|
+
};
|
1514
|
+
const modalBaseClasses = `fixed inset-0 z-50 overflow-y-auto ${theme === "dark" ? "bg-gray-900/75" : "bg-black/50"}`;
|
1515
|
+
const modalContentClasses = `relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl ${theme === "dark" ? "bg-gray-800 text-white" : "bg-white text-gray-800"}`;
|
1516
|
+
const headerClasses = `text-xl font-bold mb-4 ${theme === "dark" ? "text-white" : "text-gray-900"}`;
|
1517
|
+
const buttonPrimaryClasses = `w-full py-2 px-4 rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 ${theme === "dark" ? "bg-blue-600 hover:bg-blue-700 text-white focus:ring-blue-500" : "bg-blue-500 hover:bg-blue-600 text-white focus:ring-blue-500"}`;
|
1518
|
+
const buttonSecondaryClasses = `w-full py-2 px-4 rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 ${theme === "dark" ? "bg-gray-700 hover:bg-gray-600 text-white focus:ring-gray-500" : "bg-gray-200 hover:bg-gray-300 text-gray-800 focus:ring-gray-500"}`;
|
1519
|
+
const tabButtonClasses = `py-2 px-4 text-sm font-medium focus:outline-none transition-colors`;
|
1520
|
+
const activeTabClasses = `${theme === "dark" ? "bg-gray-700 text-white" : "bg-gray-100 text-gray-800"} rounded-t-md`;
|
1521
|
+
const inactiveTabClasses = `${theme === "dark" ? "text-gray-400 hover:text-gray-300" : "text-gray-500 hover:text-gray-700"}`;
|
1522
|
+
if (!isOpen)
|
1523
|
+
return null;
|
1524
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: modalBaseClasses, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex min-h-screen items-center justify-center p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: modalContentClasses, children: [
|
1525
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center mb-6", children: [
|
1526
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
|
1527
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: Logo, alt: "Coinley Logo", className: "h-8 mr-2" }),
|
1528
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: headerClasses, children: "Coinley Pay" })
|
1529
|
+
] }),
|
1530
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1531
|
+
"button",
|
1532
|
+
{
|
1533
|
+
onClick: handleClose,
|
1534
|
+
className: `text-gray-500 hover:text-gray-700 focus:outline-none ${theme === "dark" ? "text-gray-400 hover:text-gray-300" : ""}`,
|
1535
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
1536
|
+
}
|
1537
|
+
)
|
1538
|
+
] }),
|
1539
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-6", children: [
|
1540
|
+
payment && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `mb-6 p-4 rounded-lg ${theme === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: [
|
1541
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: merchantName }),
|
1542
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center mt-2", children: [
|
1543
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `font-medium ${theme === "dark" ? "text-gray-300" : "text-gray-700"}`, children: "Amount:" }),
|
1544
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-bold text-xl", children: [
|
1545
|
+
"$",
|
1546
|
+
formatAmount(payment.totalAmount || payment.amount)
|
1547
|
+
] })
|
1548
|
+
] }),
|
1549
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs mt-1 text-right", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `${theme === "dark" ? "text-gray-400" : "text-gray-500"}`, children: [
|
1550
|
+
"Payment ID: ",
|
1551
|
+
payment.id.slice(0, 8),
|
1552
|
+
"..."
|
1553
|
+
] }) })
|
1554
|
+
] }),
|
1555
|
+
step === "select-currency" && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1556
|
+
PaymentMethods,
|
1557
|
+
{
|
1558
|
+
onSelect: handleCurrencySelect,
|
1559
|
+
selected: selectedCurrency,
|
1560
|
+
theme
|
1561
|
+
}
|
1562
|
+
),
|
1563
|
+
step === "confirm" && payment && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
1564
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: [
|
1565
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `text-lg font-medium mb-2 ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "Payment Details" }),
|
1566
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
1567
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
|
1568
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: theme === "dark" ? "text-gray-300" : "text-gray-600", children: "Currency:" }),
|
1569
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: selectedCurrency })
|
1570
|
+
] }),
|
1571
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
|
1572
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: theme === "dark" ? "text-gray-300" : "text-gray-600", children: "Network:" }),
|
1573
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: selectedCurrency === "SOL" || selectedCurrency === "USDC_SOL" ? "Solana" : "Ethereum" })
|
1574
|
+
] }),
|
1575
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
|
1576
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: theme === "dark" ? "text-gray-300" : "text-gray-600", children: "Fee:" }),
|
1577
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: "1.75%" })
|
1578
|
+
] })
|
1579
|
+
] })
|
1580
|
+
] }),
|
1581
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex border-b border-gray-200", children: [
|
1582
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1583
|
+
"button",
|
1584
|
+
{
|
1585
|
+
onClick: () => togglePaymentMethod("wallet"),
|
1586
|
+
className: `${tabButtonClasses} ${paymentMethod === "wallet" ? activeTabClasses : inactiveTabClasses}`,
|
1587
|
+
children: "Connect Wallet"
|
1588
|
+
}
|
1589
|
+
),
|
1590
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1591
|
+
"button",
|
1592
|
+
{
|
1593
|
+
onClick: () => togglePaymentMethod("qrcode"),
|
1594
|
+
className: `${tabButtonClasses} ${paymentMethod === "qrcode" ? activeTabClasses : inactiveTabClasses}`,
|
1595
|
+
children: "QR Code"
|
1596
|
+
}
|
1597
|
+
)
|
1598
|
+
] }) }),
|
1599
|
+
testMode ? (
|
1600
|
+
// Test mode payment option
|
1601
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-blue-900/20" : "bg-blue-50"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
|
1602
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bg-blue-500 rounded-full p-2 mr-3", children: /* @__PURE__ */ jsxRuntimeExports.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: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 10V3L4 14h7v7l9-11h-7z" }) }) }),
|
1603
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
1604
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `font-medium ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "Test Mode Payment" }),
|
1605
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: 'Click "Pay Now" to simulate a successful payment' })
|
1606
|
+
] })
|
1607
|
+
] }) })
|
1608
|
+
) : paymentMethod === "qrcode" ? (
|
1609
|
+
// QR Code payment option
|
1610
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-blue-900/20" : "bg-blue-50"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1611
|
+
QRCode,
|
1612
|
+
{
|
1613
|
+
walletAddress: payment.walletAddress || "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
|
1614
|
+
amount: payment.totalAmount || payment.amount,
|
1615
|
+
currency: selectedCurrency,
|
1616
|
+
theme
|
1617
|
+
}
|
1618
|
+
) })
|
1619
|
+
) : isMetaMaskAvailable ? (
|
1620
|
+
// MetaMask available option
|
1621
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-blue-900/20" : "bg-blue-50"}`, children: [
|
1622
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
|
1623
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1624
|
+
"img",
|
1625
|
+
{
|
1626
|
+
src: "https://metamask.io/images/metamask-fox.svg",
|
1627
|
+
alt: "MetaMask",
|
1628
|
+
className: "w-8 h-8 mr-2"
|
1629
|
+
}
|
1630
|
+
),
|
1631
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
1632
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `font-medium ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "Pay with MetaMask" }),
|
1633
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: walletConnected ? "Your wallet is connected. Click 'Pay Now' to proceed." : "Click 'Connect Wallet' to proceed with payment." })
|
1634
|
+
] })
|
1635
|
+
] }),
|
1636
|
+
!walletConnected && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1637
|
+
"button",
|
1638
|
+
{
|
1639
|
+
onClick: onConnectWallet,
|
1640
|
+
className: `mt-3 ${buttonPrimaryClasses}`,
|
1641
|
+
children: "Connect Wallet"
|
1642
|
+
}
|
1643
|
+
)
|
1644
|
+
] })
|
1645
|
+
) : (
|
1646
|
+
// MetaMask not available warning
|
1647
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-yellow-900/20" : "bg-yellow-50"}`, children: [
|
1648
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
|
1649
|
+
/* @__PURE__ */ jsxRuntimeExports.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: /* @__PURE__ */ jsxRuntimeExports.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" }) }),
|
1650
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
1651
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `font-medium ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "MetaMask Not Detected" }),
|
1652
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: "Please install MetaMask extension to make payments" })
|
1653
|
+
] })
|
1654
|
+
] }),
|
1655
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1656
|
+
"a",
|
1657
|
+
{
|
1658
|
+
href: "https://metamask.io/download/",
|
1659
|
+
target: "_blank",
|
1660
|
+
rel: "noopener noreferrer",
|
1661
|
+
className: `block mt-3 text-center ${buttonPrimaryClasses}`,
|
1662
|
+
children: "Install MetaMask"
|
1663
|
+
}
|
1664
|
+
)
|
1665
|
+
] })
|
1666
|
+
),
|
1667
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-6 grid grid-cols-2 gap-3", children: [
|
1668
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1669
|
+
"button",
|
1670
|
+
{
|
1671
|
+
type: "button",
|
1672
|
+
onClick: handleBack,
|
1673
|
+
className: buttonSecondaryClasses,
|
1674
|
+
children: "Back"
|
1675
|
+
}
|
1676
|
+
),
|
1677
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1678
|
+
"button",
|
1679
|
+
{
|
1680
|
+
type: "button",
|
1681
|
+
onClick: handlePaymentConfirm,
|
1682
|
+
className: buttonPrimaryClasses,
|
1683
|
+
disabled: !testMode && paymentMethod === "wallet" && isMetaMaskAvailable && !walletConnected,
|
1684
|
+
children: "Pay Now"
|
1685
|
+
}
|
1686
|
+
)
|
1687
|
+
] })
|
1688
|
+
] }),
|
1689
|
+
step === "processing" && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1690
|
+
PaymentStatus,
|
1691
|
+
{
|
1692
|
+
status: "processing",
|
1693
|
+
theme,
|
1694
|
+
message: "Processing your payment..."
|
1695
|
+
}
|
1696
|
+
),
|
1697
|
+
step === "success" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
1698
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1699
|
+
PaymentStatus,
|
1700
|
+
{
|
1701
|
+
status: "success",
|
1702
|
+
theme,
|
1703
|
+
message: "Payment successful!"
|
1704
|
+
}
|
1705
|
+
),
|
1706
|
+
transactionHash && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `mt-4 p-3 rounded-lg ${theme === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: [
|
1707
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-xs ${theme === "dark" ? "text-gray-300" : "text-gray-600"} mb-1`, children: "Transaction Hash:" }),
|
1708
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm font-mono break-all ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: formatTransactionHash(transactionHash) }),
|
1709
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1710
|
+
"a",
|
1711
|
+
{
|
1712
|
+
href: `https://etherscan.io/tx/${transactionHash}`,
|
1713
|
+
target: "_blank",
|
1714
|
+
rel: "noopener noreferrer",
|
1715
|
+
className: `text-xs ${theme === "dark" ? "text-blue-400" : "text-blue-600"} mt-2 inline-block`,
|
1716
|
+
children: "View on Etherscan →"
|
1717
|
+
}
|
1718
|
+
)
|
1719
|
+
] })
|
1720
|
+
] }),
|
1721
|
+
step === "error" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
1722
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1723
|
+
PaymentStatus,
|
1724
|
+
{
|
1725
|
+
status: "error",
|
1726
|
+
theme,
|
1727
|
+
message: error || "An error occurred while processing your payment."
|
1728
|
+
}
|
1729
|
+
),
|
1730
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1731
|
+
"button",
|
1732
|
+
{
|
1733
|
+
type: "button",
|
1734
|
+
onClick: handleBack,
|
1735
|
+
className: `mt-4 ${buttonSecondaryClasses}`,
|
1736
|
+
children: "Try Again"
|
1737
|
+
}
|
1738
|
+
)
|
1739
|
+
] })
|
1740
|
+
] }),
|
1741
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `text-center text-xs ${theme === "dark" ? "text-gray-400" : "text-gray-500"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "Powered by Coinley - Secure Cryptocurrency Payments" }) })
|
1742
|
+
] }) }) });
|
1743
|
+
};
|
1744
|
+
const CoinleyCheckout = require$$0.forwardRef(({
|
1745
|
+
apiKey,
|
1746
|
+
apiSecret,
|
1747
|
+
apiUrl,
|
1748
|
+
customerEmail,
|
1749
|
+
merchantName = "Merchant",
|
1750
|
+
onSuccess,
|
1751
|
+
onError,
|
1752
|
+
onClose,
|
1753
|
+
theme,
|
1754
|
+
autoOpen = false,
|
1755
|
+
debug = false,
|
1756
|
+
testMode = false
|
1757
|
+
}, ref) => {
|
1758
|
+
const coinleyContext = useCoinley();
|
1759
|
+
const { theme: contextTheme } = useTheme();
|
1760
|
+
const [isOpen, setIsOpen] = require$$0.useState(autoOpen);
|
1761
|
+
const [payment, setPayment] = require$$0.useState(null);
|
1762
|
+
const [paymentStatus, setPaymentStatus] = require$$0.useState("idle");
|
1763
|
+
const [selectedCurrency, setSelectedCurrency] = require$$0.useState("USDT");
|
1764
|
+
const [error, setError] = require$$0.useState(null);
|
1765
|
+
const [transactionHash, setTransactionHash] = require$$0.useState(null);
|
1766
|
+
const [walletConnected, setWalletConnected] = require$$0.useState(false);
|
1767
|
+
apiKey || (coinleyContext == null ? void 0 : coinleyContext.apiKey);
|
1768
|
+
apiSecret || (coinleyContext == null ? void 0 : coinleyContext.apiSecret);
|
1769
|
+
apiUrl || (coinleyContext == null ? void 0 : coinleyContext.apiUrl);
|
1770
|
+
const effectiveTheme = theme || contextTheme;
|
1771
|
+
const effectiveDebug = debug || (coinleyContext == null ? void 0 : coinleyContext.debug);
|
1772
|
+
require$$0.useImperativeHandle(ref, () => ({
|
1773
|
+
open: (paymentDetails) => {
|
1774
|
+
handleOpen(paymentDetails);
|
1775
|
+
},
|
1776
|
+
close: () => {
|
1777
|
+
handleClose();
|
1778
|
+
},
|
1779
|
+
getPayment: () => payment
|
1780
|
+
}));
|
1781
|
+
const log = (message, data) => {
|
1782
|
+
if (effectiveDebug) {
|
1783
|
+
console.log(`[Coinley SDK] ${message}`, data);
|
1784
|
+
}
|
1785
|
+
};
|
1786
|
+
require$$0.useEffect(() => {
|
1787
|
+
const checkWalletConnection = async () => {
|
1788
|
+
if (isMetaMaskInstalled()) {
|
1789
|
+
try {
|
1790
|
+
const accounts = await window.ethereum.request({ method: "eth_accounts" });
|
1791
|
+
setWalletConnected(accounts && accounts.length > 0);
|
1792
|
+
} catch (err) {
|
1793
|
+
log("Error checking wallet connection:", err);
|
1794
|
+
setWalletConnected(false);
|
1795
|
+
}
|
1796
|
+
} else {
|
1797
|
+
setWalletConnected(false);
|
1798
|
+
}
|
1799
|
+
};
|
1800
|
+
checkWalletConnection();
|
1801
|
+
}, []);
|
1802
|
+
require$$0.useEffect(() => {
|
1803
|
+
const handleAccountsChanged = (accounts) => {
|
1804
|
+
setWalletConnected(accounts.length > 0);
|
1805
|
+
};
|
1806
|
+
if (typeof window !== "undefined" && window.ethereum) {
|
1807
|
+
window.ethereum.on("accountsChanged", handleAccountsChanged);
|
1808
|
+
}
|
1809
|
+
return () => {
|
1810
|
+
if (typeof window !== "undefined" && window.ethereum) {
|
1811
|
+
window.ethereum.removeListener("accountsChanged", handleAccountsChanged);
|
1812
|
+
}
|
1813
|
+
};
|
1814
|
+
}, []);
|
1815
|
+
const handleOpen = async (paymentDetails) => {
|
1816
|
+
if (!paymentDetails || !paymentDetails.amount) {
|
1817
|
+
setError("Payment amount is required");
|
1818
|
+
if (onError)
|
1819
|
+
onError(new Error("Payment amount is required"));
|
1820
|
+
return;
|
1821
|
+
}
|
1822
|
+
setPaymentStatus("loading");
|
1823
|
+
setIsOpen(true);
|
1824
|
+
try {
|
1825
|
+
log("Creating payment with details:", paymentDetails);
|
1826
|
+
const paymentResponse = await createPayment({
|
1827
|
+
amount: paymentDetails.amount,
|
1828
|
+
currency: paymentDetails.currency || "USDT",
|
1829
|
+
customerEmail: paymentDetails.customerEmail || customerEmail,
|
1830
|
+
callbackUrl: paymentDetails.callbackUrl,
|
1831
|
+
metadata: paymentDetails.metadata || {}
|
1832
|
+
});
|
1833
|
+
log("Payment created:", paymentResponse);
|
1834
|
+
setPayment(paymentResponse.payment);
|
1835
|
+
setPaymentStatus("idle");
|
1836
|
+
setError(null);
|
1837
|
+
log("Payment created and state updated:", {
|
1838
|
+
payment: paymentResponse.payment,
|
1839
|
+
status: "idle"
|
1840
|
+
});
|
1841
|
+
} catch (err) {
|
1842
|
+
log("Error creating payment:", err);
|
1843
|
+
setError(err.message || "Failed to create payment");
|
1844
|
+
setPaymentStatus("error");
|
1845
|
+
if (onError)
|
1846
|
+
onError(err);
|
1847
|
+
}
|
1848
|
+
};
|
1849
|
+
const handleClose = () => {
|
1850
|
+
setIsOpen(false);
|
1851
|
+
setTransactionHash(null);
|
1852
|
+
if (onClose)
|
1853
|
+
onClose();
|
1854
|
+
};
|
1855
|
+
const handlePaymentMethodSelect = (currency) => {
|
1856
|
+
log("Currency selected:", currency);
|
1857
|
+
setSelectedCurrency(currency);
|
1858
|
+
};
|
1859
|
+
const connectToWallet = async () => {
|
1860
|
+
if (!isMetaMaskInstalled()) {
|
1861
|
+
setError("MetaMask is not installed. Please install MetaMask to make payments.");
|
1862
|
+
return false;
|
1863
|
+
}
|
1864
|
+
try {
|
1865
|
+
const accounts = await connectWallet();
|
1866
|
+
setWalletConnected(accounts.length > 0);
|
1867
|
+
return accounts.length > 0;
|
1868
|
+
} catch (err) {
|
1869
|
+
log("Error connecting to wallet:", err);
|
1870
|
+
setError(err.message || "Failed to connect to wallet");
|
1871
|
+
return false;
|
1872
|
+
}
|
1873
|
+
};
|
1874
|
+
const handlePayment = async (isQrCodeMode = false) => {
|
1875
|
+
if (!payment) {
|
1876
|
+
setError("No active payment to process");
|
1877
|
+
return;
|
1878
|
+
}
|
1879
|
+
log("Starting payment process...", { isQrCodeMode });
|
1880
|
+
setPaymentStatus("loading");
|
1881
|
+
setTransactionHash(null);
|
1882
|
+
try {
|
1883
|
+
log("Processing payment:", { paymentId: payment.id, currency: selectedCurrency, isQrCodeMode });
|
1884
|
+
let txHash;
|
1885
|
+
if (testMode) {
|
1886
|
+
log("Test mode: Generating mock transaction...");
|
1887
|
+
txHash = `0x${Array.from({ length: 64 }, () => Math.floor(Math.random() * 16).toString(16)).join("")}`;
|
1888
|
+
} else if (isQrCodeMode) {
|
1889
|
+
log("QR code payment: User confirms payment was sent");
|
1890
|
+
txHash = `qrcode_${Date.now().toString(16)}_${Math.random().toString(16).substring(2, 10)}`;
|
1891
|
+
} else {
|
1892
|
+
if (!walletConnected) {
|
1893
|
+
const connected = await connectToWallet();
|
1894
|
+
if (!connected) {
|
1895
|
+
throw new Error("Please connect your wallet to proceed with payment");
|
1896
|
+
}
|
1897
|
+
}
|
1898
|
+
const merchantAddress = payment.walletAddress || "0x742d35Cc6634C0532925a3b844Bc454e4438f44e";
|
1899
|
+
const txParams = {
|
1900
|
+
from: await window.ethereum.request({ method: "eth_requestAccounts" }).then((accounts) => accounts[0]),
|
1901
|
+
to: merchantAddress,
|
1902
|
+
value: "0x0",
|
1903
|
+
// For ERC-20 tokens, value is 0
|
1904
|
+
data: "0x"
|
1905
|
+
// Would include token transfer data for ERC-20
|
1906
|
+
};
|
1907
|
+
log("Sending transaction to wallet for approval...");
|
1908
|
+
txHash = await sendTransaction(txParams);
|
1909
|
+
}
|
1910
|
+
log("Transaction hash:", txHash);
|
1911
|
+
setTransactionHash(txHash);
|
1912
|
+
log("Sending process payment request to API...");
|
1913
|
+
const processResponse = await processPayment({
|
1914
|
+
paymentId: payment.id,
|
1915
|
+
transactionHash: txHash,
|
1916
|
+
network: selectedCurrency === "SOL" || selectedCurrency === "USDC_SOL" ? "solana" : "ethereum"
|
1917
|
+
});
|
1918
|
+
log("Payment processed successfully:", processResponse);
|
1919
|
+
setPaymentStatus("success");
|
1920
|
+
if (onSuccess) {
|
1921
|
+
log("Calling onSuccess callback...");
|
1922
|
+
onSuccess(payment.id, txHash);
|
1923
|
+
}
|
1924
|
+
} catch (err) {
|
1925
|
+
log("Payment error:", err);
|
1926
|
+
setError(err.message || "Failed to process payment");
|
1927
|
+
setPaymentStatus("error");
|
1928
|
+
if (onError)
|
1929
|
+
onError(err);
|
1930
|
+
}
|
1931
|
+
};
|
1932
|
+
require$$0.useEffect(() => {
|
1933
|
+
if (autoOpen && payment) {
|
1934
|
+
setIsOpen(true);
|
1935
|
+
}
|
1936
|
+
}, [autoOpen, payment]);
|
1937
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isOpen && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1938
|
+
CoinleyModal,
|
1939
|
+
{
|
1940
|
+
isOpen,
|
1941
|
+
onClose: handleClose,
|
1942
|
+
payment,
|
1943
|
+
paymentStatus,
|
1944
|
+
selectedCurrency,
|
1945
|
+
onCurrencySelect: handlePaymentMethodSelect,
|
1946
|
+
onPayment: handlePayment,
|
1947
|
+
error,
|
1948
|
+
theme: effectiveTheme,
|
1949
|
+
merchantName,
|
1950
|
+
transactionHash,
|
1951
|
+
walletConnected,
|
1952
|
+
onConnectWallet: connectToWallet,
|
1953
|
+
testMode
|
1954
|
+
}
|
1955
|
+
) });
|
1956
|
+
});
|
1957
|
+
CoinleyCheckout.displayName = "CoinleyCheckout";
|
1958
|
+
const styles = "";
|
1959
|
+
const DEFAULT_CONFIG = {
|
1960
|
+
apiUrl: "https://coinleyserver-production.up.railway.app",
|
1961
|
+
debug: false,
|
1962
|
+
testMode: false,
|
1963
|
+
theme: "light"
|
1964
|
+
};
|
1965
|
+
const VERSION = "1.0.4";
|
1966
|
+
exports2.CoinleyCheckout = CoinleyCheckout;
|
1967
|
+
exports2.CoinleyModal = CoinleyModal;
|
1968
|
+
exports2.CoinleyProvider = CoinleyProvider;
|
1969
|
+
exports2.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
1970
|
+
exports2.PaymentMethods = PaymentMethods;
|
1971
|
+
exports2.PaymentStatus = PaymentStatus;
|
1972
|
+
exports2.QRCode = QRCode$1;
|
1973
|
+
exports2.TOKEN_ADDRESSES = TOKEN_ADDRESSES;
|
1974
|
+
exports2.ThemeProvider = ThemeProvider;
|
1975
|
+
exports2.VERSION = VERSION;
|
1976
|
+
exports2.connectWallet = connectWallet;
|
1977
|
+
exports2.createPayment = createPayment;
|
1978
|
+
exports2.getAccounts = getAccounts;
|
1979
|
+
exports2.getChainId = getChainId;
|
1980
|
+
exports2.getMerchantPaymentStats = getMerchantPaymentStats;
|
1981
|
+
exports2.getMerchantPayments = getMerchantPayments;
|
1982
|
+
exports2.getNetworkName = getNetworkName;
|
1983
|
+
exports2.getPayment = getPayment;
|
1984
|
+
exports2.getSupportedCurrencies = getSupportedCurrencies;
|
1985
|
+
exports2.getTokenBalance = getTokenBalance;
|
1986
|
+
exports2.isMetaMaskInstalled = isMetaMaskInstalled;
|
1987
|
+
exports2.isWalletConnected = isWalletConnected;
|
1988
|
+
exports2.processPayment = processPayment;
|
1989
|
+
exports2.sendToken = sendToken;
|
1990
|
+
exports2.sendTransaction = sendTransaction;
|
1991
|
+
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
1992
|
+
});
|
1993
|
+
//# sourceMappingURL=coinley-checkout.umd.js.map
|