@cedros/pay-react
Version:
React frontend library for Cedros Pay - unified Stripe and Solana x402 payments
2 lines (1 loc) • 40.6 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),c=require("react"),V=require("@solana/wallet-adapter-react"),a=require("./styles-Dup9uK6S.js"),h=require("./CedrosContext-DbndTsTA.js"),ve=require("@solana/web3.js"),ue=require("@solana/wallet-adapter-base"),Ee=require("@solana/wallet-adapter-react-ui");require("@solana/wallet-adapter-wallets");function ke(e){switch(e){case"mainnet-beta":return"https://api.mainnet-beta.solana.com";case"devnet":return"https://api.devnet.solana.com";case"testnet":return"https://api.testnet.solana.com";default:return"https://api.mainnet-beta.solana.com"}}function Te(e){try{const s=new URL(e);return`${s.protocol}//${s.host}`}catch{return e}}function de(e={}){const{solanaCluster:s="mainnet-beta",solanaEndpoint:r,customRpcProviders:i=[],allowUnsafeScripts:g=!1,additionalScriptSrc:u=[],additionalConnectSrc:S=[],additionalFrameSrc:E=[],includeStripe:y=!0}=e,p=["'self'"];g&&p.push("'unsafe-inline'","'unsafe-eval'"),y&&p.push("https://js.stripe.com"),p.push(...u);const o=["'self'"];y&&o.push("https://api.stripe.com","https://*.stripe.com");const x=ke(s);if(o.push(x),o.push("https://*.solana.com"),r){const m=Te(r);o.includes(m)||o.push(m)}i.forEach(m=>{o.includes(m)||o.push(m)}),o.push(...S);const d=["'self'"];return y&&d.push("https://js.stripe.com","https://checkout.stripe.com"),d.push(...E),{scriptSrc:p,connectSrc:o,frameSrc:d}}function pe(e,s="header"){const{scriptSrc:r,connectSrc:i,frameSrc:g}=e;switch(s){case"header":case"meta":case"nextjs":case"nginx":{const u=[];return r.length>0&&u.push(`script-src ${r.join(" ")}`),i.length>0&&u.push(`connect-src ${i.join(" ")}`),g.length>0&&u.push(`frame-src ${g.join(" ")}`),u.join("; ")}case"helmet":{const u={};return r.length>0&&(u.scriptSrc=r),i.length>0&&(u.connectSrc=i),g.length>0&&(u.frameSrc=g),u}case"directives":return{scriptSrc:r,connectSrc:i,frameSrc:g};default:throw new Error(`Unknown CSP format: ${s}`)}}function Re(e={},s="header"){const r=de(e);return pe(r,s)}const je={HELIUS:"https://*.helius-rpc.com",QUICKNODE:"https://*.quicknode.pro",ALCHEMY:"https://*.alchemy.com",ANKR:"https://rpc.ankr.com",TRITON:"https://*.rpcpool.com"},Me={MAINNET_CUSTOM_RPC:e=>({solanaCluster:"mainnet-beta",solanaEndpoint:e,allowUnsafeScripts:!1}),MAINNET_NEXTJS:e=>({solanaCluster:"mainnet-beta",solanaEndpoint:e,allowUnsafeScripts:!0}),DEVNET:()=>({solanaCluster:"devnet",allowUnsafeScripts:!0}),CRYPTO_ONLY:e=>({solanaCluster:"mainnet-beta",solanaEndpoint:e,includeStripe:!1}),STRIPE_ONLY:()=>({solanaCluster:"mainnet-beta",includeStripe:!0,customRpcProviders:[]})},me=({resource:e,items:s,label:r,cardLabel:i,cryptoLabel:g,showCard:u=!0,showCrypto:S=!0,onPaymentAttempt:E,onPaymentSuccess:y,onPaymentError:p,onStripeSuccess:o,onCryptoSuccess:x,onStripeError:d,onCryptoError:m,customerEmail:n,successUrl:l,cancelUrl:f,metadata:P,couponCode:k,autoDetectWallets:b=!0,testPageUrl:I,hideMessages:B=!1,renderModal:R})=>{const M=h.useCedrosTheme(),[v,T]=c.useState(!1),{status:q,processPayment:j,processCartCheckout:D}=a.useStripeCheckout(),{isCartMode:N,effectiveResource:z}=a.usePaymentMode(e,s),{t:$}=a.useTranslation(),A=r||$("ui.purchase"),O=i||$("ui.card"),re=g||$("ui.usdc_solana"),X=c.useCallback(async()=>{if(b&&u){const{detectSolanaWallets:L}=await Promise.resolve().then(()=>require("./walletDetection-bNmV5ItZ.js"));if(!L()){const F=N?void 0:z,H=N&&s?a.getCartItemCount(s):void 0;a.emitPaymentStart("stripe",F,H),E&&E("stripe"),a.emitPaymentProcessing("stripe",F,H);let _;N&&s?_=await D(s,l,f,P,n,k):z&&(_=await j(z,l,f,P,n,k)),_&&_.success&&_.transactionId?(a.emitPaymentSuccess("stripe",_.transactionId,F,H),o?o(_.transactionId):y&&y(_.transactionId)):_&&!_.success&&_.error&&(a.emitPaymentError("stripe",_.error,F,H),d?d(_.error):p&&p(_.error));return}}T(!0)},[b,u,N,s,z,D,j,l,f,P,n,k,y,p,o,d,E]),Y=c.useMemo(()=>N&&s?`purchase-cart-${s.map(L=>L.resource).join("-")}`:`purchase-${z||"unknown"}`,[N,s,z]),J=c.useMemo(()=>a.createDedupedClickHandler(Y,X),[Y,X]),U=q==="loading",Z={isOpen:v,onClose:()=>T(!1),resource:N?void 0:z,items:N?s:void 0,cardLabel:O,cryptoLabel:re,showCard:u,showCrypto:S,onPaymentAttempt:E,onPaymentSuccess:L=>{T(!1),y?.(L)},onPaymentError:L=>{T(!1),p?.(L)},onStripeSuccess:L=>{T(!1),o?.(L)},onCryptoSuccess:L=>{T(!1),x?.(L)},onStripeError:L=>{T(!1),d?.(L)},onCryptoError:L=>{T(!1),m?.(L)},customerEmail:n,successUrl:l,cancelUrl:f,metadata:P,couponCode:k,testPageUrl:I,hideMessages:B};return t.jsxs("div",{className:M.unstyled?"":M.className,style:M.unstyled?{}:M.style,children:[t.jsx("button",{onClick:J,disabled:U,className:M.unstyled?"":"cedros-theme__button cedros-theme__stripe",style:{width:"100%",cursor:U?"not-allowed":"pointer",opacity:U?.6:1},type:"button",children:U?$("ui.processing"):A}),R?R(Z):t.jsx(a.PaymentModal,{...Z})]})};function Ie(e){const{resource:s,items:r,checkout:i={},display:g={},callbacks:u={},advanced:S={}}=e,{config:E,walletPool:y}=h.useCedrosContext(),p=h.useCedrosTheme(),{isCartMode:o}=a.usePaymentMode(s,r),x=c.useMemo(()=>({marginTop:"0.5rem",fontSize:"0.875rem",color:p.tokens.surfaceText,opacity:.7,textAlign:"center"}),[p.tokens.surfaceText]),d=c.useMemo(()=>S.wallets&&S.wallets.length>0?S.wallets:y.getAdapters(),[S.wallets,y]),m=c.useMemo(()=>r?a.getCartItemCount(r):0,[r]),n=c.useMemo(()=>u.onPaymentSuccess?T=>u.onPaymentSuccess({transactionId:T,method:"stripe"}):void 0,[u.onPaymentSuccess]),l=c.useMemo(()=>u.onPaymentSuccess?T=>u.onPaymentSuccess({transactionId:T,method:"crypto"}):void 0,[u.onPaymentSuccess]),f=c.useMemo(()=>u.onPaymentError?T=>u.onPaymentError({message:T,method:"stripe"}):void 0,[u.onPaymentError]),P=c.useMemo(()=>u.onPaymentError?T=>u.onPaymentError({message:T,method:"crypto"}):void 0,[u.onPaymentError]),k=E.solanaEndpoint??ve.clusterApiUrl(E.solanaCluster);if(!s&&(!r||r.length===0))return h.getLogger().error('CedrosPay: Must provide either "resource" or "items" prop'),t.jsx("div",{className:g.className,style:{color:p.tokens.errorText},children:"Configuration error: No resource or items provided"});const b=g.showCard??!0,I=g.showCrypto??!0,B=g.showPurchaseButton??!1,R=g.layout??"vertical",M=g.hideMessages??!1,v=S.autoDetectWallets??!0;return t.jsx("div",{className:p.unstyled?g.className:p.className,style:p.unstyled?{}:p.style,children:t.jsx(V.ConnectionProvider,{endpoint:k,children:t.jsx(V.WalletProvider,{wallets:d,autoConnect:!1,children:t.jsx("div",{className:p.unstyled?g.className:`cedros-theme__pay ${g.className||""}`,children:t.jsxs("div",{className:p.unstyled?"":`cedros-theme__pay-content cedros-theme__pay-content--${R}`,children:[B?t.jsx(me,{resource:o?void 0:s||r?.[0]?.resource,items:o?r:void 0,label:g.purchaseLabel,cardLabel:g.cardLabel,cryptoLabel:g.cryptoLabel,showCard:b,showCrypto:I,onPaymentAttempt:u.onPaymentAttempt,onPaymentSuccess:n,onPaymentError:f,onStripeSuccess:n,onCryptoSuccess:l,onStripeError:f,onCryptoError:P,customerEmail:i.customerEmail,successUrl:i.successUrl,cancelUrl:i.cancelUrl,metadata:i.metadata,couponCode:i.couponCode,autoDetectWallets:v,testPageUrl:S.testPageUrl,hideMessages:M,renderModal:g.renderModal}):t.jsxs(t.Fragment,{children:[b&&t.jsx(a.StripeButton,{resource:o?void 0:s||r?.[0]?.resource,items:o?r:void 0,customerEmail:i.customerEmail,successUrl:i.successUrl,cancelUrl:i.cancelUrl,metadata:i.metadata,couponCode:i.couponCode,label:g.cardLabel,onAttempt:u.onPaymentAttempt,onSuccess:n,onError:f}),I&&t.jsx(a.CryptoButton,{resource:o?void 0:s||r?.[0]?.resource,items:o?r:void 0,metadata:i.metadata,couponCode:i.couponCode,label:g.cryptoLabel,onAttempt:u.onPaymentAttempt,onSuccess:l,onError:P,testPageUrl:S.testPageUrl,hideMessages:M})]}),o&&r&&r.length>1&&!M&&t.jsxs("div",{style:x,children:["Checking out ",m," items"]})]})})})})})}function fe(){const{subscriptionManager:e}=h.useCedrosContext(),[s,r]=c.useState({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null}),i=c.useCallback(async E=>{r(p=>({...p,status:"loading",error:null}));const y=await e.processSubscription(E);return r(p=>({...p,status:y.success?"success":"error",error:y.success?null:y.error||"Subscription failed",sessionId:y.success&&y.transactionId||null})),y},[e]),g=c.useCallback(async E=>{r(y=>({...y,status:"checking",error:null}));try{const y=await e.checkSubscriptionStatus(E);return r(p=>({...p,status:y.active?"success":"idle",subscriptionStatus:y.status,expiresAt:y.expiresAt||y.currentPeriodEnd||null})),y}catch(y){const p=y instanceof Error?y.message:"Failed to check subscription status";throw r(o=>({...o,status:"error",error:p})),y}},[e]),u=c.useCallback(async(E,y,p)=>{r(o=>({...o,status:"loading",error:null}));try{const o=await e.requestSubscriptionQuote(E,y,p);return r(x=>({...x,status:"idle"})),o}catch(o){const x=o instanceof Error?o.message:"Failed to get subscription quote";throw r(d=>({...d,status:"error",error:x})),o}},[e]),S=c.useCallback(()=>{r({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null})},[]);return{...s,processSubscription:i,checkStatus:g,requestQuote:u,reset:S}}function Be({resource:e,interval:s,intervalDays:r,trialDays:i,successUrl:g,cancelUrl:u,metadata:S,customerEmail:E,couponCode:y,label:p,disabled:o=!1,onAttempt:x,onSuccess:d,onError:m,className:n=""}){const{status:l,error:f,sessionId:P,processSubscription:k}=fe(),b=h.useCedrosTheme(),{t:I,translations:B}=a.useTranslation(),R=p||I("ui.subscribe"),M=b.unstyled?n:`${b.className} cedros-theme__stripe-button ${n}`.trim(),v=f&&typeof f!="string"?f?.code??null:null,q=f?typeof f=="string"?f:(A=>{if(!A||!B)return"";const O=B.errors[A];return O?O.action?`${O.message} ${O.action}`:O.message:""})(v):null,j=c.useCallback(async()=>{h.getLogger().debug("[SubscribeButton] executeSubscription:",{resource:e,interval:s,intervalDays:r,trialDays:i,couponCode:y}),a.emitPaymentStart("stripe",e),x&&x("stripe"),a.emitPaymentProcessing("stripe",e);const A=await k({resource:e,interval:s,intervalDays:r,trialDays:i,customerEmail:E,metadata:S,couponCode:y,successUrl:g,cancelUrl:u});A.success&&A.transactionId?(a.emitPaymentSuccess("stripe",A.transactionId,e),d&&d(A.transactionId)):!A.success&&A.error&&(a.emitPaymentError("stripe",A.error,e),m&&m(A.error))},[e,s,r,i,E,S,y,g,u,k,x,d,m]),D=c.useMemo(()=>`subscribe-${e}-${s}`,[e,s]),N=c.useMemo(()=>a.createDedupedClickHandler(D,j),[D,j]),z=l==="loading",$=o||z;return t.jsxs("div",{className:M,style:b.unstyled?{}:b.style,children:[t.jsx("button",{onClick:N,disabled:$,className:b.unstyled?n:"cedros-theme__button cedros-theme__stripe",type:"button",children:z?I("ui.processing"):R}),q&&t.jsx("div",{className:b.unstyled?"":"cedros-theme__error",children:q}),P&&t.jsx("div",{className:b.unstyled?"":"cedros-theme__success",children:I("ui.redirecting_to_checkout")})]})}function ge(){const{subscriptionManager:e,x402Manager:s,walletManager:r}=h.useCedrosContext(),{publicKey:i,signTransaction:g}=V.useWallet(),[u,S]=c.useState({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null}),[E,y]=c.useState(null),p=c.useCallback(()=>{if(!i){const n="Wallet not connected";return S(l=>({...l,status:"error",error:n})),{valid:!1,error:n}}if(!g){const n="Wallet does not support signing";return S(l=>({...l,status:"error",error:n})),{valid:!1,error:n}}return{valid:!0}},[i,g]),o=c.useCallback(async n=>{if(!i)return S(l=>({...l,status:"error",error:"Wallet not connected"})),null;S(l=>({...l,status:"checking",error:null}));try{const l=await e.checkSubscriptionStatus({resource:n,userId:i.toString()});return S(f=>({...f,status:l.active?"success":"idle",subscriptionStatus:l.status,expiresAt:l.expiresAt||l.currentPeriodEnd||null})),l}catch(l){const f=h.formatError(l,"Failed to check subscription status");return S(P=>({...P,status:"error",error:f})),null}},[i,e]),x=c.useCallback(async(n,l,f)=>{S(P=>({...P,status:"loading",error:null}));try{const P=await e.requestSubscriptionQuote(n,l,f);return y(P),S(k=>({...k,status:"idle"})),P}catch(P){const k=h.formatError(P,"Failed to get subscription quote");return S(b=>({...b,status:"error",error:k})),null}},[e]),d=c.useCallback(async(n,l,f)=>{const P=p();if(!P.valid)return{success:!1,error:P.error};S(k=>({...k,status:"loading",error:null}));try{const k=await e.requestSubscriptionQuote(n,l,f);y(k);const b=k.requirement;if(!s.validateRequirement(b))throw new Error("Invalid subscription quote received from server");const I=!!b.extra?.feePayer;let B;if(I){const{transaction:R,blockhash:M}=await s.buildGaslessTransaction({resourceId:n,userWallet:i.toString(),feePayer:b.extra.feePayer,couponCode:f?.couponCode}),v=r.deserializeTransaction(R),T=await r.partiallySignTransaction({transaction:v,signTransaction:g,blockhash:M});B=await s.submitGaslessTransaction({resource:n,partialTx:T,couponCode:f?.couponCode,resourceType:"regular",requirement:b})}else{const R=await r.buildTransaction({requirement:b,payerPublicKey:i}),M=await r.signTransaction({transaction:R,signTransaction:g}),v=r.buildPaymentPayload({requirement:b,signedTx:M,payerPublicKey:i});B=await s.submitPayment({resource:n,payload:v,couponCode:f?.couponCode,resourceType:"regular"})}if(B.success){const R=await e.checkSubscriptionStatus({resource:n,userId:i.toString()});S({status:"success",error:null,sessionId:B.transactionId||null,subscriptionStatus:R.status,expiresAt:R.expiresAt||R.currentPeriodEnd||null})}else S(R=>({...R,status:"error",error:B.error||"Subscription payment failed"}));return B}catch(k){const b=h.formatError(k,"Subscription payment failed");return S(I=>({...I,status:"error",error:b})),{success:!1,error:b}}},[p,e,s,r,i,g]),m=c.useCallback(()=>{S({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null}),y(null)},[]);return{...u,quote:E,checkStatus:o,requestQuote:x,processPayment:d,reset:m}}function _e({resource:e,interval:s,intervalDays:r,couponCode:i,label:g,disabled:u=!1,onAttempt:S,onSuccess:E,onError:y,className:p="",testPageUrl:o,hideMessages:x=!1,autoCheckStatus:d=!0}){const{connected:m,connecting:n,connect:l,disconnect:f,select:P,wallets:k,wallet:b,publicKey:I}=V.useWallet(),{status:B,error:R,subscriptionStatus:M,expiresAt:v,checkStatus:T,processPayment:q}=ge(),j=h.useCedrosTheme(),{solanaError:D}=h.useCedrosContext(),{t:N,translations:z}=a.useTranslation(),$=g||N("ui.subscribe_with_crypto"),A=c.useRef(q),O=c.useRef(T);c.useEffect(()=>{A.current=q,O.current=T},[q,T]);const re=R&&typeof R!="string"?R?.code??null:null,X=D&&typeof D!="string"?D?.code??null:null,Y=w=>{if(!w||!z)return"";const W=z.errors[w];return W?W.action?`${W.message} ${W.action}`:W.message:""},J=R?typeof R=="string"?R:Y(re):null,U=D?typeof D=="string"?D:Y(X):null,Z=c.useMemo(()=>k.map(w=>`${w.adapter.name}-${w.readyState}`).join(","),[k]),L=c.useMemo(()=>k.filter(({readyState:w})=>w===ue.WalletReadyState.Installed||w===ue.WalletReadyState.Loadable),[Z]);c.useEffect(()=>{d&&m&&I&&(h.getLogger().debug("[CryptoSubscribeButton] Auto-checking subscription status"),O.current(e))},[d,m,I,e]),c.useEffect(()=>{B==="success"&&M==="active"&&(a.emitPaymentSuccess("crypto","subscription-active",e),E&&E("subscription-active"))},[B,M,e,E]),c.useEffect(()=>{B==="error"&&R&&(a.emitPaymentError("crypto",R,e),y&&y(R))},[B,R,e,y]);const F=typeof window<"u"&&window.top!==window.self,[H,_]=c.useState(!1),[oe,se]=c.useState(!1),[ae,Q]=c.useState(!1),G=D;c.useEffect(()=>{let w=!1;return w||(async()=>{if(oe&&b&&!m&&!n){h.getLogger().debug("[CryptoSubscribeButton] Wallet detected, attempting auto-connect:",b.adapter.name),se(!1),a.emitWalletConnect(b.adapter.name);try{await l(),w||h.getLogger().debug("[CryptoSubscribeButton] Auto-connect successful")}catch(ne){if(!w){h.getLogger().error("[CryptoSubscribeButton] Auto-connect failed:",ne);const Pe=ne instanceof Error?ne.message:"Failed to connect wallet";a.emitWalletError(Pe,b.adapter.name),Q(!1)}}}})(),()=>{w=!0}},[b,oe,m,n,l]),c.useEffect(()=>{m&&ae&&I&&b&&(a.emitWalletConnected(b.adapter.name,I.toString()),h.getLogger().debug("[CryptoSubscribeButton] Processing pending subscription payment"),Q(!1),_(!1),a.emitPaymentProcessing("crypto",e),A.current(e,s,{couponCode:i,intervalDays:r}))},[m,ae,I,b,e,s,i,r]);const ie=c.useCallback(async()=>{if(h.getLogger().debug("[CryptoSubscribeButton] executeSubscriptionFlow called",{connected:m,wallet:b?.adapter.name,resource:e,interval:s}),a.emitPaymentStart("crypto",e),S&&S("crypto"),G){h.getLogger().error("[CryptoSubscribeButton] Solana dependencies missing:",G),a.emitPaymentError("crypto",G,e),y&&y(G);return}if(F){const w=o||window.location.href;window.open(w,"_blank","noopener,noreferrer");return}if(m)a.emitPaymentProcessing("crypto",e),await q(e,s,{couponCode:i,intervalDays:r});else{Q(!0);try{if(b)h.getLogger().debug("[CryptoSubscribeButton] Wallet already selected, connecting:",b.adapter.name),a.emitWalletConnect(b.adapter.name),await l();else{if(h.getLogger().debug("[CryptoSubscribeButton] No wallet selected, showing selector"),L.length===0){Q(!1);const w="No wallets available";throw a.emitWalletError(w),new Error(w)}_(!0)}}catch(w){Q(!1);const W=w instanceof Error?w.message:"Failed to connect wallet";h.getLogger().error("[CryptoSubscribeButton] Connection error:",W),a.emitWalletError(W,b?.adapter.name)}}},[m,b,e,s,i,r,F,o,L,l,q,G,S,y]),ce=c.useMemo(()=>`crypto-subscribe-${e}-${s}`,[e,s]),he=c.useMemo(()=>a.createDedupedClickHandler(ce,ie,{cooldownMs:200,deduplicationWindowMs:0}),[ce,ie]),le=B==="loading"||B==="checking",ee=M==="active"||M==="trialing",Ce=u||le||n||!!G||ee;let te=$;if(le)te=N("ui.processing");else if(ee&&v){const w=new Date(v).toLocaleDateString();te=`${N("ui.subscribed_until")} ${w}`}else ee&&(te=N("ui.subscribed"));const Se=c.useCallback(async()=>{try{se(!1),m&&await f(),P(null),_(!0)}catch(w){h.getLogger().error("Failed to change wallet:",w)}},[m,f,P]),xe=c.useCallback(w=>{h.getLogger().debug("[CryptoSubscribeButton] Wallet clicked:",w),_(!1),P(w),se(!0)},[P]),we=c.useCallback(async()=>{try{await f(),Q(!1),typeof window<"u"&&window.localStorage&&window.localStorage.removeItem("walletName")}catch(w){h.getLogger().error("Failed to disconnect wallet:",w)}},[f]);return t.jsxs("div",{className:j.unstyled?p:`${j.className} cedros-theme__crypto-button ${p||""}`,style:j.unstyled?{}:j.style,children:[t.jsx("button",{onClick:he,disabled:Ce,className:j.unstyled?p:"cedros-theme__button cedros-theme__crypto",type:"button",children:te}),H&&!x&&t.jsx("div",{className:"cedros-modal-overlay",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:j.tokens.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"1rem"},onClick:()=>_(!1),children:t.jsxs("div",{className:"cedros-modal-content",style:{backgroundColor:j.tokens.modalBackground,borderRadius:"12px",padding:"2rem",maxWidth:"400px",width:"100%",boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",border:`1px solid ${j.tokens.modalBorder}`},onClick:w=>w.stopPropagation(),children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1.5rem"},children:[t.jsx("h3",{style:{margin:0,fontSize:"1.25rem",fontWeight:600,color:j.tokens.surfaceText},children:N("wallet.select_wallet")}),t.jsx("button",{onClick:()=>_(!1),style:a.getModalCloseButtonStyles(j.tokens.surfaceText),"aria-label":"Close modal",type:"button",children:"×"})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:L.map(w=>t.jsxs("button",{onClick:()=>xe(w.adapter.name),style:{width:"100%",padding:"1rem",backgroundColor:j.tokens.surfaceBackground,border:`1px solid ${j.tokens.surfaceBorder}`,borderRadius:"0.5rem",cursor:"pointer",fontSize:"1rem",textAlign:"left",color:j.tokens.surfaceText,display:"flex",alignItems:"center",gap:"1rem",transition:"all 0.2s ease"},onMouseEnter:W=>{W.currentTarget.style.backgroundColor=j.tokens.modalBackground,W.currentTarget.style.borderColor=j.tokens.surfaceText,W.currentTarget.style.transform="translateY(-2px)"},onMouseLeave:W=>{W.currentTarget.style.backgroundColor=j.tokens.surfaceBackground,W.currentTarget.style.borderColor=j.tokens.surfaceBorder,W.currentTarget.style.transform="translateY(0)"},type:"button",children:[t.jsx(Ee.WalletIcon,{wallet:w,style:{width:"24px",height:"24px"}}),t.jsx("span",{style:{fontWeight:500},children:w.adapter.name})]},w.adapter.name))})]})}),m&&!x&&!H&&t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"0.5rem",fontSize:"0.75rem",color:j.tokens.surfaceText,opacity:.7},children:[t.jsx("button",{onClick:Se,style:{background:"none",border:"none",padding:0,color:"inherit",textDecoration:"none",cursor:"pointer",fontSize:"inherit"},type:"button",children:N("wallet.change")}),t.jsx("button",{onClick:we,style:{background:"none",border:"none",padding:0,color:"inherit",textDecoration:"none",cursor:"pointer",fontSize:"inherit"},type:"button",children:N("ui.disconnect")})]}),!x&&U&&t.jsx("div",{className:j.unstyled?"":"cedros-theme__error",children:U}),!x&&J&&t.jsx("div",{className:j.unstyled?"":"cedros-theme__error",children:J}),!x&&ee&&t.jsx("div",{className:j.unstyled?"":"cedros-theme__success",children:N("ui.subscription_active")})]})}function ye(){const{subscriptionChangeManager:e}=h.useCedrosContext(),[s,r]=c.useState({status:"idle",error:null,subscription:null,changePreview:null}),i=c.useCallback(async(o,x)=>{r(d=>({...d,status:"loading",error:null}));try{const d=await e.getDetails(o,x);return r(m=>({...m,status:"success",subscription:d})),d}catch(d){const m=d instanceof Error?d.message:"Failed to load subscription";return r(n=>({...n,status:"error",error:m})),null}},[e]),g=c.useCallback(async(o,x,d,m)=>{r(n=>({...n,status:"loading",error:null}));try{const n={currentResource:o,newResource:x,userId:d,newInterval:m},l=await e.previewChange(n);return r(f=>({...f,status:"idle",changePreview:l})),l}catch(n){const l=n instanceof Error?n.message:"Failed to preview change";return r(f=>({...f,status:"error",error:l})),null}},[e]),u=c.useCallback(async o=>{const{subscription:x}=s;if(!x)return r(d=>({...d,status:"error",error:"No subscription loaded"})),null;r(d=>({...d,status:"loading",error:null}));try{const d={currentResource:x.resource,newResource:o.newResource,userId:x.id,newInterval:o.newInterval,prorationBehavior:o.prorationBehavior,immediate:o.immediate},m=await e.changeSubscription(d);return m.success?r(n=>({...n,status:"success",subscription:n.subscription?{...n.subscription,resource:m.newResource,interval:m.newInterval,status:m.status}:null,changePreview:null})):r(n=>({...n,status:"error",error:m.error||"Failed to change subscription"})),m}catch(d){const m=d instanceof Error?d.message:"Failed to change subscription";return r(n=>({...n,status:"error",error:m})),null}},[e,s.subscription]),S=c.useCallback(async o=>{const{subscription:x}=s;if(!x)return r(d=>({...d,status:"error",error:"No subscription loaded"})),null;r(d=>({...d,status:"loading",error:null}));try{const d={resource:x.resource,userId:x.id,immediate:o},m=await e.cancel(d);if(m.success){const n=o?"canceled":x.status;r(l=>({...l,status:"success",subscription:l.subscription?{...l.subscription,status:n,cancelAtPeriodEnd:!o}:null}))}else r(n=>({...n,status:"error",error:m.error||"Failed to cancel subscription"}));return m}catch(d){const m=d instanceof Error?d.message:"Failed to cancel subscription";return r(n=>({...n,status:"error",error:m})),null}},[e,s.subscription]),E=c.useCallback(async(o,x)=>{r(d=>({...d,status:"loading",error:null}));try{const d=await e.getBillingPortalUrl({userId:o,returnUrl:x});return window.location.href=d.url,d}catch(d){const m=d instanceof Error?d.message:"Failed to open billing portal";return r(n=>({...n,status:"error",error:m})),null}},[e]),y=c.useCallback(()=>{r(o=>({...o,changePreview:null}))},[]),p=c.useCallback(()=>{r({status:"idle",error:null,subscription:null,changePreview:null})},[]);return{...s,loadSubscription:i,previewChange:g,changeSubscription:u,cancelSubscription:S,openBillingPortal:E,clearPreview:y,reset:p}}const C={container:{padding:"24px",backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e5e7eb",fontFamily:"system-ui, -apple-system, sans-serif"},error:{padding:"12px 16px",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",marginBottom:"16px"},loading:{padding:"24px",textAlign:"center",color:"#6b7280"},details:{marginBottom:"24px"},title:{margin:"0 0 16px 0",fontSize:"18px",fontWeight:600,color:"#111827"},detailRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 0",borderBottom:"1px solid #f3f4f6"},label:{color:"#6b7280",fontSize:"14px"},value:{color:"#111827",fontSize:"14px",fontWeight:500},statusBadge:{padding:"4px 8px",borderRadius:"4px",color:"#fff",fontSize:"12px",fontWeight:500,textTransform:"capitalize"},cancelNotice:{marginTop:"12px",padding:"8px 12px",backgroundColor:"#fef3c7",border:"1px solid #fcd34d",borderRadius:"6px",color:"#92400e",fontSize:"13px"},prorationPreview:{padding:"16px",backgroundColor:"#f9fafb",borderRadius:"8px",marginBottom:"24px"},previewTitle:{margin:"0 0 12px 0",fontSize:"16px",fontWeight:600,color:"#111827"},previewDetails:{marginBottom:"16px"},previewRow:{display:"flex",justifyContent:"space-between",padding:"6px 0",fontSize:"14px",color:"#4b5563"},previewTotal:{borderTop:"1px solid #e5e7eb",marginTop:"8px",paddingTop:"12px",fontWeight:600,color:"#111827"},previewActions:{display:"flex",gap:"12px",justifyContent:"flex-end"},cancelButton:{padding:"8px 16px",backgroundColor:"#fff",border:"1px solid #d1d5db",borderRadius:"6px",color:"#374151",cursor:"pointer",fontSize:"14px"},confirmButton:{padding:"8px 16px",backgroundColor:"#3b82f6",border:"none",borderRadius:"6px",color:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:500},plansSection:{marginBottom:"24px"},plansTitle:{margin:"0 0 12px 0",fontSize:"16px",fontWeight:600,color:"#111827"},plansList:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"16px"},planCard:{padding:"16px",backgroundColor:"#fff",border:"1px solid #e5e7eb",borderRadius:"8px",textAlign:"center"},currentPlan:{borderColor:"#3b82f6",backgroundColor:"#eff6ff"},planName:{fontSize:"16px",fontWeight:600,color:"#111827",marginBottom:"4px"},planPrice:{fontSize:"14px",color:"#6b7280",marginBottom:"8px"},planDescription:{fontSize:"12px",color:"#9ca3af",marginBottom:"12px"},currentBadge:{display:"inline-block",padding:"4px 8px",backgroundColor:"#3b82f6",color:"#fff",borderRadius:"4px",fontSize:"12px",fontWeight:500},changePlanButton:{padding:"8px 16px",backgroundColor:"#f3f4f6",border:"1px solid #d1d5db",borderRadius:"6px",color:"#374151",cursor:"pointer",fontSize:"14px",width:"100%"},actions:{display:"flex",gap:"12px",justifyContent:"flex-end",paddingTop:"16px",borderTop:"1px solid #e5e7eb"},portalButton:{padding:"10px 20px",backgroundColor:"#3b82f6",border:"none",borderRadius:"6px",color:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:500},cancelSubscriptionButton:{padding:"10px 20px",backgroundColor:"#fff",border:"1px solid #ef4444",borderRadius:"6px",color:"#ef4444",cursor:"pointer",fontSize:"14px"}};function K(e,s){return new Intl.NumberFormat("en-US",{style:"currency",currency:s.toUpperCase()}).format(e/100)}function be(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}function Ne(e){switch(e){case"active":return"#22c55e";case"trialing":return"#3b82f6";case"past_due":return"#f59e0b";case"canceled":case"expired":return"#ef4444";default:return"#6b7280"}}function Le({preview:e,onConfirm:s,onCancel:r,isLoading:i}){const g=e.immediateAmount<0;return t.jsxs("div",{className:"cedros-proration-preview",style:C.prorationPreview,children:[t.jsx("h4",{style:C.previewTitle,children:"Change Preview"}),t.jsxs("div",{style:C.previewDetails,children:[t.jsxs("div",{style:C.previewRow,children:[t.jsx("span",{children:"Current plan:"}),t.jsxs("span",{children:[K(e.currentPlanPrice,e.currency),"/period"]})]}),t.jsxs("div",{style:C.previewRow,children:[t.jsx("span",{children:"New plan:"}),t.jsxs("span",{children:[K(e.newPlanPrice,e.currency),"/period"]})]}),t.jsxs("div",{style:C.previewRow,children:[t.jsx("span",{children:"Days remaining:"}),t.jsxs("span",{children:[e.daysRemaining," days"]})]}),e.prorationDetails&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:C.previewRow,children:[t.jsx("span",{children:"Unused credit:"}),t.jsxs("span",{children:["-",K(e.prorationDetails.unusedCredit,e.currency)]})]}),t.jsxs("div",{style:C.previewRow,children:[t.jsx("span",{children:"New plan cost:"}),t.jsx("span",{children:K(e.prorationDetails.newPlanCost,e.currency)})]})]}),t.jsxs("div",{style:{...C.previewRow,...C.previewTotal},children:[t.jsx("span",{children:g?"Credit to account:":"Amount due now:"}),t.jsx("span",{style:{color:g?"#22c55e":"#ef4444"},children:K(Math.abs(e.immediateAmount),e.currency)})]}),t.jsxs("div",{style:C.previewRow,children:[t.jsx("span",{children:"Effective date:"}),t.jsx("span",{children:be(e.effectiveDate)})]})]}),t.jsxs("div",{style:C.previewActions,children:[t.jsx("button",{onClick:r,style:C.cancelButton,disabled:i,children:"Cancel"}),t.jsx("button",{onClick:s,style:C.confirmButton,disabled:i,children:i?"Processing...":"Confirm Change"})]})]})}function We({resource:e,userId:s,availablePlans:r=[],onSubscriptionChanged:i,onSubscriptionCanceled:g,billingPortalReturnUrl:u,showBillingPortal:S=!1,className:E,style:y}){const{subscription:p,changePreview:o,status:x,error:d,loadSubscription:m,previewChange:n,changeSubscription:l,cancelSubscription:f,openBillingPortal:P,clearPreview:k}=ye();c.useEffect(()=>{m(e,s)},[e,s,m]);const b=c.useCallback(async(v,T)=>{await n(e,v,s,T)},[e,s,n]),I=c.useCallback(async()=>{if(!o)return;const v=r.find(q=>q.price===o.newPlanPrice&&q.currency===o.currency);(await l({newResource:v?.resource||e,newInterval:v?.interval,immediate:!0}))?.success&&v&&i?.(v.resource,v.interval)},[o,r,e,l,i]),B=c.useCallback(async v=>{(await f(v))?.success&&g?.()},[f,g]),R=c.useCallback(()=>{P(s,u)},[s,u,P]),M=x==="loading";return t.jsxs("div",{className:`cedros-subscription-panel ${E||""}`,style:{...C.container,...y},children:[d&&t.jsx("div",{className:"cedros-subscription-error",style:C.error,children:d}),M&&!p&&t.jsx("div",{className:"cedros-subscription-loading",style:C.loading,children:"Loading subscription..."}),p&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"cedros-subscription-details",style:C.details,children:[t.jsx("h3",{style:C.title,children:"Current Subscription"}),t.jsxs("div",{style:C.detailRow,children:[t.jsx("span",{style:C.label,children:"Plan:"}),t.jsx("span",{style:C.value,children:p.resource})]}),t.jsxs("div",{style:C.detailRow,children:[t.jsx("span",{style:C.label,children:"Status:"}),t.jsx("span",{style:{...C.statusBadge,backgroundColor:Ne(p.status)},children:p.status})]}),t.jsxs("div",{style:C.detailRow,children:[t.jsx("span",{style:C.label,children:"Price:"}),t.jsxs("span",{style:C.value,children:[K(p.pricePerPeriod,p.currency),"/",p.interval]})]}),t.jsxs("div",{style:C.detailRow,children:[t.jsx("span",{style:C.label,children:"Current period ends:"}),t.jsx("span",{style:C.value,children:be(p.currentPeriodEnd)})]}),p.cancelAtPeriodEnd&&t.jsx("div",{style:C.cancelNotice,children:"Subscription will cancel at end of current period"})]}),o&&t.jsx(Le,{preview:o,onConfirm:I,onCancel:k,isLoading:M}),r.length>0&&!o&&t.jsxs("div",{className:"cedros-available-plans",style:C.plansSection,children:[t.jsx("h4",{style:C.plansTitle,children:"Available Plans"}),t.jsx("div",{style:C.plansList,children:r.map(v=>{const T=v.resource===p.resource;return t.jsxs("div",{style:{...C.planCard,...T?C.currentPlan:{}},children:[t.jsx("div",{style:C.planName,children:v.name}),t.jsxs("div",{style:C.planPrice,children:[K(v.price,v.currency),"/",v.interval]}),v.description&&t.jsx("div",{style:C.planDescription,children:v.description}),T?t.jsx("span",{style:C.currentBadge,children:"Current Plan"}):t.jsx("button",{onClick:()=>b(v.resource,v.interval),style:C.changePlanButton,disabled:M,children:v.price>p.pricePerPeriod?"Upgrade":"Downgrade"})]},v.resource)})})]}),t.jsxs("div",{className:"cedros-subscription-actions",style:C.actions,children:[S&&p.paymentMethod==="stripe"&&t.jsx("button",{onClick:R,style:C.portalButton,disabled:M,children:"Manage Billing"}),p.status==="active"&&!p.cancelAtPeriodEnd&&t.jsx("button",{onClick:()=>B(!1),style:C.cancelSubscriptionButton,disabled:M,children:"Cancel Subscription"})]})]})]})}function Ae(){const{x402Manager:e,walletManager:s}=h.useCedrosContext(),{publicKey:r,signTransaction:i}=V.useWallet(),[g,u]=c.useState({status:"idle",error:null,transactionId:null}),[S,E]=c.useState(null),[y,p]=c.useState(null),o=c.useCallback(async n=>{try{u(f=>({...f,status:"loading"}));const l=await e.requestQuote({resource:n});if(!e.validateRequirement(l))throw new Error("Invalid refund requirement received from server");return E(l),u(f=>({...f,status:"idle"})),l}catch(l){const f=h.formatError(l,"Failed to fetch refund requirement");throw u({status:"error",error:f,transactionId:null}),l}},[e]),x=c.useCallback(async(n,l)=>{if(!r||!i)throw new Error("Wallet not connected");try{u({status:"loading",error:null,transactionId:null});const f=await e.requestQuote({resource:n,couponCode:l});if(!e.validateRequirement(f))throw new Error("Invalid refund requirement received");E(f);const P=await s.buildTransaction({requirement:f,payerPublicKey:r}),k=await s.signTransaction({transaction:P,signTransaction:i}),b=s.buildPaymentPayload({requirement:f,signedTx:k,payerPublicKey:r}),I=await e.submitPayment({resource:n,payload:b,couponCode:l,metadata:void 0,resourceType:"refund"});return I.settlement&&p(I.settlement),u({status:"success",error:null,transactionId:I.transactionId||k.signature}),I}catch(f){const P=h.formatError(f,"Refund payment failed");throw u({status:"error",error:P,transactionId:null}),f}},[r,i,e,s]),d=c.useCallback(async n=>{if(!r||!i)throw new Error("Wallet not connected");try{u({status:"loading",error:null,transactionId:null});const l=await e.requestQuote({resource:n});if(!e.validateRequirement(l))throw new Error("Invalid refund requirement received");E(l);const{transaction:f}=await e.buildGaslessTransaction({resourceId:n,userWallet:r.toString(),feePayer:l.extra.feePayer}),P=s.deserializeTransaction(f),k=await s.partiallySignTransaction({transaction:P,signTransaction:i}),b=await e.submitGaslessTransaction({resource:n,partialTx:k,couponCode:void 0,metadata:void 0,resourceType:"refund",requirement:l});return b.settlement&&p(b.settlement),u({status:"success",error:null,transactionId:b.transactionId||"gasless-refund-tx"}),b}catch(l){const f=h.formatError(l,"Gasless refund payment failed");throw u({status:"error",error:f,transactionId:null}),l}},[r,i,e,s]),m=c.useCallback(()=>{u({status:"idle",error:null,transactionId:null}),E(null),p(null)},[]);return{state:g,requirement:S,settlement:y,fetchRefundQuote:o,processRefund:x,processGaslessRefund:d,reset:m}}function qe(){if(typeof window>"u")return{passed:!0,severity:"info",message:"HTTPS check skipped (SSR environment)"};const e=window.location.protocol==="https:",s=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1";return e||s?{passed:!0,severity:"info",message:"HTTPS enforced"}:{passed:!1,severity:"error",message:"Page not served over HTTPS",recommendation:"Enable HTTPS for all payment pages. Stripe.js requires HTTPS in production."}}function De(){return typeof document>"u"?{passed:!0,severity:"info",message:"CSP check skipped (SSR environment)"}:document.querySelector('meta[http-equiv="Content-Security-Policy"]')?{passed:!0,severity:"info",message:"Content Security Policy detected"}:{passed:!1,severity:"warning",message:"No Content Security Policy detected",recommendation:"Configure CSP headers to protect against XSS and CDN compromise. Use generateCSP() helper from @cedros/pay-react."}}function ze(){return process.env.NODE_ENV==="development"||typeof window<"u"&&window.location.hostname==="localhost"?{passed:!0,severity:"info",message:"Running in development mode (some security checks relaxed)"}:{passed:!0,severity:"info",message:"Running in production mode"}}function Oe(){return{passed:!0,severity:"info",message:"Stripe.js loaded via @stripe/stripe-js package (CSP recommended, not SRI)",recommendation:"Ensure CSP script-src includes https://js.stripe.com"}}function $e(){return typeof window>"u"?{passed:!0,severity:"info",message:"Mixed content check skipped (SSR environment)"}:window.location.protocol==="https:"?{passed:!0,severity:"info",message:"Mixed content protection active (HTTPS page)"}:{passed:!0,severity:"info",message:"Mixed content check skipped (HTTP page)"}}function Ue(){const e=[qe(),De(),ze(),Oe(),$e()],s=e.some(u=>u.severity==="error"&&!u.passed),r=e.some(u=>u.severity==="warning"&&!u.passed);let i,g;return s?(i="vulnerable",g="Security issues detected. Review errors and apply recommendations."):r?(i="warnings",g="Minor security warnings detected. Consider applying recommendations."):(i="secure",g="All security checks passed."),{checks:e,overallStatus:i,summary:g}}function Fe(e){process.env.NODE_ENV!=="production"&&(console.group("🔒 Cedros Pay Security Report"),console.log(`Status: ${e.overallStatus.toUpperCase()}`),console.log(`Summary: ${e.summary}`),console.log(""),e.checks.forEach(s=>{const r=s.passed?"✅":s.severity==="error"?"❌":"⚠️";console.log(`${r} ${s.message}`),s.recommendation&&console.log(` → ${s.recommendation}`)}),console.groupEnd())}const He={CSP:"Use generateCSP() from @cedros/pay-react to generate Content Security Policy headers",HTTPS:"Always serve payment pages over HTTPS in production",PACKAGE_UPDATES:"Keep @stripe/stripe-js and @cedros/pay-react updated for security patches",AUDIT:"Run npm audit regularly to check for known vulnerabilities",MONITORING:"Monitor Stripe security advisories and apply updates promptly",NO_SRI:"Do NOT use SRI hashes for Stripe.js - use CSP instead"};exports.CEDROS_EVENTS=a.CEDROS_EVENTS;exports.CryptoButton=a.CryptoButton;exports.ERROR_CATEGORIES=a.ERROR_CATEGORIES;exports.PaymentMethodBadge=a.PaymentMethodBadge;exports.PaymentModal=a.PaymentModal;exports.ProductPrice=a.ProductPrice;exports.StripeButton=a.StripeButton;exports.calculateDiscountPercentage=a.calculateDiscountPercentage;exports.createTranslator=a.createTranslator;exports.detectLocale=a.detectLocale;exports.emitPaymentError=a.emitPaymentError;exports.emitPaymentProcessing=a.emitPaymentProcessing;exports.emitPaymentStart=a.emitPaymentStart;exports.emitPaymentSuccess=a.emitPaymentSuccess;exports.emitWalletConnect=a.emitWalletConnect;exports.emitWalletConnected=a.emitWalletConnected;exports.emitWalletError=a.emitWalletError;exports.formatCouponCodes=a.formatCouponCodes;exports.getAvailableLocales=a.getAvailableLocales;exports.getLocalizedError=a.getLocalizedError;exports.getUserErrorMessage=a.getUserErrorMessage;exports.isRetryableError=a.isRetryableError;exports.loadLocale=a.loadLocale;exports.parseCouponCodes=a.parseCouponCodes;exports.parseStructuredErrorResponse=a.parseErrorResponse;exports.stackCheckoutCoupons=a.stackCheckoutCoupons;exports.useLocalizedError=a.useLocalizedError;exports.usePaymentMode=a.usePaymentMode;exports.useStripeCheckout=a.useStripeCheckout;exports.useTranslation=a.useTranslation;exports.useX402Payment=a.useX402Payment;exports.CIRCUIT_BREAKER_PRESETS=h.CIRCUIT_BREAKER_PRESETS;exports.CedrosProvider=h.CedrosProvider;exports.CircuitBreakerOpenError=h.CircuitBreakerOpenError;exports.CircuitState=h.CircuitState;exports.LogLevel=h.LogLevel;exports.Logger=h.Logger;exports.RATE_LIMITER_PRESETS=h.RATE_LIMITER_PRESETS;exports.RETRY_PRESETS=h.RETRY_PRESETS;exports.WalletPool=h.WalletPool;exports.createCircuitBreaker=h.createCircuitBreaker;exports.createLogger=h.createLogger;exports.createRateLimiter=h.createRateLimiter;exports.createWalletPool=h.createWalletPool;exports.getLogger=h.getLogger;exports.retryWithBackoff=h.retryWithBackoff;exports.useCedrosContext=h.useCedrosContext;exports.useCedrosTheme=h.useCedrosTheme;exports.validateConfig=h.validateConfig;exports.CSP_PRESETS=Me;exports.CedrosPay=Ie;exports.CryptoSubscribeButton=_e;exports.PurchaseButton=me;exports.RPC_PROVIDERS=je;exports.SECURITY_RECOMMENDATIONS=He;exports.SubscribeButton=Be;exports.SubscriptionManagementPanel=We;exports.formatCSP=pe;exports.generateCSP=Re;exports.generateCSPDirectives=de;exports.logSecurityReport=Fe;exports.useCryptoSubscription=ge;exports.useRefundVerification=Ae;exports.useSubscription=fe;exports.useSubscriptionManagement=ye;exports.validateSecurity=Ue;